aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2019-07-05 13:29:54 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2019-07-05 13:29:54 -0400
commit2c3b83d7ca6d73b9478afc86c89377c15a90b9ed (patch)
treec56bbb3222576852670f1413c741a12537e8861d
parentbf3cb394479210a9ebcf8fef7a7f8fcabc7b9928 (diff)
xfs: attribute scrub should use seen_enough to pass error values
When we're iterating all the attributes using the built-in xattr iterator, we can use the seen_enough variable to pass error codes back to the main scrub function instead of flattening them into 0/1. This will be used in a more exciting fashion in upcoming patches. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com>
-rw-r--r--fs/xfs/libxfs/xfs_attr.h8
-rw-r--r--fs/xfs/scrub/attr.c8
2 files changed, 13 insertions, 3 deletions
diff --git a/fs/xfs/libxfs/xfs_attr.h b/fs/xfs/libxfs/xfs_attr.h
index 3b0dce06e454..ff28ebf3b635 100644
--- a/fs/xfs/libxfs/xfs_attr.h
+++ b/fs/xfs/libxfs/xfs_attr.h
@@ -112,7 +112,13 @@ typedef struct xfs_attr_list_context {
112 struct xfs_inode *dp; /* inode */ 112 struct xfs_inode *dp; /* inode */
113 struct attrlist_cursor_kern *cursor; /* position in list */ 113 struct attrlist_cursor_kern *cursor; /* position in list */
114 char *alist; /* output buffer */ 114 char *alist; /* output buffer */
115 int seen_enough; /* T/F: seen enough of list? */ 115
116 /*
117 * Abort attribute list iteration if non-zero. Can be used to pass
118 * error values to the xfs_attr_list caller.
119 */
120 int seen_enough;
121
116 ssize_t count; /* num used entries */ 122 ssize_t count; /* num used entries */
117 int dupcnt; /* count dup hashvals seen */ 123 int dupcnt; /* count dup hashvals seen */
118 int bufsize; /* total buffer size */ 124 int bufsize; /* total buffer size */
diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c
index 099a28308815..70f025284c42 100644
--- a/fs/xfs/scrub/attr.c
+++ b/fs/xfs/scrub/attr.c
@@ -73,7 +73,7 @@ xchk_xattr_listent(
73 sx = container_of(context, struct xchk_xattr, context); 73 sx = container_of(context, struct xchk_xattr, context);
74 74
75 if (xchk_should_terminate(sx->sc, &error)) { 75 if (xchk_should_terminate(sx->sc, &error)) {
76 context->seen_enough = 1; 76 context->seen_enough = error;
77 return; 77 return;
78 } 78 }
79 79
@@ -115,7 +115,7 @@ xchk_xattr_listent(
115 args.blkno); 115 args.blkno);
116fail_xref: 116fail_xref:
117 if (sx->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) 117 if (sx->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
118 context->seen_enough = 1; 118 context->seen_enough = XFS_ITER_ABORT;
119 return; 119 return;
120} 120}
121 121
@@ -454,6 +454,10 @@ xchk_xattr(
454 error = xfs_attr_list_int_ilocked(&sx.context); 454 error = xfs_attr_list_int_ilocked(&sx.context);
455 if (!xchk_fblock_process_error(sc, XFS_ATTR_FORK, 0, &error)) 455 if (!xchk_fblock_process_error(sc, XFS_ATTR_FORK, 0, &error))
456 goto out; 456 goto out;
457
458 /* Did our listent function try to return any errors? */
459 if (sx.context.seen_enough < 0)
460 error = sx.context.seen_enough;
457out: 461out:
458 return error; 462 return error;
459} 463}