From: Christoph Hellwig <hch@infradead.org>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/3] xfs: make attr lookup returns consistent
Date: Thu, 29 Aug 2019 00:41:39 -0700 [thread overview]
Message-ID: <20190829074139.GA18966@infradead.org> (raw)
In-Reply-To: <20190828042350.6062-2-david@fromorbit.com>
On Wed, Aug 28, 2019 at 02:23:48PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> Shortform, leaf and remote value attr value retrieval return
> different values for success. This makes it more complex to handle
> actual errors xfs_attr_get() as some errors mean success and some
> mean failure. Make the return values consistent for success and
> failure consistent for all attribute formats.
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
> fs/xfs/libxfs/xfs_attr.c | 57 +++++++++++++++++++++------------
> fs/xfs/libxfs/xfs_attr_leaf.c | 15 ++++++---
> fs/xfs/libxfs/xfs_attr_remote.c | 2 ++
> fs/xfs/scrub/attr.c | 2 --
> 4 files changed, 49 insertions(+), 27 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> index d48fcf11cc35..776343c4f22b 100644
> --- a/fs/xfs/libxfs/xfs_attr.c
> +++ b/fs/xfs/libxfs/xfs_attr.c
> @@ -97,7 +97,10 @@ xfs_inode_hasattr(
> * Overall external interface routines.
> *========================================================================*/
>
> -/* Retrieve an extended attribute and its value. Must have ilock. */
> +/*
> + * Retrieve an extended attribute and its value. Must have ilock.
> + * Returns 0 on successful retrieval, otherwise an error.
> + */
> int
> xfs_attr_get_ilocked(
> struct xfs_inode *ip,
> @@ -147,7 +150,7 @@ xfs_attr_get(
> xfs_iunlock(ip, lock_mode);
>
> *valuelenp = args.valuelen;
> - return error == -EEXIST ? 0 : error;
> + return error;
> }
>
> /*
> @@ -768,6 +771,8 @@ xfs_attr_leaf_removename(
> *
> * 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).
> + *
> + * Returns 0 on successful retrieval, otherwise an error.
> */
> STATIC int
> xfs_attr_leaf_get(xfs_da_args_t *args)
> @@ -789,10 +794,15 @@ xfs_attr_leaf_get(xfs_da_args_t *args)
> }
> error = xfs_attr3_leaf_getvalue(bp, args);
> xfs_trans_brelse(args->trans, bp);
> - if (!error && (args->rmtblkno > 0) && !(args->flags & ATTR_KERNOVAL)) {
> - error = xfs_attr_rmtval_get(args);
> - }
> - return error;
> + if (error)
> + return error;
> +
> + /* check if we have to retrieve a remote attribute to get the value */
> + if (args->flags & ATTR_KERNOVAL)
> + return 0;
> + if (!args->rmtblkno)
> + return 0;
> + return xfs_attr_rmtval_get(args);
> }
>
> /*========================================================================
> @@ -1268,11 +1278,13 @@ xfs_attr_refillstate(xfs_da_state_t *state)
> }
>
> /*
> - * Look up a filename in a node attribute list.
> + * Retreive the attribute data from a node attribute list.
> *
> * This routine gets called for any attribute fork that has more than one
> * block, ie: both true Btree attr lists and for single-leaf-blocks with
> * "remote" values taking up more blocks.
> + *
> + * Returns 0 on successful retrieval, otherwise an error.
> */
> STATIC int
> xfs_attr_node_get(xfs_da_args_t *args)
> @@ -1289,29 +1301,32 @@ xfs_attr_node_get(xfs_da_args_t *args)
> state->mp = args->dp->i_mount;
>
> /*
> - * Search to see if name exists, and get back a pointer to it.
> + Search to see if name exists, and get back a pointer to it.
> */
> error = xfs_da3_node_lookup_int(state, &retval);
> if (error) {
> retval = error;
Given that you are cleaning up this mess, can you check if there
is any point in the weird xfs_da3_node_lookup_int calling conventions?
It looks like it can return errnos in both the return value and
*revtval, and from a quick check it seems like all callers treat them
more or less the same.
next prev parent reply other threads:[~2019-08-29 7:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-28 4:23 [PATCH 0/3 v2] xfs: allocate xattr buffer on demand Dave Chinner
2019-08-28 4:23 ` [PATCH 1/3] xfs: make attr lookup returns consistent Dave Chinner
2019-08-28 22:03 ` Darrick J. Wong
2019-08-29 7:41 ` Christoph Hellwig [this message]
2019-08-29 10:32 ` Dave Chinner
2019-08-28 4:23 ` [PATCH 2/3] xfs: move remote attr retrieval into xfs_attr3_leaf_getvalue Dave Chinner
2019-08-28 22:01 ` Darrick J. Wong
2019-08-29 7:46 ` Christoph Hellwig
2019-08-28 4:23 ` [PATCH 3/3] xfs: allocate xattr buffer on demand Dave Chinner
2019-08-28 22:00 ` Darrick J. Wong
2019-08-29 7:55 ` Christoph Hellwig
2019-08-29 10:45 ` Dave Chinner
2019-08-29 11:02 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190829074139.GA18966@infradead.org \
--to=hch@infradead.org \
--cc=david@fromorbit.com \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox