All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Martin Raiber <martin@urbackup.org>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: df shows no available space in 5.4.1
Date: Tue, 10 Dec 2019 09:19:38 +0800	[thread overview]
Message-ID: <2ae7f7c6-37a6-9133-6f97-e245812b005e@gmx.com> (raw)
In-Reply-To: <b0501a9b-34da-e69b-a06b-1946f7917269@gmx.com>


[-- Attachment #1.1: Type: text/plain, Size: 5053 bytes --]



On 2019/12/10 上午8:52, Qu Wenruo wrote:
> 
> 
> On 2019/12/10 上午2:56, Martin Raiber wrote:
>> On 07.12.2019 08:28 Qu Wenruo wrote:
>>>
>>> On 2019/12/7 上午5:26, Martin Raiber wrote:
>>>> Hi,
>>>>
>>>> with kernel 5.4.1 I have the problem that df shows 100% space used. I
>>>> can still write to the btrfs volume, but my software looks at the
>>>> available space and starts deleting stuff if statfs() says there is a
>>>> low amount of available space.
>>> If the bug still happens, mind to try the snippet to see why this happened?
>>>
>>> You will need to:
>>> - Apply the patch to your kernel code
>>> - Recompile the kernel or btrfs module
>>>   So this needs some experience in kernel compile.
>>> - Reboot to newly compiled kernel or load the debug btrfs module
>>>
>>> Thanks,
>>> Qu
>>>
>>> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
>>> index 23aa630f04c9..cf34c05b16d7 100644
>>> --- a/fs/btrfs/relocation.c
>>> +++ b/fs/btrfs/relocation.c
>>> @@ -523,7 +523,8 @@ static int should_ignore_root(struct btrfs_root *root)
>>>  {
>>>         struct btrfs_root *reloc_root;
>>>
>>> -       if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state))
>>> +       if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state) ||
>>> +           test_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state))
>>>                 return 0;
>>>
>>>         reloc_root = root->reloc_root;
>>> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
>>> index f452a94abdc3..c2b70d97a63b 100644
>>> --- a/fs/btrfs/super.c
>>> +++ b/fs/btrfs/super.c
>>> @@ -2064,6 +2064,8 @@ static int btrfs_statfs(struct dentry *dentry,
>>> struct kstatfs *buf)
>>>                                         found->disk_used;
>>>                 }
>>>
>>> +               pr_info("%s: found type=0x%llx disk_used=%llu factor=%d\n",
>>> +                       __func__, found->flags, found->disk_used, factor);
>>>                 total_used += found->disk_used;
>>>         }
>>>
>>> @@ -2071,6 +2073,8 @@ static int btrfs_statfs(struct dentry *dentry,
>>> struct kstatfs *buf)
>>>
>>>         buf->f_blocks = div_u64(btrfs_super_total_bytes(disk_super),
>>> factor);
>>>         buf->f_blocks >>= bits;
>>> +       pr_info("%s: super_total_bytes=%llu total_used=%llu
>>> factor=%d\n", __func__,
>>> +               btrfs_super_total_bytes(disk_super), total_used, factor);
>>>         buf->f_bfree = buf->f_blocks - (div_u64(total_used, factor) >>
>>> bits);
>>>
>>>         /* Account global block reserve as used, it's in logical size
>>> already */
>>>
>> Applied. It's currently 100% used directly after reboot, and I am
>> getting this log output:
> 
> Thank you a lot for the debug output!
> 
>>
>> [...]
>> [  241.245150] btrfs_statfs: super_total_bytes=128835387392
>> total_used=93778841600 factor=1
>> [  241.904824] btrfs_statfs: found type=0x1 disk_used=93464006656 factor=1
>> [  241.904824] btrfs_statfs: found type=0x4 disk_used=314818560 factor=1
>> [  241.904824] btrfs_statfs: found type=0x2 disk_used=16384 factor=1
>> [  241.904824] btrfs_statfs: super_total_bytes=128835387392
>> total_used=93778841600 factor=1
> 
> This proves the on-disk numbers are all correct, so far so good.
> 
> The remaining problem is the block_rsv part. Which matches with the new
> ticket system introduced in v5.4.
> 
> Mind to test the new debug snippet?
> 
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index f452a94abdc3..516969534095 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -2076,6 +2076,8 @@ static int btrfs_statfs(struct dentry *dentry,
> struct kstatfs *buf)
>         /* Account global block reserve as used, it's in logical size
> already */
>         spin_lock(&block_rsv->lock);
>         /* Mixed block groups accounting is not byte-accurate, avoid
> overflow */
> +       pr_info("%s: block_rsv->size=%llu block_rsv->reserved=%llu\n",
> __func__,
> +               block_rsv->size, block_rsv->reserved);
>         if (buf->f_bfree >= block_rsv->size >> bits)
>                 buf->f_bfree -= block_rsv->size >> bits;
>         else
> 

And this extra snippet for available space.

Thanks,
Qu

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index f452a94abdc3..f1a3e01a0ef5 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1911,6 +1911,7 @@ static inline int
btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info,
         * We aren't under the device list lock, so this is racy-ish,
but good
         * enough for our purposes.
         */
+       pr_info("%s: original_free_bytes=%llu\n", __func__, *free_bytes);
        nr_devices = fs_info->fs_devices->open_devices;
        if (!nr_devices) {
                smp_mb();
@@ -2005,6 +2006,7 @@ static inline int
btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info,

        kfree(devices_info);
        *free_bytes = avail_space;
+       pr_info("%s: calculated_bytes=%llu\n", __func__, avail_space);
        return 0;
 }



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 520 bytes --]

  reply	other threads:[~2019-12-10  1:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-06 21:26 df shows no available space in 5.4.1 Martin Raiber
2019-12-06 22:35 ` Chris Murphy
2019-12-06 22:51   ` Martin Raiber
2019-12-08 18:12   ` Zygo Blaxell
2019-12-07  7:28 ` Qu Wenruo
2019-12-09 18:56   ` Martin Raiber
2019-12-09 19:26     ` Martin Raiber
2019-12-10  0:52     ` Qu Wenruo
2019-12-10  1:19       ` Qu Wenruo [this message]
2019-12-11 13:11         ` Martin Raiber
2019-12-16  5:04           ` Qu Wenruo
2019-12-13 16:02 ` David Sterba
2019-12-13 20:03 ` Chris Murphy

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=2ae7f7c6-37a6-9133-6f97-e245812b005e@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=martin@urbackup.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.