Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Miao Xie <miaox@cn.fujitsu.com>
To: Sage Weil <sage@newdream.net>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] Btrfs: reserve sufficient space for ioctl clone
Date: Tue, 16 Aug 2011 10:09:31 +0800	[thread overview]
Message-ID: <4E49D15B.8010209@cn.fujitsu.com> (raw)
In-Reply-To: <1312911997-5075-1-git-send-email-sage@newdream.net>

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@newdream.net>
> ---
>  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;


  reply	other threads:[~2011-08-16  2:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-09 17:46 [PATCH] Btrfs: reserve sufficient space for ioctl clone Sage Weil
2011-08-16  2:09 ` Miao Xie [this message]
2011-08-16  4:33   ` Sage Weil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E49D15B.8010209@cn.fujitsu.com \
    --to=miaox@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=sage@newdream.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox