naota / linux

Linux kernel source tree
Other
3 stars 1 forks source link

Message "reclaiming chunk" but strange zone_unusable value #50

Closed kdave closed 3 years ago

kdave commented 3 years ago

With the following change

--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -1539,8 +1539,9 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
                if (ret < 0)
                        goto next;

-               btrfs_info(fs_info, "reclaiming chunk %llu with %llu%% used",
-                               bg->start, div_u64(bg->used * 100, bg->length));
+               btrfs_info(fs_info, "reclaiming chunk %llu with %llu%% used %llu%% unusable",
+                               bg->start, div64_u64(bg->used * 100, bg->length),
+                               div64_u64(bg->zone_unusable * 100, bg->length));
                trace_btrfs_reclaim_block_group(bg);
                ret = btrfs_relocate_chunk(fs_info, bg->start);
                if (ret)

all messages I can find in the syslog contain the value 0%:

[35381.581185] BTRFS info (device nullb0): reclaiming chunk 939524096 with 0% used 0% unusable
[35412.309102] BTRFS info (device nullb0): reclaiming chunk 1073741824 with 0% used 0% unusable
[35442.988072] BTRFS info (device nullb0): reclaiming chunk 1207959552 with 0% used 0% unusable
[35443.402061] BTRFS info (device nullb0): reclaiming chunk 1342177280 with 0% used 0% unusable
[35475.759895] BTRFS info (device nullb0): reclaiming chunk 1476395008 with 0% used 0% unusable
[35506.534043] BTRFS info (device nullb0): reclaiming chunk 1610612736 with 0% used 0% unusable
[35507.057768] BTRFS info (device nullb0): reclaiming chunk 1744830464 with 0% used 0% unusable
[35537.208767] BTRFS info (device nullb0): reclaiming chunk 1879048192 with 0% used 0% unusable
[35567.895208] BTRFS info (device nullb0): reclaiming chunk 2013265920 with 0% used 0% unusable
[35568.442776] BTRFS info (device nullb0): reclaiming chunk 2147483648 with 0% used 0% unusable
[35598.653825] BTRFS info (device nullb0): reclaiming chunk 2281701376 with 0% used 0% unusable
[35629.339956] BTRFS info (device nullb0): reclaiming chunk 2415919104 with 0% used 0% unusable
[35629.960541] BTRFS info (device nullb0): reclaiming chunk 2550136832 with 10% used 0% unusable
[35664.248395] BTRFS info (device nullb0): reclaiming chunk 402653184 with 0% used 0% unusable
[35694.913346] BTRFS info (device nullb0): reclaiming chunk 2684354560 with 0% used 0% unusable
[35725.560985] BTRFS info (device nullb0): reclaiming chunk 3087007744 with 0% used 0% unusable
[35726.053710] BTRFS info (device nullb0): reclaiming chunk 3221225472 with 0% used 0% unusable
[35756.352504] BTRFS info (device nullb0): reclaiming chunk 3355443200 with 0% used 0% unusable
[35756.739891] BTRFS info (device nullb0): reclaiming chunk 3489660928 with 0% used 0% unusable
[35787.053700] BTRFS info (device nullb0): reclaiming chunk 3623878656 with 0% used 0% unusable
[35817.792261] BTRFS info (device nullb0): reclaiming chunk 3758096384 with 0% used 0% unusable
[35818.672131] BTRFS info (device nullb0): reclaiming chunk 3892314112 with 0% used 0% unusable
[35850.520127] BTRFS info (device nullb0): reclaiming chunk 4026531840 with 0% used 0% unusable
[35881.258086] BTRFS info (device nullb0): reclaiming chunk 4160749568 with 0% used 0% unusable
[35911.955632] BTRFS info (device nullb0): reclaiming chunk 2818572288 with 0% used 0% unusable
[35913.607179] BTRFS info (device nullb0): reclaiming chunk 4429185024 with 0% used 0% unusable
[35944.731592] BTRFS info (device nullb0): reclaiming chunk 4563402752 with 0% used 0% unusable
[35945.104557] BTRFS info (device nullb0): reclaiming chunk 4831838208 with 0% used 0% unusable
[35975.511770] BTRFS info (device nullb0): reclaiming chunk 4966055936 with 0% used 0% unusable
[36006.228105] BTRFS info (device nullb0): reclaiming chunk 5100273664 with 0% used 0% unusable
[36006.855187] BTRFS info (device nullb0): reclaiming chunk 5234491392 with 0% used 0% unusable
[36038.898733] BTRFS info (device nullb0): reclaiming chunk 5368709120 with 0% used 0% unusable
[36069.699685] BTRFS info (device nullb0): reclaiming chunk 5502926848 with 0% used 0% unusable
[36070.244632] BTRFS info (device nullb0): reclaiming chunk 5637144576 with 0% used 0% unusable
[36100.419150] BTRFS info (device nullb0): reclaiming chunk 5771362304 with 0% used 0% unusable
[36131.154455] BTRFS info (device nullb0): reclaiming chunk 5905580032 with 0% used 0% unusable
[36161.853213] BTRFS info (device nullb0): reclaiming chunk 6039797760 with 0% used 0% unusable
[36162.333562] BTRFS info (device nullb0): reclaiming chunk 6174015488 with 0% used 0% unusable
[36192.565473] BTRFS info (device nullb0): reclaiming chunk 6308233216 with 0% used 0% unusable
[36223.330587] BTRFS info (device nullb0): reclaiming chunk 4697620480 with 0% used 0% unusable
[36224.076731] BTRFS info (device nullb0): reclaiming chunk 6442450944 with 0% used 0% unusable
[36224.589375] BTRFS info (device nullb0): reclaiming chunk 6576668672 with 0% used 0% unusable
[36256.025565] BTRFS info (device nullb0): reclaiming chunk 6845104128 with 0% used 0% unusable
[36286.749545] BTRFS info (device nullb0): reclaiming chunk 6979321856 with 0% used 0% unusable
[36317.467018] BTRFS info (device nullb0): reclaiming chunk 7113539584 with 0% used 0% unusable
[36317.962437] BTRFS info (device nullb0): reclaiming chunk 7247757312 with 0% used 0% unusable
[36348.193354] BTRFS info (device nullb0): reclaiming chunk 7381975040 with 0% used 0% unusable
[36348.949123] BTRFS info (device nullb0): reclaiming chunk 7516192768 with 0% used 0% unusable
[36380.974496] BTRFS info (device nullb0): reclaiming chunk 7650410496 with 0% used 0% unusable
[36411.682610] BTRFS info (device nullb0): reclaiming chunk 7918845952 with 0% used 0% unusable
[36442.378110] BTRFS info (device nullb0): reclaiming chunk 8053063680 with 0% used 0% unusable
[36443.150092] BTRFS info (device nullb0): reclaiming chunk 8187281408 with 1% used 0% unusable
[36476.258491] BTRFS info (device nullb0): reclaiming chunk 8321499136 with 0% used 0% unusable
[36507.987376] BTRFS info (device nullb0): reclaiming chunk 6710886400 with 0% used 0% unusable
[36508.849396] BTRFS info (device nullb0): reclaiming chunk 8589934592 with 0% used 0% unusable
[36509.527574] BTRFS info (device nullb0): reclaiming chunk 8724152320 with 4% used 0% unusable
[36540.699302] BTRFS info (device nullb0): reclaiming chunk 8858370048 with 0% used 0% unusable
[36571.432416] BTRFS info (device nullb0): reclaiming chunk 8992587776 with 0% used 0% unusable
[36604.154750] BTRFS info (device nullb0): reclaiming chunk 9261023232 with 0% used 0% unusable
[36634.948281] BTRFS info (device nullb0): reclaiming chunk 9395240960 with 0% used 0% unusable
[36635.385840] BTRFS info (device nullb0): reclaiming chunk 9529458688 with 0% used 0% unusable

The workload is the git checkout that I've been using so far, the nullb0 device is 1G with 128M zone size. The 'df' numbers look normally:

# ./btrfs fi df /root/btrfs-progs/mnt
Data, single: total=640.00MiB, used=178.33MiB, zone_unusable=198.97MiB
System, single: total=128.00MiB, used=16.00KiB, zone_unusable=1.31MiB
Metadata, single: total=128.00MiB, used=2.16MiB, zone_unusable=98.56MiB
GlobalReserve, single: total=3.25MiB, used=0.00B
kdave commented 3 years ago

Another data point: right before the zone got reclaimed, 'fi df' showed 'zone_unusable=7.12GiB', so the accounting is correct, but the message in the the log had 0 for unusable.

morbidrsa commented 3 years ago

This one's actually fairly trivial to solve. At the point the message get's printed we have already marked the block group as read only, which migrates all zone_unusable bytes to bytes_readonly and sets it to 0. The solution is to cache block_group->zone_unusable before calling inc_block_group_ro().

I'll send a patch with the message improved and fixed shortly.

morbidrsa commented 3 years ago

https://github.com/btrfs/linux/issues/279

kdave commented 3 years ago

Tested, works, thanks.