From: Miklos Szeredi <miklos@szeredi.hu>
To: Christoph Hellwig <hch@lst.de>
Cc: Matthew Wilcox <willy@infradead.org>,
Jens Axboe <axboe@kernel.dk>, Xiubo Li <xiubli@redhat.com>,
Ilya Dryomov <idryomov@gmail.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
"Theodore Ts'o" <tytso@mit.edu>, Jaegeuk Kim <jaegeuk@kernel.org>,
Chao Yu <chao@kernel.org>,
Andreas Gruenbacher <agruenba@redhat.com>,
"Darrick J. Wong" <djwong@kernel.org>,
Trond Myklebust <trond.myklebust@hammerspace.com>,
Anna Schumaker <anna@kernel.org>,
Damien Le Moal <dlemoal@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-block@vger.kernel.org, ceph-devel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
cluster-devel@redhat.com, linux-xfs@vger.kernel.org,
linux-nfs@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 09/11] fs: factor out a direct_write_fallback helper
Date: Wed, 24 May 2023 09:00:36 +0200 [thread overview]
Message-ID: <CAJfpeguT-LjhS-XrZwMystZqkxyB=HaON1zo-BTNOC0L1zCa1Q@mail.gmail.com> (raw)
In-Reply-To: <20230524063810.1595778-10-hch@lst.de>
On Wed, 24 May 2023 at 08:38, Christoph Hellwig <hch@lst.de> wrote:
>
> Add a helper dealing with handling the syncing of a buffered write fallback
> for direct I/O.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/libfs.c | 36 +++++++++++++++++++++++++
> include/linux/fs.h | 2 ++
> mm/filemap.c | 66 +++++++++++-----------------------------------
> 3 files changed, 53 insertions(+), 51 deletions(-)
>
> diff --git a/fs/libfs.c b/fs/libfs.c
> index 89cf614a327158..ad37a49e2ecfb7 100644
> --- a/fs/libfs.c
> +++ b/fs/libfs.c
> @@ -1613,3 +1613,39 @@ u64 inode_query_iversion(struct inode *inode)
> return cur >> I_VERSION_QUERIED_SHIFT;
> }
> EXPORT_SYMBOL(inode_query_iversion);
> +
> +ssize_t direct_write_fallback(struct kiocb *iocb, struct iov_iter *iter,
> + ssize_t direct_written, ssize_t buffered_written)
> +{
> + struct address_space *mapping = iocb->ki_filp->f_mapping;
> + loff_t pos = iocb->ki_pos - buffered_written;
> + loff_t end = iocb->ki_pos - 1;
> + int err;
> +
> + /*
> + * If the buffered write fallback returned an error, we want to return
> + * the number of bytes which were written by direct I/O, or the error
> + * code if that was zero.
> + *
> + * Note that this differs from normal direct-io semantics, which will
> + * return -EFOO even if some bytes were written.
> + */
> + if (unlikely(buffered_written < 0))
> + return buffered_written;
Comment/code mismatch. The comment says:
if (buffered_written < 0)
return direct_written ?: buffered_written;
> +
> + /*
> + * We need to ensure that the page cache pages are written to disk and
> + * invalidated to preserve the expected O_DIRECT semantics.
> + */
> + err = filemap_write_and_wait_range(mapping, pos, end);
> + if (err < 0) {
> + /*
> + * We don't know how much we wrote, so just return the number of
> + * bytes which were direct-written
> + */
> + return err;
Again comment/code mismatch.
Thanks,
Miklos
next prev parent reply other threads:[~2023-05-24 7:00 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-24 6:37 cleanup the filemap / direct I/O interaction v2 Christoph Hellwig
2023-05-24 6:38 ` [PATCH 01/11] backing_dev: remove current->backing_dev_info Christoph Hellwig
2023-05-24 14:50 ` Darrick J. Wong
2023-05-30 6:56 ` Hannes Reinecke
2023-05-24 6:38 ` [PATCH 02/11] iomap: update ki_pos a little later in iomap_dio_complete Christoph Hellwig
2023-05-30 6:57 ` Hannes Reinecke
2023-05-24 6:38 ` [PATCH 03/11] filemap: update ki_pos in generic_perform_write Christoph Hellwig
2023-05-30 6:57 ` Hannes Reinecke
2023-05-24 6:38 ` [PATCH 04/11] filemap: add a kiocb_write_and_wait helper Christoph Hellwig
2023-05-30 6:58 ` Hannes Reinecke
2023-05-24 6:38 ` [PATCH 05/11] filemap: add a kiocb_invalidate_pages helper Christoph Hellwig
2023-05-30 6:59 ` Hannes Reinecke
2023-05-24 6:38 ` [PATCH 06/11] filemap: add a kiocb_invalidate_post_direct_write helper Christoph Hellwig
2023-05-30 6:59 ` Hannes Reinecke
2023-05-24 6:38 ` [PATCH 07/11] iomap: update ki_pos in iomap_file_buffered_write Christoph Hellwig
2023-05-25 16:02 ` Andreas Gruenbacher
2023-05-30 7:00 ` Hannes Reinecke
2023-05-24 6:38 ` [PATCH 08/11] iomap: use kiocb_write_and_wait and kiocb_invalidate_pages Christoph Hellwig
2023-05-30 7:02 ` Hannes Reinecke
2023-05-24 6:38 ` [PATCH 09/11] fs: factor out a direct_write_fallback helper Christoph Hellwig
2023-05-24 7:00 ` Miklos Szeredi [this message]
2023-05-25 10:05 ` Christoph Hellwig
2023-05-30 7:03 ` Hannes Reinecke
2023-05-24 6:38 ` [PATCH 10/11] fuse: update ki_pos in fuse_perform_write Christoph Hellwig
2023-05-24 7:07 ` Miklos Szeredi
2023-05-25 10:09 ` Christoph Hellwig
2023-05-30 7:04 ` Hannes Reinecke
2023-05-24 6:38 ` [PATCH 11/11] fuse: drop redundant arguments to fuse_perform_write Christoph Hellwig
2023-05-24 7:09 ` Miklos Szeredi
2023-05-30 7:04 ` Hannes Reinecke
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='CAJfpeguT-LjhS-XrZwMystZqkxyB=HaON1zo-BTNOC0L1zCa1Q@mail.gmail.com' \
--to=miklos@szeredi.hu \
--cc=agruenba@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=anna@kernel.org \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=ceph-devel@vger.kernel.org \
--cc=chao@kernel.org \
--cc=cluster-devel@redhat.com \
--cc=djwong@kernel.org \
--cc=dlemoal@kernel.org \
--cc=hch@lst.de \
--cc=idryomov@gmail.com \
--cc=jaegeuk@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=trond.myklebust@hammerspace.com \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
--cc=xiubli@redhat.com \
/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