From: Al Viro <viro@zeniv.linux.org.uk>
To: Mo Zou <lostzoumo@gmail.com>
Cc: brauner@kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] Documentation: fs: fix directory locking proofs
Date: Wed, 11 Oct 2023 20:06:38 +0100 [thread overview]
Message-ID: <20231011190638.GV800259@ZenIV> (raw)
In-Reply-To: <CAHfrynPiUWiB0Vg3-pTi_yC6cER0wYMmCo_V8HZyWAD5Q_m+jQ@mail.gmail.com>
On Wed, Oct 11, 2023 at 10:11:42PM +0800, Mo Zou wrote:
>
> Consider directories objects A, B, C. The pointer orders are that A < B
> and C < A. And B is ancestor to C, so B < C. Thus we have A < B < C
> < A!
>
> A concrete deadlock example can be constructed as follows. Suppose
> the tree has following edges /A and /B/C and A < B and C < A. There are
> three operations forming a deadlock.
>
> rename(/A, /B) executes: lock /; lock A; (about to lock B)
> unlink(/B/C) executes: lock B; (about to lock C)
> rename(/A/x, /C/y) executes: lock C; (about to lock A)
Nope - your C in line 2 is not C in line 3.
There *IS* a deadlock, but it's more subtle than that.
Look:
# address(/X/A) < address(C) < address(X)
T_1: rename /C/D /X/A/B
T_2: exchange /X /C
T_3: rmdir /X/A
T_1: looked up /X/A and /C (all in dcache)
T_2: looked up /
T_3: looked up /X
T_1: grabbed ->s_vfs_rename_mutex
T_1: grabbed /X/A
T_2: grabbed /
T_2: grabbed /C
T_3: grabbed /X
T_2: tries to grab /X
T_3: tries to grab /X/A
T_1: tries to grab /C
prev parent reply other threads:[~2023-10-11 19:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-11 5:28 [PATCH] Documentation: fs: fix directory locking proofs Mo Zou
2023-10-11 6:46 ` Al Viro
2023-10-11 14:11 ` Mo Zou
2023-10-11 19:06 ` Al Viro [this message]
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=20231011190638.GV800259@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=lostzoumo@gmail.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).