All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: raid56: do blk_check_plugged check twice while writing
@ 2022-03-19  1:18 Yusuf Khan
  2022-03-19 18:31 ` Sweet Tea Dorminy
  0 siblings, 1 reply; 2+ messages in thread
From: Yusuf Khan @ 2022-03-19  1:18 UTC (permalink / raw)
  To: linux-btrfs; +Cc: linux-kernel, dsterba, josef, clm, Yusuf Khan

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@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] btrfs: raid56: do blk_check_plugged check twice while writing
  2022-03-19  1:18 [PATCH] btrfs: raid56: do blk_check_plugged check twice while writing Yusuf Khan
@ 2022-03-19 18:31 ` Sweet Tea Dorminy
  0 siblings, 0 replies; 2+ messages in thread
From: Sweet Tea Dorminy @ 2022-03-19 18:31 UTC (permalink / raw)
  To: Yusuf Khan, linux-btrfs; +Cc: linux-kernel, dsterba, josef, clm

Hi Yusuf:

On 3/18/22 21:18, Yusuf Khan wrote:
> Do the check to see if the drive was connected twice in case that
> the first was a fluke.

Block plugging is not actually about checking the connectivity of the 
drive; it's about batching IO submission. Specifically, when a client of 
the block layer (a filesystem or DM device, for instance) knows that it 
needs to send a whole batch of IO to disk from a thread, it can request 
the thread's be temporarily delayed, with blk_start_plug() 
(block/blk-core.c has a lengthy great comment about it). Then it submits 
its batch of requests. Finally, it requests the plug be released. This 
is useful because it can allow better IO by releasing a large, 
potentially better ordered batch at once.

In this particular case, to my understanding, blk_check_plug() checks 
whether the current thread is plugged, and, if it is, it adds the rbio 
to a list; when the plug expires, perhaps from the thread going to 
sleep, the plug callback gets called, specifically btrfs_raid_unplug(), 
which sorts the pending IOs.

As such, it shouldn't be necessary to check whether the thread is 
plugged twice. Your change description is a little light on *why* you'd 
like to check twice; maybe I'm missing something.

Hope this helps,

Sweet Tea


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-19 18:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-19  1:18 [PATCH] btrfs: raid56: do blk_check_plugged check twice while writing Yusuf Khan
2022-03-19 18:31 ` Sweet Tea Dorminy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.