From patchwork Tue Jul 15 19:37:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 4558191 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 01379C0514 for ; Tue, 15 Jul 2014 19:40:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 58E602018B for ; Tue, 15 Jul 2014 19:40:37 +0000 (UTC) Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mail.kernel.org (Postfix) with ESMTP id 7373D20123 for ; Tue, 15 Jul 2014 19:40:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s6FJbGw1031630; Tue, 15 Jul 2014 15:37:16 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s6FJbFOc001513 for ; Tue, 15 Jul 2014 15:37:15 -0400 Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6FJbE1p031069 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 15 Jul 2014 15:37:14 -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 s6FJbEIE022639; Tue, 15 Jul 2014 15:37:14 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id s6FJbEP0022631; Tue, 15 Jul 2014 15:37:14 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Tue, 15 Jul 2014 15:37:14 -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.22 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 5/15] block copy: use merge_bvec_fn for copies 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 We use merge_bvec_fn to make sure that copies do not split internal boundaries of device mapper devices. There is no possibility to split a copy bio (splitting would complicate the design significantly), so we must use merge_bvec_fn to make sure that the bios have appropriate size for the device mapper stack. Signed-off-by: Mikulas Patocka --- block/blk-lib.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-3.16-rc5/block/blk-lib.c =================================================================== --- linux-3.16-rc5.orig/block/blk-lib.c 2014-07-15 15:27:51.000000000 +0200 +++ linux-3.16-rc5/block/blk-lib.c 2014-07-15 15:27:59.000000000 +0200 @@ -369,6 +369,31 @@ static void bio_copy_end_io(struct bio * } } +static unsigned blkdev_copy_merge(struct block_device *bdev, + struct request_queue *q, unsigned long bi_rw, + sector_t sector, unsigned n) +{ + if (!q->merge_bvec_fn) { + return n; + } else { + unsigned m; + struct bvec_merge_data bvm = { + .bi_bdev = bdev, + .bi_sector = sector, + .bi_size = 0, + .bi_rw = bi_rw, + }; + struct bio_vec vec = { + .bv_page = NULL, + .bv_len = likely(n <= UINT_MAX >> 9) ? n << 9 : UINT_MAX & ~511U, + .bv_offset = 0, + }; + m = q->merge_bvec_fn(q, &bvm, &vec); + m >>= 9; + return min(m, n); + } +} + /** * blkdev_issue_copy - queue a copy same operation * @src_bdev: source blockdev @@ -424,6 +449,18 @@ int blkdev_issue_copy(struct block_devic struct bio_copy *bc; unsigned chunk = (unsigned)min(nr_sects, (sector_t)max_copy_sectors); + chunk = blkdev_copy_merge(src_bdev, sq, READ | REQ_COPY, src_sector, chunk); + if (!chunk) { + ret = -EOPNOTSUPP; + break; + } + + chunk = blkdev_copy_merge(dst_bdev, dq, WRITE | REQ_COPY, dst_sector, chunk); + if (!chunk) { + ret = -EOPNOTSUPP; + break; + } + bc = kmalloc(sizeof(struct bio_copy), gfp_mask); if (!bc) { ret = -ENOMEM;