From: Brian Foster <bfoster@redhat.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] fs/remap_range: avoid spurious writeback on zero length request
Date: Tue, 29 Nov 2022 06:29:51 -0500 [thread overview]
Message-ID: <Y4XtL9SzQN/A4w5U@bfoster> (raw)
In-Reply-To: <Y4TubQFwHExk07w4@magnolia>
On Mon, Nov 28, 2022 at 09:22:53AM -0800, Darrick J. Wong wrote:
> On Mon, Nov 28, 2022 at 11:08:13AM -0500, Brian Foster wrote:
> > generic_remap_checks() can reduce the effective request length (i.e.,
> > after the reflink extend to EOF case is handled) down to zero. If this
> > occurs, __generic_remap_file_range_prep() proceeds through dio
> > serialization, file mapping flush calls, and may invoke file_modified()
> > before returning back to the filesystem caller, all of which immediately
> > check for len == 0 and return.
> >
> > While this is mostly harmless, it is spurious and not completely
> > without side effect. A filemap write call can submit I/O (but not
> > wait on it) when the specified end byte precedes the start but
> > happens to land on the same aligned page boundary, which can occur
> > from __generic_remap_file_range_prep() when len is 0.
> >
> > The dedupe path already has a len == 0 check to break out before doing
> > range comparisons. Lift this check a bit earlier in the function to
> > cover the general case of len == 0 and avoid the unnecessary work.
> >
> > Signed-off-by: Brian Foster <bfoster@redhat.com>
>
> Looks correct,
> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
>
> Should there be an(other) "if (!*len) return 0;" after the
> generic_remap_check_len call to skip the mtime update if the remap
> request gets shortened to avoid remapping an unaligned eofblock into the
> middle of the destination file?
>
Looks sensible to me, though I guess I would do something like the
appended diff. Do you want to just fold that into this patch?
Brian
--- 8< ---
diff --git a/fs/remap_range.c b/fs/remap_range.c
index 32ea992f9acc..2f236c9c5802 100644
--- a/fs/remap_range.c
+++ b/fs/remap_range.c
@@ -347,7 +347,7 @@ __generic_remap_file_range_prep(struct file *file_in, loff_t pos_in,
ret = generic_remap_check_len(inode_in, inode_out, pos_out, len,
remap_flags);
- if (ret)
+ if (ret || *len == 0)
return ret;
/* If can't alter the file contents, we're done. */
next prev parent reply other threads:[~2022-11-29 11:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-28 16:08 [PATCH] fs/remap_range: avoid spurious writeback on zero length request Brian Foster
2022-11-28 17:22 ` Darrick J. Wong
2022-11-29 11:29 ` Brian Foster [this message]
2022-11-29 18:18 ` Darrick J. Wong
2022-11-29 18:43 ` Brian Foster
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=Y4XtL9SzQN/A4w5U@bfoster \
--to=bfoster@redhat.com \
--cc=djwong@kernel.org \
--cc=linux-fsdevel@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