From patchwork Wed Aug 7 21:54:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 2840655 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 5F9109F493 for ; Wed, 7 Aug 2013 22:57:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 76B252050E for ; Wed, 7 Aug 2013 22:57:01 +0000 (UTC) Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mail.kernel.org (Postfix) with ESMTP id 51E5D20512 for ; Wed, 7 Aug 2013 22:57:00 +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 r77MqriX027283; Wed, 7 Aug 2013 18:52:53 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r77Lt00F005600 for ; Wed, 7 Aug 2013 17:55:00 -0400 Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.20]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r77Lt0O6029416 for ; Wed, 7 Aug 2013 17:55:00 -0400 Received: from mail-pd0-f177.google.com (mail-pd0-f177.google.com [209.85.192.177]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r77LsxXf032589 for ; Wed, 7 Aug 2013 17:54:59 -0400 Received: by mail-pd0-f177.google.com with SMTP id u10so1848786pdi.36 for ; Wed, 07 Aug 2013 14:54:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=14EE5Ou/gKfw8nJ/TdecOPh0vCqExylKosPBYEh6LC0=; b=elFZdo52LhAG93bgx7afD4W7iacaoEVfgMsQvcVEZYqij9aKWIy1yblzcHw1s6r2+I D0W7LHUURTSAagw8icZmHldwN83NYL21W/qr4UE3lMEuIJbget8Msibba9JvspppZXvX qsYyrAjrXY7R07mnifoveHsHQub9VANRFqxJpqdbUicWl5ZA6VkE0gcbL5YJiBHLVBmz L2byhXtA8p3rkziNDjg8ShP4lrH4hAl36w9WgpRXp++iQVc1MdJyHYMDViibkXhf946e QsksRhN1Ed2tPEfeG+T6rxTYSEeaM+S+pQZtC9iR2ghC/jxPQEYq0DbkSaCka2m52wWq fK5A== X-Gm-Message-State: ALoCoQkzYOqTArtskOZN19OURrjT58hiCFvEbPdd5dAWknDCAftwinEKgEiVHTkTRQGkSy71YaUv X-Received: by 10.67.4.136 with SMTP id ce8mr2608683pad.158.1375912498626; Wed, 07 Aug 2013 14:54:58 -0700 (PDT) Received: from localhost.localdomain (173-13-132-141-sfba.hfc.comcastbusiness.net. [173.13.132.141]) by mx.google.com with ESMTPSA id xe9sm12505640pab.0.2013.08.07.14.54.57 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 Aug 2013 14:54:58 -0700 (PDT) From: Kent Overstreet To: axboe@kernel.dk Date: Wed, 7 Aug 2013 14:54:12 -0700 Message-Id: <1375912471-5106-4-git-send-email-kmo@daterainc.com> In-Reply-To: <1375912471-5106-1-git-send-email-kmo@daterainc.com> References: <1375912471-5106-1-git-send-email-kmo@daterainc.com> X-RedHat-Spam-Score: -2.309 (BAYES_00, DCC_REPUT_00_12, RCVD_IN_DNSWL_NONE, URIBL_BLOCKED) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.20 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Wed, 07 Aug 2013 18:51:48 -0400 Cc: Kent Overstreet , linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, dm-devel@redhat.com, linux-fsdevel@vger.kernel.org Subject: [dm-devel] [PATCH 03/22] bcache: Kill unaligned bvec hack 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 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 Bcache has a hack to avoid cloning the biovec if it's all full pages - but with immutable biovecs coming this won't be necessary anymore. For now, we remove the special case and always clone the bvec array so that the immutable biovec patches are simpler. Signed-off-by: Kent Overstreet --- drivers/md/bcache/bcache.h | 1 - drivers/md/bcache/debug.c | 4 ---- drivers/md/bcache/request.c | 32 +++++--------------------------- drivers/md/bcache/request.h | 2 +- drivers/md/bcache/super.c | 4 ---- 5 files changed, 6 insertions(+), 37 deletions(-) diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index b39f6f0..ec5f17c 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h @@ -443,7 +443,6 @@ struct bcache_device { unsigned long sectors_dirty_last; long sectors_dirty_derivative; - mempool_t *unaligned_bvec; struct bio_set *bio_split; unsigned data_csum:1; diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index 88e6411..545680b 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c @@ -191,10 +191,6 @@ void bch_data_verify(struct search *s) struct bio_vec *bv; int i; - if (!s->unaligned_bvec) - bio_for_each_segment(bv, s->orig_bio, i) - bv->bv_offset = 0, bv->bv_len = PAGE_SIZE; - check = bio_clone(s->orig_bio, GFP_NOIO); if (!check) return; diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index 786a1a4..2c2e1c1 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c @@ -679,10 +679,14 @@ static void bio_complete(struct search *s) static void do_bio_hook(struct search *s) { struct bio *bio = &s->bio.bio; - memcpy(bio, s->orig_bio, sizeof(struct bio)); + bio_init(bio); + bio->bi_io_vec = s->bv; + bio->bi_max_vecs = BIO_MAX_PAGES; + __bio_clone(bio, s->orig_bio); bio->bi_end_io = request_endio; bio->bi_private = &s->cl; + atomic_set(&bio->bi_cnt, 3); } @@ -694,16 +698,12 @@ static void search_free(struct closure *cl) if (s->op.cache_bio) bio_put(s->op.cache_bio); - if (s->unaligned_bvec) - mempool_free(s->bio.bio.bi_io_vec, s->d->unaligned_bvec); - closure_debug_destroy(cl); mempool_free(s, s->d->c->search); } static struct search *search_alloc(struct bio *bio, struct bcache_device *d) { - struct bio_vec *bv; struct search *s = mempool_alloc(d->c->search, GFP_NOIO); memset(s, 0, offsetof(struct search, op.keys)); @@ -722,15 +722,6 @@ static struct search *search_alloc(struct bio *bio, struct bcache_device *d) s->start_time = jiffies; do_bio_hook(s); - if (bio->bi_size != bio_segments(bio) * PAGE_SIZE) { - bv = mempool_alloc(d->unaligned_bvec, GFP_NOIO); - memcpy(bv, bio_iovec(bio), - sizeof(struct bio_vec) * bio_segments(bio)); - - s->bio.bio.bi_io_vec = bv; - s->unaligned_bvec = 1; - } - return s; } @@ -780,26 +771,13 @@ static void cached_dev_read_complete(struct closure *cl) static void request_read_error(struct closure *cl) { struct search *s = container_of(cl, struct search, cl); - struct bio_vec *bv; - int i; if (s->recoverable) { /* Retry from the backing device: */ trace_bcache_read_retry(s->orig_bio); s->error = 0; - bv = s->bio.bio.bi_io_vec; do_bio_hook(s); - s->bio.bio.bi_io_vec = bv; - - if (!s->unaligned_bvec) - bio_for_each_segment(bv, s->orig_bio, i) - bv->bv_offset = 0, bv->bv_len = PAGE_SIZE; - else - memcpy(s->bio.bio.bi_io_vec, - bio_iovec(s->orig_bio), - sizeof(struct bio_vec) * - bio_segments(s->orig_bio)); /* XXX: invalidate cache */ diff --git a/drivers/md/bcache/request.h b/drivers/md/bcache/request.h index 57dc478..bee95a9 100644 --- a/drivers/md/bcache/request.h +++ b/drivers/md/bcache/request.h @@ -16,7 +16,6 @@ struct search { unsigned cache_bio_sectors; unsigned recoverable:1; - unsigned unaligned_bvec:1; unsigned write:1; unsigned writeback:1; @@ -27,6 +26,7 @@ struct search { /* Anything past op->keys won't get zeroed in do_bio_hook */ struct btree_op op; + struct bio_vec bv[BIO_MAX_PAGES]; }; void bch_cache_read_endio(struct bio *, int); diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 547c4c5..dc073eb 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -743,8 +743,6 @@ static void bcache_device_free(struct bcache_device *d) put_disk(d->disk); bio_split_pool_free(&d->bio_split_hook); - if (d->unaligned_bvec) - mempool_destroy(d->unaligned_bvec); if (d->bio_split) bioset_free(d->bio_split); if (is_vmalloc_addr(d->stripe_sectors_dirty)) @@ -778,8 +776,6 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size, return -ENOMEM; if (!(d->bio_split = bioset_create(4, offsetof(struct bbio, bio))) || - !(d->unaligned_bvec = mempool_create_kmalloc_pool(1, - sizeof(struct bio_vec) * BIO_MAX_PAGES)) || bio_split_pool_init(&d->bio_split_hook) || !(d->disk = alloc_disk(1)) || !(q = blk_alloc_queue(GFP_KERNEL)))