From: Dave Chinner <david@fromorbit.com>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Jens Axboe <axboe@kernel.dk>,
Goldwyn Rodrigues <rgoldwyn@suse.de>
Subject: Re: Correctness of inode_dio_end in generic DIO code
Date: Wed, 21 Feb 2018 07:47:56 +1100 [thread overview]
Message-ID: <20180220204756.GA7000@dastard> (raw)
In-Reply-To: <d9c0c106-3d2f-0184-6f69-a4502d6c56c1@suse.com>
On Tue, Feb 20, 2018 at 10:59:46AM +0200, Nikolay Borisov wrote:
> Hello,
>
> Currently the generic DIO code calls inode_dio_begin/inode_dio_end if
> DIO_SKIP_DIO_COUNT is not set.
DIO_SKIP_DIO_COUNT is not used by anyone. It's dead code, so
probably should be removed.
> However, te generic ode doesn't really
> know if there is a lock synchronizing all the various inode_dio_*
> operations. As per inode_dio_wait comment :
>
> Must be called under a lock that serializes taking new references to
> i_dio_count, usually by inode->i_mutex.
Yup. DIO_LOCKING fileystems all use inode->i_rwsem. Filesystems that
don't use DIO_LOCKING need to provide their own locking.
Locking for DIO submission is all explained in the comment above
do_blockdev_direct_IO(). inode_dio_begin() is covered by the IO
submission locking scheme...
> So is it at all correct to increment i_dio_count in generic dio code
> without imposing strict locking requirement?
Most filesystems call blockdev_direct_IO() which sets DIO_LOCKING.
> Currently, most major
> filesystems (Ext4/xfs/btrfs) do modify i_dio_count under their own
> locks.
Sort of.
Both btrfs and ext4 use DIO_LOCKING directly, except in certain
configs ext4 doesn't do any locking at all.
XFS uses it's "own locking", but that's actually inode->i_rwsem now,
Also, XFS also uses iomap_dio_rw(), which is a new, more efficient
direct IO code path with a separate call to inode_dio_begin() under
"caller must lock IO submission" rules....
> Perhaps it's best if i_dio_count modification are removed from
> the generic code, what do people think about that?
IMO, it's in the correct spot - it's always accounted and called
under the correct IO submission locks where it is. Removing it from
the generic code will simply introduce bugs in new/lesser travelled
filesystems where they forget to call it or call it incorrectly.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
prev parent reply other threads:[~2018-02-20 20:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-20 8:59 Correctness of inode_dio_end in generic DIO code Nikolay Borisov
2018-02-20 13:55 ` Jan Kara
2018-02-20 20:47 ` Dave Chinner [this message]
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=20180220204756.GA7000@dastard \
--to=david@fromorbit.com \
--cc=axboe@kernel.dk \
--cc=linux-fsdevel@vger.kernel.org \
--cc=nborisov@suse.com \
--cc=rgoldwyn@suse.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.