From patchwork Mon Oct 15 20:08:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 1595631 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by patchwork1.kernel.org (Postfix) with ESMTP id BC5FF3FD86 for ; Mon, 15 Oct 2012 20:13:33 +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 q9FKBFLP010301; Mon, 15 Oct 2012 16:11:15 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q9FKASbl027042 for ; Mon, 15 Oct 2012 16:10:28 -0400 Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.21]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9FKANnM026660 for ; Mon, 15 Oct 2012 16:10:23 -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 q9FK9gLF018945 for ; Mon, 15 Oct 2012 16:10:22 -0400 Received: by mail-pa0-f46.google.com with SMTP id hz1so5214109pad.33 for ; Mon, 15 Oct 2012 13:10:22 -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=0gIri3B/PfNTMbhimw3ifMEu2xwMlOkLipicU1gTvKQ=; b=Emgh42ctq1bjJLMZ0ZRzEeHeSJtz1zXvlS8kniCXNz1Tdl9TVdXFUI6gFq7uSwx9jQ Ry7TaLNxJVRoFgV5WrHDukTek4pfkV2cp9SnL5MFL3FLUCpYOytxt5XDBca8iWZcq5U7 3YiMyNB3NiA3wVzVqz9vKBULHQML5M2px7bwxHQgN+w0qG+YfrxWGPCKxc0MBtDPP3i/ FJJCmtkvJpcqVe48QuNz8sr540JCvnss2Gt2vZrC5vNz04hsXA9aQ649s+QRgRfiU9cC L3hk5k+AN/LeI7Pi2Vk8z1if6caGw3okRbHJsMREelx7z774MTtYX3fQTWr7lehjaCjh nokQ== 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=0gIri3B/PfNTMbhimw3ifMEu2xwMlOkLipicU1gTvKQ=; b=jxXdWkfEQkNsE5T4VNaXxEMyIQgy2d/dR+KNL6KCJ3IcQk3Wa5BjyL4mUTNPxjWElN bCRTHSruJ15drC7X0Gl6s/5Hc1xODsZEuiUYpIgRq1LK/NU1HD2gWLmkUIaPEV974ar7 pPLAu8X9tVdkPHqi1ZruwSU+csXD8wgPHJoh1wo4BZi9F5E9HSdmE8D60Rtayj4z7s4H 4thuIQH5eMq8VeeWP8L4zCPoV/74Ntu6rPA4vZfmW1Pl4MZ6xHqf2rVGkNNpZT9xRpcv 9zXp1OoB9a2IBhxt9MLDHMhkPhuhiEZOzQPZR9kibcFsGJ/X0tcZ7tlLrudqw1egLJfq OC3w== Received: by 10.68.217.201 with SMTP id pa9mr40352825pbc.45.1350331822454; Mon, 15 Oct 2012 13:10:22 -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 k9sm3021703paz.22.2012.10.15.13.10.21 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 15 Oct 2012 13:10:21 -0700 (PDT) From: Kent Overstreet To: linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com Date: Mon, 15 Oct 2012 13:08:58 -0700 Message-Id: <1350331769-14856-25-git-send-email-koverstreet@google.com> In-Reply-To: <1350331769-14856-1-git-send-email-koverstreet@google.com> References: <1350331769-14856-1-git-send-email-koverstreet@google.com> X-Gm-Message-State: ALoCoQk38PLM/nJywUSVTBFn9Lwb7ruxzXAs/4mnDF3Yhqs1GgMOmKCt3Pr44yNx8n9pHC/AxID8UJFoCXZC3fOOvHGhJhHOkAgv2Yvlui+qyekJdvUYkfx0gpbWWwLip9/0vcqFyBQE77HbkuZc/IldtKFy5LcIx7sbM7Qjv9o+E4RT0IY7ps+ToH0uInE9q6EQeqxmqPTx X-RedHat-Spam-Score: -3.072 (BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.21 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 v4 24/24] 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 8fb4291..352eb0b 100644 --- a/fs/bio-integrity.c +++ b/fs/bio-integrity.c @@ -625,7 +625,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 5dc8441..e8625dc 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 538289f..edc5cb9 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 */