Re: [PATCH] Btrfs: reserve sufficient space for ioctl clone

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

 



On tue, 9 Aug 2011 10:46:37 -0700, Sage Weil wrote:
> Fix a crash/BUG_ON in the clone ioctl due to insufficient reservation. We
> need to reserve space for:
> 
>  - adjusting the old extent (possibly splitting it)
>  - adding the new extent
>  - updating the inode
> 
> Signed-off-by: Sage Weil <sage@xxxxxxxxxxxx>
> ---
>  fs/btrfs/ioctl.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index a3c4751..f038d4a 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -2320,7 +2320,12 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
>  			else
>  				new_key.offset = destoff;
>  
> -			trans = btrfs_start_transaction(root, 1);
> +			/*
> +			 * 1 - adjusting old extent (we may have to split it)

I don't think it is enough. If we have lots of file extents and their extent items are stored
in many contiguous leaves, the drop operation may cause those leaves to be COWed. So I think we
must calculate the number of leaves which will be COWed at first.

Thanks
Miao

> +			 * 1 - add new extent
> +			 * 1 - inode update
> +			 */
> +			trans = btrfs_start_transaction(root, 3);
>  			if (IS_ERR(trans)) {
>  				ret = PTR_ERR(trans);
>  				goto out;

--
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