ext4: Enable support for ext4 multi-fsblock atomic write using bigalloc
authorRitesh Harjani (IBM) <ritesh.list@gmail.com>
Thu, 15 May 2025 19:50:54 +0000 (01:20 +0530)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 20 May 2025 14:31:12 +0000 (10:31 -0400)
Last couple of patches added the needed support for multi-fsblock atomic
writes using bigalloc. This patch ensures that filesystem advertizes the
needed atomic write unit min and max values for enabling multi-fsblock
atomic write support with bigalloc.

Acked-by: Darrick J. Wong <djwong@kernel.org>
Co-developed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Link: https://patch.msgid.link/5e45d7ed24499024b9079436ba6698dae5298e29.1747337952.git.ritesh.list@gmail.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/super.c

index 9bf38e21dcda358812272db673ac7756b6a88ea4..a7f80ca0117472434cd1bd0e7acf22a4035d655e 100644 (file)
@@ -4436,13 +4436,16 @@ static int ext4_handle_clustersize(struct super_block *sb)
 
 /*
  * ext4_atomic_write_init: Initializes filesystem min & max atomic write units.
+ * With non-bigalloc filesystem awu will be based upon filesystem blocksize
+ * & bdev awu units.
+ * With bigalloc it will be based upon bigalloc cluster size & bdev awu units.
  * @sb: super block
- * TODO: Later add support for bigalloc
  */
 static void ext4_atomic_write_init(struct super_block *sb)
 {
        struct ext4_sb_info *sbi = EXT4_SB(sb);
        struct block_device *bdev = sb->s_bdev;
+       unsigned int clustersize = EXT4_CLUSTER_SIZE(sb);
 
        if (!bdev_can_atomic_write(bdev))
                return;
@@ -4452,7 +4455,7 @@ static void ext4_atomic_write_init(struct super_block *sb)
 
        sbi->s_awu_min = max(sb->s_blocksize,
                              bdev_atomic_write_unit_min_bytes(bdev));
-       sbi->s_awu_max = min(sb->s_blocksize,
+       sbi->s_awu_max = min(clustersize,
                              bdev_atomic_write_unit_max_bytes(bdev));
        if (sbi->s_awu_min && sbi->s_awu_max &&
            sbi->s_awu_min <= sbi->s_awu_max) {