From: Liu Bo Date: Thu, 26 Jan 2012 20:01:12 +0000 (-0500) Subject: Btrfs: do not defrag a file partially X-Git-Tag: upstream/snapshot3+hdmi~8007^2~30 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7ec31b548a17f773ab6289e795ed3a6820e8b56e;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git 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: Liu Bo Signed-off-by: Chris Mason --- diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 6834be4..0b06a5c 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1066,7 +1066,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, i = range->start >> PAGE_CACHE_SHIFT; } 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