From patchwork Mon Oct 15 20:09:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 1595961 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by patchwork2.kernel.org (Postfix) with ESMTP id 1954BDFB34 for ; Mon, 15 Oct 2012 20:14:49 +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 q9FKBUDl006996; Mon, 15 Oct 2012 16:11:30 -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 q9FKBAG3027406 for ; Mon, 15 Oct 2012 16:11:10 -0400 Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.18]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9FKB5Uc003439 for ; Mon, 15 Oct 2012 16:11:05 -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 q9FK9m89007505 for ; Mon, 15 Oct 2012 16:11:04 -0400 Received: by mail-pa0-f46.google.com with SMTP id hz1so5214201pad.33 for ; Mon, 15 Oct 2012 13:11:04 -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=CZKx0JTaeV2hq3p9M4+zyfUzF/7O+LDt/Q+g3OpTS2U=; b=VF4dR7uyj+4KBXujt3rGRBFDyjzdAb0SrSUn+3kP/Dwyvecw3982xjxLGw6utNVYur IZM5/rd9a1Vh3JFZLHCi+Fo0nPtyn+CjeE8hfk9KiiwhYocDtf8/dBxTEbjSQ6FpIvCu BvOkPPcZTu/6B71oOQ6Jy3jAe6ipDOTeOW7KaR5TJjzZ6+igg5kAVuXIm/sDksemCHIh 5rt3/Cnk2xMgCbFagpi8JvfPSbQ6NNyc67dWdWJw22+VS9cH9FGk+U+z3hH89JF/5Gz1 5dD5Yih6AqK36hb6ejW+r3PNrmllEB/hyHmA8HiKoLRfRApJXj3u1oP4IAv7FdADCyMQ bMsg== 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=CZKx0JTaeV2hq3p9M4+zyfUzF/7O+LDt/Q+g3OpTS2U=; b=jnCcKVl1cQJV3m8n3Kr7Dz4qFsS3htSs77bYen0GxQeNsp5Q5Dh3MReleF/9q3b7p3 jsmy6CPb+YHOXxhR0adMPHbO5rxeB9Tk92w9GoP6F5Vu85le7dJWEaD0DnBO02jLwlyW LNcFYLGVu7i/+Y9AphfKOR3oJI/GWw1LnI0yjP+DaMOk7z/HdcFNDyStlN3szUZEQ24w OGdFh3yWXTbjiCnb3/z5wWCUjjXludHFWDBG/x2ewLwITcK5d4jjEcb/8LQReBfGGYNQ 316TCppQOgsgtGnywAXjy1X4KXUEv8MmLIMiQInbaWzPJKtus6SNVlM+CNCaUdOTlRAq fBTQ== Received: by 10.66.80.65 with SMTP id p1mr35813679pax.20.1350331864060; Mon, 15 Oct 2012 13:11:04 -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.11.02 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 15 Oct 2012 13:11:03 -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:09:29 -0700 Message-Id: <1350331769-14856-56-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: ALoCoQlORfNRYA4e9hTMjEEoX4er1So1PIL3A58f86/tfhhUJFq4y/mputuVG8xN4lFLgeLGt7MufaNVYB3Ai98bnxosnjHnHZbzcvar+DIkUm1WmJowBL8M+khyI/RQxGyGkru8tXxlHN+rRQ3qR8piCRynwQA5DYxdBU7Ln8aAiT0n+UyY4WCy7V50IMDK4WiFEbfQMTmE 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.25 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.18 X-loop: dm-devel@redhat.com Cc: tj@kernel.org, axboe@kernel.dk, Kent Overstreet Subject: [dm-devel] [PATCH v2 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 --- 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 97511cb..1d4e893 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1638,6 +1638,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 462a131..a77a566 100644 --- a/fs/bio-integrity.c +++ b/fs/bio-integrity.c @@ -621,7 +621,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 5e91e36..d3b6e2a 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 e9375cf..fb49107 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 */