From: Christoph Hellwig <hch@lst.de>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 13/13] fuse: use direct_write_fallback
Date: Fri, 19 May 2023 11:35:21 +0200 [thread overview]
Message-ID: <20230519093521.133226-14-hch@lst.de> (raw)
In-Reply-To: <20230519093521.133226-1-hch@lst.de>
Use the generic direct_write_fallback helper instead of duplicating the
logic.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/fuse/file.c | 27 +++------------------------
1 file changed, 3 insertions(+), 24 deletions(-)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 5f7b58798f99fc..02ab446ab57f1f 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1340,11 +1340,9 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from)
struct file *file = iocb->ki_filp;
struct address_space *mapping = file->f_mapping;
ssize_t written = 0;
- ssize_t written_buffered = 0;
struct inode *inode = mapping->host;
ssize_t err;
struct fuse_conn *fc = get_fuse_conn(inode);
- loff_t endbyte = 0;
if (fc->writeback_cache) {
/* Update size (EOF optimization) and mode (SUID clearing) */
@@ -1382,28 +1380,9 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from)
if (iocb->ki_flags & IOCB_DIRECT) {
written = generic_file_direct_write(iocb, from);
- if (written < 0 || !iov_iter_count(from))
- goto out;
-
- written_buffered = fuse_perform_write(iocb, from);
- if (written_buffered < 0) {
- err = written_buffered;
- goto out;
- }
- endbyte = iocb->ki_pos + written_buffered - 1;
-
- err = filemap_write_and_wait_range(file->f_mapping,
- iocb->ki_pos,
- endbyte);
- if (err)
- goto out;
-
- invalidate_mapping_pages(file->f_mapping,
- iocb->ki_pos >> PAGE_SHIFT,
- endbyte >> PAGE_SHIFT);
-
- written += written_buffered;
- iocb->ki_pos += written_buffered;
+ if (written >= 0 && iov_iter_count(from))
+ written = direct_write_fallback(iocb, from, written,
+ fuse_perform_write(iocb, from));
} else {
written = fuse_perform_write(iocb, from);
}
--
2.39.2
next prev parent reply other threads:[~2023-05-19 9:35 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-19 9:35 [Cluster-devel] cleanup the filemap / direct I/O interaction Christoph Hellwig
2023-05-19 9:35 ` [Cluster-devel] [PATCH 01/13] iomap: update ki_pos a little later in iomap_dio_complete Christoph Hellwig
2023-05-21 23:40 ` Damien Le Moal
2023-07-06 0:18 ` [Cluster-devel] [f2fs-dev] " patchwork-bot+f2fs
2023-05-19 9:35 ` [Cluster-devel] [PATCH 02/13] filemap: update ki_pos in generic_perform_write Christoph Hellwig
2023-05-21 23:42 ` Damien Le Moal
2023-05-22 2:20 ` Xiubo Li
2023-05-19 9:35 ` [Cluster-devel] [PATCH 03/13] filemap: assign current->backing_dev_info " Christoph Hellwig
2023-05-21 23:44 ` Damien Le Moal
2023-05-22 2:22 ` Xiubo Li
2023-05-19 9:35 ` [Cluster-devel] [PATCH 04/13] filemap: add a kiocb_write_and_wait helper Christoph Hellwig
2023-05-21 23:46 ` Damien Le Moal
2023-05-19 9:35 ` [Cluster-devel] [PATCH 05/13] filemap: add a kiocb_invalidate_pages helper Christoph Hellwig
2023-05-21 23:51 ` Damien Le Moal
2023-05-19 9:35 ` [Cluster-devel] [PATCH 06/13] filemap: add a kiocb_invalidate_post_write helper Christoph Hellwig
2023-05-21 23:56 ` Damien Le Moal
2023-05-23 16:01 ` Christoph Hellwig
2023-05-19 9:35 ` [Cluster-devel] [PATCH 07/13] iomap: update ki_pos in iomap_file_buffered_write Christoph Hellwig
2023-05-22 0:01 ` Damien Le Moal
2023-05-23 16:02 ` Christoph Hellwig
2023-05-19 9:35 ` [Cluster-devel] [PATCH 08/13] iomap: assign current->backing_dev_info " Christoph Hellwig
2023-05-22 0:05 ` Damien Le Moal
2023-05-23 1:06 ` Darrick J. Wong
2023-05-23 3:30 ` Matthew Wilcox
2023-05-23 16:02 ` Christoph Hellwig
2023-05-19 9:35 ` [Cluster-devel] [PATCH 09/13] iomap: use kiocb_write_and_wait and kiocb_invalidate_pages Christoph Hellwig
2023-05-22 0:07 ` Damien Le Moal
2023-05-19 9:35 ` [Cluster-devel] [PATCH 10/13] fs: factor out a direct_write_fallback helper Christoph Hellwig
2023-05-22 0:16 ` Damien Le Moal
2023-05-22 14:19 ` Miklos Szeredi
2023-05-23 16:03 ` Christoph Hellwig
2023-05-19 9:35 ` [Cluster-devel] [PATCH 11/13] fuse: update ki_pos in fuse_perform_write Christoph Hellwig
2023-05-22 0:18 ` Damien Le Moal
2023-05-19 9:35 ` [Cluster-devel] [PATCH 12/13] fuse: drop redundant arguments to fuse_perform_write Christoph Hellwig
2023-05-22 0:19 ` Damien Le Moal
2023-05-19 9:35 ` Christoph Hellwig [this message]
2023-05-22 0:20 ` [Cluster-devel] [PATCH 13/13] fuse: use direct_write_fallback Damien Le Moal
2023-05-23 1:12 ` [Cluster-devel] cleanup the filemap / direct I/O interaction Darrick J. Wong
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=20230519093521.133226-14-hch@lst.de \
--to=hch@lst.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;
as well as URLs for NNTP newsgroup(s).