Commit 7ec31b54 authored by Liu Bo's avatar Liu Bo Committed by Chris Mason

Btrfs: do not defrag a file partially

xfstests 218 complains that btrfs defrags a file partially:
 After: 1
 Write backwards sync, but contiguous - should defrag to 1 extent
 Before: 10
-After: 1
+After: 2

To fix this, we need to set max_to_defrag count properly.
Signed-off-by: default avatarLiu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 0b485143
...@@ -1066,7 +1066,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, ...@@ -1066,7 +1066,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
i = range->start >> PAGE_CACHE_SHIFT; i = range->start >> PAGE_CACHE_SHIFT;
} }
if (!max_to_defrag) if (!max_to_defrag)
max_to_defrag = last_index; max_to_defrag = last_index + 1;
/* /*
* make writeback starts from i, so the defrag range can be * make writeback starts from i, so the defrag range can be
......
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