public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] xfs: LARP - clean up xfs_attr_set_iter state machine
@ 2022-04-12  4:25 Dave Chinner
  2022-04-12  4:25 ` [PATCH 01/10] xfs: avoid empty xattr transaction when attrs are inline Dave Chinner
                   ` (12 more replies)
  0 siblings, 13 replies; 16+ messages in thread
From: Dave Chinner @ 2022-04-12  4:25 UTC (permalink / raw)
  To: linux-xfs; +Cc: allison.henderson

Hi Allison,

This is first patchset for fixing up stuff in the LARP code. I've
based this on my current 5.19-compose branch here:

git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs.git xfs-5.19-compose

The first patch in the series fixes the splat that occurs in
generic/642 in that merge from the empty, dirty transaction. I
haven't touched the xfs_attri_finish_one() code to remove the
XFS_TRANS_DIRTY there because that code is used for the remove path,
too, and I didn't want to perturb that before I was finished with
the set path.

The rest of the patchset is cleaning up the xfs_attr_set_iter()
state machine. THe use of XFS_DAS_UNINIT is gone - instead I set the
initial state according to the format of the attr fork. Then if we
convert from sf to leaf, or leaf to node, we bump the state to
LEAF_ADD or NODE_ADD and roll the transaction. The next time in it
will perform the appropriate attr addition.

I've then added extra states to handle remote value block allocation
and setting of the value for the leaf blocks. This makes the code
the same as setting the remote value for node blocks, and that then
leads to collapsing all the duplicate code paths.

To do that, I set up the leaf and node states as identical
numerically ascending sequences, allowing state changes to be done
by incrementing the state value from a specific initial condition,
but progressing down the correct sequence of states even though they
are executing the same code path. This initial condition (leaf or
node) is set directly by the LEAF/NODE_ADD states that have already
been separated and set up.

From there, it's really just cleanup - I separated the flipflags
operation into a separate state, so when larp is enabled it just
skips straight over it. I renamed the states to describe the
high level operation it is performing rather than the mechanics of
the modification it is making. Like the remote val block alloc, I
enabled it to skip over the remote attr states on remove if it isn't
a remote attr.

I factored the code a bit more, cleaning up the final leaf/node
states to look the same from the perspective of the state machine.

I then made sure that the state machine has a termination state -
XFS_DAS_DONE - so taht callers can determine whether the operation
is complete without requiring xfs_attr_set_iter() to return -EAGAIN
to tell the caller it needs to keep iterating. This allows removal
of most of the -EAGAIN returns and conditional logic in the
xfs_attr_set_iter() implementation and leaf functions. This means
that requirement of the deferop transaction rolling API (return
-EAGAIN) is contained entirely within xfs_attri_finish_one() instead
of bleeding through to xfs_attr_set_iter().

Overall, I find the state machine code much easier to read and
follow because it largely separates the implementation of individual
states from the execution of the state machine. The states are
smaller and easier to understate, too.

What I haven't done yet is update the big flowchart in xfs_attr.h.
Much of it is now stale and it doesn't match the new states or
progression through the states. I'm wondering if there's a better
way to document the state machine than a comment that will get
rapidly out of date, even though that comment was very helpful in
working out how to re-write the state machine cleanly....

I plan to make the same structural mods to xfs_attr_remove_iter(),
and then I can clean up xfs_attri_finish_one() and get rid of the
XFS_TRANS_DIRTY in that code.

The diffstat isn't too bad - it doesn't make the code smaller
overall because I split a lot of stuff out into smaller functions,
but it doesn't get bigger, either, and I think the result is much
more readable and maintainable.

 fs/xfs/libxfs/xfs_attr.c | 586 ++++++++++++++++-------------------
 fs/xfs/libxfs/xfs_attr.h |  60 +++-
 fs/xfs/xfs_attr_item.c   |   2 +
 fs/xfs/xfs_trace.h       |  26 +-
 4 files changed, 345 insertions(+), 329 deletions(-)

The patchset passes fstests '-g attr' running in a loop when larp=0,
but I haven't tested it with larp=1 yet - I've done zero larp=1
testing so far so I don't even know whether it works in the base
5.19 compose yet. I'll look at that when I finish the state machine
updates....

Thoughts?

Cheers,

Dave.



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-04-12 17:29 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-12  4:25 [PATCH 00/10] xfs: LARP - clean up xfs_attr_set_iter state machine Dave Chinner
2022-04-12  4:25 ` [PATCH 01/10] xfs: avoid empty xattr transaction when attrs are inline Dave Chinner
2022-04-12  4:25 ` [PATCH 02/10] xfs: make xattri_leaf_bp more useful Dave Chinner
2022-04-12  4:25 ` [PATCH 03/10] xfs: separate out initial attr_set states Dave Chinner
2022-04-12  4:25 ` [PATCH 04/10] xfs: kill XFS_DAC_LEAF_ADDNAME_INIT Dave Chinner
2022-04-12  4:25 ` [PATCH 05/10] xfs: consolidate leaf/node states in xfs_attr_set_iter Dave Chinner
2022-04-12  4:25 ` [PATCH 06/10] xfs: split remote attr setting out from replace path Dave Chinner
2022-04-12  4:25 ` [PATCH 07/10] xfs: XFS_DAS_LEAF_REPLACE state only needed if !LARP Dave Chinner
2022-04-12  4:25 ` [PATCH 08/10] xfs: remote xattr removal in xfs_attr_set_iter() is conditional Dave Chinner
2022-04-12  4:25 ` [PATCH 09/10] xfs: clean up final attr removal in xfs_attr_set_iter Dave Chinner
2022-04-12  4:25 ` [PATCH 10/10] xfs: xfs_attr_set_iter() does not need to return EAGAIN Dave Chinner
2022-04-12  4:48 ` [PATCH 00/10] xfs: LARP - clean up xfs_attr_set_iter state machine Christoph Hellwig
2022-04-12  5:04   ` Dave Chinner
2022-04-12  9:09 ` [PATCH 11/10] xfs: initialise attrd item to zero Dave Chinner
2022-04-12 10:42 ` [PATCH 00/10] xfs: LARP - clean up xfs_attr_set_iter state machine Dave Chinner
2022-04-12 17:28   ` Alli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox