From: Cen Zhang <zzzccc427@gmail.com>
To: shaggy@kernel.org
Cc: gregkh@linuxfoundation.org, jfs-discussion@lists.sourceforge.net,
linux-kernel@vger.kernel.org, baijiaju1990@gmail.com,
Cen Zhang <zzzccc427@gmail.com>
Subject: [PATCH] jfs: serialize jfs_flush_journal() logsync list checks
Date: Tue, 5 May 2026 23:04:47 +0800 [thread overview]
Message-ID: <20260505150447.1708174-1-zzzccc427@gmail.com> (raw)
The logsync list is protected by log->synclock. Entries are added,
moved, removed, and have their metapage logsync state updated while
holding that lock.
jfs_flush_journal() checks log->synclist without taking log->synclock
while waiting for the lazycommit thread to catch up. In debug builds it
can also traverse the list and dump entries without serialization. A
lazy commit can wake a flush waiter before txUnlock() updates metapage
logsync state and removes the transaction block from log->synclist, so
jfs_flush_journal() can sample or traverse the list concurrently with a
protected updater.
Use log->synclock for the flush-side empty checks and for the debug list
walk. This keeps jfs_flush_journal() serialized with the existing
logsync mutators without changing commit ordering.
Signed-off-by: Cen Zhang <zzzccc427@gmail.com>
---
fs/jfs/jfs_logmgr.c | 57 +++++++++++++++++++++++++++++++++------------
1 file changed, 38 insertions(+), 19 deletions(-)
diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
index ada00d5..ea607ce 100644
--- a/fs/jfs/jfs_logmgr.c
+++ b/fs/jfs/jfs_logmgr.c
@@ -1495,6 +1495,18 @@ int lmLogClose(struct super_block *sb)
}
+static bool jfs_log_synclist_empty(struct jfs_log *log)
+{
+ unsigned long flags;
+ bool empty;
+
+ LOGSYNC_LOCK(log, flags);
+ empty = list_empty(&log->synclist);
+ LOGSYNC_UNLOCK(log, flags);
+
+ return empty;
+}
+
/*
* NAME: jfs_flush_journal()
*
@@ -1575,40 +1587,47 @@ void jfs_flush_journal(struct jfs_log *log, int wait)
* If there was recent activity, we may need to wait
* for the lazycommit thread to catch up
*/
- if ((!list_empty(&log->cqueue)) || !list_empty(&log->synclist)) {
+ if ((!list_empty(&log->cqueue)) || !jfs_log_synclist_empty(log)) {
for (i = 0; i < 200; i++) { /* Too much? */
msleep(250);
write_special_inodes(log, filemap_fdatawrite);
if (list_empty(&log->cqueue) &&
- list_empty(&log->synclist))
+ jfs_log_synclist_empty(log))
break;
}
}
assert(list_empty(&log->cqueue));
#ifdef CONFIG_JFS_DEBUG
- if (!list_empty(&log->synclist)) {
+ {
+ unsigned long flags;
struct logsyncblk *lp;
- printk(KERN_ERR "jfs_flush_journal: synclist not empty\n");
- list_for_each_entry(lp, &log->synclist, synclist) {
- if (lp->xflag & COMMIT_PAGE) {
- struct metapage *mp = (struct metapage *)lp;
- print_hex_dump(KERN_ERR, "metapage: ",
- DUMP_PREFIX_ADDRESS, 16, 4,
- mp, sizeof(struct metapage), 0);
- print_hex_dump(KERN_ERR, "page: ",
- DUMP_PREFIX_ADDRESS, 16,
- sizeof(long), mp->folio,
- sizeof(struct page), 0);
- } else
- print_hex_dump(KERN_ERR, "tblock:",
- DUMP_PREFIX_ADDRESS, 16, 4,
- lp, sizeof(struct tblock), 0);
+ LOGSYNC_LOCK(log, flags);
+ if (!list_empty(&log->synclist)) {
+ pr_err("%s: synclist not empty\n", __func__);
+ list_for_each_entry(lp, &log->synclist, synclist) {
+ if (lp->xflag & COMMIT_PAGE) {
+ struct metapage *mp = (struct metapage *)lp;
+
+ print_hex_dump(KERN_ERR, "metapage: ",
+ DUMP_PREFIX_ADDRESS, 16, 4,
+ mp, sizeof(struct metapage), 0);
+ print_hex_dump(KERN_ERR, "page: ",
+ DUMP_PREFIX_ADDRESS, 16,
+ sizeof(long), mp->folio,
+ sizeof(struct page), 0);
+ } else {
+ print_hex_dump(KERN_ERR, "tblock:",
+ DUMP_PREFIX_ADDRESS, 16, 4,
+ lp, sizeof(struct tblock), 0);
+ }
+ }
}
+ LOGSYNC_UNLOCK(log, flags);
}
#else
- WARN_ON(!list_empty(&log->synclist));
+ WARN_ON(!jfs_log_synclist_empty(log));
#endif
clear_bit(log_FLUSH, &log->flag);
}
--
2.51.0
reply other threads:[~2026-05-05 15:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260505150447.1708174-1-zzzccc427@gmail.com \
--to=zzzccc427@gmail.com \
--cc=baijiaju1990@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=shaggy@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®