Re: [PATCH v6 16/16] xfs: Add delay ready attr set routines

Allison Collins
2020-02-05T23:07:43Z

On 1/22/20 3:30 AM, Allison Collins wrote:
>
>
> On 1/21/20 5:12 PM, Darrick J. Wong wrote:
>> On Sat, Jan 18, 2020 at 03:50:35PM -0700, Allison Collins wrote:

<snip>

>>> diff --git a/fs/xfs/libxfs/xfs_attr_remote.h
>>> b/fs/xfs/libxfs/xfs_attr_remote.h
>>> index 7ab3770..ab03519 100644
>>> --- a/fs/xfs/libxfs/xfs_attr_remote.h
>>> +++ b/fs/xfs/libxfs/xfs_attr_remote.h
>>> @@ -13,4 +13,8 @@ int xfs_attr_rmtval_set(struct xfs_da_args *args);
>>>   int xfs_attr_rmtval_remove(struct xfs_da_args *args);
>>>   int xfs_attr_rmtval_invalidate(struct xfs_da_args *args);
>>>   int xfs_attr_rmtval_unmap(struct xfs_da_args *args);
>>> +int xfs_attr_rmt_find_hole(struct xfs_da_args *args);
>>> +int xfs_attr_rmtval_set_value(struct xfs_da_args *args);
>>> +int xfs_attr_rmtval_set_blk(struct xfs_da_args *args);
>>> +int xfs_attr_rmtval_set_init(struct xfs_da_args *args);
>>>   #endif /* __XFS_ATTR_REMOTE_H__ */
>>> diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h
>>> index 7fc87da..9943062 100644
>>> --- a/fs/xfs/libxfs/xfs_da_btree.h
>>> +++ b/fs/xfs/libxfs/xfs_da_btree.h
>>> @@ -55,6 +55,14 @@ enum xfs_dacmp {
>>>   enum xfs_delattr_state {
>>>       XFS_DAS_RM_SHRINK    = 1, /* We are shrinking the tree */
>>>       XFS_DAS_RM_NODE_BLKS    = 2, /* We are removing node blocks */
>>> +    XFS_DAS_SF_TO_LEAF    = 3, /* Converted short form to leaf */
>>> +    XFS_DAS_FOUND_LBLK    = 4, /* We found leaf blk for attr */
>>> +    XFS_DAS_LEAF_TO_NODE    = 5, /* Converted leaf to node */
>>> +    XFS_DAS_FOUND_NBLK    = 6, /* We found node blk for attr */
>>> +    XFS_DAS_ALLOC_LEAF    = 7, /* We are allocating leaf blocks */
>>> +    XFS_DAS_FLIP_LFLAG    = 8, /* Flipped leaf INCOMPLETE attr flag */
>>> +    XFS_DAS_ALLOC_NODE    = 9, /* We are allocating node blocks */
>>> +    XFS_DAS_FLIP_NFLAG    = 10,/* Flipped node INCOMPLETE attr flag */
>>
>> We've definitely reached the point where a state diagram would be
>> helpful.  Can you go from any of the RM_ states to the ones that you've
>> just added?
> No.  And if they did, they would have to show up in the calling
> functions state switches.  Because the calling function has to manage
> jumping straight back to the subroutine when ever the state belongs to
> the subroutine.  Kind of like how you see XFS_DAS_ALLOC_LEAF and
> XFS_DAS_FLIP_LFLAG in the state switch for xfs_attr_set_iter, even
> though those states only apply to xfs_attr_leaf_addname.
>
>>
>> The new state machine code in last two patches would be a lot easier to
>> review if I could look down from above instead of up from the XFS_DAS
>> values and goto labels.  I /think/ it looks sane, but I'm only 20%
>> confident of that statement.
>>
> Sure, I'll see if I can put together a diagram to help folks out a bit.
>
> Thanks for the reviews!
> Allison
>
>> --D
>>

Ok, so I've put together some quick high level diagrams, and I wanted to
run it by you to see what you thought.

These diagrams illustrate the state machine logic as it appears in the
current set. The XFS_DAS_* states indicate places where the function
would return -EAGAIN, and then immediately resume from after being
recalled by the calling function. States marked as a "subroutine state"
indicate that they belong to a subroutine, and so the calling function
needs to pass them back to that subroutine to allow it to finish where
it left off. But they otherwise do not have a role in the calling
function other than just passing through.

Hope this helps! Let me know if you have any questions or if there's
anything that would help make things more clear. Thanks!

Allison

/*
* State machine diagram for attr remove operations
*
* xfs_attr_remove_iter()
* XFS_DAS_RM_SHRINK ─┐
* (subroutine state) │
* │
* XFS_DAS_RMTVAL_REMOVE ─┤
* (subroutine state) │
* └─>xfs_attr_node_removename()
* │
* v
* need to remove
* ┌─n── rmt blocks?
* │ │
* │ y
* │ │
* │ v
* │ ┌─>XFS_DAS_RMTVAL_REMOVE
* │ │ │
* │ │ v
* │ └──y── more blks
* │ to remove?
* │ │
* │ n
* │ │
* │ v
* │ need to
* └─────> shrink tree? ─n─┐
* │ │
* y │
* │ │
* v │
* XFS_DAS_RM_SHRINK │
* │ │
* v │
* done <─────┘
*/

/*
* State machine diagram for attr set operations
*
* xfs_attr_set_iter()
* │
* v
* need to upgrade
* from sf to leaf? ──n─┐
* │ │
* y │
* │ │
* V │
* XFS_DAS_ADD_LEAF │
* │ │
* v │
* ┌──────n── fork has <──────┘
* │ only 1 blk?
* │ │
* │ y
* │ │
* │ v
* │ xfs_attr_leaf_try_add()
* │ │
* │ v
* │ had enough
* ├──────n── space?
* │ │
* │ y
* │ │
* │ v
* │ XFS_DAS_FOUND_LBLK ──┐
* │ │
* │ XFS_DAS_FLIP_LFLAG ──┤
* │ (subroutine state) │
* │ │
* │ XFS_DAS_ALLOC_LEAF ──┤
* │ (subroutine state) │
* │ └─>xfs_attr_leaf_addname()
* │ │
* │ v
* │ ┌─────n── need to
* │ │ alloc blks?
* │ │ │
* │ │ y
* │ │ │
* │ │ v
* │ │ ┌─>XFS_DAS_ALLOC_LEAF
* │ │ │ │
* │ │ │ v
* │ │ └──y── need to alloc
* │ │ more blocks?
* │ │ │
* │ │ n
* │ │ │
* │ │ v
* │ │ was this
* │ └────────> a rename? ──n─┐
* │ │ │
* │ y │
* │ │ │
* │ v │
* │ XFS_DAS_FLIP_LFLAG │
* │ │ │
* │ v │
* │ done <──────┘
* └────> XFS_DAS_LEAF_TO_NODE ─┐
* │
* XFS_DAS_FOUND_NBLK ──┤
* (subroutine state) │
* │
* XFS_DAS_ALLOC_NODE ──┤
* (subroutine state) │
* │
* XFS_DAS_FLIP_NFLAG ──┤
* (subroutine state) │
* │
* └─>xfs_attr_node_addname()
* │
* v
* find space to store
* attr. Split if needed
* │
* v
* XFS_DAS_FOUND_NBLK
* │
* v
* ┌─────n── need to
* │ alloc blks?
* │ │
* │ y
* │ │
* │ v
* │ ┌─>XFS_DAS_ALLOC_NODE
* │ │ │
* │ │ v
* │ └──y── need to alloc
* │ more blocks?
* │ │
* │ n
* │ │
* │ v
* │ was this
* └────────> a rename? ──n─┐
* │ │
* y │
* │ │
* v │
* XFS_DAS_FLIP_NFLAG │
* │ │
* v │
* done <──────┘
*/