public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: avoid shared rmap operations for attr fork extents
@ 2020-09-23 18:23 Darrick J. Wong
  2020-09-24  4:44 ` Chandan Babu R
  2020-09-24  5:44 ` Christoph Hellwig
  0 siblings, 2 replies; 3+ messages in thread
From: Darrick J. Wong @ 2020-09-23 18:23 UTC (permalink / raw)
  To: xfs

From: Darrick J. Wong <darrick.wong@oracle.com>

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>
---
 fs/xfs/libxfs/xfs_rmap.c |   27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_rmap.c b/fs/xfs/libxfs/xfs_rmap.c
index 27c39268c31f..340c83f76c80 100644
--- a/fs/xfs/libxfs/xfs_rmap.c
+++ b/fs/xfs/libxfs/xfs_rmap.c
@@ -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. */

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs: avoid shared rmap operations for attr fork extents
  2020-09-23 18:23 [PATCH] xfs: avoid shared rmap operations for attr fork extents Darrick J. Wong
@ 2020-09-24  4:44 ` Chandan Babu R
  2020-09-24  5:44 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Chandan Babu R @ 2020-09-24  4:44 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: xfs

On Wednesday 23 September 2020 11:53:40 PM IST Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> 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>

Looks good to me.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>

> ---
>  fs/xfs/libxfs/xfs_rmap.c |   27 ++++++++++++++++++---------
>  1 file changed, 18 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_rmap.c b/fs/xfs/libxfs/xfs_rmap.c
> index 27c39268c31f..340c83f76c80 100644
> --- a/fs/xfs/libxfs/xfs_rmap.c
> +++ b/fs/xfs/libxfs/xfs_rmap.c
> @@ -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. */
> 


-- 
chandan




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs: avoid shared rmap operations for attr fork extents
  2020-09-23 18:23 [PATCH] xfs: avoid shared rmap operations for attr fork extents Darrick J. Wong
  2020-09-24  4:44 ` Chandan Babu R
@ 2020-09-24  5:44 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2020-09-24  5:44 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: xfs

On Wed, Sep 23, 2020 at 11:23:40AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> 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.

This looks correct:

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-24  5:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-23 18:23 [PATCH] xfs: avoid shared rmap operations for attr fork extents Darrick J. Wong
2020-09-24  4:44 ` Chandan Babu R
2020-09-24  5:44 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox