From c9cfdb381172174ade2445e7b468f1be550b1a44 Mon Sep 17 00:00:00 2001 From: Brian Foster Date: Wed, 11 Jul 2018 22:26:08 -0700 Subject: xfs: remove dfops param from high level dirname calls All callers of the directory create, rename and remove interfaces already associate the dfops with the transaction. Drop the dfops parameters in these calls in preparation for further cleanups in the layers below. This patch does not change behavior. Signed-off-by: Brian Foster Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_dir2.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'fs/xfs/libxfs/xfs_dir2.c') diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index 59169aff30fe..c98250f0de50 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -244,7 +244,6 @@ xfs_dir_createname( struct xfs_name *name, xfs_ino_t inum, /* new entry inode number */ xfs_fsblock_t *first, /* bmap's firstblock */ - struct xfs_defer_ops *dfops, /* bmap's freeblock list */ xfs_extlen_t total) /* bmap's total block count */ { struct xfs_da_args *args; @@ -252,6 +251,8 @@ xfs_dir_createname( int v; /* type-checking value */ ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); + ASSERT(tp->t_dfops || !first); + if (inum) { rval = xfs_dir_ino_validate(tp->t_mountp, inum); if (rval) @@ -270,11 +271,11 @@ xfs_dir_createname( args->hashval = dp->i_mount->m_dirnameops->hashname(name); args->inumber = inum; args->dp = dp; - args->firstblock = first; - args->dfops = dfops; args->total = total; args->whichfork = XFS_DATA_FORK; args->trans = tp; + args->dfops = tp->t_dfops; + args->firstblock = first; args->op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT; if (!inum) args->op_flags |= XFS_DA_OP_JUSTCHECK; @@ -421,7 +422,6 @@ xfs_dir_removename( struct xfs_name *name, xfs_ino_t ino, xfs_fsblock_t *first, /* bmap's firstblock */ - struct xfs_defer_ops *dfops, /* bmap's freeblock list */ xfs_extlen_t total) /* bmap's total block count */ { struct xfs_da_args *args; @@ -429,6 +429,7 @@ xfs_dir_removename( int v; /* type-checking value */ ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); + ASSERT(tp->t_dfops); XFS_STATS_INC(dp->i_mount, xs_dir_remove); args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS); @@ -443,10 +444,10 @@ xfs_dir_removename( args->inumber = ino; args->dp = dp; args->firstblock = first; - args->dfops = dfops; args->total = total; args->whichfork = XFS_DATA_FORK; args->trans = tp; + args->dfops = tp->t_dfops; if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL) { rval = xfs_dir2_sf_removename(args); @@ -483,7 +484,6 @@ xfs_dir_replace( struct xfs_name *name, /* name of entry to replace */ xfs_ino_t inum, /* new inode number */ xfs_fsblock_t *first, /* bmap's firstblock */ - struct xfs_defer_ops *dfops, /* bmap's freeblock list */ xfs_extlen_t total) /* bmap's total block count */ { struct xfs_da_args *args; @@ -491,6 +491,7 @@ xfs_dir_replace( int v; /* type-checking value */ ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); + ASSERT(tp->t_dfops); rval = xfs_dir_ino_validate(tp->t_mountp, inum); if (rval) @@ -508,10 +509,10 @@ xfs_dir_replace( args->inumber = inum; args->dp = dp; args->firstblock = first; - args->dfops = dfops; args->total = total; args->whichfork = XFS_DATA_FORK; args->trans = tp; + args->dfops = tp->t_dfops; if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL) { rval = xfs_dir2_sf_replace(args); @@ -547,7 +548,7 @@ xfs_dir_canenter( xfs_inode_t *dp, struct xfs_name *name) /* name of entry to add */ { - return xfs_dir_createname(tp, dp, name, 0, NULL, NULL, 0); + return xfs_dir_createname(tp, dp, name, 0, NULL, 0); } /* -- cgit From 32a9b7c65cfc7d9283055fc9d61e6393ee2aa984 Mon Sep 17 00:00:00 2001 From: Brian Foster Date: Wed, 11 Jul 2018 22:26:11 -0700 Subject: xfs: replace xfs_da_args->dfops accesses with ->t_dfops and remove Now that xfs_da_args->dfops is always assigned from a ->t_dfops pointer (or one that is immediately attached), replace all downstream accesses of the former with the latter and remove the field from struct xfs_da_args. Signed-off-by: Brian Foster Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 103 +++++++++++++++++++++------------------- fs/xfs/libxfs/xfs_attr_leaf.c | 24 +++++----- fs/xfs/libxfs/xfs_attr_remote.c | 23 ++++----- fs/xfs/libxfs/xfs_bmap.c | 1 - fs/xfs/libxfs/xfs_da_btree.c | 19 ++++---- fs/xfs/libxfs/xfs_da_btree.h | 1 - fs/xfs/libxfs/xfs_dir2.c | 65 ++++++++++++------------- 7 files changed, 117 insertions(+), 119 deletions(-) (limited to 'fs/xfs/libxfs/xfs_dir2.c') diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index cc23c269f2bf..a14ab9b2669e 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -220,7 +220,6 @@ xfs_attr_set( args.value = value; args.valuelen = valuelen; args.firstblock = &firstblock; - args.dfops = &dfops; args.op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT; args.total = xfs_attr_calc_size(&args, &local); @@ -407,7 +406,6 @@ xfs_attr_remove( return error; args.firstblock = &firstblock; - args.dfops = &dfops; /* * we have no control over the attribute names that userspace passes us @@ -539,11 +537,12 @@ xfs_attr_shortform_addname(xfs_da_args_t *args) * if bmap_one_block() says there is only one block (ie: no remote blks). */ STATIC int -xfs_attr_leaf_addname(xfs_da_args_t *args) +xfs_attr_leaf_addname( + struct xfs_da_args *args) { - xfs_inode_t *dp; - struct xfs_buf *bp; - int retval, error, forkoff; + struct xfs_inode *dp; + struct xfs_buf *bp; + int retval, error, forkoff; trace_xfs_attr_leaf_addname(args); @@ -601,12 +600,12 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) * Commit that transaction so that the node_addname() call * can manage its own transactions. */ - xfs_defer_init(args->dfops, args->firstblock); + xfs_defer_init(args->trans->t_dfops, args->firstblock); error = xfs_attr3_leaf_to_node(args); if (error) goto out_defer_cancel; - xfs_defer_ijoin(args->dfops, dp); - error = xfs_defer_finish(&args->trans, args->dfops); + xfs_defer_ijoin(args->trans->t_dfops, dp); + error = xfs_defer_finish(&args->trans, args->trans->t_dfops); if (error) goto out_defer_cancel; @@ -690,13 +689,13 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) * If the result is small enough, shrink it all into the inode. */ if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { - xfs_defer_init(args->dfops, args->firstblock); + xfs_defer_init(args->trans->t_dfops, args->firstblock); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); /* bp is gone due to xfs_da_shrink_inode */ if (error) goto out_defer_cancel; - xfs_defer_ijoin(args->dfops, dp); - error = xfs_defer_finish(&args->trans, args->dfops); + xfs_defer_ijoin(args->trans->t_dfops, dp); + error = xfs_defer_finish(&args->trans, args->trans->t_dfops); if (error) goto out_defer_cancel; } @@ -714,7 +713,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) } return error; out_defer_cancel: - xfs_defer_cancel(args->dfops); + xfs_defer_cancel(args->trans->t_dfops); return error; } @@ -725,11 +724,12 @@ out_defer_cancel: * if bmap_one_block() says there is only one block (ie: no remote blks). */ STATIC int -xfs_attr_leaf_removename(xfs_da_args_t *args) +xfs_attr_leaf_removename( + struct xfs_da_args *args) { - xfs_inode_t *dp; - struct xfs_buf *bp; - int error, forkoff; + struct xfs_inode *dp; + struct xfs_buf *bp; + int error, forkoff; trace_xfs_attr_leaf_removename(args); @@ -754,19 +754,19 @@ xfs_attr_leaf_removename(xfs_da_args_t *args) * If the result is small enough, shrink it all into the inode. */ if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { - xfs_defer_init(args->dfops, args->firstblock); + xfs_defer_init(args->trans->t_dfops, args->firstblock); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); /* bp is gone due to xfs_da_shrink_inode */ if (error) goto out_defer_cancel; - xfs_defer_ijoin(args->dfops, dp); - error = xfs_defer_finish(&args->trans, args->dfops); + xfs_defer_ijoin(args->trans->t_dfops, dp); + error = xfs_defer_finish(&args->trans, args->trans->t_dfops); if (error) goto out_defer_cancel; } return 0; out_defer_cancel: - xfs_defer_cancel(args->dfops); + xfs_defer_cancel(args->trans->t_dfops); return error; } @@ -817,13 +817,14 @@ xfs_attr_leaf_get(xfs_da_args_t *args) * add a whole extra layer of confusion on top of that. */ STATIC int -xfs_attr_node_addname(xfs_da_args_t *args) +xfs_attr_node_addname( + struct xfs_da_args *args) { - xfs_da_state_t *state; - xfs_da_state_blk_t *blk; - xfs_inode_t *dp; - xfs_mount_t *mp; - int retval, error; + struct xfs_da_state *state; + struct xfs_da_state_blk *blk; + struct xfs_inode *dp; + struct xfs_mount *mp; + int retval, error; trace_xfs_attr_node_addname(args); @@ -882,12 +883,13 @@ restart: */ xfs_da_state_free(state); state = NULL; - xfs_defer_init(args->dfops, args->firstblock); + xfs_defer_init(args->trans->t_dfops, args->firstblock); error = xfs_attr3_leaf_to_node(args); if (error) goto out_defer_cancel; - xfs_defer_ijoin(args->dfops, dp); - error = xfs_defer_finish(&args->trans, args->dfops); + xfs_defer_ijoin(args->trans->t_dfops, dp); + error = xfs_defer_finish(&args->trans, + args->trans->t_dfops); if (error) goto out_defer_cancel; @@ -908,12 +910,12 @@ restart: * in the index/blkno/rmtblkno/rmtblkcnt fields and * in the index2/blkno2/rmtblkno2/rmtblkcnt2 fields. */ - xfs_defer_init(args->dfops, args->firstblock); + xfs_defer_init(args->trans->t_dfops, args->firstblock); error = xfs_da3_split(state); if (error) goto out_defer_cancel; - xfs_defer_ijoin(args->dfops, dp); - error = xfs_defer_finish(&args->trans, args->dfops); + xfs_defer_ijoin(args->trans->t_dfops, dp); + error = xfs_defer_finish(&args->trans, args->trans->t_dfops); if (error) goto out_defer_cancel; } else { @@ -1006,12 +1008,12 @@ restart: * Check to see if the tree needs to be collapsed. */ if (retval && (state->path.active > 1)) { - xfs_defer_init(args->dfops, args->firstblock); + xfs_defer_init(args->trans->t_dfops, args->firstblock); error = xfs_da3_join(state); if (error) goto out_defer_cancel; - xfs_defer_ijoin(args->dfops, dp); - error = xfs_defer_finish(&args->trans, args->dfops); + xfs_defer_ijoin(args->trans->t_dfops, dp); + error = xfs_defer_finish(&args->trans, args->trans->t_dfops); if (error) goto out_defer_cancel; } @@ -1040,7 +1042,7 @@ out: return error; return retval; out_defer_cancel: - xfs_defer_cancel(args->dfops); + xfs_defer_cancel(args->trans->t_dfops); goto out; } @@ -1052,13 +1054,14 @@ out_defer_cancel: * the root node (a special case of an intermediate node). */ STATIC int -xfs_attr_node_removename(xfs_da_args_t *args) +xfs_attr_node_removename( + struct xfs_da_args *args) { - xfs_da_state_t *state; - xfs_da_state_blk_t *blk; - xfs_inode_t *dp; - struct xfs_buf *bp; - int retval, error, forkoff; + struct xfs_da_state *state; + struct xfs_da_state_blk *blk; + struct xfs_inode *dp; + struct xfs_buf *bp; + int retval, error, forkoff; trace_xfs_attr_node_removename(args); @@ -1130,12 +1133,12 @@ xfs_attr_node_removename(xfs_da_args_t *args) * Check to see if the tree needs to be collapsed. */ if (retval && (state->path.active > 1)) { - xfs_defer_init(args->dfops, args->firstblock); + xfs_defer_init(args->trans->t_dfops, args->firstblock); error = xfs_da3_join(state); if (error) goto out_defer_cancel; - xfs_defer_ijoin(args->dfops, dp); - error = xfs_defer_finish(&args->trans, args->dfops); + xfs_defer_ijoin(args->trans->t_dfops, dp); + error = xfs_defer_finish(&args->trans, args->trans->t_dfops); if (error) goto out_defer_cancel; /* @@ -1162,13 +1165,13 @@ xfs_attr_node_removename(xfs_da_args_t *args) goto out; if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { - xfs_defer_init(args->dfops, args->firstblock); + xfs_defer_init(args->trans->t_dfops, args->firstblock); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); /* bp is gone due to xfs_da_shrink_inode */ if (error) goto out_defer_cancel; - xfs_defer_ijoin(args->dfops, dp); - error = xfs_defer_finish(&args->trans, args->dfops); + xfs_defer_ijoin(args->trans->t_dfops, dp); + error = xfs_defer_finish(&args->trans, args->trans->t_dfops); if (error) goto out_defer_cancel; } else @@ -1180,7 +1183,7 @@ out: xfs_da_state_free(state); return error; out_defer_cancel: - xfs_defer_cancel(args->dfops); + xfs_defer_cancel(args->trans->t_dfops); goto out; } diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 76e90046731c..c131469db0f1 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -747,18 +747,18 @@ xfs_attr_shortform_getvalue(xfs_da_args_t *args) */ int xfs_attr_shortform_to_leaf( - struct xfs_da_args *args, - struct xfs_buf **leaf_bp) + struct xfs_da_args *args, + struct xfs_buf **leaf_bp) { - xfs_inode_t *dp; - xfs_attr_shortform_t *sf; - xfs_attr_sf_entry_t *sfe; - xfs_da_args_t nargs; - char *tmpbuffer; - int error, i, size; - xfs_dablk_t blkno; - struct xfs_buf *bp; - xfs_ifork_t *ifp; + struct xfs_inode *dp; + struct xfs_attr_shortform *sf; + struct xfs_attr_sf_entry *sfe; + struct xfs_da_args nargs; + char *tmpbuffer; + int error, i, size; + xfs_dablk_t blkno; + struct xfs_buf *bp; + struct xfs_ifork *ifp; trace_xfs_attr_sf_to_leaf(args); @@ -803,7 +803,6 @@ xfs_attr_shortform_to_leaf( nargs.dp = dp; nargs.geo = args->geo; nargs.firstblock = args->firstblock; - nargs.dfops = args->dfops; nargs.total = args->total; nargs.whichfork = XFS_ATTR_FORK; nargs.trans = args->trans; @@ -1007,7 +1006,6 @@ xfs_attr3_leaf_to_shortform( nargs.geo = args->geo; nargs.dp = dp; nargs.firstblock = args->firstblock; - nargs.dfops = args->dfops; nargs.total = args->total; nargs.whichfork = XFS_ATTR_FORK; nargs.trans = args->trans; diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index bf2e0371149b..577c4c372265 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -480,15 +480,16 @@ xfs_attr_rmtval_set( * extent and then crash then the block may not contain the * correct metadata after log recovery occurs. */ - xfs_defer_init(args->dfops, args->firstblock); + xfs_defer_init(args->trans->t_dfops, args->firstblock); nmap = 1; error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno, blkcnt, XFS_BMAPI_ATTRFORK, args->firstblock, - args->total, &map, &nmap, args->dfops); + args->total, &map, &nmap, + args->trans->t_dfops); if (error) goto out_defer_cancel; - xfs_defer_ijoin(args->dfops, dp); - error = xfs_defer_finish(&args->trans, args->dfops); + xfs_defer_ijoin(args->trans->t_dfops, dp); + error = xfs_defer_finish(&args->trans, args->trans->t_dfops); if (error) goto out_defer_cancel; @@ -522,7 +523,7 @@ xfs_attr_rmtval_set( ASSERT(blkcnt > 0); - xfs_defer_init(args->dfops, args->firstblock); + xfs_defer_init(args->trans->t_dfops, args->firstblock); nmap = 1; error = xfs_bmapi_read(dp, (xfs_fileoff_t)lblkno, blkcnt, &map, &nmap, @@ -557,7 +558,7 @@ xfs_attr_rmtval_set( ASSERT(valuelen == 0); return 0; out_defer_cancel: - xfs_defer_cancel(args->dfops); + xfs_defer_cancel(args->trans->t_dfops); args->trans = NULL; return error; } @@ -626,14 +627,14 @@ xfs_attr_rmtval_remove( blkcnt = args->rmtblkcnt; done = 0; while (!done) { - xfs_defer_init(args->dfops, args->firstblock); + xfs_defer_init(args->trans->t_dfops, args->firstblock); error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt, XFS_BMAPI_ATTRFORK, 1, args->firstblock, - args->dfops, &done); + args->trans->t_dfops, &done); if (error) goto out_defer_cancel; - xfs_defer_ijoin(args->dfops, args->dp); - error = xfs_defer_finish(&args->trans, args->dfops); + xfs_defer_ijoin(args->trans->t_dfops, args->dp); + error = xfs_defer_finish(&args->trans, args->trans->t_dfops); if (error) goto out_defer_cancel; @@ -646,7 +647,7 @@ xfs_attr_rmtval_remove( } return 0; out_defer_cancel: - xfs_defer_cancel(args->dfops); + xfs_defer_cancel(args->trans->t_dfops); args->trans = NULL; return error; } diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 459a29cb17c2..c65aeb088552 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -1007,7 +1007,6 @@ xfs_bmap_add_attrfork_local( dargs.geo = ip->i_mount->m_dir_geo; dargs.dp = ip; dargs.firstblock = firstblock; - dargs.dfops = tp->t_dfops; dargs.total = dargs.geo->fsbcount; dargs.whichfork = XFS_DATA_FORK; dargs.trans = tp; diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index 8a301402bbc4..d2048e4e93ec 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -2063,7 +2063,7 @@ xfs_da_grow_inode_int( error = xfs_bmapi_write(tp, dp, *bno, count, xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA|XFS_BMAPI_CONTIG, args->firstblock, args->total, &map, &nmap, - args->dfops); + args->trans->t_dfops); if (error) return error; @@ -2086,7 +2086,8 @@ xfs_da_grow_inode_int( error = xfs_bmapi_write(tp, dp, b, c, xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA, args->firstblock, args->total, - &mapp[mapi], &nmap, args->dfops); + &mapp[mapi], &nmap, + args->trans->t_dfops); if (error) goto out_free_map; if (nmap < 1) @@ -2375,13 +2376,13 @@ done: */ int xfs_da_shrink_inode( - xfs_da_args_t *args, - xfs_dablk_t dead_blkno, - struct xfs_buf *dead_buf) + struct xfs_da_args *args, + xfs_dablk_t dead_blkno, + struct xfs_buf *dead_buf) { - xfs_inode_t *dp; - int done, error, w, count; - xfs_trans_t *tp; + struct xfs_inode *dp; + int done, error, w, count; + struct xfs_trans *tp; trace_xfs_da_shrink_inode(args); @@ -2396,7 +2397,7 @@ xfs_da_shrink_inode( */ error = xfs_bunmapi(tp, dp, dead_blkno, count, xfs_bmapi_aflag(w), 0, args->firstblock, - args->dfops, &done); + args->trans->t_dfops, &done); if (error == -ENOSPC) { if (w != XFS_DATA_FORK) break; diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h index 28260073ae71..6b8a04f3f162 100644 --- a/fs/xfs/libxfs/xfs_da_btree.h +++ b/fs/xfs/libxfs/xfs_da_btree.h @@ -58,7 +58,6 @@ typedef struct xfs_da_args { xfs_ino_t inumber; /* input/output inode number */ struct xfs_inode *dp; /* directory inode to manipulate */ xfs_fsblock_t *firstblock; /* ptr to firstblock for bmap calls */ - struct xfs_defer_ops *dfops; /* ptr to freelist for bmap_finish */ struct xfs_trans *trans; /* current trans (changes over time) */ xfs_extlen_t total; /* total blocks needed, for 1st bmap */ int whichfork; /* data or attribute fork */ diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index c98250f0de50..b21f55a11f35 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -239,8 +239,8 @@ xfs_dir_init( */ int xfs_dir_createname( - xfs_trans_t *tp, - xfs_inode_t *dp, + struct xfs_trans *tp, + struct xfs_inode *dp, struct xfs_name *name, xfs_ino_t inum, /* new entry inode number */ xfs_fsblock_t *first, /* bmap's firstblock */ @@ -274,7 +274,6 @@ xfs_dir_createname( args->total = total; args->whichfork = XFS_DATA_FORK; args->trans = tp; - args->dfops = tp->t_dfops; args->firstblock = first; args->op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT; if (!inum) @@ -417,16 +416,16 @@ out_free: */ int xfs_dir_removename( - xfs_trans_t *tp, - xfs_inode_t *dp, - struct xfs_name *name, - xfs_ino_t ino, - xfs_fsblock_t *first, /* bmap's firstblock */ - xfs_extlen_t total) /* bmap's total block count */ + struct xfs_trans *tp, + struct xfs_inode *dp, + struct xfs_name *name, + xfs_ino_t ino, + xfs_fsblock_t *first, /* bmap's firstblock */ + xfs_extlen_t total) /* bmap's total block count */ { - struct xfs_da_args *args; - int rval; - int v; /* type-checking value */ + struct xfs_da_args *args; + int rval; + int v; /* type-checking value */ ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); ASSERT(tp->t_dfops); @@ -447,7 +446,6 @@ xfs_dir_removename( args->total = total; args->whichfork = XFS_DATA_FORK; args->trans = tp; - args->dfops = tp->t_dfops; if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL) { rval = xfs_dir2_sf_removename(args); @@ -479,16 +477,16 @@ out_free: */ int xfs_dir_replace( - xfs_trans_t *tp, - xfs_inode_t *dp, - struct xfs_name *name, /* name of entry to replace */ - xfs_ino_t inum, /* new inode number */ - xfs_fsblock_t *first, /* bmap's firstblock */ - xfs_extlen_t total) /* bmap's total block count */ + struct xfs_trans *tp, + struct xfs_inode *dp, + struct xfs_name *name, /* name of entry to replace */ + xfs_ino_t inum, /* new inode number */ + xfs_fsblock_t *first, /* bmap's firstblock */ + xfs_extlen_t total) /* bmap's total block count */ { - struct xfs_da_args *args; - int rval; - int v; /* type-checking value */ + struct xfs_da_args *args; + int rval; + int v; /* type-checking value */ ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); ASSERT(tp->t_dfops); @@ -512,7 +510,6 @@ xfs_dir_replace( args->total = total; args->whichfork = XFS_DATA_FORK; args->trans = tp; - args->dfops = tp->t_dfops; if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL) { rval = xfs_dir2_sf_replace(args); @@ -646,17 +643,17 @@ xfs_dir2_isleaf( */ int xfs_dir2_shrink_inode( - xfs_da_args_t *args, - xfs_dir2_db_t db, - struct xfs_buf *bp) + struct xfs_da_args *args, + xfs_dir2_db_t db, + struct xfs_buf *bp) { - xfs_fileoff_t bno; /* directory file offset */ - xfs_dablk_t da; /* directory file offset */ - int done; /* bunmap is finished */ - xfs_inode_t *dp; - int error; - xfs_mount_t *mp; - xfs_trans_t *tp; + xfs_fileoff_t bno; /* directory file offset */ + xfs_dablk_t da; /* directory file offset */ + int done; /* bunmap is finished */ + struct xfs_inode *dp; + int error; + struct xfs_mount *mp; + struct xfs_trans *tp; trace_xfs_dir2_shrink_inode(args, db); @@ -667,7 +664,7 @@ xfs_dir2_shrink_inode( /* Unmap the fsblock(s). */ error = xfs_bunmapi(tp, dp, da, args->geo->fsbcount, 0, 0, - args->firstblock, args->dfops, &done); + args->firstblock, args->trans->t_dfops, &done); if (error) { /* * ENOSPC actually can happen if we're in a removename with no -- cgit From ccd9d91148780a5e979ac00bce67c2155fb6378f Mon Sep 17 00:00:00 2001 From: Brian Foster Date: Wed, 11 Jul 2018 22:26:13 -0700 Subject: xfs: remove xfs_bunmapi() dfops param Now that all xfs_bunmapi() callers use ->t_dfops, remove the unnecessary parameter and access ->t_dfops directly. This patch does not change behavior. Signed-off-by: Brian Foster Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_bmap.c | 20 +++++++++----------- fs/xfs/libxfs/xfs_bmap.h | 5 ++--- fs/xfs/libxfs/xfs_da_btree.c | 2 +- fs/xfs/libxfs/xfs_dir2.c | 2 +- fs/xfs/xfs_bmap_util.c | 2 +- fs/xfs/xfs_inode.c | 2 +- fs/xfs/xfs_reflink.c | 5 ++--- fs/xfs/xfs_symlink.c | 3 +-- 9 files changed, 19 insertions(+), 24 deletions(-) (limited to 'fs/xfs/libxfs/xfs_dir2.c') diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index 1f2bc86a28ed..179259fd1b5e 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -629,7 +629,7 @@ xfs_attr_rmtval_remove( xfs_defer_init(args->trans->t_dfops, args->firstblock); error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt, XFS_BMAPI_ATTRFORK, 1, args->firstblock, - args->trans->t_dfops, &done); + &done); if (error) goto out_defer_cancel; xfs_defer_ijoin(args->trans->t_dfops, args->dp); diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 02e72c195c4f..9c778e50ad19 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -5143,26 +5143,26 @@ done: */ int /* error */ __xfs_bunmapi( - xfs_trans_t *tp, /* transaction pointer */ + struct xfs_trans *tp, /* transaction pointer */ struct xfs_inode *ip, /* incore inode */ xfs_fileoff_t start, /* first file offset deleted */ xfs_filblks_t *rlen, /* i/o: amount remaining */ int flags, /* misc flags */ xfs_extnum_t nexts, /* number of extents max */ - xfs_fsblock_t *firstblock, /* first allocated block + xfs_fsblock_t *firstblock) /* first allocated block controls a.g. for allocs */ - struct xfs_defer_ops *dfops) /* i/o: deferred updates */ { - xfs_btree_cur_t *cur; /* bmap btree cursor */ - xfs_bmbt_irec_t del; /* extent being deleted */ + struct xfs_defer_ops *dfops = tp ? tp->t_dfops : NULL; + struct xfs_btree_cur *cur; /* bmap btree cursor */ + struct xfs_bmbt_irec del; /* extent being deleted */ int error; /* error return value */ xfs_extnum_t extno; /* extent number in list */ - xfs_bmbt_irec_t got; /* current extent record */ + struct xfs_bmbt_irec got; /* current extent record */ xfs_ifork_t *ifp; /* inode fork pointer */ int isrt; /* freeing in rt area */ int logflags; /* transaction logging flags */ xfs_extlen_t mod; /* rt extent offset */ - xfs_mount_t *mp; /* mount structure */ + struct xfs_mount *mp; /* mount structure */ int tmp_logflags; /* partial logging flags */ int wasdel; /* was a delayed alloc extent */ int whichfork; /* data or attribute fork */ @@ -5516,13 +5516,11 @@ xfs_bunmapi( int flags, xfs_extnum_t nexts, xfs_fsblock_t *firstblock, - struct xfs_defer_ops *dfops, int *done) { int error; - error = __xfs_bunmapi(tp, ip, bno, &len, flags, nexts, firstblock, - dfops); + error = __xfs_bunmapi(tp, ip, bno, &len, flags, nexts, firstblock); *done = (len == 0); return error; } @@ -6193,7 +6191,7 @@ xfs_bmap_finish_one( break; case XFS_BMAP_UNMAP: error = __xfs_bunmapi(tp, ip, startoff, blockcount, - XFS_BMAPI_REMAP, 1, &firstfsb, dfops); + XFS_BMAPI_REMAP, 1, &firstfsb); break; default: ASSERT(0); diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h index fc86cc218c58..a83906ec6141 100644 --- a/fs/xfs/libxfs/xfs_bmap.h +++ b/fs/xfs/libxfs/xfs_bmap.h @@ -206,12 +206,11 @@ int xfs_bmapi_write(struct xfs_trans *tp, struct xfs_inode *ip, struct xfs_bmbt_irec *mval, int *nmap); int __xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip, xfs_fileoff_t bno, xfs_filblks_t *rlen, int flags, - xfs_extnum_t nexts, xfs_fsblock_t *firstblock, - struct xfs_defer_ops *dfops); + xfs_extnum_t nexts, xfs_fsblock_t *firstblock); int xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip, xfs_fileoff_t bno, xfs_filblks_t len, int flags, xfs_extnum_t nexts, xfs_fsblock_t *firstblock, - struct xfs_defer_ops *dfops, int *done); + int *done); int xfs_bmap_del_extent_delay(struct xfs_inode *ip, int whichfork, struct xfs_iext_cursor *cur, struct xfs_bmbt_irec *got, struct xfs_bmbt_irec *del); diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index e43f1dda02e4..68a72e3d9f53 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -2395,7 +2395,7 @@ xfs_da_shrink_inode( */ error = xfs_bunmapi(tp, dp, dead_blkno, count, xfs_bmapi_aflag(w), 0, args->firstblock, - args->trans->t_dfops, &done); + &done); if (error == -ENOSPC) { if (w != XFS_DATA_FORK) break; diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index b21f55a11f35..781dc63d305d 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -664,7 +664,7 @@ xfs_dir2_shrink_inode( /* Unmap the fsblock(s). */ error = xfs_bunmapi(tp, dp, da, args->geo->fsbcount, 0, 0, - args->firstblock, args->trans->t_dfops, &done); + args->firstblock, &done); if (error) { /* * ENOSPC actually can happen if we're in a removename with no diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 76f28b823866..6c02cd264045 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -1046,7 +1046,7 @@ xfs_unmap_extent( xfs_defer_init(&dfops, &firstfsb); tp->t_dfops = &dfops; error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2, &firstfsb, - tp->t_dfops, done); + done); if (error) goto out_bmap_cancel; diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 539d96201666..f456df2e1394 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1588,7 +1588,7 @@ xfs_itruncate_extents_flags( tp->t_dfops = &dfops; error = xfs_bunmapi(tp, ip, first_unmap_block, unmap_len, flags, XFS_ITRUNC_MAX_EXTENTS, &first_block, - tp->t_dfops, &done); + &done); if (error) goto out_bmap_cancel; diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index c119cd33766e..0ac0706c98e8 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -703,7 +703,7 @@ xfs_reflink_end_cow( tp->t_dfops = &dfops; rlen = del.br_blockcount; error = __xfs_bunmapi(tp, ip, del.br_startoff, &rlen, 0, 1, - &firstfsb, tp->t_dfops); + &firstfsb); if (error) goto out_defer; @@ -1052,8 +1052,7 @@ xfs_reflink_remap_extent( while (rlen) { xfs_defer_init(&dfops, &firstfsb); tp->t_dfops = &dfops; - error = __xfs_bunmapi(tp, ip, destoff, &rlen, 0, 1, - &firstfsb, tp->t_dfops); + error = __xfs_bunmapi(tp, ip, destoff, &rlen, 0, 1, &firstfsb); if (error) goto out_defer; diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c index 290ae13d4673..a54f095c1409 100644 --- a/fs/xfs/xfs_symlink.c +++ b/fs/xfs/xfs_symlink.c @@ -466,8 +466,7 @@ xfs_inactive_symlink_rmt( /* * Unmap the dead block(s) to the dfops. */ - error = xfs_bunmapi(tp, ip, 0, size, 0, nmaps, - &first_block, tp->t_dfops, &done); + error = xfs_bunmapi(tp, ip, 0, size, 0, nmaps, &first_block, &done); if (error) goto error_bmap_cancel; ASSERT(done); -- cgit From 381eee69f862d38bef468e91517e37fc53f60885 Mon Sep 17 00:00:00 2001 From: Brian Foster Date: Wed, 11 Jul 2018 22:26:21 -0700 Subject: xfs: remove firstblock param from xfs dir ops All callers of the xfs_dir_*() functions pass ->t_firstblock as the firstblock parameter. Drop the parameter and access ->t_firstblock directly. Signed-off-by: Brian Foster Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_dir2.c | 12 ++++-------- fs/xfs/libxfs/xfs_dir2.h | 6 +++--- fs/xfs/xfs_inode.c | 32 ++++++++++++-------------------- fs/xfs/xfs_symlink.c | 3 +-- 4 files changed, 20 insertions(+), 33 deletions(-) (limited to 'fs/xfs/libxfs/xfs_dir2.c') diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index 781dc63d305d..a3983e3eb64a 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -243,7 +243,6 @@ xfs_dir_createname( struct xfs_inode *dp, struct xfs_name *name, xfs_ino_t inum, /* new entry inode number */ - xfs_fsblock_t *first, /* bmap's firstblock */ xfs_extlen_t total) /* bmap's total block count */ { struct xfs_da_args *args; @@ -251,7 +250,6 @@ xfs_dir_createname( int v; /* type-checking value */ ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); - ASSERT(tp->t_dfops || !first); if (inum) { rval = xfs_dir_ino_validate(tp->t_mountp, inum); @@ -274,7 +272,7 @@ xfs_dir_createname( args->total = total; args->whichfork = XFS_DATA_FORK; args->trans = tp; - args->firstblock = first; + args->firstblock = &tp->t_firstblock; args->op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT; if (!inum) args->op_flags |= XFS_DA_OP_JUSTCHECK; @@ -420,7 +418,6 @@ xfs_dir_removename( struct xfs_inode *dp, struct xfs_name *name, xfs_ino_t ino, - xfs_fsblock_t *first, /* bmap's firstblock */ xfs_extlen_t total) /* bmap's total block count */ { struct xfs_da_args *args; @@ -442,7 +439,7 @@ xfs_dir_removename( args->hashval = dp->i_mount->m_dirnameops->hashname(name); args->inumber = ino; args->dp = dp; - args->firstblock = first; + args->firstblock = &tp->t_firstblock; args->total = total; args->whichfork = XFS_DATA_FORK; args->trans = tp; @@ -481,7 +478,6 @@ xfs_dir_replace( struct xfs_inode *dp, struct xfs_name *name, /* name of entry to replace */ xfs_ino_t inum, /* new inode number */ - xfs_fsblock_t *first, /* bmap's firstblock */ xfs_extlen_t total) /* bmap's total block count */ { struct xfs_da_args *args; @@ -506,7 +502,7 @@ xfs_dir_replace( args->hashval = dp->i_mount->m_dirnameops->hashname(name); args->inumber = inum; args->dp = dp; - args->firstblock = first; + args->firstblock = &tp->t_firstblock; args->total = total; args->whichfork = XFS_DATA_FORK; args->trans = tp; @@ -545,7 +541,7 @@ xfs_dir_canenter( xfs_inode_t *dp, struct xfs_name *name) /* name of entry to add */ { - return xfs_dir_createname(tp, dp, name, 0, NULL, 0); + return xfs_dir_createname(tp, dp, name, 0, 0); } /* diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h index f203aebc07ed..ba5acd03de94 100644 --- a/fs/xfs/libxfs/xfs_dir2.h +++ b/fs/xfs/libxfs/xfs_dir2.h @@ -118,16 +118,16 @@ extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp, struct xfs_inode *pdp); extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp, struct xfs_name *name, xfs_ino_t inum, - xfs_fsblock_t *first, xfs_extlen_t tot); + xfs_extlen_t tot); extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp, struct xfs_name *name, xfs_ino_t *inum, struct xfs_name *ci_name); extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp, struct xfs_name *name, xfs_ino_t ino, - xfs_fsblock_t *first, xfs_extlen_t tot); + xfs_extlen_t tot); extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp, struct xfs_name *name, xfs_ino_t inum, - xfs_fsblock_t *first, xfs_extlen_t tot); + xfs_extlen_t tot); extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp, struct xfs_name *name); diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 6a3fe2d3df6c..ab1fd696500c 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1223,7 +1223,7 @@ xfs_create( xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); unlock_dp_on_error = false; - error = xfs_dir_createname(tp, dp, name, ip->i_ino, &tp->t_firstblock, + error = xfs_dir_createname(tp, dp, name, ip->i_ino, resblks ? resblks - XFS_IALLOC_SPACE_RES(mp) : 0); if (error) { @@ -1460,7 +1460,7 @@ xfs_link( } error = xfs_dir_createname(tp, tdp, target_name, sip->i_ino, - &tp->t_firstblock, resblks); + resblks); if (error) goto error_return; xfs_trans_ichgtime(tp, tdp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); @@ -2655,8 +2655,7 @@ xfs_remove( goto out_trans_cancel; xfs_defer_init(tp, &dfops, &tp->t_firstblock); - error = xfs_dir_removename(tp, dp, name, ip->i_ino, &tp->t_firstblock, - resblks); + error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks); if (error) { ASSERT(error != -ENOENT); goto out_bmap_cancel; @@ -2788,14 +2787,12 @@ xfs_cross_rename( int dp2_flags = 0; /* Swap inode number for dirent in first parent */ - error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, &tp->t_firstblock, - spaceres); + error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, spaceres); if (error) goto out_trans_abort; /* Swap inode number for dirent in second parent */ - error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, &tp->t_firstblock, - spaceres); + error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, spaceres); if (error) goto out_trans_abort; @@ -2809,8 +2806,7 @@ xfs_cross_rename( if (S_ISDIR(VFS_I(ip2)->i_mode)) { error = xfs_dir_replace(tp, ip2, &xfs_name_dotdot, - dp1->i_ino, &tp->t_firstblock, - spaceres); + dp1->i_ino, spaceres); if (error) goto out_trans_abort; @@ -2836,8 +2832,7 @@ xfs_cross_rename( if (S_ISDIR(VFS_I(ip1)->i_mode)) { error = xfs_dir_replace(tp, ip1, &xfs_name_dotdot, - dp2->i_ino, &tp->t_firstblock, - spaceres); + dp2->i_ino, spaceres); if (error) goto out_trans_abort; @@ -3043,8 +3038,7 @@ xfs_rename( * to account for the ".." reference from the new entry. */ error = xfs_dir_createname(tp, target_dp, target_name, - src_ip->i_ino, &tp->t_firstblock, - spaceres); + src_ip->i_ino, spaceres); if (error) goto out_bmap_cancel; @@ -3083,8 +3077,7 @@ xfs_rename( * name at the destination directory, remove it first. */ error = xfs_dir_replace(tp, target_dp, target_name, - src_ip->i_ino, &tp->t_firstblock, - spaceres); + src_ip->i_ino, spaceres); if (error) goto out_bmap_cancel; @@ -3118,8 +3111,7 @@ xfs_rename( * directory. */ error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot, - target_dp->i_ino, &tp->t_firstblock, - spaceres); + target_dp->i_ino, spaceres); ASSERT(error != -EEXIST); if (error) goto out_bmap_cancel; @@ -3158,10 +3150,10 @@ xfs_rename( */ if (wip) { error = xfs_dir_replace(tp, src_dp, src_name, wip->i_ino, - &tp->t_firstblock, spaceres); + spaceres); } else error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino, - &tp->t_firstblock, spaceres); + spaceres); if (error) goto out_bmap_cancel; diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c index 8ddc7f1147dc..583ca83353f7 100644 --- a/fs/xfs/xfs_symlink.c +++ b/fs/xfs/xfs_symlink.c @@ -336,8 +336,7 @@ xfs_symlink( /* * Create the directory entry for the symlink. */ - error = xfs_dir_createname(tp, dp, link_name, ip->i_ino, - &tp->t_firstblock, resblks); + error = xfs_dir_createname(tp, dp, link_name, ip->i_ino, resblks); if (error) goto out_bmap_cancel; xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); -- cgit From 766139032f95bb41031f6de9c2ee0538bd035229 Mon Sep 17 00:00:00 2001 From: Brian Foster Date: Wed, 11 Jul 2018 22:26:22 -0700 Subject: xfs: use ->t_firstblock in xattr ops Similar to the dirops code, the xattr code uses an on-stack firstblock variable for the various operations. This code rolls the underlying transaction in various places, however, which means we cannot simply replace the local firstblock vars with ->t_firstblock. Doing so (without further changes) would invalidate the memory pointed to by xfs_da_args.firstblock as soon as the first transaction rolls. To avoid this problem, remove xfs_da_args.firstblock and replace all such accesses with ->t_firstblock at the same time. This ensures that accesses to the current firstblock always occur through the current transaction rather than a potentially invalid xfs_da_args pointer. Signed-off-by: Brian Foster Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 37 ++++++++++++++++++------------------- fs/xfs/libxfs/xfs_attr_leaf.c | 2 -- fs/xfs/libxfs/xfs_attr_remote.c | 18 +++++++++++------- fs/xfs/libxfs/xfs_bmap.c | 1 - fs/xfs/libxfs/xfs_da_btree.c | 7 +++---- fs/xfs/libxfs/xfs_da_btree.h | 1 - fs/xfs/libxfs/xfs_dir2.c | 5 +---- 7 files changed, 33 insertions(+), 38 deletions(-) (limited to 'fs/xfs/libxfs/xfs_dir2.c') diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 8a7e2c0308c4..153d2e29f872 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -204,7 +204,6 @@ xfs_attr_set( struct xfs_da_args args; struct xfs_defer_ops dfops; struct xfs_trans_res tres; - xfs_fsblock_t firstblock; int rsvd = (flags & ATTR_ROOT) != 0; int error, err2, local; @@ -219,7 +218,6 @@ xfs_attr_set( args.value = value; args.valuelen = valuelen; - args.firstblock = &firstblock; args.op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT; args.total = xfs_attr_calc_size(&args, &local); @@ -253,7 +251,7 @@ xfs_attr_set( rsvd ? XFS_TRANS_RESERVE : 0, &args.trans); if (error) return error; - xfs_defer_init(args.trans, &dfops, &firstblock); + xfs_defer_init(args.trans, &dfops, &args.trans->t_firstblock); xfs_ilock(dp, XFS_ILOCK_EXCL); error = xfs_trans_reserve_quota_nblks(args.trans, dp, args.total, 0, @@ -392,7 +390,6 @@ xfs_attr_remove( struct xfs_mount *mp = dp->i_mount; struct xfs_da_args args; struct xfs_defer_ops dfops; - xfs_fsblock_t firstblock; int error; XFS_STATS_INC(mp, xs_attr_remove); @@ -404,8 +401,6 @@ xfs_attr_remove( if (error) return error; - args.firstblock = &firstblock; - /* * we have no control over the attribute names that userspace passes us * to remove, so we have to allow the name lookup prior to attribute @@ -427,7 +422,7 @@ xfs_attr_remove( &args.trans); if (error) return error; - xfs_defer_init(args.trans, &dfops, &firstblock); + xfs_defer_init(args.trans, &dfops, &args.trans->t_firstblock); xfs_ilock(dp, XFS_ILOCK_EXCL); /* @@ -598,7 +593,8 @@ xfs_attr_leaf_addname( * Commit that transaction so that the node_addname() call * can manage its own transactions. */ - xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock); + xfs_defer_init(args->trans, args->trans->t_dfops, + &args->trans->t_firstblock); error = xfs_attr3_leaf_to_node(args); if (error) goto out_defer_cancel; @@ -687,8 +683,8 @@ xfs_attr_leaf_addname( * If the result is small enough, shrink it all into the inode. */ if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { - xfs_defer_init(NULL, args->trans->t_dfops, - args->firstblock); + xfs_defer_init(args->trans, args->trans->t_dfops, + &args->trans->t_firstblock); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); /* bp is gone due to xfs_da_shrink_inode */ if (error) @@ -753,7 +749,8 @@ xfs_attr_leaf_removename( * If the result is small enough, shrink it all into the inode. */ if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { - xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock); + xfs_defer_init(args->trans, args->trans->t_dfops, + &args->trans->t_firstblock); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); /* bp is gone due to xfs_da_shrink_inode */ if (error) @@ -882,8 +879,8 @@ restart: */ xfs_da_state_free(state); state = NULL; - xfs_defer_init(NULL, args->trans->t_dfops, - args->firstblock); + xfs_defer_init(args->trans, args->trans->t_dfops, + &args->trans->t_firstblock); error = xfs_attr3_leaf_to_node(args); if (error) goto out_defer_cancel; @@ -910,7 +907,8 @@ restart: * in the index/blkno/rmtblkno/rmtblkcnt fields and * in the index2/blkno2/rmtblkno2/rmtblkcnt2 fields. */ - xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock); + xfs_defer_init(args->trans, args->trans->t_dfops, + &args->trans->t_firstblock); error = xfs_da3_split(state); if (error) goto out_defer_cancel; @@ -1008,8 +1006,8 @@ restart: * Check to see if the tree needs to be collapsed. */ if (retval && (state->path.active > 1)) { - xfs_defer_init(NULL, args->trans->t_dfops, - args->firstblock); + xfs_defer_init(args->trans, args->trans->t_dfops, + &args->trans->t_firstblock); error = xfs_da3_join(state); if (error) goto out_defer_cancel; @@ -1134,7 +1132,8 @@ xfs_attr_node_removename( * Check to see if the tree needs to be collapsed. */ if (retval && (state->path.active > 1)) { - xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock); + xfs_defer_init(args->trans, args->trans->t_dfops, + &args->trans->t_firstblock); error = xfs_da3_join(state); if (error) goto out_defer_cancel; @@ -1166,8 +1165,8 @@ xfs_attr_node_removename( goto out; if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { - xfs_defer_init(NULL, args->trans->t_dfops, - args->firstblock); + xfs_defer_init(args->trans, args->trans->t_dfops, + &args->trans->t_firstblock); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); /* bp is gone due to xfs_da_shrink_inode */ if (error) diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index c131469db0f1..251304f3bc5d 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -802,7 +802,6 @@ xfs_attr_shortform_to_leaf( memset((char *)&nargs, 0, sizeof(nargs)); nargs.dp = dp; nargs.geo = args->geo; - nargs.firstblock = args->firstblock; nargs.total = args->total; nargs.whichfork = XFS_ATTR_FORK; nargs.trans = args->trans; @@ -1005,7 +1004,6 @@ xfs_attr3_leaf_to_shortform( memset((char *)&nargs, 0, sizeof(nargs)); nargs.geo = args->geo; nargs.dp = dp; - nargs.firstblock = args->firstblock; nargs.total = args->total; nargs.whichfork = XFS_ATTR_FORK; nargs.trans = args->trans; diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index ab7c2755ad8c..205098aeb4bc 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -480,11 +480,13 @@ xfs_attr_rmtval_set( * extent and then crash then the block may not contain the * correct metadata after log recovery occurs. */ - xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock); + xfs_defer_init(args->trans, args->trans->t_dfops, + &args->trans->t_firstblock); nmap = 1; error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno, - blkcnt, XFS_BMAPI_ATTRFORK, args->firstblock, - args->total, &map, &nmap); + blkcnt, XFS_BMAPI_ATTRFORK, + &args->trans->t_firstblock, args->total, &map, + &nmap); if (error) goto out_defer_cancel; xfs_defer_ijoin(args->trans->t_dfops, dp); @@ -522,7 +524,8 @@ xfs_attr_rmtval_set( ASSERT(blkcnt > 0); - xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock); + xfs_defer_init(args->trans, args->trans->t_dfops, + &args->trans->t_firstblock); nmap = 1; error = xfs_bmapi_read(dp, (xfs_fileoff_t)lblkno, blkcnt, &map, &nmap, @@ -626,10 +629,11 @@ xfs_attr_rmtval_remove( blkcnt = args->rmtblkcnt; done = 0; while (!done) { - xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock); + xfs_defer_init(args->trans, args->trans->t_dfops, + &args->trans->t_firstblock); error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt, - XFS_BMAPI_ATTRFORK, 1, args->firstblock, - &done); + XFS_BMAPI_ATTRFORK, 1, + &args->trans->t_firstblock, &done); if (error) goto out_defer_cancel; xfs_defer_ijoin(args->trans->t_dfops, args->dp); diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index da73c1a011d3..6f9b2cddb933 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -1000,7 +1000,6 @@ xfs_bmap_add_attrfork_local( memset(&dargs, 0, sizeof(dargs)); dargs.geo = ip->i_mount->m_dir_geo; dargs.dp = ip; - dargs.firstblock = &tp->t_firstblock; dargs.total = dargs.geo->fsbcount; dargs.whichfork = XFS_DATA_FORK; dargs.trans = tp; diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index 68a72e3d9f53..2f2be86c10dc 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -2059,10 +2059,9 @@ xfs_da_grow_inode_int( * Try mapping it in one filesystem block. */ nmap = 1; - ASSERT(args->firstblock != NULL); error = xfs_bmapi_write(tp, dp, *bno, count, xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA|XFS_BMAPI_CONTIG, - args->firstblock, args->total, &map, &nmap); + &tp->t_firstblock, args->total, &map, &nmap); if (error) return error; @@ -2084,7 +2083,7 @@ xfs_da_grow_inode_int( c = (int)(*bno + count - b); error = xfs_bmapi_write(tp, dp, b, c, xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA, - args->firstblock, args->total, + &tp->t_firstblock, args->total, &mapp[mapi], &nmap); if (error) goto out_free_map; @@ -2394,7 +2393,7 @@ xfs_da_shrink_inode( * the last block to the place we want to kill. */ error = xfs_bunmapi(tp, dp, dead_blkno, count, - xfs_bmapi_aflag(w), 0, args->firstblock, + xfs_bmapi_aflag(w), 0, &tp->t_firstblock, &done); if (error == -ENOSPC) { if (w != XFS_DATA_FORK) diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h index 6b8a04f3f162..59e290ef334f 100644 --- a/fs/xfs/libxfs/xfs_da_btree.h +++ b/fs/xfs/libxfs/xfs_da_btree.h @@ -57,7 +57,6 @@ typedef struct xfs_da_args { xfs_dahash_t hashval; /* hash value of name */ xfs_ino_t inumber; /* input/output inode number */ struct xfs_inode *dp; /* directory inode to manipulate */ - xfs_fsblock_t *firstblock; /* ptr to firstblock for bmap calls */ struct xfs_trans *trans; /* current trans (changes over time) */ xfs_extlen_t total; /* total blocks needed, for 1st bmap */ int whichfork; /* data or attribute fork */ diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index a3983e3eb64a..5db73d96b99e 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -272,7 +272,6 @@ xfs_dir_createname( args->total = total; args->whichfork = XFS_DATA_FORK; args->trans = tp; - args->firstblock = &tp->t_firstblock; args->op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT; if (!inum) args->op_flags |= XFS_DA_OP_JUSTCHECK; @@ -439,7 +438,6 @@ xfs_dir_removename( args->hashval = dp->i_mount->m_dirnameops->hashname(name); args->inumber = ino; args->dp = dp; - args->firstblock = &tp->t_firstblock; args->total = total; args->whichfork = XFS_DATA_FORK; args->trans = tp; @@ -502,7 +500,6 @@ xfs_dir_replace( args->hashval = dp->i_mount->m_dirnameops->hashname(name); args->inumber = inum; args->dp = dp; - args->firstblock = &tp->t_firstblock; args->total = total; args->whichfork = XFS_DATA_FORK; args->trans = tp; @@ -660,7 +657,7 @@ xfs_dir2_shrink_inode( /* Unmap the fsblock(s). */ error = xfs_bunmapi(tp, dp, da, args->geo->fsbcount, 0, 0, - args->firstblock, &done); + &tp->t_firstblock, &done); if (error) { /* * ENOSPC actually can happen if we're in a removename with no -- cgit From 2af528425342dc8f696b28693c5e61587cd72b43 Mon Sep 17 00:00:00 2001 From: Brian Foster Date: Wed, 11 Jul 2018 22:26:25 -0700 Subject: xfs: remove xfs_bunmapi() firstblock param All callers pass ->t_firstblock from the current transaction. Signed-off-by: Brian Foster Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr_remote.c | 3 +-- fs/xfs/libxfs/xfs_bmap.c | 25 ++++++++++++------------- fs/xfs/libxfs/xfs_bmap.h | 5 ++--- fs/xfs/libxfs/xfs_da_btree.c | 3 +-- fs/xfs/libxfs/xfs_dir2.c | 3 +-- fs/xfs/xfs_bmap_util.c | 3 +-- fs/xfs/xfs_inode.c | 3 +-- fs/xfs/xfs_reflink.c | 6 ++---- fs/xfs/xfs_symlink.c | 3 +-- 9 files changed, 22 insertions(+), 32 deletions(-) (limited to 'fs/xfs/libxfs/xfs_dir2.c') diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index 2db9ef186e05..f02c705965ff 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -631,8 +631,7 @@ xfs_attr_rmtval_remove( xfs_defer_init(args->trans, args->trans->t_dfops, &args->trans->t_firstblock); error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt, - XFS_BMAPI_ATTRFORK, 1, - &args->trans->t_firstblock, &done); + XFS_BMAPI_ATTRFORK, 1, &done); if (error) goto out_defer_cancel; xfs_defer_ijoin(args->trans->t_dfops, args->dp); diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index ca30e972288a..619d3adc5923 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -5122,9 +5122,7 @@ __xfs_bunmapi( xfs_fileoff_t start, /* first file offset deleted */ xfs_filblks_t *rlen, /* i/o: amount remaining */ int flags, /* misc flags */ - xfs_extnum_t nexts, /* number of extents max */ - xfs_fsblock_t *firstblock) /* first allocated block - controls a.g. for allocs */ + xfs_extnum_t nexts) /* number of extents max */ { struct xfs_btree_cur *cur; /* bmap btree cursor */ struct xfs_bmbt_irec del; /* extent being deleted */ @@ -5198,7 +5196,7 @@ __xfs_bunmapi( if (ifp->if_flags & XFS_IFBROOT) { ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE); cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork); - cur->bc_private.b.firstblock = *firstblock; + cur->bc_private.b.firstblock = tp->t_firstblock; cur->bc_private.b.flags = 0; } else cur = NULL; @@ -5314,7 +5312,7 @@ __xfs_bunmapi( del.br_state = XFS_EXT_UNWRITTEN; error = xfs_bmap_add_extent_unwritten_real(tp, ip, whichfork, &icur, &cur, &del, - firstblock, &logflags); + &tp->t_firstblock, &logflags); if (error) goto error0; goto nodelete; @@ -5371,7 +5369,8 @@ __xfs_bunmapi( prev.br_state = XFS_EXT_UNWRITTEN; error = xfs_bmap_add_extent_unwritten_real(tp, ip, whichfork, &icur, &cur, - &prev, firstblock, &logflags); + &prev, &tp->t_firstblock, + &logflags); if (error) goto error0; goto nodelete; @@ -5380,7 +5379,8 @@ __xfs_bunmapi( del.br_state = XFS_EXT_UNWRITTEN; error = xfs_bmap_add_extent_unwritten_real(tp, ip, whichfork, &icur, &cur, - &del, firstblock, &logflags); + &del, &tp->t_firstblock, + &logflags); if (error) goto error0; goto nodelete; @@ -5427,8 +5427,8 @@ nodelete: */ if (xfs_bmap_needs_btree(ip, whichfork)) { ASSERT(cur == NULL); - error = xfs_bmap_extents_to_btree(tp, ip, firstblock, &cur, 0, - &tmp_logflags, whichfork); + error = xfs_bmap_extents_to_btree(tp, ip, &tp->t_firstblock, + &cur, 0, &tmp_logflags, whichfork); logflags |= tmp_logflags; if (error) goto error0; @@ -5467,7 +5467,7 @@ error0: xfs_trans_log_inode(tp, ip, logflags); if (cur) { if (!error) { - *firstblock = cur->bc_private.b.firstblock; + tp->t_firstblock = cur->bc_private.b.firstblock; cur->bc_private.b.allocated = 0; } xfs_btree_del_cursor(cur, @@ -5485,12 +5485,11 @@ xfs_bunmapi( xfs_filblks_t len, int flags, xfs_extnum_t nexts, - xfs_fsblock_t *firstblock, int *done) { int error; - error = __xfs_bunmapi(tp, ip, bno, &len, flags, nexts, firstblock); + error = __xfs_bunmapi(tp, ip, bno, &len, flags, nexts); *done = (len == 0); return error; } @@ -6148,7 +6147,7 @@ xfs_bmap_finish_one( break; case XFS_BMAP_UNMAP: error = __xfs_bunmapi(tp, ip, startoff, blockcount, - XFS_BMAPI_REMAP, 1, &tp->t_firstblock); + XFS_BMAPI_REMAP, 1); break; default: ASSERT(0); diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h index 88c2b5dc499e..108a3073d658 100644 --- a/fs/xfs/libxfs/xfs_bmap.h +++ b/fs/xfs/libxfs/xfs_bmap.h @@ -204,11 +204,10 @@ int xfs_bmapi_write(struct xfs_trans *tp, struct xfs_inode *ip, xfs_extlen_t total, struct xfs_bmbt_irec *mval, int *nmap); int __xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip, xfs_fileoff_t bno, xfs_filblks_t *rlen, int flags, - xfs_extnum_t nexts, xfs_fsblock_t *firstblock); + xfs_extnum_t nexts); int xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip, xfs_fileoff_t bno, xfs_filblks_t len, int flags, - xfs_extnum_t nexts, xfs_fsblock_t *firstblock, - int *done); + xfs_extnum_t nexts, int *done); int xfs_bmap_del_extent_delay(struct xfs_inode *ip, int whichfork, struct xfs_iext_cursor *cur, struct xfs_bmbt_irec *got, struct xfs_bmbt_irec *del); diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index fe4a192696ae..9efbd2038ffb 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -2392,8 +2392,7 @@ xfs_da_shrink_inode( * the last block to the place we want to kill. */ error = xfs_bunmapi(tp, dp, dead_blkno, count, - xfs_bmapi_aflag(w), 0, &tp->t_firstblock, - &done); + xfs_bmapi_aflag(w), 0, &done); if (error == -ENOSPC) { if (w != XFS_DATA_FORK) break; diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index 5db73d96b99e..4ea1fddb126f 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -656,8 +656,7 @@ xfs_dir2_shrink_inode( da = xfs_dir2_db_to_da(args->geo, db); /* Unmap the fsblock(s). */ - error = xfs_bunmapi(tp, dp, da, args->geo->fsbcount, 0, 0, - &tp->t_firstblock, &done); + error = xfs_bunmapi(tp, dp, da, args->geo->fsbcount, 0, 0, &done); if (error) { /* * ENOSPC actually can happen if we're in a removename with no diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 4f4b1d3fb898..f225707c89be 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -1041,8 +1041,7 @@ xfs_unmap_extent( xfs_trans_ijoin(tp, ip, 0); xfs_defer_init(tp, &dfops, &tp->t_firstblock); - error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2, - &tp->t_firstblock, done); + error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2, done); if (error) goto out_bmap_cancel; diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 3cdfd795a50c..5e1eaa26435c 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1581,8 +1581,7 @@ xfs_itruncate_extents_flags( while (!done) { xfs_defer_init(tp, &dfops, &tp->t_firstblock); error = xfs_bunmapi(tp, ip, first_unmap_block, unmap_len, flags, - XFS_ITRUNC_MAX_EXTENTS, &tp->t_firstblock, - &done); + XFS_ITRUNC_MAX_EXTENTS, &done); if (error) goto out_bmap_cancel; diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 7010f3453c29..2972efeee5cc 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -696,8 +696,7 @@ xfs_reflink_end_cow( /* Unmap the old blocks in the data fork. */ xfs_defer_init(tp, &dfops, &tp->t_firstblock); rlen = del.br_blockcount; - error = __xfs_bunmapi(tp, ip, del.br_startoff, &rlen, 0, 1, - &tp->t_firstblock); + error = __xfs_bunmapi(tp, ip, del.br_startoff, &rlen, 0, 1); if (error) goto out_defer; @@ -1044,8 +1043,7 @@ xfs_reflink_remap_extent( rlen = unmap_len; while (rlen) { xfs_defer_init(tp, &dfops, &tp->t_firstblock); - error = __xfs_bunmapi(tp, ip, destoff, &rlen, 0, 1, - &tp->t_firstblock); + error = __xfs_bunmapi(tp, ip, destoff, &rlen, 0, 1); if (error) goto out_defer; diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c index 94301b63525f..a3dc552a5b97 100644 --- a/fs/xfs/xfs_symlink.c +++ b/fs/xfs/xfs_symlink.c @@ -460,8 +460,7 @@ xfs_inactive_symlink_rmt( /* * Unmap the dead block(s) to the dfops. */ - error = xfs_bunmapi(tp, ip, 0, size, 0, nmaps, &tp->t_firstblock, - &done); + error = xfs_bunmapi(tp, ip, 0, size, 0, nmaps, &done); if (error) goto error_bmap_cancel; ASSERT(done); -- cgit From 9d9e6233859706875c392707efd6d516cfb764fb Mon Sep 17 00:00:00 2001 From: Brian Foster Date: Wed, 1 Aug 2018 07:20:35 -0700 Subject: xfs: fold dfops into the transaction struct xfs_defer_ops has now been reduced to a single list_head. The external dfops mechanism is unused and thus everywhere a (permanent) transaction is accessible the associated dfops structure is as well. Remove the xfs_defer_ops structure and fold the list_head into the transaction. Also remove the last remnant of external dfops in xfs_trans_dup(). Signed-off-by: Brian Foster Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_bmap.c | 1 - fs/xfs/libxfs/xfs_btree.h | 1 - fs/xfs/libxfs/xfs_da_btree.h | 1 - fs/xfs/libxfs/xfs_defer.c | 67 +++++++++++++------------------------------- fs/xfs/libxfs/xfs_defer.h | 2 -- fs/xfs/libxfs/xfs_dir2.c | 2 -- fs/xfs/libxfs/xfs_dir2.h | 1 - fs/xfs/xfs_inode.h | 1 - fs/xfs/xfs_reflink.c | 5 ++-- fs/xfs/xfs_trace.h | 40 ++++++++++++-------------- fs/xfs/xfs_trans.c | 13 ++++----- fs/xfs/xfs_trans.h | 8 ++---- 12 files changed, 46 insertions(+), 96 deletions(-) (limited to 'fs/xfs/libxfs/xfs_dir2.c') diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index c9fec0443f38..5648a177e0ac 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -4286,7 +4286,6 @@ xfs_bmapi_write( bma.ip = ip; bma.total = total; bma.datatype = 0; - ASSERT(!tp || tp->t_dfops); while (bno < end && n < *nmap) { bool need_alloc = false, wasdelay = false; diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h index 503615f4d729..e3b3e9dce5da 100644 --- a/fs/xfs/libxfs/xfs_btree.h +++ b/fs/xfs/libxfs/xfs_btree.h @@ -7,7 +7,6 @@ #define __XFS_BTREE_H__ struct xfs_buf; -struct xfs_defer_ops; struct xfs_inode; struct xfs_mount; struct xfs_trans; diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h index 59e290ef334f..84dd865b6c3d 100644 --- a/fs/xfs/libxfs/xfs_da_btree.h +++ b/fs/xfs/libxfs/xfs_da_btree.h @@ -7,7 +7,6 @@ #ifndef __XFS_DA_BTREE_H__ #define __XFS_DA_BTREE_H__ -struct xfs_defer_ops; struct xfs_inode; struct xfs_trans; struct zone; diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index ce2286763531..e792b167150a 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -183,11 +183,10 @@ STATIC void xfs_defer_create_intents( struct xfs_trans *tp) { - struct xfs_defer_ops *dop = tp->t_dfops; struct list_head *li; struct xfs_defer_pending *dfp; - list_for_each_entry(dfp, &dop->dop_intake, dfp_list) { + list_for_each_entry(dfp, &tp->t_dfops, dfp_list) { dfp->dfp_intent = dfp->dfp_type->create_intent(tp, dfp->dfp_count); trace_xfs_defer_create_intent(tp->t_mountp, dfp); @@ -204,10 +203,9 @@ xfs_defer_trans_abort( struct xfs_trans *tp, struct list_head *dop_pending) { - struct xfs_defer_ops *dop = tp->t_dfops; struct xfs_defer_pending *dfp; - trace_xfs_defer_trans_abort(tp->t_mountp, dop, _RET_IP_); + trace_xfs_defer_trans_abort(tp, _RET_IP_); /* Abort intent items that don't have a done item. */ list_for_each_entry(dfp, dop_pending, dfp_list) { @@ -266,14 +264,13 @@ xfs_defer_trans_roll( } } - trace_xfs_defer_trans_roll(tp->t_mountp, tp->t_dfops, _RET_IP_); + trace_xfs_defer_trans_roll(tp, _RET_IP_); /* Roll the transaction. */ error = xfs_trans_roll(tpp); tp = *tpp; if (error) { - trace_xfs_defer_trans_roll_error(tp->t_mountp, - tp->t_dfops, error); + trace_xfs_defer_trans_roll_error(tp, error); return error; } @@ -297,7 +294,7 @@ static void xfs_defer_reset( struct xfs_trans *tp) { - ASSERT(list_empty(&tp->t_dfops->dop_intake)); + ASSERT(list_empty(&tp->t_dfops)); /* * Low mode state transfers across transaction rolls to mirror dfops @@ -358,15 +355,13 @@ xfs_defer_finish_noroll( ASSERT((*tp)->t_flags & XFS_TRANS_PERM_LOG_RES); - trace_xfs_defer_finish((*tp)->t_mountp, (*tp)->t_dfops, _RET_IP_); + trace_xfs_defer_finish(*tp, _RET_IP_); /* Until we run out of pending work to finish... */ - while (!list_empty(&dop_pending) || - !list_empty(&(*tp)->t_dfops->dop_intake)) { + while (!list_empty(&dop_pending) || !list_empty(&(*tp)->t_dfops)) { /* log intents and pull in intake items */ xfs_defer_create_intents(*tp); - list_splice_tail_init(&(*tp)->t_dfops->dop_intake, - &dop_pending); + list_splice_tail_init(&(*tp)->t_dfops, &dop_pending); /* * Roll the transaction. @@ -438,14 +433,13 @@ out: if (error) { xfs_defer_trans_abort(*tp, &dop_pending); xfs_force_shutdown((*tp)->t_mountp, SHUTDOWN_CORRUPT_INCORE); - trace_xfs_defer_finish_error((*tp)->t_mountp, (*tp)->t_dfops, - error); + trace_xfs_defer_finish_error(*tp, error); xfs_defer_cancel_list((*tp)->t_mountp, &dop_pending); xfs_defer_cancel(*tp); return error; } - trace_xfs_defer_finish_done((*tp)->t_mountp, (*tp)->t_dfops, _RET_IP_); + trace_xfs_defer_finish_done(*tp, _RET_IP_); return 0; } @@ -480,8 +474,8 @@ xfs_defer_cancel( { struct xfs_mount *mp = tp->t_mountp; - trace_xfs_defer_cancel(mp, tp->t_dfops, _RET_IP_); - xfs_defer_cancel_list(mp, &tp->t_dfops->dop_intake); + trace_xfs_defer_cancel(tp, _RET_IP_); + xfs_defer_cancel_list(mp, &tp->t_dfops); } /* Add an item for later deferred processing. */ @@ -491,7 +485,6 @@ xfs_defer_add( enum xfs_defer_ops_type type, struct list_head *li) { - struct xfs_defer_ops *dop = tp->t_dfops; struct xfs_defer_pending *dfp = NULL; ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); @@ -501,8 +494,8 @@ xfs_defer_add( * If the last pending item has the same type, reuse it. Else, * create a new pending item at the end of the intake list. */ - if (!list_empty(&dop->dop_intake)) { - dfp = list_last_entry(&dop->dop_intake, + if (!list_empty(&tp->t_dfops)) { + dfp = list_last_entry(&tp->t_dfops, struct xfs_defer_pending, dfp_list); if (dfp->dfp_type->type != type || (dfp->dfp_type->max_items && @@ -517,7 +510,7 @@ xfs_defer_add( dfp->dfp_done = NULL; dfp->dfp_count = 0; INIT_LIST_HEAD(&dfp->dfp_work); - list_add_tail(&dfp->dfp_list, &dop->dop_intake); + list_add_tail(&dfp->dfp_list, &tp->t_dfops); } list_add_tail(li, &dfp->dfp_work); @@ -532,39 +525,17 @@ xfs_defer_init_op_type( defer_op_types[type->type] = type; } -/* Initialize a deferred operation. */ -void -xfs_defer_init( - struct xfs_trans *tp, - struct xfs_defer_ops *dop) -{ - struct xfs_mount *mp = NULL; - - memset(dop, 0, sizeof(struct xfs_defer_ops)); - INIT_LIST_HEAD(&dop->dop_intake); - if (tp) { - ASSERT(tp->t_firstblock == NULLFSBLOCK); - tp->t_dfops = dop; - mp = tp->t_mountp; - } - trace_xfs_defer_init(mp, dop, _RET_IP_); -} - /* - * Move state from one xfs_defer_ops to another and reset the source to initial - * state. This is primarily used to carry state forward across transaction rolls - * with internal dfops. + * Move deferred ops from one transaction to another and reset the source to + * initial state. This is primarily used to carry state forward across + * transaction rolls with pending dfops. */ void xfs_defer_move( struct xfs_trans *dtp, struct xfs_trans *stp) { - struct xfs_defer_ops *dst = dtp->t_dfops; - struct xfs_defer_ops *src = stp->t_dfops; - ASSERT(dst != src); - - list_splice_init(&src->dop_intake, &dst->dop_intake); + list_splice_init(&stp->t_dfops, &dtp->t_dfops); /* * Low free space mode was historically controlled by a dfops field. diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index b2675f1ca909..2584a5b95b0d 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h @@ -7,7 +7,6 @@ #define __XFS_DEFER_H__ struct xfs_defer_op_type; -struct xfs_defer_ops; /* * Save a log intent item and a list of extents, so that we can replay @@ -40,7 +39,6 @@ void xfs_defer_add(struct xfs_trans *tp, enum xfs_defer_ops_type type, int xfs_defer_finish_noroll(struct xfs_trans **tp); int xfs_defer_finish(struct xfs_trans **tp); void xfs_defer_cancel(struct xfs_trans *); -void xfs_defer_init(struct xfs_trans *tp, struct xfs_defer_ops *dop); void xfs_defer_move(struct xfs_trans *dtp, struct xfs_trans *stp); /* Description of a deferred type. */ diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index 4ea1fddb126f..229152cd1a24 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -424,7 +424,6 @@ xfs_dir_removename( int v; /* type-checking value */ ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); - ASSERT(tp->t_dfops); XFS_STATS_INC(dp->i_mount, xs_dir_remove); args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS); @@ -483,7 +482,6 @@ xfs_dir_replace( int v; /* type-checking value */ ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); - ASSERT(tp->t_dfops); rval = xfs_dir_ino_validate(tp->t_mountp, inum); if (rval) diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h index ba5acd03de94..c3e3f6b813d8 100644 --- a/fs/xfs/libxfs/xfs_dir2.h +++ b/fs/xfs/libxfs/xfs_dir2.h @@ -9,7 +9,6 @@ #include "xfs_da_format.h" #include "xfs_da_btree.h" -struct xfs_defer_ops; struct xfs_da_args; struct xfs_inode; struct xfs_mount; diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 79a3e61a6991..be2014520155 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -15,7 +15,6 @@ struct xfs_dinode; struct xfs_inode; struct xfs_buf; -struct xfs_defer_ops; struct xfs_bmbt_irec; struct xfs_inode_log_item; struct xfs_mount; diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index cbceb320a2e7..38f405415b88 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -502,7 +502,6 @@ xfs_reflink_cancel_cow_blocks( if (error) break; } else if (del.br_state == XFS_EXT_UNWRITTEN || cancel_real) { - ASSERT((*tpp)->t_dfops); ASSERT((*tpp)->t_firstblock == NULLFSBLOCK); /* Free the CoW orphan record. */ @@ -678,7 +677,7 @@ xfs_reflink_end_cow( goto prev_extent; /* Unmap the old blocks in the data fork. */ - ASSERT(tp->t_dfops && tp->t_firstblock == NULLFSBLOCK); + ASSERT(tp->t_firstblock == NULLFSBLOCK); rlen = del.br_blockcount; error = __xfs_bunmapi(tp, ip, del.br_startoff, &rlen, 0, 1); if (error) @@ -1021,7 +1020,7 @@ xfs_reflink_remap_extent( /* Unmap the old blocks in the data fork. */ rlen = unmap_len; while (rlen) { - ASSERT(tp->t_dfops && tp->t_firstblock == NULLFSBLOCK); + ASSERT(tp->t_firstblock == NULLFSBLOCK); error = __xfs_bunmapi(tp, ip, destoff, &rlen, 0, 1); if (error) goto out_cancel; diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index fec9cfe3dfb4..ad315e83bc02 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -2213,57 +2213,54 @@ DEFINE_BTREE_CUR_EVENT(xfs_btree_overlapped_query_range); /* deferred ops */ struct xfs_defer_pending; -struct xfs_defer_ops; DECLARE_EVENT_CLASS(xfs_defer_class, - TP_PROTO(struct xfs_mount *mp, struct xfs_defer_ops *dop, - unsigned long caller_ip), - TP_ARGS(mp, dop, caller_ip), + TP_PROTO(struct xfs_trans *tp, unsigned long caller_ip), + TP_ARGS(tp, caller_ip), TP_STRUCT__entry( __field(dev_t, dev) - __field(void *, dop) + __field(struct xfs_trans *, tp) __field(char, committed) __field(unsigned long, caller_ip) ), TP_fast_assign( - __entry->dev = mp ? mp->m_super->s_dev : 0; - __entry->dop = dop; + __entry->dev = tp->t_mountp->m_super->s_dev; + __entry->tp = tp; __entry->caller_ip = caller_ip; ), - TP_printk("dev %d:%d ops %p caller %pS", + TP_printk("dev %d:%d tp %p caller %pS", MAJOR(__entry->dev), MINOR(__entry->dev), - __entry->dop, + __entry->tp, (char *)__entry->caller_ip) ) #define DEFINE_DEFER_EVENT(name) \ DEFINE_EVENT(xfs_defer_class, name, \ - TP_PROTO(struct xfs_mount *mp, struct xfs_defer_ops *dop, \ - unsigned long caller_ip), \ - TP_ARGS(mp, dop, caller_ip)) + TP_PROTO(struct xfs_trans *tp, unsigned long caller_ip), \ + TP_ARGS(tp, caller_ip)) DECLARE_EVENT_CLASS(xfs_defer_error_class, - TP_PROTO(struct xfs_mount *mp, struct xfs_defer_ops *dop, int error), - TP_ARGS(mp, dop, error), + TP_PROTO(struct xfs_trans *tp, int error), + TP_ARGS(tp, error), TP_STRUCT__entry( __field(dev_t, dev) - __field(void *, dop) + __field(struct xfs_trans *, tp) __field(char, committed) __field(int, error) ), TP_fast_assign( - __entry->dev = mp ? mp->m_super->s_dev : 0; - __entry->dop = dop; + __entry->dev = tp->t_mountp->m_super->s_dev; + __entry->tp = tp; __entry->error = error; ), - TP_printk("dev %d:%d ops %p err %d", + TP_printk("dev %d:%d tp %p err %d", MAJOR(__entry->dev), MINOR(__entry->dev), - __entry->dop, + __entry->tp, __entry->error) ) #define DEFINE_DEFER_ERROR_EVENT(name) \ DEFINE_EVENT(xfs_defer_error_class, name, \ - TP_PROTO(struct xfs_mount *mp, struct xfs_defer_ops *dop, int error), \ - TP_ARGS(mp, dop, error)) + TP_PROTO(struct xfs_trans *tp, int error), \ + TP_ARGS(tp, error)) DECLARE_EVENT_CLASS(xfs_defer_pending_class, TP_PROTO(struct xfs_mount *mp, struct xfs_defer_pending *dfp), @@ -2382,7 +2379,6 @@ DEFINE_EVENT(xfs_map_extent_deferred_class, name, \ xfs_exntst_t state), \ TP_ARGS(mp, agno, op, agbno, ino, whichfork, offset, len, state)) -DEFINE_DEFER_EVENT(xfs_defer_init); DEFINE_DEFER_EVENT(xfs_defer_cancel); DEFINE_DEFER_EVENT(xfs_defer_trans_roll); DEFINE_DEFER_EVENT(xfs_defer_trans_abort); diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 413e4138357f..bedc5a5133a5 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -100,6 +100,7 @@ xfs_trans_dup( ntp->t_mountp = tp->t_mountp; INIT_LIST_HEAD(&ntp->t_items); INIT_LIST_HEAD(&ntp->t_busy); + INIT_LIST_HEAD(&ntp->t_dfops); ntp->t_firstblock = NULLFSBLOCK; ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); @@ -120,12 +121,8 @@ xfs_trans_dup( tp->t_rtx_res = tp->t_rtx_res_used; ntp->t_pflags = tp->t_pflags; - /* copy the dfops pointer if it's external, otherwise move it */ - xfs_defer_init(ntp, &ntp->t_dfops_internal); - if (tp->t_dfops != &tp->t_dfops_internal) - ntp->t_dfops = tp->t_dfops; - else - xfs_defer_move(ntp, tp); + /* move deferred ops over to the new tp */ + xfs_defer_move(ntp, tp); xfs_trans_dup_dqinfo(tp, ntp); @@ -280,8 +277,8 @@ xfs_trans_alloc( tp->t_mountp = mp; INIT_LIST_HEAD(&tp->t_items); INIT_LIST_HEAD(&tp->t_busy); + INIT_LIST_HEAD(&tp->t_dfops); tp->t_firstblock = NULLFSBLOCK; - xfs_defer_init(tp, &tp->t_dfops_internal); error = xfs_trans_reserve(tp, resp, blocks, rtextents); if (error) { @@ -929,7 +926,7 @@ __xfs_trans_commit( * Finish deferred items on final commit. Only permanent transactions * should ever have deferred ops. */ - WARN_ON_ONCE(!list_empty(&tp->t_dfops->dop_intake) && + WARN_ON_ONCE(!list_empty(&tp->t_dfops) && !(tp->t_flags & XFS_TRANS_PERM_LOG_RES)); if (!regrant && (tp->t_flags & XFS_TRANS_PERM_LOG_RES)) { error = xfs_defer_finish_noroll(&tp); diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index 1cdc7c0ebeac..c3d278e96ad1 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h @@ -90,13 +90,10 @@ void xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item, #define XFS_ITEM_FLUSHING 3 /* - * Deferred operations tracking structure. + * Deferred operation item relogging limits. */ #define XFS_DEFER_OPS_NR_INODES 2 /* join up to two inodes */ #define XFS_DEFER_OPS_NR_BUFS 2 /* join up to two buffers */ -struct xfs_defer_ops { - struct list_head dop_intake; /* unlogged pending work */ -}; /* * This is the structure maintained for every active transaction. @@ -114,7 +111,6 @@ typedef struct xfs_trans { struct xlog_ticket *t_ticket; /* log mgr ticket */ struct xfs_mount *t_mountp; /* ptr to fs mount struct */ struct xfs_dquot_acct *t_dqinfo; /* acctg info for dquots */ - struct xfs_defer_ops *t_dfops; /* dfops reference */ int64_t t_icount_delta; /* superblock icount change */ int64_t t_ifree_delta; /* superblock ifree change */ int64_t t_fdblocks_delta; /* superblock fdblocks chg */ @@ -136,8 +132,8 @@ typedef struct xfs_trans { int64_t t_rextslog_delta;/* superblocks rextslog chg */ struct list_head t_items; /* log item descriptors */ struct list_head t_busy; /* list of busy extents */ + struct list_head t_dfops; /* deferred operations */ unsigned long t_pflags; /* saved process flags state */ - struct xfs_defer_ops t_dfops_internal; } xfs_trans_t; /* -- cgit