All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carlos Maiolino <cem@kernel.org>
To: Eric Sandeen <sandeen@redhat.com>
Cc: linux-xfs@vger.kernel.org, djwong@kernel.org
Subject: Re: [PATCH 1/3] xfs: factor out xfs_dir2_sf_copy_entries helper
Date: Mon, 5 Oct 2026 14:14:31 +0200	[thread overview]
Message-ID: <asOUn3CDkcVWdCek@nidhogg.toxiclabs.cc> (raw)
In-Reply-To: <20261002211038.2139655-2-sandeen@redhat.com>

On Fri, Oct 02, 2026 at 04:08:09PM -0500, Eric Sandeen wrote:
> xfs_dir2_sf_toino8 and xfs_dir2_sf_toino64 share a dozen or so lines
> of copied code used to move short form directory entries; factor that
> out to eliminate cut and paste.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---

Looks good.

Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

>  fs/xfs/libxfs/xfs_dir2_sf.c | 68 ++++++++++++++++---------------------
>  1 file changed, 30 insertions(+), 38 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
> index 0567cf8b9c1b..a8675a0d574e 100644
> --- a/fs/xfs/libxfs/xfs_dir2_sf.c
> +++ b/fs/xfs/libxfs/xfs_dir2_sf.c
> @@ -1124,6 +1124,34 @@ xfs_dir2_sf_replace(
>  	return 0;
>  }
>  
> +static inline void
> +xfs_dir2_sf_copy_entries(
> +	struct xfs_mount	*mp,
> +	struct xfs_dir2_sf_hdr	*sfp,
> +	struct xfs_dir2_sf_hdr	*oldsfp)
> +{
> +	int			i;
> +	struct xfs_dir2_sf_entry *sfep;		/* new sf entry */
> +	struct xfs_dir2_sf_entry *oldsfep;	/* old sf entry */
> +
> +	/*
> +	 * Copy the entries field by field.
> +	 */
> +	for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp),
> +		    oldsfep = xfs_dir2_sf_firstentry(oldsfp);
> +	     i < sfp->count;
> +	     i++, sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep),
> +		  oldsfep = xfs_dir2_sf_nextentry(mp, oldsfp, oldsfep)) {
> +		sfep->namelen = oldsfep->namelen;
> +		memcpy(sfep->offset, oldsfep->offset, sizeof(sfep->offset));
> +		memcpy(sfep->name, oldsfep->name, sfep->namelen);
> +		xfs_dir2_sf_put_ino(mp, sfp, sfep,
> +				xfs_dir2_sf_get_ino(mp, oldsfp, oldsfep));
> +		xfs_dir2_sf_put_ftype(mp, sfep,
> +				xfs_dir2_sf_get_ftype(mp, oldsfep));
> +	}
> +}
> +
>  /*
>   * Convert from 8-byte inode numbers to 4-byte inode numbers.
>   * The last 8-byte inode number is gone, but the count is still 1.
> @@ -1136,11 +1164,8 @@ xfs_dir2_sf_toino4(
>  	struct xfs_mount	*mp = dp->i_mount;
>  	struct xfs_dir2_sf_hdr	*oldsfp = dp->i_df.if_data;
>  	char			*buf;		/* old dir's buffer */
> -	int			i;		/* entry index */
>  	int			newsize;	/* new inode size */
> -	xfs_dir2_sf_entry_t	*oldsfep;	/* old sf entry */
>  	int			oldsize;	/* old inode size */
> -	xfs_dir2_sf_entry_t	*sfep;		/* new sf entry */
>  	xfs_dir2_sf_hdr_t	*sfp;		/* new sf directory */
>  
>  	trace_xfs_dir2_sf_toino4(args);
> @@ -1171,22 +1196,7 @@ xfs_dir2_sf_toino4(
>  	sfp->count = oldsfp->count;
>  	sfp->i8count = 0;
>  	xfs_dir2_sf_put_parent_ino(sfp, xfs_dir2_sf_get_parent_ino(oldsfp));
> -	/*
> -	 * Copy the entries field by field.
> -	 */
> -	for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp),
> -		    oldsfep = xfs_dir2_sf_firstentry(oldsfp);
> -	     i < sfp->count;
> -	     i++, sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep),
> -		  oldsfep = xfs_dir2_sf_nextentry(mp, oldsfp, oldsfep)) {
> -		sfep->namelen = oldsfep->namelen;
> -		memcpy(sfep->offset, oldsfep->offset, sizeof(sfep->offset));
> -		memcpy(sfep->name, oldsfep->name, sfep->namelen);
> -		xfs_dir2_sf_put_ino(mp, sfp, sfep,
> -				xfs_dir2_sf_get_ino(mp, oldsfp, oldsfep));
> -		xfs_dir2_sf_put_ftype(mp, sfep,
> -				xfs_dir2_sf_get_ftype(mp, oldsfep));
> -	}
> +	xfs_dir2_sf_copy_entries(mp, sfp, oldsfp);
>  	/*
>  	 * Clean up the inode.
>  	 */
> @@ -1208,11 +1218,8 @@ xfs_dir2_sf_toino8(
>  	struct xfs_mount	*mp = dp->i_mount;
>  	struct xfs_dir2_sf_hdr	*oldsfp = dp->i_df.if_data;
>  	char			*buf;		/* old dir's buffer */
> -	int			i;		/* entry index */
>  	int			newsize;	/* new inode size */
> -	xfs_dir2_sf_entry_t	*oldsfep;	/* old sf entry */
>  	int			oldsize;	/* old inode size */
> -	xfs_dir2_sf_entry_t	*sfep;		/* new sf entry */
>  	xfs_dir2_sf_hdr_t	*sfp;		/* new sf directory */
>  
>  	trace_xfs_dir2_sf_toino8(args);
> @@ -1243,22 +1250,7 @@ xfs_dir2_sf_toino8(
>  	sfp->count = oldsfp->count;
>  	sfp->i8count = 1;
>  	xfs_dir2_sf_put_parent_ino(sfp, xfs_dir2_sf_get_parent_ino(oldsfp));
> -	/*
> -	 * Copy the entries field by field.
> -	 */
> -	for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp),
> -		    oldsfep = xfs_dir2_sf_firstentry(oldsfp);
> -	     i < sfp->count;
> -	     i++, sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep),
> -		  oldsfep = xfs_dir2_sf_nextentry(mp, oldsfp, oldsfep)) {
> -		sfep->namelen = oldsfep->namelen;
> -		memcpy(sfep->offset, oldsfep->offset, sizeof(sfep->offset));
> -		memcpy(sfep->name, oldsfep->name, sfep->namelen);
> -		xfs_dir2_sf_put_ino(mp, sfp, sfep,
> -				xfs_dir2_sf_get_ino(mp, oldsfp, oldsfep));
> -		xfs_dir2_sf_put_ftype(mp, sfep,
> -				xfs_dir2_sf_get_ftype(mp, oldsfep));
> -	}
> +	xfs_dir2_sf_copy_entries(mp, sfp, oldsfp);
>  	/*
>  	 * Clean up the inode.
>  	 */
> -- 
> 2.55.0
> 
> 

  reply	other threads:[~2026-10-05 12:14 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-02 21:08 [PATCH 0/3] xfs: more misc code deduplication Eric Sandeen
2026-10-02 21:08 ` [PATCH 1/3] xfs: factor out xfs_dir2_sf_copy_entries helper Eric Sandeen
2026-10-05 12:14   ` Carlos Maiolino [this message]
2026-10-07 13:50   ` Christoph Hellwig
2026-10-02 21:08 ` [PATCH 2/3] xfs: factor out xrep_reset_fork_to_extents helper for scrub/repair Eric Sandeen
2026-10-05 13:07   ` Carlos Maiolino
2026-10-05 14:12     ` Eric Sandeen
2026-10-05 19:11   ` [PATCH V2 " Eric Sandeen
2026-10-05 20:20     ` Darrick J. Wong
2026-10-05 20:43       ` Eric Sandeen
2026-10-05 21:17         ` Darrick J. Wong
2026-10-06  8:32           ` Carlos Maiolino
2026-10-07 13:52             ` Christoph Hellwig
2026-10-07 15:25     ` [PATCH V3 " Eric Sandeen
2026-10-08 11:02       ` Carlos Maiolino
2026-10-02 21:08 ` [PATCH 3/3] xfs: re-use refcount scrub/repair code for rtrefcount Eric Sandeen
2026-10-05 20:38   ` Darrick J. Wong
2026-10-06  8:25   ` Carlos Maiolino
2026-10-07 13:51   ` Christoph Hellwig
2026-10-07 15:32     ` Eric Sandeen
2026-10-07 15:37       ` Darrick J. Wong
2026-10-08 11:15         ` Carlos Maiolino
2026-10-08 11:09   ` Carlos Maiolino
2026-10-08 13:32 ` [PATCH 0/3] xfs: more misc code deduplication Carlos Maiolino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=asOUn3CDkcVWdCek@nidhogg.toxiclabs.cc \
    --to=cem@kernel.org \
    --cc=djwong@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.