[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZJHcT9DPGWVlTsHg@casper.infradead.org>
Date: Tue, 20 Jun 2023 18:05:19 +0100
From: Matthew Wilcox <willy@...radead.org>
To: stsp <stsp2@...dex.ru>
Cc: Jeff Layton <jlayton@...nel.org>, linux-kernel@...r.kernel.org,
Chuck Lever <chuck.lever@...cle.com>,
Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>,
linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH 2/3] fd/locks: allow get the lock owner by F_OFD_GETLK
On Tue, Jun 20, 2023 at 08:45:21PM +0500, stsp wrote:
>
> 20.06.2023 19:36, Matthew Wilcox пишет:
> > On Tue, Jun 20, 2023 at 06:47:31PM +0500, stsp wrote:
> > > 20.06.2023 18:46, Matthew Wilcox пишет:
> > > > On Tue, Jun 20, 2023 at 06:39:07PM +0500, stsp wrote:
> > > > > Though it will, for sure, represent the
> > > > > task that _owns_ the lock.
> > > > No, it *DOESN'T*. I can open a file, SCM_RIGHTS pass it to another task
> > > > and then exit. Now the only owner of that lock is the recipient ...
> > > Won't I get the recipient's pid in an
> > > l_pid then?
> > You snipped the part where I pointed out that at times there can be
> > _no_ task that owns it. open a fd, set the lock, pass the fd to another
> > task, exit. until that task calls recvmsg(), no task owns it.
> Hmm, interesting case.
> So at least it seems if recipient also exits,
> then the untransferred fd gets closed.
yes, pretty sure this is done by garbage collection in the unix socket
handling code, though i've never looked at it. it's done that way
because annoying people can do things like open two sockets and send the
fd of each to the other, then exit.
> Does this mean, by any chance, that the
> recipient actually owns an fd before
> recvmsg() is done?
no, it's not in their fd table. they don't own it.
Powered by blists - more mailing lists