From patchwork Tue Jul 15 19:39:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 4558511 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 28B379F37C for ; Tue, 15 Jul 2014 19:57:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 59C0F2017E for ; Tue, 15 Jul 2014 19:57:49 +0000 (UTC) Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mail.kernel.org (Postfix) with ESMTP id 6642F20179 for ; Tue, 15 Jul 2014 19:57:48 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s6FJqmHC000505; Tue, 15 Jul 2014 15:52:49 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s6FJdt0B006659 for ; Tue, 15 Jul 2014 15:39:55 -0400 Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6FJdsb6023980 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 15 Jul 2014 15:39:55 -0400 Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id s6FJdsP8022865; Tue, 15 Jul 2014 15:39:54 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id s6FJdsJV022861; Tue, 15 Jul 2014 15:39:54 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Tue, 15 Jul 2014 15:39:54 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: "Alasdair G. Kergon" , Mike Snitzer , Jonathan Brassow , Edward Thornber , "Martin K. Petersen" , Jens Axboe , Christoph Hellwig In-Reply-To: Message-ID: References: User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org Subject: [dm-devel] [PATCH 8/15] dm: introduce dm_ask_for_duplicate_bios X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 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 X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP [ this isn't connected to XCOPY, but it is requires for the following device mapper patches to apply cleanly ] This function can be used if the target needs to receive another duplicate of the current bio. Signed-off-by: Mikulas Patocka --- drivers/md/dm.c | 24 +++++++++++++++++++----- include/linux/device-mapper.h | 2 ++ 2 files changed, 21 insertions(+), 5 deletions(-) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-3.16-rc5/drivers/md/dm.c =================================================================== --- linux-3.16-rc5.orig/drivers/md/dm.c 2014-07-14 16:25:29.000000000 +0200 +++ linux-3.16-rc5/drivers/md/dm.c 2014-07-14 16:25:31.000000000 +0200 @@ -1161,9 +1161,9 @@ EXPORT_SYMBOL_GPL(dm_set_target_max_io_l * to make it empty) * The target requires that region 3 is to be sent in the next bio. * - * If the target wants to receive multiple copies of the bio (via num_*bios, etc), - * the partially processed part (the sum of regions 1+2) must be the same for all - * copies of the bio. + * If the target wants to receive multiple copies of the bio with num_*_bios or + * dm_ask_for_duplicate_bio, the partially processed part (the sum of regions + * 1+2) must be the same for all copies of the bio. */ void dm_accept_partial_bio(struct bio *bio, unsigned n_sectors) { @@ -1177,6 +1177,17 @@ void dm_accept_partial_bio(struct bio *b } EXPORT_SYMBOL_GPL(dm_accept_partial_bio); +/* + * The target driver can call this function only from the map routine. The + * target driver requests that the dm sends more duplicates of the current bio. + */ +void dm_ask_for_duplicate_bios(struct bio *bio, unsigned n_duplicates) +{ + struct dm_target_io *tio = container_of(bio, struct dm_target_io, clone); + (*tio->num_bios) += n_duplicates; +} +EXPORT_SYMBOL_GPL(dm_ask_for_duplicate_bios); + static void __map_bio(struct dm_target_io *tio) { int r; @@ -1267,12 +1278,14 @@ static struct dm_target_io *alloc_tio(st static void __clone_and_map_simple_bio(struct clone_info *ci, struct dm_target *ti, - unsigned target_bio_nr, unsigned *len) + unsigned target_bio_nr, unsigned *len, + unsigned *num_bios) { struct dm_target_io *tio = alloc_tio(ci, ti, ci->bio->bi_max_vecs, target_bio_nr); struct bio *clone = &tio->clone; tio->len_ptr = len; + tio->num_bios = num_bios; /* * Discard requests require the bio's inline iovecs be initialized. @@ -1292,7 +1305,7 @@ static void __send_duplicate_bios(struct unsigned target_bio_nr; for (target_bio_nr = 0; target_bio_nr < num_bios; target_bio_nr++) - __clone_and_map_simple_bio(ci, ti, target_bio_nr, len); + __clone_and_map_simple_bio(ci, ti, target_bio_nr, len, &num_bios); } static int __send_empty_flush(struct clone_info *ci) @@ -1318,6 +1331,7 @@ static void __clone_and_map_data_bio(str for (target_bio_nr = 0; target_bio_nr < num_target_bios; target_bio_nr++) { tio = alloc_tio(ci, ti, 0, target_bio_nr); tio->len_ptr = len; + tio->num_bios = &num_target_bios; clone_bio(tio, bio, sector, *len); __map_bio(tio); } Index: linux-3.16-rc5/include/linux/device-mapper.h =================================================================== --- linux-3.16-rc5.orig/include/linux/device-mapper.h 2014-07-14 16:25:29.000000000 +0200 +++ linux-3.16-rc5/include/linux/device-mapper.h 2014-07-14 16:25:31.000000000 +0200 @@ -271,6 +271,7 @@ struct dm_target_io { struct dm_target *ti; unsigned target_bio_nr; unsigned *len_ptr; + unsigned *num_bios; struct bio clone; }; @@ -382,6 +383,7 @@ struct gendisk *dm_disk(struct mapped_de int dm_suspended(struct dm_target *ti); int dm_noflush_suspending(struct dm_target *ti); void dm_accept_partial_bio(struct bio *bio, unsigned n_sectors); +void dm_ask_for_duplicate_bios(struct bio *bio, unsigned n_duplicates); union map_info *dm_get_rq_mapinfo(struct request *rq); struct queue_limits *dm_get_queue_limits(struct mapped_device *md);