From nobody Sat Jun 13 20:56:13 2026 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 26F1B429811 for ; Tue, 5 May 2026 12:33:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777984416; cv=none; b=f2IFMe7iDcaU6Qyhza/Gbq9RRhyz7296jy2j49H94jUJfyuKJEmCcV0bB0Yak1Sm/6959Y8zIspCCX4vkPgNVUbpUjSbRF5t56yPF7jttpQ88RbIElnek+gfs4fFil+bDZ/YlYH2JJJsIN+8I7wVaaJf4IMFMZH0+YwjTLKSWC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777984416; c=relaxed/simple; bh=TLIH/Tgx3dg9i1TNN4EsgmGal4HuOLfx7/7fIa8ct+k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=crgjMHQhO7cGE+TIQ6pQeZKtkH9u6sP0B6gjN4X8alJLiPhpil46kq8uB7DwIs68mdx3SjT3OVUd9zjvAm7BTilmPhFTKBgocKlNmGtnp3flwuqd8wPd2DwjVk54/PDmXA/l/IzRoeFxTMNFgZRlNPKNKeMj41B4ec1gpmu2yns= 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=U8WQEN6y; arc=none smtp.client-ip=209.85.128.44 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="U8WQEN6y" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4891e5b9c1fso50042155e9.2 for ; Tue, 05 May 2026 05:33:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777984413; x=1778589213; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K2WNU8nICgt72CKBqTTHtMF4K06yXBKs3UcZ/HI1eik=; b=U8WQEN6ytTntXP/0KyTyQf+3O17R5hg8UnF3SS1MqIM9k05SBLctBUA92sy9gLOgDX xDUFvr1sLsXWjWkOhRCsEXYn00KA0XdF4P/iqfFVCLv4i9KgyZi8lIS6zNRJgJMbjXcS zsPmACh+8CGgcfPGVm8oMzMuA28AWI44s437b/rFX/0OJhkytrmUBaEXbNGvWyzqaSWk CuWHcctI6DF4rdZpcwRpSzzHexL0Hq5RQbTjWHwKpxBlOvkzycGXXjcSJ8oU1Fb2I2h+ UtyJNpwoj7tr9xCZPCA7WzLJ+IaNLCMOC+ms1H1OcJIhVXFv17eN3/vnoir5962zlbUE RsHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777984413; x=1778589213; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=K2WNU8nICgt72CKBqTTHtMF4K06yXBKs3UcZ/HI1eik=; b=B/Msxmied/qcWfrSepdXYccufZFFT+DAAw35M2gTbo6Oe1AL933VOe99cGJFLAKlug dI/kYyOgYYWV+jj0feZ5lUU2zqZMB9dfCu+1L5n757Qi2G+j1Ln5y7NPyZZl/VV3JpEM y0u/jFhi6IOA/ksZfU7oj1jmlSfsQyG9m9JpcIN7QEl/9zy+nVQVwUy8hcNvqajNwA0R mMz+RTu/cAtWbrIN7g5KIxbU3M8dA7imZ3vkdXsJWcewQxtZqIIan1n29VpFs6tZqFBG n11HgpBELlDs6FR3jg12g4SqA2I9bwPW1xkFbNDT/vmDIf2LKwvZXsBrg+pkZGac+gyS VZaQ== X-Forwarded-Encrypted: i=1; AFNElJ/6uYATakQZXuzNCAnvvbY6b3aCTSGAiUKboYdCEYqxaktxUj8NaonKTz6/rykbTh8PtXpc9BQy415P6wg=@vger.kernel.org X-Gm-Message-State: AOJu0Yxyuc+ReROr4RcMFhaVtQ8r/y4PY72NfCmdDXX9D1L1NcwTwZzk KtqwKjcIfu3VuduOehHXgm3rxQv1wjFnnxb+h6pP9eG/GP/lGUUT8fM= X-Gm-Gg: AeBDiesr3KCgk13PI9+piTonlsLx+rp1zgcyw1kPH1zvlDyzpqUQw5cc99w/IPdEZ2P 85Mp6DT+Ibp/bKY+AGrxshmgGXxmqY3imaHvAIFS0D4f5o3Gz4Otv8k0EtzXNQeMfw7g2pytq+S h24AwXQj12zpiYwRqhOQJJWG7E+X/7BO0RvKF0KC6SLn1dT34HcmRUBIWuPpRnSRA1Osqznw4Go A3mQeBdML4pzlf/JNHUeECjxCmtADvmBZkZgRxMiY7EoYk7HiOsr9ncAqdhqXjdiDC7rHDCvHsK Tavuk9iy4cGnzI0ASGCNKMNiGl4S7J+VHXR9fhwJgvqgWIZSwcfA0wvZuzRQ4YUV3uU6A1OccTO DE9i942BB9YPu6l81dbv6cI23qy629hWlclqZXzSkmfnpI9CXd9t5J+0x01rW+wSq4dJW3KQtpp /3Z74d21NlWmgVkw== X-Received: by 2002:a05:600c:a11:b0:487:12c:e7e1 with SMTP id 5b1f17b1804b1-48d187d95d2mr49896755e9.11.1777984412421; Tue, 05 May 2026 05:33:32 -0700 (PDT) Received: from debian.. ([2001:41d0:303:db6b::]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a822bf3ffsm431044285e9.7.2026.05.05.05.33.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2026 05:33:31 -0700 (PDT) From: Tristan Madani To: Dave Kleikamp Cc: jfs-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org, syzbot+c244f4a09ca85dd2ebc1@syzkaller.appspotmail.com, syzbot+885a4f3281b8d99c48d8@syzkaller.appspotmail.com, stable@vger.kernel.org, Tristan Madani Subject: [PATCH v2 1/2] jfs: drain lazy commit queue during unmount to prevent use-after-free Date: Tue, 5 May 2026 12:33:29 +0000 Message-ID: <20260505123330.2822833-2-tristmd@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260505123330.2822833-1-tristmd@gmail.com> References: <20260501110236.43226-1-tristmd@gmail.com> <20260505123330.2822833-1-tristmd@gmail.com> 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" From: Tristan Madani The jfsCommit kernel thread processes committed transactions from TxAnchor.unlock_queue via jfs_lazycommit(). During filesystem unmount, jfs_umount() calls jfs_flush_journal(log, 2) which waits for the log commit queue (log->cqueue) to drain. However, after log I/O completes, lazy transactions are moved to TxAnchor.unlock_queue for asynchronous processing by jfsCommit. If jfs_umount() proceeds to free the jfs_log (via lmLogClose) or jfs_sb_info (via kfree in jfs_put_super) while entries referencing this superblock remain on unlock_queue, the jfsCommit thread will access freed memory when it later processes these entries: - jfs_lazycommit reads sbi->commit_state (UAF of jfs_sb_info) - txLazyCommit accesses JFS_SBI(tblk->sb)->log and takes log->gclock (UAF of jfs_log) Add txLazyDrain() which waits for all entries in TxAnchor.unlock_queue belonging to the unmounting superblock to be processed, and also waits for any in-flight txLazyCommit (IN_LAZYCOMMIT) for this superblock to complete. Call it from both jfs_umount() and jfs_umount_rw() after jfs_flush_journal(). Reported-by: syzbot+c244f4a09ca85dd2ebc1@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3Dc244f4a09ca85dd2ebc1 Tested-by: syzbot+c244f4a09ca85dd2ebc1@syzkaller.appspotmail.com Reported-by: syzbot+885a4f3281b8d99c48d8@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D885a4f3281b8d99c48d8 Tested-by: syzbot+885a4f3281b8d99c48d8@syzkaller.appspotmail.com Fixes: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Tristan Madani --- fs/jfs/jfs_txnmgr.c | 35 +++++++++++++++++++++++++++++++++++ fs/jfs/jfs_txnmgr.h | 1 + fs/jfs/jfs_umount.c | 8 ++++++++ 3 files changed, 44 insertions(+) diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c index 083dbbb0c3268..67a9908b5a4d9 100644 --- a/fs/jfs/jfs_txnmgr.c +++ b/fs/jfs/jfs_txnmgr.c @@ -2791,6 +2791,41 @@ void txLazyUnlock(struct tblock * tblk) LAZY_UNLOCK(flags); } =20 + +/* + * txLazyDrain + * + * Wait for all pending lazy commit entries for this superblock + * to be processed by the jfsCommit thread. Must be called + * before freeing per-filesystem structures during unmount. + */ +void txLazyDrain(struct super_block *sb) +{ + struct jfs_sb_info *sbi =3D JFS_SBI(sb); + struct tblock *tblk; + unsigned long flags; + bool found; + + do { + found =3D false; + LAZY_LOCK(flags); + list_for_each_entry(tblk, &TxAnchor.unlock_queue, cqueue) { + if (tblk->sb =3D=3D sb) { + found =3D true; + break; + } + } + if (!found && (sbi->commit_state & IN_LAZYCOMMIT)) + found =3D true; + LAZY_UNLOCK(flags); + + if (found) { + wake_up(&jfs_commit_thread_wait); + schedule_timeout_uninterruptible(1); + } + } while (found); +} + static void LogSyncRelease(struct metapage * mp) { struct jfs_log *log =3D mp->log; diff --git a/fs/jfs/jfs_txnmgr.h b/fs/jfs/jfs_txnmgr.h index ba71eb5ced567..80ce468eadde0 100644 --- a/fs/jfs/jfs_txnmgr.h +++ b/fs/jfs/jfs_txnmgr.h @@ -291,6 +291,7 @@ extern void txFreelock(struct inode *); extern int lmLog(struct jfs_log *, struct tblock *, struct lrd *, struct tlock *); extern void txQuiesce(struct super_block *); +extern void txLazyDrain(struct super_block *sb); extern void txResume(struct super_block *); extern void txLazyUnlock(struct tblock *); extern int jfs_lazycommit(void *); diff --git a/fs/jfs/jfs_umount.c b/fs/jfs/jfs_umount.c index 18569f1eaabdb..657707361be2a 100644 --- a/fs/jfs/jfs_umount.c +++ b/fs/jfs/jfs_umount.c @@ -58,6 +58,13 @@ int jfs_umount(struct super_block *sb) */ jfs_flush_journal(log, 2); =20 + /* + * Drain any pending lazy commit entries for this filesystem so + * the jfsCommit thread does not access freed structures. + */ + if (log) + txLazyDrain(sb); + /* * Hold log lock so write_special_inodes (lmLogSync) cannot see * this sbi with a NULL inode pointer while iterating log->sb_list. @@ -142,6 +149,7 @@ int jfs_umount_rw(struct super_block *sb) * remove file system from log active file system list. */ jfs_flush_journal(log, 2); + txLazyDrain(sb); =20 /* * Make sure all metadata makes it to disk --=20 2.47.3 From nobody Sat Jun 13 20:56:13 2026 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 0B00342B75A for ; Tue, 5 May 2026 12:33:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777984416; cv=none; b=Acc+kbTQWak/wWYWr1uvKyM7/Uo8d4DK+q6PBE/2F2ArZ/AWZX8JQtuFwnUtyo8W3SObPI++Qqg/lTN1aa5VZAdV2+KxIKmq0/J4Y+IbCZfMAkb6WETc7e08ocESV8vSU2YEY34eJhhzw2TcgG5CEMiRqeKWZgPW9Av463TnS6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777984416; c=relaxed/simple; bh=Z3ON3mFU82KZ4ejixTSR3VCbT6rBl8vXb8mMuYvWmVc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aawpk7ZGZ4hkt833nJ9s4RQ8YJ+uzDje1pgaUGXlt1NRfhSzm+H7Blg2vD2lW4Deknwd29bEbMCA+NQqZfxghYl6eZb3FFtoPdPoTctO06QCv/Dgfhd+zqXD45IulkZ/6McPLuITph2cH8SR0kh5ZFo96L1ClAjF+S1ZUxHb36M= 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=CzuRKsd5; arc=none smtp.client-ip=209.85.128.41 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="CzuRKsd5" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-48d102471a4so18924875e9.2 for ; Tue, 05 May 2026 05:33:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777984413; x=1778589213; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ef0p1N+2QsEru7968/qc5yXSbaXMb/XOXU32VPi/MUM=; b=CzuRKsd55tn1cTm3V398v5mT3hLHBp8ptcsZMnj5ogoy0reBqTWmZnckuEIwIxo/OO S7aJQqNo7pyOvohxUGbLz/QwJBUcby6RbsGGXKEcEaiyvNMZZMrwaIJT/JLzrFaWFrIi iS+SMV1iDNyd9ynsZ++UTuF76Obh7ByaNdFoKnx/GK4Kd+PYqzMpYAMB6He+VwZkxhla kkKVIi/BqJWM06WONpMrloSMkO6SD9seSMznew4aJWNFs/Nhdwme9wafm2/yb61aaH2/ 7JhNlS1Sr5eJVMgGQm9RZmgC+WNJx/83PMp/hyrxbG7aFFMT3en0Hcjnz9pVK5uzTIrL G4Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777984413; x=1778589213; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ef0p1N+2QsEru7968/qc5yXSbaXMb/XOXU32VPi/MUM=; b=HkoAhDCE3idcxvMv1reQFw5O7XwjynGj7Jbd6ldsr68HMJhAp8Y2RlGOvWRfPIUYnj FEmyCIGz02Se9Nau2V8wa0qm+WJtu2at6bUVyPN8eWVrZQGIeLFzXt7RWCsUp5nxCcTV 94VPJiAz+FjhOo+R3yiT+9dojsLxBRMgATKgUzze2iUiJnkO1+XAnH6gyuXeX1d2qbGd 1/oiFc4tDBdSAbnMZMFJUGxyLBzS+Tj2zq7V9P7bgMnkI58Svz/qmsvuV8pwVaTcWkK7 KPFAmXyEop6+a8CQEnuRVDX0vus9QlChGENhGGgJCsLGmdExpwJ3yWgN5wIc3TqB9iLn KstQ== X-Forwarded-Encrypted: i=1; AFNElJ/xNd7b/LOj6C1Gtl+3OQqP8bfCFgz9yERf6mWz9zZVaugYKyFyWnpC5U7Qlj0EJz817JiES4HljPk91Eg=@vger.kernel.org X-Gm-Message-State: AOJu0YxTD1xxGkYOHZyH+WUprz6ACzoqqHnHgRE51CvM9qCxGNqXvwG+ t6f33vLVGgmJu6U+srDvE7DggbFS541PBR8ofoc5Ki3C5k0GvA0AYUA= X-Gm-Gg: AeBDieu1qrVjh6ItMCgpdI1E33wPpX97TACf5510ZloNbefoH2uS7tiDd0oaCV1UlQ5 EiT6+CQSPu9UuPv/DnhEjheahbYa+3q+PjD1RKBt0aT8uKGu2dUPXSXlDsZDIsX9Sunej6HaZK2 Ptukf/gO5oN9swWZxwXTrBWBPLfJiydFIYbfcse6/m0LkqzjDerDG1wI3i6XNfQU9AMuS+kNcCl xipjHifJ8jc3OZW0rMuEd/RKokMNLQwH8M4Lu0SzIAxsV9HbzQcMQy2BgxzL+kfK8+GUZ3PoWt5 MXQtGmOiJt+cCDMwTxHZbeW/Wrh6pi0q33mUYsVOiBnCUfgD9RPUMfaOB+dmaeBOvPQ+7t5XHzp nJPy2QV3jPr/ISrv02O7TrQfNKfqYeWpiLhR3ApBNLTNCmU03AqsvpkdGVfh8sgrh0LvxGsFtXC DiZX8= X-Received: by 2002:a05:600c:a590:b0:48d:5e7:a5b4 with SMTP id 5b1f17b1804b1-48d05e7afb7mr92025535e9.23.1777984413307; Tue, 05 May 2026 05:33:33 -0700 (PDT) Received: from debian.. ([2001:41d0:303:db6b::]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a822bf3ffsm431044285e9.7.2026.05.05.05.33.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2026 05:33:32 -0700 (PDT) From: Tristan Madani To: Dave Kleikamp Cc: jfs-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org, syzbot+c244f4a09ca85dd2ebc1@syzkaller.appspotmail.com, syzbot+885a4f3281b8d99c48d8@syzkaller.appspotmail.com, stable@vger.kernel.org, Tristan Madani Subject: [PATCH v2 2/2] jfs: wait for in-flight log I/O before freeing lbufs in lbmLogShutdown Date: Tue, 5 May 2026 12:33:30 +0000 Message-ID: <20260505123330.2822833-3-tristmd@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260505123330.2822833-1-tristmd@gmail.com> References: <20260501110236.43226-1-tristmd@gmail.com> <20260505123330.2822833-1-tristmd@gmail.com> 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" From: Tristan Madani lbmLogShutdown() frees log buffer (lbuf) pages and structures from log->lbuf_free. However, BIO completions (lbmIODone) may still be executing in softirq context when lbmLogShutdown() runs, because lbmIODone accesses lbuf fields (l_flag, l_log, l_freelist) before returning the buffer to the freelist. If lbmLogShutdown() runs concurrently with lbmIODone in-flight, it can free an lbuf that lbmIODone is still accessing -- resulting in a use-after-free. Fix this by adding an atomic io_count to struct jfs_log that tracks in-flight BIO operations. lbmStartIO increments it before submit_bio (or before calling lbmIODone directly for no_integrity mode), and lbmIODone decrements it after all lbuf accesses are complete. lbmLogShutdown waits for io_count to reach zero before freeing any lbufs. Reported-by: syzbot+c244f4a09ca85dd2ebc1@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3Dc244f4a09ca85dd2ebc1 Reported-by: syzbot+885a4f3281b8d99c48d8@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D885a4f3281b8d99c48d8 Fixes: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Tristan Madani --- fs/jfs/jfs_logmgr.c | 12 ++++++++++++ fs/jfs/jfs_logmgr.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c index 306165e61438c..95e95f71ec0fa 100644 --- a/fs/jfs/jfs_logmgr.c +++ b/fs/jfs/jfs_logmgr.c @@ -1804,6 +1804,8 @@ static int lbmLogInit(struct jfs_log * log) * avoid deadlock here. */ init_waitqueue_head(&log->free_wait); + atomic_set(&log->io_count, 0); + init_waitqueue_head(&log->io_done_wait); =20 log->lbuf_free =3D NULL; =20 @@ -1855,6 +1857,9 @@ static void lbmLogShutdown(struct jfs_log * log) =20 jfs_info("lbmLogShutdown: log:0x%p", log); =20 + /* Wait for all in-flight log I/O to complete */ + wait_event(log->io_done_wait, !atomic_read(&log->io_count)); + lbuf =3D log->lbuf_free; while (lbuf) { struct lbuf *next =3D lbuf->l_freelist; @@ -1976,6 +1981,8 @@ static int lbmRead(struct jfs_log * log, int pn, stru= ct lbuf ** bpp) =20 bio->bi_end_io =3D lbmIODone; bio->bi_private =3D bp; + + atomic_inc(&log->io_count); /*check if journaling to disk has been disabled*/ if (log->no_integrity) { bio->bi_iter.bi_size =3D 0; @@ -2123,6 +2130,8 @@ static void lbmStartIO(struct lbuf * bp) bio->bi_end_io =3D lbmIODone; bio->bi_private =3D bp; =20 + atomic_inc(&log->io_count); + /* check if journaling to disk has been disabled */ if (log->no_integrity) { bio->bi_iter.bi_size =3D 0; @@ -2299,6 +2308,9 @@ static void lbmIODone(struct bio *bio) out: bp->l_flag |=3D lbmDONE; LCACHE_UNLOCK(flags); + + if (atomic_dec_and_test(&bp->l_log->io_count)) + wake_up(&bp->l_log->io_done_wait); } =20 int jfsIOWait(void *arg) diff --git a/fs/jfs/jfs_logmgr.h b/fs/jfs/jfs_logmgr.h index 09e0ef6aeccef..cbf38ed27c950 100644 --- a/fs/jfs/jfs_logmgr.h +++ b/fs/jfs/jfs_logmgr.h @@ -367,6 +367,8 @@ struct jfs_log { =20 struct lbuf *lbuf_free; /* 4: free lbufs */ wait_queue_head_t free_wait; /* 4: */ + atomic_t io_count; /* in-flight log I/O count */ + wait_queue_head_t io_done_wait; /* wait for io_count =3D=3D 0 */ =20 /* log write */ int logtid; /* 4: log tid */ --=20 2.47.3