btrfs: Add enospc_debug printing in metadata_reserve_bytes
authorNikolay Borisov <nborisov@suse.com>
Fri, 15 Dec 2017 10:05:37 +0000 (12:05 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 26 Mar 2018 13:09:35 +0000 (15:09 +0200)
Currently when enospc_debug mount option is turned on we do not print
any debug info in case metadata reservation failures happen. Fix this
by adding the necessary hook in reserve_metadata_bytes.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c

index 9a677860f64d2d623f22767361fe83d84f6924db..85258e85a030cfa54dcc5c2a8fa2a0ac89c7ae01 100644 (file)
@@ -5394,10 +5394,15 @@ static int reserve_metadata_bytes(struct btrfs_root *root,
                    !block_rsv_use_bytes(global_rsv, orig_bytes))
                        ret = 0;
        }
-       if (ret == -ENOSPC)
+       if (ret == -ENOSPC) {
                trace_btrfs_space_reservation(fs_info, "space_info:enospc",
                                              block_rsv->space_info->flags,
                                              orig_bytes, 1);
+
+               if (btrfs_test_opt(fs_info, ENOSPC_DEBUG))
+                       dump_space_info(fs_info, block_rsv->space_info,
+                                       orig_bytes, 0);
+       }
        return ret;
 }