From patchwork Tue Jul 3 18:13:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 10504909 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 41D64601D3 for ; Tue, 3 Jul 2018 18:16:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EE99288CF for ; Tue, 3 Jul 2018 18:16:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2135028D6B; Tue, 3 Jul 2018 18:16:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BF7C0288CF for ; Tue, 3 Jul 2018 18:16:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D75AC307D86D; Tue, 3 Jul 2018 18:16:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C00760A9A; Tue, 3 Jul 2018 18:16:23 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E4A7118037ED; Tue, 3 Jul 2018 18:16:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.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 w63IE3ct022717 for ; Tue, 3 Jul 2018 14:14:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8D3821057FA5; Tue, 3 Jul 2018 18:14:03 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from leontynka.twibright.com (ovpn-204-34.brq.redhat.com [10.40.204.34]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BFC9B10493B4; Tue, 3 Jul 2018 18:14:02 +0000 (UTC) Received: from debian-a64.vm ([192.168.208.2]) by leontynka.twibright.com with smtp (Exim 4.89) (envelope-from ) id 1faPoO-0004Ad-7Y; Tue, 03 Jul 2018 20:14:01 +0200 Received: by debian-a64.vm (sSMTP sendmail emulation); Tue, 03 Jul 2018 20:13:59 +0200 Message-Id: <20180703181359.379386600@debian-a64.vm> User-Agent: quilt/0.65 Date: Tue, 03 Jul 2018 20:13:29 +0200 From: Mikulas Patocka To: Milan Broz , Mike Snitzer MIME-Version: 1.0 Content-Disposition: inline; filename=dm-integrity-move-start-to-get_data_sector.patch X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Mikulas Patocka Subject: [dm-devel] [PATCH 5/9] dm-integrity: add ic->start in get_data_sector X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 03 Jul 2018 18:16:24 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP A small refactoring. Add the variable ic->start in get_data_sector and not in the callers. This is a prerequisite for the patch that uses external metadata device. Signed-off-by: Mikulas Patocka --- drivers/md/dm-integrity.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-2.6/drivers/md/dm-integrity.c =================================================================== --- linux-2.6.orig/drivers/md/dm-integrity.c 2018-06-29 23:14:01.770000000 +0200 +++ linux-2.6/drivers/md/dm-integrity.c 2018-06-29 23:14:01.760000000 +0200 @@ -394,6 +394,8 @@ static sector_t get_data_sector(struct d result += (area + 1) * ic->metadata_run; result += (sector_t)ic->initial_sectors + offset; + result += ic->start; + return result; } @@ -865,7 +867,7 @@ static void copy_from_journal(struct dm_ io_req.notify.context = data; io_req.client = ic->io; io_loc.bdev = ic->dev->bdev; - io_loc.sector = ic->start + target; + io_loc.sector = target; io_loc.count = n_sectors; r = dm_io(&io_req, 1, &io_loc, NULL); @@ -1756,7 +1758,6 @@ offload_to_thread: bio->bi_end_io = integrity_end_io; bio->bi_iter.bi_size = dio->range.n_sectors << SECTOR_SHIFT; - bio->bi_iter.bi_sector += ic->start; generic_make_request(bio); if (need_sync_io) { @@ -2394,7 +2395,7 @@ static int calculate_device_limits(struc get_area_and_offset(ic, ic->provided_data_sectors - 1, &last_area, &last_offset); last_sector = get_data_sector(ic, last_area, last_offset); - if (ic->start + last_sector < last_sector || ic->start + last_sector >= ic->device_sectors) + if (last_sector < ic->start || last_sector >= ic->device_sectors) return -EINVAL; return 0;