@@ -3896,6 +3896,34 @@ static inline void ext4_atomic_write_fsawu(struct super_block *sb,
*fsawu_max = 0;
}
+/**
+ * ext4_init_atomic_write ext4 init atomic writes using fsawu
+ * @sb super_block
+ *
+ * Function to initialize atomic/untorn write support using fsawu.
+ * TODO: In future, when mballoc will get aligned allocations support,
+ * then we can enable atomic write support for ext4 without fsawu restrictions.
+ */
+static inline void ext4_init_atomic_write(struct super_block *sb)
+{
+ struct block_device *bdev = sb->s_bdev;
+ unsigned int fsawu_min, fsawu_max;
+
+ if (!ext4_has_feature_extents(sb))
+ return;
+
+ if (!bdev_can_atomic_write(bdev))
+ return;
+
+ ext4_atomic_write_fsawu(sb, &fsawu_min, &fsawu_max);
+ if (fsawu_min && fsawu_max) {
+ ext4_set_mount_flag(sb, EXT4_MF_ATOMIC_WRITE_FSAWU);
+ ext4_msg(sb, KERN_NOTICE,
+ "Supports atomic writes using EXT4_MF_ATOMIC_WRITE_FSAWU, fsawu_min %u fsawu_max: %u",
+ fsawu_min, fsawu_max);
+ }
+}
+
#endif /* __KERNEL__ */
#define EFSBADCRC EBADMSG /* Bad CRC detected */
@@ -5352,6 +5352,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
mutex_init(&sbi->s_orphan_lock);
ext4_fast_commit_init(sb);
+ ext4_init_atomic_write(sb);
sb->s_root = NULL;