linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: NeilBrown <neilb@suse.de>
Cc: Miklos Szeredi <mszeredi@redhat.com>,
	Xavier Roche <xavier.roche@algolia.com>,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v2] vfs: fix link vs. rename race
Date: Wed, 14 Sep 2022 01:13:31 +0100	[thread overview]
Message-ID: <YyEcqxthoso9SGI2@ZenIV> (raw)
In-Reply-To: <166311315747.20483.5039023553379547679@noble.neil.brown.name>

On Wed, Sep 14, 2022 at 09:52:37AM +1000, NeilBrown wrote:
>  - lookup the parents of both paths.
>  - lock the "to" directory.
>  - if the "from" directory is the same, or if a trylock of the from
>    directory succeeds, then we have the locks and can perform the
>    last component lookup and perform the link without racing with
>    rename. 
>  - if the trylock fails, we drop the lock on "to" and use lock_rename().
>    We drop the s_vfs_rename_mutex immediately after lock_rename()
>    so after the vfs_link() we just unlock both parent directories.

Umm...  Care to put together an update of deadlock avoidance proof?
The one in D/f/directory-locking.rst, that is.  I'm not saying it's
not a usable approach - it might very well work...

BTW, one testcase worth profiling would be something like
for i in `seq 100`; do
	cp -al linux.git linux.git-$i &
done

  reply	other threads:[~2022-09-14  0:13 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-21  8:20 [PATCH v2] vfs: fix link vs. rename race Miklos Szeredi
2022-02-21  8:56 ` Xavier Roche
2022-09-13  2:04 ` Al Viro
2022-09-13  4:29   ` Al Viro
2022-09-13  8:02     ` Amir Goldstein
2022-09-13 10:03       ` Miklos Szeredi
2022-09-13  4:41 ` NeilBrown
2022-09-13  5:20   ` Al Viro
2022-09-13  5:40     ` Al Viro
2022-09-14  0:14       ` NeilBrown
2022-09-14  1:30         ` Al Viro
2022-09-13 23:52     ` NeilBrown
2022-09-14  0:13       ` Al Viro [this message]
2022-09-16  6:13         ` [PATCH RFC] VFS: lock source directory for link to avoid " NeilBrown
2022-09-16  6:28           ` Miklos Szeredi
2022-09-16  6:45             ` NeilBrown
2022-09-16  6:49             ` Al Viro
2022-09-16 14:32           ` Amir Goldstein
2022-09-19  8:28             ` Christian Brauner
2022-09-19 22:56               ` NeilBrown
2022-09-23  3:02           ` [VFS] 3fb4ec6faa: ltp.linkat02.fail kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YyEcqxthoso9SGI2@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mszeredi@redhat.com \
    --cc=neilb@suse.de \
    --cc=xavier.roche@algolia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).