diff mbox series

[17/18] btrfs: migrate btrfs_super_block::sectorsize to blocksize

Message ID ab8cdd215939cf260ac831f367735faebab42abc.1734514696.git.wqu@suse.com (mailing list archive)
State New
Headers show
Series btrfs: migrate to "block size" to describe the | expand

Commit Message

Qu Wenruo Dec. 18, 2024, 9:41 a.m. UTC
This is the rename of the on-disk format btrfs_super_block, which also
affects the accessors and a few callers.

To keep compatibility for old programs which may still access
btrfs_super_block::sectorsize, use a union so @blocksize and @sectorsize
can both access the same @blocksize value.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/accessors.h            |  4 ++--
 fs/btrfs/disk-io.c              |  4 ++--
 include/uapi/linux/btrfs_tree.h | 13 +++++++++++--
 3 files changed, 15 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/fs/btrfs/accessors.h b/fs/btrfs/accessors.h
index a796ec3fcb67..ecafbd6262cc 100644
--- a/fs/btrfs/accessors.h
+++ b/fs/btrfs/accessors.h
@@ -873,8 +873,8 @@  BTRFS_SETGET_STACK_FUNCS(super_total_bytes, struct btrfs_super_block,
 			 total_bytes, 64);
 BTRFS_SETGET_STACK_FUNCS(super_bytes_used, struct btrfs_super_block,
 			 bytes_used, 64);
-BTRFS_SETGET_STACK_FUNCS(super_sectorsize, struct btrfs_super_block,
-			 sectorsize, 32);
+BTRFS_SETGET_STACK_FUNCS(super_blocksize, struct btrfs_super_block,
+			 blocksize, 32);
 BTRFS_SETGET_STACK_FUNCS(super_nodesize, struct btrfs_super_block,
 			 nodesize, 32);
 BTRFS_SETGET_STACK_FUNCS(super_stripesize, struct btrfs_super_block,
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index d3d2c9e2356a..9e6a1ea507d7 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2341,7 +2341,7 @@  int btrfs_validate_super(const struct btrfs_fs_info *fs_info,
 			 const struct btrfs_super_block *sb, int mirror_num)
 {
 	u64 nodesize = btrfs_super_nodesize(sb);
-	u64 blocksize = btrfs_super_sectorsize(sb);
+	u64 blocksize = btrfs_super_blocksize(sb);
 	int ret = 0;
 	const bool ignore_flags = btrfs_test_opt(fs_info, IGNORESUPERFLAGS);
 
@@ -3310,7 +3310,7 @@  int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
 
 	/* Set up fs_info before parsing mount options */
 	nodesize = btrfs_super_nodesize(disk_super);
-	blocksize = btrfs_super_sectorsize(disk_super);
+	blocksize = btrfs_super_blocksize(disk_super);
 	stripesize = blocksize;
 	fs_info->dirty_metadata_batch = nodesize * (1 + ilog2(nr_cpu_ids));
 	fs_info->delalloc_batch = blocksize * 512 * (1 + ilog2(nr_cpu_ids));
diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h
index fc29d273845d..3fbefe00be4c 100644
--- a/include/uapi/linux/btrfs_tree.h
+++ b/include/uapi/linux/btrfs_tree.h
@@ -272,7 +272,7 @@ 
  * When a block group becomes very fragmented, we convert it to use bitmaps
  * instead of extents. A free space bitmap is keyed on
  * (start, FREE_SPACE_BITMAP, length); the corresponding item is a bitmap with
- * (length / sectorsize) bits.
+ * (length / blocksize) bits.
  */
 #define BTRFS_FREE_SPACE_BITMAP_KEY 200
 
@@ -690,7 +690,16 @@  struct btrfs_super_block {
 	__le64 bytes_used;
 	__le64 root_dir_objectid;
 	__le64 num_devices;
-	__le32 sectorsize;
+	union {
+		/*
+		 * The minimum data block size.
+		 *
+		 * Used to be called "sectorsize", but not recommended now.
+		 * Keep the old "sectorsize" just for old programs.
+		 */
+		__le32 blocksize;
+		__le32 sectorsize;
+	};
 	__le32 nodesize;
 	__le32 __unused_leafsize;
 	__le32 stripesize;