• Filipe Manana's avatar
    btrfs: turn space cache writeout failure messages into debug messages · bbcd1f4d
    Filipe Manana authored
    Since commit 1afb648e ("btrfs: use standard debug config option to
    enable free-space-cache debug prints"), we started to log error messages
    that were never logged before since there was no DEBUG macro defined
    anywhere. This started to make test case btrfs/187 to fail very often,
    as it greps for any btrfs error messages in dmesg/syslog and fails if
    any is found:
    
    (...)
    btrfs/186 1s ...  2s
    btrfs/187       - output mismatch (see .../results//btrfs/187.out.bad)
        \--- tests/btrfs/187.out     2019-05-17 12:48:32.537340749 +0100
        \+++ /home/fdmanana/git/hub/xfstests/results//btrfs/187.out.bad ...
        \@@ -1,3 +1,8 @@
         QA output created by 187
         Create a readonly snapshot of 'SCRATCH_MNT' in 'SCRATCH_MNT/snap1'
         Create a readonly snapshot of 'SCRATCH_MNT' in 'SCRATCH_MNT/snap2'
        +[268364.139958] BTRFS error (device sdc): failed to write free space cache for block group 30408704
        +[268380.156503] BTRFS error (device sdc): failed to write free space cache for block group 30408704
        +[268380.161703] BTRFS error (device sdc): failed to write free space cache for block group 30408704
        +[268380.253180] BTRFS error (device sdc): failed to write free space cache for block group 30408704
        ...
        (Run 'diff -u /home/fdmanana/git/hub/xfstests/tests/btrfs/187.out ...
    btrfs/188 4s ...  2s
    (...)
    
    The space cache write failures happen due to ENOSPC when attempting to
    update the free space cache items in the root tree. This happens because
    when starting or joining a transaction we don't know how many block
    groups we will end up changing (due to extent allocation or release) and
    therefore never reserve space for updating free space cache items.
    More often than not, the free space cache writeout succeeds since the
    metadata space info is not yet full nor very close to being full, but
    when it is, the space cache writeout fails with ENOSPC.
    
    Occasional failures to write space caches are not considered critical
    since they can be rebuilt when mounting the filesystem or the next
    attempt to write a free space cache in the next transaction commit might
    succeed, so we used to hide those error messages with a preprocessor
    check for the existence of the DEBUG macro that was never enabled
    anywhere.
    
    A few other generic test cases also trigger the error messages due to
    ENOSPC failure when writing free space caches as well, however they don't
    fail since they don't grep dmesg/syslog for any btrfs specific error
    messages.
    
    So change the messages from 'error' level to 'debug' level, as it doesn't
    make much sense to have error messages triggered only if the debug macro
    is enabled plus, more importantly, the error is not serious nor highly
    unexpected.
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    bbcd1f4d
free-space-cache.c 107 KB