Commit 2e171ffc authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'xfs-4.17-fixes-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux

Pull xfs fixes from Darrick Wong:
 "I've got one more bug fix for xfs for 4.17-rc4, which caps the amount
  of data we try to handle in one dedupe request so that userspace can't
  livelock the kernel.

  This series has been run through a full xfstests run during the week
  and through a quick xfstests run against this morning's master, with
  no ajor failures reported.

  Summary:

  - Cap the maximum length of a deduplication request at MAX_RW_COUNT/2
    to avoid kernel livelock due to excessively large IO requests"

* tag 'xfs-4.17-fixes-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
  xfs: cap the length of deduplication requests
parents 4148d388 021ba8e9
...@@ -880,8 +880,18 @@ xfs_file_dedupe_range( ...@@ -880,8 +880,18 @@ xfs_file_dedupe_range(
struct file *dst_file, struct file *dst_file,
u64 dst_loff) u64 dst_loff)
{ {
struct inode *srci = file_inode(src_file);
u64 max_dedupe;
int error; 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, error = xfs_reflink_remap_range(src_file, loff, dst_file, dst_loff,
len, true); len, true);
if (error) if (error)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment