xfsprogs: Delayed Attributes
v14 cover xfsprogs: Delayed Attributes
Hi all,
This set applies the corresponding changes for delayed attributes to xfsprogs. I will pick up the reviews from the kernel side series and mirror them here. This set also includes some patches from the kernel side that have not yet been ported. This set also includes patches needed for the user space cli and log printing routines
Additionally, the following updates have been made since v13:
xfsprogs: Add log item printing for ATTRI and ATTRD
Modified print routines to print names and values as strings
if they are printable, or hexdump if they are not
Added helper function is_printable
Added helper function print_or_dump
Misc alignment fixes in xlog_print_record
This series can also be viewed on github here:
https://github.com/allisonhenderson/xfs_work/tree/delay_ready_attrs_xfsprogs_v14
And also the extended delayed attribute and parent pointer series:
https://github.com/allisonhenderson/xfs_work/tree/delay_ready_attrs_xfsprogs_v14_extended
Thanks all!
Allison
Allison Collins (3):
xfsprogs: Add helper xfs_attr_node_remove_step
xfsprogs: Add xfs_attr_set_deferred and xfs_attr_remove_deferred
xfsprogs: Add delayed attributes error tag
Allison Henderson (11):
xfsprogs: Add xfs_attr_node_remove_cleanup
xfsprogs: Hoist transaction handling in xfs_attr_node_remove_step
xfsprogs: Add delay ready attr remove routines
xfsprogs: Add delay ready attr set routines
xfsprogs: Add state machine tracepoints
xfsprogs: Rename __xfs_attr_rmtval_remove
xfsprogs: Set up infastructure for deferred attribute operations
xfsprogs: Skip flip flags for delayed attrs
xfsprogs: Remove unused xfs_attr_*_args
xfsprogs: Merge xfs_delattr_context into xfs_attr_item
xfsprogs: Add log item printing for ATTRI and ATTRD
include/libxfs.h | 1 + include/xfs_trace.h | 1 + io/inject.c | 1 + libxfs/defer_item.c | 128 ++++++++++ libxfs/libxfs_priv.h | 1 + libxfs/xfs_attr.c | 632 ++++++++++++++++++++++++++++++++--------------- libxfs/xfs_attr.h | 360 ++++++++++++++++++++++++++- libxfs/xfs_attr_leaf.c | 5 +- libxfs/xfs_attr_remote.c | 126 ++++++---- libxfs/xfs_attr_remote.h | 7 +- libxfs/xfs_defer.c | 1 + libxfs/xfs_defer.h | 2 + libxfs/xfs_errortag.h | 4 +- libxfs/xfs_log_format.h | 43 +++- logprint/log_misc.c | 48 +++- logprint/log_print_all.c | 12 + logprint/log_redo.c | 198 +++++++++++++++ logprint/logprint.h | 12 + 18 files changed, 1331 insertions(+), 251 deletions(-)
Signature · 1 line
2.7.4
PATCH v14 1/14 xfsprogs: Add helper xfs_attr_node_remove_step
From: Allison Collins <[email protected]>
Source kernel commit: 5e2aff99f8f0b7ff511b7bbd1213743f59806878
This patch as a new helper function xfs_attr_node_remove_step. This will help simplify and modularize the calling function xfs_attr_node_remove.
--- libxfs/xfs_attr.c | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-)
libxfs/xfs_attr.c +34 -12
@@ -1228,19 +1228,14 @@ xfs_attr_node_remove_rmt(* the root node (a special case of an intermediate node). */ STATIC int -xfs_attr_node_removename ( -struct xfs_da_args *args) +xfs_attr_node_remove_step ( +struct xfs_da_args *args, +struct xfs_da_state *state) { -struct xfs_da_state *state;struct xfs_da_state_blk *blk;int retval, error;struct xfs_inode *dp = args->dp; -trace_xfs_attr_node_removename (args); - - error =xfs_attr_node_removename_setup (args, &state); -if (error) - goto out;/* * If there is an out-of-line value, de-allocate the blocks.
@@ -1250,7 +1245,7 @@ xfs_attr_node_removename(if (args->rmtblkno >0 ) { error =xfs_attr_node_remove_rmt (args, state);if (error) - goto out; +return error; }/*
@@ -1267,18 +1262,45 @@ xfs_attr_node_removename(if (retval && (state->path.active >1 )) { error =xfs_da3_join (state);if (error) - goto out; +return error; error =xfs_defer_finish (&args->trans);if (error) - goto out; +return error;/* * Commit the Btree join operation and start a new trans. */ error =xfs_trans_roll_inode (&args->trans, dp);if (error) - goto out; +return error; } +return error; +} + +/* +* Remove a name from a B-tree attribute list. +* +* This routine will find the blocks of the name to remove, remove them and +* shrink the tree if needed. +*/ +STATIC int +xfs_attr_node_removename ( +struct xfs_da_args *args) +{ +struct xfs_da_state *state =NULL ; +int error; +struct xfs_inode *dp = args->dp; + +trace_xfs_attr_node_removename (args); + + error =xfs_attr_node_removename_setup (args, &state); +if (error) + goto out; + + error =xfs_attr_node_remove_step (args, state); +if (error) + goto out; +/* * If the result is small enough, push it all into the inode. */
Signature · 1 line
2.7.4
PATCH v14 2/14 xfsprogs: Add xfs_attr_node_remove_cleanup
In reply to Allison HendersonSource kernel commit: 4078af18570ef0f89fce18e9ed9c1fa0c827f37b
This patch pulls a new helper function xfs_attr_node_remove_cleanup out of xfs_attr_node_remove_step. This helps to modularize xfs_attr_node_remove_step which will help make the delayed attribute code easier to follow
--- libxfs/xfs_attr.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-)
libxfs/xfs_attr.c +20 -9
@@ -1220,6 +1220,25 @@ xfs_attr_node_remove_rmt(return xfs_attr_refillstate (state); } +STATIC int +xfs_attr_node_remove_cleanup ( +struct xfs_da_args *args, +struct xfs_da_state *state) +{ +struct xfs_da_state_blk *blk; +int retval; + +/* +* Remove the name and update the hashvals in the tree. +*/ + blk = &state->path.blk[state->path.active-1 ]; +ASSERT (blk->magic ==XFS_ATTR_LEAF_MAGIC ); + retval =xfs_attr3_leaf_remove (blk->bp, args); +xfs_da3_fixhashpath (state, &state->path); + +return retval; +} +/* * Remove a name from a B-tree attribute list. *
@@ -1232,7 +1251,6 @@ xfs_attr_node_remove_step(struct xfs_da_args *args, struct xfs_da_state *state) { - struct xfs_da_state_blk *blk; int retval, error;struct xfs_inode *dp = args->dp;
@@ -1247,14 +1265,7 @@ xfs_attr_node_remove_step(if (error)return error; } - -/* -* Remove the name and update the hashvals in the tree. -*/ - blk = &state->path.blk[ state->path.active-1 ]; -ASSERT (blk->magic ==XFS_ATTR_LEAF_MAGIC ); - retval =xfs_attr3_leaf_remove (blk->bp, args); -xfs_da3_fixhashpath (state, &state->path); + retval =xfs_attr_node_remove_cleanup (args, state);/* * Check to see if the tree needs to be collapsed.
Signature · 1 line
2.7.4
PATCH v14 3/14 xfsprogs: Hoist transaction handling in xfs_attr_node_remove_step
In reply to Allison HendersonSource kernel commit: b091f22a5de672a88865e451545b447d139a9be7
This patch hoists transaction handling in xfs_attr_node_remove to xfs_attr_node_remove_step. This will help keep transaction handling in higher level functions instead of buried in subfunctions when we introduce delay attributes
--- libxfs/xfs_attr.c | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-)
libxfs/xfs_attr.c +22 -21
@@ -1251,7 +1251,7 @@ xfs_attr_node_remove_step(struct xfs_da_args *args, struct xfs_da_state *state) { - int retval, error; + int error;struct xfs_inode *dp = args->dp;
@@ -1265,25 +1265,6 @@ xfs_attr_node_remove_step(if (error)return error; } - retval =xfs_attr_node_remove_cleanup (args, state); - -/* -* Check to see if the tree needs to be collapsed. -*/ -if (retval && (state->path.active >1 )) { - error =xfs_da3_join (state); -if (error) -return error; - error =xfs_defer_finish (&args->trans); -if (error) -return error; -/* -* Commit the Btree join operation and start a new trans. -*/ - error =xfs_trans_roll_inode (&args->trans, dp); -if (error) -return error; - }return error; }
@@ -1299,7 +1280,7 @@ xfs_attr_node_removename( struct xfs_da_args *args) {struct xfs_da_state *state =NULL ; -int error; +int retval, error;struct xfs_inode *dp = args->dp;trace_xfs_attr_node_removename (args);
@@ -1312,6 +1293,26 @@ xfs_attr_node_removename(if (error) goto out; + retval =xfs_attr_node_remove_cleanup (args, state); + +/* +* Check to see if the tree needs to be collapsed. +*/ +if (retval && (state->path.active >1 )) { + error =xfs_da3_join (state); +if (error) +return error; + error =xfs_defer_finish (&args->trans); +if (error) +return error; +/* +* Commit the Btree join operation and start a new trans. +*/ + error =xfs_trans_roll_inode (&args->trans, dp); +if (error) +return error; + } +/* * If the result is small enough, push it all into the inode. */
Signature · 1 line
2.7.4
PATCH v14 4/14 xfsprogs: Add delay ready attr remove routines
In reply to Allison HendersonThis patch modifies the attr remove routines to be delay ready. This means they no longer roll or commit transactions, but instead return -EAGAIN to have the calling routine roll and refresh the transaction. In this series, xfs_attr_remove_args has become xfs_attr_remove_iter, which uses a sort of state machine like switch to keep track of where it was when EAGAIN was returned. xfs_attr_node_removename has also been modified to use the switch, and a new version of xfs_attr_remove_args consists of a simple loop to refresh the transaction until the operation is completed. A new XFS_DAC_DEFER_FINISH flag is used to finish the transaction where ever the existing code used to.
Calls to xfs_attr_rmtval_remove are replaced with the delay ready version __xfs_attr_rmtval_remove. We will rename __xfs_attr_rmtval_remove back to xfs_attr_rmtval_remove when we are done.
xfs_attr_rmtval_remove itself is still in use by the set routines (used during a rename). For reasons of preserving existing function, we modify xfs_attr_rmtval_remove to call xfs_defer_finish when the flag is set. Similar to how xfs_attr_remove_args does here. Once we transition the set routines to be delay ready, xfs_attr_rmtval_remove is no longer used and will be removed.
This patch also adds a new struct xfs_delattr_context, which we will use to keep track of the current state of an attribute operation. The new xfs_delattr_state enum is used to track various operations that are in progress so that we know not to repeat them, and resume where we left off before EAGAIN was returned to cycle out the transaction. Other members take the place of local variables that need to retain their values across multiple function recalls. See xfs_attr.h for a more detailed diagram of the states.
--- include/libxfs.h | 1 + libxfs/xfs_attr.c | 218 ++++++++++++++++++++++++++++++++++------------- libxfs/xfs_attr.h | 100 ++++++++++++++++++++++ libxfs/xfs_attr_leaf.c | 2 +- libxfs/xfs_attr_remote.c | 48 ++++++----- libxfs/xfs_attr_remote.h | 2 +- 6 files changed, 288 insertions(+), 83 deletions(-)
include/libxfs.h +1 -0
@@ -168,6 +168,7 @@ enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC };#include "xfs_ialloc.h" #include "xfs_attr_leaf.h" +#include "xfs_attr.h" #include "xfs_attr_remote.h" #include "xfs_trans_space.h"
libxfs/xfs_attr.c +157 -61
295 lines not on this page · raw message
libxfs/xfs_attr.h +100 -0
112 lines not on this page · raw message
libxfs/xfs_attr_leaf.c +1 -1
@@ -19,8 +19,8 @@#include "xfs_bmap_btree.h" #include "xfs_bmap.h" #include "xfs_attr_sf.h" -#include "xfs_attr_remote.h" #include "xfs_attr.h" +#include "xfs_attr_remote.h" #include "xfs_attr_leaf.h" #include "xfs_trace.h" #include "xfs_dir2.h"
libxfs/xfs_attr_remote.c +28 -20
81 lines not on this page · raw message
libxfs/xfs_attr_remote.h +1 -1
@@ -14,5 +14,5 @@ int xfs_attr_rmtval_remove(struct xfs_da_args *args);int xfs_attr_rmtval_stale (struct xfs_inode *ip,struct xfs_bmbt_irec *map,xfs_buf_flags_t incore_flags);int xfs_attr_rmtval_invalidate (struct xfs_da_args *args); -int __xfs_attr_rmtval_remove (struct xfs_da_args *args); +int __xfs_attr_rmtval_remove (struct xfs_delattr_context *dac);#endif /* __XFS_ATTR_REMOTE_H__ */
Signature · 1 line
2.7.4
PATCH v14 5/14 xfsprogs: Add delay ready attr set routines
In reply to Allison HendersonThis patch modifies the attr set routines to be delay ready. This means they no longer roll or commit transactions, but instead return -EAGAIN to have the calling routine roll and refresh the transaction. In this series, xfs_attr_set_args has become xfs_attr_set_iter, which uses a state machine like switch to keep track of where it was when EAGAIN was returned. See xfs_attr.h for a more detailed diagram of the states.
Two new helper functions have been added: xfs_attr_rmtval_set_init and xfs_attr_rmtval_set_blk. They provide a subset of logic similar to xfs_attr_rmtval_set, but they store the current block in the delay attr context to allow the caller to roll the transaction between allocations. This helps to simplify and consolidate code used by xfs_attr_leaf_addname and xfs_attr_node_addname. xfs_attr_set_args has now become a simple loop to refresh the transaction until the operation is completed. Lastly, xfs_attr_rmtval_remove is no longer used, and is removed.
--- libxfs/xfs_attr.c | 357 +++++++++++++++++++++++++++++++---------------- libxfs/xfs_attr.h | 235 ++++++++++++++++++++++++++++++- libxfs/xfs_attr_remote.c | 98 ++++++++----- libxfs/xfs_attr_remote.h | 5 +- 4 files changed, 541 insertions(+), 154 deletions(-)
libxfs/xfs_attr.c +238 -119
@@ -44,7 +44,7 @@ STATIC int xfs_attr_shortform_addname(xfs_da_args_t *args);* Internal routines when attribute list is one block. */ STATIC int xfs_attr_leaf_get(xfs_da_args_t *args); -STATIC int xfs_attr_leaf_addname(xfs_da_args_t *args); +STATIC int xfs_attr_leaf_addname(struct xfs_delattr_context *dac); STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args); STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp);
@@ -52,12 +52,15 @@ STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp);* Internal routines when attribute list is more than one block. */ STATIC int xfs_attr_node_get(xfs_da_args_t *args); -STATIC int xfs_attr_node_addname(xfs_da_args_t *args); +STATIC int xfs_attr_node_addname(struct xfs_delattr_context *dac); STATIC int xfs_attr_node_removename_iter(struct xfs_delattr_context *dac); STATIC int xfs_attr_node_hasname(xfs_da_args_t *args,struct xfs_da_state **state); STATIC int xfs_attr_fillstate(xfs_da_state_t *state); STATIC int xfs_attr_refillstate(xfs_da_state_t *state); +STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp); +STATIC int xfs_attr_set_iter(struct xfs_delattr_context *dac, +struct xfs_buf **leaf_bp);int xfs_inode_hasattr(
@@ -218,8 +221,11 @@ xfs_attr_is_shortform(/* * Attempts to set an attr in shortform, or converts short form to leaf form if -* there is not enough room. If the attr is set, the transaction is committed -* and set to NULL. +* there is not enough room. This function is meant to operate as a helper +* routine to the delayed attribute functions. It returns -EAGAIN to indicate +* that the calling function should roll the transaction, and then proceed to +* add the attr in leaf form. This subroutine does not expect to be recalled +* again like the other delayed attr routines do. */ STATIC int xfs_attr_set_shortform(
@@ -227,16 +233,16 @@ xfs_attr_set_shortform( struct xfs_buf **leaf_bp) {struct xfs_inode *dp = args->dp; -int error, error2 =0 ; +int error =0 ;/* * Try to add the attr to the attribute list in the inode. */ error =xfs_attr_try_sf_addname (dp, args); + +/* Should only be 0, -EEXIST or -ENOSPC */ if (error != -ENOSPC ) { - error2 =xfs_trans_commit (args->trans); - args->trans =NULL ; -return error ? error : error2; +return error; }/* * It won't fit in the shortform, transform to a leaf block. GROT:
@@ -249,18 +255,15 @@ xfs_attr_set_shortform(/* * Prevent the leaf buffer from being unlocked so that a concurrent AIL * push cannot grab the half-baked leaf buffer and run into problems -* with the write verifier. Once we're done rolling the transaction we -* can release the hold and add the attr to the leaf. +* with the write verifier. */ xfs_trans_bhold (args->trans, *leaf_bp); - error =xfs_defer_finish (&args->trans); -xfs_trans_bhold_release (args->trans, *leaf_bp); -if (error) { -xfs_trans_brelse (args->trans, *leaf_bp); -return error; - } -return 0 ; +/* +* We're still in XFS_DAS_UNINIT state here. We've converted the attr +* fork to leaf format and will restart with the leaf add. +*/ +return -EAGAIN ; }/*
@@ -268,7 +271,7 @@ xfs_attr_set_shortform(* also checks for a defer finish. Transaction is finished and rolled as * needed, and returns true of false if the delayed operation should continue. */ -int +STATIC intxfs_attr_trans_roll (struct xfs_delattr_context *dac) {
@@ -298,34 +301,95 @@ intxfs_attr_set_args ( struct xfs_da_args *args) { -struct xfs_inode *dp = args->dp; -struct xfs_buf *leaf_bp =NULL ; -int error =0 ; +struct xfs_buf *leaf_bp =NULL ; +int error =0 ; +struct xfs_delattr_context dac = { + .da_args = args, + }; + +do { + error =xfs_attr_set_iter (&dac, &leaf_bp); +if (error != -EAGAIN ) +break ; + + error =xfs_attr_trans_roll (&dac); +if (error) +return error; + }while (true); + +return error; +} + +/* +* Set the attribute specified in @args. +* This routine is meant to function as a delayed operation, and may return +* -EAGAIN when the transaction needs to be rolled. Calling functions will need +* to handle this, and recall the function until a successful error code is +* returned. +*/ +STATIC int +xfs_attr_set_iter ( +struct xfs_delattr_context *dac, +struct xfs_buf **leaf_bp) +{ +struct xfs_da_args *args = dac->da_args; +struct xfs_inode *dp = args->dp; +int error =0 ; + +/* State machine switch */ +switch (dac->dela_state) { +case XFS_DAS_FLIP_LFLAG : +case XFS_DAS_FOUND_LBLK : +case XFS_DAS_RM_LBLK : +return xfs_attr_leaf_addname (dac); +case XFS_DAS_FOUND_NBLK : +case XFS_DAS_FLIP_NFLAG : +case XFS_DAS_ALLOC_NODE : +return xfs_attr_node_addname (dac); +case XFS_DAS_UNINIT : +break ; +default : +ASSERT (dac->dela_state !=XFS_DAS_RM_SHRINK ); +break ; + }/* * If the attribute list is already in leaf format, jump straight to * leaf handling. Otherwise, try to add the attribute to the shortform * list; if there's no room then convert the list to leaf format and try -* again. +* again. No need to set state as we will be in leaf form when we come +* back */ if (xfs_attr_is_shortform (dp)) {/* -* If the attr was successfully set in shortform, the -* transaction is committed and set to NULL. Otherwise, is it -* converted from shortform to leaf, and the transaction is -* retained. +* If the attr was successfully set in shortform, no need to +* continue. Otherwise, is it converted from shortform to leaf +* and -EAGAIN is returned. */ - error =xfs_attr_set_shortform (args, &leaf_bp); -if (error || !args->trans) -return error; + error =xfs_attr_set_shortform (args, leaf_bp); +if (error == -EAGAIN ) + dac->flags |=XFS_DAC_DEFER_FINISH ; + +return error; } -if (xfs_bmap_one_block (dp,XFS_ATTR_FORK )) { - error =xfs_attr_leaf_addname (args); -if (error != -ENOSPC ) -return error; +/* +* After a shortform to leaf conversion, we need to hold the leaf and +* cycle out the transaction. When we get back, we need to release +* the leaf to release the hold on the leaf buffer. +*/ +if (*leaf_bp !=NULL ) { +xfs_trans_bhold_release (args->trans, *leaf_bp); + *leaf_bp =NULL ; + } + +if (!xfs_bmap_one_block (dp,XFS_ATTR_FORK )) +return xfs_attr_node_addname (dac); + error =xfs_attr_leaf_try_add (args, *leaf_bp); +switch (error) { +case -ENOSPC :/* * Promote the attribute list to the Btree format. */
@@ -334,25 +398,22 @@ xfs_attr_set_args(return error;/* -* Finish any deferred work items and roll the transaction once -* more. The goal here is to call node_addname with the inode -* and transaction in the same state (inode locked and joined, -* transaction clean) no matter how we got to this step. -*/ - error =xfs_defer_finish (&args->trans); -if (error) -return error; - -/* -* Commit the current trans (including the inode) and -* start a new one. +* Finish any deferred work items and roll the +* transaction once more. The goal here is to call +* node_addname with the inode and transaction in the +* same state (inode locked and joined, transaction +* clean) no matter how we got to this step. +* +* At this point, we are still in XFS_DAS_UNINIT, but +* when we come back, we'll be a node, so we'll fall +* down into the node handling code below */ - error =xfs_trans_roll_inode (&args->trans, dp); -if (error) -return error; + dac->flags |=XFS_DAC_DEFER_FINISH ; +return -EAGAIN ; +case 0 : + dac->dela_state =XFS_DAS_FOUND_LBLK ; +return -EAGAIN ; } - - error =xfs_attr_node_addname (args);return error; }
@@ -728,28 +789,30 @@ out_brelse:* * This leaf block cannot have a "remote" value, we only call this routine * if bmap_one_block() says there is only one block (ie: no remote blks). +* +* This routine is meant to function as a delayed operation, and may return +* -EAGAIN when the transaction needs to be rolled. Calling functions will need +* to handle this, and recall the function until a successful error code is +* returned. */ STATIC intxfs_attr_leaf_addname ( -struct xfs_da_args *args) +struct xfs_delattr_context *dac) { -int error, forkoff; -struct xfs_buf *bp =NULL ; -struct xfs_inode *dp = args->dp; - -trace_xfs_attr_leaf_addname (args); - - error =xfs_attr_leaf_try_add (args, bp); -if (error) -return error; +struct xfs_da_args *args = dac->da_args; +struct xfs_buf *bp =NULL ; +int error, forkoff; +struct xfs_inode *dp = args->dp; -/* -* Commit the transaction that added the attr name so that -* later routines can manage their own transactions. -*/ - error =xfs_trans_roll_inode (&args->trans, dp); -if (error) -return error; +/* State machine switch */ +switch (dac->dela_state) { +case XFS_DAS_FLIP_LFLAG : + goto das_flip_flag; +case XFS_DAS_RM_LBLK : + goto das_rm_lblk; +default : +break ; + }/* * If there was an out-of-line value, allocate the blocks we
@@ -757,12 +820,34 @@ xfs_attr_leaf_addname(* after we create the attribute so that we don't overflow the * maximum size of a transaction and/or hit a deadlock. */ -if (args->rmtblkno >0 ) { - error =xfs_attr_rmtval_set (args); + +/* Open coded xfs_attr_rmtval_set without trans handling */ +if ((dac->flags &XFS_DAC_LEAF_ADDNAME_INIT ) ==0 ) { + dac->flags |=XFS_DAC_LEAF_ADDNAME_INIT ; +if (args->rmtblkno >0 ) { + error =xfs_attr_rmtval_find_space (dac); +if (error) +return error; + } + } + +/* +* Roll through the "value", allocating blocks on disk as +* required. +*/ +if (dac->blkcnt >0 ) { + error =xfs_attr_rmtval_set_blk (dac);if (error)return error; + + dac->flags |=XFS_DAC_DEFER_FINISH ; +return -EAGAIN ; } + error =xfs_attr_rmtval_set_value (args); +if (error) +return error; +if (!(args->op_flags &XFS_DA_OP_RENAME )) {/* * Added a "remote" value, just clear the incomplete flag.
@@ -782,29 +867,30 @@ xfs_attr_leaf_addname(* In a separate transaction, set the incomplete flag on the "old" attr * and clear the incomplete flag on the "new" attr. */ - error =xfs_attr3_leaf_flipflags (args);if (error)return error;/* * Commit the flag value change and start the next trans in series. */ - error =xfs_trans_roll_inode (&args->trans, args->dp); -if (error) -return error; - + dac->dela_state =XFS_DAS_FLIP_LFLAG ; +return -EAGAIN ; +das_flip_flag:/* * Dismantle the "old" attribute/value pair by removing a "remote" value * (if it exists). */ xfs_attr_restore_rmt_blk (args); -if (args->rmtblkno) { - error =xfs_attr_rmtval_invalidate (args); -if (error) -return error; + error =xfs_attr_rmtval_invalidate (args); +if (error) +return error; - error =xfs_attr_rmtval_remove (args); +/* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ + dac->dela_state =XFS_DAS_RM_LBLK ; +das_rm_lblk: +if (args->rmtblkno) { + error =__xfs_attr_rmtval_remove (dac);if (error)return error; }
@@ -970,23 +1056,38 @@ xfs_attr_node_hasname(* * "Remote" attribute values confuse the issue and atomic rename operations * add a whole extra layer of confusion on top of that. +* +* This routine is meant to function as a delayed operation, and may return +* -EAGAIN when the transaction needs to be rolled. Calling functions will need +* to handle this, and recall the function until a successful error code is +*returned. */ STATIC intxfs_attr_node_addname ( -struct xfs_da_args *args) +struct xfs_delattr_context *dac) { -struct xfs_da_state *state; -struct xfs_da_state_blk *blk; -struct xfs_inode *dp; -int retval, error; +struct xfs_da_args *args = dac->da_args; +struct xfs_da_state *state =NULL ; +struct xfs_da_state_blk *blk; +int retval =0 ; +int error =0 ;trace_xfs_attr_node_addname (args); -/* -* Fill in bucket of arguments/results/context to carry around. -*/ - dp = args->dp; -restart: +/* State machine switch */ +switch (dac->dela_state) { +case XFS_DAS_FLIP_NFLAG : + goto das_flip_flag; +case XFS_DAS_FOUND_NBLK : + goto das_found_nblk; +case XFS_DAS_ALLOC_NODE : + goto das_alloc_node; +case XFS_DAS_RM_NBLK : + goto das_rm_nblk; +default : +break ; + } +/* * Search to see if name already exists, and get back a pointer * to where it should go.
@@ -1032,19 +1133,16 @@ restart: error =xfs_attr3_leaf_to_node (args);if (error) goto out; - error =xfs_defer_finish (&args->trans); -if (error) - goto out;/* -* Commit the node conversion and start the next -* trans in the chain. +* Now that we have converted the leaf to a node, we can +* roll the transaction, and try xfs_attr3_leaf_add +* again on re-entry. No need to set dela_state to do +* this. dela_state is still unset by this function at +* this point. */ - error =xfs_trans_roll_inode (&args->trans, dp); -if (error) - goto out; - - goto restart; + dac->flags |=XFS_DAC_DEFER_FINISH ; +return -EAGAIN ; }/*
@@ -1056,9 +1154,7 @@ restart: error =xfs_da3_split (state);if (error) goto out; - error =xfs_defer_finish (&args->trans); -if (error) - goto out; + dac->flags |=XFS_DAC_DEFER_FINISH ; }else {/* * Addition succeeded, update Btree hashvals.
@@ -1066,6 +1162,11 @@ restart:xfs_da3_fixhashpath (state, &state->path); } +if (!args->rmtblkno && !(args->op_flags &XFS_DA_OP_RENAME )) { + retval = error; + goto out; + } +/* * Kill the state structure, we're done with it and need to * allow the buffers to come back later.
@@ -1073,13 +1174,9 @@ restart:xfs_da_state_free (state); state =NULL ; -/* -* Commit the leaf addition or btree split and start the next -* trans in the chain. -*/ - error =xfs_trans_roll_inode (&args->trans, dp); -if (error) - goto out; + dac->dela_state =XFS_DAS_FOUND_NBLK ; +return -EAGAIN ; +das_found_nblk:/* * If there was an out-of-line value, allocate the blocks we
@@ -1088,7 +1185,27 @@ restart:* maximum size of a transaction and/or hit a deadlock. */ if (args->rmtblkno >0 ) { - error =xfs_attr_rmtval_set (args); +/* Open coded xfs_attr_rmtval_set without trans handling */ + error =xfs_attr_rmtval_find_space (dac); +if (error) +return error; + +/* +* Roll through the "value", allocating blocks on disk as +* required. Set the state in case of -EAGAIN return code +*/ + dac->dela_state =XFS_DAS_ALLOC_NODE ; +das_alloc_node: +if (dac->blkcnt >0 ) { + error =xfs_attr_rmtval_set_blk (dac); +if (error) +return error; + + dac->flags |=XFS_DAC_DEFER_FINISH ; +return -EAGAIN ; + } + + error =xfs_attr_rmtval_set_value (args);if (error)return error; }
@@ -1118,22 +1235,24 @@ restart:/* * Commit the flag value change and start the next trans in series */ - error =xfs_trans_roll_inode (&args->trans, args->dp); -if (error) - goto out; - + dac->dela_state =XFS_DAS_FLIP_NFLAG ; +return -EAGAIN ; +das_flip_flag:/* * Dismantle the "old" attribute/value pair by removing a "remote" value * (if it exists). */ xfs_attr_restore_rmt_blk (args); -if (args->rmtblkno) { - error =xfs_attr_rmtval_invalidate (args); -if (error) -return error; + error =xfs_attr_rmtval_invalidate (args); +if (error) +return error; - error =xfs_attr_rmtval_remove (args); +/* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ + dac->dela_state =XFS_DAS_RM_NBLK ; +das_rm_nblk: +if (args->rmtblkno) { + error =__xfs_attr_rmtval_remove (dac);if (error)return error; }
libxfs/xfs_attr.h +234 -1
265 lines not on this page · raw message
libxfs/xfs_attr_remote.c +65 -33
122 lines not on this page · raw message
libxfs/xfs_attr_remote.h +4 -1
@@ -10,9 +10,12 @@ int xfs_attr3_rmt_blocks(struct xfs_mount *mp, int attrlen);int xfs_attr_rmtval_get (struct xfs_da_args *args);int xfs_attr_rmtval_set (struct xfs_da_args *args); -int xfs_attr_rmtval_remove (struct xfs_da_args *args);int xfs_attr_rmtval_stale (struct xfs_inode *ip,struct xfs_bmbt_irec *map,xfs_buf_flags_t incore_flags);int xfs_attr_rmtval_invalidate (struct xfs_da_args *args);int __xfs_attr_rmtval_remove (struct xfs_delattr_context *dac); +int xfs_attr_rmt_find_hole (struct xfs_da_args *args); +int xfs_attr_rmtval_set_value (struct xfs_da_args *args); +int xfs_attr_rmtval_set_blk (struct xfs_delattr_context *dac); +int xfs_attr_rmtval_find_space (struct xfs_delattr_context *dac);#endif /* __XFS_ATTR_REMOTE_H__ */
Signature · 1 line
2.7.4
PATCH v14 6/14 xfsprogs: Add state machine tracepoints
In reply to Allison HendersonSource kernel commit: 5421d11d87aa32479cb41c18e2487db3b3a75cde
This is a quick patch to add a new tracepoint: xfs_das_state_return. We use this to track when ever a new state is set or -EAGAIN is returned
--- include/xfs_trace.h | 1 + libxfs/xfs_attr.c | 22 +++++++++++++++++++++- libxfs/xfs_attr_remote.c | 1 + 3 files changed, 23 insertions(+), 1 deletion(-)
include/xfs_trace.h +1 -0
@@ -314,4 +314,5 @@#define trace_xfs_perag_get_tag (a,b,c,d) ((c) = (c))#define trace_xfs_perag_put (a,b,c,d) ((c) = (c)) +#define trace_xfs_das_state_return (a) ((void) 0)#endif /* __TRACE_H__ */
libxfs/xfs_attr.c +21 -1
@@ -263,6 +263,7 @@ xfs_attr_set_shortform(* We're still in XFS_DAS_UNINIT state here. We've converted the attr * fork to leaf format and will restart with the leaf add. */ +trace_xfs_das_state_return (XFS_DAS_UNINIT );return -EAGAIN ; }
@@ -409,9 +410,11 @@ xfs_attr_set_iter(* down into the node handling code below */ dac->flags |=XFS_DAC_DEFER_FINISH ; +trace_xfs_das_state_return (dac->dela_state);return -EAGAIN ;case 0 : dac->dela_state =XFS_DAS_FOUND_LBLK ; +trace_xfs_das_state_return (dac->dela_state);return -EAGAIN ; }return error;
@@ -841,6 +844,7 @@ xfs_attr_leaf_addname(return error; dac->flags |=XFS_DAC_DEFER_FINISH ; +trace_xfs_das_state_return (dac->dela_state);return -EAGAIN ; }
@@ -874,6 +878,7 @@ xfs_attr_leaf_addname(* Commit the flag value change and start the next trans in series. */ dac->dela_state =XFS_DAS_FLIP_LFLAG ; +trace_xfs_das_state_return (dac->dela_state);return -EAGAIN ; das_flip_flag:/*
@@ -891,6 +896,8 @@ das_flip_flag: das_rm_lblk:if (args->rmtblkno) { error =__xfs_attr_rmtval_remove (dac); +if (error == -EAGAIN ) +trace_xfs_das_state_return (dac->dela_state);if (error)return error; }
@@ -1142,6 +1149,7 @@ xfs_attr_node_addname(* this point. */ dac->flags |=XFS_DAC_DEFER_FINISH ; +trace_xfs_das_state_return (dac->dela_state);return -EAGAIN ; }
@@ -1175,6 +1183,7 @@ xfs_attr_node_addname( state =NULL ; dac->dela_state =XFS_DAS_FOUND_NBLK ; +trace_xfs_das_state_return (dac->dela_state);return -EAGAIN ; das_found_nblk:
@@ -1202,6 +1211,7 @@ das_alloc_node:return error; dac->flags |=XFS_DAC_DEFER_FINISH ; +trace_xfs_das_state_return (dac->dela_state);return -EAGAIN ; }
@@ -1236,6 +1246,7 @@ das_alloc_node:* Commit the flag value change and start the next trans in series */ dac->dela_state =XFS_DAS_FLIP_NFLAG ; +trace_xfs_das_state_return (dac->dela_state);return -EAGAIN ; das_flip_flag:/*
@@ -1253,6 +1264,10 @@ das_flip_flag: das_rm_nblk:if (args->rmtblkno) { error =__xfs_attr_rmtval_remove (dac); + +if (error == -EAGAIN ) +trace_xfs_das_state_return (dac->dela_state); +if (error)return error; }
@@ -1396,6 +1411,8 @@ xfs_attr_node_remove_rmt (* May return -EAGAIN to request that the caller recall this function */ error =__xfs_attr_rmtval_remove (dac); +if (error == -EAGAIN ) +trace_xfs_das_state_return (dac->dela_state);if (error)return error;
@@ -1514,6 +1531,7 @@ xfs_attr_node_removename_iter( dac->flags |=XFS_DAC_DEFER_FINISH ; dac->dela_state =XFS_DAS_RM_SHRINK ; +trace_xfs_das_state_return (dac->dela_state);return -EAGAIN ; }
@@ -1532,8 +1550,10 @@ xfs_attr_node_removename_iter( goto out; } -if (error == -EAGAIN ) +if (error == -EAGAIN ) { +trace_xfs_das_state_return (dac->dela_state);return error; + } out:if (state)xfs_da_state_free (state);
libxfs/xfs_attr_remote.c +1 -0
@@ -762,6 +762,7 @@ __xfs_attr_rmtval_remove(*/ if (!done) { dac->flags |=XFS_DAC_DEFER_FINISH ; +trace_xfs_das_state_return (dac->dela_state);return -EAGAIN ; }
Signature · 1 line
2.7.4
PATCH v14 7/14 xfsprogs: Rename __xfs_attr_rmtval_remove
In reply to Allison HendersonNow that xfs_attr_rmtval_remove is gone, rename __xfs_attr_rmtval_remove to xfs_attr_rmtval_remove
--- libxfs/xfs_attr.c | 6 +++--- libxfs/xfs_attr_remote.c | 2 +- libxfs/xfs_attr_remote.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
libxfs/xfs_attr.c +3 -3
@@ -895,7 +895,7 @@ das_flip_flag: dac->dela_state =XFS_DAS_RM_LBLK ; das_rm_lblk:if (args->rmtblkno) { - error =__xfs_attr_rmtval_remove (dac); + error =xfs_attr_rmtval_remove (dac);if (error == -EAGAIN )trace_xfs_das_state_return (dac->dela_state);if (error)
@@ -1263,7 +1263,7 @@ das_flip_flag: dac->dela_state =XFS_DAS_RM_NBLK ; das_rm_nblk:if (args->rmtblkno) { - error =__xfs_attr_rmtval_remove (dac); + error =xfs_attr_rmtval_remove (dac);if (error == -EAGAIN )trace_xfs_das_state_return (dac->dela_state);
@@ -1410,7 +1410,7 @@ xfs_attr_node_remove_rmt (/* * May return -EAGAIN to request that the caller recall this function */ - error =__xfs_attr_rmtval_remove (dac); + error =xfs_attr_rmtval_remove (dac);if (error == -EAGAIN )trace_xfs_das_state_return (dac->dela_state);if (error)
libxfs/xfs_attr_remote.c +1 -1
@@ -736,7 +736,7 @@ xfs_attr_rmtval_invalidate(* transaction and re-call the function */ int -__xfs_attr_rmtval_remove ( +xfs_attr_rmtval_remove (struct xfs_delattr_context *dac) {struct xfs_da_args *args = dac->da_args;
libxfs/xfs_attr_remote.h +1 -1
@@ -13,7 +13,7 @@ int xfs_attr_rmtval_set(struct xfs_da_args *args);int xfs_attr_rmtval_stale (struct xfs_inode *ip,struct xfs_bmbt_irec *map,xfs_buf_flags_t incore_flags);int xfs_attr_rmtval_invalidate (struct xfs_da_args *args); -int __xfs_attr_rmtval_remove (struct xfs_delattr_context *dac); +int xfs_attr_rmtval_remove (struct xfs_delattr_context *dac);int xfs_attr_rmt_find_hole (struct xfs_da_args *args);int xfs_attr_rmtval_set_value (struct xfs_da_args *args);int xfs_attr_rmtval_set_blk (struct xfs_delattr_context *dac);
Signature · 1 line
2.7.4
PATCH v14 8/14 xfsprogs: Set up infastructure for deferred attribute operations
In reply to Allison HendersonCurrently attributes are modified directly across one or more transactions. But they are not logged or replayed in the event of an error. The goal of delayed attributes is to enable logging and replaying of attribute operations using the existing delayed operations infrastructure. This will later enable the attributes to become part of larger multi part operations that also must first be recorded to the log. This is mostly of interest in the scheme of parent pointers which would need to maintain an attribute containing parent inode information any time an inode is moved, created, or removed. Parent pointers would then be of interest to any feature that would need to quickly derive an inode path from the mount point. Online scrub, nfs lookups and fs grow or shrink operations are all features that could take advantage of this.
This patch adds two new log item types for setting or removing attributes as deferred operations. The xfs_attri_log_item logs an intent to set or remove an attribute. The corresponding xfs_attrd_log_item holds a reference to the xfs_attri_log_item and is freed once the transaction is done. Both log items use a generic xfs_attr_log_format structure that contains the attribute name, value, flags, inode, and an op_flag that indicates if the operations is a set or remove.
--- libxfs/defer_item.c | 132 ++++++++++++++++++++++++++++++++++++++++++++++++ libxfs/libxfs_priv.h | 1 + libxfs/xfs_attr.c | 7 ++- libxfs/xfs_attr.h | 31 ++++++++++++ libxfs/xfs_defer.c | 1 + libxfs/xfs_defer.h | 2 + libxfs/xfs_log_format.h | 43 +++++++++++++++- 7 files changed, 211 insertions(+), 6 deletions(-)
libxfs/defer_item.c +132 -0
@@ -16,10 +16,14 @@#include "xfs_trans.h" #include "xfs_bmap.h" #include "xfs_alloc.h" +#include "xfs_attr_item.h" #include "xfs_rmap.h" #include "xfs_refcount.h" #include "xfs_bmap.h" #include "xfs_inode.h" +#include "xfs_da_format.h" +#include "xfs_da_btree.h" +#include "xfs_attr.h" /* Dummy defer item ops, since we don't do logging. */
@@ -112,6 +116,134 @@ const struct xfs_defer_op_type xfs_extent_free_defer_type = { .cancel_item = xfs_extent_free_cancel_item, }; +static inline struct xfs_attrd_log_item *ATTRD_ITEM (struct xfs_log_item *lip) +{ + return container_of(lip, struct xfs_attrd_log_item, attrd_item); +} + +/* +* Log an ATTRI it to the ATTRD when the attr op is done. An attr operation +* may be a set or a remove. Note that the transaction is marked dirty +* regardless of whether the operation succeeds or fails to support the +* ATTRI/ATTRD lifecycle rules. +*/ +int +xfs_trans_attr ( +struct xfs_delattr_context *dac, +struct xfs_attrd_log_item *attrdp, +struct xfs_buf **leaf_bp, +uint32_t op_flags) +{ +struct xfs_da_args *args = dac->da_args; +int error; + + error =xfs_qm_dqattach_locked (args->dp,0 ); +if (error) +return error; + +switch (op_flags) { +case XFS_ATTR_OP_FLAGS_SET : + args->op_flags |=XFS_DA_OP_ADDNAME ; + error =xfs_attr_set_iter (dac, leaf_bp); +break ; +case XFS_ATTR_OP_FLAGS_REMOVE : +ASSERT (XFS_IFORK_Q ((args->dp))); + error =xfs_attr_remove_iter (dac); +break ; +default : + error = -EFSCORRUPTED ; +break ; + } + +/* +* Mark the transaction dirty, even on error. This ensures the +* transaction is aborted, which: +* +* 1.) releases the ATTRI and frees the ATTRD +* 2.) shuts down the filesystem +*/ + args->trans->t_flags |=XFS_TRANS_DIRTY ; + +return error; +} + +/* Get an ATTRI. */ +static struct xfs_log_item * +xfs_attr_create_intent ( +struct xfs_trans *tp, +struct list_head *items, +unsigned int count, +bool sort) +{ +return NULL ; +} + +/* Abort all pending ATTRs. */ +STATIC void +xfs_attr_abort_intent ( +struct xfs_log_item *intent) +{ +} + +/* Get an ATTRD so we can process all the attrs. */ +static struct xfs_log_item * +xfs_attr_create_done ( +struct xfs_trans *tp, +struct xfs_log_item *intent, +unsigned int count) +{ +return NULL ; +} + +/* Process an attr. */ +STATIC int +xfs_attr_finish_item ( +struct xfs_trans *tp, +struct xfs_log_item *done, +struct list_head *item, +struct xfs_btree_cur **state) +{ +struct xfs_attr_item *attr; +int error; +struct xfs_delattr_context *dac; + + attr = container_of(item, struct xfs_attr_item, xattri_list); + dac = &attr->xattri_dac; + +/* +* Always reset trans after EAGAIN cycle +* since the transaction is new +*/ + dac->da_args->trans = tp; + + error =xfs_trans_attr (dac,ATTRD_ITEM (done), &dac->leaf_bp, + attr->xattri_op_flags); +if (error != -EAGAIN ) +kmem_free (attr); + +return error; +} + +/* Cancel an attr */ +STATIC void +xfs_attr_cancel_item ( +struct list_head *item) +{ +struct xfs_attr_item *attr; + + attr = container_of(item, struct xfs_attr_item, xattri_list); +kmem_free (attr); +} + +const struct xfs_defer_op_type xfs_attr_defer_type = { + .max_items =1 , + .create_intent = xfs_attr_create_intent, + .abort_intent = xfs_attr_abort_intent, + .create_done = xfs_attr_create_done, + .finish_item = xfs_attr_finish_item, + .cancel_item = xfs_attr_cancel_item, +}; +/* * AGFL blocks are accounted differently in the reserve pools and are not * inserted into the busy extent list.
libxfs/libxfs_priv.h +1 -0
@@ -497,6 +497,7 @@ void __xfs_buf_mark_corrupt(struct xfs_buf *bp, xfs_failaddr_t fa);#define xfs_trans_reserve_quota_nblks (t,i,b,n,f) (0)#define xfs_trans_unreserve_quota_nblks (t,i,b,n,f) ((void) 0)#define xfs_qm_dqattach (i) (0) +#define xfs_qm_dqattach_locked (i,b) (0)#define uuid_copy (s,d) platform_uuid_copy((s),(d))#define uuid_equal (s,d) (platform_uuid_compare((s),(d)) == 0)
libxfs/xfs_attr.c +3 -4
@@ -24,6 +24,7 @@#include "xfs_quota_defs.h" #include "xfs_trans_space.h" #include "xfs_trace.h" +#include "xfs_attr_item.h" /* * xfs_attr.c
@@ -59,8 +60,6 @@ STATIC int xfs_attr_node_hasname(xfs_da_args_t *args, STATIC int xfs_attr_fillstate(xfs_da_state_t *state); STATIC int xfs_attr_refillstate(xfs_da_state_t *state); STATIC int xfs_attr_leaf_try_add(struct xfs_da_args *args, struct xfs_buf *bp); -STATIC int xfs_attr_set_iter(struct xfs_delattr_context *dac, -struct xfs_buf **leaf_bp);int xfs_inode_hasattr(
@@ -142,7 +141,7 @@ xfs_attr_get(/* * Calculate how many blocks we need for the new attribute, */ -STATIC int +int xfs_attr_calc_size (struct xfs_da_args *args,int *local)
@@ -328,7 +327,7 @@ xfs_attr_set_args(* to handle this, and recall the function until a successful error code is * returned. */ -STATIC int +int xfs_attr_set_iter (struct xfs_delattr_context *dac,struct xfs_buf **leaf_bp)
libxfs/xfs_attr.h +31 -0
@@ -28,6 +28,11 @@ struct xfs_attr_list_context;*/ #define ATTR_MAX_VALUELEN (64*1024)/* max length of a value */ +static inline bool xfs_hasdelattr (struct xfs_mount *mp) +{ +return false; +} +/* * Kernel-internal version of the attrlist cursor. */
@@ -384,6 +389,7 @@ enum xfs_delattr_state {*/ #define XFS_DAC_DEFER_FINISH 0x01/* finish the transaction */ #define XFS_DAC_LEAF_ADDNAME_INIT 0x02/* xfs_attr_leaf_addname init*/ +#define XFS_DAC_DELAYED_OP_INIT 0x04/* delayed operations init*/ /* * Context used for keeping track of delayed attribute operations
@@ -391,6 +397,11 @@ enum xfs_delattr_state {struct xfs_delattr_context {struct xfs_da_args *da_args; +/* +* Used by xfs_attr_set to hold a leaf buffer across a transaction roll +*/ +struct xfs_buf *leaf_bp; +/* Used in xfs_attr_rmtval_set_blk to roll through allocating blocks */ struct xfs_bmbt_irec map;xfs_dablk_t lblkno;
@@ -404,6 +415,23 @@ struct xfs_delattr_context {enum xfs_delattr_state dela_state; }; +/* +* List of attrs to commit later. +*/ +struct xfs_attr_item { +struct xfs_delattr_context xattri_dac; + +/* +* Indicates if the attr operation is a set or a remove +* XFS_ATTR_OP_FLAGS_{SET,REMOVE} +*/ +uint32_t xattri_op_flags; + +/* used to log this item to an intent */ +struct list_head xattri_list; +}; + +/*======================================================================== * Function prototypes for the kernel. *========================================================================*/
@@ -419,11 +447,14 @@ int xfs_attr_get_ilocked(struct xfs_da_args *args);int xfs_attr_get (struct xfs_da_args *args);int xfs_attr_set (struct xfs_da_args *args);int xfs_attr_set_args (struct xfs_da_args *args); +int xfs_attr_set_iter (struct xfs_delattr_context *dac, +struct xfs_buf **leaf_bp);int xfs_has_attr (struct xfs_da_args *args);int xfs_attr_remove_args (struct xfs_da_args *args);int xfs_attr_remove_iter (struct xfs_delattr_context *dac);bool xfs_attr_namecheck (const void *name,size_t length);void xfs_delattr_context_init (struct xfs_delattr_context *dac,struct xfs_da_args *args); +int xfs_attr_calc_size (struct xfs_da_args *args,int *local);#endif /* __XFS_ATTR_H__ */
libxfs/xfs_defer.c +1 -0
@@ -174,6 +174,7 @@ static const struct xfs_defer_op_type *defer_op_types[] = { [XFS_DEFER_OPS_TYPE_RMAP] = &xfs_rmap_update_defer_type, [XFS_DEFER_OPS_TYPE_FREE] = &xfs_extent_free_defer_type, [XFS_DEFER_OPS_TYPE_AGFL_FREE] = &xfs_agfl_free_defer_type, + [XFS_DEFER_OPS_TYPE_ATTR] = &xfs_attr_defer_type, }; static void
libxfs/xfs_defer.h +2 -0
@@ -19,6 +19,7 @@ enum xfs_defer_ops_type {XFS_DEFER_OPS_TYPE_RMAP ,XFS_DEFER_OPS_TYPE_FREE ,XFS_DEFER_OPS_TYPE_AGFL_FREE , +XFS_DEFER_OPS_TYPE_ATTR , XFS_DEFER_OPS_TYPE_MAX, };
@@ -63,6 +64,7 @@ extern const struct xfs_defer_op_type xfs_refcount_update_defer_type;extern const struct xfs_defer_op_type xfs_rmap_update_defer_type;extern const struct xfs_defer_op_type xfs_extent_free_defer_type;extern const struct xfs_defer_op_type xfs_agfl_free_defer_type; +extern const struct xfs_defer_op_type xfs_attr_defer_type;/* * This structure enables a dfops user to detach the chain of deferred
libxfs/xfs_log_format.h +41 -2
65 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v14 9/14 xfsprogs: Skip flip flags for delayed attrs
In reply to Allison HendersonSource kernel commit: 2b1c81a8c3f453ba16b6db8dae256723bf53c051
This is a clean up patch that skips the flip flag logic for delayed attr renames. Since the log replay keeps the inode locked, we do not need to worry about race windows with attr lookups. So we can skip over flipping the flag and the extra transaction roll for it
--- libxfs/xfs_attr.c | 43 ++++++++++++++++++++++++------------------- libxfs/xfs_attr_leaf.c | 3 ++- 2 files changed, 26 insertions(+), 20 deletions(-)
libxfs/xfs_attr.c +24 -19
@@ -805,6 +805,7 @@ xfs_attr_leaf_addname(struct xfs_buf *bp =NULL ;int error, forkoff;struct xfs_inode *dp = args->dp; +struct xfs_mount *mp = args->dp->i_mount;/* State machine switch */ switch (dac->dela_state) {
@@ -870,15 +871,17 @@ xfs_attr_leaf_addname(* In a separate transaction, set the incomplete flag on the "old" attr * and clear the incomplete flag on the "new" attr. */ - error =xfs_attr3_leaf_flipflags (args); -if (error) -return error; -/* -* Commit the flag value change and start the next trans in series. -*/ - dac->dela_state =XFS_DAS_FLIP_LFLAG ; -trace_xfs_das_state_return (dac->dela_state); -return -EAGAIN ; +if (!xfs_hasdelattr (mp)) { + error =xfs_attr3_leaf_flipflags (args); +if (error) +return error; +/* +* Commit the flag value change and start the next trans in series. +*/ + dac->dela_state =XFS_DAS_FLIP_LFLAG ; +trace_xfs_das_state_return (dac->dela_state); +return -EAGAIN ; + } das_flip_flag:/* * Dismantle the "old" attribute/value pair by removing a "remote" value
@@ -1077,6 +1080,7 @@ xfs_attr_node_addname(struct xfs_da_state_blk *blk;int retval =0 ;int error =0 ; +struct xfs_mount *mp = args->dp->i_mount;trace_xfs_attr_node_addname (args);
@@ -1238,15 +1242,17 @@ das_alloc_node:* In a separate transaction, set the incomplete flag on the "old" attr * and clear the incomplete flag on the "new" attr. */ - error =xfs_attr3_leaf_flipflags (args); -if (error) - goto out; -/* -* Commit the flag value change and start the next trans in series -*/ - dac->dela_state =XFS_DAS_FLIP_NFLAG ; -trace_xfs_das_state_return (dac->dela_state); -return -EAGAIN ; +if (!xfs_hasdelattr (mp)) { + error =xfs_attr3_leaf_flipflags (args); +if (error) + goto out; +/* +* Commit the flag value change and start the next trans in series +*/ + dac->dela_state =XFS_DAS_FLIP_NFLAG ; +trace_xfs_das_state_return (dac->dela_state); +return -EAGAIN ; + } das_flip_flag:/* * Dismantle the "old" attribute/value pair by removing a "remote" value
@@ -1275,7 +1281,6 @@ das_rm_nblk:* Re-find the "old" attribute entry after any split ops. The INCOMPLETE * flag means that we will find the "old" attr, not the "new" one. */ - args->attr_filter |=XFS_ATTR_INCOMPLETE ; state =xfs_da_state_alloc (args); state->inleaf =0 ; error =xfs_da3_node_lookup_int (state, &retval);
libxfs/xfs_attr_leaf.c +2 -1
@@ -1483,7 +1483,8 @@ xfs_attr3_leaf_add_work(if (tmp) entry->flags |=XFS_ATTR_LOCAL ;if (args->op_flags &XFS_DA_OP_RENAME ) { - entry->flags |=XFS_ATTR_INCOMPLETE ; +if (!xfs_hasdelattr (mp)) + entry->flags |=XFS_ATTR_INCOMPLETE ;if ((args->blkno2 == args->blkno) && (args->index2 <= args->index)) { args->index2++;
Signature · 1 line
2.7.4
PATCH v14 10/14 xfsprogs: Add xfs_attr_set_deferred and xfs_attr_remove_deferred
In reply to Allison HendersonFrom: Allison Collins <[email protected]>
These routines to set up and start a new deferred attribute operations. These functions are meant to be called by any routine needing to initiate a deferred attribute operation as opposed to the existing inline operations. New helper function xfs_attr_item_init also added.
Finally enable delayed attributes in xfs_attr_set and xfs_attr_remove.
--- libxfs/xfs_attr.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- libxfs/xfs_attr.h | 2 ++ 2 files changed, 57 insertions(+), 2 deletions(-)
libxfs/xfs_attr.c +55 -2
@@ -604,9 +604,10 @@ xfs_attr_set(if (error != -ENOATTR && error != -EEXIST ) goto out_trans_cancel; - error =xfs_attr_set_args (args); + error =xfs_attr_set_deferred (args);if (error) goto out_trans_cancel; +/* shortform attribute has already been committed */ if (!args->trans) goto out_unlock;
@@ -615,7 +616,7 @@ xfs_attr_set(if (error != -EEXIST ) goto out_trans_cancel; - error =xfs_attr_remove_args (args); + error =xfs_attr_remove_deferred (args);if (error) goto out_trans_cancel; }
@@ -645,6 +646,58 @@ out_trans_cancel: goto out_unlock; } +STATIC int +xfs_attr_item_init ( +struct xfs_da_args *args, +unsigned int op_flags,/* op flag (set or remove) */ +struct xfs_attr_item **attr)/* new xfs_attr_item */ +{ + +struct xfs_attr_item *new; + + new =kmem_zalloc (sizeof (struct xfs_attr_item ),KM_NOFS ); + new->xattri_op_flags = op_flags; + new->xattri_dac.da_args = args; + + *attr = new; +return 0 ; +} + +/* Sets an attribute for an inode as a deferred operation */ +int +xfs_attr_set_deferred ( +struct xfs_da_args *args) +{ +struct xfs_attr_item *new; +int error =0 ; + + error =xfs_attr_item_init (args,XFS_ATTR_OP_FLAGS_SET , &new); +if (error) +return error; + +xfs_defer_add (args->trans,XFS_DEFER_OPS_TYPE_ATTR , &new->xattri_list); + +return 0 ; +} + +/* Removes an attribute for an inode as a deferred operation */ +int +xfs_attr_remove_deferred ( +struct xfs_da_args *args) +{ + +struct xfs_attr_item *new; +int error; + + error =xfs_attr_item_init (args,XFS_ATTR_OP_FLAGS_REMOVE , &new); +if (error) +return error; + +xfs_defer_add (args->trans,XFS_DEFER_OPS_TYPE_ATTR , &new->xattri_list); + +return 0 ; +} +/*======================================================================== * External routines when attribute list is inside the inode *========================================================================*/
libxfs/xfs_attr.h +2 -0
@@ -456,5 +456,7 @@ bool xfs_attr_namecheck(const void *name, size_t length);void xfs_delattr_context_init (struct xfs_delattr_context *dac,struct xfs_da_args *args);int xfs_attr_calc_size (struct xfs_da_args *args,int *local); +int xfs_attr_set_deferred (struct xfs_da_args *args); +int xfs_attr_remove_deferred (struct xfs_da_args *args);#endif /* __XFS_ATTR_H__ */
Signature · 1 line
2.7.4
PATCH v14 11/14 xfsprogs: Remove unused xfs_attr_*_args
In reply to Allison HendersonRemove xfs_attr_set_args, xfs_attr_remove_args, and xfs_attr_trans_roll. These high level loops are now driven by the delayed operations code, and can be removed.
Additionally collapse in the leaf_bp parameter of xfs_attr_set_iter since we only have one caller that passes dac->leaf_bp
--- libxfs/defer_item.c | 6 +-- libxfs/xfs_attr.c | 96 ++---------------------------------------------- libxfs/xfs_attr.h | 10 ++--- libxfs/xfs_attr_remote.c | 1 - 4 files changed, 8 insertions(+), 105 deletions(-)
libxfs/defer_item.c +2 -4
@@ -131,7 +131,6 @@ intxfs_trans_attr ( struct xfs_delattr_context *dac, struct xfs_attrd_log_item *attrdp, - struct xfs_buf **leaf_bp, uint32_t op_flags) { struct xfs_da_args *args = dac->da_args;
@@ -144,7 +143,7 @@ xfs_trans_attr(switch (op_flags) {case XFS_ATTR_OP_FLAGS_SET : args->op_flags |=XFS_DA_OP_ADDNAME ; - error =xfs_attr_set_iter (dac, leaf_bp); + error =xfs_attr_set_iter (dac);break ;case XFS_ATTR_OP_FLAGS_REMOVE :ASSERT (XFS_IFORK_Q ((args->dp)));
@@ -216,8 +215,7 @@ xfs_attr_finish_item(*/ dac->da_args->trans = tp; - error =xfs_trans_attr (dac,ATTRD_ITEM (done), &dac->leaf_bp, - attr->xattri_op_flags); + error =xfs_trans_attr (dac,ATTRD_ITEM (done), attr->xattri_op_flags);if (error != -EAGAIN )kmem_free (attr);
libxfs/xfs_attr.c +3 -93
159 lines not on this page · raw message
libxfs/xfs_attr.h +3 -7
@@ -387,9 +387,8 @@ enum xfs_delattr_state {/* * Defines for xfs_delattr_context.flags */ -#define XFS_DAC_DEFER_FINISH 0x01/* finish the transaction */ -#define XFS_DAC_LEAF_ADDNAME_INIT 0x02/* xfs_attr_leaf_addname init*/ -#define XFS_DAC_DELAYED_OP_INIT 0x04/* delayed operations init*/ +#define XFS_DAC_LEAF_ADDNAME_INIT 0x01/* xfs_attr_leaf_addname init*/ +#define XFS_DAC_DELAYED_OP_INIT 0x02/* delayed operations init*/ /* * Context used for keeping track of delayed attribute operations
@@ -446,11 +445,8 @@ int xfs_inode_hasattr(struct xfs_inode *ip);int xfs_attr_get_ilocked (struct xfs_da_args *args);int xfs_attr_get (struct xfs_da_args *args);int xfs_attr_set (struct xfs_da_args *args); -int xfs_attr_set_args (struct xfs_da_args *args); -int xfs_attr_set_iter (struct xfs_delattr_context *dac, -struct xfs_buf **leaf_bp); +int xfs_attr_set_iter (struct xfs_delattr_context *dac);int xfs_has_attr (struct xfs_da_args *args); -int xfs_attr_remove_args (struct xfs_da_args *args);int xfs_attr_remove_iter (struct xfs_delattr_context *dac);bool xfs_attr_namecheck (const void *name,size_t length); void xfs_delattr_context_init(struct xfs_delattr_context *dac,
libxfs/xfs_attr_remote.c +0 -1
@@ -761,7 +761,6 @@ xfs_attr_rmtval_remove(* by the parent */ if (!done) { - dac->flags |=XFS_DAC_DEFER_FINISH ;trace_xfs_das_state_return (dac->dela_state);return -EAGAIN ; }
Signature · 1 line
2.7.4
PATCH v14 12/14 xfsprogs: Add delayed attributes error tag
In reply to Allison HendersonFrom: Allison Collins <[email protected]>
This patch adds an error tag that we can use to test delayed attribute recovery and replay
--- io/inject.c | 1 + libxfs/xfs_errortag.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)
io/inject.c +1 -0
@@ -55,6 +55,7 @@ error_tag(char *name) { XFS_ERRTAG_FORCE_SUMMARY_RECALC, "bad_summary" }, { XFS_ERRTAG_IUNLINK_FALLBACK, "iunlink_fallback" }, { XFS_ERRTAG_BUF_IOERROR, "buf_ioerror" }, + { XFS_ERRTAG_DELAYED_ATTR, "delayed_attr" }, { XFS_ERRTAG_MAX, NULL } };int count;
libxfs/xfs_errortag.h +3 -1
@@ -56,7 +56,8 @@#define XFS_ERRTAG_FORCE_SUMMARY_RECALC 33#define XFS_ERRTAG_IUNLINK_FALLBACK 34#define XFS_ERRTAG_BUF_IOERROR 35 -#define XFS_ERRTAG_MAX 36 +#define XFS_ERRTAG_DELAYED_ATTR 36 +#define XFS_ERRTAG_MAX 37/* * Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
@@ -97,5 +98,6 @@#define XFS_RANDOM_FORCE_SUMMARY_RECALC 1#define XFS_RANDOM_IUNLINK_FALLBACK (XFS_RANDOM_DEFAULT/10)#define XFS_RANDOM_BUF_IOERROR XFS_RANDOM_DEFAULT +#define XFS_RANDOM_DELAYED_ATTR 1#endif /* __XFS_ERRORTAG_H_ */
Signature · 1 line
2.7.4
PATCH v14 13/14 xfsprogs: Merge xfs_delattr_context into xfs_attr_item
In reply to Allison HendersonThis is a clean up patch that merges xfs_delattr_context into xfs_attr_item. Now that the refactoring is complete and the delayed operation infastructure is in place, we can combine these to eliminate the extra struct
--- libxfs/defer_item.c | 14 +++-- libxfs/xfs_attr.c | 138 +++++++++++++++++++++++------------------------ libxfs/xfs_attr.h | 40 ++++++-------- libxfs/xfs_attr_remote.c | 34 ++++++------ libxfs/xfs_attr_remote.h | 6 +-- 5 files changed, 112 insertions(+), 120 deletions(-)
libxfs/defer_item.c +6 -8
@@ -129,11 +129,11 @@ static inline struct xfs_attrd_log_item *ATTRD_ITEM(struct xfs_log_item *lip)*/ int xfs_trans_attr ( -struct xfs_delattr_context *dac, +struct xfs_attr_item *attr,struct xfs_attrd_log_item *attrdp,uint32_t op_flags) { -struct xfs_da_args *args = dac->da_args; +struct xfs_da_args *args = attr->xattri_da_args;int error; error =xfs_qm_dqattach_locked (args->dp,0 );
@@ -143,11 +143,11 @@ xfs_trans_attr(switch (op_flags) {case XFS_ATTR_OP_FLAGS_SET : args->op_flags |=XFS_DA_OP_ADDNAME ; - error =xfs_attr_set_iter (dac); + error =xfs_attr_set_iter (attr);break ;case XFS_ATTR_OP_FLAGS_REMOVE :ASSERT (XFS_IFORK_Q ((args->dp))); - error =xfs_attr_remove_iter (dac); + error =xfs_attr_remove_iter (attr);break ;default : error = -EFSCORRUPTED ;
@@ -204,18 +204,16 @@ xfs_attr_finish_item( {struct xfs_attr_item *attr;int error; -struct xfs_delattr_context *dac; attr = container_of(item, struct xfs_attr_item, xattri_list); - dac = &attr->xattri_dac;/* * Always reset trans after EAGAIN cycle * since the transaction is new */ - dac->da_args->trans = tp; + attr->xattri_da_args->trans = tp; - error =xfs_trans_attr (dac,ATTRD_ITEM (done), attr->xattri_op_flags); + error =xfs_trans_attr (attr,ATTRD_ITEM (done), attr->xattri_op_flags);if (error != -EAGAIN )kmem_free (attr);
libxfs/xfs_attr.c +69 -69
374 lines not on this page · raw message
libxfs/xfs_attr.h +17 -23
@@ -364,7 +364,7 @@ struct xfs_attr_list_context {*/ /* -* Enum values for xfs_delattr_context.da_state +* Enum values for xfs_attr_item.xattri_da_state * * These values are used by delayed attribute operations to keep track of where * they were before they returned -EAGAIN. A return code of -EAGAIN signals the
@@ -385,7 +385,7 @@ enum xfs_delattr_state { };/* -* Defines for xfs_delattr_context.flags +* Defines for xfs_attr_item.xattri_flags */ #define XFS_DAC_LEAF_ADDNAME_INIT 0x01/* xfs_attr_leaf_addname init*/ #define XFS_DAC_DELAYED_OP_INIT 0x02/* delayed operations init*/
@@ -393,32 +393,25 @@ enum xfs_delattr_state {/* * Context used for keeping track of delayed attribute operations */ -struct xfs_delattr_context { -struct xfs_da_args *da_args; +struct xfs_attr_item { +struct xfs_da_args *xattri_da_args;/* * Used by xfs_attr_set to hold a leaf buffer across a transaction roll */ -struct xfs_buf *leaf_bp; +struct xfs_buf *xattri_leaf_bp;/* Used in xfs_attr_rmtval_set_blk to roll through allocating blocks */ -struct xfs_bmbt_irec map; -xfs_dablk_t lblkno; -int blkcnt; +struct xfs_bmbt_irec xattri_map; +xfs_dablk_t xattri_lblkno; +int xattri_blkcnt;/* Used in xfs_attr_node_removename to roll through removing blocks */ -struct xfs_da_state *da_state; +struct xfs_da_state *xattri_da_state;/* Used to keep track of current state of delayed operation */ -unsigned int flags; -enum xfs_delattr_state dela_state; -}; - -/* -* List of attrs to commit later. -*/ -struct xfs_attr_item { -struct xfs_delattr_context xattri_dac; +unsigned int xattri_flags; +enum xfs_delattr_state xattri_dela_state;/* * Indicates if the attr operation is a set or a remove
@@ -426,7 +419,10 @@ struct xfs_attr_item {*/ uint32_t xattri_op_flags; -/* used to log this item to an intent */ +/* +* used to log this item to an intent containing a list of attrs to +* commit later +*/ struct list_head xattri_list; };
@@ -445,12 +441,10 @@ int xfs_inode_hasattr(struct xfs_inode *ip);int xfs_attr_get_ilocked (struct xfs_da_args *args);int xfs_attr_get (struct xfs_da_args *args);int xfs_attr_set (struct xfs_da_args *args); -int xfs_attr_set_iter (struct xfs_delattr_context *dac); +int xfs_attr_set_iter (struct xfs_attr_item *attr);int xfs_has_attr (struct xfs_da_args *args); -int xfs_attr_remove_iter (struct xfs_delattr_context *dac); +int xfs_attr_remove_iter (struct xfs_attr_item *attr);bool xfs_attr_namecheck (const void *name,size_t length); -void xfs_delattr_context_init (struct xfs_delattr_context *dac, -struct xfs_da_args *args);int xfs_attr_calc_size (struct xfs_da_args *args,int *local);int xfs_attr_set_deferred (struct xfs_da_args *args);int xfs_attr_remove_deferred (struct xfs_da_args *args);
libxfs/xfs_attr_remote.c +17 -17
@@ -633,14 +633,14 @@ xfs_attr_rmtval_set(*/ int xfs_attr_rmtval_find_space ( -struct xfs_delattr_context *dac) +struct xfs_attr_item *attr) { -struct xfs_da_args *args = dac->da_args; -struct xfs_bmbt_irec *map = &dac->map; +struct xfs_da_args *args = attr->xattri_da_args; +struct xfs_bmbt_irec *map = &attr->xattri_map;int error; - dac->lblkno =0 ; - dac->blkcnt =0 ; + attr->xattri_lblkno =0 ; + attr->xattri_blkcnt =0 ; args->rmtblkcnt =0 ; args->rmtblkno =0 ;memset (map,0 ,sizeof (struct xfs_bmbt_irec ));
@@ -649,8 +649,8 @@ xfs_attr_rmtval_find_space(if (error)return error; - dac->blkcnt = args->rmtblkcnt; - dac->lblkno = args->rmtblkno; + attr->xattri_blkcnt = args->rmtblkcnt; + attr->xattri_lblkno = args->rmtblkno;return 0 ; }
@@ -663,17 +663,17 @@ xfs_attr_rmtval_find_space(*/ int xfs_attr_rmtval_set_blk ( -struct xfs_delattr_context *dac) +struct xfs_attr_item *attr) { -struct xfs_da_args *args = dac->da_args; +struct xfs_da_args *args = attr->xattri_da_args;struct xfs_inode *dp = args->dp; -struct xfs_bmbt_irec *map = &dac->map; +struct xfs_bmbt_irec *map = &attr->xattri_map;int nmap;int error; nmap =1 ; - error =xfs_bmapi_write (args->trans, dp, (xfs_fileoff_t )dac->lblkno, - dac->blkcnt,XFS_BMAPI_ATTRFORK , args->total, + error =xfs_bmapi_write (args->trans, dp, (xfs_fileoff_t )attr->xattri_lblkno, + attr->xattri_blkcnt,XFS_BMAPI_ATTRFORK , args->total, map, &nmap);if (error)return error;
@@ -683,8 +683,8 @@ xfs_attr_rmtval_set_blk( (map->br_startblock != HOLESTARTBLOCK));/* roll attribute extent map forwards */ - dac->lblkno += map->br_blockcount; - dac->blkcnt -= map->br_blockcount; + attr->xattri_lblkno += map->br_blockcount; + attr->xattri_blkcnt -= map->br_blockcount;return 0 ; }
@@ -737,9 +737,9 @@ xfs_attr_rmtval_invalidate(*/ int xfs_attr_rmtval_remove ( -struct xfs_delattr_context *dac) +struct xfs_attr_item *attr) { -struct xfs_da_args *args = dac->da_args; +struct xfs_da_args *args = attr->xattri_da_args;int error, done;/*
@@ -761,7 +761,7 @@ xfs_attr_rmtval_remove(* by the parent */ if (!done) { -trace_xfs_das_state_return (dac->dela_state); +trace_xfs_das_state_return (attr->xattri_dela_state);return -EAGAIN ; }
libxfs/xfs_attr_remote.h +3 -3
@@ -13,9 +13,9 @@ int xfs_attr_rmtval_set(struct xfs_da_args *args);int xfs_attr_rmtval_stale (struct xfs_inode *ip,struct xfs_bmbt_irec *map,xfs_buf_flags_t incore_flags);int xfs_attr_rmtval_invalidate (struct xfs_da_args *args); -int xfs_attr_rmtval_remove (struct xfs_delattr_context *dac); +int xfs_attr_rmtval_remove (struct xfs_attr_item *attr);int xfs_attr_rmt_find_hole (struct xfs_da_args *args);int xfs_attr_rmtval_set_value (struct xfs_da_args *args); -int xfs_attr_rmtval_set_blk (struct xfs_delattr_context *dac); -int xfs_attr_rmtval_find_space (struct xfs_delattr_context *dac); +int xfs_attr_rmtval_set_blk (struct xfs_attr_item *attr); +int xfs_attr_rmtval_find_space (struct xfs_attr_item *attr);#endif /* __XFS_ATTR_REMOTE_H__ */
Signature · 1 line
2.7.4
PATCH v14 14/14 xfsprogs: Add log item printing for ATTRI and ATTRD
In reply to Allison HendersonThis patch implements a new set of log printing functions to print the ATTRI and ATTRD items and vectors in the log. These will be used during log dump and log recover operations.
RFC: Though most attributes are strings, the attribute operations accept any binary payload, so we cannot assume them printable. This was done intentionally in preparation for parent pointers. And until parent pointers get here, attributes have no discernible format. So the print routines are just a simple hex dump for now. It's not pretty, but works for now.
--- logprint/log_misc.c | 48 +++++++++++- logprint/log_print_all.c | 12 +++ logprint/log_redo.c | 198 +++++++++++++++++++++++++++++++++++++++++++++++ logprint/logprint.h | 12 +++ 4 files changed, 269 insertions(+), 1 deletion(-)
logprint/log_misc.c +47 -1
@@ -54,11 +54,46 @@ print_stars(void) "***********************************\n"); }/* print_stars */ +void +print_hex_dump (char *ptr,int len) { +int i =0 ; + +for (i =0 ; i < len; i++) { +if (i %16 ==0 ) +printf ("%08x " , i); + +printf ("%02x" , ptr[i]); + +if ((i+1 )%16 ==0 ) +printf ("\n" ); +else if ((i+1 )%2 ==0 ) +printf (" " ); + } +printf ("\n" ); +} + +bool +is_printable (char *ptr,int len) { +int i =0 ; + +for (i =0 ; i < len; i++) +if (!isprint (ptr[i]) ) +return false; +return true; +} + +void print_or_dump (char *ptr,int len) { +if (is_printable (ptr, len)) +printf ("%.*s\n" , len, ptr); +else +print_hex_dump (ptr, len); +} +/* * Given a pointer to a data segment, print out the data as if it were * a log operation header. */ -static void +void xlog_print_op_header (xlog_op_header_t *op_head,int i,char **ptr)
@@ -961,6 +996,17 @@ xlog_print_record( be32_to_cpu(op_head->oh_len));break ; } +case XFS_LI_ATTRI : { + skip =xlog_print_trans_attri (&ptr, +be32_to_cpu (op_head->oh_len), + &i); +break ; + } +case XFS_LI_ATTRD : { + skip =xlog_print_trans_attrd (&ptr, +be32_to_cpu (op_head->oh_len)); +break ; + }case XFS_LI_RUI : { skip = xlog_print_trans_rui(&ptr, be32_to_cpu(op_head->oh_len),
logprint/log_print_all.c +12 -0
@@ -404,6 +404,12 @@ xlog_recover_print_logitem(case XFS_LI_EFI :xlog_recover_print_efi (item);break ; +case XFS_LI_ATTRD : +xlog_recover_print_attrd (item); +break ; +case XFS_LI_ATTRI : +xlog_recover_print_attri (item); +break ;case XFS_LI_RUD :xlog_recover_print_rud (item);break ;
@@ -456,6 +462,12 @@ xlog_recover_print_item(case XFS_LI_EFI :printf ("EFI" );break ; +case XFS_LI_ATTRD : +printf ("ATTRD" ); +break ; +case XFS_LI_ATTRI : +printf ("ATTRI" ); +break ;case XFS_LI_RUD :printf ("RUD" );break ;
logprint/log_redo.c +198 -0
207 lines not on this page · raw message
logprint/logprint.h +12 -0
@@ -29,6 +29,9 @@ extern void xfs_log_print_trans(struct xlog *, int);extern void print_xlog_record_line (void );extern void print_xlog_op_line (void );extern void print_stars (void ); +extern void print_hex_dump (char * ptr,int len); +extern bool is_printable (char * ptr,int len); +extern void print_or_dump (char * ptr,int len);extern struct xfs_inode_log_format *xfs_inode_item_format_convert (char *,uint ,struct xfs_inode_log_format *);
@@ -53,4 +56,13 @@ extern void xlog_recover_print_bui(struct xlog_recover_item *item);extern int xlog_print_trans_bud (char **ptr,uint len);extern void xlog_recover_print_bud (struct xlog_recover_item *item); +#define MAX_ATTR_VAL_PRINT 128 + +extern int xlog_print_trans_attri (char **ptr,uint src_len,int *i); +extern int xlog_print_trans_attri_name (char **ptr,uint src_len); +extern int xlog_print_trans_attri_value (char **ptr,uint src_len,int value_len); +extern void xlog_recover_print_attri (struct xlog_recover_item *item); +extern int xlog_print_trans_attrd (char **ptr,uint len); +extern void xlog_recover_print_attrd (struct xlog_recover_item *item); +extern void xlog_print_op_header (xlog_op_header_t *op_head,int i,char **ptr);#endif /* LOGPRINT_H */
Signature · 1 line
2.7.4