linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Liu Bo <bo.li.liu@oracle.com>
To: Miao Xie <miaox@cn.fujitsu.com>
Cc: Linux Btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH 2/2] Btrfs: fix off-by-one error of the reserved size of btrfs_allocate()
Date: Wed, 28 Nov 2012 18:49:33 +0800	[thread overview]
Message-ID: <20121128104932.GA2791@liubo> (raw)
In-Reply-To: <50B5E766.3010804@cn.fujitsu.com>

On Wed, Nov 28, 2012 at 06:28:54PM +0800, Miao Xie wrote:
> alloc_end is not the real end of the current extent, it is the start of the
> next adjoining extent. So we needn't +1 when calculating the size the space
> that is about to be reserved.
> 

Good catch.

Reviewed-by: Liu Bo <bo.li.liu@oracle.com>

thanks,
liubo

> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
> ---
>  fs/btrfs/file.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index 641bbaa..bd5afcc 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -2085,7 +2085,7 @@ static long btrfs_fallocate(struct file *file, int mode,
>  	 * Make sure we have enough space before we do the
>  	 * allocation.
>  	 */
> -	ret = btrfs_check_data_free_space(inode, alloc_end - alloc_start + 1);
> +	ret = btrfs_check_data_free_space(inode, alloc_end - alloc_start);
>  	if (ret)
>  		return ret;
>  
> @@ -2192,7 +2192,7 @@ static long btrfs_fallocate(struct file *file, int mode,
>  out:
>  	mutex_unlock(&inode->i_mutex);
>  	/* Let go of our reservation. */
> -	btrfs_free_reserved_data_space(inode, alloc_end - alloc_start + 1);
> +	btrfs_free_reserved_data_space(inode, alloc_end - alloc_start);
>  	return ret;
>  }
>  
> -- 
> 1.7.11.7
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2012-11-28 10:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-28 10:28 [PATCH 2/2] Btrfs: fix off-by-one error of the reserved size of btrfs_allocate() Miao Xie
2012-11-28 10:49 ` Liu Bo [this message]

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=20121128104932.GA2791@liubo \
    --to=bo.li.liu@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=miaox@cn.fujitsu.com \
    /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;
as well as URLs for NNTP newsgroup(s).