linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Liu Bo <bo.li.liu@oracle.com>
To: Jan Schmidt <list.btrfs@jan-o-sch.net>
Cc: chris.mason@fusionio.com, linux-btrfs@vger.kernel.org,
	lev@zadarastorage.com, sensille@gmx.net
Subject: Re: [PATCH] Btrfs: fix EDQUOT handling in btrfs_delalloc_reserve_metadata
Date: Mon, 28 Jan 2013 16:55:29 +0800	[thread overview]
Message-ID: <20130128085528.GB19533@liubo> (raw)
In-Reply-To: <1359354360-604-1-git-send-email-list.btrfs@jan-o-sch.net>

On Mon, Jan 28, 2013 at 07:26:00AM +0100, Jan Schmidt wrote:
> When btrfs_qgroup_reserve returned a failure, we were missing a counter
> operation for BTRFS_I(inode)->outstanding_extents++, leading to warning
> messages about outstanding extents and space_info->bytes_may_use != 0.
> Additionally, the error handling code didn't take into account that we
> dropped the inode lock which might require more cleanup.
> 
> Luckily, all the cleanup code we need is already there and can be shared
> with reserve_metadata_bytes, which is exactly what this patch does.

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

> 
> Reported-by: Lev Vainblat <lev@zadarastorage.com>
> Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
> ---
>  fs/btrfs/extent-tree.c |   22 ++++++++++------------
>  1 files changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 85b8454..61da9d0 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -4534,7 +4534,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
>  	unsigned nr_extents = 0;
>  	int extra_reserve = 0;
>  	enum btrfs_reserve_flush_enum flush = BTRFS_RESERVE_FLUSH_ALL;
> -	int ret;
> +	int ret = 0;
>  	bool delalloc_lock = true;
>  
>  	/* If we are a free space inode we need to not flush since we will be in
> @@ -4579,20 +4579,18 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
>  	csum_bytes = BTRFS_I(inode)->csum_bytes;
>  	spin_unlock(&BTRFS_I(inode)->lock);
>  
> -	if (root->fs_info->quota_enabled) {
> +	if (root->fs_info->quota_enabled)
>  		ret = btrfs_qgroup_reserve(root, num_bytes +
>  					   nr_extents * root->leafsize);
> -		if (ret) {
> -			spin_lock(&BTRFS_I(inode)->lock);
> -			calc_csum_metadata_size(inode, num_bytes, 0);
> -			spin_unlock(&BTRFS_I(inode)->lock);
> -			if (delalloc_lock)
> -				mutex_unlock(&BTRFS_I(inode)->delalloc_mutex);
> -			return ret;
> -		}
> -	}
>  
> -	ret = reserve_metadata_bytes(root, block_rsv, to_reserve, flush);
> +	/*
> +	 * ret != 0 here means the qgroup reservation failed, we go straight to
> +	 * the shared error handling then.
> +	 */
> +	if (ret == 0)
> +		ret = reserve_metadata_bytes(root, block_rsv,
> +					     to_reserve, flush);
> +
>  	if (ret) {
>  		u64 to_free = 0;
>  		unsigned dropped;
> -- 
> 1.7.1
> 
> --
> 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:[~2013-01-28  8:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-28  6:26 [PATCH] Btrfs: fix EDQUOT handling in btrfs_delalloc_reserve_metadata Jan Schmidt
2013-01-28  8:55 ` 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=20130128085528.GB19533@liubo \
    --to=bo.li.liu@oracle.com \
    --cc=chris.mason@fusionio.com \
    --cc=lev@zadarastorage.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=list.btrfs@jan-o-sch.net \
    --cc=sensille@gmx.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;
as well as URLs for NNTP newsgroup(s).