* Correctness of inode_dio_end in generic DIO code
@ 2018-02-20 8:59 Nikolay Borisov
2018-02-20 13:55 ` Jan Kara
2018-02-20 20:47 ` Dave Chinner
0 siblings, 2 replies; 3+ messages in thread
From: Nikolay Borisov @ 2018-02-20 8:59 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Jens Axboe, Goldwyn Rodrigues
Hello,
Currently the generic DIO code calls inode_dio_begin/inode_dio_end if
DIO_SKIP_DIO_COUNT is not set. 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.
So is it at all correct to increment i_dio_count in generic dio code
without imposing strict locking requirement? Currently, most major
filesystems (Ext4/xfs/btrfs) do modify i_dio_count under their own
locks. Perhaps it's best if i_dio_count modification are removed from
the generic code, what do people think about that?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Correctness of inode_dio_end in generic DIO code
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
1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2018-02-20 13:55 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: linux-fsdevel, Jens Axboe, Goldwyn Rodrigues
Hello,
On Tue 20-02-18 10:59:46, Nikolay Borisov wrote:
> Currently the generic DIO code calls inode_dio_begin/inode_dio_end if
> DIO_SKIP_DIO_COUNT is not set. 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.
>
> So is it at all correct to increment i_dio_count in generic dio code
> without imposing strict locking requirement? Currently, most major
> filesystems (Ext4/xfs/btrfs) do modify i_dio_count under their own
> locks. Perhaps it's best if i_dio_count modification are removed from
> the generic code, what do people think about that?
Currently the onus is on inode_dio_wait() callers to make sure they cannot
livelock (usually by calling that function in a context which blocks
submission of new direct IO). So in this sense I don't see anything wrong
with calling inode_dio_begin() from do_blockdev_direct_IO(). Whether
calling these functions directly from fs code instead of from
do_blockdev_direct_IO() to make things clearer is worth the additional
code in quite a few filesystems is IMHO a matter of taste. I'm fine with
the current state but then I admit I might have just got used to it :)
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Correctness of inode_dio_end in generic DIO code
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
1 sibling, 0 replies; 3+ messages in thread
From: Dave Chinner @ 2018-02-20 20:47 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: linux-fsdevel, Jens Axboe, Goldwyn Rodrigues
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-20 20:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).