mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Showta Ishizaki <zakinko@snowrabbit.org>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>, Ali Ahmet Memis <ali@iusegentoo.com>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Showta Ishizaki <zakinko@snowrabbit.org>
Subject: [PATCH 0/4] ufs: fs_clean and fs_mtime of a 44bsd filesystem that is read-write
Date: Fri, 27 Nov 2026 14:22:20 +0900 (JST)	[thread overview]
Message-ID: <20261127-ufs-suj-0-v1@snowrabbit.org> (raw)

After Linux crashes with a FreeBSD UFS mounted read-write, fsck_ffs -p
of FreeBSD 15.0 says

  /dev/md0: FILE SYSTEM CLEAN; SKIPPING CHECKS

and fsck_ffs -fn then finds 161 to 224 errors in it.  ufs leaves
fs_clean at 1 while the filesystem is read-write.

Patch 1 keeps fs_clean at 0 while a 44bsd or ufs2 filesystem is
read-write.  Patch 2 reads 2, which NetBSD leaves after a crash, as not
clean.  Patch 3 sets fs_mtime, without which FreeBSD's fsck recovers
from its soft updates journal and marks the filesystem clean.  Patch 4
keeps ufs_error() from storing 0xff, which the BSDs read as clean.

What changes for a user of Linux alone: after a crash the filesystem is
mounted read-only the next time, as one that FreeBSD left unclean is
today.  It can still be made read-write with remount, and then stays not
clean until a fsck on a BSD.

The filesystems were UFS1 and UFS2 with journaled soft updates.  Six
processes created, renamed and removed files, the device was suspended
with dmsetup, and its backing file was copied; eight such copies for
each kernel.  The UFS2 had its check hashes turned off in the image, as
Linux does not keep them; with them on fsck_ffs -p stops at the cylinder
group hashes with and without the patches.

Without the patches fsck_ffs -p skipped all eight as clean, and
fsck_ffs -fn found 161 to 224 errors in each.  With patch 1 alone it
recovered all eight from the journal and marked them clean, and -fn
found 154 to 225 errors.  With all four it says "Journal timestamp does
not match fs mount time" for all eight, goes on to the full check and
exits with 8, asking for a manual fsck; -fn reports 139 to 240 errors.

After an unmount fsck_ffs -fn finds nothing with any of the three.
After a remount to read-only it finds one without the patches, FREE BLK
COUNT(S) WRONG IN SUPERBLK, and none with them.  fs_clean goes
1, 0, 1, 0, 1 over mount read-only, remount read-write, read-only,
read-write, unmount.  A filesystem with 0 that is remounted read-write
has 0 after the unmount, and FreeBSD checks it.  One with 2 is mounted
read-only and keeps 2.  After ufs_error() fs_clean is 0, and 0 after
the unmount; it was 255.

Not tried: the background check that fsck -F leaves a filesystem with
soft updates only to, gjournal, write errors, and a filesystem made by
NetBSD.  That the BSD kernels read 0xff as clean is from their sources.

Patches 1, 7 and 8 of "ufs: correctness fixes for valid on-disk
filesystems" by Ali Ahmet Memis (2026-08-01) touch the same places.
Patch 1 there names the fields in fs_sparecon, fs_mtime among them, as
patch 3 here does for that one.  Patch 7 there refuses to remount
read-write a filesystem that is not clean; patch 1 here lets it through
and leaves it not clean at unmount, as the BSDs do after a forced mount.
Patch 8 there refuses UFS2 with a journal read-write; patch 3 here
leaves it writable and has FreeBSD's fsck ignore the journal.

This is on the fs/ufs of next-20261125.  Patch 2 applies to Linus' tree
(4dce97c6c265) as well; the others are on top of the sb_emergency_ro()
changes in next.

Showta Ishizaki (4):
  ufs: clear fs_clean of a 44bsd filesystem while it is read-write
  ufs: do not take a filesystem NetBSD has mounted for clean
  ufs: let FreeBSD see that its soft updates journal is out of date
  ufs: leave fs_clean of a 44bsd filesystem at 0 after an error

 fs/ufs/super.c  | 102 ++++++++++++++++++++++++++++++++++++++++++++++--
 fs/ufs/ufs.h    |   1 +
 fs/ufs/ufs_fs.h |   4 +-
 3 files changed, 103 insertions(+), 4 deletions(-)

-- 
2.54.0 (Apple Git-157)


             reply	other threads:[~2026-11-27  5:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  5:22 Showta Ishizaki [this message]
2026-11-27  5:22 ` [PATCH 1/4] ufs: clear fs_clean of a 44bsd filesystem while it " Showta Ishizaki
2026-11-27  5:22 ` [PATCH 2/4] ufs: do not take a filesystem NetBSD has mounted for clean Showta Ishizaki
2026-11-27  5:22 ` [PATCH 3/4] ufs: let FreeBSD see that its soft updates journal is out of date Showta Ishizaki
2026-11-27  5:22 ` [PATCH 4/4] ufs: leave fs_clean of a 44bsd filesystem at 0 after an error Showta Ishizaki

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=20261127-ufs-suj-0-v1@snowrabbit.org \
    --to=zakinko@snowrabbit.org \
    --cc=ali@iusegentoo.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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®