]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: print a message when a missing device re-appears
authorQu Wenruo <wqu@suse.com>
Tue, 2 Jun 2026 05:26:49 +0000 (14:56 +0930)
committerJohannes Thumshirn <johannes.thumshirn@wdc.com>
Tue, 9 Jun 2026 16:22:46 +0000 (18:22 +0200)
There is a bug report that fstrim crashed, and that crash is eventually
pinned down to a missing device which re-appeared and screwed up callers
that only checks BTRFS_DEV_STATE_MISSING, but not
BTRFS_DEV_STATE_WRITEABLE nor device->bdev.

A missing device re-appearing can be very tricky, as for now it will
result in a device without WRITEABLE or MISSING flag, and still no bdev
pointer.

As the first step to enhance handling of such re-appearing missing
devices, add a dmesg output when a missing device re-appeared.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c

index f409f870a6bcd27494625af17ba347499e9a99f1..6eab4cc73ce44c8d935a57515ebefb6a73ac1dd8 100644 (file)
@@ -963,6 +963,11 @@ static noinline struct btrfs_device *device_list_add(const char *path,
                                          devid, btrfs_dev_name(device),
                                          path, current->comm,
                                          task_pid_nr(current));
+               } else {
+                       btrfs_info(NULL,
+       "missing devid %llu re-appeared at %s scanned by %s (%d)",
+                                  devid, path, current->comm,
+                                  task_pid_nr(current));
                }
 
                name = kstrdup(path, GFP_NOFS);