From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs: remove the dead copied check in btrfs_copy_from_user()
Date: Thu, 13 Aug 2020 14:15:33 +0800 [thread overview]
Message-ID: <20200813061533.85671-1-wqu@suse.com> (raw)
There is btrfs specific check in btrfs_copy_from_user(), after
iov_iter_copy_from_user_atomic() call, we check if the page is uptodate
and if the copied bytes is smaller than what we expect.
However that check will never be triggered due to the following reasons:
- PageUptodate() check conflicts with current behavior
Currently we ensure all pages that will go through a partial write
(some bytes are not covered by the write range) will be forced
uptodate.
This is the common behavior to ensure we get the correct content.
This behavior is always true, no matter if my previous patch "btrfs:
refactor how we prepare pages for btrfs_buffered_write()" is applied.
- iov_iter_copy_from_user_atomic() only returns 0 or @bytes
It won't return a short write.
So we're completely fine to remove the (PageUptodate() && copied <
count) check, as we either get copied == 0, and break the loop anyway,
or do a proper copy.
This will revert commit 31339acd07b4 ("Btrfs: deal with short returns from
copy_from_user").
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/file.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 705ebe709e8d..2f96f083eb8c 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -403,18 +403,6 @@ static noinline int btrfs_copy_from_user(loff_t pos, size_t write_bytes,
/* Flush processor's dcache for this page */
flush_dcache_page(page);
- /*
- * if we get a partial write, we can end up with
- * partially up to date pages. These add
- * a lot of complexity, so make sure they don't
- * happen by forcing this copy to be retried.
- *
- * The rest of the btrfs_file_write code will fall
- * back to page at a time copies after we return 0.
- */
- if (!PageUptodate(page) && copied < count)
- copied = 0;
-
iov_iter_advance(i, copied);
write_bytes -= copied;
total_copied += copied;
--
2.28.0
next reply other threads:[~2020-08-13 6:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-13 6:15 Qu Wenruo [this message]
2020-08-13 10:48 ` [PATCH] btrfs: remove the dead copied check in btrfs_copy_from_user() David Sterba
2020-08-13 11:03 ` Qu Wenruo
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=20200813061533.85671-1-wqu@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/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