btrfs: warn for any missed cleanup at btrfs_close_one_device
authorAnand Jain <anand.jain@oracle.com>
Tue, 4 Apr 2023 14:55:11 +0000 (22:55 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 17 Apr 2023 16:01:23 +0000 (18:01 +0200)
During my recent search for the root cause of a reported bug, I realized
that it's a good idea to issue a warning for missed cleanup instead of
using debug-only assertions. Since most installations run with debug off,
missed cleanups and premature calls to close could go unnoticed. However,
these issues are serious enough to warrant reporting and fixing.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c

index eead4a1f53b7f59139b498794ddcfd7da9f06e92..0e3677650a781a7d04794bf8a8e0ca5a23d26d85 100644 (file)
@@ -1150,10 +1150,10 @@ static void btrfs_close_one_device(struct btrfs_device *device)
        device->last_flush_error = 0;
 
        /* Verify the device is back in a pristine state  */
-       ASSERT(!test_bit(BTRFS_DEV_STATE_FLUSH_SENT, &device->dev_state));
-       ASSERT(!test_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state));
-       ASSERT(list_empty(&device->dev_alloc_list));
-       ASSERT(list_empty(&device->post_commit_list));
+       WARN_ON(test_bit(BTRFS_DEV_STATE_FLUSH_SENT, &device->dev_state));
+       WARN_ON(test_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state));
+       WARN_ON(!list_empty(&device->dev_alloc_list));
+       WARN_ON(!list_empty(&device->post_commit_list));
 }
 
 static void close_fs_devices(struct btrfs_fs_devices *fs_devices)