[PATCH] btrfs: raid56: do blk_check_plugged check twice while writing

From: Yusuf Khan
Date: Fri Mar 18 2022 - 21:20:55 EST


Do the check to see if the drive was connected twice in case that
the first was a fluke.

Signed-off-by: Yusuf Khan <yusisamerican@xxxxxxxxx>
---
fs/btrfs/raid56.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index 0e239a4c3b26..f652900d7569 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -1750,18 +1750,23 @@ int raid56_parity_write(struct bio *bio, struct btrfs_io_context *bioc,

cb = blk_check_plugged(btrfs_raid_unplug, fs_info, sizeof(*plug));
if (cb) {
- plug = container_of(cb, struct btrfs_plug_cb, cb);
- if (!plug->info) {
- plug->info = fs_info;
- INIT_LIST_HEAD(&plug->rbio_list);
+ cpu_relax();
+ cb = blk_check_plugged(btrfs_raid_unplug, fs_info, sizeof(*plug));
+ if (cb) {
+ plug = container_of(cb, struct btrfs_plug_cb, cb);
+ if (!plug->info) {
+ plug->info = fs_info;
+ INIT_LIST_HEAD(&plug->rbio_list);
+ }
+ list_add_tail(&rbio->plug_list, &plug->rbio_list);
+ return 0;
}
- list_add_tail(&rbio->plug_list, &plug->rbio_list);
- ret = 0;
- } else {
- ret = __raid56_parity_write(rbio);
- if (ret)
- btrfs_bio_counter_dec(fs_info);
+ btrfs_warn(fs_info,
+"during a write operation, the first check to see if the drive was plugged in failed, seccond check succeeded, write continued");
}
+ ret = __raid56_parity_write(rbio);
+ if (ret)
+ btrfs_bio_counter_dec(fs_info);
return ret;
}

--
2.25.1