All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
To: Josef Bacik <jbacik@fb.com>, <cyril.scetbon@free.fr>
Cc: <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH 2/2] Btrfs: qgroup: Introduce a may_use to account space_info->bytes_may_use.
Date: Wed, 10 Dec 2014 16:09:41 +0800	[thread overview]
Message-ID: <5487FFC5.9050708@cn.fujitsu.com> (raw)
In-Reply-To: <54871B79.3090206@fb.com>

On 12/09/2014 11:55 PM, Josef Bacik wrote:
> On 12/09/2014 06:27 AM, Dongsheng Yang wrote:
>> Currently, for pre_alloc or delay_alloc, the bytes will be accounted
>> in space_info by the three guys.
>> space_info->bytes_may_use --- space_info->reserved --- space_info->used.
>> But on the other hand, in qgroup, there are only two counters to 
>> account the
>> bytes, qgroup->reserved and qgroup->excl. And qg->reserved accounts
>> bytes in space_info->bytes_may_use and qg->excl accounts bytes in
>> space_info->used. So the bytes in space_info->reserved is not accounted
>> in qgroup. If so, there is a window we can exceed the quota limit when
>> bytes is in space_info->reserved.
>>
>> Example:
>>     # btrfs quota enable /mnt
>>     # btrfs qgroup limit -e 10M /mnt
>>     # for((i=0;i<20;i++));do fallocate -l 1M /mnt/data$i; done
>>     # sync
>>     # btrfs qgroup show -pcre /mnt
>> qgroupid rfer     excl     max_rfer max_excl parent  child
>> -------- ----     ----     -------- -------- ------  -----
>> 0/5      20987904 20987904 0        10485760 ---     ---
>>
>> qg->excl is 20987904 larger than max_excl 10485760.
>>
>> This patch introduce a new counter named may_use to qgroup, then
>> there are three counters in qgroup to account bytes in space_info
>> as below.
>> space_info->bytes_may_use --- space_info->reserved --- space_info->used.
>> qgroup->may_use           --- qgroup->reserved     --- qgroup->excl
>>
>> With this patch applied:
>>     # btrfs quota enable /mnt
>>     # btrfs qgroup limit -e 10M /mnt
>>     # for((i=0;i<20;i++));do fallocate -l 1M /mnt/data$i; done
>> fallocate: /mnt/data9: fallocate failed: Disk quota exceeded
>> fallocate: /mnt/data10: fallocate failed: Disk quota exceeded
>> fallocate: /mnt/data11: fallocate failed: Disk quota exceeded
>> fallocate: /mnt/data12: fallocate failed: Disk quota exceeded
>> fallocate: /mnt/data13: fallocate failed: Disk quota exceeded
>> fallocate: /mnt/data14: fallocate failed: Disk quota exceeded
>> fallocate: /mnt/data15: fallocate failed: Disk quota exceeded
>> fallocate: /mnt/data16: fallocate failed: Disk quota exceeded
>> fallocate: /mnt/data17: fallocate failed: Disk quota exceeded
>> fallocate: /mnt/data18: fallocate failed: Disk quota exceeded
>> fallocate: /mnt/data19: fallocate failed: Disk quota exceeded
>>     # sync
>>     # btrfs qgroup show -pcre /mnt
>> qgroupid rfer    excl    max_rfer max_excl parent  child
>> -------- ----    ----    -------- -------- ------  -----
>> 0/5      9453568 9453568 0        10485760 ---     ---
>>
>> Reported-by: Cyril SCETBON <cyril.scetbon@free.fr>
>> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
>> ---
>>   fs/btrfs/extent-tree.c | 25 ++++++++++++++++++-
>>   fs/btrfs/inode.c       | 22 +++++++++++++++-
>>   fs/btrfs/qgroup.c      | 68 
>> +++++++++++++++++++++++++++++++++++++++++++++++---
>>   fs/btrfs/qgroup.h      |  4 +++
>>   4 files changed, 113 insertions(+), 6 deletions(-)
>>
>> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
>> index 014b7f2..9eaf268 100644
>> --- a/fs/btrfs/extent-tree.c
>> +++ b/fs/btrfs/extent-tree.c
>> @@ -5500,8 +5500,13 @@ static int pin_down_extent(struct btrfs_root 
>> *root,
>>
>>       set_extent_dirty(root->fs_info->pinned_extents, bytenr,
>>                bytenr + num_bytes - 1, GFP_NOFS | __GFP_NOFAIL);
>> -    if (reserved)
>> +    if (reserved) {
>> +        if (root->fs_info->quota_enabled)
>
> You already have this check in btrfs_qgroup_update_reserved_bytes, 
> just call it unconditionally everywhere in this patch.  Otherwise this 
> looks good, thanks,

Thanx, I will update it in V2.
>
> Josef
> -- 
> 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:[~2014-12-10  8:12 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <BA68E495-8B7B-4F0F-A64B-0413B1480B9C@free.fr>
2014-12-09 11:27 ` [PATCH 1/2] Btrfs: qgroup: free reserved in exceeding quota Dongsheng Yang
2014-12-09 11:27   ` [PATCH 2/2] Btrfs: qgroup: Introduce a may_use to account space_info->bytes_may_use Dongsheng Yang
2014-12-09 15:55     ` Josef Bacik
2014-12-10  8:09       ` Dongsheng Yang [this message]
2014-12-09 15:42   ` [PATCH 1/2] Btrfs: qgroup: free reserved in exceeding quota Josef Bacik
2014-12-10  8:09     ` Dongsheng Yang
2014-12-11 18:25       ` Josef Bacik
2014-12-12  0:44         ` Dongsheng Yang
2014-12-12  8:44           ` [PATCH v2 " Dongsheng Yang
2014-12-12  8:44             ` [PATCH v2 2/2] Btrfs: qgroup: Introduce a may_use to account space_info->bytes_may_use Dongsheng Yang
     [not found]               ` <549CBAB1.3070909@cn.fujitsu.com>
2014-12-26  5:43                 ` Satoru Takeuchi
2014-12-26  6:49                   ` Dongsheng Yang
2014-12-26  7:00                     ` Dongsheng Yang
2014-12-28  2:03                   ` Dongsheng Yang
2015-01-05  6:16                   ` [PATCH v3 0/3] Btrfs: Enhancment for qgroup Dongsheng Yang
2015-01-05  6:16                     ` [PATCH v3 1/3] Btrfs: qgroup: free reserved in exceeding quota Dongsheng Yang
2015-01-05  6:16                     ` [PATCH v3 2/3] Btrfs: qgroup: Introduce a may_use to account space_info->bytes_may_use Dongsheng Yang
2015-01-05  6:16                     ` [PATCH v3 3/3] Btrfs: qgroup, Account data space in more proper timings Dongsheng Yang
2015-01-07  0:49                     ` [PATCH v3 0/3] Btrfs: Enhancment for qgroup Satoru Takeuchi
2015-01-08  3:53                       ` Dongsheng Yang

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=5487FFC5.9050708@cn.fujitsu.com \
    --to=yangds.fnst@cn.fujitsu.com \
    --cc=cyril.scetbon@free.fr \
    --cc=jbacik@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.