public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jann Horn <[email protected]>
To: Jens Axboe <[email protected]>
Cc: io-uring <[email protected]>
Subject: Re: [PATCH RFC] io_uring: improve current file position IO
Date: Mon, 3 Jan 2022 16:17:31 +0100	[thread overview]
Message-ID: <CAG48ez3ndoSC=fRvmzku1hLkO99RPwA3F3PA5mVZ47AkU5q-5A@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>

On Fri, Dec 24, 2021 at 3:35 PM Jens Axboe <[email protected]> wrote:
> io_uring should be protecting the current file position with the
> file position lock, ->f_pos_lock. Grab and track the lock state when
> the request is being issued, and make the unlock part of request
> cleaning.
>
> Fixes: ba04291eb66e ("io_uring: allow use of offset == -1 to mean file position")
> Reported-by: Linus Torvalds <[email protected]>
> Signed-off-by: Jens Axboe <[email protected]>
>
> ---
>
> Main thing I don't like here:
>
> - We're holding the f_pos_lock across the kernel/user boundary, as
>   it's held for the duration of the IO. Alternatively we could
>   keep it local to io_read() and io_write() and lose REQ_F_CUR_POS_LOCK,
>   but will messy up those functions more and add more items to the
>   fast path (which current position read/write definitely is not).
>
> Suggestions welcome...

Oh, that's not pretty... is it guaranteed that the
__f_unlock_pos(req->file) will happen in the same task as the
io_file_pos_lock(req, false), and have you tried running this with
lockdep and mutex debugging enabled? Could a task deadlock if it tried
to do a read() on a file while io_uring is already holding the
position lock?

  reply	other threads:[~2022-01-03 15:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-24 14:35 [PATCH RFC] io_uring: improve current file position IO Jens Axboe
2022-01-03 15:17 ` Jann Horn [this message]
2022-01-03 15:22   ` Jens Axboe

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='CAG48ez3ndoSC=fRvmzku1hLkO99RPwA3F3PA5mVZ47AkU5q-5A@mail.gmail.com' \
    [email protected] \
    [email protected] \
    [email protected] \
    /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