[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1455519687-23873-2-git-send-email-ming.lei@canonical.com>
Date: Mon, 15 Feb 2016 15:01:24 +0800
From: Ming Lei <ming.lei@...onical.com>
To: Jens Axboe <axboe@...nel.dk>, linux-kernel@...r.kernel.org
Cc: linux-block@...r.kernel.org, Christoph Hellwig <hch@...radead.org>,
Sagi Grimberg <sagig@....mellanox.co.il>,
Ming Lei <ming.lei@...onical.com>, stable@...r.kernel.org
Subject: [PATCH 1/4] block: bio: introduce helpers to get the 1st and last bvec
After bio splitting is introduced, the splitted bio can
be fast-cloned, which is correct because biovecs has become
immutable since v3.13.
Unfortunately bio_will_gap() isn't ready for this kind of change,
because it figures out the last bvec via 'bi_io_vec[prev->bi_vcnt - 1]'.
This patch introduces two helpers for getting the first and last
bvec of one bio.
Cc: stable@...r.kernel.org # v4.3+
Reported-by: Sagi Grimberg <sagig@....mellanox.co.il>
Cc: Christoph Hellwig <hch@...radead.org>
Signed-off-by: Ming Lei <ming.lei@...onical.com>
---
include/linux/bio.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 5349e68..56d2db8 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -265,6 +265,26 @@ static inline unsigned bio_segments(struct bio *bio)
return segs;
}
+static inline void bio_get_first_bvec(struct bio *bio, struct bio_vec *bv)
+{
+ *bv = bio_iovec(bio);
+}
+
+/*
+ * bio_get_last_bvec() is introduced to get the last bvec of one
+ * bio for bio_will_gap().
+ *
+ * TODO: make it more efficient.
+ */
+static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv)
+{
+ struct bvec_iter iter;
+
+ bio_for_each_segment(*bv, bio, iter)
+ if (bv->bv_len == iter.bi_size)
+ break;
+}
+
/*
* get a reference to a bio, so it won't disappear. the intended use is
* something like:
--
1.9.1
Powered by blists - more mailing lists