[lustre-discuss] question about rename operation ?

Andreas Dilger adilger at whamcloud.com
Wed Aug 16 01:49:54 PDT 2023


Any directory renames where it is not just a simple name change (ie. parent directory is
not the same for both source and target) the MDS thread doing the rename will take the
LDLM "big filesystem lock" (BFL), which is a specific FID for global rename serialization.

This ensures that there is only one thread in the whole filesystem doing a rename that
may create directory loops, and the parent/child relationship is checked under
this lock to ensure there are no loops.

For regular file renames, and directory renames within a single parent, it is possible
to do parallel renames, and the MDS only locks the parent, source, and target FIDs to
avoid multiple threads modifying the same file or directory at once.

The client will also take the VFS rename lock before sending the rename RPC, which serializes the changes on the client, but does not help anything for the rest of the filesystem.  This unfortunately also serializes regular renames on a single client, but they
can still be done in parallel on multiple clients.

Cheers, Andreas

On Aug 15, 2023, at 20:14, 宋慕晗 via lustre-discuss <lustre-discuss at lists.lustre.org> wrote:


Dear lustre maintainers,
There seems to be a bug in lustre *ll_rename* function:
/* VFS has locked the inodes before calling this */
ll_set_inode_lock_owner(src);
ll_set_inode_lock_owner(tgt);
if (tgt_dchild->d_inode)
ll_set_inode_lock_owner(tgt_dchild->d_inode);

Here we lock the src directory, target directory, and lock the target child if exists. But we don't lock the src child, but it's possible to change the ".." pointer of src child.
see this in xfs: https://www.spinics.net/lists/linux-xfs/msg68693.html

And I am also wondering how lustre deal with concurrent rename ?  Specifically, my concern revolves around the potential for directory loops when two clients initiate renames simultaneously.
In the VFS, there's a filesystem-specific vfs_rename_mutex that serializes the rename operation. In Ceph, I noticed the presence of a global client lock. However, I'm uncertain if the MDS serializes rename requests.
Consider the following scenario:

        a
       /   \
     b     c
    /         \
  d           e
 /              \
f                g

If Client 1 attempts to rename "c" to "f" while Client 2 tries to rename "b" to "g" concurrently, and both succeed, we could end up with a loop in the directory structure.
Could you please provide clarity on how lustre handles such situations? Your insights would be invaluable.
Thank you in advance for your time and assistance.
Warm regards,
Muhan Song

_______________________________________________
lustre-discuss mailing list
lustre-discuss at lists.lustre.org
http://lists.lustre.org/listinfo.cgi/lustre-discuss-lustre.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lustre.org/pipermail/lustre-discuss-lustre.org/attachments/20230816/b64d58ca/attachment.htm>


More information about the lustre-discuss mailing list