]> git.itanic.dy.fi Git - linux-stable/commitdiff
xfs: respect the stable writes flag on the RT device
authorChristoph Hellwig <hch@lst.de>
Wed, 25 Oct 2023 14:10:20 +0000 (16:10 +0200)
committerChristian Brauner <brauner@kernel.org>
Mon, 20 Nov 2023 14:05:19 +0000 (15:05 +0100)
Update the per-folio stable writes flag dependening on which device an
inode resides on.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20231025141020.192413-5-hch@lst.de
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/xfs/xfs_inode.h
fs/xfs/xfs_ioctl.c
fs/xfs/xfs_iops.c

index 3dc47937da5d17d81e46fd590435f574d11558dc..3beb470f18920d6730b32e5d1edcf5530b93b327 100644 (file)
@@ -569,6 +569,14 @@ extern void xfs_setup_inode(struct xfs_inode *ip);
 extern void xfs_setup_iops(struct xfs_inode *ip);
 extern void xfs_diflags_to_iflags(struct xfs_inode *ip, bool init);
 
+static inline void xfs_update_stable_writes(struct xfs_inode *ip)
+{
+       if (bdev_stable_writes(xfs_inode_buftarg(ip)->bt_bdev))
+               mapping_set_stable_writes(VFS_I(ip)->i_mapping);
+       else
+               mapping_clear_stable_writes(VFS_I(ip)->i_mapping);
+}
+
 /*
  * When setting up a newly allocated inode, we need to call
  * xfs_finish_inode_setup() once the inode is fully instantiated at
index 022dc2dc78d2f72d7978226e0f50aecaf19f53b8..6c3919687ea6b306585ea2f32f125c59a4b53a60 100644 (file)
@@ -1150,6 +1150,14 @@ xfs_ioctl_setattr_xflags(
        ip->i_diflags2 = i_flags2;
 
        xfs_diflags_to_iflags(ip, false);
+
+       /*
+        * Make the stable writes flag match that of the device the inode
+        * resides on when flipping the RT flag.
+        */
+       if (rtflag != XFS_IS_REALTIME_INODE(ip) && S_ISREG(VFS_I(ip)->i_mode))
+               xfs_update_stable_writes(ip);
+
        xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
        xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
        XFS_STATS_INC(mp, xs_ig_attrchg);
index fdfda4fba12b1e9afd3b8631ec8587ac7295ce13..a0d77f5f512e2412c0e4c89aefacdd5c7c52c00c 100644 (file)
@@ -1298,6 +1298,13 @@ xfs_setup_inode(
        gfp_mask = mapping_gfp_mask(inode->i_mapping);
        mapping_set_gfp_mask(inode->i_mapping, (gfp_mask & ~(__GFP_FS)));
 
+       /*
+        * For real-time inodes update the stable write flags to that of the RT
+        * device instead of the data device.
+        */
+       if (S_ISREG(inode->i_mode) && XFS_IS_REALTIME_INODE(ip))
+               xfs_update_stable_writes(ip);
+
        /*
         * If there is no attribute fork no ACL can exist on this inode,
         * and it can't have any file capabilities attached to it either.