From patchwork Fri Jun 19 07:51:21 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiyoshi Ueda X-Patchwork-Id: 31312 X-Patchwork-Delegate: agk@redhat.com 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 n5J7pfbC001119 for ; Fri, 19 Jun 2009 07:51:41 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 3B9188E01A9; Fri, 19 Jun 2009 03:51:40 -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 n5J7pcT7021771 for ; Fri, 19 Jun 2009 03:51:38 -0400 Received: from mx1.redhat.com (mx1.redhat.com [172.16.48.31]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with SMTP id n5J7pbwZ004734; Fri, 19 Jun 2009 03:51:37 -0400 Received: from tyo201.gate.nec.co.jp (TYO201.gate.nec.co.jp [202.32.8.193]) by mx1.redhat.com (8.13.8/8.13.8) with SMTP id n5J7pNAs016895; Fri, 19 Jun 2009 03:51:24 -0400 Received: from mailgate3.nec.co.jp ([10.7.69.197]) by tyo201.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id n5J7pMMb005244; Fri, 19 Jun 2009 16:51:22 +0900 (JST) Received: (from root@localhost) by mailgate3.nec.co.jp (8.11.7/3.7W-MAILGATE-NEC) id n5J7pMw06930; Fri, 19 Jun 2009 16:51:22 +0900 (JST) Received: from mailsv.linux.bs1.fc.nec.co.jp (mailsv.linux.bs1.fc.nec.co.jp [10.34.125.2]) by mailsv3.nec.co.jp (8.13.8/8.13.4) with ESMTP id n5J7pLYl018668; Fri, 19 Jun 2009 16:51:21 +0900 (JST) Received: from elcondor.linux.bs1.fc.nec.co.jp (elcondor.linux.bs1.fc.nec.co.jp [10.34.125.195]) by mailsv.linux.bs1.fc.nec.co.jp (Postfix) with ESMTP id C4E2DE482EB; Fri, 19 Jun 2009 16:51:21 +0900 (JST) Message-ID: <4A3B4379.1010104@ct.jp.nec.com> Date: Fri, 19 Jun 2009 16:51:21 +0900 From: Kiyoshi Ueda User-Agent: Thunderbird 2.0.0.21 (X11/20090320) MIME-Version: 1.0 To: Alasdair Kergon References: <4A3B40D4.1040905@ct.jp.nec.com> In-Reply-To: <4A3B40D4.1040905@ct.jp.nec.com> X-RedHat-Spam-Score: -0.74 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Scanned-By: MIMEDefang 2.63 on 172.16.48.31 X-loop: dm-devel@redhat.com Cc: device-mapper development Subject: [dm-devel] [PATCH 4/4] dm core: use generic clone setup interface 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 This patch changes to use the block-layer's clone setup interface instead of setting clone up internally in request-based dm. As a result, some internal functions aren't needed anymore, so removed them. Signed-off-by: Kiyoshi Ueda Signed-off-by: Jun'ichi Nomura Cc: Alasdair G Kergon --- drivers/md/dm.c | 94 ++++++++++---------------------------------------------- 1 file changed, 18 insertions(+), 76 deletions(-) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: 2.6.31-rc/drivers/md/dm.c =================================================================== --- 2.6.31-rc.orig/drivers/md/dm.c +++ 2.6.31-rc/drivers/md/dm.c @@ -709,17 +709,6 @@ static void end_clone_bio(struct bio *cl blk_update_request(tio->orig, 0, nr_bytes); } -static void free_bio_clone(struct request *clone) -{ - struct bio *bio; - - while ((bio = clone->bio) != NULL) { - clone->bio = bio->bi_next; - - bio_put(bio); - } -} - /* * Don't touch any member of the md after calling this function because * the md may be freed in dm_put() at the end of this function. @@ -757,7 +746,7 @@ static void dm_unprep_request(struct req rq->special = NULL; rq->cmd_flags &= ~REQ_DONTPREP; - free_bio_clone(clone); + blk_rq_unprep_clone(clone); free_rq_tio(tio); } @@ -1396,85 +1385,38 @@ static void dm_rq_bio_destructor(struct bio_free(bio, md->bs); } -static void copy_request_info(struct request *clone, struct request *rq) -{ - clone->cpu = rq->cpu; - clone->cmd_flags = (rq_data_dir(rq) | REQ_NOMERGE); - clone->cmd_type = rq->cmd_type; - clone->__sector = blk_rq_pos(rq); - clone->__data_len = blk_rq_bytes(rq); - clone->nr_phys_segments = rq->nr_phys_segments; - clone->ioprio = rq->ioprio; - clone->buffer = rq->buffer; - clone->cmd_len = rq->cmd_len; - if (rq->cmd_len) - clone->cmd = rq->cmd; - clone->extra_len = rq->extra_len; - clone->sense = rq->sense; -} - -static int clone_request_bios(struct request *clone, struct request *rq, - struct dm_rq_target_io *tio) +static int dm_rq_bio_constructor(struct bio *bio, struct bio *bio_orig, + void *data) { + struct dm_rq_target_io *tio = data; struct mapped_device *md = tio->md; - struct bio *bio, *clone_bio; - struct dm_rq_clone_bio_info *info; + struct dm_rq_clone_bio_info *info = alloc_bio_info(md); - for (bio = rq->bio; bio; bio = bio->bi_next) { - info = alloc_bio_info(md); - if (!info) - goto free_and_out; - - info->tio = tio; - info->orig = bio; - - clone_bio = bio_alloc_bioset(GFP_ATOMIC, bio->bi_max_vecs, - md->bs); - if (!clone_bio) { - free_bio_info(info); - goto free_and_out; - } - - __bio_clone(clone_bio, bio); - - if (bio_integrity(bio) && - !bio_integrity_clone(clone_bio, bio, GFP_ATOMIC)) { - bio_free(clone_bio, md->bs); - free_bio_info(info); - goto free_and_out; - } + if (!info) + return -ENOMEM; - clone_bio->bi_destructor = dm_rq_bio_destructor; - clone_bio->bi_end_io = end_clone_bio; - clone_bio->bi_private = info; - - if (clone->bio) { - clone->biotail->bi_next = clone_bio; - clone->biotail = clone_bio; - } else - clone->bio = clone->biotail = clone_bio; - } + info->orig = bio_orig; + info->tio = tio; + bio->bi_end_io = end_clone_bio; + bio->bi_private = info; + bio->bi_destructor = dm_rq_bio_destructor; return 0; - -free_and_out: - free_bio_clone(clone); - - return -ENOMEM; } static int setup_clone(struct request *clone, struct request *rq, struct dm_rq_target_io *tio) { - int r; - - blk_rq_init(NULL, clone); + int r = blk_rq_prep_clone(clone, rq, tio->md->bs, GFP_ATOMIC, + dm_rq_bio_constructor, tio); - r = clone_request_bios(clone, rq, tio); if (r) return r; - copy_request_info(clone, rq); + clone->cmd = rq->cmd; + clone->cmd_len = rq->cmd_len; + clone->sense = rq->sense; + clone->buffer = rq->buffer; clone->end_io = end_clone_request; clone->end_io_data = tio;