From patchwork Sat Aug 8 04:55:58 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikanth Karthikesan X-Patchwork-Id: 40090 Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n784t0Jc005361 for ; Sat, 8 Aug 2009 04:55:00 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 40EBF8E001E; Sat, 8 Aug 2009 00:55:00 -0400 (EDT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n784ssug026656 for ; Sat, 8 Aug 2009 00:54:54 -0400 Received: from mx3.redhat.com (mx3.redhat.com [172.16.48.32]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n784ssRZ012650; Sat, 8 Aug 2009 00:54:54 -0400 Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by mx3.redhat.com (8.13.8/8.13.8) with ESMTP id n784sdHR016998; Sat, 8 Aug 2009 00:54:39 -0400 Received: from relay2.suse.de (relay-ext.suse.de [195.135.221.8]) by mx2.suse.de (Postfix) with ESMTP id 83CAF86445; Sat, 8 Aug 2009 06:54:37 +0200 (CEST) From: Nikanth Karthikesan Organization: suse.de To: Jens Axboe , Alasdair G Kergon Date: Sat, 8 Aug 2009 10:25:58 +0530 User-Agent: KMail/1.11.1 (Linux/2.6.27.23-0.1-default; KDE/4.2.1; x86_64; ; ) MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200908081025.58865.knikanth@suse.de> X-RedHat-Spam-Score: -3.709 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Scanned-By: MIMEDefang 2.63 on 172.16.48.32 X-loop: dm-devel@redhat.com Cc: Kiyoshi Ueda , dm-devel@redhat.com, linux-kernel@vger.kernel.org Subject: [dm-devel] [PATCH 1/2] Allow delaying initialization of queue after allocation X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com Export a way to delay initializing a request_queue after allocating it. This is needed by device-mapper devices, as they create the queue on device creation time, but they decide whether it would use the elevator and requests only after first successful table load. Only request-based dm-devices use the elevator and requests. Without this either one needs to initialize and free the mempool and elevator, if it was a bio-based dm-device or leave it allocated, as it is currently done. Signed-off-by: Nikanth Karthikesan --- -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel diff --git a/block/blk-core.c b/block/blk-core.c index 4b45435..5db0772 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -495,6 +495,8 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id) if (!q) return NULL; + q->node = node_id; + q->backing_dev_info.unplug_io_fn = blk_backing_dev_unplug; q->backing_dev_info.unplug_io_data = q; q->backing_dev_info.ra_pages = @@ -569,12 +571,25 @@ blk_init_queue_node(request_fn_proc *rfn, spinlock_t *lock, int node_id) if (!q) return NULL; - q->node = node_id; - if (blk_init_free_list(q)) { + if (blk_init_allocated_queue(q, rfn, lock)) { + blk_put_queue(q); kmem_cache_free(blk_requestq_cachep, q); return NULL; } + return q; +} +EXPORT_SYMBOL(blk_init_queue_node); + +int blk_init_allocated_queue(struct request_queue *q, request_fn_proc *rfn, + spinlock_t *lock) +{ + int err = 0; + + err = blk_init_free_list(q); + if (err) + goto out; + /* * if caller didn't supply a lock, they get per-queue locking with * our embedded lock @@ -598,15 +613,20 @@ blk_init_queue_node(request_fn_proc *rfn, spinlock_t *lock, int node_id) /* * all done */ - if (!elevator_init(q, NULL)) { - blk_queue_congestion_threshold(q); - return q; - } + err = elevator_init(q, NULL); + if (err) + goto free_and_out; - blk_put_queue(q); - return NULL; + blk_queue_congestion_threshold(q); + + return 0; + +free_and_out: + mempool_destroy(q->rq.rq_pool); +out: + return err; } -EXPORT_SYMBOL(blk_init_queue_node); +EXPORT_SYMBOL(blk_init_allocated_queue); int blk_get_queue(struct request_queue *q) { diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index e7cb5db..9552961 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -901,6 +901,8 @@ extern void blk_abort_queue(struct request_queue *); extern struct request_queue *blk_init_queue_node(request_fn_proc *rfn, spinlock_t *lock, int node_id); extern struct request_queue *blk_init_queue(request_fn_proc *, spinlock_t *); +extern int blk_init_allocated_queue(struct request_queue *q, + request_fn_proc *rfn, spinlock_t *lock); extern void blk_cleanup_queue(struct request_queue *); extern void blk_queue_make_request(struct request_queue *, make_request_fn *); extern void blk_queue_bounce_limit(struct request_queue *, u64);