Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Goldwyn Rodrigues <rgoldwyn@suse.de>
Cc: linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org,
	darrick.wong@oracle.com, hch@infradead.org, nborisov@suse.com,
	Goldwyn Rodrigues <rgoldwyn@suse.com>
Subject: Re: [PATCH 1/2] iomap: Separate out generic_write_sync() from iomap_dio_complete()
Date: Wed, 16 Dec 2020 09:16:50 +1100	[thread overview]
Message-ID: <20201215221650.GR3913616@dread.disaster.area> (raw)
In-Reply-To: <f52d649dd35c616786b54ff7d76c6bcf95f9197e.1608053602.git.rgoldwyn@suse.com>

On Tue, Dec 15, 2020 at 12:06:35PM -0600, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
> 
> This introduces a separate function __iomap_dio_complte() which
> completes the Direct I/O without performing the write sync.
> 
> Filesystems such as btrfs which require an inode_lock for sync can call
> __iomap_dio_complete() and must perform sync on their own after unlock.
> 
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
> ---
>  fs/iomap/direct-io.c  | 16 +++++++++++++---
>  include/linux/iomap.h |  2 +-
>  2 files changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
> index 933f234d5bec..11a108f39fd9 100644
> --- a/fs/iomap/direct-io.c
> +++ b/fs/iomap/direct-io.c
> @@ -76,7 +76,7 @@ static void iomap_dio_submit_bio(struct iomap_dio *dio, struct iomap *iomap,
>  		dio->submit.cookie = submit_bio(bio);
>  }
>  
> -ssize_t iomap_dio_complete(struct iomap_dio *dio)
> +ssize_t __iomap_dio_complete(struct iomap_dio *dio)
>  {
>  	const struct iomap_dio_ops *dops = dio->dops;
>  	struct kiocb *iocb = dio->iocb;
> @@ -119,18 +119,28 @@ ssize_t iomap_dio_complete(struct iomap_dio *dio)
>  	}
>  
>  	inode_dio_end(file_inode(iocb->ki_filp));
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(__iomap_dio_complete);
> +
> +ssize_t iomap_dio_complete(struct iomap_dio *dio)
> +{
> +	ssize_t ret;
> +
> +	ret = __iomap_dio_complete(dio);
>  	/*
>  	 * If this is a DSYNC write, make sure we push it to stable storage now
>  	 * that we've written data.
>  	 */
>  	if (ret > 0 && (dio->flags & IOMAP_DIO_NEED_SYNC))
> -		ret = generic_write_sync(iocb, ret);
> +		ret = generic_write_sync(dio->iocb, ret);
>  
>  	kfree(dio);
>  
>  	return ret;
>  }
> -EXPORT_SYMBOL_GPL(iomap_dio_complete);
> +

NACK.

If you don't want iomap_dio_complete to do O_DSYNC work after
successfully writing data, strip those flags out of the kiocb
before you call iomap_dio_rw() and do it yourself after calling
iomap_dio_complete().

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

  parent reply	other threads:[~2020-12-15 22:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-15 18:06 [PATCH v2 0/2] Fix locking for btrfs direct writes Goldwyn Rodrigues
2020-12-15 18:06 ` [PATCH 1/2] iomap: Separate out generic_write_sync() from iomap_dio_complete() Goldwyn Rodrigues
2020-12-15 21:24   ` kernel test robot
2020-12-15 22:16   ` Dave Chinner [this message]
2020-12-15 18:06 ` [PATCH 2/2] btrfs: Make btrfs_direct_write atomic with respect to inode_lock Goldwyn Rodrigues
2020-12-15 22:13   ` Darrick J. Wong
2020-12-16 21:07     ` Goldwyn Rodrigues

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=20201215221650.GR3913616@dread.disaster.area \
    --to=david@fromorbit.com \
    --cc=darrick.wong@oracle.com \
    --cc=hch@infradead.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=nborisov@suse.com \
    --cc=rgoldwyn@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox