remove m_dirops
PATCH 30/34 xfs: devirtualize ->data_bestfree_p
In reply to Christoph HellwigReplace the ->data_bestfree_p dir ops method with a directly called xfs_dir2_data_bestfree_p helper that takes care of the differences between the v4 and v5 on-disk format.
--- fs/xfs/libxfs/xfs_da_format.c | 15 --------------- fs/xfs/libxfs/xfs_dir2.h | 3 --- fs/xfs/libxfs/xfs_dir2_block.c | 6 +++--- fs/xfs/libxfs/xfs_dir2_data.c | 23 ++++++++++++++++------- fs/xfs/libxfs/xfs_dir2_leaf.c | 11 ++++++----- fs/xfs/libxfs/xfs_dir2_node.c | 6 +++--- fs/xfs/libxfs/xfs_dir2_priv.h | 2 ++ fs/xfs/scrub/dir.c | 7 ++----- 8 files changed, 32 insertions(+), 41 deletions(-)
fs/xfs/libxfs/xfs_da_format.c +0 -15
@@ -56,34 +56,19 @@ xfs_dir3_data_put_ftype( dep->name[dep->namelen] = type; } -static struct xfs_dir2_data_free * -xfs_dir2_data_bestfree_p (struct xfs_dir2_data_hdr *hdr) -{ -return hdr->bestfree; -} - -static struct xfs_dir2_data_free * -xfs_dir3_data_bestfree_p (struct xfs_dir2_data_hdr *hdr) -{ -return ((struct xfs_dir3_data_hdr *)hdr)->best_free; -} -static const struct xfs_dir_ops xfs_dir2_ops = { .data_get_ftype = xfs_dir2_data_get_ftype, .data_put_ftype = xfs_dir2_data_put_ftype, - .data_bestfree_p = xfs_dir2_data_bestfree_p, };static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype, - .data_bestfree_p = xfs_dir2_data_bestfree_p, };static const struct xfs_dir_ops xfs_dir3_ops = { .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype, - .data_bestfree_p = xfs_dir3_data_bestfree_p, };/*
fs/xfs/libxfs/xfs_dir2.h +0 -3
@@ -35,8 +35,6 @@ struct xfs_dir_ops {uint8_t (*data_get_ftype)(struct xfs_dir2_data_entry *dep);void (*data_put_ftype)(struct xfs_dir2_data_entry *dep,uint8_t ftype); -struct xfs_dir2_data_free * - (*data_bestfree_p)(struct xfs_dir2_data_hdr *hdr); }; extern const struct xfs_dir_ops *
@@ -81,7 +79,6 @@ 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_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,struct xfs_dir2_data_hdr *hdr,int *loghead);
fs/xfs/libxfs/xfs_dir2_block.c +3 -3
@@ -172,7 +172,7 @@ xfs_dir2_block_need_space(struct xfs_dir2_data_unused *enddup =NULL ; *compact =0 ; - bf = dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (dp->i_mount, hdr);/* * If there are stale entries we'll use one for the leaf.
@@ -1207,8 +1207,8 @@ xfs_dir2_sf_to_block( ((char *)dup - (char *)hdr));xfs_dir2_data_log_unused (args, bp, dup);xfs_dir2_data_freeinsert (hdr, - dp->d_ops->data_bestfree_p (hdr), - dup, &dummy); +xfs_dir2_data_bestfree_p (mp, hdr), + dup, &dummy); offset +=be16_to_cpu (dup->length);continue ; }
fs/xfs/libxfs/xfs_dir2_data.c +16 -7
@@ -24,6 +24,16 @@ static xfs_failaddr_t xfs_dir2_data_freefind_verify(struct xfs_dir2_data_unused *dup, struct xfs_dir2_data_free **bf_ent); +struct xfs_dir2_data_free * +xfs_dir2_data_bestfree_p ( +struct xfs_mount *mp, +struct xfs_dir2_data_hdr *hdr) +{ +if (xfs_sb_version_hascrc (&mp->m_sb)) +return ((struct xfs_dir3_data_hdr *)hdr)->best_free; +return hdr->bestfree; +} + int xfs_dir2_data_entsize( struct xfs_mount *mp,
@@ -130,7 +140,7 @@ __xfs_dir3_data_check(/* * Account for zero bestfree entries. */ - bf = ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (mp, hdr); count = lastfree = freeseen =0 ;if (!bf[0 ].length) {if (bf[0 ].offset)
@@ -590,7 +600,6 @@ xfs_dir2_data_freeremove(void xfs_dir2_data_freescan_int (struct xfs_mount *mp, -const struct xfs_dir_ops *ops,struct xfs_dir2_data_hdr *hdr,int *loghead) {
@@ -609,7 +618,7 @@ xfs_dir2_data_freescan_int(/* * Start by clearing the table. */ - bf = ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (mp, hdr);memset (bf,0 ,sizeof (*bf) *XFS_DIR2_DATA_FD_COUNT ); *loghead =1 ;/*
@@ -650,7 +659,7 @@ xfs_dir2_data_freescan(struct xfs_dir2_data_hdr *hdr, int *loghead) { - return xfs_dir2_data_freescan_int(dp->i_mount, dp->d_ops, hdr, loghead); + return xfs_dir2_data_freescan_int(dp->i_mount, hdr, loghead); }/*
@@ -703,7 +712,7 @@ xfs_dir3_data_init( }else hdr->magic =cpu_to_be32 (XFS_DIR2_DATA_MAGIC ); - bf = dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (mp, hdr); bf[0 ].offset =cpu_to_be16 (args->geo->data_entry_offset);for (i =1 ; i <XFS_DIR2_DATA_FD_COUNT ; i++) { bf[i].length =0 ;
@@ -862,7 +871,7 @@ xfs_dir2_data_make_free(* Previous and following entries are both free, * merge everything into a single free entry. */ - bf = args->dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (args->dp->i_mount, hdr);if (prevdup && postdup) {xfs_dir2_data_free_t *dfp2;/* another bestfree pointer */
@@ -1053,7 +1062,7 @@ xfs_dir2_data_use_free(* Look up the entry in the bestfree table. */ oldlen =be16_to_cpu (dup->length); - bf = args->dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (args->dp->i_mount, hdr); dfp =xfs_dir2_data_freefind (hdr, bf, dup);ASSERT (dfp || oldlen <=be16_to_cpu (bf[2 ].length));/*
fs/xfs/libxfs/xfs_dir2_leaf.c +6 -5
@@ -425,7 +425,7 @@ xfs_dir2_block_to_leaf(xfs_dir3_data_check (dp, dbp); btp =xfs_dir2_block_tail_p (args->geo, hdr); blp =xfs_dir2_block_leaf_p (btp); - bf = dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (dp->i_mount, hdr);/* * Set the counts in the leaf header.
@@ -823,7 +823,7 @@ xfs_dir2_leaf_addname(else xfs_dir3_leaf_log_bests (args, lbp, use_block, use_block); hdr = dbp->b_addr; - bf = dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (dp->i_mount, hdr); bestsp[use_block] = bf[0 ].length; grown =1 ; }else {
@@ -839,7 +839,7 @@ xfs_dir2_leaf_addname(return error; } hdr = dbp->b_addr; - bf = dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (dp->i_mount, hdr); grown =0 ; }/*
@@ -1376,7 +1376,7 @@ xfs_dir2_leaf_removename( leaf = lbp->b_addr; hdr = dbp->b_addr;xfs_dir3_data_check (dp, dbp); - bf = dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (dp->i_mount, hdr);/* * Point to the leaf entry, use that to point to the data entry.
@@ -1618,7 +1618,8 @@ xfs_dir2_leaf_trim_data(#ifdef DEBUG {struct xfs_dir2_data_hdr *hdr = dbp->b_addr; -struct xfs_dir2_data_free *bf = dp->d_ops->data_bestfree_p (hdr); +struct xfs_dir2_data_free *bf = +xfs_dir2_data_bestfree_p (dp->i_mount, hdr);ASSERT (hdr->magic ==cpu_to_be32 (XFS_DIR2_DATA_MAGIC ) || hdr->magic ==cpu_to_be32 (XFS_DIR3_DATA_MAGIC ));
fs/xfs/libxfs/xfs_dir2_node.c +3 -3
@@ -1311,7 +1311,7 @@ xfs_dir2_leafn_remove( dbp = dblk->bp; hdr = dbp->b_addr; dep = (xfs_dir2_data_entry_t *)((char *)hdr + off); - bf = dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (dp->i_mount, hdr); longest =be16_to_cpu (bf[0 ].length); needlog = needscan =0 ; xfs_dir2_data_make_free(args, dbp, off,
@@ -1769,7 +1769,7 @@ xfs_dir2_node_add_datablk( }/* Update the freespace value for the new block in the table. */ - bf = dp->d_ops->data_bestfree_p (dbp->b_addr); + bf =xfs_dir2_data_bestfree_p (mp, dbp->b_addr); hdr->bests[*findex] = bf[0 ].length; *dbpp = dbp;
@@ -1942,7 +1942,7 @@ xfs_dir2_node_addname_int(/* setup for data block up now */ hdr = dbp->b_addr; - bf = dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (dp->i_mount, hdr);ASSERT (be16_to_cpu (bf[0 ].length) >= length);/* Point to the existing unused space. */
fs/xfs/libxfs/xfs_dir2_priv.h +2 -0
@@ -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 */ +struct xfs_dir2_data_free *xfs_dir2_data_bestfree_p (struct xfs_mount *mp, +struct xfs_dir2_data_hdr *hdr);int xfs_dir2_data_entsize (struct xfs_mount *mp,int n);__be16 *xfs_dir2_data_entry_tag_p (struct xfs_mount *mp,struct xfs_dir2_data_entry *dep);
fs/xfs/scrub/dir.c +2 -5
@@ -327,7 +327,6 @@ xchk_directory_data_bestfree(struct xfs_buf *bp;struct xfs_dir2_data_free *bf;struct xfs_mount *mp = sc->mp; -const struct xfs_dir_ops *d_ops;char *ptr;char *endptr;u16 tag;
@@ -338,8 +337,6 @@ xchk_directory_data_bestfree(int offset;int error; - d_ops = sc->ip->d_ops; -if (is_block) {/* dir block format */ if (lblk !=XFS_B_TO_FSBT (mp,XFS_DIR2_DATA_OFFSET ))
@@ -359,7 +356,7 @@ xchk_directory_data_bestfree( goto out_buf;/* Do the bestfrees correspond to actual free space? */ - bf = d_ops->data_bestfree_p (bp->b_addr); + bf =xfs_dir2_data_bestfree_p (mp, bp->b_addr); smallest_bestfree =UINT_MAX ;for (dfp = &bf[0 ]; dfp < &bf[XFS_DIR2_DATA_FD_COUNT ]; dfp++) { offset =be16_to_cpu (dfp->offset);
@@ -466,7 +463,7 @@ xchk_directory_check_freesp( {struct xfs_dir2_data_free *dfp; - dfp = sc->ip->d_ops->data_bestfree_p (dbp->b_addr); + dfp =xfs_dir2_data_bestfree_p (sc->mp, dbp->b_addr);if (len !=be16_to_cpu (dfp->length))xchk_fblock_set_corrupt (sc,XFS_DATA_FORK , lblk);
Signature · 1 line
2.20.1
Re: [PATCH 30/34] xfs: devirtualize ->data_bestfree_p
Quoted 5 lines · Christoph Hellwig
Replace the ->data_bestfree_p dir ops method with a directly called
xfs_dir2_data_bestfree_phelper that takes care of the differences between the v4 and v5 on-disk format.Signed-off-by Christoph Hellwig <[email protected]>
Woot!
--D
Quoted 314 lines
--- fs/xfs/libxfs/xfs_da_format.c | 15 --------------- fs/xfs/libxfs/xfs_dir2.h | 3 --- fs/xfs/libxfs/xfs_dir2_block.c | 6 +++--- fs/xfs/libxfs/xfs_dir2_data.c | 23 ++++++++++++++++------- fs/xfs/libxfs/xfs_dir2_leaf.c | 11 ++++++----- fs/xfs/libxfs/xfs_dir2_node.c | 6 +++--- fs/xfs/libxfs/xfs_dir2_priv.h | 2 ++ fs/xfs/scrub/dir.c | 7 ++----- 8 files changed, 32 insertions(+), 41 deletions(-)fs/xfs/libxfs/xfs_da_format.c +0
-15@@ -56,34 +56,19 @@ xfs_dir3_data_put_ftype( dep->name[dep->namelen] = type; } -static struct xfs_dir2_data_free * -xfs_dir2_data_bestfree_p (struct xfs_dir2_data_hdr *hdr) -{ -return hdr->bestfree; -} - -static struct xfs_dir2_data_free * -xfs_dir3_data_bestfree_p (struct xfs_dir2_data_hdr *hdr) -{ -return ((struct xfs_dir3_data_hdr *)hdr)->best_free; -} -static const struct xfs_dir_ops xfs_dir2_ops = { .data_get_ftype = xfs_dir2_data_get_ftype, .data_put_ftype = xfs_dir2_data_put_ftype, - .data_bestfree_p = xfs_dir2_data_bestfree_p, };static const struct xfs_dir_ops xfs_dir2_ftype_ops = { .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype, - .data_bestfree_p = xfs_dir2_data_bestfree_p, };static const struct xfs_dir_ops xfs_dir3_ops = { .data_get_ftype = xfs_dir3_data_get_ftype, .data_put_ftype = xfs_dir3_data_put_ftype, - .data_bestfree_p = xfs_dir3_data_bestfree_p, };/* fs/xfs/libxfs/xfs_dir2.h +0
-3@@ -35,8 +35,6 @@ struct xfs_dir_ops {uint8_t (*data_get_ftype)(struct xfs_dir2_data_entry *dep);void (*data_put_ftype)(struct xfs_dir2_data_entry *dep,uint8_t ftype); -struct xfs_dir2_data_free * - (*data_bestfree_p)(struct xfs_dir2_data_hdr *hdr); }; extern const struct xfs_dir_ops *@@ -81,7 +79,6 @@ 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_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,struct xfs_dir2_data_hdr *hdr,int *loghead);fs/xfs/libxfs/xfs_dir2_block.c +3
-3@@ -172,7 +172,7 @@ xfs_dir2_block_need_space(struct xfs_dir2_data_unused *enddup =NULL ; *compact =0 ; - bf = dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (dp->i_mount, hdr);/* * If there are stale entries we'll use one for the leaf. @@ -1207,8 +1207,8 @@ xfs_dir2_sf_to_block( ((char *)dup - (char *)hdr));xfs_dir2_data_log_unused (args, bp, dup);xfs_dir2_data_freeinsert (hdr, - dp->d_ops->data_bestfree_p (hdr), - dup, &dummy); +xfs_dir2_data_bestfree_p (mp, hdr), + dup, &dummy); offset +=be16_to_cpu (dup->length);continue ; }fs/xfs/libxfs/xfs_dir2_data.c +16
-7@@ -24,6 +24,16 @@ static xfs_failaddr_t xfs_dir2_data_freefind_verify(struct xfs_dir2_data_unused *dup, struct xfs_dir2_data_free **bf_ent); +struct xfs_dir2_data_free * +xfs_dir2_data_bestfree_p ( +struct xfs_mount *mp, +struct xfs_dir2_data_hdr *hdr) +{ +if (xfs_sb_version_hascrc (&mp->m_sb)) +return ((struct xfs_dir3_data_hdr *)hdr)->best_free; +return hdr->bestfree; +} + int xfs_dir2_data_entsize( struct xfs_mount *mp,@@ -130,7 +140,7 @@ __xfs_dir3_data_check(/* * Account for zero bestfree entries. */ - bf = ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (mp, hdr); count = lastfree = freeseen =0 ;if (!bf[0 ].length) {if (bf[0 ].offset)@@ -590,7 +600,6 @@ xfs_dir2_data_freeremove(void xfs_dir2_data_freescan_int (struct xfs_mount *mp, -const struct xfs_dir_ops *ops,struct xfs_dir2_data_hdr *hdr,int *loghead) {@@ -609,7 +618,7 @@ xfs_dir2_data_freescan_int(/* * Start by clearing the table. */ - bf = ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (mp, hdr);memset (bf,0 ,sizeof (*bf) *XFS_DIR2_DATA_FD_COUNT ); *loghead =1 ;/* @@ -650,7 +659,7 @@ xfs_dir2_data_freescan(struct xfs_dir2_data_hdr *hdr, int *loghead) { - return xfs_dir2_data_freescan_int(dp->i_mount, dp->d_ops, hdr, loghead); + return xfs_dir2_data_freescan_int(dp->i_mount, hdr, loghead); }/* @@ -703,7 +712,7 @@ xfs_dir3_data_init( }else hdr->magic =cpu_to_be32 (XFS_DIR2_DATA_MAGIC ); - bf = dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (mp, hdr); bf[0 ].offset =cpu_to_be16 (args->geo->data_entry_offset);for (i =1 ; i <XFS_DIR2_DATA_FD_COUNT ; i++) { bf[i].length =0 ;@@ -862,7 +871,7 @@ xfs_dir2_data_make_free(* Previous and following entries are both free, * merge everything into a single free entry. */ - bf = args->dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (args->dp->i_mount, hdr);if (prevdup && postdup) {xfs_dir2_data_free_t *dfp2;/* another bestfree pointer */ @@ -1053,7 +1062,7 @@ xfs_dir2_data_use_free(* Look up the entry in the bestfree table. */ oldlen =be16_to_cpu (dup->length); - bf = args->dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (args->dp->i_mount, hdr); dfp =xfs_dir2_data_freefind (hdr, bf, dup);ASSERT (dfp || oldlen <=be16_to_cpu (bf[2 ].length));/* fs/xfs/libxfs/xfs_dir2_leaf.c +6
-5@@ -425,7 +425,7 @@ xfs_dir2_block_to_leaf(xfs_dir3_data_check (dp, dbp); btp =xfs_dir2_block_tail_p (args->geo, hdr); blp =xfs_dir2_block_leaf_p (btp); - bf = dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (dp->i_mount, hdr);/* * Set the counts in the leaf header. @@ -823,7 +823,7 @@ xfs_dir2_leaf_addname(else xfs_dir3_leaf_log_bests (args, lbp, use_block, use_block); hdr = dbp->b_addr; - bf = dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (dp->i_mount, hdr); bestsp[use_block] = bf[0 ].length; grown =1 ; }else {@@ -839,7 +839,7 @@ xfs_dir2_leaf_addname(return error; } hdr = dbp->b_addr; - bf = dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (dp->i_mount, hdr); grown =0 ; }/* @@ -1376,7 +1376,7 @@ xfs_dir2_leaf_removename( leaf = lbp->b_addr; hdr = dbp->b_addr;xfs_dir3_data_check (dp, dbp); - bf = dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (dp->i_mount, hdr);/* * Point to the leaf entry, use that to point to the data entry. @@ -1618,7 +1618,8 @@ xfs_dir2_leaf_trim_data(#ifdef DEBUG {struct xfs_dir2_data_hdr *hdr = dbp->b_addr; -struct xfs_dir2_data_free *bf = dp->d_ops->data_bestfree_p (hdr); +struct xfs_dir2_data_free *bf = +xfs_dir2_data_bestfree_p (dp->i_mount, hdr);ASSERT (hdr->magic ==cpu_to_be32 (XFS_DIR2_DATA_MAGIC ) || hdr->magic ==cpu_to_be32 (XFS_DIR3_DATA_MAGIC ));fs/xfs/libxfs/xfs_dir2_node.c +3
-3@@ -1311,7 +1311,7 @@ xfs_dir2_leafn_remove( dbp = dblk->bp; hdr = dbp->b_addr; dep = (xfs_dir2_data_entry_t *)((char *)hdr + off); - bf = dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (dp->i_mount, hdr); longest =be16_to_cpu (bf[0 ].length); needlog = needscan =0 ; xfs_dir2_data_make_free(args, dbp, off,@@ -1769,7 +1769,7 @@ xfs_dir2_node_add_datablk( }/* Update the freespace value for the new block in the table. */ - bf = dp->d_ops->data_bestfree_p (dbp->b_addr); + bf =xfs_dir2_data_bestfree_p (mp, dbp->b_addr); hdr->bests[*findex] = bf[0 ].length; *dbpp = dbp;@@ -1942,7 +1942,7 @@ xfs_dir2_node_addname_int(/* setup for data block up now */ hdr = dbp->b_addr; - bf = dp->d_ops->data_bestfree_p (hdr); + bf =xfs_dir2_data_bestfree_p (dp->i_mount, hdr);ASSERT (be16_to_cpu (bf[0 ].length) >= length);/* Point to the existing unused space. */ fs/xfs/libxfs/xfs_dir2_priv.h +2
-0@@ -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 */ +struct xfs_dir2_data_free *xfs_dir2_data_bestfree_p (struct xfs_mount *mp, +struct xfs_dir2_data_hdr *hdr);int xfs_dir2_data_entsize (struct xfs_mount *mp,int n);__be16 *xfs_dir2_data_entry_tag_p (struct xfs_mount *mp,struct xfs_dir2_data_entry *dep);fs/xfs/scrub/dir.c +2
-5@@ -327,7 +327,6 @@ xchk_directory_data_bestfree(struct xfs_buf *bp;struct xfs_dir2_data_free *bf;struct xfs_mount *mp = sc->mp; -const struct xfs_dir_ops *d_ops;char *ptr;char *endptr;u16 tag;@@ -338,8 +337,6 @@ xchk_directory_data_bestfree(int offset;int error; - d_ops = sc->ip->d_ops; -if (is_block) {/* dir block format */ if (lblk !=XFS_B_TO_FSBT (mp,XFS_DIR2_DATA_OFFSET ))@@ -359,7 +356,7 @@ xchk_directory_data_bestfree( goto out_buf;/* Do the bestfrees correspond to actual free space? */ - bf = d_ops->data_bestfree_p (bp->b_addr); + bf =xfs_dir2_data_bestfree_p (mp, bp->b_addr); smallest_bestfree =UINT_MAX ;for (dfp = &bf[0 ]; dfp < &bf[XFS_DIR2_DATA_FD_COUNT ]; dfp++) { offset =be16_to_cpu (dfp->offset);@@ -466,7 +463,7 @@ xchk_directory_check_freesp( {struct xfs_dir2_data_free *dfp; - dfp = sc->ip->d_ops->data_bestfree_p (dbp->b_addr); + dfp =xfs_dir2_data_bestfree_p (sc->mp, dbp->b_addr);if (len !=be16_to_cpu (dfp->length))xchk_fblock_set_corrupt (sc,XFS_DATA_FORK , lblk);Signature · 1 line
2.20.1
PATCH 31/34 xfs: devirtualize ->data_get_ftype and ->data_put_ftype
In reply to Christoph HellwigReplace the ->data_get_ftype and ->data_put_ftype dir ops methods with directly called xfs_dir2_data_get_ftype and xfs_dir2_data_put_ftype helpers that takes care of the differences between the directory format with and without the file type field.
--- fs/xfs/libxfs/xfs_da_format.c | 47 ---------------------------------- fs/xfs/libxfs/xfs_dir2.h | 3 --- fs/xfs/libxfs/xfs_dir2_block.c | 13 +++++----- fs/xfs/libxfs/xfs_dir2_data.c | 47 +++++++++++++++++++++++----------- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 ++--- fs/xfs/libxfs/xfs_dir2_node.c | 6 ++--- fs/xfs/libxfs/xfs_dir2_priv.h | 4 +++ fs/xfs/libxfs/xfs_dir2_sf.c | 2 +- fs/xfs/xfs_dir2_readdir.c | 4 +-- 9 files changed, 52 insertions(+), 80 deletions(-)
fs/xfs/libxfs/xfs_da_format.c +0 -47
@@ -15,60 +15,13 @@#include "xfs_dir2.h" #include "xfs_dir2_priv.h" -/* -* Directory data block operations -*/ - -static uint8_t -xfs_dir2_data_get_ftype ( -struct xfs_dir2_data_entry *dep) -{ -return XFS_DIR3_FT_UNKNOWN ; -} - -static void -xfs_dir2_data_put_ftype ( -struct xfs_dir2_data_entry *dep, -uint8_t ftype) -{ -ASSERT (ftype <XFS_DIR3_FT_MAX ); -} - -static uint8_t -xfs_dir3_data_get_ftype ( -struct xfs_dir2_data_entry *dep) -{ -uint8_t ftype = dep->name[dep->namelen]; - -if (ftype >=XFS_DIR3_FT_MAX ) -return XFS_DIR3_FT_UNKNOWN ; -return ftype; -} - -static void -xfs_dir3_data_put_ftype ( -struct xfs_dir2_data_entry *dep, -uint8_t type) -{ -ASSERT (type <XFS_DIR3_FT_MAX ); -ASSERT (dep->namelen !=0 ); - - dep->name[dep->namelen] = type; -} -static const struct xfs_dir_ops xfs_dir2_ops = { - .data_get_ftype = xfs_dir2_data_get_ftype, - .data_put_ftype = xfs_dir2_data_put_ftype, };static const struct xfs_dir_ops xfs_dir2_ftype_ops = { - .data_get_ftype = xfs_dir3_data_get_ftype, - .data_put_ftype = xfs_dir3_data_put_ftype, };static const struct xfs_dir_ops xfs_dir3_ops = { - .data_get_ftype = xfs_dir3_data_get_ftype, - .data_put_ftype = xfs_dir3_data_put_ftype, };/*
fs/xfs/libxfs/xfs_dir2.h +0 -3
@@ -32,9 +32,6 @@ extern unsigned char xfs_mode_to_ftype(int mode);* directory operations vector for encode/decode routines */ struct xfs_dir_ops { -uint8_t (*data_get_ftype)(struct xfs_dir2_data_entry *dep); -void (*data_put_ftype)(struct xfs_dir2_data_entry *dep, -uint8_t ftype); }; extern const struct xfs_dir_ops *
fs/xfs/libxfs/xfs_dir2_block.c +7 -6
@@ -541,7 +541,7 @@ xfs_dir2_block_addname( dep->inumber =cpu_to_be64 (args->inumber); dep->namelen = args->namelen;memcpy (dep->name, args->name, args->namelen); - dp->d_ops->data_put_ftype (dep, args->filetype); +xfs_dir2_data_put_ftype (dp->i_mount, dep, args->filetype); tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);/*
@@ -633,7 +633,7 @@ xfs_dir2_block_lookup(* Fill in inode number, CI name if appropriate, release the block. */ args->inumber =be64_to_cpu (dep->inumber); - args->filetype = dp->d_ops->data_get_ftype (dep); + args->filetype =xfs_dir2_data_get_ftype (dp->i_mount, dep); error =xfs_dir_cilookup_result (args, dep->name, dep->namelen);xfs_trans_brelse (args->trans, bp);return error;
@@ -865,7 +865,7 @@ xfs_dir2_block_replace(* Change the inode number to the new value. */ dep->inumber =cpu_to_be64 (args->inumber); - dp->d_ops->data_put_ftype (dep, args->filetype); +xfs_dir2_data_put_ftype (dp->i_mount, dep, args->filetype);xfs_dir2_data_log_entry (args, bp, dep);xfs_dir3_data_check (dp, bp);return 0 ;
@@ -1154,7 +1154,7 @@ xfs_dir2_sf_to_block( dep->inumber =cpu_to_be64 (dp->i_ino); dep->namelen =1 ; dep->name[0 ] ='.' ; - dp->d_ops->data_put_ftype (dep,XFS_DIR3_FT_DIR ); +xfs_dir2_data_put_ftype (mp, dep,XFS_DIR3_FT_DIR ); tagp =xfs_dir2_data_entry_tag_p (mp, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);xfs_dir2_data_log_entry (args, bp, dep);
@@ -1168,7 +1168,7 @@ xfs_dir2_sf_to_block( dep->inumber =cpu_to_be64 (xfs_dir2_sf_get_parent_ino (sfp)); dep->namelen =2 ; dep->name[0 ] = dep->name[1 ] ='.' ; - dp->d_ops->data_put_ftype (dep,XFS_DIR3_FT_DIR ); +xfs_dir2_data_put_ftype (mp, dep,XFS_DIR3_FT_DIR ); tagp =xfs_dir2_data_entry_tag_p (mp, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);xfs_dir2_data_log_entry (args, bp, dep);
@@ -1218,7 +1218,8 @@ xfs_dir2_sf_to_block( dep = (xfs_dir2_data_entry_t *)((char *)hdr + newoffset); dep->inumber =cpu_to_be64 (xfs_dir2_sf_get_ino (mp, sfp, sfep)); dep->namelen = sfep->namelen; - dp->d_ops->data_put_ftype (dep,xfs_dir2_sf_get_ftype (mp, sfep)); +xfs_dir2_data_put_ftype (mp, dep, +xfs_dir2_sf_get_ftype (mp, sfep));memcpy (dep->name, sfep->name, dep->namelen); tagp =xfs_dir2_data_entry_tag_p (mp, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);
fs/xfs/libxfs/xfs_dir2_data.c +32 -15
68 lines not on this page · raw message
fs/xfs/libxfs/xfs_dir2_leaf.c +3 -3
@@ -865,7 +865,7 @@ xfs_dir2_leaf_addname( dep->inumber =cpu_to_be64 (args->inumber); dep->namelen = args->namelen;memcpy (dep->name, args->name, dep->namelen); - dp->d_ops->data_put_ftype (dep, args->filetype); +xfs_dir2_data_put_ftype (dp->i_mount, dep, args->filetype); tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);/*
@@ -1195,7 +1195,7 @@ xfs_dir2_leaf_lookup(* Return the found inode number & CI name if appropriate */ args->inumber =be64_to_cpu (dep->inumber); - args->filetype = dp->d_ops->data_get_ftype (dep); + args->filetype =xfs_dir2_data_get_ftype (dp->i_mount, dep); error =xfs_dir_cilookup_result (args, dep->name, dep->namelen);xfs_trans_brelse (tp, dbp);xfs_trans_brelse (tp, lbp);
@@ -1524,7 +1524,7 @@ xfs_dir2_leaf_replace(* Put the new inode number in, log it. */ dep->inumber =cpu_to_be64 (args->inumber); - dp->d_ops->data_put_ftype (dep, args->filetype); +xfs_dir2_data_put_ftype (dp->i_mount, dep, args->filetype); tp = args->trans;xfs_dir2_data_log_entry (args, dbp, dep);xfs_dir3_leaf_check (dp, lbp);
fs/xfs/libxfs/xfs_dir2_node.c +3 -3
@@ -878,7 +878,7 @@ xfs_dir2_leafn_lookup_for_entry(xfs_trans_brelse (tp, state->extrablk.bp); args->cmpresult = cmp; args->inumber =be64_to_cpu (dep->inumber); - args->filetype = dp->d_ops->data_get_ftype (dep); + args->filetype =xfs_dir2_data_get_ftype (mp, dep); *indexp = index; state->extravalid =1 ; state->extrablk.bp = curbp;
@@ -1963,7 +1963,7 @@ xfs_dir2_node_addname_int( dep->inumber =cpu_to_be64 (args->inumber); dep->namelen = args->namelen;memcpy (dep->name, args->name, dep->namelen); - dp->d_ops->data_put_ftype (dep, args->filetype); +xfs_dir2_data_put_ftype (dp->i_mount, dep, args->filetype); tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);xfs_dir2_data_log_entry (args, dbp, dep);
@@ -2247,7 +2247,7 @@ xfs_dir2_node_replace(* Fill in the new inode number and log the entry. */ dep->inumber =cpu_to_be64 (inum); - args->dp->d_ops->data_put_ftype (dep, ftype); +xfs_dir2_data_put_ftype (state->mp, dep, ftype);xfs_dir2_data_log_entry (args, state->extrablk.bp, dep); rval =0 ; }
fs/xfs/libxfs/xfs_dir2_priv.h +4 -0
@@ -52,6 +52,10 @@ struct xfs_dir2_data_free *xfs_dir2_data_bestfree_p(struct xfs_mount *mp,int xfs_dir2_data_entsize (struct xfs_mount *mp,int n);__be16 *xfs_dir2_data_entry_tag_p (struct xfs_mount *mp,struct xfs_dir2_data_entry *dep); +uint8_t xfs_dir2_data_get_ftype (struct xfs_mount *mp, +struct xfs_dir2_data_entry *dep); +void xfs_dir2_data_put_ftype (struct xfs_mount *mp, +struct xfs_dir2_data_entry *dep,uint8_t ftype);#ifdef DEBUG extern void xfs_dir3_data_check (struct xfs_inode *dp,struct xfs_buf *bp);
fs/xfs/libxfs/xfs_dir2_sf.c +1 -1
@@ -337,7 +337,7 @@ xfs_dir2_block_to_sf(xfs_dir2_sf_put_ino (mp, sfp, sfep,be64_to_cpu (dep->inumber));xfs_dir2_sf_put_ftype (mp, sfep, - dp->d_ops->data_get_ftype (dep)); +xfs_dir2_data_get_ftype (mp, dep)); sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep); }
fs/xfs/xfs_dir2_readdir.c +2 -2
@@ -208,7 +208,7 @@ xfs_dir2_block_getdents( (char *)dep - (char *)hdr); ctx->pos = cook &0x7fffffff ; - filetype = dp->d_ops->data_get_ftype (dep); + filetype =xfs_dir2_data_get_ftype (dp->i_mount, dep);/* * If it didn't fit, set the final offset to here & return. */
@@ -463,7 +463,7 @@ xfs_dir2_leaf_getdents( dep = (xfs_dir2_data_entry_t *)ptr; length =xfs_dir2_data_entsize (mp, dep->namelen); - filetype = dp->d_ops->data_get_ftype (dep); + filetype =xfs_dir2_data_get_ftype (mp, dep); ctx->pos =xfs_dir2_byte_to_dataptr (curoff) &0x7fffffff ;if (!xfs_dir2_namecheck (dep->name, dep->namelen)) {
Signature · 1 line
2.20.1
Re: [PATCH 31/34] xfs: devirtualize ->data_get_ftype and ->data_put_ftype
Quoted 6 lines · Christoph Hellwig
Replace the ->data_get_ftype and ->data_put_ftype dir ops methods with directly called
xfs_dir2_data_get_ftypeandxfs_dir2_data_put_ftypehelpers that takes care of the differences between the directory format with and without the file type field.Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
--D
Quoted 340 lines
--- fs/xfs/libxfs/xfs_da_format.c | 47 ---------------------------------- fs/xfs/libxfs/xfs_dir2.h | 3 --- fs/xfs/libxfs/xfs_dir2_block.c | 13 +++++----- fs/xfs/libxfs/xfs_dir2_data.c | 47 +++++++++++++++++++++++----------- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 ++--- fs/xfs/libxfs/xfs_dir2_node.c | 6 ++--- fs/xfs/libxfs/xfs_dir2_priv.h | 4 +++ fs/xfs/libxfs/xfs_dir2_sf.c | 2 +- fs/xfs/xfs_dir2_readdir.c | 4 +-- 9 files changed, 52 insertions(+), 80 deletions(-)fs/xfs/libxfs/xfs_da_format.c +0
-47@@ -15,60 +15,13 @@#include "xfs_dir2.h" #include "xfs_dir2_priv.h" -/* -* Directory data block operations -*/ - -static uint8_t -xfs_dir2_data_get_ftype ( -struct xfs_dir2_data_entry *dep) -{ -return XFS_DIR3_FT_UNKNOWN ; -} - -static void -xfs_dir2_data_put_ftype ( -struct xfs_dir2_data_entry *dep, -uint8_t ftype) -{ -ASSERT (ftype <XFS_DIR3_FT_MAX ); -} - -static uint8_t -xfs_dir3_data_get_ftype ( -struct xfs_dir2_data_entry *dep) -{ -uint8_t ftype = dep->name[dep->namelen]; - -if (ftype >=XFS_DIR3_FT_MAX ) -return XFS_DIR3_FT_UNKNOWN ; -return ftype; -} - -static void -xfs_dir3_data_put_ftype ( -struct xfs_dir2_data_entry *dep, -uint8_t type) -{ -ASSERT (type <XFS_DIR3_FT_MAX ); -ASSERT (dep->namelen !=0 ); - - dep->name[dep->namelen] = type; -} -static const struct xfs_dir_ops xfs_dir2_ops = { - .data_get_ftype = xfs_dir2_data_get_ftype, - .data_put_ftype = xfs_dir2_data_put_ftype, };static const struct xfs_dir_ops xfs_dir2_ftype_ops = { - .data_get_ftype = xfs_dir3_data_get_ftype, - .data_put_ftype = xfs_dir3_data_put_ftype, };static const struct xfs_dir_ops xfs_dir3_ops = { - .data_get_ftype = xfs_dir3_data_get_ftype, - .data_put_ftype = xfs_dir3_data_put_ftype, };/* fs/xfs/libxfs/xfs_dir2.h +0
-3@@ -32,9 +32,6 @@ extern unsigned char xfs_mode_to_ftype(int mode);* directory operations vector for encode/decode routines */ struct xfs_dir_ops { -uint8_t (*data_get_ftype)(struct xfs_dir2_data_entry *dep); -void (*data_put_ftype)(struct xfs_dir2_data_entry *dep, -uint8_t ftype); }; extern const struct xfs_dir_ops *fs/xfs/libxfs/xfs_dir2_block.c +7
-6@@ -541,7 +541,7 @@ xfs_dir2_block_addname( dep->inumber =cpu_to_be64 (args->inumber); dep->namelen = args->namelen;memcpy (dep->name, args->name, args->namelen); - dp->d_ops->data_put_ftype (dep, args->filetype); +xfs_dir2_data_put_ftype (dp->i_mount, dep, args->filetype); tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);/* @@ -633,7 +633,7 @@ xfs_dir2_block_lookup(* Fill in inode number, CI name if appropriate, release the block. */ args->inumber =be64_to_cpu (dep->inumber); - args->filetype = dp->d_ops->data_get_ftype (dep); + args->filetype =xfs_dir2_data_get_ftype (dp->i_mount, dep); error =xfs_dir_cilookup_result (args, dep->name, dep->namelen);xfs_trans_brelse (args->trans, bp);return error;@@ -865,7 +865,7 @@ xfs_dir2_block_replace(* Change the inode number to the new value. */ dep->inumber =cpu_to_be64 (args->inumber); - dp->d_ops->data_put_ftype (dep, args->filetype); +xfs_dir2_data_put_ftype (dp->i_mount, dep, args->filetype);xfs_dir2_data_log_entry (args, bp, dep);xfs_dir3_data_check (dp, bp);return 0 ;@@ -1154,7 +1154,7 @@ xfs_dir2_sf_to_block( dep->inumber =cpu_to_be64 (dp->i_ino); dep->namelen =1 ; dep->name[0 ] ='.' ; - dp->d_ops->data_put_ftype (dep,XFS_DIR3_FT_DIR ); +xfs_dir2_data_put_ftype (mp, dep,XFS_DIR3_FT_DIR ); tagp =xfs_dir2_data_entry_tag_p (mp, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);xfs_dir2_data_log_entry (args, bp, dep);@@ -1168,7 +1168,7 @@ xfs_dir2_sf_to_block( dep->inumber =cpu_to_be64 (xfs_dir2_sf_get_parent_ino (sfp)); dep->namelen =2 ; dep->name[0 ] = dep->name[1 ] ='.' ; - dp->d_ops->data_put_ftype (dep,XFS_DIR3_FT_DIR ); +xfs_dir2_data_put_ftype (mp, dep,XFS_DIR3_FT_DIR ); tagp =xfs_dir2_data_entry_tag_p (mp, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);xfs_dir2_data_log_entry (args, bp, dep);@@ -1218,7 +1218,8 @@ xfs_dir2_sf_to_block( dep = (xfs_dir2_data_entry_t *)((char *)hdr + newoffset); dep->inumber =cpu_to_be64 (xfs_dir2_sf_get_ino (mp, sfp, sfep)); dep->namelen = sfep->namelen; - dp->d_ops->data_put_ftype (dep,xfs_dir2_sf_get_ftype (mp, sfep)); +xfs_dir2_data_put_ftype (mp, dep, +xfs_dir2_sf_get_ftype (mp, sfep));memcpy (dep->name, sfep->name, dep->namelen); tagp =xfs_dir2_data_entry_tag_p (mp, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);fs/xfs/libxfs/xfs_dir2_data.c +32
-15@@ -60,6 +60,34 @@ xfs_dir2_data_entry_tag_p( xfs_dir2_data_entsize(mp, dep->namelen) - sizeof(__be16)); } +uint8_t +xfs_dir2_data_get_ftype ( +struct xfs_mount *mp, +struct xfs_dir2_data_entry *dep) +{ +if (xfs_sb_version_hasftype (&mp->m_sb)) { +uint8_t ftype = dep->name[dep->namelen]; + +if (likely (ftype <XFS_DIR3_FT_MAX )) +return ftype; + } + +return XFS_DIR3_FT_UNKNOWN ; +} + +void +xfs_dir2_data_put_ftype ( +struct xfs_mount *mp, +struct xfs_dir2_data_entry *dep, +uint8_t ftype) +{ +ASSERT (ftype <XFS_DIR3_FT_MAX ); +ASSERT (dep->namelen !=0 ); + +if (xfs_sb_version_hasftype (&mp->m_sb)) + dep->name[dep->namelen] = ftype; +} +/* * Check the consistency of the data block. * The input can also be a block-format directory. @@ -88,23 +116,12 @@ __xfs_dir3_data_check(char *p;/* current data position */ int stale;/* count of stale leaves */ struct xfs_name name; -const struct xfs_dir_ops *ops; -struct xfs_da_geometry *geo; - - geo = mp->m_dir_geo; - -/* -* We can be passed a null dp here from a verifier, so we need to go the -* hard way to get them. -*/ - ops =xfs_dir_get_ops (mp, dp); +struct xfs_da_geometry *geo = mp->m_dir_geo;/* -* If this isn't a directory, or we don't get handed the dir ops, -* something is seriously wrong. Bail out. +* If this isn't a directory, something is seriously wrong. Bail out. */ -if ((dp && !S_ISDIR (VFS_I (dp)->i_mode)) || - ops !=xfs_dir_get_ops (mp,NULL )) +if (dp && !S_ISDIR (VFS_I (dp)->i_mode))return __this_address; hdr = bp->b_addr;@@ -215,7 +232,7 @@ __xfs_dir3_data_check(if (be16_to_cpu (*xfs_dir2_data_entry_tag_p (mp, dep)) != (char *)dep - (char *)hdr)return __this_address; -if (ops->data_get_ftype (dep) >=XFS_DIR3_FT_MAX ) +if (xfs_dir2_data_get_ftype (mp, dep) >=XFS_DIR3_FT_MAX )return __this_address; count++; lastfree =0 ;fs/xfs/libxfs/xfs_dir2_leaf.c +3
-3@@ -865,7 +865,7 @@ xfs_dir2_leaf_addname( dep->inumber =cpu_to_be64 (args->inumber); dep->namelen = args->namelen;memcpy (dep->name, args->name, dep->namelen); - dp->d_ops->data_put_ftype (dep, args->filetype); +xfs_dir2_data_put_ftype (dp->i_mount, dep, args->filetype); tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);/* @@ -1195,7 +1195,7 @@ xfs_dir2_leaf_lookup(* Return the found inode number & CI name if appropriate */ args->inumber =be64_to_cpu (dep->inumber); - args->filetype = dp->d_ops->data_get_ftype (dep); + args->filetype =xfs_dir2_data_get_ftype (dp->i_mount, dep); error =xfs_dir_cilookup_result (args, dep->name, dep->namelen);xfs_trans_brelse (tp, dbp);xfs_trans_brelse (tp, lbp);@@ -1524,7 +1524,7 @@ xfs_dir2_leaf_replace(* Put the new inode number in, log it. */ dep->inumber =cpu_to_be64 (args->inumber); - dp->d_ops->data_put_ftype (dep, args->filetype); +xfs_dir2_data_put_ftype (dp->i_mount, dep, args->filetype); tp = args->trans;xfs_dir2_data_log_entry (args, dbp, dep);xfs_dir3_leaf_check (dp, lbp);fs/xfs/libxfs/xfs_dir2_node.c +3
-3@@ -878,7 +878,7 @@ xfs_dir2_leafn_lookup_for_entry(xfs_trans_brelse (tp, state->extrablk.bp); args->cmpresult = cmp; args->inumber =be64_to_cpu (dep->inumber); - args->filetype = dp->d_ops->data_get_ftype (dep); + args->filetype =xfs_dir2_data_get_ftype (mp, dep); *indexp = index; state->extravalid =1 ; state->extrablk.bp = curbp;@@ -1963,7 +1963,7 @@ xfs_dir2_node_addname_int( dep->inumber =cpu_to_be64 (args->inumber); dep->namelen = args->namelen;memcpy (dep->name, args->name, dep->namelen); - dp->d_ops->data_put_ftype (dep, args->filetype); +xfs_dir2_data_put_ftype (dp->i_mount, dep, args->filetype); tagp =xfs_dir2_data_entry_tag_p (dp->i_mount, dep); *tagp =cpu_to_be16 ((char *)dep - (char *)hdr);xfs_dir2_data_log_entry (args, dbp, dep);@@ -2247,7 +2247,7 @@ xfs_dir2_node_replace(* Fill in the new inode number and log the entry. */ dep->inumber =cpu_to_be64 (inum); - args->dp->d_ops->data_put_ftype (dep, ftype); +xfs_dir2_data_put_ftype (state->mp, dep, ftype);xfs_dir2_data_log_entry (args, state->extrablk.bp, dep); rval =0 ; }fs/xfs/libxfs/xfs_dir2_priv.h +4
-0@@ -52,6 +52,10 @@ struct xfs_dir2_data_free *xfs_dir2_data_bestfree_p(struct xfs_mount *mp,int xfs_dir2_data_entsize (struct xfs_mount *mp,int n);__be16 *xfs_dir2_data_entry_tag_p (struct xfs_mount *mp,struct xfs_dir2_data_entry *dep); +uint8_t xfs_dir2_data_get_ftype (struct xfs_mount *mp, +struct xfs_dir2_data_entry *dep); +void xfs_dir2_data_put_ftype (struct xfs_mount *mp, +struct xfs_dir2_data_entry *dep,uint8_t ftype);#ifdef DEBUG extern void xfs_dir3_data_check (struct xfs_inode *dp,struct xfs_buf *bp);fs/xfs/libxfs/xfs_dir2_sf.c +1
-1@@ -337,7 +337,7 @@ xfs_dir2_block_to_sf(xfs_dir2_sf_put_ino (mp, sfp, sfep,be64_to_cpu (dep->inumber));xfs_dir2_sf_put_ftype (mp, sfep, - dp->d_ops->data_get_ftype (dep)); +xfs_dir2_data_get_ftype (mp, dep)); sfep =xfs_dir2_sf_nextentry (mp, sfp, sfep); }fs/xfs/xfs_dir2_readdir.c +2
-2@@ -208,7 +208,7 @@ xfs_dir2_block_getdents( (char *)dep - (char *)hdr); ctx->pos = cook &0x7fffffff ; - filetype = dp->d_ops->data_get_ftype (dep); + filetype =xfs_dir2_data_get_ftype (dp->i_mount, dep);/* * If it didn't fit, set the final offset to here & return. */ @@ -463,7 +463,7 @@ xfs_dir2_leaf_getdents( dep = (xfs_dir2_data_entry_t *)ptr; length =xfs_dir2_data_entsize (mp, dep->namelen); - filetype = dp->d_ops->data_get_ftype (dep); + filetype =xfs_dir2_data_get_ftype (mp, dep); ctx->pos =xfs_dir2_byte_to_dataptr (curoff) &0x7fffffff ;if (!xfs_dir2_namecheck (dep->name, dep->namelen)) {Signature · 1 line
2.20.1
PATCH 32/34 xfs: remove the now unused dir ops infrastructure
In reply to Christoph Hellwig--- fs/xfs/Makefile | 1 - fs/xfs/libxfs/xfs_da_btree.h | 1 - fs/xfs/libxfs/xfs_da_format.c | 46 ----------------------------------- fs/xfs/libxfs/xfs_dir2.c | 2 -- fs/xfs/libxfs/xfs_dir2.h | 9 ------- fs/xfs/xfs_inode.h | 3 --- fs/xfs/xfs_iops.c | 1 - fs/xfs/xfs_mount.h | 2 -- 8 files changed, 65 deletions(-) delete mode 100644 fs/xfs/libxfs/xfs_da_format.c
fs/xfs/Makefile +0 -1
@@ -27,7 +27,6 @@ xfs-y += $(addprefix libxfs/, \ xfs_bmap_btree.o \ xfs_btree.o \ xfs_da_btree.o \ - xfs_da_format.o \ xfs_defer.o \ xfs_dir2.o \ xfs_dir2_block.o \
fs/xfs/libxfs/xfs_da_btree.h +0 -1
@@ -10,7 +10,6 @@struct xfs_inode ;struct xfs_trans ;struct zone ; -struct xfs_dir_ops ;/* * Directory/attribute geometry information. There will be one of these for each
fs/xfs/libxfs/xfs_da_format.c deleted +0 -46
46 lines not on this page · raw message
fs/xfs/libxfs/xfs_dir2.c +0 -2
@@ -104,8 +104,6 @@ xfs_da_mount(ASSERT (mp->m_sb.sb_versionnum &XFS_SB_VERSION_DIRV2BIT );ASSERT (xfs_dir2_dirblock_bytes (&mp->m_sb) <=XFS_MAX_BLOCKSIZE ); - mp->m_dir_inode_ops =xfs_dir_get_ops (mp,NULL ); - mp->m_dir_geo =kmem_zalloc (sizeof (struct xfs_da_geometry ),KM_MAYFAIL ); mp->m_attr_geo = kmem_zalloc(sizeof(struct xfs_da_geometry),
fs/xfs/libxfs/xfs_dir2.h +0 -9
@@ -28,15 +28,6 @@ extern struct xfs_name xfs_name_dotdot;*/ extern unsigned char xfs_mode_to_ftype (int mode); -/* -* directory operations vector for encode/decode routines -*/ -struct xfs_dir_ops { -}; - -extern const struct xfs_dir_ops * -xfs_dir_get_ops (struct xfs_mount *mp,struct xfs_inode *dp); -/* * Generic directory interface routines */
fs/xfs/xfs_inode.h +0 -3
@@ -37,9 +37,6 @@ typedef struct xfs_inode {struct xfs_ifork *i_cowfp;/* copy on write extents */ struct xfs_ifork i_df;/* data fork */ -/* operations vectors */ -const struct xfs_dir_ops *d_ops;/* directory ops vector */ -/* Transaction and locking information. */ struct xfs_inode_log_item *i_itemp;/* logging information */ mrlock_t i_lock;/* inode lock */
fs/xfs/xfs_iops.c +0 -1
@@ -1317,7 +1317,6 @@ xfs_setup_inode(lockdep_set_class (&inode->i_rwsem, &inode->i_sb->s_type->i_mutex_dir_key);lockdep_set_class (&ip->i_lock.mr_lock, &xfs_dir_ilock_class); - ip->d_ops = ip->i_mount->m_dir_inode_ops; }else {lockdep_set_class (&ip->i_lock.mr_lock, &xfs_nondir_ilock_class); }
fs/xfs/xfs_mount.h +0 -2
@@ -12,7 +12,6 @@ struct xfs_mru_cache;struct xfs_nameops ;struct xfs_ail ;struct xfs_quotainfo ; -struct xfs_dir_ops ;struct xfs_da_geometry ;/* dynamic preallocation free space thresholds, 5% down to 1% */
@@ -158,7 +157,6 @@ typedef struct xfs_mount {int m_swidth;/* stripe width */ uint8_t m_sectbb_log;/* sectlog - BBSHIFT */ const struct xfs_nameops *m_dirnameops;/* vector of dir name ops */ -const struct xfs_dir_ops *m_dir_inode_ops;/* vector of dir inode ops */ uint m_chsize;/* size of next field */ atomic_t m_active_trans;/* number trans frozen */ struct xfs_mru_cache *m_filestream;/* per-mount filestream data */
Signature · 1 line
2.20.1
Re: [PATCH 32/34] xfs: remove the now unused dir ops infrastructure
Quoted 1 line · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>
YAY!
--D
Quoted 170 lines
--- fs/xfs/Makefile | 1 - fs/xfs/libxfs/xfs_da_btree.h | 1 - fs/xfs/libxfs/xfs_da_format.c | 46 ----------------------------------- fs/xfs/libxfs/xfs_dir2.c | 2 -- fs/xfs/libxfs/xfs_dir2.h | 9 ------- fs/xfs/xfs_inode.h | 3 --- fs/xfs/xfs_iops.c | 1 - fs/xfs/xfs_mount.h | 2 -- 8 files changed, 65 deletions(-) delete mode 100644 fs/xfs/libxfs/xfs_da_format.cfs/xfs/Makefile +0
-1@@ -27,7 +27,6 @@ xfs-y += $(addprefix libxfs/, \ xfs_bmap_btree.o \ xfs_btree.o \ xfs_da_btree.o \ - xfs_da_format.o \ xfs_defer.o \ xfs_dir2.o \ xfs_dir2_block.o \fs/xfs/libxfs/xfs_da_btree.h +0
-1@@ -10,7 +10,6 @@struct xfs_inode ;struct xfs_trans ;struct zone ; -struct xfs_dir_ops ;/* * Directory/attribute geometry information. There will be one of these for each fs/xfs/libxfs/xfs_da_format.c deleted +0
-46@@ -1,46 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* -* Copyright (c) 2000,2002,2005 Silicon Graphics, Inc. -* Copyright (c) 2013 Red Hat, Inc. -* All Rights Reserved. -*/ -#include "xfs.h" -#include "xfs_fs.h" -#include "xfs_shared.h" -#include "xfs_format.h" -#include "xfs_log_format.h" -#include "xfs_trans_resv.h" -#include "xfs_mount.h" -#include "xfs_inode.h" -#include "xfs_dir2.h" -#include "xfs_dir2_priv.h" - -static const struct xfs_dir_ops xfs_dir2_ops = { -}; - -static const struct xfs_dir_ops xfs_dir2_ftype_ops = { -}; - -static const struct xfs_dir_ops xfs_dir3_ops = { -}; - -/* -* Return the ops structure according to the current config. If we are passed -* an inode, then that overrides the default config we use which is based on -* feature bits. -*/ -const struct xfs_dir_ops * -xfs_dir_get_ops ( -struct xfs_mount *mp, -struct xfs_inode *dp) -{ -if (dp) -return dp->d_ops; -if (mp->m_dir_inode_ops) -return mp->m_dir_inode_ops; -if (xfs_sb_version_hascrc (&mp->m_sb)) -return &xfs_dir3_ops; -if (xfs_sb_version_hasftype (&mp->m_sb)) -return &xfs_dir2_ftype_ops; -return &xfs_dir2_ops; -}fs/xfs/libxfs/xfs_dir2.c +0
-2@@ -104,8 +104,6 @@ xfs_da_mount(ASSERT (mp->m_sb.sb_versionnum &XFS_SB_VERSION_DIRV2BIT );ASSERT (xfs_dir2_dirblock_bytes (&mp->m_sb) <=XFS_MAX_BLOCKSIZE ); - mp->m_dir_inode_ops =xfs_dir_get_ops (mp,NULL ); - mp->m_dir_geo =kmem_zalloc (sizeof (struct xfs_da_geometry ),KM_MAYFAIL ); mp->m_attr_geo = kmem_zalloc(sizeof(struct xfs_da_geometry),fs/xfs/libxfs/xfs_dir2.h +0
-9@@ -28,15 +28,6 @@ extern struct xfs_name xfs_name_dotdot;*/ extern unsigned char xfs_mode_to_ftype (int mode); -/* -* directory operations vector for encode/decode routines -*/ -struct xfs_dir_ops { -}; - -extern const struct xfs_dir_ops * -xfs_dir_get_ops (struct xfs_mount *mp,struct xfs_inode *dp); -/* * Generic directory interface routines */ fs/xfs/xfs_inode.h +0
-3@@ -37,9 +37,6 @@ typedef struct xfs_inode {struct xfs_ifork *i_cowfp;/* copy on write extents */ struct xfs_ifork i_df;/* data fork */ -/* operations vectors */ -const struct xfs_dir_ops *d_ops;/* directory ops vector */ -/* Transaction and locking information. */ struct xfs_inode_log_item *i_itemp;/* logging information */ mrlock_t i_lock;/* inode lock */ fs/xfs/xfs_iops.c +0
-1@@ -1317,7 +1317,6 @@ xfs_setup_inode(lockdep_set_class (&inode->i_rwsem, &inode->i_sb->s_type->i_mutex_dir_key);lockdep_set_class (&ip->i_lock.mr_lock, &xfs_dir_ilock_class); - ip->d_ops = ip->i_mount->m_dir_inode_ops; }else {lockdep_set_class (&ip->i_lock.mr_lock, &xfs_nondir_ilock_class); }fs/xfs/xfs_mount.h +0
-2@@ -12,7 +12,6 @@ struct xfs_mru_cache;struct xfs_nameops ;struct xfs_ail ;struct xfs_quotainfo ; -struct xfs_dir_ops ;struct xfs_da_geometry ;/* dynamic preallocation free space thresholds, 5% down to 1% */ @@ -158,7 +157,6 @@ typedef struct xfs_mount {int m_swidth;/* stripe width */ uint8_t m_sectbb_log;/* sectlog - BBSHIFT */ const struct xfs_nameops *m_dirnameops;/* vector of dir name ops */ -const struct xfs_dir_ops *m_dir_inode_ops;/* vector of dir inode ops */ uint m_chsize;/* size of next field */ atomic_t m_active_trans;/* number trans frozen */ struct xfs_mru_cache *m_filestream;/* per-mount filestream data */ Signature · 1 line
2.20.1
PATCH 33/34 xfs: merge xfs_dir2_data_freescan and xfs_dir2_data_freescan_int
In reply to Christoph HellwigThere is no real need for xfs_dir2_data_freescan wrapper, so rename xfs_dir2_data_freescan_int to xfs_dir2_data_freescan and let the callers dereference the mount pointer from the inode.
--- fs/xfs/libxfs/xfs_dir2.h | 4 +--- fs/xfs/libxfs/xfs_dir2_block.c | 10 +++++----- fs/xfs/libxfs/xfs_dir2_data.c | 11 +---------- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +++--- fs/xfs/libxfs/xfs_dir2_node.c | 4 ++-- 5 files changed, 12 insertions(+), 23 deletions(-)
fs/xfs/libxfs/xfs_dir2.h +1 -3
@@ -66,9 +66,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_mount *mp, -struct xfs_dir2_data_hdr *hdr,int *loghead); -extern void xfs_dir2_data_freescan (struct xfs_inode *dp, +extern void xfs_dir2_data_freescan (struct xfs_mount *mp,struct xfs_dir2_data_hdr *hdr,int *loghead);extern void xfs_dir2_data_log_entry (struct xfs_da_args *args,struct xfs_buf *bp,struct xfs_dir2_data_entry *dep);
fs/xfs/libxfs/xfs_dir2_block.c +5 -5
@@ -311,7 +311,7 @@ xfs_dir2_block_compact(* This needs to happen before the next call to use_free. */ if (needscan) -xfs_dir2_data_freescan (args->dp, hdr, needlog); +xfs_dir2_data_freescan (args->dp->i_mount, hdr, needlog); }/*
@@ -458,7 +458,7 @@ xfs_dir2_block_addname(* This needs to happen before the next call to use_free. */ if (needscan) { -xfs_dir2_data_freescan (dp, hdr, &needlog); +xfs_dir2_data_freescan (dp->i_mount, hdr, &needlog); needscan =0 ; }/*
@@ -548,7 +548,7 @@ xfs_dir2_block_addname(* Clean up the bestfree array and log the header, tail, and entry. */ if (needscan) -xfs_dir2_data_freescan (dp, hdr, &needlog); +xfs_dir2_data_freescan (dp->i_mount, hdr, &needlog);if (needlog)xfs_dir2_data_log_header (args, bp);xfs_dir2_block_log_tail (tp, bp);
@@ -807,7 +807,7 @@ xfs_dir2_block_removename(* Fix up bestfree, log the header if necessary. */ if (needscan) -xfs_dir2_data_freescan (dp, hdr, &needlog); +xfs_dir2_data_freescan (dp->i_mount, hdr, &needlog);if (needlog)xfs_dir2_data_log_header (args, bp);xfs_dir3_data_check (dp, bp);
@@ -1014,7 +1014,7 @@ xfs_dir2_leaf_to_block(* Scan the bestfree if we need it and log the data block header. */ if (needscan) -xfs_dir2_data_freescan (dp, hdr, &needlog); +xfs_dir2_data_freescan (dp->i_mount, hdr, &needlog);if (needlog)xfs_dir2_data_log_header (args, dbp);/*
fs/xfs/libxfs/xfs_dir2_data.c +1 -10
@@ -615,7 +615,7 @@ xfs_dir2_data_freeremove(* Given a data block, reconstruct its bestfree map. */ void -xfs_dir2_data_freescan_int ( +xfs_dir2_data_freescan (struct xfs_mount *mp,struct xfs_dir2_data_hdr *hdr,int *loghead)
@@ -670,15 +670,6 @@ xfs_dir2_data_freescan_int( } } -void -xfs_dir2_data_freescan ( -struct xfs_inode *dp, -struct xfs_dir2_data_hdr *hdr, -int *loghead) -{ -return xfs_dir2_data_freescan_int (dp->i_mount, hdr, loghead); -} -/* * Initialize a data block at the given block number in the directory. * Give back the buffer for the created block.
fs/xfs/libxfs/xfs_dir2_leaf.c +3 -3
@@ -465,7 +465,7 @@ xfs_dir2_block_to_leaf( hdr->magic =cpu_to_be32 (XFS_DIR3_DATA_MAGIC );if (needscan) -xfs_dir2_data_freescan (dp, hdr, &needlog); +xfs_dir2_data_freescan (dp->i_mount, hdr, &needlog);/* * Set up leaf tail and bests table. */
@@ -872,7 +872,7 @@ xfs_dir2_leaf_addname(* Need to scan fix up the bestfree table. */ if (needscan) -xfs_dir2_data_freescan (dp, hdr, &needlog); +xfs_dir2_data_freescan (dp->i_mount, hdr, &needlog);/* * Need to log the data block's header. */
@@ -1413,7 +1413,7 @@ xfs_dir2_leaf_removename(* log the data block header if necessary. */ if (needscan) -xfs_dir2_data_freescan (dp, hdr, &needlog); +xfs_dir2_data_freescan (dp->i_mount, hdr, &needlog);if (needlog)xfs_dir2_data_log_header (args, dbp);/*
fs/xfs/libxfs/xfs_dir2_node.c +2 -2
@@ -1322,7 +1322,7 @@ xfs_dir2_leafn_remove(* Log the data block header if needed. */ if (needscan) -xfs_dir2_data_freescan (dp, hdr, &needlog); +xfs_dir2_data_freescan (dp->i_mount, hdr, &needlog);if (needlog)xfs_dir2_data_log_header (args, dbp);xfs_dir3_data_check (dp, dbp);
@@ -1970,7 +1970,7 @@ xfs_dir2_node_addname_int(/* Rescan the freespace and log the data block if needed. */ if (needscan) -xfs_dir2_data_freescan (dp, hdr, &needlog); +xfs_dir2_data_freescan (dp->i_mount, hdr, &needlog);if (needlog)xfs_dir2_data_log_header (args, dbp);
Signature · 1 line
2.20.1
Re: [PATCH 33/34] xfs: merge xfs_dir2_data_freescan and xfs_dir2_data_freescan_int
Quoted 5 lines · Christoph Hellwig
There is no real need for
xfs_dir2_data_freescanwrapper, so renamexfs_dir2_data_freescan_inttoxfs_dir2_data_freescanand let the callers dereference the mount pointer from the inode.Signed-off-by Christoph Hellwig <[email protected]>
Seems reasonable to me,
--D
Quoted 157 lines
--- fs/xfs/libxfs/xfs_dir2.h | 4 +--- fs/xfs/libxfs/xfs_dir2_block.c | 10 +++++----- fs/xfs/libxfs/xfs_dir2_data.c | 11 +---------- fs/xfs/libxfs/xfs_dir2_leaf.c | 6 +++--- fs/xfs/libxfs/xfs_dir2_node.c | 4 ++-- 5 files changed, 12 insertions(+), 23 deletions(-)fs/xfs/libxfs/xfs_dir2.h +1
-3@@ -66,9 +66,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_mount *mp, -struct xfs_dir2_data_hdr *hdr,int *loghead); -extern void xfs_dir2_data_freescan (struct xfs_inode *dp, +extern void xfs_dir2_data_freescan (struct xfs_mount *mp,struct xfs_dir2_data_hdr *hdr,int *loghead);extern void xfs_dir2_data_log_entry (struct xfs_da_args *args,struct xfs_buf *bp,struct xfs_dir2_data_entry *dep);fs/xfs/libxfs/xfs_dir2_block.c +5
-5@@ -311,7 +311,7 @@ xfs_dir2_block_compact(* This needs to happen before the next call to use_free. */ if (needscan) -xfs_dir2_data_freescan (args->dp, hdr, needlog); +xfs_dir2_data_freescan (args->dp->i_mount, hdr, needlog); }/* @@ -458,7 +458,7 @@ xfs_dir2_block_addname(* This needs to happen before the next call to use_free. */ if (needscan) { -xfs_dir2_data_freescan (dp, hdr, &needlog); +xfs_dir2_data_freescan (dp->i_mount, hdr, &needlog); needscan =0 ; }/* @@ -548,7 +548,7 @@ xfs_dir2_block_addname(* Clean up the bestfree array and log the header, tail, and entry. */ if (needscan) -xfs_dir2_data_freescan (dp, hdr, &needlog); +xfs_dir2_data_freescan (dp->i_mount, hdr, &needlog);if (needlog)xfs_dir2_data_log_header (args, bp);xfs_dir2_block_log_tail (tp, bp);@@ -807,7 +807,7 @@ xfs_dir2_block_removename(* Fix up bestfree, log the header if necessary. */ if (needscan) -xfs_dir2_data_freescan (dp, hdr, &needlog); +xfs_dir2_data_freescan (dp->i_mount, hdr, &needlog);if (needlog)xfs_dir2_data_log_header (args, bp);xfs_dir3_data_check (dp, bp);@@ -1014,7 +1014,7 @@ xfs_dir2_leaf_to_block(* Scan the bestfree if we need it and log the data block header. */ if (needscan) -xfs_dir2_data_freescan (dp, hdr, &needlog); +xfs_dir2_data_freescan (dp->i_mount, hdr, &needlog);if (needlog)xfs_dir2_data_log_header (args, dbp);/* fs/xfs/libxfs/xfs_dir2_data.c +1
-10@@ -615,7 +615,7 @@ xfs_dir2_data_freeremove(* Given a data block, reconstruct its bestfree map. */ void -xfs_dir2_data_freescan_int ( +xfs_dir2_data_freescan (struct xfs_mount *mp,struct xfs_dir2_data_hdr *hdr,int *loghead)@@ -670,15 +670,6 @@ xfs_dir2_data_freescan_int( } } -void -xfs_dir2_data_freescan ( -struct xfs_inode *dp, -struct xfs_dir2_data_hdr *hdr, -int *loghead) -{ -return xfs_dir2_data_freescan_int (dp->i_mount, hdr, loghead); -} -/* * Initialize a data block at the given block number in the directory. * Give back the buffer for the created block. fs/xfs/libxfs/xfs_dir2_leaf.c +3
-3@@ -465,7 +465,7 @@ xfs_dir2_block_to_leaf( hdr->magic =cpu_to_be32 (XFS_DIR3_DATA_MAGIC );if (needscan) -xfs_dir2_data_freescan (dp, hdr, &needlog); +xfs_dir2_data_freescan (dp->i_mount, hdr, &needlog);/* * Set up leaf tail and bests table. */ @@ -872,7 +872,7 @@ xfs_dir2_leaf_addname(* Need to scan fix up the bestfree table. */ if (needscan) -xfs_dir2_data_freescan (dp, hdr, &needlog); +xfs_dir2_data_freescan (dp->i_mount, hdr, &needlog);/* * Need to log the data block's header. */ @@ -1413,7 +1413,7 @@ xfs_dir2_leaf_removename(* log the data block header if necessary. */ if (needscan) -xfs_dir2_data_freescan (dp, hdr, &needlog); +xfs_dir2_data_freescan (dp->i_mount, hdr, &needlog);if (needlog)xfs_dir2_data_log_header (args, dbp);/* fs/xfs/libxfs/xfs_dir2_node.c +2
-2@@ -1322,7 +1322,7 @@ xfs_dir2_leafn_remove(* Log the data block header if needed. */ if (needscan) -xfs_dir2_data_freescan (dp, hdr, &needlog); +xfs_dir2_data_freescan (dp->i_mount, hdr, &needlog);if (needlog)xfs_dir2_data_log_header (args, dbp);xfs_dir3_data_check (dp, dbp);@@ -1970,7 +1970,7 @@ xfs_dir2_node_addname_int(/* Rescan the freespace and log the data block if needed. */ if (needscan) -xfs_dir2_data_freescan (dp, hdr, &needlog); +xfs_dir2_data_freescan (dp->i_mount, hdr, &needlog);if (needlog)xfs_dir2_data_log_header (args, dbp);Signature · 1 line
2.20.1
PATCH 34/34 xfs: always pass a valid hdr to xfs_dir3_leaf_check_int
In reply to Christoph HellwigMove the code for extracting the incore header to the only caller that didn't already do that.
--- fs/xfs/libxfs/xfs_dir2_leaf.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-)
fs/xfs/libxfs/xfs_dir2_leaf.c +13 -18
@@ -137,20 +137,14 @@ xfs_dir3_leaf_check(xfs_failaddr_t xfs_dir3_leaf_check_int ( -struct xfs_mount *mp, -struct xfs_dir3_icleaf_hdr *hdr, -struct xfs_dir2_leaf *leaf) +struct xfs_mount *mp, +struct xfs_dir3_icleaf_hdr *hdr, +struct xfs_dir2_leaf *leaf) { -xfs_dir2_leaf_tail_t *ltp; -int stale; -int i; -struct xfs_dir3_icleaf_hdr leafhdr; -struct xfs_da_geometry *geo = mp->m_dir_geo; - -if (!hdr) { -xfs_dir2_leaf_hdr_from_disk (mp, &leafhdr, leaf); - hdr = &leafhdr; - } +struct xfs_da_geometry *geo = mp->m_dir_geo; +xfs_dir2_leaf_tail_t *ltp; +int stale; +int i; ltp =xfs_dir2_leaf_tail_p (geo, leaf);
@@ -190,17 +184,18 @@ xfs_dir3_leaf_check_int(*/ static xfs_failaddr_t xfs_dir3_leaf_verify ( -struct xfs_buf *bp) +struct xfs_buf *bp) { -struct xfs_mount *mp = bp->b_mount; -struct xfs_dir2_leaf *leaf = bp->b_addr; -xfs_failaddr_t fa; +struct xfs_mount *mp = bp->b_mount; +struct xfs_dir3_icleaf_hdr leafhdr; +xfs_failaddr_t fa; fa =xfs_da3_blkinfo_verify (bp, bp->b_addr);if (fa)return fa; -return xfs_dir3_leaf_check_int (mp,NULL , leaf); +xfs_dir2_leaf_hdr_from_disk (mp, &leafhdr, bp->b_addr); +return xfs_dir3_leaf_check_int (mp, &leafhdr, bp->b_addr); } static void
Signature · 1 line
2.20.1
Re: [PATCH 34/34] xfs: always pass a valid hdr to xfs_dir3_leaf_check_int
Quoted 4 lines · Christoph Hellwig
Move the code for extracting the incore header to the only caller that didn't already do that.
Signed-off-by Christoph Hellwig <[email protected]>
Well, that was quite the cleanup. Even more surprisingly it didn't clash too badly with the health reporting patch series I sent yesterday. :)
--D
Quoted 63 lines
--- fs/xfs/libxfs/xfs_dir2_leaf.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-)fs/xfs/libxfs/xfs_dir2_leaf.c +13
-18@@ -137,20 +137,14 @@ xfs_dir3_leaf_check(xfs_failaddr_t xfs_dir3_leaf_check_int ( -struct xfs_mount *mp, -struct xfs_dir3_icleaf_hdr *hdr, -struct xfs_dir2_leaf *leaf) +struct xfs_mount *mp, +struct xfs_dir3_icleaf_hdr *hdr, +struct xfs_dir2_leaf *leaf) { -xfs_dir2_leaf_tail_t *ltp; -int stale; -int i; -struct xfs_dir3_icleaf_hdr leafhdr; -struct xfs_da_geometry *geo = mp->m_dir_geo; - -if (!hdr) { -xfs_dir2_leaf_hdr_from_disk (mp, &leafhdr, leaf); - hdr = &leafhdr; - } +struct xfs_da_geometry *geo = mp->m_dir_geo; +xfs_dir2_leaf_tail_t *ltp; +int stale; +int i; ltp =xfs_dir2_leaf_tail_p (geo, leaf);@@ -190,17 +184,18 @@ xfs_dir3_leaf_check_int(*/ static xfs_failaddr_t xfs_dir3_leaf_verify ( -struct xfs_buf *bp) +struct xfs_buf *bp) { -struct xfs_mount *mp = bp->b_mount; -struct xfs_dir2_leaf *leaf = bp->b_addr; -xfs_failaddr_t fa; +struct xfs_mount *mp = bp->b_mount; +struct xfs_dir3_icleaf_hdr leafhdr; +xfs_failaddr_t fa; fa =xfs_da3_blkinfo_verify (bp, bp->b_addr);if (fa)return fa; -return xfs_dir3_leaf_check_int (mp,NULL , leaf); +xfs_dir2_leaf_hdr_from_disk (mp, &leafhdr, bp->b_addr); +return xfs_dir3_leaf_check_int (mp, &leafhdr, bp->b_addr); } static voidSignature · 1 line
2.20.1