All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs: do not defrag a file partially
@ 2012-01-16 10:21 Liu Bo
  2012-01-17  2:43 ` Li Zefan
  0 siblings, 1 reply; 2+ messages in thread
From: Liu Bo @ 2012-01-16 10:21 UTC (permalink / raw)
  To: linux-btrfs

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 <liubo2009@cn.fujitsu.com>
---
 fs/btrfs/ioctl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index c04f02c..712fb0c 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1058,7 +1058,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
-- 
1.6.5.2


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

* Re: [PATCH] Btrfs: do not defrag a file partially
  2012-01-16 10:21 [PATCH] Btrfs: do not defrag a file partially Liu Bo
@ 2012-01-17  2:43 ` Li Zefan
  0 siblings, 0 replies; 2+ messages in thread
From: Li Zefan @ 2012-01-17  2:43 UTC (permalink / raw)
  To: Liu Bo; +Cc: linux-btrfs

Liu Bo wrote:
> 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 <liubo2009@cn.fujitsu.com>

Reviewed-by: Li Zefan <lizf@cn.fujitsu.com>

> ---
>  fs/btrfs/ioctl.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

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

end of thread, other threads:[~2012-01-17  2:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-16 10:21 [PATCH] Btrfs: do not defrag a file partially Liu Bo
2012-01-17  2:43 ` Li Zefan

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.