All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Move the second call to get_request to the end of the loop
@ 2008-05-22  8:29 Zhang, Yanmin
  2008-05-22 13:10 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang, Yanmin @ 2008-05-22  8:29 UTC (permalink / raw)
  To: LKML; +Cc: Jens Axboe

In function get_request_wait, the second call to get_request could be moved to the end of the while loop,
because if the first call to get_request fails, the second call will fail without sleep.

Signed-off-by: Zhang Yanmin <yanmin.zhang@intel.com>

---

--- linux-2.6.26-rc3/block/blk-core.c	2008-05-19 07:17:18.000000000 +0800
+++ linux-2.6.26-rc3_block/block/blk-core.c	2008-05-22 07:00:15.000000000 +0800
@@ -806,35 +806,32 @@ static struct request *get_request_wait(
 	rq = get_request(q, rw_flags, bio, GFP_NOIO);
 	while (!rq) {
 		DEFINE_WAIT(wait);
+		struct io_context *ioc;
 		struct request_list *rl = &q->rq;
 
 		prepare_to_wait_exclusive(&rl->wait[rw], &wait,
 				TASK_UNINTERRUPTIBLE);
 
-		rq = get_request(q, rw_flags, bio, GFP_NOIO);
-
-		if (!rq) {
-			struct io_context *ioc;
+		blk_add_trace_generic(q, bio, rw, BLK_TA_SLEEPRQ);
 
-			blk_add_trace_generic(q, bio, rw, BLK_TA_SLEEPRQ);
-
-			__generic_unplug_device(q);
-			spin_unlock_irq(q->queue_lock);
-			io_schedule();
+		__generic_unplug_device(q);
+		spin_unlock_irq(q->queue_lock);
+		io_schedule();
 
-			/*
-			 * After sleeping, we become a "batching" process and
-			 * will be able to allocate at least one request, and
-			 * up to a big batch of them for a small period time.
-			 * See ioc_batching, ioc_set_batching
-			 */
-			ioc = current_io_context(GFP_NOIO, q->node);
-			ioc_set_batching(q, ioc);
+		/*
+		 * After sleeping, we become a "batching" process and
+		 * will be able to allocate at least one request, and
+		 * up to a big batch of them for a small period time.
+		 * See ioc_batching, ioc_set_batching
+		 */
+		ioc = current_io_context(GFP_NOIO, q->node);
+		ioc_set_batching(q, ioc);
 
-			spin_lock_irq(q->queue_lock);
-		}
+		spin_lock_irq(q->queue_lock);
 		finish_wait(&rl->wait[rw], &wait);
-	}
+
+		rq = get_request(q, rw_flags, bio, GFP_NOIO);
+	};
 
 	return rq;
 }



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

* Re: [PATCH] Move the second call to get_request to the end of the loop
  2008-05-22  8:29 [PATCH] Move the second call to get_request to the end of the loop Zhang, Yanmin
@ 2008-05-22 13:10 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2008-05-22 13:10 UTC (permalink / raw)
  To: Zhang, Yanmin; +Cc: LKML

On Thu, May 22 2008, Zhang, Yanmin wrote:
> In function get_request_wait, the second call to get_request could be
> moved to the end of the while loop, because if the first call to
> get_request fails, the second call will fail without sleep.

Looks safe enough, since we don't drop the lock in between getting the
request and adding to the wait queue. I'll add it to the testing mix,
thanks!


-- 
Jens Axboe


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

end of thread, other threads:[~2008-05-22 13:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-22  8:29 [PATCH] Move the second call to get_request to the end of the loop Zhang, Yanmin
2008-05-22 13:10 ` Jens Axboe

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.