xfs: broad enablement of deferred agfl frees
cover xfs: broad enablement of deferred agfl frees
Hi all,
Here's the next wave of dfops/xfs_trans related cleanups. This was split off the original series that introduced ->t_agfl_dfops to separate fixing the log reservation problems in those particular codepaths from broader cleanups and generalization of deferred agfl block frees.
The purpose of this series is to 1.) enable deferred AGFL frees for the broader codebase (wherever a dfops is already used) and 2.) clean up the various places dfops is carried through on the stack or via interface structures as the transaction reference is populated.
This work does expose a few warts with how dfops are used in relation to transactions. For example, log recovery uses a dfops as a primary structure and transactions are allocated/committed further down the callchain. In that case, we don't want the transaction to commit the caller's dfops. A few other places receive a transaction and then locally init/finish a dfops on the stack. We have to be careful in these places to not return a transaction to the caller with a dfops reference that points to freed or reused stack memory by the time the tx is committed.
I think these issues can be mostly resolved by the end goal of a combined xfs_trans/xfs_defer_ops structure. Boilerplate code that allocates a transaction, inits a dfops, finishes a dfops and commits the transaction can then reduce to allocating and committing the transaction (where the former and latter respectively init/finish an internal dfops). There are other patterns and issues to consider, however, so that will be a matter for a subsequent patch series. (I'm actually thinking of cleaning up all of the firstblock stuff as a next step in that direction.)
In this series: Patch 1 has been previously posted/reviewed. It is included just as a dependency. Patch 2 renames ->t_agfl_dfops back to ->t_dfops for general purpose use. Patches 3-4 reintroduce some cleanups dropped from the original series (where ->t_dfops is already used). Patches 5-23 enable the use of ->t_dfops for transactions in various subsystems, remove any subsequently unnecessary stack/data structure dfops references and repeat until pretty much every transaction has a dfops reference. Patch 24 refactors xfs_defer_init() to do the transaction association, cleaning up all of the manual assignments added by the previous patches.
I moved the final patch from the beginning to the end because it seemed controversial in the previous posting, for whatever reason. This order more explicitly documents the associated cleanup. Personally, I think the patch should be a requirement for the broad use of ->t_dfops implemented in this series, otherwise it's not clear to the developer that an association needs to be made with the transaction in many codepaths.
Finally, this has so far survived a couple rounds of xfstests with and without rmapbt and reflink enabled. Further testing is ongoing.
Thoughts, reviews, flames appreciated.
Brian
Brian Foster (24):
xfs: cow unwritten conversion uses uninitialized dfops
xfs: rename xfs_trans ->t_agfl_dfops to ->t_dfops
xfs: remove dfops parameter from ifree call stack
xfs: remove dfops param from high level dirname calls
xfs: use ->t_dfops for recovery of [b|c]ui log items
xfs: use ->t_dfops for attr set/remove operations
xfs: remove dfops param in attr fork add path
xfs: use ->t_dfops in extent split tx and remove param
xfs: replace xfs_da_args->dfops accesses with ->t_dfops and remove
xfs: use ->t_dfops in dqalloc transaction
xfs: use ->t_dfops for all xfs_bmapi_write() callers
xfs: remove xfs_bmapi_write() dfops param
xfs: use ->t_dfops for all xfs_bunmapi() callers
xfs: remove xfs_bunmapi() dfops param
xfs: remove xfs_bmapi_remap() dfops param
xfs: remove struct xfs_bmalloca dfops field
xfs: use ->t_dfops for collapse/insert range operations
xfs: remove dfops param from internal bmap extent helpers
xfs: remove xfs_btree_cur bmbt dfops field
xfs: remove unused btree cursor bc_private.a.dfops field
xfs: use ->t_dfops for rmap extent swap operations
xfs: use ->t_dfops in cancel cow blocks operation
xfs: use ->t_dfops in reflink cow recover path
xfs: refactor dfops init to attach to transaction
fs/xfs/libxfs/xfs_alloc.c | 4 +- fs/xfs/libxfs/xfs_attr.c | 116 ++++++++++--------- fs/xfs/libxfs/xfs_attr_leaf.c | 24 ++-- fs/xfs/libxfs/xfs_attr_remote.c | 22 ++-- fs/xfs/libxfs/xfs_bmap.c | 178 +++++++++++++---------------- fs/xfs/libxfs/xfs_bmap.h | 17 +-- fs/xfs/libxfs/xfs_bmap_btree.c | 9 +- fs/xfs/libxfs/xfs_btree.h | 2 - fs/xfs/libxfs/xfs_da_btree.c | 19 ++- fs/xfs/libxfs/xfs_da_btree.h | 1 - fs/xfs/libxfs/xfs_defer.c | 17 ++- fs/xfs/libxfs/xfs_defer.h | 3 +- fs/xfs/libxfs/xfs_dir2.c | 75 ++++++------ fs/xfs/libxfs/xfs_dir2.h | 9 +- fs/xfs/libxfs/xfs_ialloc.c | 6 +- fs/xfs/libxfs/xfs_ialloc.h | 1 - fs/xfs/libxfs/xfs_refcount.c | 14 +-- fs/xfs/libxfs/xfs_refcount_btree.c | 7 +- fs/xfs/libxfs/xfs_refcount_btree.h | 4 +- fs/xfs/scrub/common.c | 2 +- fs/xfs/xfs_bmap_item.c | 3 + fs/xfs/xfs_bmap_util.c | 63 +++++----- fs/xfs/xfs_dquot.c | 33 +++--- fs/xfs/xfs_filestream.c | 3 +- fs/xfs/xfs_fsmap.c | 2 +- fs/xfs/xfs_inode.c | 87 +++++++------- fs/xfs/xfs_inode.h | 3 +- fs/xfs/xfs_iomap.c | 25 ++-- fs/xfs/xfs_log_recover.c | 2 +- fs/xfs/xfs_refcount_item.c | 3 + fs/xfs/xfs_reflink.c | 68 ++++++----- fs/xfs/xfs_rtalloc.c | 8 +- fs/xfs/xfs_symlink.c | 22 ++-- fs/xfs/xfs_trans.c | 6 +- fs/xfs/xfs_trans.h | 2 +- 35 files changed, 415 insertions(+), 445 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/24 xfs: cow unwritten conversion uses uninitialized dfops
A couple COW fork unwritten extent conversion helpers pass an uninitialized dfops pointer to xfs_bmapi_write(). This does not cause problems because conversion does not use a transaction or the dfops structure for the COW fork. Drop the uninitialized usage of dfops in these codepaths and pass NULL along to xfs_bmapi_write() instead.
--- fs/xfs/xfs_reflink.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
fs/xfs/xfs_reflink.c +4 -7
@@ -312,8 +312,7 @@ xfs_reflink_convert_cow_extent(struct xfs_inode *ip, struct xfs_bmbt_irec *imap, xfs_fileoff_t offset_fsb, - xfs_filblks_t count_fsb, - struct xfs_defer_ops *dfops) + xfs_filblks_t count_fsb) { xfs_fsblock_t first_block = NULLFSBLOCK;int nimaps =1 ;
@@ -327,7 +326,7 @@ xfs_reflink_convert_cow_extent(return 0 ;return xfs_bmapi_write (NULL , ip, imap->br_startoff, imap->br_blockcount,XFS_BMAPI_COWFORK |XFS_BMAPI_CONVERT , &first_block, -0 , imap, &nimaps, dfops); +0 , imap, &nimaps,NULL ); }/* Convert all of the unwritten CoW extents in a file's range to real ones. */
@@ -342,7 +341,6 @@ xfs_reflink_convert_cow(xfs_fileoff_t end_fsb =XFS_B_TO_FSB (mp, offset + count);xfs_filblks_t count_fsb = end_fsb - offset_fsb;struct xfs_bmbt_irec imap; -struct xfs_defer_ops dfops;xfs_fsblock_t first_block =NULLFSBLOCK ;int nimaps =1 , error =0 ;
@@ -352,7 +350,7 @@ xfs_reflink_convert_cow( error =xfs_bmapi_write (NULL , ip, offset_fsb, count_fsb,XFS_BMAPI_COWFORK |XFS_BMAPI_CONVERT |XFS_BMAPI_CONVERT_ONLY , &first_block,0 , &imap, &nimaps, - &dfops); +NULL );xfs_iunlock (ip,XFS_ILOCK_EXCL );return error; }
@@ -458,8 +456,7 @@ xfs_reflink_allocate_cow(if (nimaps ==0 )return -ENOSPC ; convert: -return xfs_reflink_convert_cow_extent (ip, imap, offset_fsb, count_fsb, - &dfops); +return xfs_reflink_convert_cow_extent (ip, imap, offset_fsb, count_fsb); out_bmap_cancel:xfs_defer_cancel (&dfops); xfs_trans_unreserve_quota_nblks(tp, ip, (long)resblks, 0,
Signature · 1 line
2.17.1
Re: [PATCH 01/24] xfs: cow unwritten conversion uses uninitialized dfops
Quoted 6 lines · Brian Foster
A couple COW fork unwritten extent conversion helpers pass an uninitialized dfops pointer to
xfs_bmapi_write(). This does not cause problems because conversion does not use a transaction or the dfops structure for the COW fork. Drop the uninitialized usage of dfops in these codepaths and pass NULL along toxfs_bmapi_write()instead.
Looks good.
Is this something we should maybe queue up for 4.18?
Re: [PATCH 01/24] xfs: cow unwritten conversion uses uninitialized dfops
Quoted 8 lines · Christoph Hellwig
Quoted 6 lines · Brian Foster
A couple COW fork unwritten extent conversion helpers pass an uninitialized dfops pointer to
xfs_bmapi_write(). This does not cause problems because conversion does not use a transaction or the dfops structure for the COW fork. Drop the uninitialized usage of dfops in these codepaths and pass NULL along toxfs_bmapi_write()instead.
Quoted 4 lines
Looks good.
Is this something we should maybe queue up for 4.18?
That might make sense because of all the refactoring, but otherwise I don't have a strong opinion. Let's see what Darrick wants to do...
Brian
Quoted 5 lines
Reviewed-by Christoph Hellwig <[email protected]>--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 01/24] xfs: cow unwritten conversion uses uninitialized dfops
Quoted 9 lines · Brian Foster
Quoted 8 lines · Christoph Hellwig
Quoted 6 lines · Brian Foster
A couple COW fork unwritten extent conversion helpers pass an uninitialized dfops pointer to
xfs_bmapi_write(). This does not cause problems because conversion does not use a transaction or the dfops structure for the COW fork. Drop the uninitialized usage of dfops in these codepaths and pass NULL along toxfs_bmapi_write()instead.
Quoted 7 lines
Quoted 4 lines
Looks good.
Is this something we should maybe queue up for 4.18?
That might make sense because of all the refactoring, but otherwise I don't have a strong opinion. Let's see what Darrick wants to do...
AFAICT this only eliminates the passing around of an unus{ed,able} dfops parameter, right? We're not fixing a regression or some other breakage, just eliminating cpu cycle waste, so I think this can soak (along with everything else) until 4.19.
--D
Quoted 11 lines
Brian
Quoted 5 lines
Reviewed-by Christoph Hellwig <[email protected]>--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 01/24] xfs: cow unwritten conversion uses uninitialized dfops
Quoted 15 lines · Darrick J. Wong
Quoted 14 lines · Brian Foster
Quoted 12 lines · Christoph Hellwig
Quoted 6 lines · Brian Foster
A couple COW fork unwritten extent conversion helpers pass an uninitialized dfops pointer to
xfs_bmapi_write(). This does not cause problems because conversion does not use a transaction or the dfops structure for the COW fork. Drop the uninitialized usage of dfops in these codepaths and pass NULL along toxfs_bmapi_write()instead.Looks good.
Is this something we should maybe queue up for 4.18?
Quoted 8 lines
Quoted 2 lines
That might make sense because of all the refactoring, but otherwise I don't have a strong opinion. Let's see what Darrick wants to do...
AFAICT this only eliminates the passing around of an unus{ed,able} dfops parameter, right? We're not fixing a regression or some other breakage, just eliminating cpu cycle waste, so I think this can soak (along with everything else) until 4.19.
Works for me. This does have the side effect of enabling the deferred AGFL block free behavior wherever dfops is used, but that is a not a critical change/fix. The problem that inspired the behavior in the first place was resolved by the more targeted changes in the first series. The goals of this (and the series or two to follow) are primarily follow up refactoring and to provide more consistent behavior fs-wide.
Brian
Quoted 17 lines
--D
Quoted 11 lines
Brian
Quoted 5 lines
Reviewed-by Christoph Hellwig <[email protected]>--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 01/24] xfs: cow unwritten conversion uses uninitialized dfops
Quoted 25 lines · Brian Foster
Quoted 15 lines · Darrick J. Wong
Quoted 14 lines · Brian Foster
Quoted 12 lines · Christoph Hellwig
Quoted 6 lines · Brian Foster
A couple COW fork unwritten extent conversion helpers pass an uninitialized dfops pointer to
xfs_bmapi_write(). This does not cause problems because conversion does not use a transaction or the dfops structure for the COW fork. Drop the uninitialized usage of dfops in these codepaths and pass NULL along toxfs_bmapi_write()instead.Looks good.
Is this something we should maybe queue up for 4.18?
Quoted 8 lines
Quoted 2 lines
That might make sense because of all the refactoring, but otherwise I don't have a strong opinion. Let's see what Darrick wants to do...
AFAICT this only eliminates the passing around of an unus{ed,able} dfops parameter, right? We're not fixing a regression or some other breakage, just eliminating cpu cycle waste, so I think this can soak (along with everything else) until 4.19.
Quoted 6 lines
Works for me. This does have the side effect of enabling the deferred AGFL block free behavior wherever dfops is used, but that is a not a critical change/fix. The problem that inspired the behavior in the first place was resolved by the more targeted changes in the first series. The goals of this (and the series or two to follow) are primarily follow up refactoring and to provide more consistent behavior fs-wide.
Follow-up question, then: are there situations where we defered agfl freeing is /not/ desirable? I couldn't think of any, but my head (and shop vac) are full of sawdust. :)
--D
Quoted 19 lines
Brian
Quoted 17 lines
--D
Quoted 11 lines
Brian
Quoted 5 lines
Reviewed-by Christoph Hellwig <[email protected]>--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 01/24] xfs: cow unwritten conversion uses uninitialized dfops
Quoted 33 lines · Darrick J. Wong
Quoted 25 lines · Brian Foster
Quoted 15 lines · Darrick J. Wong
Quoted 14 lines · Brian Foster
Quoted 12 lines · Christoph Hellwig
Quoted 6 lines · Brian Foster
A couple COW fork unwritten extent conversion helpers pass an uninitialized dfops pointer to
xfs_bmapi_write(). This does not cause problems because conversion does not use a transaction or the dfops structure for the COW fork. Drop the uninitialized usage of dfops in these codepaths and pass NULL along toxfs_bmapi_write()instead.Looks good.
Is this something we should maybe queue up for 4.18?
Quoted 8 lines
Quoted 2 lines
That might make sense because of all the refactoring, but otherwise I don't have a strong opinion. Let's see what Darrick wants to do...
AFAICT this only eliminates the passing around of an unus{ed,able} dfops parameter, right? We're not fixing a regression or some other breakage, just eliminating cpu cycle waste, so I think this can soak (along with everything else) until 4.19.
Quoted 6 lines
Works for me. This does have the side effect of enabling the deferred AGFL block free behavior wherever dfops is used, but that is a not a critical change/fix. The problem that inspired the behavior in the first place was resolved by the more targeted changes in the first series. The goals of this (and the series or two to follow) are primarily follow up refactoring and to provide more consistent behavior fs-wide.
Quoted 4 lines
Follow-up question, then: are there situations where we defered agfl freeing is /not/ desirable? I couldn't think of any, but my head (and shop vac) are full of sawdust. :)
I don't think so. My presumption since the original series is that this is essentially an analogus situation to freeing file blocks. We defer it unconditionally to provide some semblence of consistent/predictable transaction reservation consumption. I haven't audited to the point of seeing if we need to add dfops in certain paths purely for deferred AGFL frees (i.e., adding dfops to paths that don't already have a dfops), but the bit I mentioned in my last mail would effectively cover that last case by embedding ->t_dfops in the transaction. With that, any transaction is capable of deferring operations to be finished automatically at commit time (and the boilerplate trans_alloc() -> defer_init() -> defer_finish() -> trans_commit() sequence can be factored away). One obvious tradeoff is that the transaction becomes bigger, but I'm not sure how much that matters given that we have a dfops in most cases anyways and we're using it more progressively.
BTW, I don't think any of this precludes us from not deferring AGFL frees in a particular case if that becomes necessary for some reason in the future. We'd just need to decide out how to communicate that to the allocator (alloc_arg flag, tx flag, etc.).
Brian
Quoted 21 lines
--D
Quoted 19 lines
Brian
Quoted 17 lines
--D
Quoted 11 lines
Brian
Quoted 5 lines
Reviewed-by Christoph Hellwig <[email protected]>--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Darrick J. Wong
Reviewed-byRe: [PATCH 01/24] xfs: cow unwritten conversion uses uninitialized dfops
Quoted 39 lines · Brian Foster
Quoted 33 lines · Darrick J. Wong
Quoted 25 lines · Brian Foster
Quoted 15 lines · Darrick J. Wong
Quoted 14 lines · Brian Foster
Quoted 12 lines · Christoph Hellwig
Quoted 6 lines · Brian Foster
A couple COW fork unwritten extent conversion helpers pass an uninitialized dfops pointer to
xfs_bmapi_write(). This does not cause problems because conversion does not use a transaction or the dfops structure for the COW fork. Drop the uninitialized usage of dfops in these codepaths and pass NULL along toxfs_bmapi_write()instead.Looks good.
Is this something we should maybe queue up for 4.18?
Quoted 8 lines
Quoted 2 lines
That might make sense because of all the refactoring, but otherwise I don't have a strong opinion. Let's see what Darrick wants to do...
AFAICT this only eliminates the passing around of an unus{ed,able} dfops parameter, right? We're not fixing a regression or some other breakage, just eliminating cpu cycle waste, so I think this can soak (along with everything else) until 4.19.
Quoted 6 lines
Works for me. This does have the side effect of enabling the deferred AGFL block free behavior wherever dfops is used, but that is a not a critical change/fix. The problem that inspired the behavior in the first place was resolved by the more targeted changes in the first series. The goals of this (and the series or two to follow) are primarily follow up refactoring and to provide more consistent behavior fs-wide.
Quoted 4 lines
Follow-up question, then: are there situations where we defered agfl freeing is /not/ desirable? I couldn't think of any, but my head (and shop vac) are full of sawdust. :)
Quoted 14 lines
I don't think so. My presumption since the original series is that this is essentially an analogus situation to freeing file blocks. We defer it unconditionally to provide some semblence of consistent/predictable transaction reservation consumption. I haven't audited to the point of seeing if we need to add dfops in certain paths purely for deferred AGFL frees (i.e., adding dfops to paths that don't already have a dfops), but the bit I mentioned in my last mail would effectively cover that last case by embedding ->t_dfops in the transaction. With that, any transaction is capable of deferring operations to be finished automatically at commit time (and the boilerplate
trans_alloc()->defer_init()->defer_finish()->trans_commit()sequence can be factored away). One obvious tradeoff is that the transaction becomes bigger, but I'm not sure how much that matters given that we have a dfops in most cases anyways and we're using it more progressively.
There's also the advantage that we're no longer using stack space for the dfops, and by sticking it in the transaction it's a little more explicit that we don't do nested dfops.
Quoted 4 lines
BTW, I don't think any of this precludes us from not deferring AGFL frees in a particular case if that becomes necessary for some reason in the future. We'd just need to decide out how to communicate that to the allocator (
alloc_argflag, tx flag, etc.).
<nod> seeing as the agfl free items get written to the log as regular EFIs I figured the only harm would come from the extra overhead of finishing the dfops. I'm not sure what /that/ is though... :)
Anyway, for the patch itself,
--D
Quoted 28 lines
Brian
Quoted 21 lines
--D
Quoted 19 lines
Brian
Quoted 17 lines
--D
Quoted 11 lines
Brian
Quoted 5 lines
Reviewed-by Christoph Hellwig <[email protected]>--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/24 xfs: rename xfs_trans ->t_agfl_dfops to ->t_dfops
In reply to Brian FosterThe ->t_agfl_dfops field is currently used to defer agfl block frees from associated transaction contexts. While all known problematic contexts have already been updated to use ->t_agfl_dfops, the broader goal is defer agfl frees from all callers that already use a deferred operations structure. Further, the transaction field facilitates a good amount of code clean up where the transaction and dfops have historically been passed down through the stack separately.
Rename the field to something more generic to prepare to use it as such throughout XFS. This patch does not change behavior.
--- fs/xfs/libxfs/xfs_alloc.c | 4 ++-- fs/xfs/libxfs/xfs_defer.c | 8 ++++---- fs/xfs/xfs_inode.c | 10 +++++----- fs/xfs/xfs_symlink.c | 2 +- fs/xfs/xfs_trans.c | 6 +++--- fs/xfs/xfs_trans.h | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-)
fs/xfs/libxfs/xfs_alloc.c +2 -2
@@ -2323,8 +2323,8 @@ xfs_alloc_fix_freelist( goto out_agbp_relse;/* defer agfl frees if dfops is provided */ -if (tp->t_agfl_dfops) { -xfs_defer_agfl_block (mp, tp->t_agfl_dfops, args->agno, +if (tp->t_dfops) { +xfs_defer_agfl_block (mp, tp->t_dfops, args->agno, bno, &targs.oinfo); }else { error = xfs_free_agfl_block(tp, args->agno, bno, agbp,
fs/xfs/libxfs/xfs_defer.c +4 -4
@@ -350,9 +350,9 @@ xfs_defer_finish(* Note that this code can go away once all dfops users attach to the * associated tp. */ -ASSERT (!(*tp)->t_agfl_dfops || ((*tp)->t_agfl_dfops == dop)); - orig_dop = (*tp)->t_agfl_dfops; - (*tp)->t_agfl_dfops = dop; +ASSERT (!(*tp)->t_dfops || ((*tp)->t_dfops == dop)); + orig_dop = (*tp)->t_dfops; + (*tp)->t_dfops = dop;/* Until we run out of pending work to finish... */ while (xfs_defer_has_unfinished_work (dop)) {
@@ -425,7 +425,7 @@ xfs_defer_finish( } out: - (*tp)->t_agfl_dfops = orig_dop; + (*tp)->t_dfops = orig_dop;if (error)trace_xfs_defer_finish_error ((*tp)->t_mountp, dop, error);else
fs/xfs/xfs_inode.c +5 -5
@@ -1196,7 +1196,7 @@ xfs_create( unlock_dp_on_error = true;xfs_defer_init (&dfops, &first_block); - tp->t_agfl_dfops = &dfops; + tp->t_dfops = &dfops;/* * Reserve disk quota and the inode.
@@ -1452,7 +1452,7 @@ xfs_link( }xfs_defer_init (&dfops, &first_block); - tp->t_agfl_dfops = &dfops; + tp->t_dfops = &dfops;/* * Handle initial link state of O_TMPFILE inode
@@ -1813,7 +1813,7 @@ xfs_inactive_ifree(xfs_trans_ijoin (tp, ip,0 );xfs_defer_init (&dfops, &first_block); - tp->t_agfl_dfops = &dfops; + tp->t_dfops = &dfops; error =xfs_ifree (tp, ip, &dfops);if (error) {/*
@@ -2659,7 +2659,7 @@ xfs_remove( goto out_trans_cancel;xfs_defer_init (&dfops, &first_block); - tp->t_agfl_dfops = &dfops; + tp->t_dfops = &dfops; error =xfs_dir_removename (tp, dp, name, ip->i_ino, &first_block, &dfops, resblks);if (error) {
@@ -3027,7 +3027,7 @@ xfs_rename( }xfs_defer_init (&dfops, &first_block); - tp->t_agfl_dfops = &dfops; + tp->t_dfops = &dfops;/* RENAME_EXCHANGE is unique from here on. */ if (flags &RENAME_EXCHANGE )
fs/xfs/xfs_symlink.c +1 -1
@@ -247,7 +247,7 @@ xfs_symlink(* bmapi or the directory create code. */ xfs_defer_init (&dfops, &first_block); - tp->t_agfl_dfops = &dfops; + tp->t_dfops = &dfops;/* * Allocate an inode for the symlink.
fs/xfs/xfs_trans.c +3 -3
@@ -118,7 +118,7 @@ xfs_trans_dup( ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used; tp->t_rtx_res = tp->t_rtx_res_used; ntp->t_pflags = tp->t_pflags; - ntp->t_agfl_dfops = tp->t_agfl_dfops; + ntp->t_dfops = tp->t_dfops;xfs_trans_dup_dqinfo (tp, ntp);
@@ -914,8 +914,8 @@ __xfs_trans_commit(int error =0 ;int sync = tp->t_flags &XFS_TRANS_SYNC ; -ASSERT (!tp->t_agfl_dfops || - !xfs_defer_has_unfinished_work (tp->t_agfl_dfops) || regrant); +ASSERT (!tp->t_dfops || + !xfs_defer_has_unfinished_work (tp->t_dfops) || regrant);trace_xfs_trans_commit (tp, _RET_IP_);
fs/xfs/xfs_trans.h +1 -1
@@ -105,7 +105,7 @@ 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_agfl_dfops;/* optional agfl fixup dfops */ +struct xfs_defer_ops *t_dfops;/* dfops reference */ unsigned int t_flags;/* misc flags */ int64_t t_icount_delta;/* superblock icount change */ int64_t t_ifree_delta;/* superblock ifree change */
Signature · 1 line
2.17.1
Re: [PATCH 02/24] xfs: rename xfs_trans ->t_agfl_dfops to ->t_dfops
Quoted 9 lines · Brian Foster
The ->t_agfl_dfops field is currently used to defer agfl block frees from associated transaction contexts. While all known problematic contexts have already been updated to use ->t_agfl_dfops, the broader goal is defer agfl frees from all callers that already use a deferred operations structure. Further, the transaction field facilitates a good amount of code clean up where the transaction and dfops have historically been passed down through the stack separately.
Quoted 4 lines
Rename the field to something more generic to prepare to use it as such throughout XFS. This patch does not change behavior.
Signed-off-by Brian Foster <[email protected]>
Looks good,
Re: [PATCH 02/24] xfs: rename xfs_trans ->t_agfl_dfops to ->t_dfops
In reply to Brian FosterQuoted 9 lines · Brian Foster
The ->t_agfl_dfops field is currently used to defer agfl block frees from associated transaction contexts. While all known problematic contexts have already been updated to use ->t_agfl_dfops, the broader goal is defer agfl frees from all callers that already use a deferred operations structure. Further, the transaction field facilitates a good amount of code clean up where the transaction and dfops have historically been passed down through the stack separately.
Quoted 4 lines
Rename the field to something more generic to prepare to use it as such throughout XFS. This patch does not change behavior.
Signed-off-by Brian Foster <[email protected]>
Looks ok,
--D
Quoted 156 lines
--- fs/xfs/libxfs/xfs_alloc.c | 4 ++-- fs/xfs/libxfs/xfs_defer.c | 8 ++++---- fs/xfs/xfs_inode.c | 10 +++++----- fs/xfs/xfs_symlink.c | 2 +- fs/xfs/xfs_trans.c | 6 +++--- fs/xfs/xfs_trans.h | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-)fs/xfs/libxfs/xfs_alloc.c +2
-2@@ -2323,8 +2323,8 @@ xfs_alloc_fix_freelist( goto out_agbp_relse;/* defer agfl frees if dfops is provided */ -if (tp->t_agfl_dfops) { -xfs_defer_agfl_block (mp, tp->t_agfl_dfops, args->agno, +if (tp->t_dfops) { +xfs_defer_agfl_block (mp, tp->t_dfops, args->agno, bno, &targs.oinfo); }else { error = xfs_free_agfl_block(tp, args->agno, bno, agbp,fs/xfs/libxfs/xfs_defer.c +4
-4@@ -350,9 +350,9 @@ xfs_defer_finish(* Note that this code can go away once all dfops users attach to the * associated tp. */ -ASSERT (!(*tp)->t_agfl_dfops || ((*tp)->t_agfl_dfops == dop)); - orig_dop = (*tp)->t_agfl_dfops; - (*tp)->t_agfl_dfops = dop; +ASSERT (!(*tp)->t_dfops || ((*tp)->t_dfops == dop)); + orig_dop = (*tp)->t_dfops; + (*tp)->t_dfops = dop;/* Until we run out of pending work to finish... */ while (xfs_defer_has_unfinished_work (dop)) {@@ -425,7 +425,7 @@ xfs_defer_finish( } out: - (*tp)->t_agfl_dfops = orig_dop; + (*tp)->t_dfops = orig_dop;if (error)trace_xfs_defer_finish_error ((*tp)->t_mountp, dop, error);else fs/xfs/xfs_inode.c +5
-5@@ -1196,7 +1196,7 @@ xfs_create( unlock_dp_on_error = true;xfs_defer_init (&dfops, &first_block); - tp->t_agfl_dfops = &dfops; + tp->t_dfops = &dfops;/* * Reserve disk quota and the inode. @@ -1452,7 +1452,7 @@ xfs_link( }xfs_defer_init (&dfops, &first_block); - tp->t_agfl_dfops = &dfops; + tp->t_dfops = &dfops;/* * Handle initial link state of O_TMPFILE inode @@ -1813,7 +1813,7 @@ xfs_inactive_ifree(xfs_trans_ijoin (tp, ip,0 );xfs_defer_init (&dfops, &first_block); - tp->t_agfl_dfops = &dfops; + tp->t_dfops = &dfops; error =xfs_ifree (tp, ip, &dfops);if (error) {/* @@ -2659,7 +2659,7 @@ xfs_remove( goto out_trans_cancel;xfs_defer_init (&dfops, &first_block); - tp->t_agfl_dfops = &dfops; + tp->t_dfops = &dfops; error =xfs_dir_removename (tp, dp, name, ip->i_ino, &first_block, &dfops, resblks);if (error) {@@ -3027,7 +3027,7 @@ xfs_rename( }xfs_defer_init (&dfops, &first_block); - tp->t_agfl_dfops = &dfops; + tp->t_dfops = &dfops;/* RENAME_EXCHANGE is unique from here on. */ if (flags &RENAME_EXCHANGE )fs/xfs/xfs_symlink.c +1
-1@@ -247,7 +247,7 @@ xfs_symlink(* bmapi or the directory create code. */ xfs_defer_init (&dfops, &first_block); - tp->t_agfl_dfops = &dfops; + tp->t_dfops = &dfops;/* * Allocate an inode for the symlink. fs/xfs/xfs_trans.c +3
-3@@ -118,7 +118,7 @@ xfs_trans_dup( ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used; tp->t_rtx_res = tp->t_rtx_res_used; ntp->t_pflags = tp->t_pflags; - ntp->t_agfl_dfops = tp->t_agfl_dfops; + ntp->t_dfops = tp->t_dfops;xfs_trans_dup_dqinfo (tp, ntp);@@ -914,8 +914,8 @@ __xfs_trans_commit(int error =0 ;int sync = tp->t_flags &XFS_TRANS_SYNC ; -ASSERT (!tp->t_agfl_dfops || - !xfs_defer_has_unfinished_work (tp->t_agfl_dfops) || regrant); +ASSERT (!tp->t_dfops || + !xfs_defer_has_unfinished_work (tp->t_dfops) || regrant);trace_xfs_trans_commit (tp, _RET_IP_);fs/xfs/xfs_trans.h +1
-1@@ -105,7 +105,7 @@ 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_agfl_dfops;/* optional agfl fixup dfops */ +struct xfs_defer_ops *t_dfops;/* dfops reference */ unsigned int t_flags;/* misc flags */ int64_t t_icount_delta;/* superblock icount change */ int64_t t_ifree_delta;/* superblock ifree change */ Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/24 xfs: remove dfops parameter from ifree call stack
In reply to Brian FosterThe inode free callchain starting in xfs_inactive_ifree() already associates its dfops with the transaction. It still passes the dfops on the stack down through xfs_difree_inobt(), however.
Clean up the call stack and reference dfops directly from the transaction. This patch does not change behavior.
--- fs/xfs/libxfs/xfs_ialloc.c | 6 ++---- fs/xfs/libxfs/xfs_ialloc.h | 1 - fs/xfs/xfs_inode.c | 9 ++++----- fs/xfs/xfs_inode.h | 3 +-- 4 files changed, 7 insertions(+), 12 deletions(-)
fs/xfs/libxfs/xfs_ialloc.c +2 -4
@@ -1915,7 +1915,6 @@ xfs_difree_inobt(struct xfs_trans *tp, struct xfs_buf *agbp, xfs_agino_t agino, - struct xfs_defer_ops *dfops, struct xfs_icluster *xic, struct xfs_inobt_rec_incore *orec) {
@@ -2003,7 +2002,7 @@ xfs_difree_inobt( goto error0; } -xfs_difree_inode_chunk (mp, agno, &rec, dfops); +xfs_difree_inode_chunk (mp, agno, &rec, tp->t_dfops); }else { xic->deleted = false;
@@ -2148,7 +2147,6 @@ intxfs_difree ( struct xfs_trans *tp, /* transaction pointer */ xfs_ino_t inode, /* inode to be freed */ - struct xfs_defer_ops *dfops, /* extents to free */ struct xfs_icluster *xic) /* cluster info if deleted */ {/* REFERENCED */
@@ -2200,7 +2198,7 @@ xfs_difree(/* * Fix up the inode allocation btree. */ - error =xfs_difree_inobt (mp, tp, agbp, agino, dfops, xic, &rec); + error =xfs_difree_inobt (mp, tp, agbp, agino, xic, &rec);if (error) goto error0;
fs/xfs/libxfs/xfs_ialloc.h +0 -1
@@ -82,7 +82,6 @@ int /* error */xfs_difree ( struct xfs_trans *tp, /* transaction pointer */ xfs_ino_t inode, /* inode to be freed */ - struct xfs_defer_ops *dfops, /* extents to free */ struct xfs_icluster *ifree); /* cluster info if deleted *//*
fs/xfs/xfs_inode.c +4 -5
@@ -1814,7 +1814,7 @@ xfs_inactive_ifree(xfs_defer_init (&dfops, &first_block); tp->t_dfops = &dfops; - error =xfs_ifree (tp, ip, &dfops); + error =xfs_ifree (tp, ip);if (error) {/* * If we fail to free the inode, shut down. The cancel
@@ -2445,9 +2445,8 @@ xfs_ifree_local_data(*/ int xfs_ifree ( -xfs_trans_t *tp, -xfs_inode_t *ip, -struct xfs_defer_ops *dfops) +struct xfs_trans *tp, +struct xfs_inode *ip) {int error;struct xfs_icluster xic = {0 };
@@ -2466,7 +2465,7 @@ xfs_ifree(if (error)return error; - error =xfs_difree (tp, ip->i_ino, dfops, &xic); + error =xfs_difree (tp, ip->i_ino, &xic);if (error)return error;
fs/xfs/xfs_inode.h +1 -2
@@ -415,8 +415,7 @@ uint xfs_ilock_data_map_shared(struct xfs_inode *);uint xfs_ilock_attr_map_shared (struct xfs_inode *);uint xfs_ip2xflags (struct xfs_inode *); -int xfs_ifree (struct xfs_trans *,xfs_inode_t *, -struct xfs_defer_ops *); +int xfs_ifree (struct xfs_trans *,struct xfs_inode *);int xfs_itruncate_extents_flags (struct xfs_trans **,struct xfs_inode *,int ,xfs_fsize_t ,int );void xfs_iext_realloc (xfs_inode_t *,int ,int );
Signature · 1 line
2.17.1
Re: [PATCH 03/24] xfs: remove dfops parameter from ifree call stack
Quoted 8 lines · Brian Foster
The inode free callchain starting in
xfs_inactive_ifree()already associates its dfops with the transaction. It still passes the dfops on the stack down throughxfs_difree_inobt(), however.Clean up the call stack and reference dfops directly from the transaction. This patch does not change behavior.
Signed-off-by Brian Foster <[email protected]>
Looks good,
Re: [PATCH 03/24] xfs: remove dfops parameter from ifree call stack
In reply to Brian FosterQuoted 8 lines · Brian Foster
The inode free callchain starting in
xfs_inactive_ifree()already associates its dfops with the transaction. It still passes the dfops on the stack down throughxfs_difree_inobt(), however.Clean up the call stack and reference dfops directly from the transaction. This patch does not change behavior.
Signed-off-by Brian Foster <[email protected]>
Looks ok,
--D
Quoted 112 lines
--- fs/xfs/libxfs/xfs_ialloc.c | 6 ++---- fs/xfs/libxfs/xfs_ialloc.h | 1 - fs/xfs/xfs_inode.c | 9 ++++----- fs/xfs/xfs_inode.h | 3 +-- 4 files changed, 7 insertions(+), 12 deletions(-)fs/xfs/libxfs/xfs_ialloc.c +2
-4@@ -1915,7 +1915,6 @@ xfs_difree_inobt(struct xfs_trans *tp, struct xfs_buf *agbp, xfs_agino_t agino, - struct xfs_defer_ops *dfops, struct xfs_icluster *xic, struct xfs_inobt_rec_incore *orec) {@@ -2003,7 +2002,7 @@ xfs_difree_inobt( goto error0; } -xfs_difree_inode_chunk (mp, agno, &rec, dfops); +xfs_difree_inode_chunk (mp, agno, &rec, tp->t_dfops); }else { xic->deleted = false;@@ -2148,7 +2147,6 @@ intxfs_difree ( struct xfs_trans *tp, /* transaction pointer */ xfs_ino_t inode, /* inode to be freed */ - struct xfs_defer_ops *dfops, /* extents to free */ struct xfs_icluster *xic) /* cluster info if deleted */ {/* REFERENCED */ @@ -2200,7 +2198,7 @@ xfs_difree(/* * Fix up the inode allocation btree. */ - error =xfs_difree_inobt (mp, tp, agbp, agino, dfops, xic, &rec); + error =xfs_difree_inobt (mp, tp, agbp, agino, xic, &rec);if (error) goto error0;fs/xfs/libxfs/xfs_ialloc.h +0
-1@@ -82,7 +82,6 @@ int /* error */xfs_difree ( struct xfs_trans *tp, /* transaction pointer */ xfs_ino_t inode, /* inode to be freed */ - struct xfs_defer_ops *dfops, /* extents to free */ struct xfs_icluster *ifree); /* cluster info if deleted *//* fs/xfs/xfs_inode.c +4
-5@@ -1814,7 +1814,7 @@ xfs_inactive_ifree(xfs_defer_init (&dfops, &first_block); tp->t_dfops = &dfops; - error =xfs_ifree (tp, ip, &dfops); + error =xfs_ifree (tp, ip);if (error) {/* * If we fail to free the inode, shut down. The cancel @@ -2445,9 +2445,8 @@ xfs_ifree_local_data(*/ int xfs_ifree ( -xfs_trans_t *tp, -xfs_inode_t *ip, -struct xfs_defer_ops *dfops) +struct xfs_trans *tp, +struct xfs_inode *ip) {int error;struct xfs_icluster xic = {0 };@@ -2466,7 +2465,7 @@ xfs_ifree(if (error)return error; - error =xfs_difree (tp, ip->i_ino, dfops, &xic); + error =xfs_difree (tp, ip->i_ino, &xic);if (error)return error;fs/xfs/xfs_inode.h +1
-2@@ -415,8 +415,7 @@ uint xfs_ilock_data_map_shared(struct xfs_inode *);uint xfs_ilock_attr_map_shared (struct xfs_inode *);uint xfs_ip2xflags (struct xfs_inode *); -int xfs_ifree (struct xfs_trans *,xfs_inode_t *, -struct xfs_defer_ops *); +int xfs_ifree (struct xfs_trans *,struct xfs_inode *);int xfs_itruncate_extents_flags (struct xfs_trans **,struct xfs_inode *,int ,xfs_fsize_t ,int );void xfs_iext_realloc (xfs_inode_t *,int ,int );Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 4/24 xfs: remove dfops param from high level dirname calls
In reply to Brian FosterAll 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.
--- fs/xfs/libxfs/xfs_dir2.c | 16 ++++++------- fs/xfs/libxfs/xfs_dir2.h | 9 +++----- fs/xfs/xfs_inode.c | 50 ++++++++++++++++++---------------------- fs/xfs/xfs_symlink.c | 2 +- 4 files changed, 35 insertions(+), 42 deletions(-)
fs/xfs/libxfs/xfs_dir2.c +8 -8
@@ -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;
@@ -270,11 +269,12 @@ 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; +ASSERT (tp->t_dfops || !first); + 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 +421,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;
@@ -443,10 +442,11 @@ 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; +ASSERT (tp->t_dfops); + args->dfops = tp->t_dfops;if (dp->i_d.di_format ==XFS_DINODE_FMT_LOCAL ) { rval =xfs_dir2_sf_removename (args);
@@ -483,7 +483,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;
@@ -508,10 +507,11 @@ 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; +ASSERT (tp->t_dfops); + args->dfops = tp->t_dfops;if (dp->i_d.di_format ==XFS_DINODE_FMT_LOCAL ) { rval =xfs_dir2_sf_replace (args);
@@ -547,7 +547,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); }/*
fs/xfs/libxfs/xfs_dir2.h +3 -6
@@ -118,19 +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, -struct xfs_defer_ops *dfops,xfs_extlen_t tot); +xfs_fsblock_t *first,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, -struct xfs_defer_ops *dfops,xfs_extlen_t tot); +xfs_fsblock_t *first,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, -struct xfs_defer_ops *dfops,xfs_extlen_t tot); +xfs_fsblock_t *first,xfs_extlen_t tot);extern int xfs_dir_canenter (struct xfs_trans *tp,struct xfs_inode *dp,struct xfs_name *name);
fs/xfs/xfs_inode.c +23 -27
149 lines not on this page · raw message
fs/xfs/xfs_symlink.c +1 -1
@@ -339,7 +339,7 @@ xfs_symlink(* Create the directory entry for the symlink. */ error =xfs_dir_createname (tp, dp, link_name, ip->i_ino, - &first_block, &dfops, resblks); + &first_block, resblks);if (error) goto out_bmap_cancel;xfs_trans_ichgtime (tp, dp,XFS_ICHGTIME_MOD |XFS_ICHGTIME_CHG );
Signature · 1 line
2.17.1
Re: [PATCH 04/24] xfs: remove dfops param from high level dirname calls
fs/xfs/libxfs/xfs_dir2.c xfs_dir_createname( · line 275
Quoted 5 lines
fs/xfs/libxfs/xfs_dir2.c +1
-1- args->dfops = dfops; args->total = total; args->whichfork =XFS_DATA_FORK ; args->trans = tp; +ASSERT (tp->t_dfops || !first);
Nitpick: I like to have calling convention asserts always at the beginning of the function to clearly see the assumed state on the first look.
Otherwise looks fine:
Re: [PATCH 04/24] xfs: remove dfops param from high level dirname calls
Quoted 10 lines · Christoph Hellwig
fs/xfs/libxfs/xfs_dir2.c xfs_dir_createname( · line 275
Quoted 5 lines
fs/xfs/libxfs/xfs_dir2.c +1
-1- args->dfops = dfops; args->total = total; args->whichfork =XFS_DATA_FORK ; args->trans = tp; +ASSERT (tp->t_dfops || !first);Nitpick: I like to have calling convention asserts always at the beginning of the function to clearly see the assumed state on the first look.
Ok, I'll fix that up.
Brian
Quoted 7 lines
Otherwise looks fine:
Reviewed-by Christoph Hellwig <[email protected]>--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/1 xfs: remove dfops param from high level dirname calls
In reply to Brian FosterAll 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.
---
v2:
- Move asserts to function start.
fs/xfs/libxfs/xfs_dir2.c | 17 +++++++------- fs/xfs/libxfs/xfs_dir2.h | 9 +++----- fs/xfs/xfs_inode.c | 50 ++++++++++++++++++---------------------- fs/xfs/xfs_symlink.c | 2 +- 4 files changed, 36 insertions(+), 42 deletions(-)
fs/xfs/libxfs/xfs_dir2.c +9 -8
@@ -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); }/*
fs/xfs/libxfs/xfs_dir2.h +3 -6
@@ -118,19 +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, -struct xfs_defer_ops *dfops,xfs_extlen_t tot); +xfs_fsblock_t *first,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, -struct xfs_defer_ops *dfops,xfs_extlen_t tot); +xfs_fsblock_t *first,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, -struct xfs_defer_ops *dfops,xfs_extlen_t tot); +xfs_fsblock_t *first,xfs_extlen_t tot);extern int xfs_dir_canenter (struct xfs_trans *tp,struct xfs_inode *dp,struct xfs_name *name);
fs/xfs/xfs_inode.c +23 -27
149 lines not on this page · raw message
fs/xfs/xfs_symlink.c +1 -1
@@ -339,7 +339,7 @@ xfs_symlink(* Create the directory entry for the symlink. */ error =xfs_dir_createname (tp, dp, link_name, ip->i_ino, - &first_block, &dfops, resblks); + &first_block, resblks);if (error) goto out_bmap_cancel;xfs_trans_ichgtime (tp, dp,XFS_ICHGTIME_MOD |XFS_ICHGTIME_CHG );
Signature · 1 line
2.17.1
Re: [PATCH v2] xfs: remove dfops param from high level dirname calls
Quoted 7 lines · Brian Foster
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 <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>
Looks ok,
--D
Quoted 326 lines
---
v2:
- Move asserts to function start.fs/xfs/libxfs/xfs_dir2.c | 17 +++++++------- fs/xfs/libxfs/xfs_dir2.h | 9 +++----- fs/xfs/xfs_inode.c | 50 ++++++++++++++++++---------------------- fs/xfs/xfs_symlink.c | 2 +- 4 files changed, 36 insertions(+), 42 deletions(-)fs/xfs/libxfs/xfs_dir2.c +9
-8@@ -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); }/* fs/xfs/libxfs/xfs_dir2.h +3
-6@@ -118,19 +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, -struct xfs_defer_ops *dfops,xfs_extlen_t tot); +xfs_fsblock_t *first,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, -struct xfs_defer_ops *dfops,xfs_extlen_t tot); +xfs_fsblock_t *first,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, -struct xfs_defer_ops *dfops,xfs_extlen_t tot); +xfs_fsblock_t *first,xfs_extlen_t tot);extern int xfs_dir_canenter (struct xfs_trans *tp,struct xfs_inode *dp,struct xfs_name *name);fs/xfs/xfs_inode.c +23
-27@@ -1225,8 +1225,8 @@ 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, - &first_block, &dfops, resblks ? + error =xfs_dir_createname (tp, dp, name, ip->i_ino, &first_block, + resblks ? resblks -XFS_IALLOC_SPACE_RES (mp) :0 );if (error) {ASSERT (error != -ENOSPC );@@ -1464,7 +1464,7 @@ xfs_link( } error =xfs_dir_createname (tp, tdp, target_name, sip->i_ino, - &first_block, &dfops, resblks); + &first_block, resblks);if (error) goto error_return;xfs_trans_ichgtime (tp, tdp,XFS_ICHGTIME_MOD |XFS_ICHGTIME_CHG );@@ -2659,8 +2659,8 @@ xfs_remove(xfs_defer_init (&dfops, &first_block); tp->t_dfops = &dfops; - error =xfs_dir_removename (tp, dp, name, ip->i_ino, - &first_block, &dfops, resblks); + error =xfs_dir_removename (tp, dp, name, ip->i_ino, &first_block, + resblks);if (error) {ASSERT (error != -ENOENT ); goto out_bmap_cancel;@@ -2748,9 +2748,9 @@ xfs_sort_for_rename(static int xfs_finish_rename ( -struct xfs_trans *tp, -struct xfs_defer_ops *dfops) +struct xfs_trans *tp) { +struct xfs_defer_ops *dfops = tp->t_dfops;int error;/* @@ -2784,7 +2784,6 @@ xfs_cross_rename(struct xfs_inode *dp2, struct xfs_name *name2, struct xfs_inode *ip2, - struct xfs_defer_ops *dfops, xfs_fsblock_t *first_block, int spaceres) {@@ -2794,16 +2793,14 @@ 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, - first_block, dfops, spaceres); + error =xfs_dir_replace (tp, dp1, name1, ip2->i_ino, first_block, + 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, - first_block, dfops, spaceres); + error =xfs_dir_replace (tp, dp2, name2, ip1->i_ino, first_block, + spaceres);if (error) goto out_trans_abort;@@ -2818,7 +2815,7 @@ xfs_cross_rename(if (S_ISDIR (VFS_I (ip2)->i_mode)) { error =xfs_dir_replace (tp, ip2, &xfs_name_dotdot, dp1->i_ino, first_block, - dfops, spaceres); + spaceres);if (error) goto out_trans_abort;@@ -2845,7 +2842,7 @@ xfs_cross_rename(if (S_ISDIR (VFS_I (ip1)->i_mode)) { error =xfs_dir_replace (tp, ip1, &xfs_name_dotdot, dp2->i_ino, first_block, - dfops, spaceres); + spaceres);if (error) goto out_trans_abort;@@ -2884,10 +2881,10 @@ xfs_cross_rename( }xfs_trans_ichgtime (tp, dp1,XFS_ICHGTIME_MOD |XFS_ICHGTIME_CHG );xfs_trans_log_inode (tp, dp1,XFS_ILOG_CORE ); -return xfs_finish_rename (tp, dfops); +return xfs_finish_rename (tp); out_trans_abort: -xfs_defer_cancel (dfops); +xfs_defer_cancel (tp->t_dfops);xfs_trans_cancel (tp);return error; }@@ -3032,7 +3029,7 @@ xfs_rename(if (flags &RENAME_EXCHANGE )return xfs_cross_rename (tp, src_dp, src_name, src_ip, target_dp, target_name, target_ip, - &dfops, &first_block, spaceres); + &first_block, spaceres);/* * Set up the target. @@ -3054,7 +3051,7 @@ xfs_rename(*/ error =xfs_dir_createname (tp, target_dp, target_name, src_ip->i_ino, &first_block, - &dfops, spaceres); + spaceres);if (error) goto out_bmap_cancel;@@ -3093,8 +3090,7 @@ xfs_rename(* name at the destination directory, remove it first. */ error =xfs_dir_replace (tp, target_dp, target_name, - src_ip->i_ino, - &first_block, &dfops, spaceres); + src_ip->i_ino, &first_block, spaceres);if (error) goto out_bmap_cancel;@@ -3128,8 +3124,8 @@ xfs_rename(* directory. */ error =xfs_dir_replace (tp, src_ip, &xfs_name_dotdot, - target_dp->i_ino, - &first_block, &dfops, spaceres); + target_dp->i_ino, &first_block, + spaceres);ASSERT (error != -EEXIST );if (error) goto out_bmap_cancel;@@ -3168,10 +3164,10 @@ xfs_rename(*/ if (wip) { error =xfs_dir_replace (tp, src_dp, src_name, wip->i_ino, - &first_block, &dfops, spaceres); + &first_block, spaceres); }else error =xfs_dir_removename (tp, src_dp, src_name, src_ip->i_ino, - &first_block, &dfops, spaceres); + &first_block, spaceres);if (error) goto out_bmap_cancel;@@ -3206,7 +3202,7 @@ xfs_rename(if (new_parent)xfs_trans_log_inode (tp, target_dp,XFS_ILOG_CORE ); - error =xfs_finish_rename (tp, &dfops); + error =xfs_finish_rename (tp);if (wip)IRELE (wip);return error;fs/xfs/xfs_symlink.c +1
-1@@ -339,7 +339,7 @@ xfs_symlink(* Create the directory entry for the symlink. */ error =xfs_dir_createname (tp, dp, link_name, ip->i_ino, - &first_block, &dfops, resblks); + &first_block, resblks);if (error) goto out_bmap_cancel;xfs_trans_ichgtime (tp, dp,XFS_ICHGTIME_MOD |XFS_ICHGTIME_CHG );Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 5/24 xfs: use ->t_dfops for recovery of [b|c]ui log items
In reply to Brian FosterLog recovery passes down a central dfops structure to recovery handlers for bui and cui log items. Each of these handlers allocates and commits a transaction and defers any remaining operations to be completed by the main recovery sequence.
Since dfops outlives the transaction in this context, set and clear ->t_dfops appropriately such that the *_finish_item() paths and below (i.e., xfs_bmapi*()) can expect to find the dfops in the transaction without it being committed with the dfops attached. This is required because transaction commit expects that an associated dfops is finished and in this context the dfops may be populated at commit time.
--- fs/xfs/xfs_bmap_item.c | 3 +++ fs/xfs/xfs_refcount_item.c | 3 +++ 2 files changed, 6 insertions(+)
fs/xfs/xfs_bmap_item.c +3 -0
@@ -441,6 +441,7 @@ xfs_bui_recover( XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK), 0, 0, &tp);if (error)return error; + tp->t_dfops = dfops; budp =xfs_trans_get_bud (tp, buip);/* Grab the inode. */
@@ -487,6 +488,7 @@ xfs_bui_recover( }set_bit (XFS_BUI_RECOVERED , &buip->bui_flags); + tp->t_dfops =NULL ; error =xfs_trans_commit (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL );IRELE (ip);
@@ -494,6 +496,7 @@ xfs_bui_recover(return error; err_inode: + tp->t_dfops =NULL ;xfs_trans_cancel (tp);if (ip) {xfs_iunlock (ip,XFS_ILOCK_EXCL );
fs/xfs/xfs_refcount_item.c +3 -0
@@ -452,6 +452,7 @@ xfs_cui_recover( mp->m_refc_maxlevels * 2, 0, XFS_TRANS_RESERVE, &tp);if (error)return error; + tp->t_dfops = dfops; cudp =xfs_trans_get_cud (tp, cuip);for (i =0 ; i < cuip->cui_format.cui_nextents; i++) {
@@ -514,11 +515,13 @@ xfs_cui_recover(xfs_refcount_finish_one_cleanup (tp, rcur, error);set_bit (XFS_CUI_RECOVERED , &cuip->cui_flags); + tp->t_dfops =NULL ; error =xfs_trans_commit (tp);return error; abort_error:xfs_refcount_finish_one_cleanup (tp, rcur, error); + tp->t_dfops =NULL ;xfs_trans_cancel (tp);return error; }
Signature · 1 line
2.17.1
Re: [PATCH 05/24] xfs: use ->t_dfops for recovery of [b|c]ui log items
Quoted 5 lines · Brian Foster
Log recovery passes down a central dfops structure to recovery handlers for bui and cui log items. Each of these handlers allocates and commits a transaction and defers any remaining operations to be completed by the main recovery sequence.
Quoted 7 lines
Since dfops outlives the transaction in this context, set and clear ->t_dfops appropriately such that the
*_finish_item()paths and below (i.e., xfs_bmapi*()) can expect to find the dfops in the transaction without it being committed with the dfops attached. This is required because transaction commit expects that an associated dfops is finished and in this context the dfops may be populated at commit time.
Do we want comments explaining this in the code?
Otherwise looks fine:
Re: [PATCH 05/24] xfs: use ->t_dfops for recovery of [b|c]ui log items
Quoted 14 lines · Christoph Hellwig
Quoted 5 lines · Brian Foster
Log recovery passes down a central dfops structure to recovery handlers for bui and cui log items. Each of these handlers allocates and commits a transaction and defers any remaining operations to be completed by the main recovery sequence.
Quoted 7 lines
Since dfops outlives the transaction in this context, set and clear ->t_dfops appropriately such that the
*_finish_item()paths and below (i.e., xfs_bmapi*()) can expect to find the dfops in the transaction without it being committed with the dfops attached. This is required because transaction commit expects that an associated dfops is finished and in this context the dfops may be populated at commit time.
Quoted 2 lines
Do we want comments explaining this in the code?
Yeah, I think I meant to do that and just lost track. Thanks.
Brian
Quoted 7 lines
Otherwise looks fine:
Reviewed-by Christoph Hellwig <[email protected]>--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/1 xfs: use ->t_dfops for recovery of [b|c]ui log items
In reply to Brian FosterLog recovery passes down a central dfops structure to recovery handlers for bui and cui log items. Each of these handlers allocates and commits a transaction and defers any remaining operations to be completed by the main recovery sequence.
Since dfops outlives the transaction in this context, set and clear ->t_dfops appropriately such that the *_finish_item() paths and below (i.e., xfs_bmapi*()) can expect to find the dfops in the transaction without it being committed with the dfops attached. This is required because transaction commit expects that an associated dfops is finished and in this context the dfops may be populated at commit time.
---
v2:
- Add comments to explain unique ->t_dfops usage in bui/cui log item recovery.
fs/xfs/xfs_bmap_item.c | 8 ++++++++ fs/xfs/xfs_refcount_item.c | 8 ++++++++ 2 files changed, 16 insertions(+)
fs/xfs/xfs_bmap_item.c +8 -0
@@ -441,6 +441,7 @@ xfs_bui_recover( XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK), 0, 0, &tp);if (error)return error; + tp->t_dfops = dfops; budp =xfs_trans_get_bud (tp, buip);/* Grab the inode. */
@@ -487,6 +488,12 @@ xfs_bui_recover( }set_bit (XFS_BUI_RECOVERED , &buip->bui_flags); +/* +* Recovery finishes all deferred ops once intent processing is +* complete. Reset the trans reference because commit expects a finished +* dfops or none at all. +*/ + tp->t_dfops =NULL ; error =xfs_trans_commit (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL );IRELE (ip);
@@ -494,6 +501,7 @@ xfs_bui_recover(return error; err_inode: + tp->t_dfops =NULL ;xfs_trans_cancel (tp);if (ip) {xfs_iunlock (ip,XFS_ILOCK_EXCL );
fs/xfs/xfs_refcount_item.c +8 -0
@@ -452,6 +452,7 @@ xfs_cui_recover( mp->m_refc_maxlevels * 2, 0, XFS_TRANS_RESERVE, &tp);if (error)return error; + tp->t_dfops = dfops; cudp =xfs_trans_get_cud (tp, cuip);for (i =0 ; i < cuip->cui_format.cui_nextents; i++) {
@@ -514,11 +515,18 @@ xfs_cui_recover(xfs_refcount_finish_one_cleanup (tp, rcur, error);set_bit (XFS_CUI_RECOVERED , &cuip->cui_flags); +/* +* Recovery finishes all deferred ops once intent processing is +* complete. Reset the trans reference because commit expects a finished +* dfops or none at all. +*/ + tp->t_dfops =NULL ; error =xfs_trans_commit (tp);return error; abort_error:xfs_refcount_finish_one_cleanup (tp, rcur, error); + tp->t_dfops =NULL ;xfs_trans_cancel (tp);return error; }
Signature · 1 line
2.17.1
Re: [PATCH v2] xfs: use ->t_dfops for recovery of [b|c]ui log items
Quoted 15 lines · Brian Foster
Log recovery passes down a central dfops structure to recovery handlers for bui and cui log items. Each of these handlers allocates and commits a transaction and defers any remaining operations to be completed by the main recovery sequence.
Since dfops outlives the transaction in this context, set and clear ->t_dfops appropriately such that the
*_finish_item()paths and below (i.e., xfs_bmapi*()) can expect to find the dfops in the transaction without it being committed with the dfops attached. This is required because transaction commit expects that an associated dfops is finished and in this context the dfops may be populated at commit time.Signed-off-by Brian Foster <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>
Quoted 8 lines
---
v2:
- Add comments to explain unique ->t_dfops usage in bui/cui log item recovery.fs/xfs/xfs_bmap_item.c | 8 ++++++++ fs/xfs/xfs_refcount_item.c | 8 ++++++++
General note: realtime rmap (being rooted in an inode) log item replay can generate further dfops, so I'll have to wire that up when I pass the log recovery dfops collector into xfs_rui_recover, and I'll have to remember to attach it to the transaction when I do that.
Otherwise I think this is fine,
--D
Quoted 73 lines
2 files changed, 16 insertions(+)fs/xfs/xfs_bmap_item.c +8
-0@@ -441,6 +441,7 @@ xfs_bui_recover( XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK), 0, 0, &tp);if (error)return error; + tp->t_dfops = dfops; budp =xfs_trans_get_bud (tp, buip);/* Grab the inode. */ @@ -487,6 +488,12 @@ xfs_bui_recover( }set_bit (XFS_BUI_RECOVERED , &buip->bui_flags); +/* +* Recovery finishes all deferred ops once intent processing is +* complete. Reset the trans reference because commit expects a finished +* dfops or none at all. +*/ + tp->t_dfops =NULL ; error =xfs_trans_commit (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL );IRELE (ip);@@ -494,6 +501,7 @@ xfs_bui_recover(return error; err_inode: + tp->t_dfops =NULL ;xfs_trans_cancel (tp);if (ip) {xfs_iunlock (ip,XFS_ILOCK_EXCL );fs/xfs/xfs_refcount_item.c +8
-0@@ -452,6 +452,7 @@ xfs_cui_recover( mp->m_refc_maxlevels * 2, 0, XFS_TRANS_RESERVE, &tp);if (error)return error; + tp->t_dfops = dfops; cudp =xfs_trans_get_cud (tp, cuip);for (i =0 ; i < cuip->cui_format.cui_nextents; i++) {@@ -514,11 +515,18 @@ xfs_cui_recover(xfs_refcount_finish_one_cleanup (tp, rcur, error);set_bit (XFS_CUI_RECOVERED , &cuip->cui_flags); +/* +* Recovery finishes all deferred ops once intent processing is +* complete. Reset the trans reference because commit expects a finished +* dfops or none at all. +*/ + tp->t_dfops =NULL ; error =xfs_trans_commit (tp);return error; abort_error:xfs_refcount_finish_one_cleanup (tp, rcur, error); + tp->t_dfops =NULL ;xfs_trans_cancel (tp);return error; }Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] xfs: use ->t_dfops for recovery of [b|c]ui log items
Quoted 22 lines · Darrick J. Wong
Quoted 21 lines · Brian Foster
Log recovery passes down a central dfops structure to recovery handlers for bui and cui log items. Each of these handlers allocates and commits a transaction and defers any remaining operations to be completed by the main recovery sequence.
Since dfops outlives the transaction in this context, set and clear ->t_dfops appropriately such that the
*_finish_item()paths and below (i.e., xfs_bmapi*()) can expect to find the dfops in the transaction without it being committed with the dfops attached. This is required because transaction commit expects that an associated dfops is finished and in this context the dfops may be populated at commit time.Signed-off-by Brian Foster <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>---
v2:
- Add comments to explain unique ->t_dfops usage in bui/cui log item recovery.
Quoted 8 lines
Quoted 2 lines
fs/xfs/xfs_bmap_item.c | 8 ++++++++ fs/xfs/xfs_refcount_item.c | 8 ++++++++General note: realtime rmap (being rooted in an inode) log item replay can generate further dfops, so I'll have to wire that up when I pass the log recovery dfops collector into
xfs_rui_recover, and I'll have to remember to attach it to the transaction when I do that.
Ok. I'm hoping that a last step to embed ->t_dfops directly in the transaction may clean up this ugly set/unset pattern a bit. What I'm thinking is that a transaction roll would end up having to transfer (splice) the pending dfops items from the current ->t_dfops to the new one rather than simply copy the pointer. Some of the dfops code has to become a bit more transaction centric to make sure we don't lose the dfops pointer, but otherwise if we factor that into a little helper I think that means these recovery functions would just have to do something like:
xfs_defer_move(&tp->t_dfops, dfops);
... before committing tp to collect all the deferred items in the dfops from the caller. Otherwise, the transaction commit would actually run xfs_defer_finish() itself if the associated dfops has pending work. I haven't really dug into that yet, though, so there may be more issues to consider (thoughts appreciated, if that triggers any for you).
Brian
Quoted 78 lines
Otherwise I think this is fine,
Reviewed-by Darrick J. Wong <[email protected]>--D
Quoted 73 lines
2 files changed, 16 insertions(+)fs/xfs/xfs_bmap_item.c +8
-0@@ -441,6 +441,7 @@ xfs_bui_recover( XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK), 0, 0, &tp);if (error)return error; + tp->t_dfops = dfops; budp =xfs_trans_get_bud (tp, buip);/* Grab the inode. */ @@ -487,6 +488,12 @@ xfs_bui_recover( }set_bit (XFS_BUI_RECOVERED , &buip->bui_flags); +/* +* Recovery finishes all deferred ops once intent processing is +* complete. Reset the trans reference because commit expects a finished +* dfops or none at all. +*/ + tp->t_dfops =NULL ; error =xfs_trans_commit (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL );IRELE (ip);@@ -494,6 +501,7 @@ xfs_bui_recover(return error; err_inode: + tp->t_dfops =NULL ;xfs_trans_cancel (tp);if (ip) {xfs_iunlock (ip,XFS_ILOCK_EXCL );fs/xfs/xfs_refcount_item.c +8
-0@@ -452,6 +452,7 @@ xfs_cui_recover( mp->m_refc_maxlevels * 2, 0, XFS_TRANS_RESERVE, &tp);if (error)return error; + tp->t_dfops = dfops; cudp =xfs_trans_get_cud (tp, cuip);for (i =0 ; i < cuip->cui_format.cui_nextents; i++) {@@ -514,11 +515,18 @@ xfs_cui_recover(xfs_refcount_finish_one_cleanup (tp, rcur, error);set_bit (XFS_CUI_RECOVERED , &cuip->cui_flags); +/* +* Recovery finishes all deferred ops once intent processing is +* complete. Reset the trans reference because commit expects a finished +* dfops or none at all. +*/ + tp->t_dfops =NULL ; error =xfs_trans_commit (tp);return error; abort_error:xfs_refcount_finish_one_cleanup (tp, rcur, error); + tp->t_dfops =NULL ;xfs_trans_cancel (tp);return error; }Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] xfs: use ->t_dfops for recovery of [b|c]ui log items
Quoted 42 lines · Brian Foster
Quoted 22 lines · Darrick J. Wong
Quoted 21 lines · Brian Foster
Log recovery passes down a central dfops structure to recovery handlers for bui and cui log items. Each of these handlers allocates and commits a transaction and defers any remaining operations to be completed by the main recovery sequence.
Since dfops outlives the transaction in this context, set and clear ->t_dfops appropriately such that the
*_finish_item()paths and below (i.e., xfs_bmapi*()) can expect to find the dfops in the transaction without it being committed with the dfops attached. This is required because transaction commit expects that an associated dfops is finished and in this context the dfops may be populated at commit time.Signed-off-by Brian Foster <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>---
v2:
- Add comments to explain unique ->t_dfops usage in bui/cui log item recovery.Quoted 8 lines
Quoted 2 lines
fs/xfs/xfs_bmap_item.c | 8 ++++++++ fs/xfs/xfs_refcount_item.c | 8 ++++++++General note: realtime rmap (being rooted in an inode) log item replay can generate further dfops, so I'll have to wire that up when I pass the log recovery dfops collector into
xfs_rui_recover, and I'll have to remember to attach it to the transaction when I do that.Ok. I'm hoping that a last step to embed ->t_dfops directly in the transaction may clean up this ugly set/unset pattern a bit. What I'm thinking is that a transaction roll would end up having to transfer (splice) the pending dfops items from the current ->t_dfops to the new one rather than simply copy the pointer. Some of the dfops code has to become a bit more transaction centric to make sure we don't lose the dfops pointer, but otherwise if we factor that into a little helper I think that means these recovery functions would just have to do something like:
Quoted 7 lines
xfs_defer_move(&tp->t_dfops, dfops);... before committing tp to collect all the deferred items in the dfops from the caller. Otherwise, the transaction commit would actually run
xfs_defer_finish()itself if the associated dfops has pending work. I haven't really dug into that yet, though, so there may be more issues to consider (thoughts appreciated, if that triggers any for you).
I think that would work fine, and it would make it more obvious that log recovery defers finishing all the new dfops until after we're done recovering, as opposed to just NULLing out t_dfops.
(Not sure what you call that though, dfdfops? :P)
--D
Quoted 84 lines
Brian
Quoted 74 lines
Otherwise I think this is fine,
Reviewed-by Darrick J. Wong <[email protected]>--D
Quoted 69 lines
2 files changed, 16 insertions(+)fs/xfs/xfs_bmap_item.c +8
-0@@ -441,6 +441,7 @@ xfs_bui_recover( XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK), 0, 0, &tp);if (error)return error; + tp->t_dfops = dfops; budp =xfs_trans_get_bud (tp, buip);/* Grab the inode. */ @@ -487,6 +488,12 @@ xfs_bui_recover( }set_bit (XFS_BUI_RECOVERED , &buip->bui_flags); +/* +* Recovery finishes all deferred ops once intent processing is +* complete. Reset the trans reference because commit expects a finished +* dfops or none at all. +*/ + tp->t_dfops =NULL ; error =xfs_trans_commit (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL );IRELE (ip);@@ -494,6 +501,7 @@ xfs_bui_recover(return error; err_inode: + tp->t_dfops =NULL ;xfs_trans_cancel (tp);if (ip) {xfs_iunlock (ip,XFS_ILOCK_EXCL );fs/xfs/xfs_refcount_item.c +8
-0@@ -452,6 +452,7 @@ xfs_cui_recover( mp->m_refc_maxlevels * 2, 0, XFS_TRANS_RESERVE, &tp);if (error)return error; + tp->t_dfops = dfops; cudp =xfs_trans_get_cud (tp, cuip);for (i =0 ; i < cuip->cui_format.cui_nextents; i++) {@@ -514,11 +515,18 @@ xfs_cui_recover(xfs_refcount_finish_one_cleanup (tp, rcur, error);set_bit (XFS_CUI_RECOVERED , &cuip->cui_flags); +/* +* Recovery finishes all deferred ops once intent processing is +* complete. Reset the trans reference because commit expects a finished +* dfops or none at all. +*/ + tp->t_dfops =NULL ; error =xfs_trans_commit (tp);return error; abort_error:xfs_refcount_finish_one_cleanup (tp, rcur, error); + tp->t_dfops =NULL ;xfs_trans_cancel (tp);return error; }Signature · 1 line
2.17.1Quoted 4 lines
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 6/24 xfs: use ->t_dfops for attr set/remove operations
In reply to Brian FosterAttach the local dfops to the transaction allocated for xattr add and remove operations. Add an earlier initialization in xfs_attr_remove() to ensure the structure is valid if it remains unused at transaction commit time.
--- fs/xfs/libxfs/xfs_attr.c | 11 +++++++---- fs/xfs/libxfs/xfs_bmap.c | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-)
fs/xfs/libxfs/xfs_attr.c +7 -4
@@ -254,6 +254,8 @@ xfs_attr_set( rsvd ? XFS_TRANS_RESERVE : 0, &args.trans);if (error)return error; +xfs_defer_init (&dfops, &firstblock); + args.trans->t_dfops = &dfops;xfs_ilock (dp,XFS_ILOCK_EXCL ); error = xfs_trans_reserve_quota_nblks(args.trans, dp, args.total, 0,
@@ -315,7 +317,6 @@ xfs_attr_set(* It won't fit in the shortform, transform to a leaf block. * GROT: another possible req'mt for a double-split btree op. */ -xfs_defer_init (args.dfops, args.firstblock); error =xfs_attr_shortform_to_leaf (&args, &leaf_bp);if (error) goto out_defer_cancel;
@@ -325,9 +326,9 @@ xfs_attr_set(* buffer and run into problems with the write verifier. */ xfs_trans_bhold (args.trans, leaf_bp); -xfs_defer_bjoin (args.dfops, leaf_bp); -xfs_defer_ijoin (args.dfops, dp); - error =xfs_defer_finish (&args.trans, args.dfops); +xfs_defer_bjoin (&dfops, leaf_bp); +xfs_defer_ijoin (&dfops, dp); + error =xfs_defer_finish (&args.trans, &dfops);if (error) goto out_defer_cancel;
@@ -429,6 +430,8 @@ xfs_attr_remove( &args.trans);if (error)return error; +xfs_defer_init (&dfops, &firstblock); + args.trans->t_dfops = &dfops;xfs_ilock (dp,XFS_ILOCK_EXCL );/*
fs/xfs/libxfs/xfs_bmap.c +2 -1
@@ -1057,6 +1057,8 @@ xfs_bmap_add_attrfork( rsvd ? XFS_TRANS_RESERVE : 0, &tp);if (error)return error; +xfs_defer_init (&dfops, &firstblock); + tp->t_dfops = &dfops;xfs_ilock (ip,XFS_ILOCK_EXCL ); error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ?
@@ -1104,7 +1106,6 @@ xfs_bmap_add_attrfork( ip->i_afp =kmem_zone_zalloc (xfs_ifork_zone,KM_SLEEP ); ip->i_afp->if_flags =XFS_IFEXTENTS ; logflags =0 ; -xfs_defer_init (&dfops, &firstblock);switch (ip->i_d.di_format) {case XFS_DINODE_FMT_LOCAL : error = xfs_bmap_add_attrfork_local(tp, ip, &firstblock, &dfops,
Signature · 1 line
2.17.1
Re: [PATCH 06/24] xfs: use ->t_dfops for attr set/remove operations
Quoted 4 lines · Brian Foster
Attach the local dfops to the transaction allocated for xattr add and remove operations. Add an earlier initialization in
xfs_attr_remove()to ensure the structure is valid if it remains unused at transaction commit time.
Looks fine:
Re: [PATCH 06/24] xfs: use ->t_dfops for attr set/remove operations
In reply to Brian FosterQuoted 6 lines · Brian Foster
Attach the local dfops to the transaction allocated for xattr add and remove operations. Add an earlier initialization in
xfs_attr_remove()to ensure the structure is valid if it remains unused at transaction commit time.Signed-off-by Brian Foster <[email protected]>
Looks ok,
--D
Quoted 76 lines
--- fs/xfs/libxfs/xfs_attr.c | 11 +++++++---- fs/xfs/libxfs/xfs_bmap.c | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-)fs/xfs/libxfs/xfs_attr.c +7
-4@@ -254,6 +254,8 @@ xfs_attr_set( rsvd ? XFS_TRANS_RESERVE : 0, &args.trans);if (error)return error; +xfs_defer_init (&dfops, &firstblock); + args.trans->t_dfops = &dfops;xfs_ilock (dp,XFS_ILOCK_EXCL ); error = xfs_trans_reserve_quota_nblks(args.trans, dp, args.total, 0,@@ -315,7 +317,6 @@ xfs_attr_set(* It won't fit in the shortform, transform to a leaf block. * GROT: another possible req'mt for a double-split btree op. */ -xfs_defer_init (args.dfops, args.firstblock); error =xfs_attr_shortform_to_leaf (&args, &leaf_bp);if (error) goto out_defer_cancel;@@ -325,9 +326,9 @@ xfs_attr_set(* buffer and run into problems with the write verifier. */ xfs_trans_bhold (args.trans, leaf_bp); -xfs_defer_bjoin (args.dfops, leaf_bp); -xfs_defer_ijoin (args.dfops, dp); - error =xfs_defer_finish (&args.trans, args.dfops); +xfs_defer_bjoin (&dfops, leaf_bp); +xfs_defer_ijoin (&dfops, dp); + error =xfs_defer_finish (&args.trans, &dfops);if (error) goto out_defer_cancel;@@ -429,6 +430,8 @@ xfs_attr_remove( &args.trans);if (error)return error; +xfs_defer_init (&dfops, &firstblock); + args.trans->t_dfops = &dfops;xfs_ilock (dp,XFS_ILOCK_EXCL );/* fs/xfs/libxfs/xfs_bmap.c +2
-1@@ -1057,6 +1057,8 @@ xfs_bmap_add_attrfork( rsvd ? XFS_TRANS_RESERVE : 0, &tp);if (error)return error; +xfs_defer_init (&dfops, &firstblock); + tp->t_dfops = &dfops;xfs_ilock (ip,XFS_ILOCK_EXCL ); error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ?@@ -1104,7 +1106,6 @@ xfs_bmap_add_attrfork( ip->i_afp =kmem_zone_zalloc (xfs_ifork_zone,KM_SLEEP ); ip->i_afp->if_flags =XFS_IFEXTENTS ; logflags =0 ; -xfs_defer_init (&dfops, &firstblock);switch (ip->i_d.di_format) {case XFS_DINODE_FMT_LOCAL : error = xfs_bmap_add_attrfork_local(tp, ip, &firstblock, &dfops,Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 7/24 xfs: remove dfops param in attr fork add path
In reply to Brian FosterNow that the attribute fork add tx carries dfops along with the transaction, it is unnecessary to pass it down the stack. Remove the dfops parameter and access ->t_dfops directly where necessary. This patch does not change behavior.
--- fs/xfs/libxfs/xfs_bmap.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +8 -11
@@ -918,7 +918,6 @@ xfs_bmap_add_attrfork_btree( xfs_trans_t *tp, /* transaction pointer */ xfs_inode_t *ip, /* incore inode pointer */ xfs_fsblock_t *firstblock, /* first block allocated */ - struct xfs_defer_ops *dfops, /* blocks to free at commit */ int *flags) /* inode logging flags */ {xfs_btree_cur_t *cur;/* btree cursor */
@@ -931,7 +930,7 @@ xfs_bmap_add_attrfork_btree( *flags |=XFS_ILOG_DBROOT ; else { cur =xfs_bmbt_init_cursor (mp, tp, ip,XFS_DATA_FORK ); - cur->bc_private.b.dfops = dfops; + cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.firstblock = *firstblock; error =xfs_bmbt_lookup_first (cur, &stat);if (error)
@@ -962,7 +961,6 @@ xfs_bmap_add_attrfork_extents( xfs_trans_t *tp, /* transaction pointer */ xfs_inode_t *ip, /* incore inode pointer */ xfs_fsblock_t *firstblock, /* first block allocated */ - struct xfs_defer_ops *dfops, /* blocks to free at commit */ int *flags) /* inode logging flags */ {xfs_btree_cur_t *cur;/* bmap btree cursor */
@@ -971,7 +969,7 @@ xfs_bmap_add_attrfork_extents(if (ip->i_d.di_nextents *sizeof (xfs_bmbt_rec_t) <=XFS_IFORK_DSIZE (ip))return 0 ; cur =NULL ; - error =xfs_bmap_extents_to_btree (tp, ip, firstblock, dfops, &cur,0 , + error =xfs_bmap_extents_to_btree (tp, ip, firstblock, tp->t_dfops, &cur,0 , flags,XFS_DATA_FORK );if (cur) { cur->bc_private.b.allocated =0 ;
@@ -997,7 +995,6 @@ xfs_bmap_add_attrfork_local( xfs_trans_t *tp, /* transaction pointer */ xfs_inode_t *ip, /* incore inode pointer */ xfs_fsblock_t *firstblock, /* first block allocated */ - struct xfs_defer_ops *dfops, /* blocks to free at commit */ int *flags) /* inode logging flags */ {xfs_da_args_t dargs;/* args for dir/attr code */
@@ -1010,7 +1007,7 @@ xfs_bmap_add_attrfork_local( dargs.geo = ip->i_mount->m_dir_geo; dargs.dp = ip; dargs.firstblock = firstblock; - dargs.dfops = dfops; + dargs.dfops = tp->t_dfops; dargs.total = dargs.geo->fsbcount; dargs.whichfork =XFS_DATA_FORK ; dargs.trans = tp;
@@ -1108,16 +1105,16 @@ xfs_bmap_add_attrfork( logflags =0 ;switch (ip->i_d.di_format) {case XFS_DINODE_FMT_LOCAL : - error =xfs_bmap_add_attrfork_local (tp, ip, &firstblock, &dfops, - &logflags); + error =xfs_bmap_add_attrfork_local (tp, ip, &firstblock, + &logflags);break ;case XFS_DINODE_FMT_EXTENTS : error =xfs_bmap_add_attrfork_extents (tp, ip, &firstblock, - &dfops, &logflags); + &logflags);break ;case XFS_DINODE_FMT_BTREE : - error =xfs_bmap_add_attrfork_btree (tp, ip, &firstblock, &dfops, - &logflags); + error =xfs_bmap_add_attrfork_btree (tp, ip, &firstblock, + &logflags);break ;default : error =0 ;
Signature · 1 line
2.17.1
Re: [PATCH 07/24] xfs: remove dfops param in attr fork add path
Quoted 6 lines · Brian Foster
Now that the attribute fork add tx carries dfops along with the transaction, it is unnecessary to pass it down the stack. Remove the dfops parameter and access ->t_dfops directly where necessary. This patch does not change behavior.
Signed-off-by Brian Foster <[email protected]>
Looks good:
Re: [PATCH 07/24] xfs: remove dfops param in attr fork add path
In reply to Brian FosterQuoted 6 lines · Brian Foster
Now that the attribute fork add tx carries dfops along with the transaction, it is unnecessary to pass it down the stack. Remove the dfops parameter and access ->t_dfops directly where necessary. This patch does not change behavior.
Signed-off-by Brian Foster <[email protected]>
Looks ok,
--D
Quoted 88 lines
--- fs/xfs/libxfs/xfs_bmap.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)fs/xfs/libxfs/xfs_bmap.c +8
-11@@ -918,7 +918,6 @@ xfs_bmap_add_attrfork_btree( xfs_trans_t *tp, /* transaction pointer */ xfs_inode_t *ip, /* incore inode pointer */ xfs_fsblock_t *firstblock, /* first block allocated */ - struct xfs_defer_ops *dfops, /* blocks to free at commit */ int *flags) /* inode logging flags */ {xfs_btree_cur_t *cur;/* btree cursor */ @@ -931,7 +930,7 @@ xfs_bmap_add_attrfork_btree( *flags |=XFS_ILOG_DBROOT ; else { cur =xfs_bmbt_init_cursor (mp, tp, ip,XFS_DATA_FORK ); - cur->bc_private.b.dfops = dfops; + cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.firstblock = *firstblock; error =xfs_bmbt_lookup_first (cur, &stat);if (error)@@ -962,7 +961,6 @@ xfs_bmap_add_attrfork_extents( xfs_trans_t *tp, /* transaction pointer */ xfs_inode_t *ip, /* incore inode pointer */ xfs_fsblock_t *firstblock, /* first block allocated */ - struct xfs_defer_ops *dfops, /* blocks to free at commit */ int *flags) /* inode logging flags */ {xfs_btree_cur_t *cur;/* bmap btree cursor */ @@ -971,7 +969,7 @@ xfs_bmap_add_attrfork_extents(if (ip->i_d.di_nextents *sizeof (xfs_bmbt_rec_t) <=XFS_IFORK_DSIZE (ip))return 0 ; cur =NULL ; - error =xfs_bmap_extents_to_btree (tp, ip, firstblock, dfops, &cur,0 , + error =xfs_bmap_extents_to_btree (tp, ip, firstblock, tp->t_dfops, &cur,0 , flags,XFS_DATA_FORK );if (cur) { cur->bc_private.b.allocated =0 ;@@ -997,7 +995,6 @@ xfs_bmap_add_attrfork_local( xfs_trans_t *tp, /* transaction pointer */ xfs_inode_t *ip, /* incore inode pointer */ xfs_fsblock_t *firstblock, /* first block allocated */ - struct xfs_defer_ops *dfops, /* blocks to free at commit */ int *flags) /* inode logging flags */ {xfs_da_args_t dargs;/* args for dir/attr code */ @@ -1010,7 +1007,7 @@ xfs_bmap_add_attrfork_local( dargs.geo = ip->i_mount->m_dir_geo; dargs.dp = ip; dargs.firstblock = firstblock; - dargs.dfops = dfops; + dargs.dfops = tp->t_dfops; dargs.total = dargs.geo->fsbcount; dargs.whichfork =XFS_DATA_FORK ; dargs.trans = tp;@@ -1108,16 +1105,16 @@ xfs_bmap_add_attrfork( logflags =0 ;switch (ip->i_d.di_format) {case XFS_DINODE_FMT_LOCAL : - error =xfs_bmap_add_attrfork_local (tp, ip, &firstblock, &dfops, - &logflags); + error =xfs_bmap_add_attrfork_local (tp, ip, &firstblock, + &logflags);break ;case XFS_DINODE_FMT_EXTENTS : error =xfs_bmap_add_attrfork_extents (tp, ip, &firstblock, - &dfops, &logflags); + &logflags);break ;case XFS_DINODE_FMT_BTREE : - error =xfs_bmap_add_attrfork_btree (tp, ip, &firstblock, &dfops, - &logflags); + error =xfs_bmap_add_attrfork_btree (tp, ip, &firstblock, + &logflags);break ;default : error =0 ;Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 8/24 xfs: use ->t_dfops in extent split tx and remove param
In reply to Brian FosterAttach the local dfops to ->t_dfops of the extent split transaction. Since this is the only caller of xfs_bmap_split_extent_at(), remove the dfops parameter as well.
--- fs/xfs/libxfs/xfs_bmap.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +6 -7
@@ -5921,8 +5921,7 @@ xfs_bmap_split_extent_at(struct xfs_trans *tp, struct xfs_inode *ip, xfs_fileoff_t split_fsb, - xfs_fsblock_t *firstfsb, - struct xfs_defer_ops *dfops) + xfs_fsblock_t *firstfsb) { int whichfork = XFS_DATA_FORK;struct xfs_btree_cur *cur =NULL ;
@@ -5972,7 +5971,7 @@ xfs_bmap_split_extent_at(if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = *firstfsb; - cur->bc_private.b.dfops = dfops; + cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags =0 ; error =xfs_bmbt_lookup_eq (cur, &got, &i);if (error)
@@ -6016,7 +6015,7 @@ xfs_bmap_split_extent_at(int tmp_logflags;/* partial log flag return val */ ASSERT (cur ==NULL ); - error =xfs_bmap_extents_to_btree (tp, ip, firstfsb, dfops, + error =xfs_bmap_extents_to_btree (tp, ip, firstfsb, tp->t_dfops, &cur,0 , &tmp_logflags, whichfork); logflags |= tmp_logflags; }
@@ -6048,14 +6047,14 @@ xfs_bmap_split_extent( XFS_DIOSTRAT_SPACE_RES(mp, 0), 0, 0, &tp);if (error)return error; +xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops;xfs_ilock (ip,XFS_ILOCK_EXCL );xfs_trans_ijoin (tp, ip,XFS_ILOCK_EXCL ); -xfs_defer_init (&dfops, &firstfsb); - error =xfs_bmap_split_extent_at (tp, ip, split_fsb, - &firstfsb, &dfops); + &firstfsb);if (error) goto out;
Signature · 1 line
2.17.1
Re: [PATCH 08/24] xfs: use ->t_dfops in extent split tx and remove param
Quoted 5 lines · Brian Foster
Attach the local dfops to ->t_dfops of the extent split transaction. Since this is the only caller of
xfs_bmap_split_extent_at(), remove the dfops parameter as well.Signed-off-by Brian Foster <[email protected]>
Looks good,
Re: [PATCH 08/24] xfs: use ->t_dfops in extent split tx and remove param
In reply to Brian FosterQuoted 5 lines · Brian Foster
Attach the local dfops to ->t_dfops of the extent split transaction. Since this is the only caller of
xfs_bmap_split_extent_at(), remove the dfops parameter as well.Signed-off-by Brian Foster <[email protected]>
Looks ok,
--D
Quoted 61 lines
--- fs/xfs/libxfs/xfs_bmap.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)fs/xfs/libxfs/xfs_bmap.c +6
-7@@ -5921,8 +5921,7 @@ xfs_bmap_split_extent_at(struct xfs_trans *tp, struct xfs_inode *ip, xfs_fileoff_t split_fsb, - xfs_fsblock_t *firstfsb, - struct xfs_defer_ops *dfops) + xfs_fsblock_t *firstfsb) { int whichfork = XFS_DATA_FORK;struct xfs_btree_cur *cur =NULL ;@@ -5972,7 +5971,7 @@ xfs_bmap_split_extent_at(if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = *firstfsb; - cur->bc_private.b.dfops = dfops; + cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags =0 ; error =xfs_bmbt_lookup_eq (cur, &got, &i);if (error)@@ -6016,7 +6015,7 @@ xfs_bmap_split_extent_at(int tmp_logflags;/* partial log flag return val */ ASSERT (cur ==NULL ); - error =xfs_bmap_extents_to_btree (tp, ip, firstfsb, dfops, + error =xfs_bmap_extents_to_btree (tp, ip, firstfsb, tp->t_dfops, &cur,0 , &tmp_logflags, whichfork); logflags |= tmp_logflags; }@@ -6048,14 +6047,14 @@ xfs_bmap_split_extent( XFS_DIOSTRAT_SPACE_RES(mp, 0), 0, 0, &tp);if (error)return error; +xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops;xfs_ilock (ip,XFS_ILOCK_EXCL );xfs_trans_ijoin (tp, ip,XFS_ILOCK_EXCL ); -xfs_defer_init (&dfops, &firstfsb); - error =xfs_bmap_split_extent_at (tp, ip, split_fsb, - &firstfsb, &dfops); + &firstfsb);if (error) goto out;Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 9/24 xfs: replace xfs_da_args->dfops accesses with ->t_dfops and remove
In reply to Brian FosterNow 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.
--- 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(-)
fs/xfs/libxfs/xfs_attr.c +53 -50
@@ -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 @@ xfs_attr_leaf_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_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 @@ xfs_attr_node_addname(xfs_da_args_t *args)*/ 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 @@ xfs_attr_node_addname(xfs_da_args_t *args)* 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 @@ xfs_attr_node_addname(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; }
@@ -1040,7 +1042,7 @@ xfs_attr_node_addname(xfs_da_args_t *args)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 @@ xfs_attr_node_addname(xfs_da_args_t *args)* 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 @@ xfs_attr_node_removename(xfs_da_args_t *args)xfs_da_state_free (state);return error; out_defer_cancel: -xfs_defer_cancel (args->dfops); +xfs_defer_cancel (args->trans->t_dfops); goto out; }
fs/xfs/libxfs/xfs_attr_leaf.c +11 -13
@@ -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;
fs/xfs/libxfs/xfs_attr_remote.c +12 -11
@@ -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; }
fs/xfs/libxfs/xfs_bmap.c +0 -1
@@ -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;
fs/xfs/libxfs/xfs_da_btree.c +10 -9
@@ -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 @@ xfs_da3_swap_lastblock(*/ 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 ;
fs/xfs/libxfs/xfs_da_btree.h +0 -1
@@ -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 */
fs/xfs/libxfs/xfs_dir2.c +31 -34
116 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH 09/24] xfs: replace xfs_da_args->dfops accesses with ->t_dfops and remove
Quoted 6 lines · Brian Foster
Now that
xfs_da_args->dfopsis 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 structxfs_da_args.Signed-off-by Brian Foster <[email protected]>
Looks good,
Re: [PATCH 09/24] xfs: replace xfs_da_args->dfops accesses with ->t_dfops and remove
In reply to Brian FosterQuoted 6 lines · Brian Foster
Now that
xfs_da_args->dfopsis 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 structxfs_da_args.Signed-off-by Brian Foster <[email protected]>
Looks ok,
--D
Quoted 604 lines
--- 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(-)fs/xfs/libxfs/xfs_attr.c +53
-50@@ -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 @@ xfs_attr_leaf_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_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 @@ xfs_attr_node_addname(xfs_da_args_t *args)*/ 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 @@ xfs_attr_node_addname(xfs_da_args_t *args)* 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 @@ xfs_attr_node_addname(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; }@@ -1040,7 +1042,7 @@ xfs_attr_node_addname(xfs_da_args_t *args)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 @@ xfs_attr_node_addname(xfs_da_args_t *args)* 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 @@ xfs_attr_node_removename(xfs_da_args_t *args)xfs_da_state_free (state);return error; out_defer_cancel: -xfs_defer_cancel (args->dfops); +xfs_defer_cancel (args->trans->t_dfops); goto out; }fs/xfs/libxfs/xfs_attr_leaf.c +11
-13@@ -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;fs/xfs/libxfs/xfs_attr_remote.c +12
-11@@ -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; }fs/xfs/libxfs/xfs_bmap.c +0
-1@@ -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;fs/xfs/libxfs/xfs_da_btree.c +10
-9@@ -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 @@ xfs_da3_swap_lastblock(*/ 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 ;fs/xfs/libxfs/xfs_da_btree.h +0
-1@@ -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 */ fs/xfs/libxfs/xfs_dir2.c +31
-34@@ -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 */@@ -273,7 +273,6 @@ xfs_dir_createname( args->whichfork =XFS_DATA_FORK ; args->trans = tp;ASSERT (tp->t_dfops || !first); - args->dfops = tp->t_dfops; args->firstblock = first; args->op_flags =XFS_DA_OP_ADDNAME |XFS_DA_OP_OKNOENT ;if (!inum)@@ -416,16 +415,16 @@ xfs_dir_lookup(*/ 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));XFS_STATS_INC (dp->i_mount, xs_dir_remove);@@ -446,7 +445,6 @@ xfs_dir_removename( args->whichfork =XFS_DATA_FORK ; args->trans = tp;ASSERT (tp->t_dfops); - args->dfops = tp->t_dfops;if (dp->i_d.di_format ==XFS_DINODE_FMT_LOCAL ) { rval =xfs_dir2_sf_removename (args);@@ -478,16 +476,16 @@ xfs_dir_removename(*/ 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));@@ -511,7 +509,6 @@ xfs_dir_replace( args->whichfork =XFS_DATA_FORK ; args->trans = tp;ASSERT (tp->t_dfops); - args->dfops = tp->t_dfops;if (dp->i_d.di_format ==XFS_DINODE_FMT_LOCAL ) { rval =xfs_dir2_sf_replace (args);@@ -645,17 +642,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);@@ -666,7 +663,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 Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 10/24 xfs: use ->t_dfops in dqalloc transaction
In reply to Brian Fosterxfs_dquot_disk_alloc() receives a transaction from the caller and passes a local dfops along to xfs_bmapi_write(). If we attach this dfops to the transaction, we have to make sure to clear it before returning to avoid invalid access of stack memory.
Since xfs_qm_dqread_alloc() is the only caller, pull dfops into the caller and attach it to the transaction to eliminate this pattern entirely.
--- fs/xfs/xfs_dquot.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-)
fs/xfs/xfs_dquot.c +20 -14
@@ -286,8 +286,8 @@ xfs_dquot_disk_alloc( struct xfs_buf **bpp) {struct xfs_bmbt_irec map; -struct xfs_defer_ops dfops; -struct xfs_mount *mp = (*tpp)->t_mountp; +struct xfs_trans *tp = *tpp; +struct xfs_mount *mp = tp->t_mountp;struct xfs_buf *bp;struct xfs_inode *quotip =xfs_quota_inode (mp, dqp->dq_flags);xfs_fsblock_t firstblock;
@@ -296,7 +296,8 @@ xfs_dquot_disk_alloc(trace_xfs_dqalloc (dqp); -xfs_defer_init (&dfops, &firstblock); +xfs_defer_init (tp->t_dfops, &firstblock); +xfs_ilock (quotip,XFS_ILOCK_EXCL );if (!xfs_this_quota_on (dqp->q_mount, dqp->dq_flags)) {/*
@@ -308,11 +309,11 @@ xfs_dquot_disk_alloc( }/* Create the block mapping. */ -xfs_trans_ijoin (*tpp, quotip,XFS_ILOCK_EXCL ); - error =xfs_bmapi_write (*tpp, quotip, dqp->q_fileoffset, +xfs_trans_ijoin (tp, quotip,XFS_ILOCK_EXCL ); + error =xfs_bmapi_write (tp, quotip, dqp->q_fileoffset,XFS_DQUOT_CLUSTER_SIZE_FSB ,XFS_BMAPI_METADATA , &firstblock,XFS_QM_DQALLOC_SPACE_RES (mp), - &map, &nmaps, &dfops); + &map, &nmaps, tp->t_dfops);if (error) goto error0;ASSERT (map.br_blockcount ==XFS_DQUOT_CLUSTER_SIZE_FSB );
@@ -326,7 +327,7 @@ xfs_dquot_disk_alloc( dqp->q_blkno =XFS_FSB_TO_DADDR (mp, map.br_startblock);/* now we can just get the buffer (there's nothing to read yet) */ - bp =xfs_trans_get_buf (*tpp, mp->m_ddev_targp, dqp->q_blkno, + bp =xfs_trans_get_buf (tp, mp->m_ddev_targp, dqp->q_blkno, mp->m_quotainfo->qi_dqchunklen,0 );if (!bp) { error = -ENOMEM ;
@@ -338,7 +339,7 @@ xfs_dquot_disk_alloc(* Make a chunk of dquots out of this buffer and log * the entire thing. */ -xfs_qm_init_dquot_blk (*tpp, mp,be32_to_cpu (dqp->q_core.d_id), +xfs_qm_init_dquot_blk (tp, mp,be32_to_cpu (dqp->q_core.d_id), dqp->dq_flags &XFS_DQ_ALLTYPES , bp);xfs_buf_set_ref (bp,XFS_DQUOT_REF );
@@ -364,14 +365,15 @@ xfs_dquot_disk_alloc(* is responsible for unlocking any buffer passed back, either * manually or by committing the transaction. */ -xfs_trans_bhold (*tpp, bp); - error =xfs_defer_bjoin (&dfops, bp); +xfs_trans_bhold (tp, bp); + error =xfs_defer_bjoin (tp->t_dfops, bp);if (error) { -xfs_trans_bhold_release (*tpp, bp); -xfs_trans_brelse (*tpp, bp); +xfs_trans_bhold_release (tp, bp); +xfs_trans_brelse (tp, bp); goto error1; } - error =xfs_defer_finish (tpp, &dfops); + error =xfs_defer_finish (tpp, tp->t_dfops); + tp = *tpp;if (error) {xfs_buf_relse (bp); goto error1;
@@ -380,7 +382,7 @@ xfs_dquot_disk_alloc(return 0 ; error1: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); error0:return error; }
@@ -538,13 +540,17 @@ xfs_qm_dqread_alloc( struct xfs_buf **bpp) {struct xfs_trans *tp; +struct xfs_defer_ops dfops;struct xfs_buf *bp; +xfs_fsblock_t firstblock;int error; error =xfs_trans_alloc (mp, &M_RES (mp)->tr_qm_dqalloc,XFS_QM_DQALLOC_SPACE_RES (mp),0 ,0 , &tp);if (error) goto err; +xfs_defer_init (&dfops, &firstblock); + tp->t_dfops = &dfops; error =xfs_dquot_disk_alloc (&tp, dqp, &bp);if (error)
Signature · 1 line
2.17.1
Re: [PATCH 10/24] xfs: use ->t_dfops in dqalloc transaction
Quoted 10 lines · Brian Foster
xfs_dquot_disk_alloc()receives a transaction from the caller and passes a local dfops along toxfs_bmapi_write(). If we attach this dfops to the transaction, we have to make sure to clear it before returning to avoid invalid access of stack memory.Since
xfs_qm_dqread_alloc()is the only caller, pull dfops into the caller and attach it to the transaction to eliminate this pattern entirely.Signed-off-by Brian Foster <[email protected]>
Looks good,
Re: [PATCH 10/24] xfs: use ->t_dfops in dqalloc transaction
In reply to Brian FosterQuoted 30 lines · Brian Foster
xfs_dquot_disk_alloc()receives a transaction from the caller and passes a local dfops along toxfs_bmapi_write(). If we attach this dfops to the transaction, we have to make sure to clear it before returning to avoid invalid access of stack memory.Since
xfs_qm_dqread_alloc()is the only caller, pull dfops into the caller and attach it to the transaction to eliminate this pattern entirely.Signed-off-by Brian Foster <[email protected]>--- fs/xfs/xfs_dquot.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-)fs/xfs/xfs_dquot.c +2
-2@@ -286,8 +286,8 @@ xfs_dquot_disk_alloc( struct xfs_buf **bpp) {struct xfs_bmbt_irec map; -struct xfs_defer_ops dfops; -struct xfs_mount *mp = (*tpp)->t_mountp; +struct xfs_trans *tp = *tpp; +struct xfs_mount *mp = tp->t_mountp;struct xfs_buf *bp;struct xfs_inode *quotip =xfs_quota_inode (mp, dqp->dq_flags);xfs_fsblock_t firstblock;
fs/xfs/xfs_dquot.c xfs_dquot_disk_alloc( · line 299
Quoted 5 lines
fs/xfs/xfs_dquot.c +1
-1@@ -296,7 +296,8 @@ xfs_dquot_disk_alloc(trace_xfs_dqalloc (dqp); -xfs_defer_init (&dfops, &firstblock); +xfs_defer_init (tp->t_dfops, &firstblock);
Initializing a pointed-to dfops is a little eyebrow-raising because...
Quoted 72 lines
fs/xfs/xfs_dquot.c +14
-11+xfs_ilock (quotip,XFS_ILOCK_EXCL );if (!xfs_this_quota_on (dqp->q_mount, dqp->dq_flags)) {/* @@ -308,11 +309,11 @@ xfs_dquot_disk_alloc( }/* Create the block mapping. */ -xfs_trans_ijoin (*tpp, quotip,XFS_ILOCK_EXCL ); - error =xfs_bmapi_write (*tpp, quotip, dqp->q_fileoffset, +xfs_trans_ijoin (tp, quotip,XFS_ILOCK_EXCL ); + error =xfs_bmapi_write (tp, quotip, dqp->q_fileoffset,XFS_DQUOT_CLUSTER_SIZE_FSB ,XFS_BMAPI_METADATA , &firstblock,XFS_QM_DQALLOC_SPACE_RES (mp), - &map, &nmaps, &dfops); + &map, &nmaps, tp->t_dfops);if (error) goto error0;ASSERT (map.br_blockcount ==XFS_DQUOT_CLUSTER_SIZE_FSB );@@ -326,7 +327,7 @@ xfs_dquot_disk_alloc( dqp->q_blkno =XFS_FSB_TO_DADDR (mp, map.br_startblock);/* now we can just get the buffer (there's nothing to read yet) */ - bp =xfs_trans_get_buf (*tpp, mp->m_ddev_targp, dqp->q_blkno, + bp =xfs_trans_get_buf (tp, mp->m_ddev_targp, dqp->q_blkno, mp->m_quotainfo->qi_dqchunklen,0 );if (!bp) { error = -ENOMEM ;@@ -338,7 +339,7 @@ xfs_dquot_disk_alloc(* Make a chunk of dquots out of this buffer and log * the entire thing. */ -xfs_qm_init_dquot_blk (*tpp, mp,be32_to_cpu (dqp->q_core.d_id), +xfs_qm_init_dquot_blk (tp, mp,be32_to_cpu (dqp->q_core.d_id), dqp->dq_flags &XFS_DQ_ALLTYPES , bp);xfs_buf_set_ref (bp,XFS_DQUOT_REF );@@ -364,14 +365,15 @@ xfs_dquot_disk_alloc(* is responsible for unlocking any buffer passed back, either * manually or by committing the transaction. */ -xfs_trans_bhold (*tpp, bp); - error =xfs_defer_bjoin (&dfops, bp); +xfs_trans_bhold (tp, bp); + error =xfs_defer_bjoin (tp->t_dfops, bp);if (error) { -xfs_trans_bhold_release (*tpp, bp); -xfs_trans_brelse (*tpp, bp); +xfs_trans_bhold_release (tp, bp); +xfs_trans_brelse (tp, bp); goto error1; } - error =xfs_defer_finish (tpp, &dfops); + error =xfs_defer_finish (tpp, tp->t_dfops); + tp = *tpp;if (error) {xfs_buf_relse (bp); goto error1;@@ -380,7 +382,7 @@ xfs_dquot_disk_alloc(return 0 ; error1: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); error0:return error; }@@ -538,13 +540,17 @@ xfs_qm_dqread_alloc( struct xfs_buf **bpp) {struct xfs_trans *tp; +struct xfs_defer_ops dfops;
fs/xfs/xfs_dquot.c xfs_qm_dqread_alloc( · line 553
Quoted 10 lines
fs/xfs/xfs_dquot.c +3
-0struct xfs_buf *bp; +xfs_fsblock_t firstblock;int error; error =xfs_trans_alloc (mp, &M_RES (mp)->tr_qm_dqalloc,XFS_QM_DQALLOC_SPACE_RES (mp),0 ,0 , &tp);if (error) goto err; +xfs_defer_init (&dfops, &firstblock); + tp->t_dfops = &dfops;
...this introduces a double-initialization of dfops since xfs_dquot_disk_alloc now calls xfs_defer_init on tp->t_dfops == dfops.
--D
Quoted 10 lines
fs/xfs/xfs_dquot.c +0
-0error =xfs_dquot_disk_alloc (&tp, dqp, &bp);if (error)Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 10/24] xfs: use ->t_dfops in dqalloc transaction
Quoted 115 lines · Darrick J. Wong
Quoted 30 lines · Brian Foster
xfs_dquot_disk_alloc()receives a transaction from the caller and passes a local dfops along toxfs_bmapi_write(). If we attach this dfops to the transaction, we have to make sure to clear it before returning to avoid invalid access of stack memory.Since
xfs_qm_dqread_alloc()is the only caller, pull dfops into the caller and attach it to the transaction to eliminate this pattern entirely.Signed-off-by Brian Foster <[email protected]>--- fs/xfs/xfs_dquot.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-)fs/xfs/xfs_dquot.c +2
-2@@ -286,8 +286,8 @@ xfs_dquot_disk_alloc( struct xfs_buf **bpp) {struct xfs_bmbt_irec map; -struct xfs_defer_ops dfops; -struct xfs_mount *mp = (*tpp)->t_mountp; +struct xfs_trans *tp = *tpp; +struct xfs_mount *mp = tp->t_mountp;struct xfs_buf *bp;struct xfs_inode *quotip =xfs_quota_inode (mp, dqp->dq_flags);xfs_fsblock_t firstblock;fs/xfs/xfs_dquot.c xfs_dquot_disk_alloc( · line 299
Quoted 5 lines
fs/xfs/xfs_dquot.c +1
-1@@ -296,7 +296,8 @@ xfs_dquot_disk_alloc(trace_xfs_dqalloc (dqp); -xfs_defer_init (&dfops, &firstblock); +xfs_defer_init (tp->t_dfops, &firstblock);Initializing a pointed-to dfops is a little eyebrow-raising because...
Quoted 76 lines
fs/xfs/xfs_dquot.c +15
-11+xfs_ilock (quotip,XFS_ILOCK_EXCL );if (!xfs_this_quota_on (dqp->q_mount, dqp->dq_flags)) {/* @@ -308,11 +309,11 @@ xfs_dquot_disk_alloc( }/* Create the block mapping. */ -xfs_trans_ijoin (*tpp, quotip,XFS_ILOCK_EXCL ); - error =xfs_bmapi_write (*tpp, quotip, dqp->q_fileoffset, +xfs_trans_ijoin (tp, quotip,XFS_ILOCK_EXCL ); + error =xfs_bmapi_write (tp, quotip, dqp->q_fileoffset,XFS_DQUOT_CLUSTER_SIZE_FSB ,XFS_BMAPI_METADATA , &firstblock,XFS_QM_DQALLOC_SPACE_RES (mp), - &map, &nmaps, &dfops); + &map, &nmaps, tp->t_dfops);if (error) goto error0;ASSERT (map.br_blockcount ==XFS_DQUOT_CLUSTER_SIZE_FSB );@@ -326,7 +327,7 @@ xfs_dquot_disk_alloc( dqp->q_blkno =XFS_FSB_TO_DADDR (mp, map.br_startblock);/* now we can just get the buffer (there's nothing to read yet) */ - bp =xfs_trans_get_buf (*tpp, mp->m_ddev_targp, dqp->q_blkno, + bp =xfs_trans_get_buf (tp, mp->m_ddev_targp, dqp->q_blkno, mp->m_quotainfo->qi_dqchunklen,0 );if (!bp) { error = -ENOMEM ;@@ -338,7 +339,7 @@ xfs_dquot_disk_alloc(* Make a chunk of dquots out of this buffer and log * the entire thing. */ -xfs_qm_init_dquot_blk (*tpp, mp,be32_to_cpu (dqp->q_core.d_id), +xfs_qm_init_dquot_blk (tp, mp,be32_to_cpu (dqp->q_core.d_id), dqp->dq_flags &XFS_DQ_ALLTYPES , bp);xfs_buf_set_ref (bp,XFS_DQUOT_REF );@@ -364,14 +365,15 @@ xfs_dquot_disk_alloc(* is responsible for unlocking any buffer passed back, either * manually or by committing the transaction. */ -xfs_trans_bhold (*tpp, bp); - error =xfs_defer_bjoin (&dfops, bp); +xfs_trans_bhold (tp, bp); + error =xfs_defer_bjoin (tp->t_dfops, bp);if (error) { -xfs_trans_bhold_release (*tpp, bp); -xfs_trans_brelse (*tpp, bp); +xfs_trans_bhold_release (tp, bp); +xfs_trans_brelse (tp, bp); goto error1; } - error =xfs_defer_finish (tpp, &dfops); + error =xfs_defer_finish (tpp, tp->t_dfops); + tp = *tpp;if (error) {xfs_buf_relse (bp); goto error1;@@ -380,7 +382,7 @@ xfs_dquot_disk_alloc(return 0 ; error1: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); error0:return error; }@@ -538,13 +540,17 @@ xfs_qm_dqread_alloc( struct xfs_buf **bpp) {struct xfs_trans *tp; +struct xfs_defer_ops dfops;struct xfs_buf *bp; +xfs_fsblock_t firstblock;int error;
Quoted 10 lines
fs/xfs/xfs_dquot.c xfs_qm_dqread_alloc( · line 553
Quoted 6 lines
fs/xfs/xfs_dquot.c +2
-0error =xfs_trans_alloc (mp, &M_RES (mp)->tr_qm_dqalloc,XFS_QM_DQALLOC_SPACE_RES (mp),0 ,0 , &tp);if (error) goto err; +xfs_defer_init (&dfops, &firstblock); + tp->t_dfops = &dfops;...this introduces a double-initialization of dfops since
xfs_dquot_disk_allocnow callsxfs_defer_initontp->t_dfops== dfops.
Yeah, I noticed that when I added the earlier init. IIRC, I moved the defer_init because wanted to have the dfops init as close to the transaction as possible to facilitate the future changes, but firstblock still lives in this function and requires initialization. I left it as is because it seemed harmless for the time being (I think both calls will ultimately go away). Looking at it again, we could just drop the second defer init and initialize firstblock to NULLFSBLOCK where it's declared.
Brian
Quoted 12 lines
--D
Quoted 10 lines
fs/xfs/xfs_dquot.c +0
-0error =xfs_dquot_disk_alloc (&tp, dqp, &bp);if (error)Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 11/24 xfs: use ->t_dfops for all xfs_bmapi_write() callers
In reply to Brian FosterAttach ->t_dfops for all remaining callers of xfs_bmapi_write(). This prepares the latter to no longer require a separate dfops parameter.
Note that xfs_symlink() already uses ->t_dfops. Fix up the local references for consistency.
--- fs/xfs/xfs_bmap_util.c | 5 +++-- fs/xfs/xfs_iomap.c | 21 ++++++++++++--------- fs/xfs/xfs_reflink.c | 7 ++++--- fs/xfs/xfs_rtalloc.c | 7 ++++--- fs/xfs/xfs_symlink.c | 6 +++--- 5 files changed, 26 insertions(+), 20 deletions(-)
fs/xfs/xfs_bmap_util.c +3 -2
@@ -972,16 +972,17 @@ xfs_alloc_file_space(xfs_trans_ijoin (tp, ip,0 );xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops; error =xfs_bmapi_write (tp, ip, startoffset_fsb, allocatesize_fsb, alloc_type, &firstfsb, - resblks, imapp, &nimaps, &dfops); + resblks, imapp, &nimaps, tp->t_dfops);if (error) goto error0;/* * Complete the transaction */ - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto error0;
fs/xfs/xfs_iomap.c +12 -9
@@ -255,17 +255,18 @@ xfs_iomap_write_direct(* caller gave to us. */ xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops; nimaps =1 ; error =xfs_bmapi_write (tp, ip, offset_fsb, count_fsb, bmapi_flags, &firstfsb, resblks, imap, - &nimaps, &dfops); + &nimaps, tp->t_dfops);if (error) goto out_bmap_cancel;/* * Complete the transaction */ - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel;
@@ -289,7 +290,7 @@ xfs_iomap_write_direct(return error; out_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops);xfs_trans_unreserve_quota_nblks (tp, ip, (long )qblocks,0 , quota_flag); out_trans_cancel:xfs_trans_cancel (tp);
@@ -717,6 +718,7 @@ xfs_iomap_write_allocate(xfs_trans_ijoin (tp, ip,0 );xfs_defer_init (&dfops, &first_block); + tp->t_dfops = &dfops;/* * it is possible that the extents have changed since
@@ -772,11 +774,11 @@ xfs_iomap_write_allocate( error =xfs_bmapi_write (tp, ip, map_start_fsb, count_fsb, flags, &first_block, nres, imap, &nimaps, - &dfops); + tp->t_dfops);if (error) goto trans_cancel; - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto trans_cancel;
@@ -810,7 +812,7 @@ xfs_iomap_write_allocate( } trans_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops);xfs_trans_cancel (tp); error0:xfs_iunlock (ip,XFS_ILOCK_EXCL );
@@ -878,10 +880,11 @@ xfs_iomap_write_unwritten(* Modify the unwritten extent state of the buffer. */ xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops; nimaps =1 ; error =xfs_bmapi_write (tp, ip, offset_fsb, count_fsb,XFS_BMAPI_CONVERT , &firstfsb, resblks, - &imap, &nimaps, &dfops); + &imap, &nimaps, tp->t_dfops);if (error) goto error_on_bmapi_transaction;
@@ -901,7 +904,7 @@ xfs_iomap_write_unwritten(xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE ); } - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto error_on_bmapi_transaction;
@@ -928,7 +931,7 @@ xfs_iomap_write_unwritten(return 0 ; error_on_bmapi_transaction: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops);xfs_trans_cancel (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL );return error;
fs/xfs/xfs_reflink.c +4 -3
@@ -429,19 +429,20 @@ xfs_reflink_allocate_cow(xfs_trans_ijoin (tp, ip,0 );xfs_defer_init (&dfops, &first_block); + tp->t_dfops = &dfops; nimaps =1 ;/* Allocate the entire reservation as unwritten blocks. */ error =xfs_bmapi_write (tp, ip, imap->br_startoff, imap->br_blockcount,XFS_BMAPI_COWFORK |XFS_BMAPI_PREALLOC , &first_block, - resblks, imap, &nimaps, &dfops); + resblks, imap, &nimaps, tp->t_dfops);if (error) goto out_bmap_cancel;xfs_inode_set_cowblocks_tag (ip);/* Finish up. */ - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel;
@@ -458,7 +459,7 @@ xfs_reflink_allocate_cow( convert:return xfs_reflink_convert_cow_extent (ip, imap, offset_fsb, count_fsb); out_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops);xfs_trans_unreserve_quota_nblks (tp, ip, (long )resblks,0 ,XFS_QMOPT_RES_REGBLKS ); out:
fs/xfs/xfs_rtalloc.c +4 -3
@@ -788,13 +788,14 @@ xfs_growfs_rt_alloc(xfs_trans_ijoin (tp, ip,XFS_ILOCK_EXCL );xfs_defer_init (&dfops, &firstblock); + tp->t_dfops = &dfops;/* * Allocate blocks to the bitmap file. */ nmap =1 ; error =xfs_bmapi_write (tp, ip, oblocks, nblocks - oblocks,XFS_BMAPI_METADATA , &firstblock, - resblks, &map, &nmap, &dfops); + resblks, &map, &nmap, tp->t_dfops);if (!error && nmap <1 ) error = -ENOSPC ;if (error)
@@ -802,7 +803,7 @@ xfs_growfs_rt_alloc(/* * Free any blocks freed up in the transaction, then commit. */ - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel; error =xfs_trans_commit (tp);
@@ -855,7 +856,7 @@ xfs_growfs_rt_alloc(return 0 ; out_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out_trans_cancel:xfs_trans_cancel (tp);return error;
fs/xfs/xfs_symlink.c +3 -3
@@ -291,7 +291,7 @@ xfs_symlink( error =xfs_bmapi_write (tp, ip, first_fsb, fs_blocks,XFS_BMAPI_METADATA , &first_block, resblks, - mval, &nmaps, &dfops); + mval, &nmaps, tp->t_dfops);if (error) goto out_bmap_cancel;
@@ -354,7 +354,7 @@ xfs_symlink(xfs_trans_set_sync (tp); } - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel;
@@ -370,7 +370,7 @@ xfs_symlink(return 0 ; out_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out_trans_cancel:xfs_trans_cancel (tp); out_release_inode:
Signature · 1 line
2.17.1
Re: [PATCH 11/24] xfs: use ->t_dfops for all xfs_bmapi_write() callers
Quoted 6 lines · Brian Foster
Attach ->t_dfops for all remaining callers of
xfs_bmapi_write(). This prepares the latter to no longer require a separate dfops parameter.Note that
xfs_symlink()already uses ->t_dfops. Fix up the local references for consistency.
Looks good,
Re: [PATCH 11/24] xfs: use ->t_dfops for all xfs_bmapi_write() callers
In reply to Brian FosterQuoted 8 lines · Brian Foster
Attach ->t_dfops for all remaining callers of
xfs_bmapi_write(). This prepares the latter to no longer require a separate dfops parameter.Note that
xfs_symlink()already uses ->t_dfops. Fix up the local references for consistency.Signed-off-by Brian Foster <[email protected]>
Looks ok, though I'm starting to itch for moving all these _defer_{init,finish,cancel} calls into _trans_{alloc,commit,cancel} so that we can get rid of all the boilerplate code everywhere.
--D
Quoted 240 lines
--- fs/xfs/xfs_bmap_util.c | 5 +++-- fs/xfs/xfs_iomap.c | 21 ++++++++++++--------- fs/xfs/xfs_reflink.c | 7 ++++--- fs/xfs/xfs_rtalloc.c | 7 ++++--- fs/xfs/xfs_symlink.c | 6 +++--- 5 files changed, 26 insertions(+), 20 deletions(-)fs/xfs/xfs_bmap_util.c +3
-2@@ -972,16 +972,17 @@ xfs_alloc_file_space(xfs_trans_ijoin (tp, ip,0 );xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops; error =xfs_bmapi_write (tp, ip, startoffset_fsb, allocatesize_fsb, alloc_type, &firstfsb, - resblks, imapp, &nimaps, &dfops); + resblks, imapp, &nimaps, tp->t_dfops);if (error) goto error0;/* * Complete the transaction */ - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto error0;fs/xfs/xfs_iomap.c +12
-9@@ -255,17 +255,18 @@ xfs_iomap_write_direct(* caller gave to us. */ xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops; nimaps =1 ; error =xfs_bmapi_write (tp, ip, offset_fsb, count_fsb, bmapi_flags, &firstfsb, resblks, imap, - &nimaps, &dfops); + &nimaps, tp->t_dfops);if (error) goto out_bmap_cancel;/* * Complete the transaction */ - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel;@@ -289,7 +290,7 @@ xfs_iomap_write_direct(return error; out_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops);xfs_trans_unreserve_quota_nblks (tp, ip, (long )qblocks,0 , quota_flag); out_trans_cancel:xfs_trans_cancel (tp);@@ -717,6 +718,7 @@ xfs_iomap_write_allocate(xfs_trans_ijoin (tp, ip,0 );xfs_defer_init (&dfops, &first_block); + tp->t_dfops = &dfops;/* * it is possible that the extents have changed since @@ -772,11 +774,11 @@ xfs_iomap_write_allocate( error =xfs_bmapi_write (tp, ip, map_start_fsb, count_fsb, flags, &first_block, nres, imap, &nimaps, - &dfops); + tp->t_dfops);if (error) goto trans_cancel; - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto trans_cancel;@@ -810,7 +812,7 @@ xfs_iomap_write_allocate( } trans_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops);xfs_trans_cancel (tp); error0:xfs_iunlock (ip,XFS_ILOCK_EXCL );@@ -878,10 +880,11 @@ xfs_iomap_write_unwritten(* Modify the unwritten extent state of the buffer. */ xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops; nimaps =1 ; error =xfs_bmapi_write (tp, ip, offset_fsb, count_fsb,XFS_BMAPI_CONVERT , &firstfsb, resblks, - &imap, &nimaps, &dfops); + &imap, &nimaps, tp->t_dfops);if (error) goto error_on_bmapi_transaction;@@ -901,7 +904,7 @@ xfs_iomap_write_unwritten(xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE ); } - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto error_on_bmapi_transaction;@@ -928,7 +931,7 @@ xfs_iomap_write_unwritten(return 0 ; error_on_bmapi_transaction: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops);xfs_trans_cancel (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL );return error;fs/xfs/xfs_reflink.c +4
-3@@ -429,19 +429,20 @@ xfs_reflink_allocate_cow(xfs_trans_ijoin (tp, ip,0 );xfs_defer_init (&dfops, &first_block); + tp->t_dfops = &dfops; nimaps =1 ;/* Allocate the entire reservation as unwritten blocks. */ error =xfs_bmapi_write (tp, ip, imap->br_startoff, imap->br_blockcount,XFS_BMAPI_COWFORK |XFS_BMAPI_PREALLOC , &first_block, - resblks, imap, &nimaps, &dfops); + resblks, imap, &nimaps, tp->t_dfops);if (error) goto out_bmap_cancel;xfs_inode_set_cowblocks_tag (ip);/* Finish up. */ - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel;@@ -458,7 +459,7 @@ xfs_reflink_allocate_cow( convert:return xfs_reflink_convert_cow_extent (ip, imap, offset_fsb, count_fsb); out_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops);xfs_trans_unreserve_quota_nblks (tp, ip, (long )resblks,0 ,XFS_QMOPT_RES_REGBLKS ); out:fs/xfs/xfs_rtalloc.c +4
-3@@ -788,13 +788,14 @@ xfs_growfs_rt_alloc(xfs_trans_ijoin (tp, ip,XFS_ILOCK_EXCL );xfs_defer_init (&dfops, &firstblock); + tp->t_dfops = &dfops;/* * Allocate blocks to the bitmap file. */ nmap =1 ; error =xfs_bmapi_write (tp, ip, oblocks, nblocks - oblocks,XFS_BMAPI_METADATA , &firstblock, - resblks, &map, &nmap, &dfops); + resblks, &map, &nmap, tp->t_dfops);if (!error && nmap <1 ) error = -ENOSPC ;if (error)@@ -802,7 +803,7 @@ xfs_growfs_rt_alloc(/* * Free any blocks freed up in the transaction, then commit. */ - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel; error =xfs_trans_commit (tp);@@ -855,7 +856,7 @@ xfs_growfs_rt_alloc(return 0 ; out_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out_trans_cancel:xfs_trans_cancel (tp);return error;fs/xfs/xfs_symlink.c +3
-3@@ -291,7 +291,7 @@ xfs_symlink( error =xfs_bmapi_write (tp, ip, first_fsb, fs_blocks,XFS_BMAPI_METADATA , &first_block, resblks, - mval, &nmaps, &dfops); + mval, &nmaps, tp->t_dfops);if (error) goto out_bmap_cancel;@@ -354,7 +354,7 @@ xfs_symlink(xfs_trans_set_sync (tp); } - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel;@@ -370,7 +370,7 @@ xfs_symlink(return 0 ; out_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out_trans_cancel:xfs_trans_cancel (tp); out_release_inode:Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 11/24] xfs: use ->t_dfops for all xfs_bmapi_write() callers
Quoted 5 lines · Darrick J. Wong
Quoted 4 lines · Brian Foster
Attach ->t_dfops for all remaining callers of
xfs_bmapi_write(). This prepares the latter to no longer require a separate dfops parameter.
Quoted 9 lines
Quoted 4 lines
Note that
xfs_symlink()already uses ->t_dfops. Fix up the local references for consistency.Signed-off-by Brian Foster <[email protected]>Looks ok, though I'm starting to itch for moving all these _defer_{init,finish,cancel} calls into _trans_{alloc,commit,cancel} so that we can get rid of all the boilerplate code everywhere.
That's the next step after the firstblock fixups. :)
Brian
Quoted 244 lines
Reviewed-by Darrick J. Wong <[email protected]>--D
Quoted 240 lines
--- fs/xfs/xfs_bmap_util.c | 5 +++-- fs/xfs/xfs_iomap.c | 21 ++++++++++++--------- fs/xfs/xfs_reflink.c | 7 ++++--- fs/xfs/xfs_rtalloc.c | 7 ++++--- fs/xfs/xfs_symlink.c | 6 +++--- 5 files changed, 26 insertions(+), 20 deletions(-)fs/xfs/xfs_bmap_util.c +3
-2@@ -972,16 +972,17 @@ xfs_alloc_file_space(xfs_trans_ijoin (tp, ip,0 );xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops; error =xfs_bmapi_write (tp, ip, startoffset_fsb, allocatesize_fsb, alloc_type, &firstfsb, - resblks, imapp, &nimaps, &dfops); + resblks, imapp, &nimaps, tp->t_dfops);if (error) goto error0;/* * Complete the transaction */ - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto error0;fs/xfs/xfs_iomap.c +12
-9@@ -255,17 +255,18 @@ xfs_iomap_write_direct(* caller gave to us. */ xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops; nimaps =1 ; error =xfs_bmapi_write (tp, ip, offset_fsb, count_fsb, bmapi_flags, &firstfsb, resblks, imap, - &nimaps, &dfops); + &nimaps, tp->t_dfops);if (error) goto out_bmap_cancel;/* * Complete the transaction */ - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel;@@ -289,7 +290,7 @@ xfs_iomap_write_direct(return error; out_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops);xfs_trans_unreserve_quota_nblks (tp, ip, (long )qblocks,0 , quota_flag); out_trans_cancel:xfs_trans_cancel (tp);@@ -717,6 +718,7 @@ xfs_iomap_write_allocate(xfs_trans_ijoin (tp, ip,0 );xfs_defer_init (&dfops, &first_block); + tp->t_dfops = &dfops;/* * it is possible that the extents have changed since @@ -772,11 +774,11 @@ xfs_iomap_write_allocate( error =xfs_bmapi_write (tp, ip, map_start_fsb, count_fsb, flags, &first_block, nres, imap, &nimaps, - &dfops); + tp->t_dfops);if (error) goto trans_cancel; - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto trans_cancel;@@ -810,7 +812,7 @@ xfs_iomap_write_allocate( } trans_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops);xfs_trans_cancel (tp); error0:xfs_iunlock (ip,XFS_ILOCK_EXCL );@@ -878,10 +880,11 @@ xfs_iomap_write_unwritten(* Modify the unwritten extent state of the buffer. */ xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops; nimaps =1 ; error =xfs_bmapi_write (tp, ip, offset_fsb, count_fsb,XFS_BMAPI_CONVERT , &firstfsb, resblks, - &imap, &nimaps, &dfops); + &imap, &nimaps, tp->t_dfops);if (error) goto error_on_bmapi_transaction;@@ -901,7 +904,7 @@ xfs_iomap_write_unwritten(xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE ); } - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto error_on_bmapi_transaction;@@ -928,7 +931,7 @@ xfs_iomap_write_unwritten(return 0 ; error_on_bmapi_transaction: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops);xfs_trans_cancel (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL );return error;fs/xfs/xfs_reflink.c +4
-3@@ -429,19 +429,20 @@ xfs_reflink_allocate_cow(xfs_trans_ijoin (tp, ip,0 );xfs_defer_init (&dfops, &first_block); + tp->t_dfops = &dfops; nimaps =1 ;/* Allocate the entire reservation as unwritten blocks. */ error =xfs_bmapi_write (tp, ip, imap->br_startoff, imap->br_blockcount,XFS_BMAPI_COWFORK |XFS_BMAPI_PREALLOC , &first_block, - resblks, imap, &nimaps, &dfops); + resblks, imap, &nimaps, tp->t_dfops);if (error) goto out_bmap_cancel;xfs_inode_set_cowblocks_tag (ip);/* Finish up. */ - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel;@@ -458,7 +459,7 @@ xfs_reflink_allocate_cow( convert:return xfs_reflink_convert_cow_extent (ip, imap, offset_fsb, count_fsb); out_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops);xfs_trans_unreserve_quota_nblks (tp, ip, (long )resblks,0 ,XFS_QMOPT_RES_REGBLKS ); out:fs/xfs/xfs_rtalloc.c +4
-3@@ -788,13 +788,14 @@ xfs_growfs_rt_alloc(xfs_trans_ijoin (tp, ip,XFS_ILOCK_EXCL );xfs_defer_init (&dfops, &firstblock); + tp->t_dfops = &dfops;/* * Allocate blocks to the bitmap file. */ nmap =1 ; error =xfs_bmapi_write (tp, ip, oblocks, nblocks - oblocks,XFS_BMAPI_METADATA , &firstblock, - resblks, &map, &nmap, &dfops); + resblks, &map, &nmap, tp->t_dfops);if (!error && nmap <1 ) error = -ENOSPC ;if (error)@@ -802,7 +803,7 @@ xfs_growfs_rt_alloc(/* * Free any blocks freed up in the transaction, then commit. */ - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel; error =xfs_trans_commit (tp);@@ -855,7 +856,7 @@ xfs_growfs_rt_alloc(return 0 ; out_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out_trans_cancel:xfs_trans_cancel (tp);return error;fs/xfs/xfs_symlink.c +3
-3@@ -291,7 +291,7 @@ xfs_symlink( error =xfs_bmapi_write (tp, ip, first_fsb, fs_blocks,XFS_BMAPI_METADATA , &first_block, resblks, - mval, &nmaps, &dfops); + mval, &nmaps, tp->t_dfops);if (error) goto out_bmap_cancel;@@ -354,7 +354,7 @@ xfs_symlink(xfs_trans_set_sync (tp); } - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel;@@ -370,7 +370,7 @@ xfs_symlink(return 0 ; out_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out_trans_cancel:xfs_trans_cancel (tp); out_release_inode:Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 12/24 xfs: remove xfs_bmapi_write() dfops param
In reply to Brian FosterNow that all callers use ->t_dfops, the xfs_bmapi_write() dfops parameter is no longer necessary. Remove it and access ->t_dfops directly. This patch does not change behavior.
--- fs/xfs/libxfs/xfs_attr_remote.c | 3 +-- fs/xfs/libxfs/xfs_bmap.c | 10 +++++----- fs/xfs/libxfs/xfs_bmap.h | 3 +-- fs/xfs/libxfs/xfs_da_btree.c | 6 ++---- fs/xfs/xfs_bmap_util.c | 2 +- fs/xfs/xfs_dquot.c | 2 +- fs/xfs/xfs_iomap.c | 7 +++---- fs/xfs/xfs_reflink.c | 8 ++++---- fs/xfs/xfs_rtalloc.c | 2 +- fs/xfs/xfs_symlink.c | 2 +- 10 files changed, 20 insertions(+), 25 deletions(-)
fs/xfs/libxfs/xfs_attr_remote.c +1 -2
@@ -484,8 +484,7 @@ xfs_attr_rmtval_set( nmap =1 ; error =xfs_bmapi_write (args->trans, dp, (xfs_fileoff_t )lblkno, blkcnt,XFS_BMAPI_ATTRFORK , args->firstblock, - args->total, &map, &nmap, - args->trans->t_dfops); + args->total, &map, &nmap);if (error) goto out_defer_cancel;xfs_defer_ijoin (args->trans->t_dfops, dp);
fs/xfs/libxfs/xfs_bmap.c +5 -5
@@ -4246,8 +4246,7 @@ xfs_bmapi_write(controls a.g. for allocs */ xfs_extlen_t total,/* total blocks needed */ struct xfs_bmbt_irec *mval, /* output: map values */ - int *nmap, /* i/o: mval size/count */ - struct xfs_defer_ops *dfops) /* i/o: list extents to free */ + int *nmap) /* i/o: mval size/count */ { struct xfs_mount *mp = ip->i_mount;struct xfs_ifork *ifp;
@@ -4339,7 +4338,7 @@ xfs_bmapi_write( bma.ip = ip; bma.total = total; bma.datatype =0 ; - bma.dfops = dfops; + bma.dfops = tp ? tp->t_dfops :NULL ; bma.firstblock = firstblock;while (bno < end && n < *nmap) {
@@ -4416,8 +4415,9 @@ xfs_bmapi_write(* the refcount btree for orphan recovery. */ if (whichfork ==XFS_COW_FORK ) { - error =xfs_refcount_alloc_cow_extent (mp, dfops, - bma.blkno, bma.length); + error =xfs_refcount_alloc_cow_extent (mp, + tp->t_dfops, bma.blkno, + bma.length);if (error) goto error0; }
fs/xfs/libxfs/xfs_bmap.h +1 -2
@@ -206,8 +206,7 @@ int xfs_bmapi_read(struct xfs_inode *ip, xfs_fileoff_t bno,int xfs_bmapi_write (struct xfs_trans *tp,struct xfs_inode *ip,xfs_fileoff_t bno,xfs_filblks_t len,int flags,xfs_fsblock_t *firstblock,xfs_extlen_t total, -struct xfs_bmbt_irec *mval,int *nmap, -struct xfs_defer_ops *dfops); +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,
fs/xfs/libxfs/xfs_da_btree.c +2 -4
@@ -2062,8 +2062,7 @@ xfs_da_grow_inode_int(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, - args->trans->t_dfops); + args->firstblock, args->total, &map, &nmap);if (error)return error;
@@ -2086,8 +2085,7 @@ 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->trans->t_dfops); + &mapp[mapi], &nmap);if (error) goto out_free_map;if (nmap <1 )
fs/xfs/xfs_bmap_util.c +1 -1
@@ -975,7 +975,7 @@ xfs_alloc_file_space( tp->t_dfops = &dfops; error =xfs_bmapi_write (tp, ip, startoffset_fsb, allocatesize_fsb, alloc_type, &firstfsb, - resblks, imapp, &nimaps, tp->t_dfops); + resblks, imapp, &nimaps);if (error) goto error0;
fs/xfs/xfs_dquot.c +1 -1
@@ -313,7 +313,7 @@ xfs_dquot_disk_alloc( error =xfs_bmapi_write (tp, quotip, dqp->q_fileoffset,XFS_DQUOT_CLUSTER_SIZE_FSB ,XFS_BMAPI_METADATA , &firstblock,XFS_QM_DQALLOC_SPACE_RES (mp), - &map, &nmaps, tp->t_dfops); + &map, &nmaps);if (error) goto error0;ASSERT (map.br_blockcount ==XFS_DQUOT_CLUSTER_SIZE_FSB );
fs/xfs/xfs_iomap.c +3 -4
@@ -259,7 +259,7 @@ xfs_iomap_write_direct( nimaps =1 ; error =xfs_bmapi_write (tp, ip, offset_fsb, count_fsb, bmapi_flags, &firstfsb, resblks, imap, - &nimaps, tp->t_dfops); + &nimaps);if (error) goto out_bmap_cancel;
@@ -773,8 +773,7 @@ xfs_iomap_write_allocate(*/ error =xfs_bmapi_write (tp, ip, map_start_fsb, count_fsb, flags, &first_block, - nres, imap, &nimaps, - tp->t_dfops); + nres, imap, &nimaps);if (error) goto trans_cancel;
@@ -884,7 +883,7 @@ xfs_iomap_write_unwritten( nimaps =1 ; error =xfs_bmapi_write (tp, ip, offset_fsb, count_fsb,XFS_BMAPI_CONVERT , &firstfsb, resblks, - &imap, &nimaps, tp->t_dfops); + &imap, &nimaps);if (error) goto error_on_bmapi_transaction;
fs/xfs/xfs_reflink.c +4 -4
@@ -326,7 +326,7 @@ xfs_reflink_convert_cow_extent(return 0 ;return xfs_bmapi_write (NULL , ip, imap->br_startoff, imap->br_blockcount,XFS_BMAPI_COWFORK |XFS_BMAPI_CONVERT , &first_block, -0 , imap, &nimaps,NULL ); +0 , imap, &nimaps); }/* Convert all of the unwritten CoW extents in a file's range to real ones. */
@@ -349,8 +349,8 @@ xfs_reflink_convert_cow(xfs_ilock (ip,XFS_ILOCK_EXCL ); error =xfs_bmapi_write (NULL , ip, offset_fsb, count_fsb,XFS_BMAPI_COWFORK |XFS_BMAPI_CONVERT | -XFS_BMAPI_CONVERT_ONLY , &first_block,0 , &imap, &nimaps, -NULL ); +XFS_BMAPI_CONVERT_ONLY , &first_block,0 , &imap, + &nimaps);xfs_iunlock (ip,XFS_ILOCK_EXCL );return error; }
@@ -435,7 +435,7 @@ xfs_reflink_allocate_cow(/* Allocate the entire reservation as unwritten blocks. */ error =xfs_bmapi_write (tp, ip, imap->br_startoff, imap->br_blockcount,XFS_BMAPI_COWFORK |XFS_BMAPI_PREALLOC , &first_block, - resblks, imap, &nimaps, tp->t_dfops); + resblks, imap, &nimaps);if (error) goto out_bmap_cancel;
fs/xfs/xfs_rtalloc.c +1 -1
@@ -795,7 +795,7 @@ xfs_growfs_rt_alloc( nmap =1 ; error =xfs_bmapi_write (tp, ip, oblocks, nblocks - oblocks,XFS_BMAPI_METADATA , &firstblock, - resblks, &map, &nmap, tp->t_dfops); + resblks, &map, &nmap);if (!error && nmap <1 ) error = -ENOSPC ;if (error)
fs/xfs/xfs_symlink.c +1 -1
@@ -291,7 +291,7 @@ xfs_symlink( error =xfs_bmapi_write (tp, ip, first_fsb, fs_blocks,XFS_BMAPI_METADATA , &first_block, resblks, - mval, &nmaps, tp->t_dfops); + mval, &nmaps);if (error) goto out_bmap_cancel;
Signature · 1 line
2.17.1
Re: [PATCH 12/24] xfs: remove xfs_bmapi_write() dfops param
Quoted 5 lines · Brian Foster
Now that all callers use ->t_dfops, the
xfs_bmapi_write()dfops parameter is no longer necessary. Remove it and access ->t_dfops directly. This patch does not change behavior.Signed-off-by Brian Foster <[email protected]>
Looks good,
Re: [PATCH 12/24] xfs: remove xfs_bmapi_write() dfops param
In reply to Brian FosterQuoted 5 lines · Brian Foster
Now that all callers use ->t_dfops, the
xfs_bmapi_write()dfops parameter is no longer necessary. Remove it and access ->t_dfops directly. This patch does not change behavior.Signed-off-by Brian Foster <[email protected]>
Looks ok,
--D
Quoted 224 lines
--- fs/xfs/libxfs/xfs_attr_remote.c | 3 +-- fs/xfs/libxfs/xfs_bmap.c | 10 +++++----- fs/xfs/libxfs/xfs_bmap.h | 3 +-- fs/xfs/libxfs/xfs_da_btree.c | 6 ++---- fs/xfs/xfs_bmap_util.c | 2 +- fs/xfs/xfs_dquot.c | 2 +- fs/xfs/xfs_iomap.c | 7 +++---- fs/xfs/xfs_reflink.c | 8 ++++---- fs/xfs/xfs_rtalloc.c | 2 +- fs/xfs/xfs_symlink.c | 2 +- 10 files changed, 20 insertions(+), 25 deletions(-)fs/xfs/libxfs/xfs_attr_remote.c +1
-2@@ -484,8 +484,7 @@ xfs_attr_rmtval_set( nmap =1 ; error =xfs_bmapi_write (args->trans, dp, (xfs_fileoff_t )lblkno, blkcnt,XFS_BMAPI_ATTRFORK , args->firstblock, - args->total, &map, &nmap, - args->trans->t_dfops); + args->total, &map, &nmap);if (error) goto out_defer_cancel;xfs_defer_ijoin (args->trans->t_dfops, dp);fs/xfs/libxfs/xfs_bmap.c +5
-5@@ -4246,8 +4246,7 @@ xfs_bmapi_write(controls a.g. for allocs */ xfs_extlen_t total,/* total blocks needed */ struct xfs_bmbt_irec *mval, /* output: map values */ - int *nmap, /* i/o: mval size/count */ - struct xfs_defer_ops *dfops) /* i/o: list extents to free */ + int *nmap) /* i/o: mval size/count */ { struct xfs_mount *mp = ip->i_mount;struct xfs_ifork *ifp;@@ -4339,7 +4338,7 @@ xfs_bmapi_write( bma.ip = ip; bma.total = total; bma.datatype =0 ; - bma.dfops = dfops; + bma.dfops = tp ? tp->t_dfops :NULL ; bma.firstblock = firstblock;while (bno < end && n < *nmap) {@@ -4416,8 +4415,9 @@ xfs_bmapi_write(* the refcount btree for orphan recovery. */ if (whichfork ==XFS_COW_FORK ) { - error =xfs_refcount_alloc_cow_extent (mp, dfops, - bma.blkno, bma.length); + error =xfs_refcount_alloc_cow_extent (mp, + tp->t_dfops, bma.blkno, + bma.length);if (error) goto error0; }fs/xfs/libxfs/xfs_bmap.h +1
-2@@ -206,8 +206,7 @@ int xfs_bmapi_read(struct xfs_inode *ip, xfs_fileoff_t bno,int xfs_bmapi_write (struct xfs_trans *tp,struct xfs_inode *ip,xfs_fileoff_t bno,xfs_filblks_t len,int flags,xfs_fsblock_t *firstblock,xfs_extlen_t total, -struct xfs_bmbt_irec *mval,int *nmap, -struct xfs_defer_ops *dfops); +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,fs/xfs/libxfs/xfs_da_btree.c +2
-4@@ -2062,8 +2062,7 @@ xfs_da_grow_inode_int(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, - args->trans->t_dfops); + args->firstblock, args->total, &map, &nmap);if (error)return error;@@ -2086,8 +2085,7 @@ 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->trans->t_dfops); + &mapp[mapi], &nmap);if (error) goto out_free_map;if (nmap <1 )fs/xfs/xfs_bmap_util.c +1
-1@@ -975,7 +975,7 @@ xfs_alloc_file_space( tp->t_dfops = &dfops; error =xfs_bmapi_write (tp, ip, startoffset_fsb, allocatesize_fsb, alloc_type, &firstfsb, - resblks, imapp, &nimaps, tp->t_dfops); + resblks, imapp, &nimaps);if (error) goto error0;fs/xfs/xfs_dquot.c +1
-1@@ -313,7 +313,7 @@ xfs_dquot_disk_alloc( error =xfs_bmapi_write (tp, quotip, dqp->q_fileoffset,XFS_DQUOT_CLUSTER_SIZE_FSB ,XFS_BMAPI_METADATA , &firstblock,XFS_QM_DQALLOC_SPACE_RES (mp), - &map, &nmaps, tp->t_dfops); + &map, &nmaps);if (error) goto error0;ASSERT (map.br_blockcount ==XFS_DQUOT_CLUSTER_SIZE_FSB );fs/xfs/xfs_iomap.c +3
-4@@ -259,7 +259,7 @@ xfs_iomap_write_direct( nimaps =1 ; error =xfs_bmapi_write (tp, ip, offset_fsb, count_fsb, bmapi_flags, &firstfsb, resblks, imap, - &nimaps, tp->t_dfops); + &nimaps);if (error) goto out_bmap_cancel;@@ -773,8 +773,7 @@ xfs_iomap_write_allocate(*/ error =xfs_bmapi_write (tp, ip, map_start_fsb, count_fsb, flags, &first_block, - nres, imap, &nimaps, - tp->t_dfops); + nres, imap, &nimaps);if (error) goto trans_cancel;@@ -884,7 +883,7 @@ xfs_iomap_write_unwritten( nimaps =1 ; error =xfs_bmapi_write (tp, ip, offset_fsb, count_fsb,XFS_BMAPI_CONVERT , &firstfsb, resblks, - &imap, &nimaps, tp->t_dfops); + &imap, &nimaps);if (error) goto error_on_bmapi_transaction;fs/xfs/xfs_reflink.c +4
-4@@ -326,7 +326,7 @@ xfs_reflink_convert_cow_extent(return 0 ;return xfs_bmapi_write (NULL , ip, imap->br_startoff, imap->br_blockcount,XFS_BMAPI_COWFORK |XFS_BMAPI_CONVERT , &first_block, -0 , imap, &nimaps,NULL ); +0 , imap, &nimaps); }/* Convert all of the unwritten CoW extents in a file's range to real ones. */ @@ -349,8 +349,8 @@ xfs_reflink_convert_cow(xfs_ilock (ip,XFS_ILOCK_EXCL ); error =xfs_bmapi_write (NULL , ip, offset_fsb, count_fsb,XFS_BMAPI_COWFORK |XFS_BMAPI_CONVERT | -XFS_BMAPI_CONVERT_ONLY , &first_block,0 , &imap, &nimaps, -NULL ); +XFS_BMAPI_CONVERT_ONLY , &first_block,0 , &imap, + &nimaps);xfs_iunlock (ip,XFS_ILOCK_EXCL );return error; }@@ -435,7 +435,7 @@ xfs_reflink_allocate_cow(/* Allocate the entire reservation as unwritten blocks. */ error =xfs_bmapi_write (tp, ip, imap->br_startoff, imap->br_blockcount,XFS_BMAPI_COWFORK |XFS_BMAPI_PREALLOC , &first_block, - resblks, imap, &nimaps, tp->t_dfops); + resblks, imap, &nimaps);if (error) goto out_bmap_cancel;fs/xfs/xfs_rtalloc.c +1
-1@@ -795,7 +795,7 @@ xfs_growfs_rt_alloc( nmap =1 ; error =xfs_bmapi_write (tp, ip, oblocks, nblocks - oblocks,XFS_BMAPI_METADATA , &firstblock, - resblks, &map, &nmap, tp->t_dfops); + resblks, &map, &nmap);if (!error && nmap <1 ) error = -ENOSPC ;if (error)fs/xfs/xfs_symlink.c +1
-1@@ -291,7 +291,7 @@ xfs_symlink( error =xfs_bmapi_write (tp, ip, first_fsb, fs_blocks,XFS_BMAPI_METADATA , &first_block, resblks, - mval, &nmaps, tp->t_dfops); + mval, &nmaps);if (error) goto out_bmap_cancel;Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 13/24 xfs: use ->t_dfops for all xfs_bunmapi() callers
In reply to Brian FosterUse ->t_dfops for all remaining xfs_bunmapi() callers. This prepares the latter to no longer require a dfops parameter.
Note that xfs_itruncate_extents_flags() associates a local dfops with a transaction provided from the caller. Since there are multiple callers, set and reset ->t_dfops before the function returns to avoid exposure of stack memory to the caller.
--- fs/xfs/xfs_bmap_util.c | 9 +++++---- fs/xfs/xfs_inode.c | 12 ++++++++---- fs/xfs/xfs_reflink.c | 27 +++++++++++++++------------ fs/xfs/xfs_symlink.c | 9 +++++---- 4 files changed, 33 insertions(+), 24 deletions(-)
fs/xfs/xfs_bmap_util.c +5 -4
@@ -1043,13 +1043,14 @@ xfs_unmap_extent(xfs_trans_ijoin (tp, ip,0 );xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops; error =xfs_bunmapi (tp, ip, startoffset_fsb, len_fsb,0 ,2 , &firstfsb, - &dfops, done); + tp->t_dfops, done);if (error) goto out_bmap_cancel; -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (&tp, &dfops); +xfs_defer_ijoin (tp->t_dfops, ip); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel;
@@ -1059,7 +1060,7 @@ xfs_unmap_extent(return error; out_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out_trans_cancel:xfs_trans_cancel (tp); goto out_unlock;
fs/xfs/xfs_inode.c +8 -4
@@ -1545,6 +1545,7 @@ xfs_itruncate_extents_flags( {struct xfs_mount *mp = ip->i_mount;struct xfs_trans *tp = *tpp; +struct xfs_defer_ops *odfops = tp->t_dfops;struct xfs_defer_ops dfops;xfs_fsblock_t first_block;xfs_fileoff_t first_unmap_block;
@@ -1584,9 +1585,10 @@ xfs_itruncate_extents_flags( unmap_len = last_block - first_unmap_block +1 ;while (!done) {xfs_defer_init (&dfops, &first_block); + tp->t_dfops = &dfops; error =xfs_bunmapi (tp, ip, first_unmap_block, unmap_len, flags,XFS_ITRUNC_MAX_EXTENTS , &first_block, - &dfops, &done); + tp->t_dfops, &done);if (error) goto out_bmap_cancel;
@@ -1594,8 +1596,8 @@ xfs_itruncate_extents_flags(* Duplicate the transaction that has the permanent * reservation and commit the old transaction. */ -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (&tp, &dfops); +xfs_defer_ijoin (tp->t_dfops, ip); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel;
@@ -1623,6 +1625,8 @@ xfs_itruncate_extents_flags(trace_xfs_itruncate_extents_end (ip, new_size); out: +/* ->t_dfops points to local stack, don't leak it! */ + tp->t_dfops = odfops; *tpp = tp;return error; out_bmap_cancel:
@@ -1631,7 +1635,7 @@ xfs_itruncate_extents_flags(* the transaction can be properly aborted. We just need to make sure * we're not holding any resources that we were not when we came in. */ -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); goto out; }
fs/xfs/xfs_reflink.c +15 -12
@@ -763,9 +763,10 @@ xfs_reflink_end_cow(/* Unmap the old blocks in the data fork. */ xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops; rlen = del.br_blockcount; error =__xfs_bunmapi (tp, ip, del.br_startoff, &rlen,0 ,1 , - &firstfsb, &dfops); + &firstfsb, tp->t_dfops);if (error) goto out_defer;
@@ -777,13 +778,14 @@ xfs_reflink_end_cow(trace_xfs_reflink_cow_remap (ip, &del);/* Free the CoW orphan record. */ - error =xfs_refcount_free_cow_extent (tp->t_mountp, &dfops, + error =xfs_refcount_free_cow_extent (tp->t_mountp, tp->t_dfops, del.br_startblock, del.br_blockcount);if (error) goto out_defer;/* Map the new blocks into the data fork. */ - error =xfs_bmap_map_extent (tp->t_mountp, &dfops, ip, &del); + error =xfs_bmap_map_extent (tp->t_mountp, tp->t_dfops, ip, + &del);if (error) goto out_defer;
@@ -794,8 +796,8 @@ xfs_reflink_end_cow(/* Remove the mapping from the CoW fork. */ xfs_bmap_del_extent_cow (ip, &icur, &got, &del); -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (&tp, &dfops); +xfs_defer_ijoin (tp->t_dfops, ip); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_defer;if (!xfs_iext_get_extent (ifp, &icur, &got))
@@ -813,7 +815,7 @@ xfs_reflink_end_cow(return 0 ; out_defer: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out_cancel:xfs_trans_cancel (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL );
@@ -1112,8 +1114,9 @@ xfs_reflink_remap_extent( rlen = unmap_len;while (rlen) {xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops; error =__xfs_bunmapi (tp, ip, destoff, &rlen,0 ,1 , - &firstfsb, &dfops); + &firstfsb, tp->t_dfops);if (error) goto out_defer;
@@ -1134,12 +1137,12 @@ xfs_reflink_remap_extent( uirec.br_blockcount, uirec.br_startblock);/* Update the refcount tree */ - error =xfs_refcount_increase_extent (mp, &dfops, &uirec); + error =xfs_refcount_increase_extent (mp, tp->t_dfops, &uirec);if (error) goto out_defer;/* Map the new blocks into the data fork. */ - error =xfs_bmap_map_extent (mp, &dfops, ip, &uirec); + error =xfs_bmap_map_extent (mp, tp->t_dfops, ip, &uirec);if (error) goto out_defer;
@@ -1160,8 +1163,8 @@ xfs_reflink_remap_extent( next_extent:/* Process all the deferred stuff. */ -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (&tp, &dfops); +xfs_defer_ijoin (tp->t_dfops, ip); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_defer; }
@@ -1173,7 +1176,7 @@ xfs_reflink_remap_extent(return 0 ; out_defer: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out_cancel:xfs_trans_cancel (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL );
fs/xfs/xfs_symlink.c +5 -4
@@ -444,6 +444,7 @@ xfs_inactive_symlink_rmt(*/ done =0 ;xfs_defer_init (&dfops, &first_block); + tp->t_dfops = &dfops; nmaps =ARRAY_SIZE (mval); error =xfs_bmapi_read (ip,0 ,xfs_symlink_blocks (mp, size), mval, &nmaps,0 );
@@ -466,15 +467,15 @@ xfs_inactive_symlink_rmt(* Unmap the dead block(s) to the dfops. */ error =xfs_bunmapi (tp, ip,0 , size,0 , nmaps, - &first_block, &dfops, &done); + &first_block, tp->t_dfops, &done);if (error) goto error_bmap_cancel;ASSERT (done);/* * Commit the first transaction. This logs the EFI and the inode. */ -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (&tp, &dfops); +xfs_defer_ijoin (tp->t_dfops, ip); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto error_bmap_cancel;
@@ -499,7 +500,7 @@ xfs_inactive_symlink_rmt(return 0 ; error_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); error_trans_cancel:xfs_trans_cancel (tp); error_unlock:
Signature · 1 line
2.17.1
Re: [PATCH 13/24] xfs: use ->t_dfops for all xfs_bunmapi() callers
Quoted 9 lines · Brian Foster
Use ->t_dfops for all remaining
xfs_bunmapi()callers. This prepares the latter to no longer require a dfops parameter.Note that
xfs_itruncate_extents_flags()associates a local dfops with a transaction provided from the caller. Since there are multiple callers, set and reset ->t_dfops before the function returns to avoid exposure of stack memory to the caller.Signed-off-by Brian Foster <[email protected]>
Looks good,
Re: [PATCH 13/24] xfs: use ->t_dfops for all xfs_bunmapi() callers
In reply to Brian FosterQuoted 52 lines · Brian Foster
Use ->t_dfops for all remaining
xfs_bunmapi()callers. This prepares the latter to no longer require a dfops parameter.Note that
xfs_itruncate_extents_flags()associates a local dfops with a transaction provided from the caller. Since there are multiple callers, set and reset ->t_dfops before the function returns to avoid exposure of stack memory to the caller.Signed-off-by Brian Foster <[email protected]>--- fs/xfs/xfs_bmap_util.c | 9 +++++---- fs/xfs/xfs_inode.c | 12 ++++++++---- fs/xfs/xfs_reflink.c | 27 +++++++++++++++------------ fs/xfs/xfs_symlink.c | 9 +++++---- 4 files changed, 33 insertions(+), 24 deletions(-)fs/xfs/xfs_bmap_util.c +5
-4@@ -1043,13 +1043,14 @@ xfs_unmap_extent(xfs_trans_ijoin (tp, ip,0 );xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops; error =xfs_bunmapi (tp, ip, startoffset_fsb, len_fsb,0 ,2 , &firstfsb, - &dfops, done); + tp->t_dfops, done);if (error) goto out_bmap_cancel; -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (&tp, &dfops); +xfs_defer_ijoin (tp->t_dfops, ip); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel;@@ -1059,7 +1060,7 @@ xfs_unmap_extent(return error; out_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out_trans_cancel:xfs_trans_cancel (tp); goto out_unlock;fs/xfs/xfs_inode.c +0
-0
fs/xfs/xfs_inode.c xfs_itruncate_extents_flags( · line 1548
Quoted 4 lines
fs/xfs/xfs_inode.c +1
-0@@ -1545,6 +1545,7 @@ xfs_itruncate_extents_flags( {struct xfs_mount *mp = ip->i_mount;struct xfs_trans *tp = *tpp; +struct xfs_defer_ops *odfops = tp->t_dfops;
old_dfops?
fs/xfs/xfs_inode.c xfs_itruncate_extents_flags( · line 1588
Quoted 8 lines
fs/xfs/xfs_inode.c +1
-0struct xfs_defer_ops dfops;xfs_fsblock_t first_block;xfs_fileoff_t first_unmap_block;@@ -1584,9 +1585,10 @@ xfs_itruncate_extents_flags( unmap_len = last_block - first_unmap_block +1 ;while (!done) {xfs_defer_init (&dfops, &first_block); + tp->t_dfops = &dfops;
Why can't we attach the dfops generated by the bunmapi call onto the original t_dfops? I guess it's so that we can drop the defer_ijoin from dfops? It seems odd to be nesting the dfops, since we're no longer completing them in order of oldest to newest.
--D
Quoted 182 lines
fs/xfs/xfs_inode.c +6
-4error =xfs_bunmapi (tp, ip, first_unmap_block, unmap_len, flags,XFS_ITRUNC_MAX_EXTENTS , &first_block, - &dfops, &done); + tp->t_dfops, &done);if (error) goto out_bmap_cancel;@@ -1594,8 +1596,8 @@ xfs_itruncate_extents_flags(* Duplicate the transaction that has the permanent * reservation and commit the old transaction. */ -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (&tp, &dfops); +xfs_defer_ijoin (tp->t_dfops, ip); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel;@@ -1623,6 +1625,8 @@ xfs_itruncate_extents_flags(trace_xfs_itruncate_extents_end (ip, new_size); out: +/* ->t_dfops points to local stack, don't leak it! */ + tp->t_dfops = odfops; *tpp = tp;return error; out_bmap_cancel:@@ -1631,7 +1635,7 @@ xfs_itruncate_extents_flags(* the transaction can be properly aborted. We just need to make sure * we're not holding any resources that we were not when we came in. */ -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); goto out; }fs/xfs/xfs_reflink.c +15
-12@@ -763,9 +763,10 @@ xfs_reflink_end_cow(/* Unmap the old blocks in the data fork. */ xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops; rlen = del.br_blockcount; error =__xfs_bunmapi (tp, ip, del.br_startoff, &rlen,0 ,1 , - &firstfsb, &dfops); + &firstfsb, tp->t_dfops);if (error) goto out_defer;@@ -777,13 +778,14 @@ xfs_reflink_end_cow(trace_xfs_reflink_cow_remap (ip, &del);/* Free the CoW orphan record. */ - error =xfs_refcount_free_cow_extent (tp->t_mountp, &dfops, + error =xfs_refcount_free_cow_extent (tp->t_mountp, tp->t_dfops, del.br_startblock, del.br_blockcount);if (error) goto out_defer;/* Map the new blocks into the data fork. */ - error =xfs_bmap_map_extent (tp->t_mountp, &dfops, ip, &del); + error =xfs_bmap_map_extent (tp->t_mountp, tp->t_dfops, ip, + &del);if (error) goto out_defer;@@ -794,8 +796,8 @@ xfs_reflink_end_cow(/* Remove the mapping from the CoW fork. */ xfs_bmap_del_extent_cow (ip, &icur, &got, &del); -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (&tp, &dfops); +xfs_defer_ijoin (tp->t_dfops, ip); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_defer;if (!xfs_iext_get_extent (ifp, &icur, &got))@@ -813,7 +815,7 @@ xfs_reflink_end_cow(return 0 ; out_defer: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out_cancel:xfs_trans_cancel (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL );@@ -1112,8 +1114,9 @@ xfs_reflink_remap_extent( rlen = unmap_len;while (rlen) {xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops; error =__xfs_bunmapi (tp, ip, destoff, &rlen,0 ,1 , - &firstfsb, &dfops); + &firstfsb, tp->t_dfops);if (error) goto out_defer;@@ -1134,12 +1137,12 @@ xfs_reflink_remap_extent( uirec.br_blockcount, uirec.br_startblock);/* Update the refcount tree */ - error =xfs_refcount_increase_extent (mp, &dfops, &uirec); + error =xfs_refcount_increase_extent (mp, tp->t_dfops, &uirec);if (error) goto out_defer;/* Map the new blocks into the data fork. */ - error =xfs_bmap_map_extent (mp, &dfops, ip, &uirec); + error =xfs_bmap_map_extent (mp, tp->t_dfops, ip, &uirec);if (error) goto out_defer;@@ -1160,8 +1163,8 @@ xfs_reflink_remap_extent( next_extent:/* Process all the deferred stuff. */ -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (&tp, &dfops); +xfs_defer_ijoin (tp->t_dfops, ip); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_defer; }@@ -1173,7 +1176,7 @@ xfs_reflink_remap_extent(return 0 ; out_defer: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out_cancel:xfs_trans_cancel (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL );fs/xfs/xfs_symlink.c +5
-4@@ -444,6 +444,7 @@ xfs_inactive_symlink_rmt(*/ done =0 ;xfs_defer_init (&dfops, &first_block); + tp->t_dfops = &dfops; nmaps =ARRAY_SIZE (mval); error =xfs_bmapi_read (ip,0 ,xfs_symlink_blocks (mp, size), mval, &nmaps,0 );@@ -466,15 +467,15 @@ xfs_inactive_symlink_rmt(* Unmap the dead block(s) to the dfops. */ error =xfs_bunmapi (tp, ip,0 , size,0 , nmaps, - &first_block, &dfops, &done); + &first_block, tp->t_dfops, &done);if (error) goto error_bmap_cancel;ASSERT (done);/* * Commit the first transaction. This logs the EFI and the inode. */ -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (&tp, &dfops); +xfs_defer_ijoin (tp->t_dfops, ip); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto error_bmap_cancel;@@ -499,7 +500,7 @@ xfs_inactive_symlink_rmt(return 0 ; error_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); error_trans_cancel:xfs_trans_cancel (tp); error_unlock:Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 13/24] xfs: use ->t_dfops for all xfs_bunmapi() callers
Quoted 60 lines · Darrick J. Wong
Quoted 52 lines · Brian Foster
Use ->t_dfops for all remaining
xfs_bunmapi()callers. This prepares the latter to no longer require a dfops parameter.Note that
xfs_itruncate_extents_flags()associates a local dfops with a transaction provided from the caller. Since there are multiple callers, set and reset ->t_dfops before the function returns to avoid exposure of stack memory to the caller.Signed-off-by Brian Foster <[email protected]>--- fs/xfs/xfs_bmap_util.c | 9 +++++---- fs/xfs/xfs_inode.c | 12 ++++++++---- fs/xfs/xfs_reflink.c | 27 +++++++++++++++------------ fs/xfs/xfs_symlink.c | 9 +++++---- 4 files changed, 33 insertions(+), 24 deletions(-)fs/xfs/xfs_bmap_util.c +5
-4@@ -1043,13 +1043,14 @@ xfs_unmap_extent(xfs_trans_ijoin (tp, ip,0 );xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops; error =xfs_bunmapi (tp, ip, startoffset_fsb, len_fsb,0 ,2 , &firstfsb, - &dfops, done); + tp->t_dfops, done);if (error) goto out_bmap_cancel; -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (&tp, &dfops); +xfs_defer_ijoin (tp->t_dfops, ip); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel;@@ -1059,7 +1060,7 @@ xfs_unmap_extent(return error; out_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out_trans_cancel:xfs_trans_cancel (tp); goto out_unlock;fs/xfs/xfs_inode.c +0
-0fs/xfs/xfs_inode.c xfs_itruncate_extents_flags( · line 1548
Quoted 4 lines
fs/xfs/xfs_inode.c +1
-0@@ -1545,6 +1545,7 @@ xfs_itruncate_extents_flags( {struct xfs_mount *mp = ip->i_mount;struct xfs_trans *tp = *tpp; +struct xfs_defer_ops *odfops = tp->t_dfops;
old_dfops?
Quoted 14 lines
fs/xfs/xfs_inode.c xfs_itruncate_extents_flags( · line 1588
Quoted 8 lines
fs/xfs/xfs_inode.c +1
-0struct xfs_defer_ops dfops;xfs_fsblock_t first_block;xfs_fileoff_t first_unmap_block;@@ -1584,9 +1585,10 @@ xfs_itruncate_extents_flags( unmap_len = last_block - first_unmap_block +1 ;while (!done) {xfs_defer_init (&dfops, &first_block); + tp->t_dfops = &dfops;Why can't we attach the dfops generated by the bunmapi call onto the original
t_dfops? I guess it's so that we can drop thedefer_ijoinfrom dfops? It seems odd to be nesting the dfops, since we're no longer completing them in order of oldest to newest.
Hmm, I see what you mean. If we had a populated dfops on entry, we'd skip over those items and leave them for the caller as if nothing happened.
I used this pattern here partly so this change would be transparent to the multiple callers with respect to ->t_dfops and partly because I was too lazy to pull it into the callers. ;) I don't think any of the callers currently set ->t_dfops anyways, so this logic is probably unnecessary.
I could just replace it with an assert that ->t_dfops == NULL on entry (and reset it back to NULL similar to the recovery changes) since that is unlikely to change before this is all fixed up. Alternatively, just pulling dfops up into the callers probably mirrors the end goal where ->t_dfops is internal to the caller's transaction anyways. Preference?
Brian
Quoted 184 lines
--D
Quoted 182 lines
fs/xfs/xfs_inode.c +6
-4error =xfs_bunmapi (tp, ip, first_unmap_block, unmap_len, flags,XFS_ITRUNC_MAX_EXTENTS , &first_block, - &dfops, &done); + tp->t_dfops, &done);if (error) goto out_bmap_cancel;@@ -1594,8 +1596,8 @@ xfs_itruncate_extents_flags(* Duplicate the transaction that has the permanent * reservation and commit the old transaction. */ -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (&tp, &dfops); +xfs_defer_ijoin (tp->t_dfops, ip); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel;@@ -1623,6 +1625,8 @@ xfs_itruncate_extents_flags(trace_xfs_itruncate_extents_end (ip, new_size); out: +/* ->t_dfops points to local stack, don't leak it! */ + tp->t_dfops = odfops; *tpp = tp;return error; out_bmap_cancel:@@ -1631,7 +1635,7 @@ xfs_itruncate_extents_flags(* the transaction can be properly aborted. We just need to make sure * we're not holding any resources that we were not when we came in. */ -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); goto out; }fs/xfs/xfs_reflink.c +15
-12@@ -763,9 +763,10 @@ xfs_reflink_end_cow(/* Unmap the old blocks in the data fork. */ xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops; rlen = del.br_blockcount; error =__xfs_bunmapi (tp, ip, del.br_startoff, &rlen,0 ,1 , - &firstfsb, &dfops); + &firstfsb, tp->t_dfops);if (error) goto out_defer;@@ -777,13 +778,14 @@ xfs_reflink_end_cow(trace_xfs_reflink_cow_remap (ip, &del);/* Free the CoW orphan record. */ - error =xfs_refcount_free_cow_extent (tp->t_mountp, &dfops, + error =xfs_refcount_free_cow_extent (tp->t_mountp, tp->t_dfops, del.br_startblock, del.br_blockcount);if (error) goto out_defer;/* Map the new blocks into the data fork. */ - error =xfs_bmap_map_extent (tp->t_mountp, &dfops, ip, &del); + error =xfs_bmap_map_extent (tp->t_mountp, tp->t_dfops, ip, + &del);if (error) goto out_defer;@@ -794,8 +796,8 @@ xfs_reflink_end_cow(/* Remove the mapping from the CoW fork. */ xfs_bmap_del_extent_cow (ip, &icur, &got, &del); -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (&tp, &dfops); +xfs_defer_ijoin (tp->t_dfops, ip); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_defer;if (!xfs_iext_get_extent (ifp, &icur, &got))@@ -813,7 +815,7 @@ xfs_reflink_end_cow(return 0 ; out_defer: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out_cancel:xfs_trans_cancel (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL );@@ -1112,8 +1114,9 @@ xfs_reflink_remap_extent( rlen = unmap_len;while (rlen) {xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops; error =__xfs_bunmapi (tp, ip, destoff, &rlen,0 ,1 , - &firstfsb, &dfops); + &firstfsb, tp->t_dfops);if (error) goto out_defer;@@ -1134,12 +1137,12 @@ xfs_reflink_remap_extent( uirec.br_blockcount, uirec.br_startblock);/* Update the refcount tree */ - error =xfs_refcount_increase_extent (mp, &dfops, &uirec); + error =xfs_refcount_increase_extent (mp, tp->t_dfops, &uirec);if (error) goto out_defer;/* Map the new blocks into the data fork. */ - error =xfs_bmap_map_extent (mp, &dfops, ip, &uirec); + error =xfs_bmap_map_extent (mp, tp->t_dfops, ip, &uirec);if (error) goto out_defer;@@ -1160,8 +1163,8 @@ xfs_reflink_remap_extent( next_extent:/* Process all the deferred stuff. */ -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (&tp, &dfops); +xfs_defer_ijoin (tp->t_dfops, ip); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_defer; }@@ -1173,7 +1176,7 @@ xfs_reflink_remap_extent(return 0 ; out_defer: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out_cancel:xfs_trans_cancel (tp);xfs_iunlock (ip,XFS_ILOCK_EXCL );fs/xfs/xfs_symlink.c +5
-4@@ -444,6 +444,7 @@ xfs_inactive_symlink_rmt(*/ done =0 ;xfs_defer_init (&dfops, &first_block); + tp->t_dfops = &dfops; nmaps =ARRAY_SIZE (mval); error =xfs_bmapi_read (ip,0 ,xfs_symlink_blocks (mp, size), mval, &nmaps,0 );@@ -466,15 +467,15 @@ xfs_inactive_symlink_rmt(* Unmap the dead block(s) to the dfops. */ error =xfs_bunmapi (tp, ip,0 , size,0 , nmaps, - &first_block, &dfops, &done); + &first_block, tp->t_dfops, &done);if (error) goto error_bmap_cancel;ASSERT (done);/* * Commit the first transaction. This logs the EFI and the inode. */ -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (&tp, &dfops); +xfs_defer_ijoin (tp->t_dfops, ip); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto error_bmap_cancel;@@ -499,7 +500,7 @@ xfs_inactive_symlink_rmt(return 0 ; error_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); error_trans_cancel:xfs_trans_cancel (tp); error_unlock:Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 14/24 xfs: remove xfs_bunmapi() dfops param
In reply to Brian FosterNow that all xfs_bunmapi() callers use ->t_dfops, remove the unnecessary parameter and access ->t_dfops directly. This patch does not change behavior.
--- 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(-)
fs/xfs/libxfs/xfs_attr_remote.c +1 -1
@@ -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);
fs/xfs/libxfs/xfs_bmap.c +9 -11
@@ -5145,26 +5145,26 @@ xfs_bmap_del_extent_real(*/ 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 */
@@ -5518,13 +5518,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; }
@@ -6195,7 +6193,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 );
fs/xfs/libxfs/xfs_bmap.h +2 -3
@@ -209,12 +209,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);
fs/xfs/libxfs/xfs_da_btree.c +1 -1
@@ -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 ;
fs/xfs/libxfs/xfs_dir2.c +1 -1
@@ -663,7 +663,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
fs/xfs/xfs_bmap_util.c +1 -1
@@ -1045,7 +1045,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;
fs/xfs/xfs_inode.c +1 -1
@@ -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;
fs/xfs/xfs_reflink.c +2 -3
@@ -766,7 +766,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;
@@ -1115,8 +1115,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;
fs/xfs/xfs_symlink.c +1 -2
@@ -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);
Signature · 1 line
2.17.1
Re: [PATCH 14/24] xfs: remove xfs_bunmapi() dfops param
Quoted 5 lines · Brian Foster
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 <[email protected]>
Looks good,
Re: [PATCH 14/24] xfs: remove xfs_bunmapi() dfops param
In reply to Brian FosterQuoted 5 lines · Brian Foster
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 <[email protected]>
Looks ok,
--D
Quoted 202 lines
--- 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(-)fs/xfs/libxfs/xfs_attr_remote.c +1
-1@@ -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);fs/xfs/libxfs/xfs_bmap.c +9
-11@@ -5145,26 +5145,26 @@ xfs_bmap_del_extent_real(*/ 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 */ @@ -5518,13 +5518,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; }@@ -6195,7 +6193,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 );fs/xfs/libxfs/xfs_bmap.h +2
-3@@ -209,12 +209,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);fs/xfs/libxfs/xfs_da_btree.c +1
-1@@ -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 ;fs/xfs/libxfs/xfs_dir2.c +1
-1@@ -663,7 +663,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 fs/xfs/xfs_bmap_util.c +1
-1@@ -1045,7 +1045,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;fs/xfs/xfs_inode.c +1
-1@@ -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;fs/xfs/xfs_reflink.c +2
-3@@ -766,7 +766,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;@@ -1115,8 +1115,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;fs/xfs/xfs_symlink.c +1
-2@@ -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);Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 15/24 xfs: remove xfs_bmapi_remap() dfops param
In reply to Brian FosterAll xfs_bmapi_remap() callers already use ->t_dfops. Note that deferred completion context unconditionally sets ->t_dfops if it hasn't already been set by the caller. Remove the unnecessary parameter and access ->t_dfops directly.
--- fs/xfs/libxfs/xfs_bmap.c | 8 ++++---- fs/xfs/libxfs/xfs_bmap.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +4 -4
@@ -4513,7 +4513,6 @@ xfs_bmapi_remap(xfs_fileoff_t bno, xfs_filblks_t len, xfs_fsblock_t startblock, - struct xfs_defer_ops *dfops, int flags) { struct xfs_mount *mp = ip->i_mount;
@@ -4563,7 +4562,7 @@ xfs_bmapi_remap(if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = firstblock; - cur->bc_private.b.dfops = dfops; + cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags =0 ; }
@@ -4576,7 +4575,7 @@ xfs_bmapi_remap( got.br_state =XFS_EXT_NORM ; error =xfs_bmap_add_extent_hole_real (tp, ip, whichfork, &icur, - &cur, &got, &firstblock, dfops, &logflags, flags); + &cur, &got, &firstblock, tp->t_dfops, &logflags, flags);if (error) goto error0;
@@ -6187,8 +6186,9 @@ xfs_bmap_finish_one(switch (type) {case XFS_BMAP_MAP : +ASSERT (dfops == tp->t_dfops); error =xfs_bmapi_remap (tp, ip, startoff, *blockcount, - startblock, dfops,0 ); + startblock,0 ); *blockcount =0 ;break ;case XFS_BMAP_UNMAP :
fs/xfs/libxfs/xfs_bmap.h +1 -1
@@ -287,6 +287,6 @@ xfs_failaddr_t xfs_bmap_validate_extent(struct xfs_inode *ip, int whichfork,int xfs_bmapi_remap (struct xfs_trans *tp,struct xfs_inode *ip,xfs_fileoff_t bno,xfs_filblks_t len,xfs_fsblock_t startblock, -struct xfs_defer_ops *dfops,int flags); +int flags);#endif /* __XFS_BMAP_H__ */
Signature · 1 line
2.17.1
Re: [PATCH 15/24] xfs: remove xfs_bmapi_remap() dfops param
Quoted 6 lines · Brian Foster
All
xfs_bmapi_remap()callers already use ->t_dfops. Note that deferred completion context unconditionally sets ->t_dfops if it hasn't already been set by the caller. Remove the unnecessary parameter and access ->t_dfops directly.Signed-off-by Brian Foster <[email protected]>
Looks good,
Re: [PATCH 15/24] xfs: remove xfs_bmapi_remap() dfops param
In reply to Brian FosterQuoted 6 lines · Brian Foster
All
xfs_bmapi_remap()callers already use ->t_dfops. Note that deferred completion context unconditionally sets ->t_dfops if it hasn't already been set by the caller. Remove the unnecessary parameter and access ->t_dfops directly.Signed-off-by Brian Foster <[email protected]>
Looks ok,
--D
Quoted 65 lines
--- fs/xfs/libxfs/xfs_bmap.c | 8 ++++---- fs/xfs/libxfs/xfs_bmap.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-)fs/xfs/libxfs/xfs_bmap.c +4
-4@@ -4513,7 +4513,6 @@ xfs_bmapi_remap(xfs_fileoff_t bno, xfs_filblks_t len, xfs_fsblock_t startblock, - struct xfs_defer_ops *dfops, int flags) { struct xfs_mount *mp = ip->i_mount;@@ -4563,7 +4562,7 @@ xfs_bmapi_remap(if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = firstblock; - cur->bc_private.b.dfops = dfops; + cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags =0 ; }@@ -4576,7 +4575,7 @@ xfs_bmapi_remap( got.br_state =XFS_EXT_NORM ; error =xfs_bmap_add_extent_hole_real (tp, ip, whichfork, &icur, - &cur, &got, &firstblock, dfops, &logflags, flags); + &cur, &got, &firstblock, tp->t_dfops, &logflags, flags);if (error) goto error0;@@ -6187,8 +6186,9 @@ xfs_bmap_finish_one(switch (type) {case XFS_BMAP_MAP : +ASSERT (dfops == tp->t_dfops); error =xfs_bmapi_remap (tp, ip, startoff, *blockcount, - startblock, dfops,0 ); + startblock,0 ); *blockcount =0 ;break ;case XFS_BMAP_UNMAP :fs/xfs/libxfs/xfs_bmap.h +1
-1@@ -287,6 +287,6 @@ xfs_failaddr_t xfs_bmap_validate_extent(struct xfs_inode *ip, int whichfork,int xfs_bmapi_remap (struct xfs_trans *tp,struct xfs_inode *ip,xfs_fileoff_t bno,xfs_filblks_t len,xfs_fsblock_t startblock, -struct xfs_defer_ops *dfops,int flags); +int flags);#endif /* __XFS_BMAP_H__ */ Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 16/24 xfs: remove struct xfs_bmalloca dfops field
In reply to Brian FosterNow that bma.dfops is only assigned from ->t_dfops, replace all accesses to the former with the latter and remove the unnecessary field. This patch does not change behavior.
--- fs/xfs/libxfs/xfs_bmap.c | 30 +++++++++++++++--------------- fs/xfs/libxfs/xfs_bmap.h | 1 - fs/xfs/xfs_filestream.c | 3 ++- 3 files changed, 17 insertions(+), 17 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +15 -15
@@ -1806,7 +1806,7 @@ xfs_bmap_add_extent_delay_real(if (xfs_bmap_needs_btree (bma->ip, whichfork)) { error =xfs_bmap_extents_to_btree (bma->tp, bma->ip, - bma->firstblock, bma->dfops, + bma->firstblock, bma->tp->t_dfops, &bma->cur,1 , &tmp_rval, whichfork); rval |= tmp_rval;if (error)
@@ -1884,7 +1884,7 @@ xfs_bmap_add_extent_delay_real(if (xfs_bmap_needs_btree (bma->ip, whichfork)) { error =xfs_bmap_extents_to_btree (bma->tp, bma->ip, - bma->firstblock, bma->dfops, &bma->cur,1 , + bma->firstblock, bma->tp->t_dfops, &bma->cur,1 , &tmp_rval, whichfork); rval |= tmp_rval;if (error)
@@ -1965,8 +1965,8 @@ xfs_bmap_add_extent_delay_real(if (xfs_bmap_needs_btree (bma->ip, whichfork)) { error =xfs_bmap_extents_to_btree (bma->tp, bma->ip, - bma->firstblock, bma->dfops, &bma->cur, -1 , &tmp_rval, whichfork); + bma->firstblock, bma->tp->t_dfops, + &bma->cur,1 , &tmp_rval, whichfork); rval |= tmp_rval;if (error) goto done;
@@ -1991,7 +1991,7 @@ xfs_bmap_add_extent_delay_real(/* add reverse mapping unless caller opted out */ if (!(bma->flags &XFS_BMAPI_NORMAP )) { - error =xfs_rmap_map_extent (mp, bma->dfops, bma->ip, + error =xfs_rmap_map_extent (mp, bma->tp->t_dfops, bma->ip, whichfork, new);if (error) goto done;
@@ -2003,7 +2003,7 @@ xfs_bmap_add_extent_delay_real(ASSERT (bma->cur ==NULL ); error =xfs_bmap_extents_to_btree (bma->tp, bma->ip, - bma->firstblock, bma->dfops, &bma->cur, + bma->firstblock, bma->tp->t_dfops, &bma->cur, da_old >0 , &tmp_logflags, whichfork); bma->logflags |= tmp_logflags;if (error)
@@ -3480,7 +3480,7 @@ xfs_bmap_btalloc( error =xfs_bmap_btalloc_nullfb (ap, &args, &blen);if (error)return error; - }else if (ap->dfops->dop_low) { + }else if (ap->tp->t_dfops->dop_low) {if (xfs_inode_is_filestream (ap->ip)) args.type =XFS_ALLOCTYPE_FIRST_AG ;else
@@ -3515,7 +3515,7 @@ xfs_bmap_btalloc(* is >= the stripe unit and the allocation offset is * at the end of file. */ -if (!ap->dfops->dop_low && ap->aeof) { +if (!ap->tp->t_dfops->dop_low && ap->aeof) {if (!ap->offset) { args.alignment = stripe_align; atype = args.type;
@@ -3607,7 +3607,7 @@ xfs_bmap_btalloc( args.total = ap->minlen;if ((error =xfs_alloc_vextent (&args)))return error; - ap->dfops->dop_low = true; + ap->tp->t_dfops->dop_low = true; }if (args.fsbno !=NULLFSBLOCK ) {/*
@@ -4083,7 +4083,7 @@ xfs_bmapi_allocate(if ((ifp->if_flags &XFS_IFBROOT ) && !bma->cur) { bma->cur =xfs_bmbt_init_cursor (mp, bma->tp, bma->ip, whichfork); bma->cur->bc_private.b.firstblock = *bma->firstblock; - bma->cur->bc_private.b.dfops = bma->dfops; + bma->cur->bc_private.b.dfops = bma->tp->t_dfops; }/* * Bump the number of extents we've allocated
@@ -4119,8 +4119,8 @@ xfs_bmapi_allocate(else error =xfs_bmap_add_extent_hole_real (bma->tp, bma->ip, whichfork, &bma->icur, &bma->cur, &bma->got, - bma->firstblock, bma->dfops, &bma->logflags, - bma->flags); + bma->firstblock, bma->tp->t_dfops, + &bma->logflags, bma->flags); bma->logflags |= tmp_logflags;if (error)
@@ -4172,7 +4172,7 @@ xfs_bmapi_convert_unwritten( bma->cur =xfs_bmbt_init_cursor (bma->ip->i_mount, bma->tp, bma->ip, whichfork); bma->cur->bc_private.b.firstblock = *bma->firstblock; - bma->cur->bc_private.b.dfops = bma->dfops; + bma->cur->bc_private.b.dfops = bma->tp->t_dfops; } mval->br_state = (mval->br_state ==XFS_EXT_UNWRITTEN ) ?XFS_EXT_NORM :XFS_EXT_UNWRITTEN ;
@@ -4190,7 +4190,7 @@ xfs_bmapi_convert_unwritten( error =xfs_bmap_add_extent_unwritten_real (bma->tp, bma->ip, whichfork, &bma->icur, &bma->cur, mval, bma->firstblock, - bma->dfops, &tmp_logflags); + bma->tp->t_dfops, &tmp_logflags);/* * Log the inode core unconditionally in the unwritten extent conversion * path because the conversion might not have done so (e.g., if the
@@ -4338,8 +4338,8 @@ xfs_bmapi_write( bma.ip = ip; bma.total = total; bma.datatype =0 ; - bma.dfops = tp ? tp->t_dfops :NULL ; bma.firstblock = firstblock; +ASSERT (!tp || tp->t_dfops);while (bno < end && n < *nmap) {bool need_alloc = false, wasdelay = false;
fs/xfs/libxfs/xfs_bmap.h +0 -1
@@ -20,7 +20,6 @@ extern kmem_zone_t *xfs_bmap_free_item_zone;*/ struct xfs_bmalloca {xfs_fsblock_t *firstblock;/* i/o first block allocated */ -struct xfs_defer_ops *dfops;/* bmap freelist */ struct xfs_trans *tp;/* transaction pointer */ struct xfs_inode *ip;/* incore inode pointer */ struct xfs_bmbt_irec prev;/* extent before the new one */
fs/xfs/xfs_filestream.c +2 -1
@@ -19,6 +19,7 @@#include "xfs_filestream.h" #include "xfs_trace.h" #include "xfs_ag_resv.h" +#include "xfs_trans.h" struct xfs_fstrm_item {struct xfs_mru_cache_elem mru;
@@ -377,7 +378,7 @@ xfs_filestream_new_ag(if (xfs_alloc_is_userdata (ap->datatype)) flags |=XFS_PICK_USERDATA ; -if (ap->dfops->dop_low) +if (ap->tp->t_dfops->dop_low) flags |=XFS_PICK_LOWSPACE ; err =xfs_filestream_pick_ag (pip, startag, agp, flags, minlen);
Signature · 1 line
2.17.1
Re: [PATCH 16/24] xfs: remove struct xfs_bmalloca dfops field
Quoted 5 lines · Brian Foster
Now that bma.dfops is only assigned from ->t_dfops, replace all accesses to the former with the latter and remove the unnecessary field. This patch does not change behavior.
Signed-off-by Brian Foster <[email protected]>
Looks good,
Re: [PATCH 16/24] xfs: remove struct xfs_bmalloca dfops field
In reply to Brian FosterQuoted 5 lines · Brian Foster
Now that bma.dfops is only assigned from ->t_dfops, replace all accesses to the former with the latter and remove the unnecessary field. This patch does not change behavior.
Signed-off-by Brian Foster <[email protected]>
Looks ok,
--D
Quoted 172 lines
--- fs/xfs/libxfs/xfs_bmap.c | 30 +++++++++++++++--------------- fs/xfs/libxfs/xfs_bmap.h | 1 - fs/xfs/xfs_filestream.c | 3 ++- 3 files changed, 17 insertions(+), 17 deletions(-)fs/xfs/libxfs/xfs_bmap.c +15
-15@@ -1806,7 +1806,7 @@ xfs_bmap_add_extent_delay_real(if (xfs_bmap_needs_btree (bma->ip, whichfork)) { error =xfs_bmap_extents_to_btree (bma->tp, bma->ip, - bma->firstblock, bma->dfops, + bma->firstblock, bma->tp->t_dfops, &bma->cur,1 , &tmp_rval, whichfork); rval |= tmp_rval;if (error)@@ -1884,7 +1884,7 @@ xfs_bmap_add_extent_delay_real(if (xfs_bmap_needs_btree (bma->ip, whichfork)) { error =xfs_bmap_extents_to_btree (bma->tp, bma->ip, - bma->firstblock, bma->dfops, &bma->cur,1 , + bma->firstblock, bma->tp->t_dfops, &bma->cur,1 , &tmp_rval, whichfork); rval |= tmp_rval;if (error)@@ -1965,8 +1965,8 @@ xfs_bmap_add_extent_delay_real(if (xfs_bmap_needs_btree (bma->ip, whichfork)) { error =xfs_bmap_extents_to_btree (bma->tp, bma->ip, - bma->firstblock, bma->dfops, &bma->cur, -1 , &tmp_rval, whichfork); + bma->firstblock, bma->tp->t_dfops, + &bma->cur,1 , &tmp_rval, whichfork); rval |= tmp_rval;if (error) goto done;@@ -1991,7 +1991,7 @@ xfs_bmap_add_extent_delay_real(/* add reverse mapping unless caller opted out */ if (!(bma->flags &XFS_BMAPI_NORMAP )) { - error =xfs_rmap_map_extent (mp, bma->dfops, bma->ip, + error =xfs_rmap_map_extent (mp, bma->tp->t_dfops, bma->ip, whichfork, new);if (error) goto done;@@ -2003,7 +2003,7 @@ xfs_bmap_add_extent_delay_real(ASSERT (bma->cur ==NULL ); error =xfs_bmap_extents_to_btree (bma->tp, bma->ip, - bma->firstblock, bma->dfops, &bma->cur, + bma->firstblock, bma->tp->t_dfops, &bma->cur, da_old >0 , &tmp_logflags, whichfork); bma->logflags |= tmp_logflags;if (error)@@ -3480,7 +3480,7 @@ xfs_bmap_btalloc( error =xfs_bmap_btalloc_nullfb (ap, &args, &blen);if (error)return error; - }else if (ap->dfops->dop_low) { + }else if (ap->tp->t_dfops->dop_low) {if (xfs_inode_is_filestream (ap->ip)) args.type =XFS_ALLOCTYPE_FIRST_AG ;else @@ -3515,7 +3515,7 @@ xfs_bmap_btalloc(* is >= the stripe unit and the allocation offset is * at the end of file. */ -if (!ap->dfops->dop_low && ap->aeof) { +if (!ap->tp->t_dfops->dop_low && ap->aeof) {if (!ap->offset) { args.alignment = stripe_align; atype = args.type;@@ -3607,7 +3607,7 @@ xfs_bmap_btalloc( args.total = ap->minlen;if ((error =xfs_alloc_vextent (&args)))return error; - ap->dfops->dop_low = true; + ap->tp->t_dfops->dop_low = true; }if (args.fsbno !=NULLFSBLOCK ) {/* @@ -4083,7 +4083,7 @@ xfs_bmapi_allocate(if ((ifp->if_flags &XFS_IFBROOT ) && !bma->cur) { bma->cur =xfs_bmbt_init_cursor (mp, bma->tp, bma->ip, whichfork); bma->cur->bc_private.b.firstblock = *bma->firstblock; - bma->cur->bc_private.b.dfops = bma->dfops; + bma->cur->bc_private.b.dfops = bma->tp->t_dfops; }/* * Bump the number of extents we've allocated @@ -4119,8 +4119,8 @@ xfs_bmapi_allocate(else error =xfs_bmap_add_extent_hole_real (bma->tp, bma->ip, whichfork, &bma->icur, &bma->cur, &bma->got, - bma->firstblock, bma->dfops, &bma->logflags, - bma->flags); + bma->firstblock, bma->tp->t_dfops, + &bma->logflags, bma->flags); bma->logflags |= tmp_logflags;if (error)@@ -4172,7 +4172,7 @@ xfs_bmapi_convert_unwritten( bma->cur =xfs_bmbt_init_cursor (bma->ip->i_mount, bma->tp, bma->ip, whichfork); bma->cur->bc_private.b.firstblock = *bma->firstblock; - bma->cur->bc_private.b.dfops = bma->dfops; + bma->cur->bc_private.b.dfops = bma->tp->t_dfops; } mval->br_state = (mval->br_state ==XFS_EXT_UNWRITTEN ) ?XFS_EXT_NORM :XFS_EXT_UNWRITTEN ;@@ -4190,7 +4190,7 @@ xfs_bmapi_convert_unwritten( error =xfs_bmap_add_extent_unwritten_real (bma->tp, bma->ip, whichfork, &bma->icur, &bma->cur, mval, bma->firstblock, - bma->dfops, &tmp_logflags); + bma->tp->t_dfops, &tmp_logflags);/* * Log the inode core unconditionally in the unwritten extent conversion * path because the conversion might not have done so (e.g., if the @@ -4338,8 +4338,8 @@ xfs_bmapi_write( bma.ip = ip; bma.total = total; bma.datatype =0 ; - bma.dfops = tp ? tp->t_dfops :NULL ; bma.firstblock = firstblock; +ASSERT (!tp || tp->t_dfops);while (bno < end && n < *nmap) {bool need_alloc = false, wasdelay = false;fs/xfs/libxfs/xfs_bmap.h +0
-1@@ -20,7 +20,6 @@ extern kmem_zone_t *xfs_bmap_free_item_zone;*/ struct xfs_bmalloca {xfs_fsblock_t *firstblock;/* i/o first block allocated */ -struct xfs_defer_ops *dfops;/* bmap freelist */ struct xfs_trans *tp;/* transaction pointer */ struct xfs_inode *ip;/* incore inode pointer */ struct xfs_bmbt_irec prev;/* extent before the new one */ fs/xfs/xfs_filestream.c +2
-1@@ -19,6 +19,7 @@#include "xfs_filestream.h" #include "xfs_trace.h" #include "xfs_ag_resv.h" +#include "xfs_trans.h" struct xfs_fstrm_item {struct xfs_mru_cache_elem mru;@@ -377,7 +378,7 @@ xfs_filestream_new_ag(if (xfs_alloc_is_userdata (ap->datatype)) flags |=XFS_PICK_USERDATA ; -if (ap->dfops->dop_low) +if (ap->tp->t_dfops->dop_low) flags |=XFS_PICK_LOWSPACE ; err =xfs_filestream_pick_ag (pip, startag, agp, flags, minlen);Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 17/24 xfs: use ->t_dfops for collapse/insert range operations
In reply to Brian FosterUse ->t_dfops for the collapse and insert range transactions. These are the only callers of the respective bmap helpers, so replace the unnecessary dfops parameters with direct accesses to ->t_dfops.
--- fs/xfs/libxfs/xfs_bmap.c | 16 +++++++--------- fs/xfs/libxfs/xfs_bmap.h | 6 ++---- fs/xfs/xfs_bmap_util.c | 14 ++++++++------ 3 files changed, 17 insertions(+), 19 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +7 -9
@@ -5685,8 +5685,7 @@ xfs_bmap_collapse_extents(xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb, bool *done, - xfs_fsblock_t *firstblock, - struct xfs_defer_ops *dfops) + xfs_fsblock_t *firstblock) { int whichfork = XFS_DATA_FORK;struct xfs_mount *mp = ip->i_mount;
@@ -5720,7 +5719,7 @@ xfs_bmap_collapse_extents(if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = *firstblock; - cur->bc_private.b.dfops = dfops; + cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags =0 ; }
@@ -5741,7 +5740,7 @@ xfs_bmap_collapse_extents(if (xfs_bmse_can_merge (&prev, &got, offset_shift_fsb)) { error =xfs_bmse_merge (ip, whichfork, offset_shift_fsb, &icur, &got, &prev, cur, &logflags, - dfops); + tp->t_dfops);if (error) goto del_cursor; goto done;
@@ -5754,7 +5753,7 @@ xfs_bmap_collapse_extents( } error =xfs_bmap_shift_update_extent (ip, whichfork, &icur, &got, cur, - &logflags, dfops, new_startoff); + &logflags, tp->t_dfops, new_startoff);if (error) goto del_cursor;
@@ -5808,8 +5807,7 @@ xfs_bmap_insert_extents(xfs_fileoff_t offset_shift_fsb, bool *done, xfs_fileoff_t stop_fsb, - xfs_fsblock_t *firstblock, - struct xfs_defer_ops *dfops) + xfs_fsblock_t *firstblock) { int whichfork = XFS_DATA_FORK;struct xfs_mount *mp = ip->i_mount;
@@ -5843,7 +5841,7 @@ xfs_bmap_insert_extents(if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = *firstblock; - cur->bc_private.b.dfops = dfops; + cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags =0 ; }
@@ -5886,7 +5884,7 @@ xfs_bmap_insert_extents( } error =xfs_bmap_shift_update_extent (ip, whichfork, &icur, &got, cur, - &logflags, dfops, new_startoff); + &logflags, tp->t_dfops, new_startoff);if (error) goto del_cursor;
fs/xfs/libxfs/xfs_bmap.h +2 -4
@@ -222,14 +222,12 @@ void xfs_bmap_del_extent_cow(struct xfs_inode *ip,uint xfs_default_attroffset (struct xfs_inode *ip);int xfs_bmap_collapse_extents (struct xfs_trans *tp,struct xfs_inode *ip,xfs_fileoff_t *next_fsb,xfs_fileoff_t offset_shift_fsb, -bool *done,xfs_fsblock_t *firstblock, -struct xfs_defer_ops *dfops); +bool *done,xfs_fsblock_t *firstblock);int xfs_bmap_can_insert_extents (struct xfs_inode *ip,xfs_fileoff_t off,xfs_fileoff_t shift);int xfs_bmap_insert_extents (struct xfs_trans *tp,struct xfs_inode *ip,xfs_fileoff_t *next_fsb,xfs_fileoff_t offset_shift_fsb, -bool *done,xfs_fileoff_t stop_fsb,xfs_fsblock_t *firstblock, -struct xfs_defer_ops *dfops); +bool *done,xfs_fileoff_t stop_fsb,xfs_fsblock_t *firstblock);int xfs_bmap_split_extent (struct xfs_inode *ip,xfs_fileoff_t split_offset); int xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, int whichfork, xfs_fileoff_t off, xfs_filblks_t len, xfs_filblks_t prealloc,
fs/xfs/xfs_bmap_util.c +8 -6
@@ -1347,12 +1347,13 @@ xfs_collapse_file_space(xfs_trans_ijoin (tp, ip,XFS_ILOCK_EXCL );xfs_defer_init (&dfops, &first_block); + tp->t_dfops = &dfops; error =xfs_bmap_collapse_extents (tp, ip, &next_fsb, shift_fsb, - &done, &first_block, &dfops); + &done, &first_block);if (error) goto out_bmap_cancel; - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel; error =xfs_trans_commit (tp);
@@ -1361,7 +1362,7 @@ xfs_collapse_file_space(return error; out_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out_trans_cancel:xfs_trans_cancel (tp);return error;
@@ -1426,12 +1427,13 @@ xfs_insert_file_space(xfs_ilock (ip,XFS_ILOCK_EXCL );xfs_trans_ijoin (tp, ip,XFS_ILOCK_EXCL );xfs_defer_init (&dfops, &first_block); + tp->t_dfops = &dfops; error =xfs_bmap_insert_extents (tp, ip, &next_fsb, shift_fsb, - &done, stop_fsb, &first_block, &dfops); + &done, stop_fsb, &first_block);if (error) goto out_bmap_cancel; - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel; error =xfs_trans_commit (tp);
@@ -1440,7 +1442,7 @@ xfs_insert_file_space(return error; out_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops);xfs_trans_cancel (tp);return error; }
Signature · 1 line
2.17.1
Re: [PATCH 17/24] xfs: use ->t_dfops for collapse/insert range operations
Quoted 5 lines · Brian Foster
Use ->t_dfops for the collapse and insert range transactions. These are the only callers of the respective bmap helpers, so replace the unnecessary dfops parameters with direct accesses to ->t_dfops.
Signed-off-by Brian Foster <[email protected]>
Looks good,
Re: [PATCH 17/24] xfs: use ->t_dfops for collapse/insert range operations
In reply to Brian FosterQuoted 5 lines · Brian Foster
Use ->t_dfops for the collapse and insert range transactions. These are the only callers of the respective bmap helpers, so replace the unnecessary dfops parameters with direct accesses to ->t_dfops.
Signed-off-by Brian Foster <[email protected]>
Looks ok,
--D
Quoted 157 lines
--- fs/xfs/libxfs/xfs_bmap.c | 16 +++++++--------- fs/xfs/libxfs/xfs_bmap.h | 6 ++---- fs/xfs/xfs_bmap_util.c | 14 ++++++++------ 3 files changed, 17 insertions(+), 19 deletions(-)fs/xfs/libxfs/xfs_bmap.c +7
-9@@ -5685,8 +5685,7 @@ xfs_bmap_collapse_extents(xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb, bool *done, - xfs_fsblock_t *firstblock, - struct xfs_defer_ops *dfops) + xfs_fsblock_t *firstblock) { int whichfork = XFS_DATA_FORK;struct xfs_mount *mp = ip->i_mount;@@ -5720,7 +5719,7 @@ xfs_bmap_collapse_extents(if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = *firstblock; - cur->bc_private.b.dfops = dfops; + cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags =0 ; }@@ -5741,7 +5740,7 @@ xfs_bmap_collapse_extents(if (xfs_bmse_can_merge (&prev, &got, offset_shift_fsb)) { error =xfs_bmse_merge (ip, whichfork, offset_shift_fsb, &icur, &got, &prev, cur, &logflags, - dfops); + tp->t_dfops);if (error) goto del_cursor; goto done;@@ -5754,7 +5753,7 @@ xfs_bmap_collapse_extents( } error =xfs_bmap_shift_update_extent (ip, whichfork, &icur, &got, cur, - &logflags, dfops, new_startoff); + &logflags, tp->t_dfops, new_startoff);if (error) goto del_cursor;@@ -5808,8 +5807,7 @@ xfs_bmap_insert_extents(xfs_fileoff_t offset_shift_fsb, bool *done, xfs_fileoff_t stop_fsb, - xfs_fsblock_t *firstblock, - struct xfs_defer_ops *dfops) + xfs_fsblock_t *firstblock) { int whichfork = XFS_DATA_FORK;struct xfs_mount *mp = ip->i_mount;@@ -5843,7 +5841,7 @@ xfs_bmap_insert_extents(if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = *firstblock; - cur->bc_private.b.dfops = dfops; + cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags =0 ; }@@ -5886,7 +5884,7 @@ xfs_bmap_insert_extents( } error =xfs_bmap_shift_update_extent (ip, whichfork, &icur, &got, cur, - &logflags, dfops, new_startoff); + &logflags, tp->t_dfops, new_startoff);if (error) goto del_cursor;fs/xfs/libxfs/xfs_bmap.h +2
-4@@ -222,14 +222,12 @@ void xfs_bmap_del_extent_cow(struct xfs_inode *ip,uint xfs_default_attroffset (struct xfs_inode *ip);int xfs_bmap_collapse_extents (struct xfs_trans *tp,struct xfs_inode *ip,xfs_fileoff_t *next_fsb,xfs_fileoff_t offset_shift_fsb, -bool *done,xfs_fsblock_t *firstblock, -struct xfs_defer_ops *dfops); +bool *done,xfs_fsblock_t *firstblock);int xfs_bmap_can_insert_extents (struct xfs_inode *ip,xfs_fileoff_t off,xfs_fileoff_t shift);int xfs_bmap_insert_extents (struct xfs_trans *tp,struct xfs_inode *ip,xfs_fileoff_t *next_fsb,xfs_fileoff_t offset_shift_fsb, -bool *done,xfs_fileoff_t stop_fsb,xfs_fsblock_t *firstblock, -struct xfs_defer_ops *dfops); +bool *done,xfs_fileoff_t stop_fsb,xfs_fsblock_t *firstblock);int xfs_bmap_split_extent (struct xfs_inode *ip,xfs_fileoff_t split_offset); int xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, int whichfork, xfs_fileoff_t off, xfs_filblks_t len, xfs_filblks_t prealloc,fs/xfs/xfs_bmap_util.c +8
-6@@ -1347,12 +1347,13 @@ xfs_collapse_file_space(xfs_trans_ijoin (tp, ip,XFS_ILOCK_EXCL );xfs_defer_init (&dfops, &first_block); + tp->t_dfops = &dfops; error =xfs_bmap_collapse_extents (tp, ip, &next_fsb, shift_fsb, - &done, &first_block, &dfops); + &done, &first_block);if (error) goto out_bmap_cancel; - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel; error =xfs_trans_commit (tp);@@ -1361,7 +1362,7 @@ xfs_collapse_file_space(return error; out_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out_trans_cancel:xfs_trans_cancel (tp);return error;@@ -1426,12 +1427,13 @@ xfs_insert_file_space(xfs_ilock (ip,XFS_ILOCK_EXCL );xfs_trans_ijoin (tp, ip,XFS_ILOCK_EXCL );xfs_defer_init (&dfops, &first_block); + tp->t_dfops = &dfops; error =xfs_bmap_insert_extents (tp, ip, &next_fsb, shift_fsb, - &done, stop_fsb, &first_block, &dfops); + &done, stop_fsb, &first_block);if (error) goto out_bmap_cancel; - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_bmap_cancel; error =xfs_trans_commit (tp);@@ -1440,7 +1442,7 @@ xfs_insert_file_space(return error; out_bmap_cancel: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops);xfs_trans_cancel (tp);return error; }Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 18/24 xfs: remove dfops param from internal bmap extent helpers
In reply to Brian FosterAll callers of the various bmap extent helpers now use ->t_dfops. Remove the unnecessary dfops params and access ->t_dfops directly. This patch does not change behavior.
--- fs/xfs/libxfs/xfs_bmap.c | 92 +++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 48 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +44 -48
@@ -644,25 +644,24 @@ xfs_bmap_btree_to_extents(*/ STATIC int /* error */xfs_bmap_extents_to_btree ( -xfs_trans_t *tp,/* transaction pointer */ -xfs_inode_t *ip,/* incore inode pointer */ +struct xfs_trans *tp,/* transaction pointer */ +struct xfs_inode *ip,/* incore inode pointer */ xfs_fsblock_t *firstblock,/* first-block-allocated */ -struct xfs_defer_ops *dfops,/* blocks freed in xaction */ -xfs_btree_cur_t **curp,/* cursor returned to caller */ +struct xfs_btree_cur **curp,/* cursor returned to caller */ int wasdel,/* converting a delayed alloc */ int *logflagsp,/* inode logging flags */ int whichfork)/* data or attr fork */ {struct xfs_btree_block *ablock;/* allocated (child) bt block */ -xfs_buf_t *abp;/* buffer for ablock */ -xfs_alloc_arg_t args;/* allocation arguments */ -xfs_bmbt_rec_t *arp;/* child record pointer */ +struct xfs_buf *abp;/* buffer for ablock */ +struct xfs_alloc_arg args;/* allocation arguments */ +struct xfs_bmbt_rec *arp;/* child record pointer */ struct xfs_btree_block *block;/* btree root block */ -xfs_btree_cur_t *cur;/* bmap btree cursor */ +struct xfs_btree_cur *cur;/* bmap btree cursor */ int error;/* error return value */ -xfs_ifork_t *ifp;/* inode fork pointer */ -xfs_bmbt_key_t *kp;/* root block key pointer */ -xfs_mount_t *mp;/* mount structure */ +struct xfs_ifork *ifp;/* inode fork pointer */ +struct xfs_bmbt_key *kp;/* root block key pointer */ +struct xfs_mount *mp;/* mount structure */ xfs_bmbt_ptr_t *pp;/* root block address pointer */ struct xfs_iext_cursor icur;struct xfs_bmbt_irec rec;
@@ -691,7 +690,7 @@ xfs_bmap_extents_to_btree(*/ cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = *firstblock; - cur->bc_private.b.dfops = dfops; + cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags = wasdel ?XFS_BTCUR_BPRV_WASDEL :0 ;/* * Convert to a btree with two levels, one record in root.
@@ -705,7 +704,7 @@ xfs_bmap_extents_to_btree(if (*firstblock ==NULLFSBLOCK ) { args.type =XFS_ALLOCTYPE_START_BNO ; args.fsbno =XFS_INO_TO_FSB (mp, ip->i_ino); - }else if (dfops->dop_low) { + }else if (tp->t_dfops->dop_low) { args.type =XFS_ALLOCTYPE_START_BNO ; args.fsbno = *firstblock; }else {
@@ -958,8 +957,8 @@ xfs_bmap_add_attrfork_btree(*/ STATIC int /* error */xfs_bmap_add_attrfork_extents ( -xfs_trans_t *tp,/* transaction pointer */ -xfs_inode_t *ip,/* incore inode pointer */ +struct xfs_trans *tp,/* transaction pointer */ +struct xfs_inode *ip,/* incore inode pointer */ xfs_fsblock_t *firstblock,/* first block allocated */ int *flags)/* inode logging flags */ {
@@ -969,8 +968,8 @@ xfs_bmap_add_attrfork_extents(if (ip->i_d.di_nextents *sizeof (xfs_bmbt_rec_t) <=XFS_IFORK_DSIZE (ip))return 0 ; cur =NULL ; - error =xfs_bmap_extents_to_btree (tp, ip, firstblock, tp->t_dfops, &cur,0 , - flags,XFS_DATA_FORK ); + error =xfs_bmap_extents_to_btree (tp, ip, firstblock, &cur,0 , flags, +XFS_DATA_FORK );if (cur) { cur->bc_private.b.allocated =0 ; xfs_btree_del_cursor(cur,
@@ -1806,8 +1805,8 @@ xfs_bmap_add_extent_delay_real(if (xfs_bmap_needs_btree (bma->ip, whichfork)) { error =xfs_bmap_extents_to_btree (bma->tp, bma->ip, - bma->firstblock, bma->tp->t_dfops, - &bma->cur,1 , &tmp_rval, whichfork); + bma->firstblock, &bma->cur,1 , + &tmp_rval, whichfork); rval |= tmp_rval;if (error) goto done;
@@ -1884,8 +1883,8 @@ xfs_bmap_add_extent_delay_real(if (xfs_bmap_needs_btree (bma->ip, whichfork)) { error =xfs_bmap_extents_to_btree (bma->tp, bma->ip, - bma->firstblock, bma->tp->t_dfops, &bma->cur,1 , - &tmp_rval, whichfork); + bma->firstblock, &bma->cur,1 , &tmp_rval, + whichfork); rval |= tmp_rval;if (error) goto done;
@@ -1965,8 +1964,8 @@ xfs_bmap_add_extent_delay_real(if (xfs_bmap_needs_btree (bma->ip, whichfork)) { error =xfs_bmap_extents_to_btree (bma->tp, bma->ip, - bma->firstblock, bma->tp->t_dfops, - &bma->cur,1 , &tmp_rval, whichfork); + bma->firstblock, &bma->cur,1 , + &tmp_rval, whichfork); rval |= tmp_rval;if (error) goto done;
@@ -2003,8 +2002,8 @@ xfs_bmap_add_extent_delay_real(ASSERT (bma->cur ==NULL ); error =xfs_bmap_extents_to_btree (bma->tp, bma->ip, - bma->firstblock, bma->tp->t_dfops, &bma->cur, - da_old >0 , &tmp_logflags, whichfork); + bma->firstblock, &bma->cur, da_old >0 , + &tmp_logflags, whichfork); bma->logflags |= tmp_logflags;if (error) goto done;
@@ -2044,7 +2043,6 @@ xfs_bmap_add_extent_unwritten_real( xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ xfs_bmbt_irec_t *new, /* new data to add to file extents */ xfs_fsblock_t *first, /* pointer to firstblock variable */ - struct xfs_defer_ops *dfops, /* list of extents to be freed */ int *logflagsp) /* inode logging flags */ {xfs_btree_cur_t *cur;/* btree cursor */
@@ -2058,6 +2056,7 @@ xfs_bmap_add_extent_unwritten_real(int state =xfs_bmap_fork_to_state (whichfork);struct xfs_mount *mp = ip->i_mount;struct xfs_bmbt_irec old; +struct xfs_defer_ops *dfops = tp ? tp->t_dfops :NULL ; *logflagsp =0 ;
@@ -2485,8 +2484,8 @@ xfs_bmap_add_extent_unwritten_real(int tmp_logflags;/* partial log flag return val */ ASSERT (cur ==NULL ); - error =xfs_bmap_extents_to_btree (tp, ip, first, dfops, &cur, -0 , &tmp_logflags, whichfork); + error =xfs_bmap_extents_to_btree (tp, ip, first, &cur,0 , + &tmp_logflags, whichfork); *logflagsp |= tmp_logflags;if (error) goto done;
@@ -2658,7 +2657,6 @@ xfs_bmap_add_extent_hole_real(struct xfs_btree_cur **curp, struct xfs_bmbt_irec *new, xfs_fsblock_t *first, - struct xfs_defer_ops *dfops, int *logflagsp, int flags) {
@@ -2839,7 +2837,8 @@ xfs_bmap_add_extent_hole_real(/* add reverse mapping unless caller opted out */ if (!(flags &XFS_BMAPI_NORMAP )) { - error =xfs_rmap_map_extent (mp, dfops, ip, whichfork, new); + error =xfs_rmap_map_extent (mp, tp->t_dfops, ip, whichfork, + new);if (error) goto done; }
@@ -2849,8 +2848,8 @@ xfs_bmap_add_extent_hole_real(int tmp_logflags;/* partial log flag return val */ ASSERT (cur ==NULL ); - error =xfs_bmap_extents_to_btree (tp, ip, first, dfops, curp, -0 , &tmp_logflags, whichfork); + error =xfs_bmap_extents_to_btree (tp, ip, first, curp,0 , + &tmp_logflags, whichfork); *logflagsp |= tmp_logflags; cur = *curp;if (error)
@@ -4119,8 +4118,7 @@ xfs_bmapi_allocate(else error =xfs_bmap_add_extent_hole_real (bma->tp, bma->ip, whichfork, &bma->icur, &bma->cur, &bma->got, - bma->firstblock, bma->tp->t_dfops, - &bma->logflags, bma->flags); + bma->firstblock, &bma->logflags, bma->flags); bma->logflags |= tmp_logflags;if (error)
@@ -4190,7 +4188,7 @@ xfs_bmapi_convert_unwritten( error =xfs_bmap_add_extent_unwritten_real (bma->tp, bma->ip, whichfork, &bma->icur, &bma->cur, mval, bma->firstblock, - bma->tp->t_dfops, &tmp_logflags); + &tmp_logflags);/* * Log the inode core unconditionally in the unwritten extent conversion * path because the conversion might not have done so (e.g., if the
@@ -4575,7 +4573,7 @@ xfs_bmapi_remap( got.br_state =XFS_EXT_NORM ; error =xfs_bmap_add_extent_hole_real (tp, ip, whichfork, &icur, - &cur, &got, &firstblock, tp->t_dfops, &logflags, flags); + &cur, &got, &firstblock, &logflags, flags);if (error) goto error0;
@@ -4894,7 +4892,6 @@ xfs_bmap_del_extent_real( xfs_inode_t *ip,/* incore inode pointer */ xfs_trans_t *tp,/* current transaction pointer */ struct xfs_iext_cursor *icur, - struct xfs_defer_ops *dfops, /* list of extents to be freed */ xfs_btree_cur_t *cur,/* if null, not a btree */ xfs_bmbt_irec_t *del,/* data to remove from extents */ int *logflagsp, /* inode logging flags */
@@ -4917,6 +4914,7 @@ xfs_bmap_del_extent_real(uint qfield;/* quota field to update */ int state =xfs_bmap_fork_to_state (whichfork);struct xfs_bmbt_irec old; +struct xfs_defer_ops *dfops = tp ? tp->t_dfops :NULL ; mp = ip->i_mount;XFS_STATS_INC (mp, xs_del_exlist);
@@ -5343,7 +5341,7 @@ __xfs_bunmapi( del.br_state =XFS_EXT_UNWRITTEN ; error =xfs_bmap_add_extent_unwritten_real (tp, ip, whichfork, &icur, &cur, &del, - firstblock, dfops, &logflags); + firstblock, &logflags);if (error) goto error0; goto nodelete;
@@ -5400,8 +5398,7 @@ __xfs_bunmapi( prev.br_state =XFS_EXT_UNWRITTEN ; error =xfs_bmap_add_extent_unwritten_real (tp, ip, whichfork, &icur, &cur, - &prev, firstblock, dfops, - &logflags); + &prev, firstblock, &logflags);if (error) goto error0; goto nodelete;
@@ -5410,8 +5407,7 @@ __xfs_bunmapi( del.br_state =XFS_EXT_UNWRITTEN ; error =xfs_bmap_add_extent_unwritten_real (tp, ip, whichfork, &icur, &cur, - &del, firstblock, dfops, - &logflags); + &del, firstblock, &logflags);if (error) goto error0; goto nodelete;
@@ -5423,8 +5419,8 @@ __xfs_bunmapi( error =xfs_bmap_del_extent_delay (ip, whichfork, &icur, &got, &del); }else { - error =xfs_bmap_del_extent_real (ip, tp, &icur, dfops, - cur, &del, &tmp_logflags, whichfork, + error =xfs_bmap_del_extent_real (ip, tp, &icur, cur, + &del, &tmp_logflags, whichfork, flags); logflags |= tmp_logflags; }
@@ -5458,8 +5454,8 @@ __xfs_bunmapi(*/ if (xfs_bmap_needs_btree (ip, whichfork)) {ASSERT (cur ==NULL ); - error =xfs_bmap_extents_to_btree (tp, ip, firstblock, dfops, - &cur,0 , &tmp_logflags, whichfork); + error =xfs_bmap_extents_to_btree (tp, ip, firstblock, &cur,0 , + &tmp_logflags, whichfork); logflags |= tmp_logflags;if (error) goto error0;
@@ -6009,8 +6005,8 @@ xfs_bmap_split_extent_at(int tmp_logflags;/* partial log flag return val */ ASSERT (cur ==NULL ); - error =xfs_bmap_extents_to_btree (tp, ip, firstfsb, tp->t_dfops, - &cur,0 , &tmp_logflags, whichfork); + error =xfs_bmap_extents_to_btree (tp, ip, firstfsb, &cur,0 , + &tmp_logflags, whichfork); logflags |= tmp_logflags; }
Signature · 1 line
2.17.1
Re: [PATCH 18/24] xfs: remove dfops param from internal bmap extent helpers
Quoted 5 lines · Brian Foster
All callers of the various bmap extent helpers now use ->t_dfops. Remove the unnecessary dfops params and access ->t_dfops directly. This patch does not change behavior.
Signed-off-by Brian Foster <[email protected]>
Looks good,
Re: [PATCH 18/24] xfs: remove dfops param from internal bmap extent helpers
In reply to Brian FosterQuoted 5 lines · Brian Foster
All callers of the various bmap extent helpers now use ->t_dfops. Remove the unnecessary dfops params and access ->t_dfops directly. This patch does not change behavior.
Signed-off-by Brian Foster <[email protected]>
Looks ok,
--D
Quoted 297 lines
--- fs/xfs/libxfs/xfs_bmap.c | 92 +++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 48 deletions(-)fs/xfs/libxfs/xfs_bmap.c +44
-48@@ -644,25 +644,24 @@ xfs_bmap_btree_to_extents(*/ STATIC int /* error */xfs_bmap_extents_to_btree ( -xfs_trans_t *tp,/* transaction pointer */ -xfs_inode_t *ip,/* incore inode pointer */ +struct xfs_trans *tp,/* transaction pointer */ +struct xfs_inode *ip,/* incore inode pointer */ xfs_fsblock_t *firstblock,/* first-block-allocated */ -struct xfs_defer_ops *dfops,/* blocks freed in xaction */ -xfs_btree_cur_t **curp,/* cursor returned to caller */ +struct xfs_btree_cur **curp,/* cursor returned to caller */ int wasdel,/* converting a delayed alloc */ int *logflagsp,/* inode logging flags */ int whichfork)/* data or attr fork */ {struct xfs_btree_block *ablock;/* allocated (child) bt block */ -xfs_buf_t *abp;/* buffer for ablock */ -xfs_alloc_arg_t args;/* allocation arguments */ -xfs_bmbt_rec_t *arp;/* child record pointer */ +struct xfs_buf *abp;/* buffer for ablock */ +struct xfs_alloc_arg args;/* allocation arguments */ +struct xfs_bmbt_rec *arp;/* child record pointer */ struct xfs_btree_block *block;/* btree root block */ -xfs_btree_cur_t *cur;/* bmap btree cursor */ +struct xfs_btree_cur *cur;/* bmap btree cursor */ int error;/* error return value */ -xfs_ifork_t *ifp;/* inode fork pointer */ -xfs_bmbt_key_t *kp;/* root block key pointer */ -xfs_mount_t *mp;/* mount structure */ +struct xfs_ifork *ifp;/* inode fork pointer */ +struct xfs_bmbt_key *kp;/* root block key pointer */ +struct xfs_mount *mp;/* mount structure */ xfs_bmbt_ptr_t *pp;/* root block address pointer */ struct xfs_iext_cursor icur;struct xfs_bmbt_irec rec;@@ -691,7 +690,7 @@ xfs_bmap_extents_to_btree(*/ cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = *firstblock; - cur->bc_private.b.dfops = dfops; + cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags = wasdel ?XFS_BTCUR_BPRV_WASDEL :0 ;/* * Convert to a btree with two levels, one record in root. @@ -705,7 +704,7 @@ xfs_bmap_extents_to_btree(if (*firstblock ==NULLFSBLOCK ) { args.type =XFS_ALLOCTYPE_START_BNO ; args.fsbno =XFS_INO_TO_FSB (mp, ip->i_ino); - }else if (dfops->dop_low) { + }else if (tp->t_dfops->dop_low) { args.type =XFS_ALLOCTYPE_START_BNO ; args.fsbno = *firstblock; }else {@@ -958,8 +957,8 @@ xfs_bmap_add_attrfork_btree(*/ STATIC int /* error */xfs_bmap_add_attrfork_extents ( -xfs_trans_t *tp,/* transaction pointer */ -xfs_inode_t *ip,/* incore inode pointer */ +struct xfs_trans *tp,/* transaction pointer */ +struct xfs_inode *ip,/* incore inode pointer */ xfs_fsblock_t *firstblock,/* first block allocated */ int *flags)/* inode logging flags */ {@@ -969,8 +968,8 @@ xfs_bmap_add_attrfork_extents(if (ip->i_d.di_nextents *sizeof (xfs_bmbt_rec_t) <=XFS_IFORK_DSIZE (ip))return 0 ; cur =NULL ; - error =xfs_bmap_extents_to_btree (tp, ip, firstblock, tp->t_dfops, &cur,0 , - flags,XFS_DATA_FORK ); + error =xfs_bmap_extents_to_btree (tp, ip, firstblock, &cur,0 , flags, +XFS_DATA_FORK );if (cur) { cur->bc_private.b.allocated =0 ; xfs_btree_del_cursor(cur,@@ -1806,8 +1805,8 @@ xfs_bmap_add_extent_delay_real(if (xfs_bmap_needs_btree (bma->ip, whichfork)) { error =xfs_bmap_extents_to_btree (bma->tp, bma->ip, - bma->firstblock, bma->tp->t_dfops, - &bma->cur,1 , &tmp_rval, whichfork); + bma->firstblock, &bma->cur,1 , + &tmp_rval, whichfork); rval |= tmp_rval;if (error) goto done;@@ -1884,8 +1883,8 @@ xfs_bmap_add_extent_delay_real(if (xfs_bmap_needs_btree (bma->ip, whichfork)) { error =xfs_bmap_extents_to_btree (bma->tp, bma->ip, - bma->firstblock, bma->tp->t_dfops, &bma->cur,1 , - &tmp_rval, whichfork); + bma->firstblock, &bma->cur,1 , &tmp_rval, + whichfork); rval |= tmp_rval;if (error) goto done;@@ -1965,8 +1964,8 @@ xfs_bmap_add_extent_delay_real(if (xfs_bmap_needs_btree (bma->ip, whichfork)) { error =xfs_bmap_extents_to_btree (bma->tp, bma->ip, - bma->firstblock, bma->tp->t_dfops, - &bma->cur,1 , &tmp_rval, whichfork); + bma->firstblock, &bma->cur,1 , + &tmp_rval, whichfork); rval |= tmp_rval;if (error) goto done;@@ -2003,8 +2002,8 @@ xfs_bmap_add_extent_delay_real(ASSERT (bma->cur ==NULL ); error =xfs_bmap_extents_to_btree (bma->tp, bma->ip, - bma->firstblock, bma->tp->t_dfops, &bma->cur, - da_old >0 , &tmp_logflags, whichfork); + bma->firstblock, &bma->cur, da_old >0 , + &tmp_logflags, whichfork); bma->logflags |= tmp_logflags;if (error) goto done;@@ -2044,7 +2043,6 @@ xfs_bmap_add_extent_unwritten_real( xfs_btree_cur_t **curp, /* if *curp is null, not a btree */ xfs_bmbt_irec_t *new, /* new data to add to file extents */ xfs_fsblock_t *first, /* pointer to firstblock variable */ - struct xfs_defer_ops *dfops, /* list of extents to be freed */ int *logflagsp) /* inode logging flags */ {xfs_btree_cur_t *cur;/* btree cursor */ @@ -2058,6 +2056,7 @@ xfs_bmap_add_extent_unwritten_real(int state =xfs_bmap_fork_to_state (whichfork);struct xfs_mount *mp = ip->i_mount;struct xfs_bmbt_irec old; +struct xfs_defer_ops *dfops = tp ? tp->t_dfops :NULL ; *logflagsp =0 ;@@ -2485,8 +2484,8 @@ xfs_bmap_add_extent_unwritten_real(int tmp_logflags;/* partial log flag return val */ ASSERT (cur ==NULL ); - error =xfs_bmap_extents_to_btree (tp, ip, first, dfops, &cur, -0 , &tmp_logflags, whichfork); + error =xfs_bmap_extents_to_btree (tp, ip, first, &cur,0 , + &tmp_logflags, whichfork); *logflagsp |= tmp_logflags;if (error) goto done;@@ -2658,7 +2657,6 @@ xfs_bmap_add_extent_hole_real(struct xfs_btree_cur **curp, struct xfs_bmbt_irec *new, xfs_fsblock_t *first, - struct xfs_defer_ops *dfops, int *logflagsp, int flags) {@@ -2839,7 +2837,8 @@ xfs_bmap_add_extent_hole_real(/* add reverse mapping unless caller opted out */ if (!(flags &XFS_BMAPI_NORMAP )) { - error =xfs_rmap_map_extent (mp, dfops, ip, whichfork, new); + error =xfs_rmap_map_extent (mp, tp->t_dfops, ip, whichfork, + new);if (error) goto done; }@@ -2849,8 +2848,8 @@ xfs_bmap_add_extent_hole_real(int tmp_logflags;/* partial log flag return val */ ASSERT (cur ==NULL ); - error =xfs_bmap_extents_to_btree (tp, ip, first, dfops, curp, -0 , &tmp_logflags, whichfork); + error =xfs_bmap_extents_to_btree (tp, ip, first, curp,0 , + &tmp_logflags, whichfork); *logflagsp |= tmp_logflags; cur = *curp;if (error)@@ -4119,8 +4118,7 @@ xfs_bmapi_allocate(else error =xfs_bmap_add_extent_hole_real (bma->tp, bma->ip, whichfork, &bma->icur, &bma->cur, &bma->got, - bma->firstblock, bma->tp->t_dfops, - &bma->logflags, bma->flags); + bma->firstblock, &bma->logflags, bma->flags); bma->logflags |= tmp_logflags;if (error)@@ -4190,7 +4188,7 @@ xfs_bmapi_convert_unwritten( error =xfs_bmap_add_extent_unwritten_real (bma->tp, bma->ip, whichfork, &bma->icur, &bma->cur, mval, bma->firstblock, - bma->tp->t_dfops, &tmp_logflags); + &tmp_logflags);/* * Log the inode core unconditionally in the unwritten extent conversion * path because the conversion might not have done so (e.g., if the @@ -4575,7 +4573,7 @@ xfs_bmapi_remap( got.br_state =XFS_EXT_NORM ; error =xfs_bmap_add_extent_hole_real (tp, ip, whichfork, &icur, - &cur, &got, &firstblock, tp->t_dfops, &logflags, flags); + &cur, &got, &firstblock, &logflags, flags);if (error) goto error0;@@ -4894,7 +4892,6 @@ xfs_bmap_del_extent_real( xfs_inode_t *ip,/* incore inode pointer */ xfs_trans_t *tp,/* current transaction pointer */ struct xfs_iext_cursor *icur, - struct xfs_defer_ops *dfops, /* list of extents to be freed */ xfs_btree_cur_t *cur,/* if null, not a btree */ xfs_bmbt_irec_t *del,/* data to remove from extents */ int *logflagsp, /* inode logging flags */@@ -4917,6 +4914,7 @@ xfs_bmap_del_extent_real(uint qfield;/* quota field to update */ int state =xfs_bmap_fork_to_state (whichfork);struct xfs_bmbt_irec old; +struct xfs_defer_ops *dfops = tp ? tp->t_dfops :NULL ; mp = ip->i_mount;XFS_STATS_INC (mp, xs_del_exlist);@@ -5343,7 +5341,7 @@ __xfs_bunmapi( del.br_state =XFS_EXT_UNWRITTEN ; error =xfs_bmap_add_extent_unwritten_real (tp, ip, whichfork, &icur, &cur, &del, - firstblock, dfops, &logflags); + firstblock, &logflags);if (error) goto error0; goto nodelete;@@ -5400,8 +5398,7 @@ __xfs_bunmapi( prev.br_state =XFS_EXT_UNWRITTEN ; error =xfs_bmap_add_extent_unwritten_real (tp, ip, whichfork, &icur, &cur, - &prev, firstblock, dfops, - &logflags); + &prev, firstblock, &logflags);if (error) goto error0; goto nodelete;@@ -5410,8 +5407,7 @@ __xfs_bunmapi( del.br_state =XFS_EXT_UNWRITTEN ; error =xfs_bmap_add_extent_unwritten_real (tp, ip, whichfork, &icur, &cur, - &del, firstblock, dfops, - &logflags); + &del, firstblock, &logflags);if (error) goto error0; goto nodelete;@@ -5423,8 +5419,8 @@ __xfs_bunmapi( error =xfs_bmap_del_extent_delay (ip, whichfork, &icur, &got, &del); }else { - error =xfs_bmap_del_extent_real (ip, tp, &icur, dfops, - cur, &del, &tmp_logflags, whichfork, + error =xfs_bmap_del_extent_real (ip, tp, &icur, cur, + &del, &tmp_logflags, whichfork, flags); logflags |= tmp_logflags; }@@ -5458,8 +5454,8 @@ __xfs_bunmapi(*/ if (xfs_bmap_needs_btree (ip, whichfork)) {ASSERT (cur ==NULL ); - error =xfs_bmap_extents_to_btree (tp, ip, firstblock, dfops, - &cur,0 , &tmp_logflags, whichfork); + error =xfs_bmap_extents_to_btree (tp, ip, firstblock, &cur,0 , + &tmp_logflags, whichfork); logflags |= tmp_logflags;if (error) goto error0;@@ -6009,8 +6005,8 @@ xfs_bmap_split_extent_at(int tmp_logflags;/* partial log flag return val */ ASSERT (cur ==NULL ); - error =xfs_bmap_extents_to_btree (tp, ip, firstfsb, tp->t_dfops, - &cur,0 , &tmp_logflags, whichfork); + error =xfs_bmap_extents_to_btree (tp, ip, firstfsb, &cur,0 , + &tmp_logflags, whichfork); logflags |= tmp_logflags; }Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 19/24 xfs: remove xfs_btree_cur bmbt dfops field
In reply to Brian FosterAll assignments of xfs_btree_cur.bc_private.b.dfops originate from ->t_dfops. Replace accesses of the former with the latter and remove the unnecessary field. This patch does not change behavior.
--- fs/xfs/libxfs/xfs_bmap.c | 12 +----------- fs/xfs/libxfs/xfs_bmap_btree.c | 9 +++------ fs/xfs/libxfs/xfs_btree.h | 1 - 3 files changed, 4 insertions(+), 18 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +1 -11
@@ -624,7 +624,7 @@ xfs_bmap_btree_to_extents(if ((error =xfs_btree_check_block (cur, cblock,0 , cbp)))return error;xfs_rmap_ino_bmbt_owner (&oinfo, ip->i_ino, whichfork); -xfs_bmap_add_free (mp, cur->bc_private.b.dfops, cbno,1 , &oinfo); +xfs_bmap_add_free (mp, cur->bc_tp->t_dfops, cbno,1 , &oinfo); ip->i_d.di_nblocks--;xfs_trans_mod_dquot_byino (tp, ip,XFS_TRANS_DQ_BCOUNT ,-1L );xfs_trans_binval (tp, cbp);
@@ -690,7 +690,6 @@ xfs_bmap_extents_to_btree(*/ cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = *firstblock; - cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags = wasdel ?XFS_BTCUR_BPRV_WASDEL :0 ;/* * Convert to a btree with two levels, one record in root.
@@ -929,7 +928,6 @@ xfs_bmap_add_attrfork_btree( *flags |=XFS_ILOG_DBROOT ; else { cur =xfs_bmbt_init_cursor (mp, tp, ip,XFS_DATA_FORK ); - cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.firstblock = *firstblock; error =xfs_bmbt_lookup_first (cur, &stat);if (error)
@@ -4082,7 +4080,6 @@ xfs_bmapi_allocate(if ((ifp->if_flags &XFS_IFBROOT ) && !bma->cur) { bma->cur =xfs_bmbt_init_cursor (mp, bma->tp, bma->ip, whichfork); bma->cur->bc_private.b.firstblock = *bma->firstblock; - bma->cur->bc_private.b.dfops = bma->tp->t_dfops; }/* * Bump the number of extents we've allocated
@@ -4170,7 +4167,6 @@ xfs_bmapi_convert_unwritten( bma->cur =xfs_bmbt_init_cursor (bma->ip->i_mount, bma->tp, bma->ip, whichfork); bma->cur->bc_private.b.firstblock = *bma->firstblock; - bma->cur->bc_private.b.dfops = bma->tp->t_dfops; } mval->br_state = (mval->br_state ==XFS_EXT_UNWRITTEN ) ?XFS_EXT_NORM :XFS_EXT_UNWRITTEN ;
@@ -4560,7 +4556,6 @@ xfs_bmapi_remap(if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = firstblock; - cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags =0 ; }
@@ -5151,7 +5146,6 @@ __xfs_bunmapi( xfs_fsblock_t *firstblock) /* first allocated blockcontrols a.g. for allocs */ { -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 */
@@ -5225,7 +5219,6 @@ __xfs_bunmapi(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.dfops = dfops; cur->bc_private.b.flags =0 ; }else cur =NULL ;
@@ -5715,7 +5708,6 @@ xfs_bmap_collapse_extents(if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = *firstblock; - cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags =0 ; }
@@ -5837,7 +5829,6 @@ xfs_bmap_insert_extents(if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = *firstblock; - cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags =0 ; }
@@ -5961,7 +5952,6 @@ xfs_bmap_split_extent_at(if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = *firstfsb; - cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags =0 ; error =xfs_bmbt_lookup_eq (cur, &got, &i);if (error)
fs/xfs/libxfs/xfs_bmap_btree.c +3 -6
@@ -176,7 +176,6 @@ xfs_bmbt_dup_cursor(* since init cursor doesn't get them. */ new->bc_private.b.firstblock = cur->bc_private.b.firstblock; - new->bc_private.b.dfops = cur->bc_private.b.dfops; new->bc_private.b.flags = cur->bc_private.b.flags;return new;
@@ -189,7 +188,6 @@ xfs_bmbt_update_cursor( {ASSERT ((dst->bc_private.b.firstblock !=NULLFSBLOCK ) || (dst->bc_private.b.ip->i_d.di_flags &XFS_DIFLAG_REALTIME )); -ASSERT (dst->bc_private.b.dfops == src->bc_private.b.dfops); dst->bc_private.b.allocated += src->bc_private.b.allocated; dst->bc_private.b.firstblock = src->bc_private.b.firstblock;
@@ -230,7 +228,7 @@ xfs_bmbt_alloc_block(* block allocation here and corrupt the filesystem. */ args.minleft = args.tp->t_blk_res; - }else if (cur->bc_private.b.dfops->dop_low) { + }else if (cur->bc_tp->t_dfops->dop_low) { args.type =XFS_ALLOCTYPE_START_BNO ; }else { args.type =XFS_ALLOCTYPE_NEAR_BNO ;
@@ -257,7 +255,7 @@ xfs_bmbt_alloc_block( error =xfs_alloc_vextent (&args);if (error) goto error0; - cur->bc_private.b.dfops->dop_low = true; + cur->bc_tp->t_dfops->dop_low = true; }if (WARN_ON_ONCE (args.fsbno ==NULLFSBLOCK )) { *stat =0 ;
@@ -293,7 +291,7 @@ xfs_bmbt_free_block(struct xfs_owner_info oinfo;xfs_rmap_ino_bmbt_owner (&oinfo, ip->i_ino, cur->bc_private.b.whichfork); -xfs_bmap_add_free (mp, cur->bc_private.b.dfops, fsbno,1 , &oinfo); +xfs_bmap_add_free (mp, cur->bc_tp->t_dfops, fsbno,1 , &oinfo); ip->i_d.di_nblocks--;xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE );
@@ -565,7 +563,6 @@ xfs_bmbt_init_cursor( cur->bc_private.b.forksize =XFS_IFORK_SIZE (ip, whichfork); cur->bc_private.b.ip = ip; cur->bc_private.b.firstblock =NULLFSBLOCK ; - cur->bc_private.b.dfops =NULL ; cur->bc_private.b.allocated =0 ; cur->bc_private.b.flags =0 ; cur->bc_private.b.whichfork = whichfork;
fs/xfs/libxfs/xfs_btree.h +0 -1
@@ -215,7 +215,6 @@ typedef struct xfs_btree_cur } a;struct {/* needed for BMAP */ struct xfs_inode *ip;/* pointer to our inode */ -struct xfs_defer_ops *dfops;/* deferred updates */ xfs_fsblock_t firstblock;/* 1st blk allocated */ int allocated;/* count of alloced */ short forksize;/* fork's inode space */
Signature · 1 line
2.17.1
Re: [PATCH 19/24] xfs: remove xfs_btree_cur bmbt dfops field
Quoted 5 lines · Brian Foster
All assignments of xfs_btree_cur.bc_private.b.dfops originate from ->t_dfops. Replace accesses of the former with the latter and remove the unnecessary field. This patch does not change behavior.
Signed-off-by Brian Foster <[email protected]>
Looks good,
Re: [PATCH 19/24] xfs: remove xfs_btree_cur bmbt dfops field
In reply to Brian FosterQuoted 5 lines · Brian Foster
All assignments of xfs_btree_cur.bc_private.b.dfops originate from ->t_dfops. Replace accesses of the former with the latter and remove the unnecessary field. This patch does not change behavior.
Signed-off-by Brian Foster <[email protected]>
Looks ok,
--D
Quoted 173 lines
--- fs/xfs/libxfs/xfs_bmap.c | 12 +----------- fs/xfs/libxfs/xfs_bmap_btree.c | 9 +++------ fs/xfs/libxfs/xfs_btree.h | 1 - 3 files changed, 4 insertions(+), 18 deletions(-)fs/xfs/libxfs/xfs_bmap.c +1
-11@@ -624,7 +624,7 @@ xfs_bmap_btree_to_extents(if ((error =xfs_btree_check_block (cur, cblock,0 , cbp)))return error;xfs_rmap_ino_bmbt_owner (&oinfo, ip->i_ino, whichfork); -xfs_bmap_add_free (mp, cur->bc_private.b.dfops, cbno,1 , &oinfo); +xfs_bmap_add_free (mp, cur->bc_tp->t_dfops, cbno,1 , &oinfo); ip->i_d.di_nblocks--;xfs_trans_mod_dquot_byino (tp, ip,XFS_TRANS_DQ_BCOUNT ,-1L );xfs_trans_binval (tp, cbp);@@ -690,7 +690,6 @@ xfs_bmap_extents_to_btree(*/ cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = *firstblock; - cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags = wasdel ?XFS_BTCUR_BPRV_WASDEL :0 ;/* * Convert to a btree with two levels, one record in root. @@ -929,7 +928,6 @@ xfs_bmap_add_attrfork_btree( *flags |=XFS_ILOG_DBROOT ; else { cur =xfs_bmbt_init_cursor (mp, tp, ip,XFS_DATA_FORK ); - cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.firstblock = *firstblock; error =xfs_bmbt_lookup_first (cur, &stat);if (error)@@ -4082,7 +4080,6 @@ xfs_bmapi_allocate(if ((ifp->if_flags &XFS_IFBROOT ) && !bma->cur) { bma->cur =xfs_bmbt_init_cursor (mp, bma->tp, bma->ip, whichfork); bma->cur->bc_private.b.firstblock = *bma->firstblock; - bma->cur->bc_private.b.dfops = bma->tp->t_dfops; }/* * Bump the number of extents we've allocated @@ -4170,7 +4167,6 @@ xfs_bmapi_convert_unwritten( bma->cur =xfs_bmbt_init_cursor (bma->ip->i_mount, bma->tp, bma->ip, whichfork); bma->cur->bc_private.b.firstblock = *bma->firstblock; - bma->cur->bc_private.b.dfops = bma->tp->t_dfops; } mval->br_state = (mval->br_state ==XFS_EXT_UNWRITTEN ) ?XFS_EXT_NORM :XFS_EXT_UNWRITTEN ;@@ -4560,7 +4556,6 @@ xfs_bmapi_remap(if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = firstblock; - cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags =0 ; }@@ -5151,7 +5146,6 @@ __xfs_bunmapi( xfs_fsblock_t *firstblock) /* first allocated blockcontrols a.g. for allocs */ { -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 */ @@ -5225,7 +5219,6 @@ __xfs_bunmapi(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.dfops = dfops; cur->bc_private.b.flags =0 ; }else cur =NULL ;@@ -5715,7 +5708,6 @@ xfs_bmap_collapse_extents(if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = *firstblock; - cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags =0 ; }@@ -5837,7 +5829,6 @@ xfs_bmap_insert_extents(if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = *firstblock; - cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags =0 ; }@@ -5961,7 +5952,6 @@ xfs_bmap_split_extent_at(if (ifp->if_flags &XFS_IFBROOT ) { cur =xfs_bmbt_init_cursor (mp, tp, ip, whichfork); cur->bc_private.b.firstblock = *firstfsb; - cur->bc_private.b.dfops = tp->t_dfops; cur->bc_private.b.flags =0 ; error =xfs_bmbt_lookup_eq (cur, &got, &i);if (error)fs/xfs/libxfs/xfs_bmap_btree.c +3
-6@@ -176,7 +176,6 @@ xfs_bmbt_dup_cursor(* since init cursor doesn't get them. */ new->bc_private.b.firstblock = cur->bc_private.b.firstblock; - new->bc_private.b.dfops = cur->bc_private.b.dfops; new->bc_private.b.flags = cur->bc_private.b.flags;return new;@@ -189,7 +188,6 @@ xfs_bmbt_update_cursor( {ASSERT ((dst->bc_private.b.firstblock !=NULLFSBLOCK ) || (dst->bc_private.b.ip->i_d.di_flags &XFS_DIFLAG_REALTIME )); -ASSERT (dst->bc_private.b.dfops == src->bc_private.b.dfops); dst->bc_private.b.allocated += src->bc_private.b.allocated; dst->bc_private.b.firstblock = src->bc_private.b.firstblock;@@ -230,7 +228,7 @@ xfs_bmbt_alloc_block(* block allocation here and corrupt the filesystem. */ args.minleft = args.tp->t_blk_res; - }else if (cur->bc_private.b.dfops->dop_low) { + }else if (cur->bc_tp->t_dfops->dop_low) { args.type =XFS_ALLOCTYPE_START_BNO ; }else { args.type =XFS_ALLOCTYPE_NEAR_BNO ;@@ -257,7 +255,7 @@ xfs_bmbt_alloc_block( error =xfs_alloc_vextent (&args);if (error) goto error0; - cur->bc_private.b.dfops->dop_low = true; + cur->bc_tp->t_dfops->dop_low = true; }if (WARN_ON_ONCE (args.fsbno ==NULLFSBLOCK )) { *stat =0 ;@@ -293,7 +291,7 @@ xfs_bmbt_free_block(struct xfs_owner_info oinfo;xfs_rmap_ino_bmbt_owner (&oinfo, ip->i_ino, cur->bc_private.b.whichfork); -xfs_bmap_add_free (mp, cur->bc_private.b.dfops, fsbno,1 , &oinfo); +xfs_bmap_add_free (mp, cur->bc_tp->t_dfops, fsbno,1 , &oinfo); ip->i_d.di_nblocks--;xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE );@@ -565,7 +563,6 @@ xfs_bmbt_init_cursor( cur->bc_private.b.forksize =XFS_IFORK_SIZE (ip, whichfork); cur->bc_private.b.ip = ip; cur->bc_private.b.firstblock =NULLFSBLOCK ; - cur->bc_private.b.dfops =NULL ; cur->bc_private.b.allocated =0 ; cur->bc_private.b.flags =0 ; cur->bc_private.b.whichfork = whichfork;fs/xfs/libxfs/xfs_btree.h +0
-1@@ -215,7 +215,6 @@ typedef struct xfs_btree_cur } a;struct {/* needed for BMAP */ struct xfs_inode *ip;/* pointer to our inode */ -struct xfs_defer_ops *dfops;/* deferred updates */ xfs_fsblock_t firstblock;/* 1st blk allocated */ int allocated;/* count of alloced */ short forksize;/* fork's inode space */ Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 20/24 xfs: remove unused btree cursor bc_private.a.dfops field
In reply to Brian FosterThe xfs_btree_cur.bc_private.a.dfops field is only ever initialized by the refcountbt cursor init function. The only caller of that function with a non-NULL dfops is from deferred completion context, which already has attached to ->t_dfops.
In addition to that, the only actual reference of a.dfops is the cursor duplication function, which means the field is effectively unused.
Remove the dfops field from the bc_private.a union. Any future users can acquire the dfops from the transaction. This patch does not change behavior.
--- fs/xfs/libxfs/xfs_btree.h | 1 - fs/xfs/libxfs/xfs_refcount.c | 4 ++-- fs/xfs/libxfs/xfs_refcount_btree.c | 7 ++----- fs/xfs/libxfs/xfs_refcount_btree.h | 4 ++-- fs/xfs/scrub/common.c | 2 +- fs/xfs/xfs_fsmap.c | 2 +- fs/xfs/xfs_reflink.c | 2 +- 7 files changed, 9 insertions(+), 13 deletions(-)
fs/xfs/libxfs/xfs_btree.h +0 -1
@@ -209,7 +209,6 @@ typedef struct xfs_btree_curunion {struct {/* needed for BNO, CNT, INO */ struct xfs_buf *agbp;/* agf/agi buffer pointer */ -struct xfs_defer_ops *dfops;/* deferred updates */ xfs_agnumber_t agno;/* ag number */ union xfs_btree_cur_private priv; } a;
fs/xfs/libxfs/xfs_refcount.c +2 -2
@@ -1132,7 +1132,7 @@ xfs_refcount_finish_one(if (!agbp)return -EFSCORRUPTED ; - rcur =xfs_refcountbt_init_cursor (mp, tp, agbp, agno, dfops); + rcur =xfs_refcountbt_init_cursor (mp, tp, agbp, agno);if (!rcur) { error = -ENOMEM ; goto out_cur;
@@ -1666,7 +1666,7 @@ xfs_refcount_recover_cow_leftovers( error = -ENOMEM ; goto out_trans; } - cur =xfs_refcountbt_init_cursor (mp, tp, agbp, agno,NULL ); + cur =xfs_refcountbt_init_cursor (mp, tp, agbp, agno);/* Find all the leftover CoW staging extents. */ memset (&low,0 ,sizeof (low));
fs/xfs/libxfs/xfs_refcount_btree.c +2 -5
@@ -27,8 +27,7 @@ xfs_refcountbt_dup_cursor( struct xfs_btree_cur *cur) {return xfs_refcountbt_init_cursor (cur->bc_mp, cur->bc_tp, - cur->bc_private.a.agbp, cur->bc_private.a.agno, - cur->bc_private.a.dfops); + cur->bc_private.a.agbp, cur->bc_private.a.agno); }STATIC void
@@ -323,8 +322,7 @@ xfs_refcountbt_init_cursor(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buf *agbp, - xfs_agnumber_t agno, - struct xfs_defer_ops *dfops) + xfs_agnumber_t agno) { struct xfs_agf *agf = XFS_BUF_TO_AGF(agbp);struct xfs_btree_cur *cur;
@@ -344,7 +342,6 @@ xfs_refcountbt_init_cursor( cur->bc_private.a.agbp = agbp; cur->bc_private.a.agno = agno; - cur->bc_private.a.dfops = dfops; cur->bc_flags |=XFS_BTREE_CRC_BLOCKS ; cur->bc_private.a.priv.refc.nr_ops =0 ;
fs/xfs/libxfs/xfs_refcount_btree.h +2 -2
@@ -44,8 +44,8 @@ struct xfs_mount; ((index) - 1) * sizeof(xfs_refcount_ptr_t)))extern struct xfs_btree_cur *xfs_refcountbt_init_cursor (struct xfs_mount *mp, -struct xfs_trans *tp,struct xfs_buf *agbp,xfs_agnumber_t agno, -struct xfs_defer_ops *dfops); +struct xfs_trans *tp,struct xfs_buf *agbp, +xfs_agnumber_t agno);extern int xfs_refcountbt_maxrecs (int blocklen,bool leaf);extern void xfs_refcountbt_compute_maxlevels (struct xfs_mount *mp);
fs/xfs/scrub/common.c +1 -1
@@ -499,7 +499,7 @@ xfs_scrub_ag_btcur_init(/* Set up a refcountbt cursor for cross-referencing. */ if (sa->agf_bp &&xfs_sb_version_hasreflink (&mp->m_sb)) { sa->refc_cur =xfs_refcountbt_init_cursor (mp, sc->tp, - sa->agf_bp, agno,NULL ); + sa->agf_bp, agno);if (!sa->refc_cur) goto err; }
fs/xfs/xfs_fsmap.c +1 -1
@@ -214,7 +214,7 @@ xfs_getfsmap_is_shared(/* Are there any shared blocks here? */ flen =0 ; cur =xfs_refcountbt_init_cursor (mp, tp, info->agf_bp, - info->agno,NULL ); + info->agno); error =xfs_refcount_find_shared (cur, rec->rm_startblock, rec->rm_blockcount, &fbno, &flen, false);
fs/xfs/xfs_reflink.c +1 -1
@@ -157,7 +157,7 @@ xfs_reflink_find_shared(if (!agbp)return -ENOMEM ; - cur =xfs_refcountbt_init_cursor (mp, tp, agbp, agno,NULL ); + cur =xfs_refcountbt_init_cursor (mp, tp, agbp, agno); error =xfs_refcount_find_shared (cur, agbno, aglen, fbno, flen, find_end_of_shared);
Signature · 1 line
2.17.1
Re: [PATCH 20/24] xfs: remove unused btree cursor bc_private.a.dfops field
Quoted 5 lines · Brian Foster
The xfs_btree_cur.bc_private.a.dfops field is only ever initialized by the refcountbt cursor init function. The only caller of that function with a non-NULL dfops is from deferred completion context, which already has attached to ->t_dfops.
Quoted 7 lines
In addition to that, the only actual reference of a.dfops is the cursor duplication function, which means the field is effectively unused.
Remove the dfops field from the bc_private.a union. Any future users can acquire the dfops from the transaction. This patch does not change behavior.
Looks good,
Re: [PATCH 20/24] xfs: remove unused btree cursor bc_private.a.dfops field
In reply to Brian FosterQuoted 9 lines · Brian Foster
The xfs_btree_cur.bc_private.a.dfops field is only ever initialized by the refcountbt cursor init function. The only caller of that function with a non-NULL dfops is from deferred completion context, which already has attached to ->t_dfops.
In addition to that, the only actual reference of a.dfops is the cursor duplication function, which means the field is effectively unused.
Quoted 5 lines
Remove the dfops field from the bc_private.a union. Any future users can acquire the dfops from the transaction. This patch does not change behavior.
Signed-off-by Brian Foster <[email protected]>
IIRC that unused dfops was a leftover artifact of preparing for inode-rooted refcount btrees for the realtime device, but I can always add it back in whenever I get back to working on that.
--D
Quoted 137 lines
--- fs/xfs/libxfs/xfs_btree.h | 1 - fs/xfs/libxfs/xfs_refcount.c | 4 ++-- fs/xfs/libxfs/xfs_refcount_btree.c | 7 ++----- fs/xfs/libxfs/xfs_refcount_btree.h | 4 ++-- fs/xfs/scrub/common.c | 2 +- fs/xfs/xfs_fsmap.c | 2 +- fs/xfs/xfs_reflink.c | 2 +- 7 files changed, 9 insertions(+), 13 deletions(-)fs/xfs/libxfs/xfs_btree.h +0
-1@@ -209,7 +209,6 @@ typedef struct xfs_btree_curunion {struct {/* needed for BNO, CNT, INO */ struct xfs_buf *agbp;/* agf/agi buffer pointer */ -struct xfs_defer_ops *dfops;/* deferred updates */ xfs_agnumber_t agno;/* ag number */ union xfs_btree_cur_private priv; } a;fs/xfs/libxfs/xfs_refcount.c +2
-2@@ -1132,7 +1132,7 @@ xfs_refcount_finish_one(if (!agbp)return -EFSCORRUPTED ; - rcur =xfs_refcountbt_init_cursor (mp, tp, agbp, agno, dfops); + rcur =xfs_refcountbt_init_cursor (mp, tp, agbp, agno);if (!rcur) { error = -ENOMEM ; goto out_cur;@@ -1666,7 +1666,7 @@ xfs_refcount_recover_cow_leftovers( error = -ENOMEM ; goto out_trans; } - cur =xfs_refcountbt_init_cursor (mp, tp, agbp, agno,NULL ); + cur =xfs_refcountbt_init_cursor (mp, tp, agbp, agno);/* Find all the leftover CoW staging extents. */ memset (&low,0 ,sizeof (low));fs/xfs/libxfs/xfs_refcount_btree.c +2
-5@@ -27,8 +27,7 @@ xfs_refcountbt_dup_cursor( struct xfs_btree_cur *cur) {return xfs_refcountbt_init_cursor (cur->bc_mp, cur->bc_tp, - cur->bc_private.a.agbp, cur->bc_private.a.agno, - cur->bc_private.a.dfops); + cur->bc_private.a.agbp, cur->bc_private.a.agno); }STATIC void@@ -323,8 +322,7 @@ xfs_refcountbt_init_cursor(struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buf *agbp, - xfs_agnumber_t agno, - struct xfs_defer_ops *dfops) + xfs_agnumber_t agno) { struct xfs_agf *agf = XFS_BUF_TO_AGF(agbp);struct xfs_btree_cur *cur;@@ -344,7 +342,6 @@ xfs_refcountbt_init_cursor( cur->bc_private.a.agbp = agbp; cur->bc_private.a.agno = agno; - cur->bc_private.a.dfops = dfops; cur->bc_flags |=XFS_BTREE_CRC_BLOCKS ; cur->bc_private.a.priv.refc.nr_ops =0 ;fs/xfs/libxfs/xfs_refcount_btree.h +2
-2@@ -44,8 +44,8 @@ struct xfs_mount; ((index) - 1) * sizeof(xfs_refcount_ptr_t)))extern struct xfs_btree_cur *xfs_refcountbt_init_cursor (struct xfs_mount *mp, -struct xfs_trans *tp,struct xfs_buf *agbp,xfs_agnumber_t agno, -struct xfs_defer_ops *dfops); +struct xfs_trans *tp,struct xfs_buf *agbp, +xfs_agnumber_t agno);extern int xfs_refcountbt_maxrecs (int blocklen,bool leaf);extern void xfs_refcountbt_compute_maxlevels (struct xfs_mount *mp);fs/xfs/scrub/common.c +1
-1@@ -499,7 +499,7 @@ xfs_scrub_ag_btcur_init(/* Set up a refcountbt cursor for cross-referencing. */ if (sa->agf_bp &&xfs_sb_version_hasreflink (&mp->m_sb)) { sa->refc_cur =xfs_refcountbt_init_cursor (mp, sc->tp, - sa->agf_bp, agno,NULL ); + sa->agf_bp, agno);if (!sa->refc_cur) goto err; }fs/xfs/xfs_fsmap.c +1
-1@@ -214,7 +214,7 @@ xfs_getfsmap_is_shared(/* Are there any shared blocks here? */ flen =0 ; cur =xfs_refcountbt_init_cursor (mp, tp, info->agf_bp, - info->agno,NULL ); + info->agno); error =xfs_refcount_find_shared (cur, rec->rm_startblock, rec->rm_blockcount, &fbno, &flen, false);fs/xfs/xfs_reflink.c +1
-1@@ -157,7 +157,7 @@ xfs_reflink_find_shared(if (!agbp)return -ENOMEM ; - cur =xfs_refcountbt_init_cursor (mp, tp, agbp, agno,NULL ); + cur =xfs_refcountbt_init_cursor (mp, tp, agbp, agno); error =xfs_refcount_find_shared (cur, agbno, aglen, fbno, flen, find_end_of_shared);Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 21/24 xfs: use ->t_dfops for rmap extent swap operations
In reply to Brian Fosterxfs_swap_extent_rmap() uses a local dfops instance with a transaction from the caller. Since there is only one caller, pull the dfops structure into the caller and attach it to the transaction. This avoids the need to clear ->t_dfops to prevent invalid stack memory access.
--- fs/xfs/xfs_bmap_util.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-)
fs/xfs/xfs_bmap_util.c +19 -13
@@ -1570,6 +1570,8 @@ xfs_swap_extent_rmap(struct xfs_inode *ip, struct xfs_inode *tip) { + struct xfs_trans *tp = *tpp; +struct xfs_mount *mp = tp->t_mountp;struct xfs_bmbt_irec irec;struct xfs_bmbt_irec uirec;struct xfs_bmbt_irec tirec;
@@ -1577,7 +1579,6 @@ xfs_swap_extent_rmap(xfs_fileoff_t end_fsb;xfs_filblks_t count_fsb;xfs_fsblock_t firstfsb; -struct xfs_defer_ops dfops;int error;xfs_filblks_t ilen;xfs_filblks_t rlen;
@@ -1613,7 +1614,7 @@ xfs_swap_extent_rmap(/* Unmap the old blocks in the source file. */ while (tirec.br_blockcount) { -xfs_defer_init (&dfops, &firstfsb); +xfs_defer_init (tp->t_dfops, &firstfsb);trace_xfs_swap_extent_rmap_remap_piece (tip, &tirec);/* Read extent from the source file */
@@ -1635,31 +1636,32 @@ xfs_swap_extent_rmap(trace_xfs_swap_extent_rmap_remap_piece (tip, &uirec);/* Remove the mapping from the donor file. */ - error =xfs_bmap_unmap_extent ((*tpp)->t_mountp, &dfops, - tip, &uirec); + error =xfs_bmap_unmap_extent (mp, tp->t_dfops, tip, + &uirec);if (error) goto out_defer;/* Remove the mapping from the source file. */ - error =xfs_bmap_unmap_extent ((*tpp)->t_mountp, &dfops, - ip, &irec); + error =xfs_bmap_unmap_extent (mp, tp->t_dfops, ip, + &irec);if (error) goto out_defer;/* Map the donor file's blocks into the source file. */ - error =xfs_bmap_map_extent ((*tpp)->t_mountp, &dfops, - ip, &uirec); + error =xfs_bmap_map_extent (mp, tp->t_dfops, ip, + &uirec);if (error) goto out_defer;/* Map the source file's blocks into the donor file. */ - error =xfs_bmap_map_extent ((*tpp)->t_mountp, &dfops, - tip, &irec); + error =xfs_bmap_map_extent (mp, tp->t_dfops, tip, + &irec);if (error) goto out_defer; -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (tpp, &dfops); +xfs_defer_ijoin (tp->t_dfops, ip); + error =xfs_defer_finish (tpp, tp->t_dfops); + tp = *tpp;if (error) goto out_defer;
@@ -1679,7 +1681,7 @@ xfs_swap_extent_rmap(return 0 ; out_defer: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out:trace_xfs_swap_extent_rmap_error (ip, error, _RET_IP_); tip->i_d.di_flags2 = tip_flags2;
@@ -1846,6 +1848,7 @@ xfs_swap_extents( {struct xfs_mount *mp = ip->i_mount;struct xfs_trans *tp; +struct xfs_defer_ops dfops;struct xfs_bstat *sbp = &sxp->sx_stat;int src_log_flags, target_log_flags;int error =0 ;
@@ -1853,6 +1856,7 @@ xfs_swap_extents(struct xfs_ifork *cowfp;uint64_t f;int resblks =0 ; +xfs_fsblock_t firstfsb;/* * Lock the inodes against other IO, page faults and truncate to
@@ -1915,6 +1919,8 @@ xfs_swap_extents( error =xfs_trans_alloc (mp, &M_RES (mp)->tr_write, resblks,0 ,0 , &tp);if (error) goto out_unlock; +xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops;/* * Lock and join the inodes to the tansaction so that transaction commit
Signature · 1 line
2.17.1
Re: [PATCH 21/24] xfs: use ->t_dfops for rmap extent swap operations
Quoted 7 lines · Brian Foster
xfs_swap_extent_rmap()uses a local dfops instance with a transaction from the caller. Since there is only one caller, pull the dfops structure into the caller and attach it to the transaction. This avoids the need to clear ->t_dfops to prevent invalid stack memory access.Signed-off-by Brian Foster <[email protected]>
Looks good,
Re: [PATCH 21/24] xfs: use ->t_dfops for rmap extent swap operations
In reply to Brian FosterQuoted 110 lines · Brian Foster
xfs_swap_extent_rmap()uses a local dfops instance with a transaction from the caller. Since there is only one caller, pull the dfops structure into the caller and attach it to the transaction. This avoids the need to clear ->t_dfops to prevent invalid stack memory access.Signed-off-by Brian Foster <[email protected]>--- fs/xfs/xfs_bmap_util.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-)fs/xfs/xfs_bmap_util.c +17
-13@@ -1570,6 +1570,8 @@ xfs_swap_extent_rmap(struct xfs_inode *ip, struct xfs_inode *tip) { + struct xfs_trans *tp = *tpp; +struct xfs_mount *mp = tp->t_mountp;struct xfs_bmbt_irec irec;struct xfs_bmbt_irec uirec;struct xfs_bmbt_irec tirec;@@ -1577,7 +1579,6 @@ xfs_swap_extent_rmap(xfs_fileoff_t end_fsb;xfs_filblks_t count_fsb;xfs_fsblock_t firstfsb; -struct xfs_defer_ops dfops;int error;xfs_filblks_t ilen;xfs_filblks_t rlen;@@ -1613,7 +1614,7 @@ xfs_swap_extent_rmap(/* Unmap the old blocks in the source file. */ while (tirec.br_blockcount) { -xfs_defer_init (&dfops, &firstfsb); +xfs_defer_init (tp->t_dfops, &firstfsb);trace_xfs_swap_extent_rmap_remap_piece (tip, &tirec);/* Read extent from the source file */ @@ -1635,31 +1636,32 @@ xfs_swap_extent_rmap(trace_xfs_swap_extent_rmap_remap_piece (tip, &uirec);/* Remove the mapping from the donor file. */ - error =xfs_bmap_unmap_extent ((*tpp)->t_mountp, &dfops, - tip, &uirec); + error =xfs_bmap_unmap_extent (mp, tp->t_dfops, tip, + &uirec);if (error) goto out_defer;/* Remove the mapping from the source file. */ - error =xfs_bmap_unmap_extent ((*tpp)->t_mountp, &dfops, - ip, &irec); + error =xfs_bmap_unmap_extent (mp, tp->t_dfops, ip, + &irec);if (error) goto out_defer;/* Map the donor file's blocks into the source file. */ - error =xfs_bmap_map_extent ((*tpp)->t_mountp, &dfops, - ip, &uirec); + error =xfs_bmap_map_extent (mp, tp->t_dfops, ip, + &uirec);if (error) goto out_defer;/* Map the source file's blocks into the donor file. */ - error =xfs_bmap_map_extent ((*tpp)->t_mountp, &dfops, - tip, &irec); + error =xfs_bmap_map_extent (mp, tp->t_dfops, tip, + &irec);if (error) goto out_defer; -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (tpp, &dfops); +xfs_defer_ijoin (tp->t_dfops, ip); + error =xfs_defer_finish (tpp, tp->t_dfops); + tp = *tpp;if (error) goto out_defer;@@ -1679,7 +1681,7 @@ xfs_swap_extent_rmap(return 0 ; out_defer: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out:trace_xfs_swap_extent_rmap_error (ip, error, _RET_IP_); tip->i_d.di_flags2 = tip_flags2;@@ -1846,6 +1848,7 @@ xfs_swap_extents( {struct xfs_mount *mp = ip->i_mount;struct xfs_trans *tp; +struct xfs_defer_ops dfops;struct xfs_bstat *sbp = &sxp->sx_stat;int src_log_flags, target_log_flags;int error =0 ;@@ -1853,6 +1856,7 @@ xfs_swap_extents(struct xfs_ifork *cowfp;uint64_t f;int resblks =0 ; +xfs_fsblock_t firstfsb;/* * Lock the inodes against other IO, page faults and truncate to
fs/xfs/xfs_bmap_util.c xfs_swap_extents( · line 1923
Quoted 5 lines
fs/xfs/xfs_bmap_util.c +2
-0@@ -1915,6 +1919,8 @@ xfs_swap_extents( error =xfs_trans_alloc (mp, &M_RES (mp)->tr_write, resblks,0 ,0 , &tp);if (error) goto out_unlock; +xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops;
Hmm... another redundant initialization here, and extra stack usage too.
If we're going to move the dfops into struct xfs_trans I don't want this series and that series to be split across a release with all these bits scattered everywhere for a single release.
It's at this point I'm tempted to suggest starting this series over with adding a new dfops to the transaction and then converting the t_agfl_dfops and the open-coded/stack-allocated dfops to use the one embedded in the transaction, if nothing else to avoid all this scattered churn.
OTOH I also see that you already moved firstblock into the transaction. I'll keep my mouth shut until I get to the end of that series because I sense there's a lot of changes captured in those two series that would happen even if you'd started with putting the dfops in the transaction. Maybe you're really close to mailing out that last piece anyway.
Code otherwise looks ok, if a bit messy:
--D
Quoted 10 lines
fs/xfs/xfs_bmap_util.c +0
-0/* * Lock and join the inodes to the tansaction so that transaction commit Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 21/24] xfs: use ->t_dfops for rmap extent swap operations
Quoted 108 lines · Darrick J. Wong
Quoted 107 lines · Brian Foster
xfs_swap_extent_rmap()uses a local dfops instance with a transaction from the caller. Since there is only one caller, pull the dfops structure into the caller and attach it to the transaction. This avoids the need to clear ->t_dfops to prevent invalid stack memory access.Signed-off-by Brian Foster <[email protected]>--- fs/xfs/xfs_bmap_util.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-)fs/xfs/xfs_bmap_util.c +17
-13@@ -1570,6 +1570,8 @@ xfs_swap_extent_rmap(struct xfs_inode *ip, struct xfs_inode *tip) { + struct xfs_trans *tp = *tpp; +struct xfs_mount *mp = tp->t_mountp;struct xfs_bmbt_irec irec;struct xfs_bmbt_irec uirec;struct xfs_bmbt_irec tirec;@@ -1577,7 +1579,6 @@ xfs_swap_extent_rmap(xfs_fileoff_t end_fsb;xfs_filblks_t count_fsb;xfs_fsblock_t firstfsb; -struct xfs_defer_ops dfops;int error;xfs_filblks_t ilen;xfs_filblks_t rlen;@@ -1613,7 +1614,7 @@ xfs_swap_extent_rmap(/* Unmap the old blocks in the source file. */ while (tirec.br_blockcount) { -xfs_defer_init (&dfops, &firstfsb); +xfs_defer_init (tp->t_dfops, &firstfsb);trace_xfs_swap_extent_rmap_remap_piece (tip, &tirec);/* Read extent from the source file */ @@ -1635,31 +1636,32 @@ xfs_swap_extent_rmap(trace_xfs_swap_extent_rmap_remap_piece (tip, &uirec);/* Remove the mapping from the donor file. */ - error =xfs_bmap_unmap_extent ((*tpp)->t_mountp, &dfops, - tip, &uirec); + error =xfs_bmap_unmap_extent (mp, tp->t_dfops, tip, + &uirec);if (error) goto out_defer;/* Remove the mapping from the source file. */ - error =xfs_bmap_unmap_extent ((*tpp)->t_mountp, &dfops, - ip, &irec); + error =xfs_bmap_unmap_extent (mp, tp->t_dfops, ip, + &irec);if (error) goto out_defer;/* Map the donor file's blocks into the source file. */ - error =xfs_bmap_map_extent ((*tpp)->t_mountp, &dfops, - ip, &uirec); + error =xfs_bmap_map_extent (mp, tp->t_dfops, ip, + &uirec);if (error) goto out_defer;/* Map the source file's blocks into the donor file. */ - error =xfs_bmap_map_extent ((*tpp)->t_mountp, &dfops, - tip, &irec); + error =xfs_bmap_map_extent (mp, tp->t_dfops, tip, + &irec);if (error) goto out_defer; -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (tpp, &dfops); +xfs_defer_ijoin (tp->t_dfops, ip); + error =xfs_defer_finish (tpp, tp->t_dfops); + tp = *tpp;if (error) goto out_defer;@@ -1679,7 +1681,7 @@ xfs_swap_extent_rmap(return 0 ; out_defer: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out:trace_xfs_swap_extent_rmap_error (ip, error, _RET_IP_); tip->i_d.di_flags2 = tip_flags2;@@ -1846,6 +1848,7 @@ xfs_swap_extents( {struct xfs_mount *mp = ip->i_mount;struct xfs_trans *tp; +struct xfs_defer_ops dfops;struct xfs_bstat *sbp = &sxp->sx_stat;int src_log_flags, target_log_flags;int error =0 ;@@ -1853,6 +1856,7 @@ xfs_swap_extents(struct xfs_ifork *cowfp;uint64_t f;int resblks =0 ; +xfs_fsblock_t firstfsb;
Quoted 11 lines
fs/xfs/xfs_bmap_util.c xfs_swap_extents( · line 1923
Quoted 8 lines
fs/xfs/xfs_bmap_util.c +2
-0/* * Lock the inodes against other IO, page faults and truncate to @@ -1915,6 +1919,8 @@ xfs_swap_extents( error =xfs_trans_alloc (mp, &M_RES (mp)->tr_write, resblks,0 ,0 , &tp);if (error) goto out_unlock; +xfs_defer_init (&dfops, &firstfsb); + tp->t_dfops = &dfops;Hmm... another redundant initialization here, and extra stack usage too.
Similar to the last one, the initial init is to facilitate the future change where dfops may be initted by the transaction allocation. Not quite as similar to the last one, this path already does repeated inits because dfops/firstblock is reused in the associated loop. So technically I don't see how this changes much (aside from the dummy firstfsb in the caller, which could just be replaced with 'f' or something if we care that much about it).
Since dfops should be empty/initted after a finish anyways, this defer init could probably go away in the firstblock series once the latter is automatically reinitialized on tx roll (though the v1 I posted doesn't remove it).
Quoted 10 lines
If we're going to move the dfops into struct
xfs_transI don't want this series and that series to be split across a release with all these bits scattered everywhere for a single release.It's at this point I'm tempted to suggest starting this series over with adding a new dfops to the transaction and then converting the
t_agfl_dfopsand the open-coded/stack-allocated dfops to use the one embedded in the transaction, if nothing else to avoid all this scattered churn.
I think that just changes the order and manner of the churn. Regardless, it's fine with me if we want to hold merging any of it until the whole thing is posted. I may still have posted these bits regardless as review/rfc checkpoints.
Quoted 6 lines
OTOH I also see that you already moved firstblock into the transaction. I'll keep my mouth shut until I get to the end of that series because I sense there's a lot of changes captured in those two series that would happen even if you'd started with putting the dfops in the transaction. Maybe you're really close to mailing out that last piece anyway.
Not really, I'm just starting to look at the last bit. I don't think it will be that difficult once the core bits are worked out, however, so I could just incorporate the current feedback and post the whole thing as one big series rather than worry about v2 of each of the series' posted so far. Doing it incrementally seemed safer and easier to me, but either way is fine with me.
Brian
Quoted 15 lines
Code otherwise looks ok, if a bit messy:
Reviewed-by Darrick J. Wong <[email protected]>--D
Quoted 10 lines
fs/xfs/xfs_bmap_util.c +0
-0/* * Lock and join the inodes to the tansaction so that transaction commit Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 22/24 xfs: use ->t_dfops in cancel cow blocks operation
In reply to Brian FosterUse ->t_dfops of the transaction from the caller. Reset it before we return to avoid leaks of local stack memory.
--- fs/xfs/xfs_reflink.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
fs/xfs/xfs_reflink.c +8 -6
@@ -553,6 +553,7 @@ xfs_reflink_cancel_cow_blocks(struct xfs_iext_cursor icur;xfs_fsblock_t firstfsb;struct xfs_defer_ops dfops; +struct xfs_defer_ops *odfops = (*tpp)->t_dfops;int error =0 ;if (!xfs_is_reflink_inode (ip))
@@ -580,23 +581,24 @@ xfs_reflink_cancel_cow_blocks(break ; }else if (del.br_state ==XFS_EXT_UNWRITTEN || cancel_real) {xfs_defer_init (&dfops, &firstfsb); + (*tpp)->t_dfops = &dfops;/* Free the CoW orphan record. */ error =xfs_refcount_free_cow_extent (ip->i_mount, - &dfops, del.br_startblock, + (*tpp)->t_dfops, del.br_startblock, del.br_blockcount);if (error)break ; -xfs_bmap_add_free (ip->i_mount, &dfops, +xfs_bmap_add_free (ip->i_mount, (*tpp)->t_dfops, del.br_startblock, del.br_blockcount,NULL );/* Roll the transaction */ -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (tpp, &dfops); +xfs_defer_ijoin ((*tpp)->t_dfops, ip); + error =xfs_defer_finish (tpp, (*tpp)->t_dfops);if (error) { -xfs_defer_cancel (&dfops); +xfs_defer_cancel ((*tpp)->t_dfops);break ; }
@@ -621,7 +623,7 @@ xfs_reflink_cancel_cow_blocks(/* clear tag if cow fork is emptied */ if (!ifp->if_bytes)xfs_inode_clear_cowblocks_tag (ip); - + (*tpp)->t_dfops = odfops;return error; }
Signature · 1 line
2.17.1
Re: [PATCH 22/24] xfs: use ->t_dfops in cancel cow blocks operation
Quoted 2 lines · Brian Foster
Use ->t_dfops of the transaction from the caller. Reset it before we return to avoid leaks of local stack memory.
Looks good,
Re: [PATCH 22/24] xfs: use ->t_dfops in cancel cow blocks operation
In reply to Brian FosterQuoted 4 lines · Brian Foster
Use ->t_dfops of the transaction from the caller. Reset it before we return to avoid leaks of local stack memory.
Signed-off-by Brian Foster <[email protected]>
Looks ok,
--D
Quoted 62 lines
--- fs/xfs/xfs_reflink.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)fs/xfs/xfs_reflink.c +8
-6@@ -553,6 +553,7 @@ xfs_reflink_cancel_cow_blocks(struct xfs_iext_cursor icur;xfs_fsblock_t firstfsb;struct xfs_defer_ops dfops; +struct xfs_defer_ops *odfops = (*tpp)->t_dfops;int error =0 ;if (!xfs_is_reflink_inode (ip))@@ -580,23 +581,24 @@ xfs_reflink_cancel_cow_blocks(break ; }else if (del.br_state ==XFS_EXT_UNWRITTEN || cancel_real) {xfs_defer_init (&dfops, &firstfsb); + (*tpp)->t_dfops = &dfops;/* Free the CoW orphan record. */ error =xfs_refcount_free_cow_extent (ip->i_mount, - &dfops, del.br_startblock, + (*tpp)->t_dfops, del.br_startblock, del.br_blockcount);if (error)break ; -xfs_bmap_add_free (ip->i_mount, &dfops, +xfs_bmap_add_free (ip->i_mount, (*tpp)->t_dfops, del.br_startblock, del.br_blockcount,NULL );/* Roll the transaction */ -xfs_defer_ijoin (&dfops, ip); - error =xfs_defer_finish (tpp, &dfops); +xfs_defer_ijoin ((*tpp)->t_dfops, ip); + error =xfs_defer_finish (tpp, (*tpp)->t_dfops);if (error) { -xfs_defer_cancel (&dfops); +xfs_defer_cancel ((*tpp)->t_dfops);break ; }@@ -621,7 +623,7 @@ xfs_reflink_cancel_cow_blocks(/* clear tag if cow fork is emptied */ if (!ifp->if_bytes)xfs_inode_clear_cowblocks_tag (ip); - + (*tpp)->t_dfops = odfops;return error; }Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 23/24 xfs: use ->t_dfops in reflink cow recover path
In reply to Brian FosterUse ->t_dfops of the leftover COW reservation cleanup transaction.
--- fs/xfs/libxfs/xfs_refcount.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/xfs/libxfs/xfs_refcount.c +5 -4
@@ -1692,18 +1692,19 @@ xfs_refcount_recover_cow_leftovers(/* Free the orphan record */ xfs_defer_init (&dfops, &fsb); + tp->t_dfops = &dfops; agbno = rr->rr_rrec.rc_startblock -XFS_REFC_COW_START ; fsb =XFS_AGB_TO_FSB (mp, agno, agbno); - error =xfs_refcount_free_cow_extent (mp, &dfops, fsb, + error =xfs_refcount_free_cow_extent (mp, tp->t_dfops, fsb, rr->rr_rrec.rc_blockcount);if (error) goto out_defer;/* Free the block. */ -xfs_bmap_add_free (mp, &dfops, fsb, +xfs_bmap_add_free (mp, tp->t_dfops, fsb, rr->rr_rrec.rc_blockcount,NULL ); - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_defer;
@@ -1717,7 +1718,7 @@ xfs_refcount_recover_cow_leftovers(return error; out_defer: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out_trans:xfs_trans_cancel (tp); out_free:
Signature · 1 line
2.17.1
Re: [PATCH 23/24] xfs: use ->t_dfops in reflink cow recover path
Quoted 3 lines · Brian Foster
Use ->t_dfops of the leftover COW reservation cleanup transaction.
Signed-off-by Brian Foster <[email protected]>
Looks good,
Re: [PATCH 23/24] xfs: use ->t_dfops in reflink cow recover path
In reply to Brian FosterQuoted 3 lines · Brian Foster
Use ->t_dfops of the leftover COW reservation cleanup transaction.
Signed-off-by Brian Foster <[email protected]>
Looks ok,
--D
Quoted 47 lines
--- fs/xfs/libxfs/xfs_refcount.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)fs/xfs/libxfs/xfs_refcount.c +5
-4@@ -1692,18 +1692,19 @@ xfs_refcount_recover_cow_leftovers(/* Free the orphan record */ xfs_defer_init (&dfops, &fsb); + tp->t_dfops = &dfops; agbno = rr->rr_rrec.rc_startblock -XFS_REFC_COW_START ; fsb =XFS_AGB_TO_FSB (mp, agno, agbno); - error =xfs_refcount_free_cow_extent (mp, &dfops, fsb, + error =xfs_refcount_free_cow_extent (mp, tp->t_dfops, fsb, rr->rr_rrec.rc_blockcount);if (error) goto out_defer;/* Free the block. */ -xfs_bmap_add_free (mp, &dfops, fsb, +xfs_bmap_add_free (mp, tp->t_dfops, fsb, rr->rr_rrec.rc_blockcount,NULL ); - error =xfs_defer_finish (&tp, &dfops); + error =xfs_defer_finish (&tp, tp->t_dfops);if (error) goto out_defer;@@ -1717,7 +1718,7 @@ xfs_refcount_recover_cow_leftovers(return error; out_defer: -xfs_defer_cancel (&dfops); +xfs_defer_cancel (tp->t_dfops); out_trans:xfs_trans_cancel (tp); out_free:Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 24/24 xfs: refactor dfops init to attach to transaction
In reply to Brian FosterMost callers of xfs_defer_init() immediately attach the dfops structure to a transaction. Add a transaction parameter to eliminate much of this boilerplate code. This also helps self-document the fact that many codepaths now expect a dfops pointer implicitly via xfs_trans->t_dfops.
--- fs/xfs/libxfs/xfs_attr.c | 26 ++++++++++++++------------ fs/xfs/libxfs/xfs_attr_remote.c | 6 +++--- fs/xfs/libxfs/xfs_bmap.c | 6 ++---- fs/xfs/libxfs/xfs_defer.c | 9 ++++++++- fs/xfs/libxfs/xfs_defer.h | 3 ++- fs/xfs/libxfs/xfs_refcount.c | 3 +-- fs/xfs/xfs_bmap_util.c | 17 ++++++----------- fs/xfs/xfs_dquot.c | 5 ++--- fs/xfs/xfs_inode.c | 18 ++++++------------ fs/xfs/xfs_iomap.c | 9 +++------ fs/xfs/xfs_log_recover.c | 2 +- fs/xfs/xfs_reflink.c | 12 ++++-------- fs/xfs/xfs_rtalloc.c | 3 +-- fs/xfs/xfs_symlink.c | 6 ++---- 14 files changed, 55 insertions(+), 70 deletions(-)
fs/xfs/libxfs/xfs_attr.c +14 -12
@@ -253,8 +253,7 @@ xfs_attr_set( rsvd ? XFS_TRANS_RESERVE : 0, &args.trans);if (error)return error; -xfs_defer_init (&dfops, &firstblock); - args.trans->t_dfops = &dfops; +xfs_defer_init (args.trans, &dfops, &firstblock);xfs_ilock (dp,XFS_ILOCK_EXCL ); error = xfs_trans_reserve_quota_nblks(args.trans, dp, args.total, 0,
@@ -428,8 +427,7 @@ xfs_attr_remove( &args.trans);if (error)return error; -xfs_defer_init (&dfops, &firstblock); - args.trans->t_dfops = &dfops; +xfs_defer_init (args.trans, &dfops, &firstblock);xfs_ilock (dp,XFS_ILOCK_EXCL );/*
@@ -600,7 +598,7 @@ xfs_attr_leaf_addname(* Commit that transaction so that the node_addname() call * can manage its own transactions. */ -xfs_defer_init (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , args->trans->t_dfops, args->firstblock); error =xfs_attr3_leaf_to_node (args);if (error) goto out_defer_cancel;
@@ -689,7 +687,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 (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , 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)
@@ -754,7 +753,7 @@ 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 (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , 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)
@@ -883,7 +882,8 @@ xfs_attr_node_addname(*/ xfs_da_state_free (state); state =NULL ; -xfs_defer_init (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , args->trans->t_dfops, + args->firstblock); error =xfs_attr3_leaf_to_node (args);if (error) goto out_defer_cancel;
@@ -910,7 +910,7 @@ xfs_attr_node_addname(* in the index/blkno/rmtblkno/rmtblkcnt fields and * in the index2/blkno2/rmtblkno2/rmtblkcnt2 fields. */ -xfs_defer_init (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , args->trans->t_dfops, args->firstblock); error =xfs_da3_split (state);if (error) goto out_defer_cancel;
@@ -1008,7 +1008,8 @@ xfs_attr_node_addname(* Check to see if the tree needs to be collapsed. */ if (retval && (state->path.active >1 )) { -xfs_defer_init (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , args->trans->t_dfops, + args->firstblock); error =xfs_da3_join (state);if (error) goto out_defer_cancel;
@@ -1133,7 +1134,7 @@ xfs_attr_node_removename(* Check to see if the tree needs to be collapsed. */ if (retval && (state->path.active >1 )) { -xfs_defer_init (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , args->trans->t_dfops, args->firstblock); error =xfs_da3_join (state);if (error) goto out_defer_cancel;
@@ -1165,7 +1166,8 @@ xfs_attr_node_removename( goto out;if ((forkoff =xfs_attr_shortform_allfit (bp, dp))) { -xfs_defer_init (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , 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)
fs/xfs/libxfs/xfs_attr_remote.c +3 -3
@@ -480,7 +480,7 @@ 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->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , 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,
@@ -522,7 +522,7 @@ xfs_attr_rmtval_set(ASSERT (blkcnt >0 ); -xfs_defer_init (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , args->trans->t_dfops, args->firstblock); nmap =1 ; error = xfs_bmapi_read(dp, (xfs_fileoff_t)lblkno, blkcnt, &map, &nmap,
@@ -626,7 +626,7 @@ xfs_attr_rmtval_remove( blkcnt = args->rmtblkcnt; done =0 ;while (!done) { -xfs_defer_init (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , args->trans->t_dfops, args->firstblock); error =xfs_bunmapi (args->trans, args->dp, lblkno, blkcnt,XFS_BMAPI_ATTRFORK ,1 , args->firstblock, &done);
fs/xfs/libxfs/xfs_bmap.c +2 -4
@@ -1050,8 +1050,7 @@ xfs_bmap_add_attrfork( rsvd ? XFS_TRANS_RESERVE : 0, &tp);if (error)return error; -xfs_defer_init (&dfops, &firstblock); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstblock);xfs_ilock (ip,XFS_ILOCK_EXCL ); error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ?
@@ -6027,8 +6026,7 @@ xfs_bmap_split_extent( XFS_DIOSTRAT_SPACE_RES(mp, 0), 0, 0, &tp);if (error)return error; -xfs_defer_init (&dfops, &firstfsb); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstfsb);xfs_ilock (ip,XFS_ILOCK_EXCL );xfs_trans_ijoin (tp, ip,XFS_ILOCK_EXCL );
fs/xfs/libxfs/xfs_defer.c +8 -1
@@ -523,12 +523,19 @@ xfs_defer_init_op_type(/* Initialize a deferred operation. */ void xfs_defer_init ( +struct xfs_trans *tp,struct xfs_defer_ops *dop,xfs_fsblock_t *fbp) { +struct xfs_mount *mp =NULL ; +memset (dop,0 ,sizeof (struct xfs_defer_ops )); *fbp =NULLFSBLOCK ;INIT_LIST_HEAD (&dop->dop_intake);INIT_LIST_HEAD (&dop->dop_pending); -trace_xfs_defer_init (NULL , dop, _RET_IP_); +if (tp) { + tp->t_dfops = dop; + mp = tp->t_mountp; + } +trace_xfs_defer_init (mp, dop, _RET_IP_); }
fs/xfs/libxfs/xfs_defer.h +2 -1
@@ -63,7 +63,8 @@ void xfs_defer_add(struct xfs_defer_ops *dop, enum xfs_defer_ops_type type, struct list_head *h);int xfs_defer_finish (struct xfs_trans **tp,struct xfs_defer_ops *dop);void xfs_defer_cancel (struct xfs_defer_ops *dop); -void xfs_defer_init (struct xfs_defer_ops *dop,xfs_fsblock_t *fbp); +void xfs_defer_init (struct xfs_trans *tp,struct xfs_defer_ops *dop, +xfs_fsblock_t *fbp);bool xfs_defer_has_unfinished_work (struct xfs_defer_ops *dop);int xfs_defer_ijoin (struct xfs_defer_ops *dop,struct xfs_inode *ip);int xfs_defer_bjoin (struct xfs_defer_ops *dop,struct xfs_buf *bp);
fs/xfs/libxfs/xfs_refcount.c +1 -2
@@ -1691,8 +1691,7 @@ xfs_refcount_recover_cow_leftovers(trace_xfs_refcount_recover_extent (mp, agno, &rr->rr_rrec);/* Free the orphan record */ -xfs_defer_init (&dfops, &fsb); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &fsb); agbno = rr->rr_rrec.rc_startblock -XFS_REFC_COW_START ; fsb =XFS_AGB_TO_FSB (mp, agno, agbno); error = xfs_refcount_free_cow_extent(mp, tp->t_dfops, fsb,
fs/xfs/xfs_bmap_util.c +6 -11
@@ -971,8 +971,7 @@ xfs_alloc_file_space(xfs_trans_ijoin (tp, ip,0 ); -xfs_defer_init (&dfops, &firstfsb); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstfsb); error =xfs_bmapi_write (tp, ip, startoffset_fsb, allocatesize_fsb, alloc_type, &firstfsb, resblks, imapp, &nimaps);
@@ -1042,8 +1041,7 @@ xfs_unmap_extent(xfs_trans_ijoin (tp, ip,0 ); -xfs_defer_init (&dfops, &firstfsb); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstfsb); error =xfs_bunmapi (tp, ip, startoffset_fsb, len_fsb,0 ,2 , &firstfsb, done);if (error)
@@ -1346,8 +1344,7 @@ xfs_collapse_file_space( goto out_trans_cancel;xfs_trans_ijoin (tp, ip,XFS_ILOCK_EXCL ); -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block); error =xfs_bmap_collapse_extents (tp, ip, &next_fsb, shift_fsb, &done, &first_block);if (error)
@@ -1426,8 +1423,7 @@ xfs_insert_file_space(xfs_ilock (ip,XFS_ILOCK_EXCL );xfs_trans_ijoin (tp, ip,XFS_ILOCK_EXCL ); -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block); error =xfs_bmap_insert_extents (tp, ip, &next_fsb, shift_fsb, &done, stop_fsb, &first_block);if (error)
@@ -1614,7 +1610,7 @@ xfs_swap_extent_rmap(/* Unmap the old blocks in the source file. */ while (tirec.br_blockcount) { -xfs_defer_init (tp->t_dfops, &firstfsb); +xfs_defer_init (tp, tp->t_dfops, &firstfsb);trace_xfs_swap_extent_rmap_remap_piece (tip, &tirec);/* Read extent from the source file */
@@ -1919,8 +1915,7 @@ xfs_swap_extents( error =xfs_trans_alloc (mp, &M_RES (mp)->tr_write, resblks,0 ,0 , &tp);if (error) goto out_unlock; -xfs_defer_init (&dfops, &firstfsb); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstfsb);/* * Lock and join the inodes to the tansaction so that transaction commit
fs/xfs/xfs_dquot.c +2 -3
@@ -296,7 +296,7 @@ xfs_dquot_disk_alloc(trace_xfs_dqalloc (dqp); -xfs_defer_init (tp->t_dfops, &firstblock); +xfs_defer_init (tp, tp->t_dfops, &firstblock);xfs_ilock (quotip,XFS_ILOCK_EXCL );if (!xfs_this_quota_on (dqp->q_mount, dqp->dq_flags)) {
@@ -549,8 +549,7 @@ xfs_qm_dqread_alloc( XFS_QM_DQALLOC_SPACE_RES(mp), 0, 0, &tp);if (error) goto err; -xfs_defer_init (&dfops, &firstblock); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstblock); error =xfs_dquot_disk_alloc (&tp, dqp, &bp);if (error)
fs/xfs/xfs_inode.c +6 -12
@@ -1195,8 +1195,7 @@ xfs_create(xfs_ilock (dp,XFS_ILOCK_EXCL |XFS_ILOCK_PARENT ); unlock_dp_on_error = true; -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block);/* * Reserve disk quota and the inode.
@@ -1451,8 +1450,7 @@ xfs_link( goto error_return; } -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block);/* * Handle initial link state of O_TMPFILE inode
@@ -1584,8 +1582,7 @@ xfs_itruncate_extents_flags(ASSERT (first_unmap_block < last_block); unmap_len = last_block - first_unmap_block +1 ;while (!done) { -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block); error =xfs_bunmapi (tp, ip, first_unmap_block, unmap_len, flags,XFS_ITRUNC_MAX_EXTENTS , &first_block, &done);
@@ -1816,8 +1813,7 @@ xfs_inactive_ifree(xfs_ilock (ip,XFS_ILOCK_EXCL );xfs_trans_ijoin (tp, ip,0 ); -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block); error =xfs_ifree (tp, ip);if (error) {/*
@@ -2661,8 +2657,7 @@ xfs_remove(if (error) goto out_trans_cancel; -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block); error =xfs_dir_removename (tp, dp, name, ip->i_ino, &first_block, resblks);if (error) {
@@ -3026,8 +3021,7 @@ xfs_rename( goto out_trans_cancel; } -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block);/* RENAME_EXCHANGE is unique from here on. */ if (flags &RENAME_EXCHANGE )
fs/xfs/xfs_iomap.c +3 -6
@@ -254,8 +254,7 @@ xfs_iomap_write_direct(* From this point onwards we overwrite the imap pointer that the * caller gave to us. */ -xfs_defer_init (&dfops, &firstfsb); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstfsb); nimaps =1 ; error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb, bmapi_flags, &firstfsb, resblks, imap,
@@ -717,8 +716,7 @@ xfs_iomap_write_allocate(xfs_ilock (ip,XFS_ILOCK_EXCL );xfs_trans_ijoin (tp, ip,0 ); -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block);/* * it is possible that the extents have changed since
@@ -878,8 +876,7 @@ xfs_iomap_write_unwritten(/* * Modify the unwritten extent state of the buffer. */ -xfs_defer_init (&dfops, &firstfsb); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstfsb); nimaps =1 ; error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb, XFS_BMAPI_CONVERT, &firstfsb, resblks,
fs/xfs/xfs_log_recover.c +1 -1
@@ -4902,7 +4902,7 @@ xlog_recover_process_intents(#if defined(DEBUG ) || defined(XFS_WARN ) last_lsn =xlog_assign_lsn (log->l_curr_cycle, log->l_curr_block);#endif -xfs_defer_init (&dfops, &firstfsb); +xfs_defer_init (NULL , &dfops, &firstfsb);while (lip !=NULL ) {/* * We're done when we see something other than an intent.
fs/xfs/xfs_reflink.c +4 -8
@@ -428,8 +428,7 @@ xfs_reflink_allocate_cow(xfs_trans_ijoin (tp, ip,0 ); -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block); nimaps =1 ;/* Allocate the entire reservation as unwritten blocks. */
@@ -580,8 +579,7 @@ xfs_reflink_cancel_cow_blocks(if (error)break ; }else if (del.br_state ==XFS_EXT_UNWRITTEN || cancel_real) { -xfs_defer_init (&dfops, &firstfsb); - (*tpp)->t_dfops = &dfops; +xfs_defer_init (*tpp, &dfops, &firstfsb);/* Free the CoW orphan record. */ error = xfs_refcount_free_cow_extent(ip->i_mount,
@@ -764,8 +762,7 @@ xfs_reflink_end_cow( goto prev_extent;/* Unmap the old blocks in the data fork. */ -xfs_defer_init (&dfops, &firstfsb); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstfsb); rlen = del.br_blockcount; error =__xfs_bunmapi (tp, ip, del.br_startoff, &rlen,0 ,1 , &firstfsb);
@@ -1115,8 +1112,7 @@ xfs_reflink_remap_extent(/* Unmap the old blocks in the data fork. */ rlen = unmap_len;while (rlen) { -xfs_defer_init (&dfops, &firstfsb); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstfsb); error =__xfs_bunmapi (tp, ip, destoff, &rlen,0 ,1 , &firstfsb);if (error) goto out_defer;
fs/xfs/xfs_rtalloc.c +1 -2
@@ -787,8 +787,7 @@ xfs_growfs_rt_alloc(xfs_ilock (ip,XFS_ILOCK_EXCL );xfs_trans_ijoin (tp, ip,XFS_ILOCK_EXCL ); -xfs_defer_init (&dfops, &firstblock); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstblock);/* * Allocate blocks to the bitmap file. */
fs/xfs/xfs_symlink.c +2 -4
@@ -246,8 +246,7 @@ xfs_symlink(* Initialize the bmap freelist prior to calling either * bmapi or the directory create code. */ -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block);/* * Allocate an inode for the symlink.
@@ -443,8 +442,7 @@ xfs_inactive_symlink_rmt(* Find the block(s) so we can inval and unmap them. */ done =0 ; -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block); nmaps =ARRAY_SIZE (mval); error =xfs_bmapi_read (ip,0 ,xfs_symlink_blocks (mp, size), mval, &nmaps,0 );
Signature · 1 line
2.17.1
Re: [PATCH 24/24] xfs: refactor dfops init to attach to transaction
Quoted 5 lines · Brian Foster
Most callers of
xfs_defer_init()immediately attach the dfops structure to a transaction. Add a transaction parameter to eliminate much of this boilerplate code. This also helps self-document the fact that many codepaths now expect a dfops pointer implicitly viaxfs_trans->t_dfops.
Looks good,
Re: [PATCH 24/24] xfs: refactor dfops init to attach to transaction
In reply to Brian FosterQuoted 7 lines · Brian Foster
Most callers of
xfs_defer_init()immediately attach the dfops structure to a transaction. Add a transaction parameter to eliminate much of this boilerplate code. This also helps self-document the fact that many codepaths now expect a dfops pointer implicitly viaxfs_trans->t_dfops.Signed-off-by Brian Foster <[email protected]>
Looks ok, will test...
--D
Quoted 511 lines
--- fs/xfs/libxfs/xfs_attr.c | 26 ++++++++++++++------------ fs/xfs/libxfs/xfs_attr_remote.c | 6 +++--- fs/xfs/libxfs/xfs_bmap.c | 6 ++---- fs/xfs/libxfs/xfs_defer.c | 9 ++++++++- fs/xfs/libxfs/xfs_defer.h | 3 ++- fs/xfs/libxfs/xfs_refcount.c | 3 +-- fs/xfs/xfs_bmap_util.c | 17 ++++++----------- fs/xfs/xfs_dquot.c | 5 ++--- fs/xfs/xfs_inode.c | 18 ++++++------------ fs/xfs/xfs_iomap.c | 9 +++------ fs/xfs/xfs_log_recover.c | 2 +- fs/xfs/xfs_reflink.c | 12 ++++-------- fs/xfs/xfs_rtalloc.c | 3 +-- fs/xfs/xfs_symlink.c | 6 ++---- 14 files changed, 55 insertions(+), 70 deletions(-)fs/xfs/libxfs/xfs_attr.c +14
-12@@ -253,8 +253,7 @@ xfs_attr_set( rsvd ? XFS_TRANS_RESERVE : 0, &args.trans);if (error)return error; -xfs_defer_init (&dfops, &firstblock); - args.trans->t_dfops = &dfops; +xfs_defer_init (args.trans, &dfops, &firstblock);xfs_ilock (dp,XFS_ILOCK_EXCL ); error = xfs_trans_reserve_quota_nblks(args.trans, dp, args.total, 0,@@ -428,8 +427,7 @@ xfs_attr_remove( &args.trans);if (error)return error; -xfs_defer_init (&dfops, &firstblock); - args.trans->t_dfops = &dfops; +xfs_defer_init (args.trans, &dfops, &firstblock);xfs_ilock (dp,XFS_ILOCK_EXCL );/* @@ -600,7 +598,7 @@ xfs_attr_leaf_addname(* Commit that transaction so that the node_addname() call * can manage its own transactions. */ -xfs_defer_init (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , args->trans->t_dfops, args->firstblock); error =xfs_attr3_leaf_to_node (args);if (error) goto out_defer_cancel;@@ -689,7 +687,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 (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , 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)@@ -754,7 +753,7 @@ 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 (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , 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)@@ -883,7 +882,8 @@ xfs_attr_node_addname(*/ xfs_da_state_free (state); state =NULL ; -xfs_defer_init (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , args->trans->t_dfops, + args->firstblock); error =xfs_attr3_leaf_to_node (args);if (error) goto out_defer_cancel;@@ -910,7 +910,7 @@ xfs_attr_node_addname(* in the index/blkno/rmtblkno/rmtblkcnt fields and * in the index2/blkno2/rmtblkno2/rmtblkcnt2 fields. */ -xfs_defer_init (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , args->trans->t_dfops, args->firstblock); error =xfs_da3_split (state);if (error) goto out_defer_cancel;@@ -1008,7 +1008,8 @@ xfs_attr_node_addname(* Check to see if the tree needs to be collapsed. */ if (retval && (state->path.active >1 )) { -xfs_defer_init (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , args->trans->t_dfops, + args->firstblock); error =xfs_da3_join (state);if (error) goto out_defer_cancel;@@ -1133,7 +1134,7 @@ xfs_attr_node_removename(* Check to see if the tree needs to be collapsed. */ if (retval && (state->path.active >1 )) { -xfs_defer_init (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , args->trans->t_dfops, args->firstblock); error =xfs_da3_join (state);if (error) goto out_defer_cancel;@@ -1165,7 +1166,8 @@ xfs_attr_node_removename( goto out;if ((forkoff =xfs_attr_shortform_allfit (bp, dp))) { -xfs_defer_init (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , 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)fs/xfs/libxfs/xfs_attr_remote.c +3
-3@@ -480,7 +480,7 @@ 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->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , 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,@@ -522,7 +522,7 @@ xfs_attr_rmtval_set(ASSERT (blkcnt >0 ); -xfs_defer_init (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , args->trans->t_dfops, args->firstblock); nmap =1 ; error = xfs_bmapi_read(dp, (xfs_fileoff_t)lblkno, blkcnt, &map, &nmap,@@ -626,7 +626,7 @@ xfs_attr_rmtval_remove( blkcnt = args->rmtblkcnt; done =0 ;while (!done) { -xfs_defer_init (args->trans->t_dfops, args->firstblock); +xfs_defer_init (NULL , args->trans->t_dfops, args->firstblock); error =xfs_bunmapi (args->trans, args->dp, lblkno, blkcnt,XFS_BMAPI_ATTRFORK ,1 , args->firstblock, &done);fs/xfs/libxfs/xfs_bmap.c +2
-4@@ -1050,8 +1050,7 @@ xfs_bmap_add_attrfork( rsvd ? XFS_TRANS_RESERVE : 0, &tp);if (error)return error; -xfs_defer_init (&dfops, &firstblock); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstblock);xfs_ilock (ip,XFS_ILOCK_EXCL ); error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ?@@ -6027,8 +6026,7 @@ xfs_bmap_split_extent( XFS_DIOSTRAT_SPACE_RES(mp, 0), 0, 0, &tp);if (error)return error; -xfs_defer_init (&dfops, &firstfsb); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstfsb);xfs_ilock (ip,XFS_ILOCK_EXCL );xfs_trans_ijoin (tp, ip,XFS_ILOCK_EXCL );fs/xfs/libxfs/xfs_defer.c +8
-1@@ -523,12 +523,19 @@ xfs_defer_init_op_type(/* Initialize a deferred operation. */ void xfs_defer_init ( +struct xfs_trans *tp,struct xfs_defer_ops *dop,xfs_fsblock_t *fbp) { +struct xfs_mount *mp =NULL ; +memset (dop,0 ,sizeof (struct xfs_defer_ops )); *fbp =NULLFSBLOCK ;INIT_LIST_HEAD (&dop->dop_intake);INIT_LIST_HEAD (&dop->dop_pending); -trace_xfs_defer_init (NULL , dop, _RET_IP_); +if (tp) { + tp->t_dfops = dop; + mp = tp->t_mountp; + } +trace_xfs_defer_init (mp, dop, _RET_IP_); }fs/xfs/libxfs/xfs_defer.h +2
-1@@ -63,7 +63,8 @@ void xfs_defer_add(struct xfs_defer_ops *dop, enum xfs_defer_ops_type type, struct list_head *h);int xfs_defer_finish (struct xfs_trans **tp,struct xfs_defer_ops *dop);void xfs_defer_cancel (struct xfs_defer_ops *dop); -void xfs_defer_init (struct xfs_defer_ops *dop,xfs_fsblock_t *fbp); +void xfs_defer_init (struct xfs_trans *tp,struct xfs_defer_ops *dop, +xfs_fsblock_t *fbp);bool xfs_defer_has_unfinished_work (struct xfs_defer_ops *dop);int xfs_defer_ijoin (struct xfs_defer_ops *dop,struct xfs_inode *ip);int xfs_defer_bjoin (struct xfs_defer_ops *dop,struct xfs_buf *bp);fs/xfs/libxfs/xfs_refcount.c +1
-2@@ -1691,8 +1691,7 @@ xfs_refcount_recover_cow_leftovers(trace_xfs_refcount_recover_extent (mp, agno, &rr->rr_rrec);/* Free the orphan record */ -xfs_defer_init (&dfops, &fsb); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &fsb); agbno = rr->rr_rrec.rc_startblock -XFS_REFC_COW_START ; fsb =XFS_AGB_TO_FSB (mp, agno, agbno); error = xfs_refcount_free_cow_extent(mp, tp->t_dfops, fsb,fs/xfs/xfs_bmap_util.c +6
-11@@ -971,8 +971,7 @@ xfs_alloc_file_space(xfs_trans_ijoin (tp, ip,0 ); -xfs_defer_init (&dfops, &firstfsb); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstfsb); error =xfs_bmapi_write (tp, ip, startoffset_fsb, allocatesize_fsb, alloc_type, &firstfsb, resblks, imapp, &nimaps);@@ -1042,8 +1041,7 @@ xfs_unmap_extent(xfs_trans_ijoin (tp, ip,0 ); -xfs_defer_init (&dfops, &firstfsb); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstfsb); error =xfs_bunmapi (tp, ip, startoffset_fsb, len_fsb,0 ,2 , &firstfsb, done);if (error)@@ -1346,8 +1344,7 @@ xfs_collapse_file_space( goto out_trans_cancel;xfs_trans_ijoin (tp, ip,XFS_ILOCK_EXCL ); -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block); error =xfs_bmap_collapse_extents (tp, ip, &next_fsb, shift_fsb, &done, &first_block);if (error)@@ -1426,8 +1423,7 @@ xfs_insert_file_space(xfs_ilock (ip,XFS_ILOCK_EXCL );xfs_trans_ijoin (tp, ip,XFS_ILOCK_EXCL ); -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block); error =xfs_bmap_insert_extents (tp, ip, &next_fsb, shift_fsb, &done, stop_fsb, &first_block);if (error)@@ -1614,7 +1610,7 @@ xfs_swap_extent_rmap(/* Unmap the old blocks in the source file. */ while (tirec.br_blockcount) { -xfs_defer_init (tp->t_dfops, &firstfsb); +xfs_defer_init (tp, tp->t_dfops, &firstfsb);trace_xfs_swap_extent_rmap_remap_piece (tip, &tirec);/* Read extent from the source file */ @@ -1919,8 +1915,7 @@ xfs_swap_extents( error =xfs_trans_alloc (mp, &M_RES (mp)->tr_write, resblks,0 ,0 , &tp);if (error) goto out_unlock; -xfs_defer_init (&dfops, &firstfsb); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstfsb);/* * Lock and join the inodes to the tansaction so that transaction commit fs/xfs/xfs_dquot.c +2
-3@@ -296,7 +296,7 @@ xfs_dquot_disk_alloc(trace_xfs_dqalloc (dqp); -xfs_defer_init (tp->t_dfops, &firstblock); +xfs_defer_init (tp, tp->t_dfops, &firstblock);xfs_ilock (quotip,XFS_ILOCK_EXCL );if (!xfs_this_quota_on (dqp->q_mount, dqp->dq_flags)) {@@ -549,8 +549,7 @@ xfs_qm_dqread_alloc( XFS_QM_DQALLOC_SPACE_RES(mp), 0, 0, &tp);if (error) goto err; -xfs_defer_init (&dfops, &firstblock); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstblock); error =xfs_dquot_disk_alloc (&tp, dqp, &bp);if (error)fs/xfs/xfs_inode.c +6
-12@@ -1195,8 +1195,7 @@ xfs_create(xfs_ilock (dp,XFS_ILOCK_EXCL |XFS_ILOCK_PARENT ); unlock_dp_on_error = true; -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block);/* * Reserve disk quota and the inode. @@ -1451,8 +1450,7 @@ xfs_link( goto error_return; } -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block);/* * Handle initial link state of O_TMPFILE inode @@ -1584,8 +1582,7 @@ xfs_itruncate_extents_flags(ASSERT (first_unmap_block < last_block); unmap_len = last_block - first_unmap_block +1 ;while (!done) { -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block); error =xfs_bunmapi (tp, ip, first_unmap_block, unmap_len, flags,XFS_ITRUNC_MAX_EXTENTS , &first_block, &done);@@ -1816,8 +1813,7 @@ xfs_inactive_ifree(xfs_ilock (ip,XFS_ILOCK_EXCL );xfs_trans_ijoin (tp, ip,0 ); -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block); error =xfs_ifree (tp, ip);if (error) {/* @@ -2661,8 +2657,7 @@ xfs_remove(if (error) goto out_trans_cancel; -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block); error =xfs_dir_removename (tp, dp, name, ip->i_ino, &first_block, resblks);if (error) {@@ -3026,8 +3021,7 @@ xfs_rename( goto out_trans_cancel; } -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block);/* RENAME_EXCHANGE is unique from here on. */ if (flags &RENAME_EXCHANGE )fs/xfs/xfs_iomap.c +3
-6@@ -254,8 +254,7 @@ xfs_iomap_write_direct(* From this point onwards we overwrite the imap pointer that the * caller gave to us. */ -xfs_defer_init (&dfops, &firstfsb); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstfsb); nimaps =1 ; error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb, bmapi_flags, &firstfsb, resblks, imap,@@ -717,8 +716,7 @@ xfs_iomap_write_allocate(xfs_ilock (ip,XFS_ILOCK_EXCL );xfs_trans_ijoin (tp, ip,0 ); -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block);/* * it is possible that the extents have changed since @@ -878,8 +876,7 @@ xfs_iomap_write_unwritten(/* * Modify the unwritten extent state of the buffer. */ -xfs_defer_init (&dfops, &firstfsb); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstfsb); nimaps =1 ; error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb, XFS_BMAPI_CONVERT, &firstfsb, resblks,fs/xfs/xfs_log_recover.c +1
-1@@ -4902,7 +4902,7 @@ xlog_recover_process_intents(#if defined(DEBUG ) || defined(XFS_WARN ) last_lsn =xlog_assign_lsn (log->l_curr_cycle, log->l_curr_block);#endif -xfs_defer_init (&dfops, &firstfsb); +xfs_defer_init (NULL , &dfops, &firstfsb);while (lip !=NULL ) {/* * We're done when we see something other than an intent. fs/xfs/xfs_reflink.c +4
-8@@ -428,8 +428,7 @@ xfs_reflink_allocate_cow(xfs_trans_ijoin (tp, ip,0 ); -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block); nimaps =1 ;/* Allocate the entire reservation as unwritten blocks. */ @@ -580,8 +579,7 @@ xfs_reflink_cancel_cow_blocks(if (error)break ; }else if (del.br_state ==XFS_EXT_UNWRITTEN || cancel_real) { -xfs_defer_init (&dfops, &firstfsb); - (*tpp)->t_dfops = &dfops; +xfs_defer_init (*tpp, &dfops, &firstfsb);/* Free the CoW orphan record. */ error = xfs_refcount_free_cow_extent(ip->i_mount,@@ -764,8 +762,7 @@ xfs_reflink_end_cow( goto prev_extent;/* Unmap the old blocks in the data fork. */ -xfs_defer_init (&dfops, &firstfsb); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstfsb); rlen = del.br_blockcount; error =__xfs_bunmapi (tp, ip, del.br_startoff, &rlen,0 ,1 , &firstfsb);@@ -1115,8 +1112,7 @@ xfs_reflink_remap_extent(/* Unmap the old blocks in the data fork. */ rlen = unmap_len;while (rlen) { -xfs_defer_init (&dfops, &firstfsb); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstfsb); error =__xfs_bunmapi (tp, ip, destoff, &rlen,0 ,1 , &firstfsb);if (error) goto out_defer;fs/xfs/xfs_rtalloc.c +1
-2@@ -787,8 +787,7 @@ xfs_growfs_rt_alloc(xfs_ilock (ip,XFS_ILOCK_EXCL );xfs_trans_ijoin (tp, ip,XFS_ILOCK_EXCL ); -xfs_defer_init (&dfops, &firstblock); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &firstblock);/* * Allocate blocks to the bitmap file. */ fs/xfs/xfs_symlink.c +2
-4@@ -246,8 +246,7 @@ xfs_symlink(* Initialize the bmap freelist prior to calling either * bmapi or the directory create code. */ -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block);/* * Allocate an inode for the symlink. @@ -443,8 +442,7 @@ xfs_inactive_symlink_rmt(* Find the block(s) so we can inval and unmap them. */ done =0 ; -xfs_defer_init (&dfops, &first_block); - tp->t_dfops = &dfops; +xfs_defer_init (tp, &dfops, &first_block); nmaps =ARRAY_SIZE (mval); error =xfs_bmapi_read (ip,0 ,xfs_symlink_blocks (mp, size), mval, &nmaps,0 );Signature · 6 lines
2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · Brian Foster
I think these issues can be mostly resolved by the end goal of a combined xfs_trans/xfs_defer_ops structure. Boilerplate code that allocates a transaction, inits a dfops, finishes a dfops and commits the transaction can then reduce to allocating and committing the transaction (where the former and latter respectively init/finish an internal dfops). There are other patterns and issues to consider, however, so that will be a matter for a subsequent patch series. (I'm actually thinking of cleaning up all of the firstblock stuff as a next step in that direction.)
Yes, I actually did a pass at firstblock a while ago when looking into the allocation reservation issues. It cleaned things up a lot, but I ended up dropping it as it didn't actually end up helping to solve the problem directly.
Quoted 11 lines · Christoph Hellwig
Quoted 9 lines · Brian Foster
I think these issues can be mostly resolved by the end goal of a combined xfs_trans/xfs_defer_ops structure. Boilerplate code that allocates a transaction, inits a dfops, finishes a dfops and commits the transaction can then reduce to allocating and committing the transaction (where the former and latter respectively init/finish an internal dfops). There are other patterns and issues to consider, however, so that will be a matter for a subsequent patch series. (I'm actually thinking of cleaning up all of the firstblock stuff as a next step in that direction.)
Quoted 4 lines
Yes, I actually did a pass at firstblock a while ago when looking into the allocation reservation issues. It cleaned things up a lot, but I ended up dropping it as it didn't actually end up helping to solve the problem directly.
I slapped a series together to deal with firstblock at the end of last week and it survived testing over the weekend. It's basically a similar sequence as this one, replacing the on-stack firstblock instances with a ->t_firstblock field in the transaction and ultimately eliminating the need to pass it to xfs_defer_init(). I should be able to get it posted soon now that this set has been reviewed. Thanks!
Brian
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html