From patchwork Wed Mar 27 17:39:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 2352431 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by patchwork1.kernel.org (Postfix) with ESMTP id 2A5D33FC8C for ; Wed, 27 Mar 2013 17:43:44 +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 r2RHeTWG028114; Wed, 27 Mar 2013 13:40:29 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r2RHeSO1011545 for ; Wed, 27 Mar 2013 13:40:28 -0400 Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.20]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r2RHeSSK017428 for ; Wed, 27 Mar 2013 13:40:28 -0400 Received: from mail-da0-f43.google.com (mail-da0-f43.google.com [209.85.210.43]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2RHeQup025324 for ; Wed, 27 Mar 2013 13:40:26 -0400 Received: by mail-da0-f43.google.com with SMTP id u36so4211021dak.30 for ; Wed, 27 Mar 2013 10:40:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=QDSOKppAp9GBjr69ZQm9eT7w/bEDyF9B6I1BWMshB+Q=; b=Q+2g1nDeExdFwetRagdWSN5ueGbuarOWVNcvA7111B9OtqRsuTL3oKq5/3aZkW8YbI C0vZLgJOrWBcWgxPjhvCplUBD89MNm2nUmQxmWyBcT/XXjAtYR8GNgo0TEZqYDONtTkM Bflyj9iKW3fM6i/rQ9NeTS1/uQAzUiBHjnrCYTd0IjQJUNYxce0TYop5s8CB7QYzMXQm D9qSPEzjjE0hi1iM4hSHTefjYEVPZAUAgYKTNjsRpRWbp3eEz58/n4E7w5+rR5rDxjJb +D3KZMeM+nvmpo2Z5oSXiFgmBAaIF66znBAdibZuFufI9GNGvpmrCVZzeXXS5YQbHEnM JWNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=QDSOKppAp9GBjr69ZQm9eT7w/bEDyF9B6I1BWMshB+Q=; b=HuG+dli7NerbYOXhzxbpPdYdhDS3FcX5Jc/vm65IQ+DJs9JKiyv0s0dr0Rj3Kvvo3W uFaYakXj+lIgaJv+v5z+lPBfWSPziElt4yGBXSo7Iwf9uht4sc1X+1CLjF8fxDTmmZrn kdF62oucIEQ11+wNpsJZCIX+hZeG+I6nVilW9lHFQodRY2p2+hHNCRPFxO9R1KDgMQ7B KOCaW8/DT0iQ9FeX/9DVY9voMFPf3u4rdrukmzkNLj6StygSCufPqMsqBI2UitYjVIXa 6zlqOxO3vCxztdjVXtp6vq+otlJK8nk3OSOlrIAQsZxjvdi0tUFYYLJetes/44FLqe3s 5K5g== X-Received: by 10.68.212.233 with SMTP id nn9mr30237547pbc.144.1364406026002; Wed, 27 Mar 2013 10:40:26 -0700 (PDT) Received: from formenos.mtv.corp.google.com (formenos.mtv.corp.google.com [172.18.126.133]) by mx.google.com with ESMTPS id qd8sm22195440pbc.29.2013.03.27.10.40.24 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 27 Mar 2013 10:40:25 -0700 (PDT) From: Kent Overstreet To: axboe@kernel.dk, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, dm-devel@vger.kernel.org Date: Wed, 27 Mar 2013 10:39:37 -0700 Message-Id: <1364405992-28424-8-git-send-email-koverstreet@google.com> In-Reply-To: <1364405992-28424-1-git-send-email-koverstreet@google.com> References: <1364405992-28424-1-git-send-email-koverstreet@google.com> X-Gm-Message-State: ALoCoQkVRwDMhWmrTU+AsA3Sqbo0psDU1DPHI3zxPGApit6sewFO/EPaJ+rdV/GFWhZe13fgXinEM7aP6R1xwN4zN1IKiUhAW26ypXmllBl3v5s/0e2EWQtVqZEGpO0hoKnRogFtvz3lmgzWeg7AoIrrbJfl2alDpk1WBeWfJolqAfFl6ZKF38QuacGggYcMONM3AeT6hRzl X-RedHat-Spam-Score: -4.4 (BAYES_00, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.20 X-loop: dm-devel@redhat.com Cc: tj@kernel.org, Kent Overstreet , dm-devel@redhat.com, Alasdair Kergon Subject: [dm-devel] [PATCH 07/22] dm-verity: convert to bvec iter 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: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com Use the new primitives which respect the current value of bi_idx and bi_bvec_done. Signed-off-by: Kent Overstreet Cc: Alasdair Kergon Cc: dm-devel@redhat.com --- drivers/md/dm-verity.c | 51 +++++++++++++------------------------------------- 1 file changed, 13 insertions(+), 38 deletions(-) diff --git a/drivers/md/dm-verity.c b/drivers/md/dm-verity.c index 782ee42..2d01c33 100644 --- a/drivers/md/dm-verity.c +++ b/drivers/md/dm-verity.c @@ -73,15 +73,10 @@ struct dm_verity_io { sector_t block; unsigned n_blocks; - /* saved bio vector */ - struct bio_vec *io_vec; - unsigned io_vec_size; + struct bvec_iter iter; struct work_struct work; - /* A space for short vectors; longer vectors are allocated separately. */ - struct bio_vec io_vec_inline[DM_VERITY_IO_VEC_INLINE]; - /* * Three variably-size fields follow this struct: * @@ -277,9 +272,9 @@ release_ret_r: static int verity_verify_io(struct dm_verity_io *io) { struct dm_verity *v = io->v; + struct bio *bio = dm_bio_from_per_bio_data(io, v->ti->per_bio_data_size); unsigned b; int i; - unsigned vector = 0, offset = 0; for (b = 0; b < io->n_blocks; b++) { struct shash_desc *desc; @@ -329,31 +324,22 @@ test_block_hash: } todo = 1 << v->data_dev_block_bits; - do { - struct bio_vec *bv; + while (io->iter.bi_size) { u8 *page; - unsigned len; - - BUG_ON(vector >= io->io_vec_size); - bv = &io->io_vec[vector]; - page = kmap_atomic(bv->bv_page); - len = bv->bv_len - offset; - if (likely(len >= todo)) - len = todo; - r = crypto_shash_update(desc, - page + bv->bv_offset + offset, len); + struct bio_vec bv = bio_iovec_iter(bio, io->iter); + + page = kmap_atomic(bv.bv_page); + r = crypto_shash_update(desc, page + bv.bv_offset, + bv.bv_len); kunmap_atomic(page); + if (r < 0) { DMERR("crypto_shash_update failed: %d", r); return r; } - offset += len; - if (likely(offset == bv->bv_len)) { - offset = 0; - vector++; - } - todo -= len; - } while (todo); + + bio_advance_iter(bio, &io->iter, bv.bv_len); + } if (!v->version) { r = crypto_shash_update(desc, v->salt, v->salt_size); @@ -376,8 +362,6 @@ test_block_hash: return -EIO; } } - BUG_ON(vector != io->io_vec_size); - BUG_ON(offset); return 0; } @@ -393,9 +377,6 @@ static void verity_finish_io(struct dm_verity_io *io, int error) bio->bi_end_io = io->orig_bi_end_io; bio->bi_private = io->orig_bi_private; - if (io->io_vec != io->io_vec_inline) - mempool_free(io->io_vec, v->vec_mempool); - bio_endio(bio, error); } @@ -491,13 +472,7 @@ static int verity_map(struct dm_target *ti, struct bio *bio) bio->bi_end_io = verity_end_io; bio->bi_private = io; - io->io_vec_size = bio_segments(bio); - if (io->io_vec_size < DM_VERITY_IO_VEC_INLINE) - io->io_vec = io->io_vec_inline; - else - io->io_vec = mempool_alloc(v->vec_mempool, GFP_NOIO); - memcpy(io->io_vec, __bio_iovec(bio), - io->io_vec_size * sizeof(struct bio_vec)); + io->iter = bio->bi_iter; verity_prefetch_io(v, io);