From: Bart Van Assche <bvanassche@acm.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
Bart Van Assche <bvanassche@acm.org>,
Johannes Thumshirn <jthumshirn@suse.de>,
Ming Lei <ming.lei@redhat.com>, Hannes Reinecke <hare@suse.com>
Subject: [PATCH v2 3/5] block: Simplify bvec_split_segs()
Date: Thu, 1 Aug 2019 15:50:42 -0700 [thread overview]
Message-ID: <20190801225044.143478-4-bvanassche@acm.org> (raw)
In-Reply-To: <20190801225044.143478-1-bvanassche@acm.org>
Simplify this function by by removing two if-tests. Other than requiring
that the @sectors pointer is not NULL, this patch does not change the
behavior of bvec_split_segs().
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
block/blk-merge.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 51ed971709c3..7cea5050bbcf 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -167,17 +167,17 @@ static bool bvec_split_segs(const struct request_queue *q,
{
unsigned len = bv->bv_len;
unsigned total_len = 0;
- unsigned new_nsegs = 0, seg_size = 0;
+ unsigned seg_size = 0;
/*
* Multi-page bvec may be too big to hold in one segment, so the
* current bvec has to be splitted as multiple segments.
*/
- while (len && new_nsegs + *nsegs < max_segs) {
+ while (len && *nsegs < max_segs) {
seg_size = get_max_segment_size(q, bv->bv_offset + total_len);
seg_size = min(seg_size, len);
- new_nsegs++;
+ (*nsegs)++;
total_len += seg_size;
len -= seg_size;
@@ -185,11 +185,7 @@ static bool bvec_split_segs(const struct request_queue *q,
break;
}
- if (new_nsegs) {
- *nsegs += new_nsegs;
- if (sectors)
- *sectors += total_len >> 9;
- }
+ *sectors += total_len >> 9;
/* split in the middle of the bvec if len != 0 */
return !!len;
@@ -349,6 +345,7 @@ EXPORT_SYMBOL(blk_queue_split);
unsigned int blk_recalc_rq_segments(struct request *rq)
{
unsigned int nr_phys_segs = 0;
+ unsigned int nr_sectors = 0;
struct req_iterator iter;
struct bio_vec bv;
@@ -365,7 +362,8 @@ unsigned int blk_recalc_rq_segments(struct request *rq)
}
rq_for_each_bvec(bv, rq, iter)
- bvec_split_segs(rq->q, &bv, &nr_phys_segs, NULL, UINT_MAX);
+ bvec_split_segs(rq->q, &bv, &nr_phys_segs, &nr_sectors,
+ UINT_MAX);
return nr_phys_segs;
}
--
2.22.0.770.g0f2c4a37fd-goog
next prev parent reply other threads:[~2019-08-01 22:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-01 22:50 [PATCH v2 0/5] Optimize bio splitting Bart Van Assche
2019-08-01 22:50 ` [PATCH v2 1/5] block: Declare several function pointer arguments 'const' Bart Van Assche
2019-09-13 22:57 ` Chaitanya Kulkarni
2019-08-01 22:50 ` [PATCH v2 2/5] block: Document the bio splitting functions Bart Van Assche
2019-09-13 23:02 ` Chaitanya Kulkarni
2019-08-01 22:50 ` Bart Van Assche [this message]
2019-08-01 22:50 ` [PATCH v2 4/5] block: Simplify blk_bio_segment_split() Bart Van Assche
2019-08-01 22:50 ` [PATCH v2 5/5] block: Improve physical block alignment of split bios Bart Van Assche
2019-08-02 13:36 ` [PATCH v2 0/5] Optimize bio splitting Jens Axboe
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=20190801225044.143478-4-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=hare@suse.com \
--cc=hch@lst.de \
--cc=jthumshirn@suse.de \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).