From: Jeff Layton <jlayton@kernel.org>
To: stsp <stsp2@yandex.ru>, Christian Brauner <brauner@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Chuck Lever <chuck.lever@oracle.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org,
Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH 2/3] fd/locks: allow get the lock owner by F_OFD_GETLK
Date: Tue, 27 Jun 2023 12:00:42 -0400 [thread overview]
Message-ID: <51e756daf978ba61fbc15f209effac5daf59137a.camel@kernel.org> (raw)
In-Reply-To: <0697f0d1-490b-6613-fea0-967a40861b25@yandex.ru>
On Fri, 2023-06-23 at 22:18 +0500, stsp wrote:
> 23.06.2023 20:25, Christian Brauner пишет:
> > On Wed, Jun 21, 2023 at 07:05:12AM -0400, Jeff Layton wrote:
> > > On Wed, 2023-06-21 at 15:42 +0500, stsp wrote:
> > > > 21.06.2023 15:35, Jeff Layton пишет:
> > > > > I don't think we can change this at this point.
> > > > >
> > > > > The bottom line (again) is that OFD locks are owned by the file
> > > > > descriptor (much like with flock()), and since file descriptors can be
> > > > > shared across multiple process it's impossible to say that some single
> > > > > process owns it.
> > > > What's the problem with 2 owners?
> > > > Can't you get one of them, rather than
> > > > meaningless -1?
> > > > Compare this situation with read locks.
> > > > They can overlap, so when you get an
> > > > info about a read lock (except for the
> > > > new F_UNLCK case), you get the info
> > > > about *some* of the locks in that range.
> > > > In the case of multiple owners, you
> > > > likewise get the info about about some
> > > > owner. If you iteratively send them a
> > > > "please release this lock" message
> > > > (eg in a form of SIGKILL), then you
> > > > traverse all, and end up with the
> > > > lock-free area.
> > > > Is there really any problem here?
> > > Yes. Ambiguous answers are worse than none at all.
> > I agree.
> >
> > A few minor observations:
> >
> > SCM_RIGHTS have already been mentioned multiple times. But I'm not sure
> > it's been mentioned explicitly but that trivially means it's possible to
> > send an fd to a completely separate thread-group, then kill off the
> > sending thread-group by killing their thread-group leader. Bad enough as
> > the identifier is now useless. But it also means that at some later
> > point that pid can be recycled.
> Come on.
> I never proposed anything like this.
> Of course the returned pid should be
> the pid of the current, actual owner,
> or one of current owners.
> If someone else proposed to return
> stalled pids, then it wasn't me.
Beyond all of this, there is a long history of problems with the l_pid
field as well with network filesystems, even with traditional POSIX
locks. What should go into the l_pid when a traditional POSIX lock is
held by a process on a separate host?
While POSIX mandates it, the l_pid is really sort of a "legacy" field
that is really just for informational purposes only nowadays. It might
have been a reliable bit of information back in the 1980's, but even
since the 90's it was suspect as a source of information.
Even if you _know_ you hold a traditional POSIX lock, be careful
trusting the information in that field.
--
Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2023-06-27 16:00 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-20 9:55 [PATCH 0/3] RFC: F_OFD_GETLK should provide more info Stas Sergeev
2023-06-20 9:55 ` [PATCH 1/3] fs/locks: F_UNLCK extension for F_OFD_GETLK Stas Sergeev
2023-06-20 10:46 ` Jeff Layton
2023-06-20 11:00 ` stsp
2023-06-20 11:15 ` Jeff Layton
2023-06-21 15:24 ` stsp
2023-06-20 9:55 ` [PATCH 2/3] fd/locks: allow get the lock owner by F_OFD_GETLK Stas Sergeev
2023-06-20 10:51 ` Jeff Layton
2023-06-20 10:57 ` stsp
2023-06-20 11:12 ` Jeff Layton
2023-06-20 11:45 ` stsp
2023-06-20 12:02 ` Jeff Layton
2023-06-20 12:34 ` stsp
2023-06-20 13:19 ` Jeff Layton
2023-06-20 13:39 ` stsp
2023-06-20 13:46 ` Matthew Wilcox
2023-06-20 13:47 ` stsp
2023-06-20 14:36 ` Matthew Wilcox
2023-06-20 15:45 ` stsp
2023-06-20 17:05 ` Matthew Wilcox
2023-06-21 2:54 ` stsp
2023-06-23 13:10 ` David Laight
2023-06-20 13:58 ` Jeff Layton
2023-06-21 6:57 ` stsp
2023-06-21 10:35 ` Jeff Layton
2023-06-21 10:42 ` stsp
2023-06-21 11:05 ` Jeff Layton
2023-06-21 11:22 ` stsp
2023-06-21 11:26 ` stsp
2023-06-23 15:25 ` Christian Brauner
2023-06-23 17:18 ` stsp
2023-06-27 16:00 ` Jeff Layton [this message]
2023-06-27 16:20 ` stsp
2023-06-20 9:55 ` [PATCH 3/3] selftests: add OFD lock tests Stas Sergeev
2023-06-20 11:06 ` Jeff Layton
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=51e756daf978ba61fbc15f209effac5daf59137a.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=brauner@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stsp2@yandex.ru \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.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).