linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeremy Bongio <bongiojp@gmail.com>
To: Ted Tso <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-api@vger.kernel.org, linux-block@vger.kernel.org,
	Jeremy Bongio <jbongio@google.com>
Subject: [RFC PATCH 1/1] Remove buffered failover for ext4 and block fops direct writes.
Date: Wed,  1 May 2024 16:15:33 -0700	[thread overview]
Message-ID: <20240501231533.3128797-2-bongiojp@gmail.com> (raw)
In-Reply-To: <20240501231533.3128797-1-bongiojp@gmail.com>

From: Jeremy Bongio <jbongio@google.com>

ext4 and block fops would both failover to syncronous, buffered writes if
the direct IO results in a short write where only a portion of the request
was completed.

This patch changes the behavior to simply return the number of bytes
written if the direct write is short.
---
 block/fops.c   |  3 ---
 fs/ext4/file.c | 27 ---------------------------
 2 files changed, 30 deletions(-)

diff --git a/block/fops.c b/block/fops.c
index 0cf8cf72cdfa..d32574ba9d71 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -704,9 +704,6 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
 
 	if (iocb->ki_flags & IOCB_DIRECT) {
 		ret = blkdev_direct_write(iocb, from);
-		if (ret >= 0 && iov_iter_count(from))
-			ret = direct_write_fallback(iocb, from, ret,
-					blkdev_buffered_write(iocb, from));
 	} else {
 		ret = blkdev_buffered_write(iocb, from);
 	}
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 54d6ff22585c..d0760452a11f 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -595,32 +595,6 @@ static ssize_t ext4_dio_write_iter(struct kiocb *iocb, struct iov_iter *from)
 	else
 		inode_unlock(inode);
 
-	if (ret >= 0 && iov_iter_count(from)) {
-		ssize_t err;
-		loff_t endbyte;
-
-		offset = iocb->ki_pos;
-		err = ext4_buffered_write_iter(iocb, from);
-		if (err < 0)
-			return err;
-
-		/*
-		 * We need to ensure that the pages within the page cache for
-		 * the range covered by this I/O are written to disk and
-		 * invalidated. This is in attempt to preserve the expected
-		 * direct I/O semantics in the case we fallback to buffered I/O
-		 * to complete off the I/O request.
-		 */
-		ret += err;
-		endbyte = offset + err - 1;
-		err = filemap_write_and_wait_range(iocb->ki_filp->f_mapping,
-						   offset, endbyte);
-		if (!err)
-			invalidate_mapping_pages(iocb->ki_filp->f_mapping,
-						 offset >> PAGE_SHIFT,
-						 endbyte >> PAGE_SHIFT);
-	}
-
 	return ret;
 }
 
@@ -958,4 +932,3 @@ const struct inode_operations ext4_file_inode_operations = {
 	.fileattr_get	= ext4_fileattr_get,
 	.fileattr_set	= ext4_fileattr_set,
 };
-
-- 
2.44.0.769.g3c40516874-goog


  reply	other threads:[~2024-05-01 23:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-01 23:15 [RFC PATCH 0/1] Change failover behavior for DIRECT writes in ext4/block fops Jeremy Bongio
2024-05-01 23:15 ` Jeremy Bongio [this message]
2024-05-02  5:45   ` [RFC PATCH 1/1] Remove buffered failover for ext4 and block fops direct writes Christoph Hellwig
2024-05-02 14:01     ` Theodore Ts'o
2024-05-02 14:33       ` 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=20240501231533.3128797-2-bongiojp@gmail.com \
    --to=bongiojp@gmail.com \
    --cc=jbongio@google.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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).