mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ali Ahmet Memis <ali@iusegentoo.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 01/10] ufs: name the modern UFS2 superblock fields
Date: Sat,  1 Aug 2026 22:55:21 +0000	[thread overview]
Message-ID: <20260801225530.148386-2-ali@iusegentoo.com> (raw)
In-Reply-To: <20260801225530.148386-1-ali@iusegentoo.com>

The 4.4BSD derived superblock that UFS2 uses has grown a number of
fields since Linux last looked at it. All of them currently sit inside
fs_44.fs_sparecon[50], so nothing in fs/ufs can tell that a filesystem
uses snapshots, soft updates journalling or metadata check hashes.

Split fs_sparecon[] into the fields FreeBSD defines, counting from
fs_pendinginodes: fs_snapinum[20], fs_avgfilesize, fs_avgfpdir,
fs_available_spare, fs_mtime, fs_sujfree, 21 remaining spare words,
fs_ckhash, fs_metackhash and the 32 bit fs_flags, followed by the
already named fs_contigsumsize. That is exactly 50 words, so the layout
does not change; sizeof(struct ufs_super_block_third) stays 356 and
fs_contigsumsize stays at offset 292.

The 8 bit fs_flags next to fs_clean is a different field, FreeBSD's
fs_old_flags. Rename it accordingly so the two cannot be confused. It
has no users.

Add the UFS_FS_* values for the 32 bit fs_flags and UFS_FSMAXSNAP.
No functional change; later patches use these.

Signed-off-by: Ali Ahmet Memis <ali@iusegentoo.com>
---
 fs/ufs/ufs_fs.h | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/fs/ufs/ufs_fs.h b/fs/ufs/ufs_fs.h
index b8dc354ae90f..32925c356fa2 100644
--- a/fs/ufs/ufs_fs.h
+++ b/fs/ufs/ufs_fs.h
@@ -154,6 +154,26 @@ typedef __u16 __bitwise __fs16;
 #define UFS_FSLOG     ((__s8)0xfd)	/* logging fs */
 #define UFS_FSFIX     ((__s8)0xfc)	/* being repaired while mounted */
 
+/* maximum number of snapshots recorded in fs_snapinum */
+#define UFS_FSMAXSNAP 20
+
+/*
+ * Values for the 32 bit fs_flags of the modern (4.4BSD derived) superblock.
+ * Not to be confused with the historic 8 bit fs_old_flags.
+ */
+#define UFS_FS_UNCLEAN		0x00000001
+#define UFS_FS_DOSOFTDEP	0x00000002
+#define UFS_FS_NEEDSFSCK	0x00000004
+#define UFS_FS_SUJ		0x00000008
+#define UFS_FS_ACLS		0x00000010
+#define UFS_FS_MULTILABEL	0x00000020
+#define UFS_FS_GJOURNAL		0x00000040
+#define UFS_FS_FLAGS_UPDATED	0x00000080
+#define UFS_FS_NFS4ACLS		0x00000100
+#define UFS_FS_METACKHASH	0x00000200
+#define UFS_FS_TRIM		0x00000400
+#define UFS_FS_INDEXDIRS	0x01000000
+
 /* From here to next blank line, s_flags for ufs_sb_info */
 /* directory entry encoding */
 #define UFS_DE_MASK		0x00000010	/* mask for the following */
@@ -865,7 +885,7 @@ struct ufs_super_block_first {
 	__s8	fs_fmod;
 	__s8	fs_clean;
 	__s8	fs_ronly;
-	__s8	fs_flags;
+	__s8	fs_old_flags;
 	__s8	fs_fsmnt[UFS_MAXMNTLEN - 212];
 
 };
@@ -937,7 +957,16 @@ struct ufs_super_block_third {
 			__fs32	fs_qfmask[2];	/* ~usb_fmask */
 		} fs_sunx86;
 		struct {
-			__fs32	fs_sparecon[50];/* reserved for future constants */
+			__fs32	fs_snapinum[UFS_FSMAXSNAP];/* snapshot inode numbers */
+			__fs32	fs_avgfilesize;	/* expected average file size */
+			__fs32	fs_avgfpdir;	/* expected # of files per directory */
+			__fs32	fs_available_spare;/* old scratch space */
+			__fs32	fs_mtime[2];	/* last mount or fsck time */
+			__fs32	fs_sujfree;	/* SUJ free list */
+			__fs32	fs_sparecon[21];/* reserved for future constants */
+			__fs32	fs_ckhash;	/* if CK_SUPERBLOCK, its check-hash */
+			__fs32	fs_metackhash;	/* metadata check-hash, see CK_ */
+			__fs32	fs_flags;	/* see UFS_FS_* above */
 			__fs32	fs_contigsumsize;/* size of cluster summary array */
 			__fs32	fs_maxsymlinklen;/* max length of an internal symlink */
 			__fs32	fs_inodefmt;	/* format of on-disk inodes */
-- 
2.55.0


  reply	other threads:[~2026-08-01 22:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-01 22:55 [PATCH 00/10] ufs: correctness fixes for valid on-disk filesystems Ali Ahmet Memis
2026-08-01 22:55 ` Ali Ahmet Memis [this message]
2026-08-01 22:55 ` [PATCH 02/10] ufs: use i_size to detect fast symlinks Ali Ahmet Memis
2026-08-01 22:55 ` [PATCH 03/10] ufs: free UFS2 external attribute blocks on inode deletion Ali Ahmet Memis
2026-08-01 22:55 ` [PATCH 04/10] ufs: do not inherit file flags from the parent directory Ali Ahmet Memis
2026-08-01 22:55 ` [PATCH 05/10] ufs: honour on-disk immutable and append-only flags Ali Ahmet Memis
2026-08-01 22:55 ` [PATCH 06/10] ufs: fix fragment relocation offsets within a folio Ali Ahmet Memis
2026-08-01 22:55 ` [PATCH 07/10] ufs: revalidate filesystem state before remounting read-write Ali Ahmet Memis
2026-08-01 22:55 ` [PATCH 08/10] ufs: refuse read-write mount when fsck or journal replay is needed Ali Ahmet Memis
2026-08-01 22:55 ` [PATCH 09/10] ufs: refuse read-write mount of filesystems with active snapshots Ali Ahmet Memis
2026-08-01 22:55 ` [PATCH 10/10] ufs: refuse read-write mount of check-hashed filesystems Ali Ahmet Memis

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=20260801225530.148386-2-ali@iusegentoo.com \
    --to=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®