public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6 v2] blk: clean up plug
@ 2015-05-08 17:51 Shaohua Li
  2015-05-08 17:51 ` [PATCH 2/6 v2] sched: always use blk_schedule_flush_plug in io_schedule_out Shaohua Li
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Shaohua Li @ 2015-05-08 17:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: axboe, jmoyer, hch, neilb

Current code looks like inner plug gets flushed with a
blk_finish_plug(). Actually it's a nop. All requests/callbacks are added
to current->plug, while only outmost plug is assigned to current->plug.
So inner plug always has empty request/callback list, which makes
blk_flush_plug_list() a nop. This tries to make the code more clear.

Signed-off-by: Shaohua Li <shli@fb.com>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-core.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index fd154b9..d51ed61 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -3031,21 +3031,20 @@ void blk_start_plug(struct blk_plug *plug)
 {
 	struct task_struct *tsk = current;
 
+	/*
+	 * If this is a nested plug, don't actually assign it.
+	 */
+	if (tsk->plug)
+		return;
+
 	INIT_LIST_HEAD(&plug->list);
 	INIT_LIST_HEAD(&plug->mq_list);
 	INIT_LIST_HEAD(&plug->cb_list);
-
 	/*
-	 * If this is a nested plug, don't actually assign it. It will be
-	 * flushed on its own.
+	 * Store ordering should not be needed here, since a potential
+	 * preempt will imply a full memory barrier
 	 */
-	if (!tsk->plug) {
-		/*
-		 * Store ordering should not be needed here, since a potential
-		 * preempt will imply a full memory barrier
-		 */
-		tsk->plug = plug;
-	}
+	tsk->plug = plug;
 }
 EXPORT_SYMBOL(blk_start_plug);
 
@@ -3192,10 +3191,11 @@ void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)
 
 void blk_finish_plug(struct blk_plug *plug)
 {
+	if (plug != current->plug)
+		return;
 	blk_flush_plug_list(plug, false);
 
-	if (plug == current->plug)
-		current->plug = NULL;
+	current->plug = NULL;
 }
 EXPORT_SYMBOL(blk_finish_plug);
 
-- 
1.8.1


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

end of thread, other threads:[~2015-05-08 20:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-08 17:51 [PATCH 1/6 v2] blk: clean up plug Shaohua Li
2015-05-08 17:51 ` [PATCH 2/6 v2] sched: always use blk_schedule_flush_plug in io_schedule_out Shaohua Li
2015-05-08 17:51 ` [PATCH 3/6 v2] blk-mq: fix plugging in blk_sq_make_request Shaohua Li
2015-05-08 17:51 ` [PATCH 4/6 v2] blk-mq: avoid re-initialize request which is failed in direct dispatch Shaohua Li
2015-05-08 17:51 ` [PATCH 5/6 v2] blk-mq: do limited block plug for multiple queue case Shaohua Li
2015-05-08 17:51 ` [PATCH 6/6 v2] blk-mq: make plug work for mutiple disks and queues Shaohua Li
2015-05-08 20:18 ` [PATCH 1/6 v2] blk: clean up plug Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox