From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: xfs <linux-xfs@vger.kernel.org>
Cc: fstests <fstests@vger.kernel.org>, Christoph Hellwig <hch@infradead.org>
Subject: [PATCH v2] xfs: cap the length of deduplication requests
Date: Tue, 17 Apr 2018 19:57:55 -0700 [thread overview]
Message-ID: <20180418025755.GN24738@magnolia> (raw)
In-Reply-To: <20180417051918.GD5203@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
Since deduplication potentially has to read in all the pages in both
files in order to compare the contents, cap the deduplication request
length at MAX_RW_COUNT/2 (roughly 1GB) so that we have /some/ upper bound
on the request length and can't just lock up the kernel forever. Found
by running generic/304 after commit 1ddae54555b62a ("common/rc: add
missing 'local' keywords").
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
v2: halve the amount so that we do MAX_RW_COUNT IO max
---
fs/xfs/xfs_file.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 299aee4..9cafad4 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -876,8 +876,18 @@ xfs_file_dedupe_range(
struct file *dst_file,
u64 dst_loff)
{
+ struct inode *srci = file_inode(src_file);
+ u64 max_dedupe;
int error;
+ /*
+ * Since we have to read all these pages in to compare them, cut
+ * it off at MAX_RW_COUNT/2 rounded down to the nearest block.
+ * That means we won't do more than MAX_RW_COUNT IO per request.
+ */
+ max_dedupe = (MAX_RW_COUNT >> 1) & ~(i_blocksize(srci) - 1);
+ if (len > max_dedupe)
+ len = max_dedupe;
error = xfs_reflink_remap_range(src_file, loff, dst_file, dst_loff,
len, true);
if (error)
next prev parent reply other threads:[~2018-04-18 2:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-17 5:19 [PATCH] xfs: cap the length of deduplication requests Darrick J. Wong
2018-04-17 6:58 ` Christoph Hellwig
2018-04-17 15:44 ` Darrick J. Wong
2018-04-18 2:57 ` Darrick J. Wong [this message]
2018-04-22 2:57 ` [PATCH v2] " Amir Goldstein
2018-04-22 13:53 ` Darrick J. Wong
2018-05-02 15:30 ` Carlos Maiolino
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=20180418025755.GN24738@magnolia \
--to=darrick.wong@oracle.com \
--cc=fstests@vger.kernel.org \
--cc=hch@infradead.org \
--cc=linux-xfs@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;
as well as URLs for NNTP newsgroup(s).