From: Christoph Hellwig <hch@infradead.org>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/5] xfs: make attr lookup returns consistent
Date: Thu, 29 Aug 2019 22:34:04 -0700 [thread overview]
Message-ID: <20190830053404.GD6077@infradead.org> (raw)
In-Reply-To: <20190829113505.27223-2-david@fromorbit.com>
On Thu, Aug 29, 2019 at 09:35:01PM +1000, Dave Chinner wrote:
> +/*
> + * Retrieve an extended attribute and its value. Must have ilock.
> + * Returns 0 on successful retrieval, otherwise an error.
> + */
> int
> xfs_attr_get_ilocked(
This just updates a comment on xfs_attr_get_ilocked, no other change,
so looks good.
>
> 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;
> }
This drops a conversion from -EEXIST to 0 at the very top of the
callchain.
> - 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);
No change at all here, just a more verbose style.
> STATIC int
> xfs_attr_node_get(xfs_da_args_t *args)
> @@ -1294,24 +1306,27 @@ xfs_attr_node_get(xfs_da_args_t *args)
> error = xfs_da3_node_lookup_int(state, &retval);
> if (error) {
> retval = error;
> - } else if (retval == -EEXIST) {
> - blk = &state->path.blk[ state->path.active-1 ];
> - ASSERT(blk->bp != NULL);
> - ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC);
> -
> - /*
> - * Get the value, local or "remote"
> - */
> - retval = xfs_attr3_leaf_getvalue(blk->bp, args);
> - if (!retval && (args->rmtblkno > 0)
> - && !(args->flags & ATTR_KERNOVAL)) {
> - retval = xfs_attr_rmtval_get(args);
> - }
> + goto out_release;
> }
> + if (retval != -EEXIST)
> + goto out_release;
> +
> + /*
> + * Get the value, local or "remote"
> + */
> + blk = &state->path.blk[state->path.active - 1];
> + retval = xfs_attr3_leaf_getvalue(blk->bp, args);
> + if (retval)
> + goto out_release;
> + if (args->flags & ATTR_KERNOVAL)
> + goto out_release;
> + if (args->rmtblkno > 0)
> + retval = xfs_attr_rmtval_get(args);
>
> /*
> * If not in a transaction, we have to release all the buffers.
> */
> +out_release:
No change at all here as far as I can tell, just using a goto to
unwind error handling, and rewriting some code to be less
dense/obsfucated.
> int
> xfs_attr_shortform_getvalue(xfs_da_args_t *args)
> {
> @@ -743,7 +746,7 @@ xfs_attr_shortform_getvalue(xfs_da_args_t *args)
> continue;
> if (args->flags & ATTR_KERNOVAL) {
> args->valuelen = sfe->valuelen;
> - return -EEXIST;
> + return 0;
> }
> if (args->valuelen < sfe->valuelen) {
> args->valuelen = sfe->valuelen;
> @@ -752,7 +755,7 @@ xfs_attr_shortform_getvalue(xfs_da_args_t *args)
> args->valuelen = sfe->valuelen;
> memcpy(args->value, &sfe->nameval[args->namelen],
> args->valuelen);
> - return -EEXIST;
> + return 0;
And here we have the first change - xfs_attr_shortform_getvalue now
returns 0 instead of -EEXIST when finding the xattr. The old calling
conventions does indeed seem very odd. As xfs_attr_shortform_getvalue
is directly called by the small xfs_attr_get_ilocked wrapper, which
only has two calers that fix up -EEXIST to 0 this looks safe.
So overall this looks good, but I think having this split into two
pure cleanups and one to actually switch this single case away from
-EEXIST (and document the chain as I wrote above while following it)
would have been more helpful.
So what:
Reviewed-by: Christoph Hellwig <hch@lst.de>
next prev parent reply other threads:[~2019-08-30 5:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-29 11:35 [PATCH 0/3 v3] xfs: allocate xattr buffer on demand Dave Chinner
2019-08-29 11:35 ` [PATCH 1/5] xfs: make attr lookup returns consistent Dave Chinner
2019-08-30 5:34 ` Christoph Hellwig [this message]
2019-08-29 11:35 ` [PATCH 2/5] xfs: remove unnecessary indenting from xfs_attr3_leaf_getvalue Dave Chinner
2019-08-29 21:23 ` Darrick J. Wong
2019-08-30 5:34 ` Christoph Hellwig
2019-08-29 11:35 ` [PATCH 3/5] xfs: move remote attr retrieval into xfs_attr3_leaf_getvalue Dave Chinner
2019-08-29 21:26 ` Darrick J. Wong
2019-08-30 5:35 ` Christoph Hellwig
2019-08-29 11:35 ` [PATCH 4/5] xfs: consolidate attribute value copying Dave Chinner
2019-08-29 21:26 ` Darrick J. Wong
2019-08-30 5:35 ` Christoph Hellwig
2019-08-29 11:35 ` [PATCH 5/5] xfs: allocate xattr buffer on demand Dave Chinner
2019-08-29 21:27 ` Darrick J. Wong
2019-08-30 5:36 ` 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=20190830053404.GD6077@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.