]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
xfs: avoid shared rmap operations for attr fork extents
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 24 Sep 2020 16:42:55 +0000 (09:42 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Fri, 25 Sep 2020 18:34:08 +0000 (11:34 -0700)
During code review, I noticed that the rmap code uses the (slower)
shared mappings rmap functions for any extent of a reflinked file, even
if those extents are for the attr fork, which doesn't support sharing.
We can speed up rmap a tiny bit by optimizing out this case.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/libxfs/xfs_rmap.c

index 27c39268c31f78515c1b16b595a2c9f2bd77248d..340c83f76c806c2a4b2d549f8661935cd034e7e9 100644 (file)
@@ -2505,12 +2505,15 @@ xfs_rmap_map_extent(
        int                     whichfork,
        struct xfs_bmbt_irec    *PREV)
 {
+       enum xfs_rmap_intent_type type = XFS_RMAP_MAP;
+
        if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork))
                return;
 
-       __xfs_rmap_add(tp, xfs_is_reflink_inode(ip) ?
-                       XFS_RMAP_MAP_SHARED : XFS_RMAP_MAP, ip->i_ino,
-                       whichfork, PREV);
+       if (whichfork != XFS_ATTR_FORK && xfs_is_reflink_inode(ip))
+               type = XFS_RMAP_MAP_SHARED;
+
+       __xfs_rmap_add(tp, type, ip->i_ino, whichfork, PREV);
 }
 
 /* Unmap an extent out of a file. */
@@ -2521,12 +2524,15 @@ xfs_rmap_unmap_extent(
        int                     whichfork,
        struct xfs_bmbt_irec    *PREV)
 {
+       enum xfs_rmap_intent_type type = XFS_RMAP_UNMAP;
+
        if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork))
                return;
 
-       __xfs_rmap_add(tp, xfs_is_reflink_inode(ip) ?
-                       XFS_RMAP_UNMAP_SHARED : XFS_RMAP_UNMAP, ip->i_ino,
-                       whichfork, PREV);
+       if (whichfork != XFS_ATTR_FORK && xfs_is_reflink_inode(ip))
+               type = XFS_RMAP_UNMAP_SHARED;
+
+       __xfs_rmap_add(tp, type, ip->i_ino, whichfork, PREV);
 }
 
 /*
@@ -2543,12 +2549,15 @@ xfs_rmap_convert_extent(
        int                     whichfork,
        struct xfs_bmbt_irec    *PREV)
 {
+       enum xfs_rmap_intent_type type = XFS_RMAP_CONVERT;
+
        if (!xfs_rmap_update_is_needed(mp, whichfork))
                return;
 
-       __xfs_rmap_add(tp, xfs_is_reflink_inode(ip) ?
-                       XFS_RMAP_CONVERT_SHARED : XFS_RMAP_CONVERT, ip->i_ino,
-                       whichfork, PREV);
+       if (whichfork != XFS_ATTR_FORK && xfs_is_reflink_inode(ip))
+               type = XFS_RMAP_CONVERT_SHARED;
+
+       __xfs_rmap_add(tp, type, ip->i_ino, whichfork, PREV);
 }
 
 /* Schedule the creation of an rmap for non-file data. */