From: Kent Overstreet <kmo@daterainc.com>
To: hch@infradead.org, axboe@kernel.dk,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Kent Overstreet <koverstreet@google.com>,
Kent Overstreet <kmo@daterainc.com>
Subject: [PATCH 5/6] convert integrity to new merging
Date: Wed, 25 Sep 2013 13:22:43 -0700 [thread overview]
Message-ID: <1380140564-9030-6-git-send-email-kmo@daterainc.com> (raw)
In-Reply-To: <1380140564-9030-1-git-send-email-kmo@daterainc.com>
From: Kent Overstreet <koverstreet@google.com>
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
---
block/blk-integrity.c | 54 +++++++++++++--------------------------------------
fs/bio-integrity.c | 10 ++++++++++
2 files changed, 24 insertions(+), 40 deletions(-)
diff --git a/block/blk-integrity.c b/block/blk-integrity.c
index 861fcae..22d8e9c 100644
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -43,33 +43,19 @@ static const char *bi_unsupported_name = "unsupported";
*/
int blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio)
{
- struct bio_vec iv, ivprv;
unsigned int segments = 0;
- unsigned int seg_size = 0;
- struct bvec_iter iter;
- int prev = 0;
- bio_for_each_integrity_vec(iv, bio, iter) {
+ for_each_bio(bio) {
+ struct bio_integrity_payload *bip = bio->bi_integrity;
+ struct bvec_iter iter = bip->bip_iter;
- if (prev) {
- if (!BIOVEC_PHYS_MERGEABLE(&ivprv, &iv))
- goto new_segment;
+ while (iter.bi_size) {
+ struct bio_vec iv = bvec_iter_bvec(bip->bip_vec, iter);
+ unsigned nbytes = blk_max_segment(q, &iv);
- if (!BIOVEC_SEG_BOUNDARY(q, &ivprv, &iv))
- goto new_segment;
-
- if (seg_size + iv.bv_len > queue_max_segment_size(q))
- goto new_segment;
-
- seg_size += iv.bv_len;
- } else {
-new_segment:
segments++;
- seg_size = iv.bv_len;
+ bio_advance_iter(bio, &iter, nbytes);
}
-
- prev = 1;
- ivprv = iv;
}
return segments;
@@ -89,27 +75,17 @@ EXPORT_SYMBOL(blk_rq_count_integrity_sg);
int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio,
struct scatterlist *sglist)
{
- struct bio_vec iv, ivprv;
struct scatterlist *sg = NULL;
unsigned int segments = 0;
- struct bvec_iter iter;
- int prev = 0;
- bio_for_each_integrity_vec(iv, bio, iter) {
+ for_each_bio(bio) {
+ struct bio_integrity_payload *bip = bio->bi_integrity;
+ struct bvec_iter iter = bip->bip_iter;
- if (prev) {
- if (!BIOVEC_PHYS_MERGEABLE(&ivprv, &iv))
- goto new_segment;
+ while (iter.bi_size) {
+ struct bio_vec iv= bvec_iter_bvec(bip->bip_vec, iter);
+ unsigned nbytes = blk_max_segment(q, &iv);
- if (!BIOVEC_SEG_BOUNDARY(q, &ivprv, &iv))
- goto new_segment;
-
- if (sg->length + iv.bv_len > queue_max_segment_size(q))
- goto new_segment;
-
- sg->length += iv.bv_len;
- } else {
-new_segment:
if (!sg)
sg = sglist;
else {
@@ -119,10 +95,8 @@ new_segment:
sg_set_page(sg, iv.bv_page, iv.bv_len, iv.bv_offset);
segments++;
+ bio_advance_iter(bio, &iter, nbytes);
}
-
- prev = 1;
- ivprv = iv;
}
if (sg)
diff --git a/fs/bio-integrity.c b/fs/bio-integrity.c
index 31f2d5a..2578c84 100644
--- a/fs/bio-integrity.c
+++ b/fs/bio-integrity.c
@@ -129,6 +129,16 @@ int bio_integrity_add_page(struct bio *bio, struct page *page,
struct bio_integrity_payload *bip = bio->bi_integrity;
struct bio_vec *iv;
+ if (bip->bip_vcnt) {
+ iv = bip->bip_vec + bip->bip_vcnt - 1;
+
+ if (bvec_to_phys(iv) + iv->bv_len ==
+ page_to_phys(page) + offset) {
+ iv->bv_len += len;
+ return len;
+ }
+ }
+
if (bip->bip_vcnt >= bvec_nr_vecs(bip->bip_slab)) {
printk(KERN_ERR "%s: bip_vec full\n", __func__);
return 0;
--
1.8.4.rc3
next prev parent reply other threads:[~2013-09-25 20:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-25 20:22 [PATCH WIP] Multipage biovecs Kent Overstreet
2013-09-25 20:22 ` [PATCH 1/6] block: Introduce bio_for_each_page() Kent Overstreet
2013-09-25 21:17 ` Zach Brown
2013-09-25 21:49 ` Kent Overstreet
2013-09-25 22:47 ` Zach Brown
2013-09-25 20:22 ` [PATCH 2/6] block: Convert various code to bio_for_each_page() Kent Overstreet
2013-09-25 20:22 ` [PATCH 3/6] Introduce blk_max_segment() Kent Overstreet
2013-09-25 20:22 ` [PATCH 4/6] convert nvme to blk_max_segment() Kent Overstreet
2013-09-25 20:22 ` Kent Overstreet [this message]
2013-09-25 20:22 ` [PATCH 6/6] Multipage bvecs Kent Overstreet
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=1380140564-9030-6-git-send-email-kmo@daterainc.com \
--to=kmo@daterainc.com \
--cc=axboe@kernel.dk \
--cc=hch@infradead.org \
--cc=koverstreet@google.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@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;
as well as URLs for NNTP newsgroup(s).