From: Jens Axboe <axboe@kernel.dk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Christian Brauner <brauner@kernel.org>,
Christoph Hellwig <hch@lst.de>, Aleksa Sarai <cyphar@cyphar.com>,
Al Viro <viro@zeniv.linux.org.uk>,
Seth Forshee <sforshee@kernel.org>,
linux-fsdevel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] file: always lock position
Date: Tue, 25 Jul 2023 14:58:07 -0600 [thread overview]
Message-ID: <88806a9b-6b3f-1451-ee55-df7da9445a59@kernel.dk> (raw)
In-Reply-To: <CAHk-=whMEd2J5otKf76zuO831sXi4OtgyBTozq_wE43q92=EiQ@mail.gmail.com>
On 7/25/23 2:51?PM, Linus Torvalds wrote:
> On Tue, 25 Jul 2023 at 13:41, Jens Axboe <axboe@kernel.dk> wrote:
>>
>> Right, but what if the original app closes the file descriptor? Now you
>> have the io_uring file table still holding a reference to it, but it'd
>> just be 1. Which is enough to keep it alive, but you can still have
>> multiple IOs inflight against this file.
>
> Note that fdget_pos() fundamentally only works on file descriptors
> that are there - it's literally looking them up in the file table as
> it goes along. And it looks at the count of the file description as it
> is looked up. So that refcount is guaranteed to exist.
>
> If the file has been closed, fdget_pos() will just fail because it
> doesn't find it.
>
> And if it's then closed *afterwards*, that's fine and doesn't affect
> anything, because the locking has been done and we saved away the
> status bit as FDPUT_POS_UNLOCK, so the code knows to unlock even if
> the file descriptor in the meantime has turned back to having just a
> single refcount.
Ah yes good point. If registered with io_uring and closed, then it won't
matter how many extra references we hold or grab in the future, it won't
be found in the file table. I guess that's obvious...
--
Jens Axboe
next prev parent reply other threads:[~2023-07-25 20:58 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-24 15:00 [PATCH] file: always lock position Christian Brauner
2023-07-24 15:53 ` Linus Torvalds
2023-07-24 16:19 ` Christian Brauner
2023-07-24 16:36 ` Linus Torvalds
2023-07-24 16:51 ` Linus Torvalds
2023-09-02 4:44 ` Al Viro
2023-07-24 17:23 ` Christian Brauner
2023-07-24 17:34 ` Linus Torvalds
2023-07-24 17:46 ` Christian Brauner
2023-07-24 18:01 ` Linus Torvalds
2023-07-24 18:05 ` Jens Axboe
2023-07-24 18:27 ` Linus Torvalds
2023-07-24 18:48 ` Christian Brauner
2023-07-24 22:25 ` Linus Torvalds
2023-07-24 22:56 ` Jens Axboe
2023-07-25 18:30 ` Linus Torvalds
2023-07-25 20:41 ` Jens Axboe
2023-07-25 20:51 ` Linus Torvalds
2023-07-25 20:58 ` Jens Axboe [this message]
2023-07-26 8:36 ` Christian Brauner
2023-07-26 10:31 ` David Laight
2023-07-26 12:53 ` Christian Brauner
2023-07-26 8:07 ` Christian Brauner
2023-07-24 16:46 ` Christian Brauner
2023-07-24 16:59 ` Linus Torvalds
2023-07-24 17:18 ` Linus Torvalds
2023-08-03 9:53 ` Mateusz Guzik
2023-08-03 14:15 ` Christian Brauner
2023-08-03 15:17 ` Mateusz Guzik
2023-08-03 15:18 ` Mateusz Guzik
2023-08-03 15:45 ` Linus Torvalds
2023-08-03 17:54 ` Mateusz Guzik
2023-08-03 18:02 ` Christian Brauner
2023-08-03 18:35 ` Linus Torvalds
2023-08-04 13:43 ` Christian Brauner
2023-08-04 13:59 ` Christoph Hellwig
2023-09-02 3:43 ` Al Viro
[not found] <20230804-turnverein-helfer-ef07a4d7bbec@brauner>
2023-08-05 11:46 ` Christian Brauner
2023-08-05 18:47 ` Linus Torvalds
2023-08-05 19:46 ` Linus Torvalds
2023-08-06 6:10 ` Christian Brauner
2023-08-06 13:25 ` Christian Brauner
2023-08-06 17:48 ` Linus Torvalds
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=88806a9b-6b3f-1451-ee55-df7da9445a59@kernel.dk \
--to=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=cyphar@cyphar.com \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=sforshee@kernel.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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