Re: df shows no available space in 5.4.1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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 */



> 
> # df -h
> Filesystem                                            Size  Used Avail
> Use% Mounted on
> ...
> /dev/loop0                                            7.4T  623G     0
> 100% /media/backup
> ...
> 
> statfs("/media/backup", {f_type=BTRFS_SUPER_MAGIC, f_bsize=4096,
> f_blocks=1985810876, f_bfree=1822074245, f_bavail=0, f_files=0,
> f_ffree=0, f_fsid={val=[3667078581, 2813298474]}, f_namelen=255,
> f_frsize=4096, f_flags=ST_VALID|ST_NOATIME}) = 0
> 
> # btrfs fi usage /media/backup
> Overall:
>     Device size:                   7.40TiB
>     Device allocated:            671.02GiB
>     Device unallocated:            6.74TiB
>     Device missing:                  0.00B
>     Used:                        622.49GiB
>     Free (estimated):              6.79TiB      (min: 6.79TiB)
>     Data ratio:                       1.00
>     Metadata ratio:                   1.00
>     Global reserve:              512.00MiB      (used: 0.00B)
> 
> Data,single: Size:666.01GiB, Used:617.95GiB
>    /dev/loop0    666.01GiB
> 
> Metadata,single: Size:5.01GiB, Used:4.54GiB
>    /dev/loop0      5.01GiB
> 
> System,single: Size:4.00MiB, Used:96.00KiB
>    /dev/loop0      4.00MiB
> 
> Unallocated:
>    /dev/loop0      6.74TiB
> 
> # btrfs fi df /media/backup
> Data, single: total=666.01GiB, used=617.95GiB
> System, single: total=4.00MiB, used=96.00KiB
> Metadata, single: total=5.01GiB, used=4.54GiB
> GlobalReserve, single: total=512.00MiB, used=0.00B
> 
> # mount
> 
> ...
> /dev/loop0 on /media/backup type btrfs
> (rw,noatime,nossd,discard,space_cache=v2,enospc_debug,skip_balance,commit=86400,subvolid=5,subvol=/)
> ...
> 
> (I remounted with enospc_debug and the available space did not change...)
> 
> Regards,
> Martin Raiber
> 

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux