Re: [PATCH 3/4] Btrfs: fix wrong max_to_defrag in btrfs_defrag_file()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Sep 02, 2011 at 03:56:55PM +0800, Li Zefan wrote:
> It's off-by-one, and thus we may skip the last page while defragmenting.

Good catch.

> 
> An example case:
> 
>   # create /mnt/file with 2 4K file extents
>   # btrfs fi defrag /mnt/file
>   # sync
>   # filefrag /mnt/file
>   /mnt/file: 2 extents found
> 
> So it's not defragmented.
> 
> Signed-off-by: Li Zefan <lizf@xxxxxxxxxxxxxx>
Reviewed-by: David Sterba <dsterba@xxxxxxx>

> ---
>  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 6f2b257..57aa5b7 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -1046,7 +1046,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 - 1;
> +		max_to_defrag = last_index;
>  
>  	while (i <= last_index && defrag_count < max_to_defrag) {
>  		/*
> -- 
> 1.7.3.1
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux