Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Josef Bacik <josef@toxicpanda.com>
Cc: Goldwyn Rodrigues <rgoldwyn@suse.de>,
linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org,
david@fromorbit.com, hch@lst.de, johannes.thumshirn@wdc.com,
dsterba@suse.com, Goldwyn Rodrigues <rgoldwyn@suse.com>
Subject: Re: [PATCH 04/15] iomap: Call inode_dio_end() before generic_write_sync()
Date: Tue, 22 Sep 2020 09:31:56 -0700 [thread overview]
Message-ID: <20200922163156.GD7949@magnolia> (raw)
In-Reply-To: <20bf949a-7237-8409-4230-cddb430026a9@toxicpanda.com>
On Tue, Sep 22, 2020 at 10:20:11AM -0400, Josef Bacik wrote:
> On 9/21/20 10:43 AM, Goldwyn Rodrigues wrote:
> > From: Goldwyn Rodrigues <rgoldwyn@suse.com>
> >
> > iomap complete routine can deadlock with btrfs_fallocate because of the
> > call to generic_write_sync().
> >
> > P0 P1
> > inode_lock() fallocate(FALLOC_FL_ZERO_RANGE)
> > __iomap_dio_rw() inode_lock()
> > <block>
> > <submits IO>
> > <completes IO>
> > inode_unlock()
> > <gets inode_lock()>
> > inode_dio_wait()
> > iomap_dio_complete()
> > generic_write_sync()
> > btrfs_file_fsync()
> > inode_lock()
> > <deadlock>
> >
> > inode_dio_end() is used to notify the end of DIO data in order
> > to synchronize with truncate. Call inode_dio_end() before calling
> > generic_write_sync(), so filesystems can lock i_rwsem during a sync.
> >
> > ---
> > fs/iomap/direct-io.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
> > index d970c6bbbe11..e01f81e7b76f 100644
> > --- a/fs/iomap/direct-io.c
> > +++ b/fs/iomap/direct-io.c
> > @@ -118,6 +118,7 @@ ssize_t iomap_dio_complete(struct iomap_dio *dio)
> > dio_warn_stale_pagecache(iocb->ki_filp);
> > }
> > + inode_dio_end(file_inode(iocb->ki_filp));
> > /*
> > * If this is a DSYNC write, make sure we push it to stable storage now
> > * that we've written data.
> > @@ -125,7 +126,6 @@ ssize_t iomap_dio_complete(struct iomap_dio *dio)
> > if (ret > 0 && (dio->flags & IOMAP_DIO_NEED_SYNC))
> > ret = generic_write_sync(iocb, ret);
> > - inode_dio_end(file_inode(iocb->ki_filp));
> > kfree(dio);
> > return ret;
> >
>
> Did you verify that xfs or ext4 don't rely on the inode_dio_end() happening
> before the generic_write_sync()? I wouldn't expect that they would, but
> we've already run into problems making those kind of assumptions. If it's
> fine you can add
I was gonna ask the same question, but as there's no SoB on this patch I
hadn't really looked at it yet. ;)
Operations that rely on inode_dio_wait to have blocked until all the
directios are complete could get tripped up by iomap not having done the
generic_write_sync to stabilise the metadata, but I /think/ most
operations that do that also themselves flush the file. But I don't
really know if there's a subtlety there if the inode_dio_wait thread
manages to grab the ILOCK before the generic_write_sync thread does.
--D
> Reviewed-by: Josef Bacik <josef@toxicpanda.com>
>
> Thanks,
>
> Josef
next prev parent reply other threads:[~2020-09-22 16:32 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-21 14:43 [PATCH 0/15 v2] BTRFS DIO inode locking/D_SYNC fix Goldwyn Rodrigues
2020-09-21 14:43 ` [PATCH 01/15] fs: remove dio_end_io() Goldwyn Rodrigues
2020-09-22 14:17 ` Josef Bacik
2020-09-21 14:43 ` [PATCH 02/15] btrfs: remove BTRFS_INODE_READDIO_NEED_LOCK Goldwyn Rodrigues
2020-09-22 13:18 ` Christoph Hellwig
2020-09-22 14:17 ` Josef Bacik
2020-09-21 14:43 ` [PATCH 03/15] iomap: Allow filesystem to call iomap_dio_complete without i_rwsem Goldwyn Rodrigues
2020-09-21 15:09 ` Johannes Thumshirn
2020-09-22 13:19 ` hch
2020-09-22 14:17 ` Josef Bacik
2020-09-21 14:43 ` [PATCH 04/15] iomap: Call inode_dio_end() before generic_write_sync() Goldwyn Rodrigues
2020-09-21 15:11 ` Johannes Thumshirn
2020-09-22 13:21 ` Christoph Hellwig
2020-09-22 14:20 ` Josef Bacik
2020-09-22 16:31 ` Darrick J. Wong [this message]
2020-09-22 17:25 ` Goldwyn Rodrigues
2020-09-22 21:49 ` Dave Chinner
2020-09-23 5:16 ` Christoph Hellwig
2020-09-23 5:31 ` Darrick J. Wong
2020-09-23 5:49 ` Christoph Hellwig
2020-09-23 5:59 ` Dave Chinner
2020-09-21 14:43 ` [PATCH 05/15] btrfs: split btrfs_direct_IO to read and write Goldwyn Rodrigues
2020-09-22 13:22 ` Christoph Hellwig
2020-09-22 14:27 ` Josef Bacik
2020-09-21 14:43 ` [PATCH 06/15] btrfs: Move pos increment and pagecache extension to btrfs_buffered_write() Goldwyn Rodrigues
2020-09-22 13:22 ` Christoph Hellwig
2020-09-22 14:30 ` Josef Bacik
2020-09-21 14:43 ` [PATCH 07/15] btrfs: Move FS error state bit early during write Goldwyn Rodrigues
2020-09-22 14:38 ` Josef Bacik
2020-09-23 9:10 ` Nikolay Borisov
2020-09-23 14:07 ` Goldwyn Rodrigues
2020-09-21 14:43 ` [PATCH 08/15] btrfs: Introduce btrfs_write_check() Goldwyn Rodrigues
2020-09-22 13:26 ` Christoph Hellwig
2020-09-22 14:42 ` Josef Bacik
2020-09-21 14:43 ` [PATCH 09/15] btrfs: Introduce btrfs_inode_lock()/unlock() Goldwyn Rodrigues
2020-09-22 14:45 ` Josef Bacik
2020-09-21 14:43 ` [PATCH 10/15] btrfs: Push inode locking and unlocking into buffered/direct write Goldwyn Rodrigues
2020-09-22 14:48 ` Josef Bacik
2020-09-21 14:43 ` [PATCH 11/15] btrfs: Use inode_lock_shared() for direct writes within EOF Goldwyn Rodrigues
2020-09-22 14:52 ` Josef Bacik
2020-09-22 17:33 ` Goldwyn Rodrigues
2020-09-21 14:43 ` [PATCH 12/15] btrfs: Remove dio_sem Goldwyn Rodrigues
2020-09-22 14:52 ` Josef Bacik
2020-09-21 14:43 ` [PATCH 13/15] btrfs: Call iomap_dio_complete() without inode_lock Goldwyn Rodrigues
2020-09-22 15:11 ` Josef Bacik
2020-09-21 14:43 ` [PATCH 14/15] btrfs: Revert 09745ff88d93 ("btrfs: dio iomap DSYNC workaround") Goldwyn Rodrigues
2020-09-22 15:12 ` Josef Bacik
2020-09-21 14:43 ` [PATCH 15/15] iomap: Reinstate lockdep_assert_held in iomap_dio_rw() Goldwyn Rodrigues
2020-09-22 13:26 ` Christoph Hellwig
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=20200922163156.GD7949@magnolia \
--to=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=dsterba@suse.com \
--cc=hch@lst.de \
--cc=johannes.thumshirn@wdc.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=rgoldwyn@suse.com \
--cc=rgoldwyn@suse.de \
--subject='Re: [PATCH 04/15] iomap: Call inode_dio_end() before generic_write_sync()' \
/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
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).