From: Christoph Hellwig <hch@lst.de>
To: axboe@kernel.dk, martin.petersen@oracle.com,
philipp.reisner@linbit.com, lars.ellenberg@linbit.com,
target-devel@vger.kernel.org
Cc: linux-block@vger.kernel.org, dm-devel@redhat.com,
linux-scsi@vger.kernel.org, drbd-dev@lists.linbit.com
Subject: [Drbd-dev] [PATCH 8/8] block: use bio_has_data to check if a bio has bvecs
Date: Mon, 10 Apr 2017 18:08:07 +0200 [thread overview]
Message-ID: <20170410160807.23674-9-hch@lst.de> (raw)
In-Reply-To: <20170410160807.23674-1-hch@lst.de>
Now that Write Same is gone and discard bios never have a payload we
can simply use bio_has_data as an indicator that the bio has bvecs
that need to be handled.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/bio.c | 8 +-------
block/blk-merge.c | 9 +--------
include/linux/bio.h | 21 +++++----------------
3 files changed, 7 insertions(+), 31 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index b310e7ef3fbf..1c9f04c30ba9 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -679,15 +679,9 @@ static struct bio *__bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask,
bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector;
bio->bi_iter.bi_size = bio_src->bi_iter.bi_size;
- switch (bio_op(bio)) {
- case REQ_OP_DISCARD:
- case REQ_OP_SECURE_ERASE:
- case REQ_OP_WRITE_ZEROES:
- break;
- default:
+ if (bio_has_data(bio)) {
__bio_for_each_segment(bv, bio_src, iter, iter_src)
bio->bi_io_vec[bio->bi_vcnt++] = bv;
- break;
}
if (bio_integrity(bio_src)) {
diff --git a/block/blk-merge.c b/block/blk-merge.c
index d6c86bfc5722..549d060097f1 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -232,16 +232,9 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q,
struct bio *fbio, *bbio;
struct bvec_iter iter;
- if (!bio)
+ if (!bio || !bio_has_data(bio))
return 0;
- switch (bio_op(bio)) {
- case REQ_OP_DISCARD:
- case REQ_OP_SECURE_ERASE:
- case REQ_OP_WRITE_ZEROES:
- return 0;
- }
-
fbio = bio;
cluster = blk_queue_cluster(q);
seg_size = 0;
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 7a24a1a24967..86bf531f97aa 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -178,26 +178,15 @@ static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter,
static inline unsigned __bio_segments(struct bio *bio, struct bvec_iter *bvec)
{
unsigned segs = 0;
- struct bio_vec bv;
- struct bvec_iter iter;
- /*
- * We special case discard/write same/write zeroes, because they
- * interpret bi_size differently:
- */
+ if (bio_has_data(bio)) {
+ struct bio_vec bv;
+ struct bvec_iter iter;
- switch (bio_op(bio)) {
- case REQ_OP_DISCARD:
- case REQ_OP_SECURE_ERASE:
- case REQ_OP_WRITE_ZEROES:
- return 0;
- default:
- break;
+ __bio_for_each_segment(bv, bio, iter, *bvec)
+ segs++;
}
- __bio_for_each_segment(bv, bio, iter, *bvec)
- segs++;
-
return segs;
}
--
2.11.0
next prev parent reply other threads:[~2017-04-10 16:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-10 16:07 [Drbd-dev] RFC: remove REQ_OP_WRITE_SAME Christoph Hellwig
2017-04-10 16:08 ` [Drbd-dev] [PATCH 1/8] drbd: drop REQ_OP_WRITE_SAME support Christoph Hellwig
2017-04-10 16:08 ` [Drbd-dev] [PATCH 2/8] target: remove iblock WRITE_SAME passthrough support Christoph Hellwig
2017-04-12 5:30 ` Nicholas A. Bellinger
2017-04-12 5:51 ` Christoph Hellwig
2017-06-01 6:27 ` Nicholas A. Bellinger
2017-06-01 6:28 ` Christoph Hellwig
2017-04-10 16:08 ` [Drbd-dev] [PATCH 3/8] sd: remove write same support Christoph Hellwig
2017-04-10 16:08 ` [Drbd-dev] [PATCH 4/8] md: drop WRITE_SAME support Christoph Hellwig
2017-04-10 16:08 ` [Drbd-dev] [PATCH 5/8] dm: remove write same support Christoph Hellwig
2017-04-10 16:08 ` [Drbd-dev] [PATCH 6/8] block: remove REQ_OP_WRITE_SAME support Christoph Hellwig
2017-04-10 16:08 ` [Drbd-dev] [PATCH 7/8] block: remove bio_no_advance_iter Christoph Hellwig
2017-04-10 16:08 ` Christoph Hellwig [this message]
-- strict thread matches above, loose matches on Subject: below --
2017-04-12 8:48 [Drbd-dev] remove REQ_OP_WRITE_SAME Christoph Hellwig
2017-04-12 8:48 ` [Drbd-dev] [PATCH 8/8] block: use bio_has_data to check if a bio has bvecs Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170410160807.23674-9-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=dm-devel@redhat.com \
--cc=drbd-dev@lists.linbit.com \
--cc=lars.ellenberg@linbit.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=philipp.reisner@linbit.com \
--cc=target-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox