From: Baokun Li <libaokun@linux.alibaba.com>
To: linux-ext4@vger.kernel.org
Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz,
yi.zhang@huawei.com, ojaswin@linux.ibm.com,
ritesh.list@gmail.com
Subject: [PATCH e2fsprogs 1/5] fsck: consume -l option instead of passing to e2fsck
Date: Tue, 14 Jul 2026 14:31:32 +0800 [thread overview]
Message-ID: <20260714063136.1284287-2-libaokun@linux.alibaba.com> (raw)
In-Reply-To: <20260714063136.1284287-1-libaokun@linux.alibaba.com>
The -l (lockdisk) option was introduced by util-linux in commit
dd0bd943f9 ("fsck: add support for whole-disk locking (-l option)",
2010-10-26, first released in v2.19). systemd-fsck passes -l to
/sbin/fsck for parallel fsck support since commit 87c3e6c ("fsck:
pass -l to fsck").
Currently the e2fsprogs fsck wrapper (misc/fsck.c, installed via
make install) does not recognize -l and passes it through to e2fsck.
Since e2fsck's getopt string declares "l:" (requires argument), it
consumes the next argument as the bad_blocks_file parameter. This
triggers a chain of failures:
systemd-fsck -> fsck -a -T -l -M -C6 /dev/sda
-> wrapper consumes -a,-T,-M,-C6, adds -C<fd>, passes -l
-> fsck.ext4 -a -l -C<fd> /dev/sda
-> e2fsck getopt: -l consumes -C<fd> as bad_blocks_file
-> journal recovery
-> orphan cleanup (orphan inodes processed)
-> fopen("-C<fd>", "r") fails -> E2F_FLAG_ABORT
-> superblock not flushed (s_last_orphan still non-zero)
-> kernel: "bad orphan inode" on next mount
This is because the e2fsprogs wrapper lacks a case for -l in its
option parsing, unlike the util-linux wrapper which handles it
correctly (lockdisk = 1).
Fix by adding case 'l': break; to consume the option in the wrapper,
matching util-linux's behavior. Users can still pass -l to e2fsck
via the "--" separator (e.g., "fsck -- -l badblocks_file /dev/sda")
or by invoking e2fsck directly.
Signed-off-by: Baokun Li <libaokun@linux.alibaba.com>
---
misc/fsck.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/misc/fsck.c b/misc/fsck.c
index 44577590bca5..cb935e1b4b71 100644
--- a/misc/fsck.c
+++ b/misc/fsck.c
@@ -1212,6 +1212,9 @@ static void PRS(int argc, char *argv[])
case 'M':
ignore_mounted++;
break;
+ case 'l':
+ /* lockdisk option from util-linux fsck, consumed by wrapper */
+ break;
case 'P':
parallel_root++;
break;
--
2.43.7
next prev parent reply other threads:[~2026-07-14 6:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 6:31 [PATCH e2fsprogs 0/5] fsck: fix stale "bad orphan inode" after fsck runs Baokun Li
2026-07-14 6:31 ` Baokun Li [this message]
2026-07-14 6:31 ` [PATCH e2fsprogs 2/5] fsck: fix -C fd option parsing when fd is a separate argument Baokun Li
2026-07-14 6:31 ` [PATCH e2fsprogs 3/5] e2fsck: flush superblock immediately after orphan cleanup Baokun Li
2026-07-14 6:31 ` [PATCH e2fsprogs 4/5] tests: add fsck option-parsing regression test Baokun Li
2026-07-14 6:31 ` [PATCH e2fsprogs 5/5] tests: add orphan-cleanup flush " Baokun Li
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=20260714063136.1284287-2-libaokun@linux.alibaba.com \
--to=libaokun@linux.alibaba.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=tytso@mit.edu \
--cc=yi.zhang@huawei.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.