diff mbox series

[26/34] xfs: devirtualize ->data_entsize

Message ID 20191101220719.29100-27-hch@lst.de (mailing list archive)
State Superseded, archived
Headers show
Series [01/34] xfs: move incore structures out of xfs_da_format.h | expand

Commit Message

Christoph Hellwig Nov. 1, 2019, 10:07 p.m. UTC
Replace the ->data_entsize dir ops method with a directly called
xfs_dir2_data_entsize helper that takes care of the differences between
the directory format with and without the file type field.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/libxfs/xfs_da_format.c  | 22 ++++++++--------------
 fs/xfs/libxfs/xfs_dir2.h       |  3 +--
 fs/xfs/libxfs/xfs_dir2_block.c |  5 +++--
 fs/xfs/libxfs/xfs_dir2_data.c  | 13 ++++++-------
 fs/xfs/libxfs/xfs_dir2_leaf.c  |  5 +++--
 fs/xfs/libxfs/xfs_dir2_node.c  |  7 ++++---
 fs/xfs/libxfs/xfs_dir2_priv.h  |  2 ++
 fs/xfs/libxfs/xfs_dir2_sf.c    | 14 +++++++-------
 fs/xfs/scrub/dir.c             |  4 ++--
 fs/xfs/xfs_dir2_readdir.c      |  9 +++++----
 10 files changed, 41 insertions(+), 43 deletions(-)

Comments

Darrick J. Wong Nov. 4, 2019, 8:45 p.m. UTC | #1
On Fri, Nov 01, 2019 at 03:07:11PM -0700, Christoph Hellwig wrote:
> Replace the ->data_entsize dir ops method with a directly called
> xfs_dir2_data_entsize helper that takes care of the differences between
> the directory format with and without the file type field.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/libxfs/xfs_da_format.c  | 22 ++++++++--------------
>  fs/xfs/libxfs/xfs_dir2.h       |  3 +--
>  fs/xfs/libxfs/xfs_dir2_block.c |  5 +++--
>  fs/xfs/libxfs/xfs_dir2_data.c  | 13 ++++++-------
>  fs/xfs/libxfs/xfs_dir2_leaf.c  |  5 +++--
>  fs/xfs/libxfs/xfs_dir2_node.c  |  7 ++++---
>  fs/xfs/libxfs/xfs_dir2_priv.h  |  2 ++
>  fs/xfs/libxfs/xfs_dir2_sf.c    | 14 +++++++-------
>  fs/xfs/scrub/dir.c             |  4 ++--
>  fs/xfs/xfs_dir2_readdir.c      |  9 +++++----
>  10 files changed, 41 insertions(+), 43 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_da_format.c b/fs/xfs/libxfs/xfs_da_format.c
> index 47c56f6dd872..bbff0e7822b8 100644
> --- a/fs/xfs/libxfs/xfs_da_format.c
> +++ b/fs/xfs/libxfs/xfs_da_format.c
> @@ -41,18 +41,15 @@
>  		 sizeof(xfs_dir2_data_off_t) + sizeof(uint8_t)),	\
>  		XFS_DIR2_DATA_ALIGN)
>  
> -static int
> +int
>  xfs_dir2_data_entsize(
> +	struct xfs_mount	*mp,
>  	int			n)

@namelen, not just @n?

Oh, you do change that later.

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

>  {
> -	return XFS_DIR2_DATA_ENTSIZE(n);
> -}
> -
> -static int
> -xfs_dir3_data_entsize(
> -	int			n)
> -{
> -	return XFS_DIR3_DATA_ENTSIZE(n);
> +	if (xfs_sb_version_hasftype(&mp->m_sb))
> +		return XFS_DIR3_DATA_ENTSIZE(n);
> +	else
> +		return XFS_DIR2_DATA_ENTSIZE(n);
>  }
>  
>  static uint8_t
> @@ -100,7 +97,7 @@ xfs_dir2_data_entry_tag_p(
>  	struct xfs_dir2_data_entry *dep)
>  {
>  	return (__be16 *)((char *)dep +
> -		xfs_dir2_data_entsize(dep->namelen) - sizeof(__be16));
> +		XFS_DIR2_DATA_ENTSIZE(dep->namelen) - sizeof(__be16));
>  }
>  
>  static __be16 *
> @@ -108,7 +105,7 @@ xfs_dir3_data_entry_tag_p(
>  	struct xfs_dir2_data_entry *dep)
>  {
>  	return (__be16 *)((char *)dep +
> -		xfs_dir3_data_entsize(dep->namelen) - sizeof(__be16));
> +		XFS_DIR3_DATA_ENTSIZE(dep->namelen) - sizeof(__be16));
>  }
>  
>  static struct xfs_dir2_data_free *
> @@ -124,7 +121,6 @@ xfs_dir3_data_bestfree_p(struct xfs_dir2_data_hdr *hdr)
>  }
>  
>  static const struct xfs_dir_ops xfs_dir2_ops = {
> -	.data_entsize = xfs_dir2_data_entsize,
>  	.data_get_ftype = xfs_dir2_data_get_ftype,
>  	.data_put_ftype = xfs_dir2_data_put_ftype,
>  	.data_entry_tag_p = xfs_dir2_data_entry_tag_p,
> @@ -140,7 +136,6 @@ static const struct xfs_dir_ops xfs_dir2_ops = {
>  };
>  
>  static const struct xfs_dir_ops xfs_dir2_ftype_ops = {
> -	.data_entsize = xfs_dir3_data_entsize,
>  	.data_get_ftype = xfs_dir3_data_get_ftype,
>  	.data_put_ftype = xfs_dir3_data_put_ftype,
>  	.data_entry_tag_p = xfs_dir3_data_entry_tag_p,
> @@ -156,7 +151,6 @@ static const struct xfs_dir_ops xfs_dir2_ftype_ops = {
>  };
>  
>  static const struct xfs_dir_ops xfs_dir3_ops = {
> -	.data_entsize = xfs_dir3_data_entsize,
>  	.data_get_ftype = xfs_dir3_data_get_ftype,
>  	.data_put_ftype = xfs_dir3_data_put_ftype,
>  	.data_entry_tag_p = xfs_dir3_data_entry_tag_p,
> diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h
> index e9de15e62630..3fb2c514437a 100644
> --- a/fs/xfs/libxfs/xfs_dir2.h
> +++ b/fs/xfs/libxfs/xfs_dir2.h
> @@ -32,7 +32,6 @@ extern unsigned char xfs_mode_to_ftype(int mode);
>   * directory operations vector for encode/decode routines
>   */
>  struct xfs_dir_ops {
> -	int	(*data_entsize)(int len);
>  	uint8_t (*data_get_ftype)(struct xfs_dir2_data_entry *dep);
>  	void	(*data_put_ftype)(struct xfs_dir2_data_entry *dep,
>  				uint8_t ftype);
> @@ -87,7 +86,7 @@ extern int xfs_dir2_isleaf(struct xfs_da_args *args, int *r);
>  extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db,
>  				struct xfs_buf *bp);
>  
> -extern void xfs_dir2_data_freescan_int(struct xfs_da_geometry *geo,
> +extern void xfs_dir2_data_freescan_int(struct xfs_mount *mp,
>  		const struct xfs_dir_ops *ops,
>  		struct xfs_dir2_data_hdr *hdr, int *loghead);
>  extern void xfs_dir2_data_freescan(struct xfs_inode *dp,
> diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
> index b32beb71b7b2..709423199369 100644
> --- a/fs/xfs/libxfs/xfs_dir2_block.c
> +++ b/fs/xfs/libxfs/xfs_dir2_block.c
> @@ -355,7 +355,7 @@ xfs_dir2_block_addname(
>  	if (error)
>  		return error;
>  
> -	len = dp->d_ops->data_entsize(args->namelen);
> +	len = xfs_dir2_data_entsize(dp->i_mount, args->namelen);
>  
>  	/*
>  	 * Set up pointers to parts of the block.
> @@ -791,7 +791,8 @@ xfs_dir2_block_removename(
>  	needlog = needscan = 0;
>  	xfs_dir2_data_make_free(args, bp,
>  		(xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr),
> -		dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan);
> +		xfs_dir2_data_entsize(dp->i_mount, dep->namelen), &needlog,
> +		&needscan);
>  	/*
>  	 * Fix up the block tail.
>  	 */
> diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
> index edb3fe5c9174..7e3d35f0cdb5 100644
> --- a/fs/xfs/libxfs/xfs_dir2_data.c
> +++ b/fs/xfs/libxfs/xfs_dir2_data.c
> @@ -173,7 +173,7 @@ __xfs_dir3_data_check(
>  			return __this_address;
>  		if (xfs_dir_ino_validate(mp, be64_to_cpu(dep->inumber)))
>  			return __this_address;
> -		if (endp < p + ops->data_entsize(dep->namelen))
> +		if (endp < p + xfs_dir2_data_entsize(mp, dep->namelen))
>  			return __this_address;
>  		if (be16_to_cpu(*ops->data_entry_tag_p(dep)) !=
>  		    (char *)dep - (char *)hdr)
> @@ -198,7 +198,7 @@ __xfs_dir3_data_check(
>  			if (i >= be32_to_cpu(btp->count))
>  				return __this_address;
>  		}
> -		p += ops->data_entsize(dep->namelen);
> +		p += xfs_dir2_data_entsize(mp, dep->namelen);
>  	}
>  	/*
>  	 * Need to have seen all the entries and all the bestfree slots.
> @@ -562,7 +562,7 @@ xfs_dir2_data_freeremove(
>   */
>  void
>  xfs_dir2_data_freescan_int(
> -	struct xfs_da_geometry	*geo,
> +	struct xfs_mount	*mp,
>  	const struct xfs_dir_ops *ops,
>  	struct xfs_dir2_data_hdr *hdr,
>  	int			*loghead)
> @@ -588,7 +588,7 @@ xfs_dir2_data_freescan_int(
>  	 * Set up pointers.
>  	 */
>  	p = (char *)hdr + ops->data_entry_offset;
> -	endp = xfs_dir3_data_endp(geo, hdr);
> +	endp = xfs_dir3_data_endp(mp->m_dir_geo, hdr);
>  	/*
>  	 * Loop over the block's entries.
>  	 */
> @@ -610,7 +610,7 @@ xfs_dir2_data_freescan_int(
>  			dep = (xfs_dir2_data_entry_t *)p;
>  			ASSERT((char *)dep - (char *)hdr ==
>  			       be16_to_cpu(*ops->data_entry_tag_p(dep)));
> -			p += ops->data_entsize(dep->namelen);
> +			p += xfs_dir2_data_entsize(mp, dep->namelen);
>  		}
>  	}
>  }
> @@ -621,8 +621,7 @@ xfs_dir2_data_freescan(
>  	struct xfs_dir2_data_hdr *hdr,
>  	int			*loghead)
>  {
> -	return xfs_dir2_data_freescan_int(dp->i_mount->m_dir_geo, dp->d_ops,
> -			hdr, loghead);
> +	return xfs_dir2_data_freescan_int(dp->i_mount, dp->d_ops, hdr, loghead);
>  }
>  
>  /*
> diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
> index 3770107c0695..2f7eda3008a6 100644
> --- a/fs/xfs/libxfs/xfs_dir2_leaf.c
> +++ b/fs/xfs/libxfs/xfs_dir2_leaf.c
> @@ -660,7 +660,7 @@ xfs_dir2_leaf_addname(
>  	xfs_dir2_leaf_hdr_from_disk(dp->i_mount, &leafhdr, leaf);
>  	ents = leafhdr.ents;
>  	bestsp = xfs_dir2_leaf_bests_p(ltp);
> -	length = dp->d_ops->data_entsize(args->namelen);
> +	length = xfs_dir2_data_entsize(dp->i_mount, args->namelen);
>  
>  	/*
>  	 * See if there are any entries with the same hash value
> @@ -1395,7 +1395,8 @@ xfs_dir2_leaf_removename(
>  	 */
>  	xfs_dir2_data_make_free(args, dbp,
>  		(xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr),
> -		dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan);
> +		xfs_dir2_data_entsize(dp->i_mount, dep->namelen), &needlog,
> +		&needscan);
>  	/*
>  	 * We just mark the leaf entry stale by putting a null in it.
>  	 */
> diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
> index ceb5936b58dd..d08a11121dee 100644
> --- a/fs/xfs/libxfs/xfs_dir2_node.c
> +++ b/fs/xfs/libxfs/xfs_dir2_node.c
> @@ -662,7 +662,7 @@ xfs_dir2_leafn_lookup_for_addname(
>  		ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) ||
>  		       free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC));
>  	}
> -	length = dp->d_ops->data_entsize(args->namelen);
> +	length = xfs_dir2_data_entsize(mp, args->namelen);
>  	/*
>  	 * Loop over leaf entries with the right hash value.
>  	 */
> @@ -1314,7 +1314,8 @@ xfs_dir2_leafn_remove(
>  	longest = be16_to_cpu(bf[0].length);
>  	needlog = needscan = 0;
>  	xfs_dir2_data_make_free(args, dbp, off,
> -		dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan);
> +		xfs_dir2_data_entsize(dp->i_mount, dep->namelen), &needlog,
> +		&needscan);
>  	/*
>  	 * Rescan the data block freespaces for bestfree.
>  	 * Log the data block header if needed.
> @@ -1907,7 +1908,7 @@ xfs_dir2_node_addname_int(
>  	int			needscan = 0;	/* need to rescan data frees */
>  	__be16			*tagp;		/* data entry tag pointer */
>  
> -	length = dp->d_ops->data_entsize(args->namelen);
> +	length = xfs_dir2_data_entsize(dp->i_mount, args->namelen);
>  	error = xfs_dir2_node_find_freeblk(args, fblk, &dbno, &fbp, &freehdr,
>  					   &findex, length);
>  	if (error)
> diff --git a/fs/xfs/libxfs/xfs_dir2_priv.h b/fs/xfs/libxfs/xfs_dir2_priv.h
> index a92d9f0f83e0..585b7b42c204 100644
> --- a/fs/xfs/libxfs/xfs_dir2_priv.h
> +++ b/fs/xfs/libxfs/xfs_dir2_priv.h
> @@ -47,6 +47,8 @@ extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args,
>  		struct xfs_buf *lbp, struct xfs_buf *dbp);
>  
>  /* xfs_dir2_data.c */
> +int xfs_dir2_data_entsize(struct xfs_mount *mp, int n);
> +
>  #ifdef DEBUG
>  extern void xfs_dir3_data_check(struct xfs_inode *dp, struct xfs_buf *bp);
>  #else
> diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
> index b2c6c492b09d..4885a0e920c5 100644
> --- a/fs/xfs/libxfs/xfs_dir2_sf.c
> +++ b/fs/xfs/libxfs/xfs_dir2_sf.c
> @@ -341,7 +341,7 @@ xfs_dir2_block_to_sf(
>  
>  			sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
>  		}
> -		ptr += dp->d_ops->data_entsize(dep->namelen);
> +		ptr += xfs_dir2_data_entsize(mp, dep->namelen);
>  	}
>  	ASSERT((char *)sfep - (char *)sfp == size);
>  
> @@ -564,10 +564,10 @@ xfs_dir2_sf_addname_hard(
>  	 */
>  	for (offset = dp->d_ops->data_first_offset,
>  	      oldsfep = xfs_dir2_sf_firstentry(oldsfp),
> -	      add_datasize = dp->d_ops->data_entsize(args->namelen),
> +	      add_datasize = xfs_dir2_data_entsize(mp, args->namelen),
>  	      eof = (char *)oldsfep == &buf[old_isize];
>  	     !eof;
> -	     offset = new_offset + dp->d_ops->data_entsize(oldsfep->namelen),
> +	     offset = new_offset + xfs_dir2_data_entsize(mp, oldsfep->namelen),
>  	      oldsfep = xfs_dir2_sf_nextentry(mp, oldsfp, oldsfep),
>  	      eof = (char *)oldsfep == &buf[old_isize]) {
>  		new_offset = xfs_dir2_sf_get_offset(oldsfep);
> @@ -639,7 +639,7 @@ xfs_dir2_sf_addname_pick(
>  	int			used;		/* data bytes used */
>  
>  	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
> -	size = dp->d_ops->data_entsize(args->namelen);
> +	size = xfs_dir2_data_entsize(mp, args->namelen);
>  	offset = dp->d_ops->data_first_offset;
>  	sfep = xfs_dir2_sf_firstentry(sfp);
>  	holefit = 0;
> @@ -652,7 +652,7 @@ xfs_dir2_sf_addname_pick(
>  		if (!holefit)
>  			holefit = offset + size <= xfs_dir2_sf_get_offset(sfep);
>  		offset = xfs_dir2_sf_get_offset(sfep) +
> -			 dp->d_ops->data_entsize(sfep->namelen);
> +			 xfs_dir2_data_entsize(mp, sfep->namelen);
>  		sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
>  	}
>  	/*
> @@ -717,7 +717,7 @@ xfs_dir2_sf_check(
>  		i8count += ino > XFS_DIR2_MAX_SHORT_INUM;
>  		offset =
>  			xfs_dir2_sf_get_offset(sfep) +
> -			dp->d_ops->data_entsize(sfep->namelen);
> +			xfs_dir2_data_entsize(mp, sfep->namelen);
>  		ASSERT(xfs_dir2_sf_get_ftype(mp, sfep) < XFS_DIR3_FT_MAX);
>  	}
>  	ASSERT(i8count == sfp->i8count);
> @@ -817,7 +817,7 @@ xfs_dir2_sf_verify(
>  			return __this_address;
>  
>  		offset = xfs_dir2_sf_get_offset(sfep) +
> -				dops->data_entsize(sfep->namelen);
> +				xfs_dir2_data_entsize(mp, sfep->namelen);
>  
>  		sfep = next_sfep;
>  	}
> diff --git a/fs/xfs/scrub/dir.c b/fs/xfs/scrub/dir.c
> index 8d6ecfe09611..5ddd95f12b85 100644
> --- a/fs/xfs/scrub/dir.c
> +++ b/fs/xfs/scrub/dir.c
> @@ -259,7 +259,7 @@ xchk_dir_rec(
>  		dep = (struct xfs_dir2_data_entry *)p;
>  		if (dep == dent)
>  			break;
> -		p += mp->m_dir_inode_ops->data_entsize(dep->namelen);
> +		p += xfs_dir2_data_entsize(mp, dep->namelen);
>  	}
>  	if (p >= endp) {
>  		xchk_fblock_set_corrupt(ds->sc, XFS_DATA_FORK, rec_bno);
> @@ -402,7 +402,7 @@ xchk_directory_data_bestfree(
>  			struct xfs_dir2_data_entry	*dep;
>  
>  			dep = (struct xfs_dir2_data_entry *)ptr;
> -			newlen = d_ops->data_entsize(dep->namelen);
> +			newlen = xfs_dir2_data_entsize(mp, dep->namelen);
>  			if (newlen <= 0) {
>  				xchk_fblock_set_corrupt(sc, XFS_DATA_FORK,
>  						lblk);
> diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
> index 04f8c2451b93..4cc4102c85f0 100644
> --- a/fs/xfs/xfs_dir2_readdir.c
> +++ b/fs/xfs/xfs_dir2_readdir.c
> @@ -200,7 +200,7 @@ xfs_dir2_block_getdents(
>  		/*
>  		 * Bump pointer for the next iteration.
>  		 */
> -		ptr += dp->d_ops->data_entsize(dep->namelen);
> +		ptr += xfs_dir2_data_entsize(dp->i_mount, dep->namelen);
>  		/*
>  		 * The entry is before the desired starting point, skip it.
>  		 */
> @@ -355,6 +355,7 @@ xfs_dir2_leaf_getdents(
>  	size_t			bufsize)
>  {
>  	struct xfs_inode	*dp = args->dp;
> +	struct xfs_mount	*mp = dp->i_mount;
>  	struct xfs_buf		*bp = NULL;	/* data block buffer */
>  	xfs_dir2_data_hdr_t	*hdr;		/* data block header */
>  	xfs_dir2_data_entry_t	*dep;		/* data entry */
> @@ -432,8 +433,8 @@ xfs_dir2_leaf_getdents(
>  						continue;
>  					}
>  					dep = (xfs_dir2_data_entry_t *)ptr;
> -					length =
> -					   dp->d_ops->data_entsize(dep->namelen);
> +					length = xfs_dir2_data_entsize(mp,
> +							dep->namelen);
>  					ptr += length;
>  				}
>  				/*
> @@ -464,7 +465,7 @@ xfs_dir2_leaf_getdents(
>  		}
>  
>  		dep = (xfs_dir2_data_entry_t *)ptr;
> -		length = dp->d_ops->data_entsize(dep->namelen);
> +		length = xfs_dir2_data_entsize(mp, dep->namelen);
>  		filetype = dp->d_ops->data_get_ftype(dep);
>  
>  		ctx->pos = xfs_dir2_byte_to_dataptr(curoff) & 0x7fffffff;
> -- 
> 2.20.1
>
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_da_format.c b/fs/xfs/libxfs/xfs_da_format.c
index 47c56f6dd872..bbff0e7822b8 100644
--- a/fs/xfs/libxfs/xfs_da_format.c
+++ b/fs/xfs/libxfs/xfs_da_format.c
@@ -41,18 +41,15 @@ 
 		 sizeof(xfs_dir2_data_off_t) + sizeof(uint8_t)),	\
 		XFS_DIR2_DATA_ALIGN)
 
-static int
+int
 xfs_dir2_data_entsize(
+	struct xfs_mount	*mp,
 	int			n)
 {
-	return XFS_DIR2_DATA_ENTSIZE(n);
-}
-
-static int
-xfs_dir3_data_entsize(
-	int			n)
-{
-	return XFS_DIR3_DATA_ENTSIZE(n);
+	if (xfs_sb_version_hasftype(&mp->m_sb))
+		return XFS_DIR3_DATA_ENTSIZE(n);
+	else
+		return XFS_DIR2_DATA_ENTSIZE(n);
 }
 
 static uint8_t
@@ -100,7 +97,7 @@  xfs_dir2_data_entry_tag_p(
 	struct xfs_dir2_data_entry *dep)
 {
 	return (__be16 *)((char *)dep +
-		xfs_dir2_data_entsize(dep->namelen) - sizeof(__be16));
+		XFS_DIR2_DATA_ENTSIZE(dep->namelen) - sizeof(__be16));
 }
 
 static __be16 *
@@ -108,7 +105,7 @@  xfs_dir3_data_entry_tag_p(
 	struct xfs_dir2_data_entry *dep)
 {
 	return (__be16 *)((char *)dep +
-		xfs_dir3_data_entsize(dep->namelen) - sizeof(__be16));
+		XFS_DIR3_DATA_ENTSIZE(dep->namelen) - sizeof(__be16));
 }
 
 static struct xfs_dir2_data_free *
@@ -124,7 +121,6 @@  xfs_dir3_data_bestfree_p(struct xfs_dir2_data_hdr *hdr)
 }
 
 static const struct xfs_dir_ops xfs_dir2_ops = {
-	.data_entsize = xfs_dir2_data_entsize,
 	.data_get_ftype = xfs_dir2_data_get_ftype,
 	.data_put_ftype = xfs_dir2_data_put_ftype,
 	.data_entry_tag_p = xfs_dir2_data_entry_tag_p,
@@ -140,7 +136,6 @@  static const struct xfs_dir_ops xfs_dir2_ops = {
 };
 
 static const struct xfs_dir_ops xfs_dir2_ftype_ops = {
-	.data_entsize = xfs_dir3_data_entsize,
 	.data_get_ftype = xfs_dir3_data_get_ftype,
 	.data_put_ftype = xfs_dir3_data_put_ftype,
 	.data_entry_tag_p = xfs_dir3_data_entry_tag_p,
@@ -156,7 +151,6 @@  static const struct xfs_dir_ops xfs_dir2_ftype_ops = {
 };
 
 static const struct xfs_dir_ops xfs_dir3_ops = {
-	.data_entsize = xfs_dir3_data_entsize,
 	.data_get_ftype = xfs_dir3_data_get_ftype,
 	.data_put_ftype = xfs_dir3_data_put_ftype,
 	.data_entry_tag_p = xfs_dir3_data_entry_tag_p,
diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h
index e9de15e62630..3fb2c514437a 100644
--- a/fs/xfs/libxfs/xfs_dir2.h
+++ b/fs/xfs/libxfs/xfs_dir2.h
@@ -32,7 +32,6 @@  extern unsigned char xfs_mode_to_ftype(int mode);
  * directory operations vector for encode/decode routines
  */
 struct xfs_dir_ops {
-	int	(*data_entsize)(int len);
 	uint8_t (*data_get_ftype)(struct xfs_dir2_data_entry *dep);
 	void	(*data_put_ftype)(struct xfs_dir2_data_entry *dep,
 				uint8_t ftype);
@@ -87,7 +86,7 @@  extern int xfs_dir2_isleaf(struct xfs_da_args *args, int *r);
 extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db,
 				struct xfs_buf *bp);
 
-extern void xfs_dir2_data_freescan_int(struct xfs_da_geometry *geo,
+extern void xfs_dir2_data_freescan_int(struct xfs_mount *mp,
 		const struct xfs_dir_ops *ops,
 		struct xfs_dir2_data_hdr *hdr, int *loghead);
 extern void xfs_dir2_data_freescan(struct xfs_inode *dp,
diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
index b32beb71b7b2..709423199369 100644
--- a/fs/xfs/libxfs/xfs_dir2_block.c
+++ b/fs/xfs/libxfs/xfs_dir2_block.c
@@ -355,7 +355,7 @@  xfs_dir2_block_addname(
 	if (error)
 		return error;
 
-	len = dp->d_ops->data_entsize(args->namelen);
+	len = xfs_dir2_data_entsize(dp->i_mount, args->namelen);
 
 	/*
 	 * Set up pointers to parts of the block.
@@ -791,7 +791,8 @@  xfs_dir2_block_removename(
 	needlog = needscan = 0;
 	xfs_dir2_data_make_free(args, bp,
 		(xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr),
-		dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan);
+		xfs_dir2_data_entsize(dp->i_mount, dep->namelen), &needlog,
+		&needscan);
 	/*
 	 * Fix up the block tail.
 	 */
diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
index edb3fe5c9174..7e3d35f0cdb5 100644
--- a/fs/xfs/libxfs/xfs_dir2_data.c
+++ b/fs/xfs/libxfs/xfs_dir2_data.c
@@ -173,7 +173,7 @@  __xfs_dir3_data_check(
 			return __this_address;
 		if (xfs_dir_ino_validate(mp, be64_to_cpu(dep->inumber)))
 			return __this_address;
-		if (endp < p + ops->data_entsize(dep->namelen))
+		if (endp < p + xfs_dir2_data_entsize(mp, dep->namelen))
 			return __this_address;
 		if (be16_to_cpu(*ops->data_entry_tag_p(dep)) !=
 		    (char *)dep - (char *)hdr)
@@ -198,7 +198,7 @@  __xfs_dir3_data_check(
 			if (i >= be32_to_cpu(btp->count))
 				return __this_address;
 		}
-		p += ops->data_entsize(dep->namelen);
+		p += xfs_dir2_data_entsize(mp, dep->namelen);
 	}
 	/*
 	 * Need to have seen all the entries and all the bestfree slots.
@@ -562,7 +562,7 @@  xfs_dir2_data_freeremove(
  */
 void
 xfs_dir2_data_freescan_int(
-	struct xfs_da_geometry	*geo,
+	struct xfs_mount	*mp,
 	const struct xfs_dir_ops *ops,
 	struct xfs_dir2_data_hdr *hdr,
 	int			*loghead)
@@ -588,7 +588,7 @@  xfs_dir2_data_freescan_int(
 	 * Set up pointers.
 	 */
 	p = (char *)hdr + ops->data_entry_offset;
-	endp = xfs_dir3_data_endp(geo, hdr);
+	endp = xfs_dir3_data_endp(mp->m_dir_geo, hdr);
 	/*
 	 * Loop over the block's entries.
 	 */
@@ -610,7 +610,7 @@  xfs_dir2_data_freescan_int(
 			dep = (xfs_dir2_data_entry_t *)p;
 			ASSERT((char *)dep - (char *)hdr ==
 			       be16_to_cpu(*ops->data_entry_tag_p(dep)));
-			p += ops->data_entsize(dep->namelen);
+			p += xfs_dir2_data_entsize(mp, dep->namelen);
 		}
 	}
 }
@@ -621,8 +621,7 @@  xfs_dir2_data_freescan(
 	struct xfs_dir2_data_hdr *hdr,
 	int			*loghead)
 {
-	return xfs_dir2_data_freescan_int(dp->i_mount->m_dir_geo, dp->d_ops,
-			hdr, loghead);
+	return xfs_dir2_data_freescan_int(dp->i_mount, dp->d_ops, hdr, loghead);
 }
 
 /*
diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
index 3770107c0695..2f7eda3008a6 100644
--- a/fs/xfs/libxfs/xfs_dir2_leaf.c
+++ b/fs/xfs/libxfs/xfs_dir2_leaf.c
@@ -660,7 +660,7 @@  xfs_dir2_leaf_addname(
 	xfs_dir2_leaf_hdr_from_disk(dp->i_mount, &leafhdr, leaf);
 	ents = leafhdr.ents;
 	bestsp = xfs_dir2_leaf_bests_p(ltp);
-	length = dp->d_ops->data_entsize(args->namelen);
+	length = xfs_dir2_data_entsize(dp->i_mount, args->namelen);
 
 	/*
 	 * See if there are any entries with the same hash value
@@ -1395,7 +1395,8 @@  xfs_dir2_leaf_removename(
 	 */
 	xfs_dir2_data_make_free(args, dbp,
 		(xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr),
-		dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan);
+		xfs_dir2_data_entsize(dp->i_mount, dep->namelen), &needlog,
+		&needscan);
 	/*
 	 * We just mark the leaf entry stale by putting a null in it.
 	 */
diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
index ceb5936b58dd..d08a11121dee 100644
--- a/fs/xfs/libxfs/xfs_dir2_node.c
+++ b/fs/xfs/libxfs/xfs_dir2_node.c
@@ -662,7 +662,7 @@  xfs_dir2_leafn_lookup_for_addname(
 		ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) ||
 		       free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC));
 	}
-	length = dp->d_ops->data_entsize(args->namelen);
+	length = xfs_dir2_data_entsize(mp, args->namelen);
 	/*
 	 * Loop over leaf entries with the right hash value.
 	 */
@@ -1314,7 +1314,8 @@  xfs_dir2_leafn_remove(
 	longest = be16_to_cpu(bf[0].length);
 	needlog = needscan = 0;
 	xfs_dir2_data_make_free(args, dbp, off,
-		dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan);
+		xfs_dir2_data_entsize(dp->i_mount, dep->namelen), &needlog,
+		&needscan);
 	/*
 	 * Rescan the data block freespaces for bestfree.
 	 * Log the data block header if needed.
@@ -1907,7 +1908,7 @@  xfs_dir2_node_addname_int(
 	int			needscan = 0;	/* need to rescan data frees */
 	__be16			*tagp;		/* data entry tag pointer */
 
-	length = dp->d_ops->data_entsize(args->namelen);
+	length = xfs_dir2_data_entsize(dp->i_mount, args->namelen);
 	error = xfs_dir2_node_find_freeblk(args, fblk, &dbno, &fbp, &freehdr,
 					   &findex, length);
 	if (error)
diff --git a/fs/xfs/libxfs/xfs_dir2_priv.h b/fs/xfs/libxfs/xfs_dir2_priv.h
index a92d9f0f83e0..585b7b42c204 100644
--- a/fs/xfs/libxfs/xfs_dir2_priv.h
+++ b/fs/xfs/libxfs/xfs_dir2_priv.h
@@ -47,6 +47,8 @@  extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args,
 		struct xfs_buf *lbp, struct xfs_buf *dbp);
 
 /* xfs_dir2_data.c */
+int xfs_dir2_data_entsize(struct xfs_mount *mp, int n);
+
 #ifdef DEBUG
 extern void xfs_dir3_data_check(struct xfs_inode *dp, struct xfs_buf *bp);
 #else
diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
index b2c6c492b09d..4885a0e920c5 100644
--- a/fs/xfs/libxfs/xfs_dir2_sf.c
+++ b/fs/xfs/libxfs/xfs_dir2_sf.c
@@ -341,7 +341,7 @@  xfs_dir2_block_to_sf(
 
 			sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
 		}
-		ptr += dp->d_ops->data_entsize(dep->namelen);
+		ptr += xfs_dir2_data_entsize(mp, dep->namelen);
 	}
 	ASSERT((char *)sfep - (char *)sfp == size);
 
@@ -564,10 +564,10 @@  xfs_dir2_sf_addname_hard(
 	 */
 	for (offset = dp->d_ops->data_first_offset,
 	      oldsfep = xfs_dir2_sf_firstentry(oldsfp),
-	      add_datasize = dp->d_ops->data_entsize(args->namelen),
+	      add_datasize = xfs_dir2_data_entsize(mp, args->namelen),
 	      eof = (char *)oldsfep == &buf[old_isize];
 	     !eof;
-	     offset = new_offset + dp->d_ops->data_entsize(oldsfep->namelen),
+	     offset = new_offset + xfs_dir2_data_entsize(mp, oldsfep->namelen),
 	      oldsfep = xfs_dir2_sf_nextentry(mp, oldsfp, oldsfep),
 	      eof = (char *)oldsfep == &buf[old_isize]) {
 		new_offset = xfs_dir2_sf_get_offset(oldsfep);
@@ -639,7 +639,7 @@  xfs_dir2_sf_addname_pick(
 	int			used;		/* data bytes used */
 
 	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
-	size = dp->d_ops->data_entsize(args->namelen);
+	size = xfs_dir2_data_entsize(mp, args->namelen);
 	offset = dp->d_ops->data_first_offset;
 	sfep = xfs_dir2_sf_firstentry(sfp);
 	holefit = 0;
@@ -652,7 +652,7 @@  xfs_dir2_sf_addname_pick(
 		if (!holefit)
 			holefit = offset + size <= xfs_dir2_sf_get_offset(sfep);
 		offset = xfs_dir2_sf_get_offset(sfep) +
-			 dp->d_ops->data_entsize(sfep->namelen);
+			 xfs_dir2_data_entsize(mp, sfep->namelen);
 		sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep);
 	}
 	/*
@@ -717,7 +717,7 @@  xfs_dir2_sf_check(
 		i8count += ino > XFS_DIR2_MAX_SHORT_INUM;
 		offset =
 			xfs_dir2_sf_get_offset(sfep) +
-			dp->d_ops->data_entsize(sfep->namelen);
+			xfs_dir2_data_entsize(mp, sfep->namelen);
 		ASSERT(xfs_dir2_sf_get_ftype(mp, sfep) < XFS_DIR3_FT_MAX);
 	}
 	ASSERT(i8count == sfp->i8count);
@@ -817,7 +817,7 @@  xfs_dir2_sf_verify(
 			return __this_address;
 
 		offset = xfs_dir2_sf_get_offset(sfep) +
-				dops->data_entsize(sfep->namelen);
+				xfs_dir2_data_entsize(mp, sfep->namelen);
 
 		sfep = next_sfep;
 	}
diff --git a/fs/xfs/scrub/dir.c b/fs/xfs/scrub/dir.c
index 8d6ecfe09611..5ddd95f12b85 100644
--- a/fs/xfs/scrub/dir.c
+++ b/fs/xfs/scrub/dir.c
@@ -259,7 +259,7 @@  xchk_dir_rec(
 		dep = (struct xfs_dir2_data_entry *)p;
 		if (dep == dent)
 			break;
-		p += mp->m_dir_inode_ops->data_entsize(dep->namelen);
+		p += xfs_dir2_data_entsize(mp, dep->namelen);
 	}
 	if (p >= endp) {
 		xchk_fblock_set_corrupt(ds->sc, XFS_DATA_FORK, rec_bno);
@@ -402,7 +402,7 @@  xchk_directory_data_bestfree(
 			struct xfs_dir2_data_entry	*dep;
 
 			dep = (struct xfs_dir2_data_entry *)ptr;
-			newlen = d_ops->data_entsize(dep->namelen);
+			newlen = xfs_dir2_data_entsize(mp, dep->namelen);
 			if (newlen <= 0) {
 				xchk_fblock_set_corrupt(sc, XFS_DATA_FORK,
 						lblk);
diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
index 04f8c2451b93..4cc4102c85f0 100644
--- a/fs/xfs/xfs_dir2_readdir.c
+++ b/fs/xfs/xfs_dir2_readdir.c
@@ -200,7 +200,7 @@  xfs_dir2_block_getdents(
 		/*
 		 * Bump pointer for the next iteration.
 		 */
-		ptr += dp->d_ops->data_entsize(dep->namelen);
+		ptr += xfs_dir2_data_entsize(dp->i_mount, dep->namelen);
 		/*
 		 * The entry is before the desired starting point, skip it.
 		 */
@@ -355,6 +355,7 @@  xfs_dir2_leaf_getdents(
 	size_t			bufsize)
 {
 	struct xfs_inode	*dp = args->dp;
+	struct xfs_mount	*mp = dp->i_mount;
 	struct xfs_buf		*bp = NULL;	/* data block buffer */
 	xfs_dir2_data_hdr_t	*hdr;		/* data block header */
 	xfs_dir2_data_entry_t	*dep;		/* data entry */
@@ -432,8 +433,8 @@  xfs_dir2_leaf_getdents(
 						continue;
 					}
 					dep = (xfs_dir2_data_entry_t *)ptr;
-					length =
-					   dp->d_ops->data_entsize(dep->namelen);
+					length = xfs_dir2_data_entsize(mp,
+							dep->namelen);
 					ptr += length;
 				}
 				/*
@@ -464,7 +465,7 @@  xfs_dir2_leaf_getdents(
 		}
 
 		dep = (xfs_dir2_data_entry_t *)ptr;
-		length = dp->d_ops->data_entsize(dep->namelen);
+		length = xfs_dir2_data_entsize(mp, dep->namelen);
 		filetype = dp->d_ops->data_get_ftype(dep);
 
 		ctx->pos = xfs_dir2_byte_to_dataptr(curoff) & 0x7fffffff;