From: Theodore Dubois <tblodt@icloud.com>
To: Theodore Dubois <tblodt@icloud.com>
Cc: linux-man@vger.kernel.org, kernelnewbies@kernelnewbies.org
Subject: edge case posix file lock deadlock detection
Date: Wed, 30 Jan 2019 19:31:10 -0800 [thread overview]
Message-ID: <8E383B31-AB1C-449E-8AC4-DE20228CA8FF@icloud.com> (raw)
I'm having trouble figuring out how the kernel handles a particular case in deadlock detection on posix file locks. Here's the scenario:
PID 1: locks byte 2
PID 3: locks byte 0
PID 2: locks byte 10
PID 1: locks byte 10
PID 2: locks bytes 0-2 inclusive
The last step fails with EDEADLK, but I'm not sure how that is detected. The specified range conflicts with two different locks, and the first loop in posix_lock_inode would find whichever one comes first in the linked list, and pass that to the deadlock detector.
If the lock on byte 2 comes first in the list, a cycle would be found between the lock on byte 2 and the lock on byte 10. But if the lock on byte 0 comes first, the deadlock detector would return NULL from what_owner_is_waiting_for on that lock since PID 3 has no other locks, and immediately succeed.
What am I missing?
Thanks,
~Theodore
reply other threads:[~2019-01-31 3:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=8E383B31-AB1C-449E-8AC4-DE20228CA8FF@icloud.com \
--to=tblodt@icloud.com \
--cc=kernelnewbies@kernelnewbies.org \
--cc=linux-man@vger.kernel.org \
/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).