[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250208013814.GP1977892@ZenIV>
Date: Sat, 8 Feb 2025 01:38:14 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: NeilBrown <neilb@...e.de>
Cc: Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Jeff Layton <jlayton@...nel.org>,
Dave Chinner <david@...morbit.com>, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 11/19] VFS: Add ability to exclusively lock a dentry and
use for create/remove operations.
On Thu, Feb 06, 2025 at 04:42:48PM +1100, NeilBrown wrote:
> d_update_lock(), d_update_trylock(), d_update_unlock() are added which
> can be used to get an exclusive lock on a dentry in preparation for
> updating it.
>
> As contention on a name is rare this is optimised for the uncontended
> case. A bit is set under the d_lock spinlock to claim as lock, and
> wait_var_event_spinlock() is used when waiting is needed. To avoid
> sending a wakeup when not needed we have a second bit flag to indicate
> if there are any waiters.
>
> This locking is used in lookup_and_lock().
>
> Once the exclusive "update" lock is obtained on the dentry we must make
> sure it wasn't unlinked or renamed while we slept. If it was we repeat
> the lookup.
>
> We also ensure that the parent isn't similarly locked. This is will be
> used to protect a directory during rmdir.
What's the point re rmdir()? Just have the victim _always_ locked exclusive,
same as e.g. for ->unlink() or overwriting ->rename().
Powered by blists - more mailing lists