Re: [PATCH 16/17] xfs: use XFS_DA_OP flags in deferred attr ops

Alli
2022-05-10T22:31:39Z

On Mon, 2022-05-09 at 18:17 +1000, Dave Chinner wrote:
> On Fri, May 06, 2022 at 07:45:52PM +1000, Dave Chinner wrote:
> > @@ -1357,46 +1370,45 @@ xfs_attr_node_hasname(
> >
> > STATIC int
> > xfs_attr_node_addname_find_attr(
> > - struct xfs_attr_item *attr)
> > + struct xfs_attr_item *attr)
> > {
> > - struct xfs_da_args *args = attr->xattri_da_args;
> > - int retval;
> > + struct xfs_da_args *args = attr->xattri_da_args;
> > + int error;
> >
> > /*
> > * Search to see if name already exists, and get back a pointer
> > * to where it should go.
> > */
> > - retval = xfs_attr_node_hasname(args, &attr->xattri_da_state);
> > - if (retval != -ENOATTR && retval != -EEXIST)
> > - goto error;
> > -
> > - if (retval == -ENOATTR && (args->attr_flags & XATTR_REPLACE))
> > - goto error;
> > - if (retval == -EEXIST) {
> > - if (args->attr_flags & XATTR_CREATE)
> > + error = xfs_attr_node_hasname(args, &attr->xattri_da_state);
> > + switch (error) {
> > + case -ENOATTR:
> > + if (args->op_flags & XFS_DA_OP_REPLACE)
> > + goto error;
> > + break;
> > + case -EEXIST:
> > + if (!(args->op_flags & XFS_DA_OP_REPLACE))
> > goto error;
> >
> > - trace_xfs_attr_node_replace(args);
> > -
> > - /* save the attribute state for later removal*/
> > - args->op_flags |= XFS_DA_OP_RENAME; /* atomic rename op
> > */
> > - xfs_attr_save_rmt_blk(args);
> >
> > + trace_xfs_attr_node_replace(args);
> > /*
> > - * clear the remote attr state now that it is saved so
> > that the
> > - * values reflect the state of the attribute we are
> > about to
> > + * Save the existing remote attr state so that the
> > current
> > + * values reflect the state of the new attribute we are
> > about to
> > * add, not the attribute we just found and will remove
> > later.
> > */
> > - args->rmtblkno = 0;
> > - args->rmtblkcnt = 0;
> > - args->rmtvaluelen = 0;
> > + xfs_attr_save_rmt_blk(args);
>
> Ok, removing the rmtblk zeroing right there is a bug. Not sure how I
> introduced that, or why it didn't show up until this afternoon. The
> leaf version of this same code is correct, and it triggers on
> generic/026 when larp = 0 but not when larp = 1.
>
> I've fixed it, but vger is constipated again and I patches sent 8
> hours ago haven't reached the list yet so when I arrives I'll post
> an updated version of this patch against it....
>
> Cheers,
>
> Dave.
Alrighty, this part aside, I think this patch looks ok. I've applied
this set, plus a small manual fix to put back the rmtblk zeroing, and
things seem to be running ok for me now.

Reviewed-by: Allison Henderson <allison.henderson@oracle.com>