From patchwork Mon Sep 24 22:35:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 1500821 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 EA6053FE80 for ; Mon, 24 Sep 2012 22:39:16 +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 q8OMbA5D026052; Mon, 24 Sep 2012 18:37:10 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q8OMa8bU009379 for ; Mon, 24 Sep 2012 18:36:08 -0400 Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.19]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q8OMa36o003550 for ; Mon, 24 Sep 2012 18:36:03 -0400 Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8OMZemJ014010 for ; Mon, 24 Sep 2012 18:36:02 -0400 Received: by mail-pa0-f46.google.com with SMTP id hz1so1170170pad.33 for ; Mon, 24 Sep 2012 15:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=xF4j2MiHEfOPujx0P/xkK40rncMYX0i8/1tjqOny4uM=; b=EPmFg41ecvJMRkEU9wVN/fknLJ8mscnsK9TIUknantNjGZIC+WM5yws84zrV65qtsQ GNTzbijKagwCm0vsg0/aKD0P2C2wBt9QIquAdp8SJksnN81/6kF721BLGRTvey4p/BvE k/MWdghXUu0gKuqzk0QD9d5yg5kcMReDpzVVJr0pMI2mMWprQc3f4j66EJGzVADdjcBK zI68iH2y9xsC/1ZSrO94bHJyGeyJjJpNNrxG2cv726AJnG2X6HMhnZ/XgLPuEq3/qHJs Vr1Osp2gYMvIiQ0LsAomsyvBiNegrKmFUExd1Sh56AqFuNoI0FPEOLTt8AJLs3j/Fnzr /gfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=xF4j2MiHEfOPujx0P/xkK40rncMYX0i8/1tjqOny4uM=; b=R3tXkSavi/+rmrGWN+fsYtd+IXgpcP+GcmZGKUoL5w3Rgr8gbP+VNEaT0FKsaCUY2r JfftwOZzSJt/PFhjImd6fAUxtSBZgfxPVu5yho1QW5r98v73e/891cAbaXvXvlPNn6h0 2ImWviYkz4rWUpVSJSlZArUD5d5oQ+lwlvcIUx71rojV5JWxJRQN+gcev0L61ULBk48e 8ux1ZCDW8W2QsWogKkK4cZaxSc6aQ6RCnpvLmjyAcGm444zGxKF9EeuZEII+SnQnnM9U +48G6C0+7fc++X/oWIte3k2ommRvmirziCyPSqRnFJRPxMHyzdBuOgu3yzQAuWZRVMQY NIJg== Received: by 10.66.85.8 with SMTP id d8mr36107636paz.30.1348526161912; Mon, 24 Sep 2012 15:36:01 -0700 (PDT) Received: by 10.66.85.8 with SMTP id d8mr36107620paz.30.1348526161815; Mon, 24 Sep 2012 15:36:01 -0700 (PDT) Received: from formenos.mtv.corp.google.com (formenos.mtv.corp.google.com [172.18.110.66]) by mx.google.com with ESMTPS id nu8sm133316pbc.45.2012.09.24.15.36.00 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 24 Sep 2012 15:36:01 -0700 (PDT) From: Kent Overstreet To: linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com Date: Mon, 24 Sep 2012 15:35:06 -0700 Message-Id: <1348526106-17074-27-git-send-email-koverstreet@google.com> In-Reply-To: <1348526106-17074-1-git-send-email-koverstreet@google.com> References: <1348526106-17074-1-git-send-email-koverstreet@google.com> X-Gm-Message-State: ALoCoQn8czjp/fo2dI6GFmOTbf4sP9kTt6668Mitl0YWqFVwV1DhlYkryPkauX7W9q0qEiuIEELWGDaqntvNp4P6EGbkL6POJaOuYlrKEDeeZKGE1v8omYRRqPTR5mkVT8hTLSJWCzpla3ICpR+YU3A7cKP6sXjcGG9EUU7S5SrABIHFGZQG9bB///+nLx6Ih2vyMwkxW3K6 X-RedHat-Spam-Score: -3.512 (BAYES_00, 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.12 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.19 X-loop: dm-devel@redhat.com Cc: axboe@kernel.dk, "Martin K. Petersen" , Kent Overstreet , vgoyal@redhat.com, tj@kernel.org, Alasdair Kergon Subject: [dm-devel] [PATCH v3 26/26] block: Add BIO_SUBMITTED flag, kill BIO_CLONED 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 BIO_CLONED wasn't very useful, and didn't have very clear semantics, so kill it. Replace it with a more useful flag - BIO_SUBMITTED means the bio has been passed to generic_make_request() and the bvec can no longer be modified. Roll both changes into the same patch so we can steal the old bit for the new flag. Signed-off-by: Kent Overstreet CC: Jens Axboe CC: Alasdair Kergon CC: dm-devel@redhat.com CC: Martin K. Petersen --- block/blk-core.c | 2 ++ drivers/md/dm.c | 1 - fs/bio-integrity.c | 1 - fs/bio.c | 8 +++++--- include/linux/blk_types.h | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index df9bb5f..fcf4335 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1631,6 +1631,8 @@ generic_make_request_checks(struct bio *bio) might_sleep(); + bio->bi_flags |= 1 << BIO_SUBMITTED; + if (bio_check_eod(bio, nr_sectors)) goto end_io; diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 8378797..777e70d 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1065,7 +1065,6 @@ static struct bio *split_bvec(struct bio *bio, sector_t sector, clone->bi_size = to_bytes(len); clone->bi_io_vec->bv_offset = offset; clone->bi_io_vec->bv_len = clone->bi_size; - clone->bi_flags |= 1 << BIO_CLONED; if (bio_integrity(bio)) { bio_integrity_clone(clone, bio, GFP_NOIO); diff --git a/fs/bio-integrity.c b/fs/bio-integrity.c index c5f33b4..93ec7d9 100644 --- a/fs/bio-integrity.c +++ b/fs/bio-integrity.c @@ -623,7 +623,6 @@ void bio_integrity_trim(struct bio *bio, unsigned int offset, BUG_ON(bip == NULL); BUG_ON(bi == NULL); - BUG_ON(!bio_flagged(bio, BIO_CLONED)); nr_sectors = bio_integrity_hw_sectors(bi, sectors); bip->bip_sector = bip->bip_sector + offset; diff --git a/fs/bio.c b/fs/bio.c index 00639e6..dab51bf 100644 --- a/fs/bio.c +++ b/fs/bio.c @@ -531,7 +531,7 @@ void __bio_clone(struct bio *bio, struct bio *bio_src) */ bio->bi_sector = bio_src->bi_sector; bio->bi_bdev = bio_src->bi_bdev; - bio->bi_flags |= 1 << BIO_CLONED; + bio->bi_flags |= (bio_src->bi_flags & (1 << BIO_SUBMITTED)); bio->bi_rw = bio_src->bi_rw; bio->bi_vcnt = bio_src->bi_vcnt; bio->bi_size = bio_src->bi_size; @@ -604,9 +604,9 @@ static int __bio_add_page(struct request_queue *q, struct bio *bio, struct page struct bio_vec *bvec; /* - * cloned bio must not modify vec list + * submitted bio must not modify vec list */ - if (unlikely(bio_flagged(bio, BIO_CLONED))) + if (unlikely(bio_flagged(bio, BIO_SUBMITTED))) return 0; if (((bio->bi_size + len) >> 9) > max_sectors) @@ -844,6 +844,8 @@ int bio_alloc_pages(struct bio *bio, gfp_t gfp_mask) int i; struct bio_vec *bv; + BUG_ON(bio_flagged(bio, BIO_SUBMITTED)); + bio_for_each_segment_all(bv, bio, i) { bv->bv_page = alloc_page(gfp_mask); if (!bv->bv_page) { diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 6547103..3958888 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -103,7 +103,7 @@ struct bio { #define BIO_RW_BLOCK 1 /* RW_AHEAD set, and read/write would block */ #define BIO_EOF 2 /* out-out-bounds error */ #define BIO_SEG_VALID 3 /* bi_phys_segments valid */ -#define BIO_CLONED 4 /* doesn't own data */ +#define BIO_SUBMITTED 4 /* bio has been submitted */ #define BIO_BOUNCED 5 /* bio is a bounce bio */ #define BIO_USER_MAPPED 6 /* contains user pages */ #define BIO_EOPNOTSUPP 7 /* not supported */