[PATCH 4/4] ufs: leave fs_clean of a 44bsd filesystem at 0 after an error

From: Showta Ishizaki

Date: Fri Nov 27 2026 - 00:22:40 EST


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@xxxxxxxxxxxxxx>
---
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)