All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: cap the length of deduplication requests
@ 2018-04-17  5:19 Darrick J. Wong
  2018-04-17  6:58 ` Christoph Hellwig
  2018-04-18  2:57 ` [PATCH v2] " Darrick J. Wong
  0 siblings, 2 replies; 7+ messages in thread
From: Darrick J. Wong @ 2018-04-17  5:19 UTC (permalink / raw)
  To: xfs; +Cc: fstests

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 (roughly 2GB) 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 1ddae54555b62 ("common/rc: add
missing 'local' keywords").

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/xfs_file.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 299aee4..9fd9dd7 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -876,8 +876,17 @@ 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 rounded down to the nearest block.
+	 */
+	max_dedupe = MAX_RW_COUNT & ~(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)

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-05-02 15:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v2] " Darrick J. Wong
2018-04-22  2:57   ` Amir Goldstein
2018-04-22 13:53     ` Darrick J. Wong
2018-05-02 15:30   ` Carlos Maiolino

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.