Log Attribute Replay
v25 cover Log Attribute Replay
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.
The last patch in this series is unique to the userspace code, and handles printing the new log items. This will be needed when the kernel side code goes upstream since older versions will not recognise the new items.
This series can also be viewed on github here:
https://github.com/allisonhenderson/xfs_work/tree/delay_ready_attrs_xfsprogs_v25
And also the extended delayed attribute and parent pointer series:
https://github.com/allisonhenderson/xfs_work/tree/delay_ready_attrs_xfsprogs_v25_extended
Allison Collins (1):
xfsprogs: Add xfs_attr_set_deferred and xfs_attr_remove_deferred
Allison Henderson (12):
xfs: add attr state machine tracepoints
xfsprogs: Rename __xfs_attr_rmtval_remove
xfs: don't commit the first deferred transaction without intents
xfsprogs: Return from xfs_attr_set_iter if there are no more rmtblks
to process
xfsprogs: Set up infrastructure for log attribute replay
xfsprogs: Implement attr logging and replay
xfsprogs: Skip flip flags for delayed attrs
xfsprogs: Remove unused xfs_attr_*_args
xfsprogs: Add log attribute error tag
xfsprogs: Merge xfs_delattr_context into xfs_attr_item
xfsprogs: Add helper function xfs_attr_leaf_addname
xfsprogs: Add log item printing for ATTRI and ATTRD
Darrick J. Wong (1):
xfs: allow setting and clearing of log incompat feature flags
include/xfs_trace.h | 7 + io/inject.c | 1 + libxfs/defer_item.c | 124 +++++++++++ libxfs/libxfs_priv.h | 4 + libxfs/xfs_attr.c | 451 +++++++++++++++++++++------------------ libxfs/xfs_attr.h | 56 +++-- libxfs/xfs_attr_leaf.c | 3 +- libxfs/xfs_attr_remote.c | 38 ++-- libxfs/xfs_attr_remote.h | 6 +- libxfs/xfs_defer.c | 30 +-- libxfs/xfs_defer.h | 2 + libxfs/xfs_errortag.h | 4 +- libxfs/xfs_format.h | 26 ++- libxfs/xfs_log_format.h | 43 +++- logprint/log_misc.c | 48 ++++- logprint/log_print_all.c | 12 ++ logprint/log_redo.c | 197 +++++++++++++++++ logprint/logprint.h | 12 ++ 18 files changed, 800 insertions(+), 264 deletions(-)
Signature · 1 line
2.25.1
PATCH v25 1/14 xfs: allow setting and clearing of log incompat feature flags
From: "Darrick J. Wong" <[email protected]>
Source kernel commit: a9642049d91105c676526817b527a1a62940888f
Log incompat feature flags in the superblock exist for one purpose: to protect the contents of a dirty log from replay on a kernel that isn't prepared to handle those dirty contents. This means that they can be cleared if (a) we know the log is clean and (b) we know that there aren't any other threads in the system that might be setting or relying upon a log incompat flag.
Therefore, clear the log incompat flags when we've finished recovering the log, when we're unmounting cleanly, remounting read-only, or freezing; and provide a function so that subsequent patches can start using this.
--- libxfs/xfs_format.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
libxfs/xfs_format.h +15 -0
@@ -495,6 +495,21 @@ xfs_sb_has_incompat_log_feature(return (sbp->sb_features_log_incompat & feature) !=0 ; } +static inline void +xfs_sb_remove_incompat_log_features ( +struct xfs_sb *sbp) +{ + sbp->sb_features_log_incompat &= ~XFS_SB_FEAT_INCOMPAT_LOG_ALL ; +} + +static inline void +xfs_sb_add_incompat_log_features ( +struct xfs_sb *sbp, +unsigned int features) +{ + sbp->sb_features_log_incompat |= features; +} +/* * V5 superblock specific feature checks */
Signature · 1 line
2.25.1
PATCH v25 2/14 xfs: add attr state machine tracepoints
In reply to Allison HendersonSource kernel commit: df0826312a23e495faa91eee0d6ac31bca35dc09
This is a quick patch to add a new xfs_attr_*_return tracepoints. We use these to track when ever a new state is set or -EAGAIN is returned
--- include/xfs_trace.h | 6 ++++++ libxfs/xfs_attr.c | 31 +++++++++++++++++++++++++++++-- libxfs/xfs_attr_remote.c | 1 + 3 files changed, 36 insertions(+), 2 deletions(-)
include/xfs_trace.h +6 -0
@@ -314,4 +314,10 @@#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_attr_sf_addname_return (a,b) ((void) 0) +#define trace_xfs_attr_set_iter_return (a,b) ((void) 0) +#define trace_xfs_attr_node_addname_return (a,b) ((void) 0) +#define trace_xfs_attr_remove_iter_return (a,b) ((void) 0) +#define trace_xfs_attr_rmtval_remove_return (a,b) ((void) 0) +#endif /* __TRACE_H__ */
libxfs/xfs_attr.c +29 -2
@@ -335,6 +335,7 @@ xfs_attr_sf_addname(* the attr fork to leaf format and will restart with the leaf * add. */ +trace_xfs_attr_sf_addname_return (XFS_DAS_UNINIT , args->dp); dac->flags |=XFS_DAC_DEFER_FINISH ;return -EAGAIN ; }
@@ -394,6 +395,8 @@ xfs_attr_set_iter(* handling code below */ dac->flags |=XFS_DAC_DEFER_FINISH ; +trace_xfs_attr_set_iter_return ( + dac->dela_state, args->dp);return -EAGAIN ; }else if (error) {return error;
@@ -411,6 +414,7 @@ xfs_attr_set_iter( dac->dela_state =XFS_DAS_FOUND_NBLK ; } +trace_xfs_attr_set_iter_return (dac->dela_state, args->dp);return -EAGAIN ;case XFS_DAS_FOUND_LBLK :/*
@@ -438,6 +442,8 @@ xfs_attr_set_iter( error =xfs_attr_rmtval_set_blk (dac);if (error)return error; +trace_xfs_attr_set_iter_return (dac->dela_state, + args->dp);return -EAGAIN ; }
@@ -472,6 +478,7 @@ xfs_attr_set_iter(* series. */ dac->dela_state =XFS_DAS_FLIP_LFLAG ; +trace_xfs_attr_set_iter_return (dac->dela_state, args->dp);return -EAGAIN ;case XFS_DAS_FLIP_LFLAG :/*
@@ -489,10 +496,14 @@ xfs_attr_set_iter( dac->dela_state =XFS_DAS_RM_LBLK ;if (args->rmtblkno) { error =__xfs_attr_rmtval_remove (dac); +if (error == -EAGAIN ) +trace_xfs_attr_set_iter_return ( + dac->dela_state, args->dp);if (error)return error; dac->dela_state =XFS_DAS_RD_LEAF ; +trace_xfs_attr_set_iter_return (dac->dela_state, args->dp);return -EAGAIN ; }
@@ -542,6 +553,8 @@ xfs_attr_set_iter( error =xfs_attr_rmtval_set_blk (dac);if (error)return error; +trace_xfs_attr_set_iter_return ( + dac->dela_state, args->dp);return -EAGAIN ; }
@@ -577,6 +590,7 @@ xfs_attr_set_iter(* series */ dac->dela_state =XFS_DAS_FLIP_NFLAG ; +trace_xfs_attr_set_iter_return (dac->dela_state, args->dp);return -EAGAIN ;case XFS_DAS_FLIP_NFLAG :
@@ -596,10 +610,15 @@ xfs_attr_set_iter( dac->dela_state =XFS_DAS_RM_NBLK ;if (args->rmtblkno) { error =__xfs_attr_rmtval_remove (dac); +if (error == -EAGAIN ) +trace_xfs_attr_set_iter_return ( + dac->dela_state, args->dp); +if (error)return error; dac->dela_state =XFS_DAS_CLR_FLAG ; +trace_xfs_attr_set_iter_return (dac->dela_state, args->dp);return -EAGAIN ; }
@@ -1176,6 +1195,8 @@ xfs_attr_node_addname(* this point. */ dac->flags |=XFS_DAC_DEFER_FINISH ; +trace_xfs_attr_node_addname_return ( + dac->dela_state, args->dp);return -EAGAIN ; }
@@ -1422,10 +1443,13 @@ xfs_attr_remove_iter(* blocks are removed. */ error =__xfs_attr_rmtval_remove (dac); -if (error == -EAGAIN ) +if (error == -EAGAIN ) { +trace_xfs_attr_remove_iter_return ( + dac->dela_state, args->dp);return error; -else if (error) + }else if (error) { goto out; + }/* * Refill the state structure with buffers (the prior
@@ -1438,6 +1462,7 @@ xfs_attr_remove_iter( goto out; dac->dela_state =XFS_DAS_RM_NAME ; dac->flags |=XFS_DAC_DEFER_FINISH ; +trace_xfs_attr_remove_iter_return (dac->dela_state, args->dp);return -EAGAIN ; }
@@ -1466,6 +1491,8 @@ xfs_attr_remove_iter( dac->flags |=XFS_DAC_DEFER_FINISH ; dac->dela_state =XFS_DAS_RM_SHRINK ; +trace_xfs_attr_remove_iter_return ( + dac->dela_state, args->dp);return -EAGAIN ; }
libxfs/xfs_attr_remote.c +1 -0
@@ -695,6 +695,7 @@ __xfs_attr_rmtval_remove(*/ if (!done) { dac->flags |=XFS_DAC_DEFER_FINISH ; +trace_xfs_attr_rmtval_remove_return (dac->dela_state, args->dp);return -EAGAIN ; }
Signature · 1 line
2.25.1
PATCH v25 3/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
@@ -495,7 +495,7 @@ xfs_attr_set_iter(/* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ dac->dela_state =XFS_DAS_RM_LBLK ;if (args->rmtblkno) { - error =__xfs_attr_rmtval_remove (dac); + error =xfs_attr_rmtval_remove (dac);if (error == -EAGAIN )trace_xfs_attr_set_iter_return ( dac->dela_state, args->dp);
@@ -609,7 +609,7 @@ xfs_attr_set_iter(/* Set state in case xfs_attr_rmtval_remove returns -EAGAIN */ dac->dela_state =XFS_DAS_RM_NBLK ;if (args->rmtblkno) { - error =__xfs_attr_rmtval_remove (dac); + error =xfs_attr_rmtval_remove (dac);if (error == -EAGAIN )trace_xfs_attr_set_iter_return ( dac->dela_state, args->dp);
@@ -1442,7 +1442,7 @@ xfs_attr_remove_iter(* May return -EAGAIN. Roll and repeat until all remote * blocks are removed. */ - error =__xfs_attr_rmtval_remove (dac); + error =xfs_attr_rmtval_remove (dac);if (error == -EAGAIN ) {trace_xfs_attr_remove_iter_return ( dac->dela_state, args->dp);
libxfs/xfs_attr_remote.c +1 -1
@@ -671,7 +671,7 @@ xfs_attr_rmtval_invalidate(* routine until it returns something other than -EAGAIN. */ 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
@@ -12,7 +12,7 @@ int xfs_attr_rmtval_get(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.25.1
PATCH v25 4/14 xfs: don't commit the first deferred transaction without intents
In reply to Allison HendersonIf the first operation in a string of defer ops has no intents, then there is no reason to commit it before running the first call to xfs_defer_finish_one(). This allows the defer ops to be used effectively for non-intent based operations without requiring an unnecessary extra transaction commit when first called.
This fixes a regression in per-attribute modification transaction count when delayed attributes are not being used.
--- libxfs/xfs_defer.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)
libxfs/xfs_defer.c +17 -12
@@ -176,7 +176,7 @@ static const struct xfs_defer_op_type *defer_op_types[] = { [XFS_DEFER_OPS_TYPE_AGFL_FREE] = &xfs_agfl_free_defer_type, }; -static void +static bool xfs_defer_create_intent( struct xfs_trans *tp, struct xfs_defer_pending *dfp,
@@ -187,6 +187,7 @@ xfs_defer_create_intent(if (!dfp->dfp_intent) dfp->dfp_intent = ops->create_intent (tp, &dfp->dfp_work, dfp->dfp_count, sort); +return dfp->dfp_intent; }/*
@@ -194,16 +195,18 @@ xfs_defer_create_intent(* associated extents, then add the entire intake list to the end of * the pending list. */ -STATIC void +STATIC boolxfs_defer_create_intents (struct xfs_trans *tp) {struct xfs_defer_pending *dfp; +bool ret = false;list_for_each_entry (dfp, &tp->t_dfops, dfp_list) {trace_xfs_defer_create_intent (tp->t_mountp, dfp); -xfs_defer_create_intent (tp, dfp, true); + ret |=xfs_defer_create_intent (tp, dfp, true); } +return ret; }/* Abort all the intents that were committed. */
@@ -454,7 +457,7 @@ intxfs_defer_finish_noroll ( struct xfs_trans **tp) { -struct xfs_defer_pending *dfp; +struct xfs_defer_pending *dfp =NULL ;int error =0 ;LIST_HEAD (dop_pending);
@@ -473,17 +476,19 @@ xfs_defer_finish_noroll(* of time that any one intent item can stick around in memory, * pinning the log tail. */ -xfs_defer_create_intents (*tp); +bool has_intents =xfs_defer_create_intents (*tp);list_splice_init (&(*tp)->t_dfops, &dop_pending); - error =xfs_defer_trans_roll (tp); -if (error) - goto out_shutdown; +if (has_intents || dfp) { + error =xfs_defer_trans_roll (tp); +if (error) + goto out_shutdown; -/* Possibly relog intent items to keep the log moving. */ - error =xfs_defer_relog (tp, &dop_pending); -if (error) - goto out_shutdown; +/* Possibly relog intent items to keep the log moving. */ + error =xfs_defer_relog (tp, &dop_pending); +if (error) + goto out_shutdown; + } dfp = list_first_entry(&dop_pending, struct xfs_defer_pending, dfp_list);
Signature · 1 line
2.25.1
PATCH v25 5/14 xfsprogs: Return from xfs_attr_set_iter if there are no more rmtblks to process
In reply to Allison HendersonSource kernel commit: df21062113850c5aaeaa38b5194ee4c64767fb7a
During an attr rename operation, blocks are saved for later removal as rmtblkno2. The rmtblkno is used in the case of needing to alloc more blocks if not enough were available. However, in the case that no further blocks need to be added or removed, we can return as soon as xfs_attr_node_addname completes, rather than rolling the transaction with an -EAGAIN return. This extra loop does not hurt anything right now, but it will be a problem later when we get into log items because we end up with an empty log transaction. So, add a simple check to cut out the unneeded iteration.
--- libxfs/xfs_attr.c | 8 ++++++++ 1 file changed, 8 insertions(+)
libxfs/xfs_attr.c +8 -0
@@ -412,6 +412,14 @@ xfs_attr_set_iter(if (error)return error; +/* +* If addname was successful, and we dont need to alloc +* or remove anymore blks, we're done. +*/ +if (!args->rmtblkno && + !(args->op_flags &XFS_DA_OP_RENAME )) +return 0 ; + dac->dela_state =XFS_DAS_FOUND_NBLK ; }trace_xfs_attr_set_iter_return (dac->dela_state, args->dp);
Signature · 1 line
2.25.1
PATCH v25 6/14 xfsprogs: Set up infrastructure for log attribute replay
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 log attr replay 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 will log 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 | 3 +++ libxfs/xfs_attr.c | 4 +--- libxfs/xfs_attr.h | 30 ++++++++++++++++++++++++++++ libxfs/xfs_defer.h | 1 + libxfs/xfs_log_format.h | 43 +++++++++++++++++++++++++++++++++++++++-- 5 files changed, 76 insertions(+), 5 deletions(-)
libxfs/defer_item.c +3 -0
@@ -20,6 +20,9 @@#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. */
libxfs/xfs_attr.c +1 -3
@@ -61,8 +61,6 @@ 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_set_iter(struct xfs_delattr_context *dac, -struct xfs_buf **leaf_bp); STATIC int xfs_attr_node_removename(struct xfs_da_args *args,struct xfs_da_state *state);
@@ -166,7 +164,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)
libxfs/xfs_attr.h +30 -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_has_larp (struct xfs_mount *mp) +{ +return false; +} +/* * Kernel-internal version of the attrlist cursor. */
@@ -461,6 +466,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;
@@ -474,6 +484,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} +*/ +unsigned int xattri_op_flags; + +/* used to log this item to an intent */ +struct list_head xattri_list; +}; + +/*======================================================================== * Function prototypes for the kernel. *========================================================================*/
@@ -490,11 +517,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.h +1 -0
@@ -63,6 +63,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.25.1
PATCH v25 7/14 xfsprogs: Implement attr logging and replay
In reply to Allison HendersonThis patch adds the needed routines to create, log and recover logged extended attribute intents.
--- libxfs/defer_item.c | 119 ++++++++++++++++++++++++++++++++++++++++++++ libxfs/xfs_defer.c | 1 + libxfs/xfs_defer.h | 1 + libxfs/xfs_format.h | 11 +++- 4 files changed, 131 insertions(+), 1 deletion(-)
libxfs/defer_item.c +119 -0
@@ -115,6 +115,125 @@ const struct xfs_defer_op_type xfs_extent_free_defer_type = { .cancel_item = xfs_extent_free_cancel_item, }; +/* +* Performs one step of an attribute update intent and marks the attrd item +* dirty.. 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. +*/ +STATIC int +xfs_trans_attr_finish_update ( +struct xfs_delattr_context *dac, +struct xfs_buf **leaf_bp, +uint32_t op_flags) +{ +struct xfs_da_args *args = dac->da_args; +unsigned int op = op_flags & +XFS_ATTR_OP_FLAGS_TYPE_MASK ; +int error; + +switch (op) { +case XFS_ATTR_OP_FLAGS_SET : + 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_finish_update (dac, &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/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 bool
libxfs/xfs_defer.h +1 -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, };
libxfs/xfs_format.h +10 -1
@@ -485,7 +485,9 @@ xfs_sb_has_incompat_feature(return (sbp->sb_features_incompat & feature) !=0 ; } -#define XFS_SB_FEAT_INCOMPAT_LOG_ALL 0 +#define XFS_SB_FEAT_INCOMPAT_LOG_XATTRS (1 << 0)/* Delayed Attributes */ +#define XFS_SB_FEAT_INCOMPAT_LOG_ALL \ + (XFS_SB_FEAT_INCOMPAT_LOG_XATTRS)#define XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_LOG_ALLstatic inline bool xfs_sb_has_incompat_log_feature(
@@ -590,6 +592,13 @@ static inline bool xfs_sb_version_hasbigtime(struct xfs_sb *sbp) (sbp->sb_features_incompat &XFS_SB_FEAT_INCOMPAT_BIGTIME ); } +static inline bool xfs_sb_version_haslogxattrs (struct xfs_sb *sbp) +{ +return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 && + (sbp->sb_features_log_incompat & +XFS_SB_FEAT_INCOMPAT_LOG_XATTRS ); +} +/* * Inode btree block counter. We record the number of inobt and finobt blocks * in the AGI header so that we can skip the finobt walk at mount time when
Signature · 1 line
2.25.1
PATCH v25 8/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 | 54 ++++++++++++++++++++++++++---------------- libxfs/xfs_attr_leaf.c | 3 ++- 2 files changed, 35 insertions(+), 22 deletions(-)
libxfs/xfs_attr.c +33 -21
@@ -354,6 +354,7 @@ xfs_attr_set_iter(struct xfs_inode *dp = args->dp;struct xfs_buf *bp =NULL ;int forkoff, error =0 ; +struct xfs_mount *mp = args->dp->i_mount;/* State machine switch */ switch (dac->dela_state) {
@@ -476,16 +477,21 @@ xfs_attr_set_iter(* 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_attr_set_iter_return (dac->dela_state, args->dp); -return -EAGAIN ; +if (!xfs_has_larp (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_attr_set_iter_return (dac->dela_state, + args->dp); +return -EAGAIN ; + } + + fallthrough;case XFS_DAS_FLIP_LFLAG :/* * Dismantle the "old" attribute/value pair by removing a
@@ -588,17 +594,21 @@ xfs_attr_set_iter(* 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_attr_set_iter_return (dac->dela_state, args->dp); -return -EAGAIN ; +if (!xfs_has_larp (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_attr_set_iter_return (dac->dela_state, + args->dp); +return -EAGAIN ; + } + fallthrough;case XFS_DAS_FLIP_NFLAG :/* * Dismantle the "old" attribute/value pair by removing a
@@ -1236,6 +1246,7 @@ xfs_attr_node_addname_clear_incomplete( {struct xfs_da_args *args = dac->da_args;struct xfs_da_state *state =NULL ; +struct xfs_mount *mp = args->dp->i_mount;int retval =0 ;int error =0 ;
@@ -1243,7 +1254,8 @@ xfs_attr_node_addname_clear_incomplete(* 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 ; +if (!xfs_has_larp (mp)) + 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
@@ -1479,7 +1479,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_has_larp (mp)) + entry->flags |=XFS_ATTR_INCOMPLETE ;if ((args->blkno2 == args->blkno) && (args->index2 <= args->index)) { args->index2++;
Signature · 1 line
2.25.1
PATCH v25 9/14 xfsprogs: Add xfs_attr_set_deferred and xfs_attr_remove_deferred
In reply to Allison HendersonFrom: Allison Collins <[email protected]>
These routines set up and queue 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/libxfs_priv.h | 4 +++ libxfs/xfs_attr.c | 69 ++++++++++++++++++++++++++++++++++++++++++-- libxfs/xfs_attr.h | 2 ++ 3 files changed, 72 insertions(+), 3 deletions(-)
libxfs/libxfs_priv.h +4 -0
@@ -609,9 +609,13 @@ typedef int (*xfs_rtalloc_query_range_fn)(int libxfs_zero_extent (struct xfs_inode *ip,xfs_fsblock_t start_fsb,xfs_off_t count_fsb); +/* xfs_log.c */ +struct xlog ;bool xfs_log_check_lsn (struct xfs_mount *,xfs_lsn_t );void xfs_log_item_init (struct xfs_mount *,struct xfs_log_item *,int ); +int xfs_attr_use_log_assist (struct xfs_mount *mp); +void xlog_drop_incompat_feat (struct xlog *log);#define xfs_log_in_recovery (mp) (false)/* xfs_icache.c */
libxfs/xfs_attr.c +66 -3
113 lines not on this page · raw message
libxfs/xfs_attr.h +2 -0
@@ -526,5 +526,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.25.1
PATCH v25 10/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 | 106 ++++----------------------------------- libxfs/xfs_attr.h | 8 +-- libxfs/xfs_attr_remote.c | 1 - 4 files changed, 13 insertions(+), 108 deletions(-)
libxfs/defer_item.c +2 -4
@@ -124,7 +124,6 @@ const struct xfs_defer_op_type xfs_extent_free_defer_type = { STATIC intxfs_trans_attr_finish_update (struct xfs_delattr_context *dac, -struct xfs_buf **leaf_bp,uint32_t op_flags) {struct xfs_da_args *args = dac->da_args;
@@ -134,7 +133,7 @@ xfs_trans_attr_finish_update(switch (op) {case XFS_ATTR_OP_FLAGS_SET : - 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));
@@ -206,8 +205,7 @@ xfs_attr_finish_item(*/ dac->da_args->trans = tp; - error =xfs_trans_attr_finish_update (dac, &dac->leaf_bp, - attr->xattri_op_flags); + error =xfs_trans_attr_finish_update (dac, attr->xattri_op_flags);if (error != -EAGAIN )kmem_free (attr);
libxfs/xfs_attr.c +9 -97
183 lines not on this page · raw message
libxfs/xfs_attr.h +2 -6
@@ -457,8 +457,7 @@ 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_LEAF_ADDNAME_INIT 0x01/* xfs_attr_leaf_addname init*/ /* * Context used for keeping track of delayed attribute operations
@@ -516,11 +515,8 @@ bool xfs_attr_is_leaf(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
@@ -694,7 +694,6 @@ xfs_attr_rmtval_remove(* the parent */ if (!done) { - dac->flags |=XFS_DAC_DEFER_FINISH ;trace_xfs_attr_rmtval_remove_return (dac->dela_state, args->dp);return -EAGAIN ; }
Signature · 1 line
2.25.1
PATCH v25 11/14 xfsprogs: Add log attribute error tag
In reply to Allison HendersonThis patch adds an error tag that we can use to test log attribute recovery and replay
--- io/inject.c | 1 + libxfs/defer_item.c | 6 ++++++ libxfs/xfs_errortag.h | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-)
io/inject.c +1 -0
@@ -58,6 +58,7 @@ error_tag(char *name) { XFS_ERRTAG_REDUCE_MAX_IEXTENTS, "reduce_max_iextents" }, { XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT, "bmap_alloc_minlen_extent" }, { XFS_ERRTAG_AG_RESV_FAIL, "ag_resv_fail" }, + { XFS_ERRTAG_LARP, "larp" }, { XFS_ERRTAG_MAX, NULL } };int count;
libxfs/defer_item.c +6 -0
@@ -131,6 +131,11 @@ xfs_trans_attr_finish_update(XFS_ATTR_OP_FLAGS_TYPE_MASK ;int error; +if (XFS_TEST_ERROR (false, args->dp->i_mount,XFS_ERRTAG_LARP )) { + error = -EIO ; + goto out; + } +switch (op) {case XFS_ATTR_OP_FLAGS_SET : error =xfs_attr_set_iter (dac);
@@ -144,6 +149,7 @@ xfs_trans_attr_finish_update(break ; } +out:/* * Mark the transaction dirty, even on error. This ensures the * transaction is aborted, which:
libxfs/xfs_errortag.h +3 -1
@@ -59,7 +59,8 @@#define XFS_ERRTAG_REDUCE_MAX_IEXTENTS 36#define XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT 37#define XFS_ERRTAG_AG_RESV_FAIL 38 -#define XFS_ERRTAG_MAX 39 +#define XFS_ERRTAG_LARP 39 +#define XFS_ERRTAG_MAX 40/* * Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
@@ -103,5 +104,6 @@#define XFS_RANDOM_REDUCE_MAX_IEXTENTS 1#define XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT 1#define XFS_RANDOM_AG_RESV_FAIL 1 +#define XFS_RANDOM_LARP 1#endif /* __XFS_ERRORTAG_H_ */
Signature · 1 line
2.25.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v25 11/14] xfsprogs: Add log attribute error tag
Quoted 78 lines · Catherine Hoang
Quoted 78 lines
On Nov 16, 2021, at 8:16 PM, Allison Henderson <[email protected]
Quoted 74 lines
<mailto:[email protected]>> wrote:
This patch adds an error tag that we can use to test log attribute recovery and replay
Signed-off-by Allison Henderson <[email protected] <mailto:[email protected]>>Reviewed-by Darrick J. Wong <[email protected] <mailto:[email protected]>>Reviewed-by Chandan Babu R <[email protected] <mailto:[email protected]>>---
io/inject.c | 1 + libxfs/defer_item.c | 6 ++++++ libxfs/xfs_errortag.h | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-)io/inject.c +1
-0@@ -58,6 +58,7 @@ error_tag(char *name) { XFS_ERRTAG_REDUCE_MAX_IEXTENTS,"reduce_max_iextents" }, { XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT,"bmap_alloc_minlen_extent" }, { XFS_ERRTAG_AG_RESV_FAIL,"ag_resv_fail" }, +{ XFS_ERRTAG_LARP,"larp" }, { XFS_ERRTAG_MAX,NULL } }; intcount;libxfs/defer_item.c +5
-0@@ -131,6 +131,11 @@ xfs_trans_attr_finish_update(XFS_ATTR_OP_FLAGS_TYPE_MASK ; interror; +if (XFS_TEST_ERROR (false, args->dp->i_mount,XFS_ERRTAG_LARP )) { +error = -EIO ; +goto out; +} +switch (op) {case
XFS_ATTR_OP_FLAGS_SET:
error =xfs_attr_set_iter(dac);libxfs/defer_item.c +1
-0@@ -144,6 +149,7 @@ xfs_trans_attr_finish_update(break ; } +out:/* * Mark the transaction dirty, even on error. This ensures the * transaction is aborted, which: libxfs/xfs_errortag.h +3
-1@@ -59,7 +59,8 @@#define XFS_ERRTAG_REDUCE_MAX_IEXTENTS36 #define XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT37 #define XFS_ERRTAG_AG_RESV_FAIL38 -#define XFS_ERRTAG_MAX39 +#define XFS_ERRTAG_LARP39 +#define XFS_ERRTAG_MAX40 /* * Random factors for above tags, 1 means always, 2 means 1/2 time, etc. @@ -103,5 +104,6 @@#define XFS_RANDOM_REDUCE_MAX_IEXTENTS1 #define XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT1 #define XFS_RANDOM_AG_RESV_FAIL1 +#define XFS_RANDOM_LARP1 #endif /* __XFS_ERRORTAG_H_ */ Signature · 1 line
2.25.1Looks good
Quoted 2 lines
Quoted 2 lines
Reviewed-by Catherine Hoang <[email protected]<mailto:[email protected]>>
Great, thanks for the reviews Catherine! I will add your rvbs :-)
Allison
Quoted 1 line
Quoted 1 line
PATCH v25 12/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 infrastructure is in place, we can combine these to eliminate the extra struct
--- libxfs/defer_item.c | 14 ++-- libxfs/xfs_attr.c | 161 ++++++++++++++++++++------------------- libxfs/xfs_attr.h | 40 +++++----- libxfs/xfs_attr_remote.c | 36 ++++----- libxfs/xfs_attr_remote.h | 6 +- 5 files changed, 128 insertions(+), 129 deletions(-)
libxfs/defer_item.c +6 -8
@@ -123,10 +123,10 @@ const struct xfs_defer_op_type xfs_extent_free_defer_type = {*/ STATIC intxfs_trans_attr_finish_update ( -struct xfs_delattr_context *dac, +struct xfs_attr_item *attr,uint32_t op_flags) { -struct xfs_da_args *args = dac->da_args; +struct xfs_da_args *args = attr->xattri_da_args;unsigned int op = op_flags &XFS_ATTR_OP_FLAGS_TYPE_MASK ;int error;
@@ -138,11 +138,11 @@ xfs_trans_attr_finish_update(switch (op) {case XFS_ATTR_OP_FLAGS_SET : - 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 ;
@@ -200,18 +200,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_finish_update (dac, attr->xattri_op_flags); + error =xfs_trans_attr_finish_update (attr, attr->xattri_op_flags);if (error != -EAGAIN )kmem_free (attr);
libxfs/xfs_attr.c +83 -78
407 lines not on this page · raw message
libxfs/xfs_attr.h +17 -23
@@ -430,7 +430,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
@@ -455,39 +455,32 @@ 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*/ /* * 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
@@ -495,7 +488,10 @@ struct xfs_attr_item {*/ unsigned int 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; };
@@ -515,12 +511,10 @@ bool xfs_attr_is_leaf(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_has_attr (struct xfs_da_args *args); -int xfs_attr_remove_iter (struct xfs_delattr_context *dac); +int xfs_attr_set_iter (struct xfs_attr_item *attr); +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 +19 -17
@@ -567,14 +567,14 @@ xfs_attr_rmtval_stale(*/ 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 ));
@@ -583,8 +583,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 ; }
@@ -597,17 +597,18 @@ 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;
@@ -617,8 +618,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 ; }
@@ -672,9 +673,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;/*
@@ -694,7 +695,8 @@ xfs_attr_rmtval_remove(* the parent */ if (!done) { -trace_xfs_attr_rmtval_remove_return (dac->dela_state, args->dp); +trace_xfs_attr_rmtval_remove_return (attr->xattri_dela_state, + args->dp);return -EAGAIN ; }
libxfs/xfs_attr_remote.h +3 -3
@@ -12,9 +12,9 @@ int xfs_attr_rmtval_get(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.25.1
PATCH v25 13/14 xfsprogs: Add helper function xfs_attr_leaf_addname
In reply to Allison HendersonSource kernel commit: 6d9d518192a3f633fce0821601847966280857f7
This patch adds a helper function xfs_attr_leaf_addname. While this does help to break down xfs_attr_set_iter, it does also hoist out some of the state management. This patch has been moved to the end of the clean up series for further discussion.
--- include/xfs_trace.h | 1 + libxfs/xfs_attr.c | 110 ++++++++++++++++++++++++-------------------- 2 files changed, 61 insertions(+), 50 deletions(-)
include/xfs_trace.h +1 -0
@@ -316,6 +316,7 @@#define trace_xfs_attr_sf_addname_return (a,b) ((void) 0)#define trace_xfs_attr_set_iter_return (a,b) ((void) 0) +#define trace_xfs_attr_leaf_addname_return (a,b) ((void) 0)#define trace_xfs_attr_node_addname_return (a,b) ((void) 0)#define trace_xfs_attr_remove_iter_return (a,b) ((void) 0)#define trace_xfs_attr_rmtval_remove_return (a,b) ((void) 0)
libxfs/xfs_attr.c +60 -50
123 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v25 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 | 197 +++++++++++++++++++++++++++++++++++++++ logprint/logprint.h | 12 +++ 4 files changed, 268 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 +197 -0
200 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.25.1