Re: [PATCH v5 07/14] xfs: Factor out xfs_attr_leaf_addname helper

Allison Collins
2019-12-26T17:04:15Z

On 12/24/19 5:22 AM, Christoph Hellwig wrote:
> On Wed, Dec 11, 2019 at 09:15:06PM -0700, Allison Collins wrote:
>> Factor out new helper function xfs_attr_leaf_try_add.
>> Because new delayed attribute routines cannot roll
>> transactions, we carve off the parts of
>> xfs_attr_leaf_addname that we can use. This will help
>> to reduce repetitive code later when we introduce
>> delayed attributes.
>
> I have a hard time relating the subject to what is happening here,
> maybe because the patch does too many things at once. One thing
> is plitting a xfs_attr_leaf_try_add from xfs_attr_leaf_addname, which
> seems pretty sensible, but then it also moves code from
> xfs_attr_node_addname into the only caller. That probably should be
> a separate patch with a proper description.
>
Sure, maybe it might help to look at it this way though: the goal of all
this refactoring is to get all the transactions up into the
xfs_attr_*_args routines. Once we have them pretty much corralled, we
replace them with a sort of state machine like mechanic. This produces
the "return EAGAIN for new a transaction" behavior that we need for the
.finish_item callback.

In this case, xfs_attr_leaf_addname is a subroutine with a transaction
in the middle. So we split it into two functions. Kind of like a top
half and bottom half, and then the transaction moves up. While I can
separate the split and the move into separate patches, it didnt really
feel to me like the transaction or the node logic really fit with either
of the helpers. They are supposed to be about leaves, not nodes. It's
not a big deal I suppose to split up the patches, but I thought doing so
creates a sort of transient patch with functions that have logic not
particularly appropriate for their scope. Thoughts?

Also, perhaps I need to remove the line in the commit header about
reducing repetitive code. It might be misleading you (apologies). This
is left over from an earlier version of the series where I tried to
avoid "monster function" by having two code paths: one for inline attrs
and a separate one for delayed attrs. It generated a lot of repetitive
code with subtle differences though, and i think folks preferred the
code paths to stay merged. The goal being to first establish what
"monster function" even looks like, and then simplify it into new
helpers from there.

This is admittedly a very difficult series to review. People need to
understand patches 1 - 12 to really understand what 13 and 14 are doing.
But really, 13 and 14 are kind of driving the rest of the series.
Like literally an entire patch fell out of the last set because of some
changes we made in the end of the series. I know 13 and 14 are the
hardest to look at, but they very much dictate what the lower patches
end up doing. So I encourage people to try and focus attention there
before loosing to much sanity on scaffolding. Certainty it all needs to
get reviewed of course, but it may help to make more efficient use of
peoples review time. :-)

Hope that helps! Thanks for looking at it!
Allison