From nobody Sat Jun 13 20:22:40 2026 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 124F226E6F2 for ; Tue, 5 May 2026 15:12:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777993936; cv=none; b=TAcgwHbTB71vJYs4iyoSyLDRUzZ93pn3WU31ASPci6aYGgoqSMKcfF9Mv7FUViXAupBbv3z7zvOxtPyD3/zw8y7KeYcr1vq74ulwpvxBMsxZBs1q6A9gJaRTE38ahrAftI2AwmwyZ7Z4wMqJuAwDE61XLUI4CphK9S/ONi7SED0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777993936; c=relaxed/simple; bh=/ih9zlmnEQrNMidQ4ym8DN5CLFEQAFGacWY5osP8xC4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=dHmXvgBeOZXXsiHykEcq3xKtq3TKqaZp8Qt/PHi4qENrrmMdyoNKGusPWq0OEaDxF08824wHnNKj1IZWDuBC4J2xTRrAeeCd2vj38HiNfWZ1iYzZM/rVPnUSDecJX4iQl8Qt2VH0hG3yWFI+ogTWWcrfytai4EpNqFVZFHhhSQI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UJaaABUj; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UJaaABUj" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-356337f058aso3531398a91.2 for ; Tue, 05 May 2026 08:12:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777993934; x=1778598734; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gSVwTF8m3rRaZ++YUTtbkD8+x2rBBhsBLL8WFFIRcaw=; b=UJaaABUj27O0WMYaclnlQ5mGYwBX+wBwFlscplafTdVznYr+Msy4t8P9y4e7gOPYfx p07SL/gHcFpRHpE93H/jIOyU8giX3FVPCCbUos2IvGqq3flFXpz25BPYBWw41UjTJ0U1 fyyk8EnQF3jLnEHppC6f3svg+7J9p/ucAZFyxdo2gX9ziLxBl3utQoe6THY/hlpf+Q4f IAHIBQ9YxC0WW8Qpteho4ht2Z8F8sjpRUcTBoKQ/hAvrYoAXZoJcpJ2C/znUlM2GAMjd 4Hvek2XstKMJ+IORj3D4OxPeBU44hj5ltgYuZmivjGzky4H3YOXibLHBuqk3SkZIEFOe uBkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777993934; x=1778598734; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=gSVwTF8m3rRaZ++YUTtbkD8+x2rBBhsBLL8WFFIRcaw=; b=Tob/TNjsouumWYMr47JHg/7tekHENJXiR285K0EycO44IJiI2FunY+S9qKPE+4MGWd oABcUoCsOhWbqnNwxw1uR8sV1DOpfWJ+H6pkpU+uyvWDZUwnxpGNiieWOufrJ7qKPA72 +qAfAiAaG8P78N4GRSKgwlrlLolvqN5BGVuoq0ufczeodw7IWvTmnZlHpifa++iqp3Qd N5XiwCzRZ+4wXItzwBRZp5ZLRijG3B7e6zeLzpVp/gW/9srszchapLb99Yvv1TfBoHnX FsaikzXeKqitB5UjAygKeBRISTLb9+W5MzEtTNHsQWFWTe3IRTpTJBlLew6rYrD9b4c9 s2PQ== X-Forwarded-Encrypted: i=1; AFNElJ8egXLwHwhB6eVt7eWjzflwfi6IvTRwG9UtFzhzfeA9Nk2JcBD6WuWcvYikNy9bBpJVCsXwSR+HVD17BVI=@vger.kernel.org X-Gm-Message-State: AOJu0YzjIbv99vhh6eHK0Ul0i0Tms+kht8Q7d+TwVlWc+sgE4RjbHW6H /Y4sGFlfDqgqAIQivJ4Gs0w7ES5cHRQ/ich0Y7xAdQiwNDCUDBWt0IR8 X-Gm-Gg: AeBDiesYtsyFMd6YQmT5k+VwO5WH7g4+L1hzxTle6P2enf6ausBogZfepY1lSN+l6dt OcmAchG8QE/ijMpM9jFqPnN74p1wGr5mmZ2R464mXoa0N5WvQbSGVe53WWVvN6WP+LoVhle+Lfr UfjbMsMft6+f5oFTBx3zECEpx9kNEx51Qt8pqKRskccgjh7A/CGjh9ZA7wcJsJ6U+rDNGtReV/k WqkeoU6yDveGlG8rVuyLwwh5lw3SmCcZ3SWP4avPKhcrF5BlwmGW5rGE9SBoq4BMa7eTdJ1ewZ7 BDHqhYRKHcU4ExUpmty+NM5pYgkqx4Ue/eRJ4WYYeeBhjDMNXRTCVoSh2SoPnqBk5Dh8IChzxpd E/7eZbI0gvrjeI3RXVPc6VEisSekV2A2rbTkJTXTE8Sr1IZLe5tYJiuqkGAXo9a/FZLwidFdSul cd+JoqqSGdNgc3ZcKBzekQFuL+2vL6 X-Received: by 2002:a17:90b:390c:b0:35f:b647:d98a with SMTP id 98e67ed59e1d1-3650cd715cbmr14699839a91.5.1777993934247; Tue, 05 May 2026 08:12:14 -0700 (PDT) Received: from localhost ([111.228.63.84]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b9caa7ebc6sm142808665ad.5.2026.05.05.08.12.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2026 08:12:13 -0700 (PDT) From: Cen Zhang To: shaggy@kernel.org Cc: gregkh@linuxfoundation.org, jfs-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org, baijiaju1990@gmail.com, Cen Zhang Subject: [PATCH] jfs: wait for log read completion under lcache lock Date: Tue, 5 May 2026 23:11:58 +0800 Message-Id: <20260505151158.1727174-1-zzzccc427@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" lbmRead() waits for read I/O completion by testing l_flag with an unlocked wait_event() condition. The completion path updates l_flag under the JFS lcache lock and sets lbmDONE before it clears lbmREAD, leaving a transient lbmREAD | lbmDONE state. The existing condition only checks that l_flag is no longer exactly lbmREAD. It can therefore treat that transient state as completion and return while lbmIODone() is still handling the same buffer. Callers may then reuse the lbuf before the read completion has cleared lbmREAD. Wait for the real read-completion condition, lbmREAD being clear, and use the existing lcache wait helper so the condition is evaluated under the same lock as the completion update. Signed-off-by: Cen Zhang --- fs/jfs/jfs_logmgr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c index ada00d5bc214..a09b979b4224 100644 --- a/fs/jfs/jfs_logmgr.c +++ b/fs/jfs/jfs_logmgr.c @@ -1962,6 +1962,7 @@ static int lbmRead(struct jfs_log * log, int pn, stru= ct lbuf ** bpp) { struct bio *bio; struct lbuf *bp; + unsigned long flags; =20 /* * allocate a log buffer @@ -1986,7 +1987,9 @@ static int lbmRead(struct jfs_log * log, int pn, stru= ct lbuf ** bpp) submit_bio(bio); } =20 - wait_event(bp->l_ioevent, (bp->l_flag !=3D lbmREAD)); + LCACHE_LOCK(flags); + LCACHE_SLEEP_COND(bp->l_ioevent, !(bp->l_flag & lbmREAD), flags); + LCACHE_UNLOCK(flags); =20 return 0; }