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 4/4] ufs: leave fs_clean of a 44bsd filesystem at 0 after an error
Date: Fri, 27 Nov 2026 14:22:33 +0900 (JST)	[thread overview]
Message-ID: <20261127-ufs-suj-4-v1@snowrabbit.org> (raw)
In-Reply-To: <20261127-ufs-suj-0-v1@snowrabbit.org>

ufs_error() and ufs_panic() set fs_clean to 0xff.  That is a Solaris
value.  The FreeBSD kernel tests fs_clean for 0, and the NetBSD kernel
and fsck test its lowest bit, so that they take it for clean.

Leave it at 0.  With an image whose fragments are marked free, removing
the files gives the error, and fs_clean is 0 then and after the unmount;
it was 255.

Signed-off-by: Showta Ishizaki <zakinko@snowrabbit.org>
---
 fs/ufs/super.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index 716867fac..71e0d5808 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -269,6 +269,19 @@ static void ufs_print_cylinder_stuff(struct super_block *sb,
 
 static const struct super_operations ufs_super_ops;
 
+/*
+ * FreeBSD and NetBSD have no such value.  Their kernels, and NetBSD's fsck,
+ * test a bit or compare with 0, and would take UFS_FSBAD for clean.
+ */
+static void ufs_set_bad(struct super_block *sb,
+			struct ufs_super_block_first *usb1)
+{
+	if ((UFS_SB(sb)->s_flags & UFS_ST_MASK) == UFS_ST_44BSD)
+		usb1->fs_clean = UFS_FSACTIVE;
+	else
+		usb1->fs_clean = UFS_FSBAD;
+}
+
 void ufs_error (struct super_block * sb, const char * function,
 	const char * fmt, ...)
 {
@@ -285,7 +298,7 @@ void ufs_error (struct super_block * sb, const char * function,
 	 * marked bad goes out with the block device.
 	 */
 	if (!sb_rdonly(sb) && sb_set_emergency_ro(sb)) {
-		usb1->fs_clean = UFS_FSBAD;
+		ufs_set_bad(sb, usb1);
 		ubh_mark_buffer_dirty(USPI_UBH(uspi));
 	}
 	va_start(args, fmt);
@@ -318,7 +331,7 @@ void ufs_panic (struct super_block * sb, const char * function,
 	
 	/* See ufs_error(). */
 	if (!sb_rdonly(sb) && sb_set_emergency_ro(sb)) {
-		usb1->fs_clean = UFS_FSBAD;
+		ufs_set_bad(sb, usb1);
 		ubh_mark_buffer_dirty(USPI_UBH(uspi));
 	}
 	va_start(args, fmt);
-- 
2.54.0 (Apple Git-157)


      parent 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 [PATCH 0/4] ufs: fs_clean and fs_mtime of a 44bsd filesystem that is read-write Showta Ishizaki
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 ` Showta Ishizaki [this message]

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-4-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®