Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1370255 > unrolled thread

[PATCH v2 0/8] block: prepare for multipage bvecs

Started byMing Lei <ming.lei@canonical.com>
First post2016-04-03 18:40 +0200
Last post2016-04-03 18:40 +0200
Articles 4 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH v2 0/8] block: prepare for multipage bvecs Ming Lei <ming.lei@canonical.com> - 2016-04-03 18:40 +0200
    [PATCH v2 6/8] block: bio: remove BIO_MAX_SECTORS Ming Lei <ming.lei@canonical.com> - 2016-04-03 18:40 +0200
    [PATCH v2 4/8] iov_iter: use bvec iterator to implement iterate_bvec() Ming Lei <ming.lei@canonical.com> - 2016-04-03 18:40 +0200
    [PATCH v2 3/8] block: mark 1st parameter of bvec_iter_advance as const Ming Lei <ming.lei@canonical.com> - 2016-04-03 18:40 +0200

#1370255 — [PATCH v2 0/8] block: prepare for multipage bvecs

FromMing Lei <ming.lei@canonical.com>
Date2016-04-03 18:40 +0200
Subject[PATCH v2 0/8] block: prepare for multipage bvecs
Message-ID<rjTea-6bQ-5@gated-at.bofh.it>
Hi,

Interests[1] have been shown in multipage bvecs, so this patchset
try to prepare for the support and do two things:

1) the 1st 4 patches use bvec iterator to implement iterate_bvec(),
then we can drop the non-standard way for iterating bvec, which
can be thought as a good cleanup for lib/iov_iter.c

2) remove BIO_MAX_SECTORS & BIO_MAX_SIZE, and now there is only
one user for each. Once multipage bvecs is introduced, one bio
may hold lots of sectors, and we should always use sort of BIO_MAX_VECS
which should be introduced in future and is similiar with current
BIO_MAX_PAGES.

xfstests(-a auto) have been run and no regression found by this
patchset against linus v4.6-rc1-next-20160329.

V2:
	- rename bvec_iter.h as bvec.h
	- always include bvec.h into blk_types.h as suggested by Christoph

V1:
	- don't move BIO_MAX_* to bvec_iter.h as pointed out by Christoph
	- run xfstests against v4.6-rc1-next-20160329
	- add Reviewed-by
	- for 1,4 and 5, Reviewd-by not added, Christoph still expressed
	'this looks fine to me.'

 drivers/block/drbd/drbd_int.h |  4 +--
 fs/xfs/xfs_buf.c              |  4 +--
 include/linux/bio.h           | 52 --------------------------------
 include/linux/blk_types.h     | 22 +-------------
 include/linux/bvec.h          | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/iov_iter.c                | 30 +++++++------------
 6 files changed, 107 insertions(+), 98 deletions(-)

Thanks,
Ming

[toc] | [next] | [standalone]


#1370256 — [PATCH v2 6/8] block: bio: remove BIO_MAX_SECTORS

FromMing Lei <ming.lei@canonical.com>
Date2016-04-03 18:40 +0200
Subject[PATCH v2 6/8] block: bio: remove BIO_MAX_SECTORS
Message-ID<rjTea-6bQ-23@gated-at.bofh.it>
In reply to#1370255
No one need this macro, so remove it. The motivation is
for supporting multipage bvecs, in which we only know
what the max count of bvecs is supported in the bio,
instead of max size or max sectors.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 include/linux/bio.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/linux/bio.h b/include/linux/bio.h
index 7f998ac..f7e1c27 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -42,7 +42,6 @@
 
 #define BIO_MAX_PAGES		256
 #define BIO_MAX_SIZE		(BIO_MAX_PAGES << PAGE_CACHE_SHIFT)
-#define BIO_MAX_SECTORS		(BIO_MAX_SIZE >> 9)
 
 /*
  * upper 16 bits of bi_rw define the io priority of this bio
-- 
1.9.1

[toc] | [prev] | [next] | [standalone]


#1370257 — [PATCH v2 4/8] iov_iter: use bvec iterator to implement iterate_bvec()

FromMing Lei <ming.lei@canonical.com>
Date2016-04-03 18:40 +0200
Subject[PATCH v2 4/8] iov_iter: use bvec iterator to implement iterate_bvec()
Message-ID<rjTeb-6bQ-29@gated-at.bofh.it>
In reply to#1370255
bvec has provided one iterator already, so not necessary
to reinvent a new wheel for this job.

Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 lib/iov_iter.c | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 5fecddc..c8691ac 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -57,35 +57,25 @@
 }
 
 #define iterate_bvec(i, n, __v, __p, skip, STEP) {	\
-	size_t wanted = n;				\
+	struct bvec_iter __bi, __start;			\
+	__start.bi_size = n;				\
+	__start.bi_bvec_done = skip;			\
+	__start.bi_idx = 0;				\
 	__p = i->bvec;					\
-	__v.bv_len = min_t(size_t, n, __p->bv_len - skip);	\
-	if (likely(__v.bv_len)) {			\
-		__v.bv_page = __p->bv_page;		\
-		__v.bv_offset = __p->bv_offset + skip; 	\
+	for_each_bvec(__v, __p, __bi, __start) {	\
 		(void)(STEP);				\
-		skip += __v.bv_len;			\
-		n -= __v.bv_len;			\
 	}						\
-	while (unlikely(n)) {				\
-		__p++;					\
-		__v.bv_len = min_t(size_t, n, __p->bv_len);	\
-		if (unlikely(!__v.bv_len))		\
-			continue;			\
-		__v.bv_page = __p->bv_page;		\
-		__v.bv_offset = __p->bv_offset;		\
-		(void)(STEP);				\
+	if (!__bi.bi_idx)				\
+		skip += __v.bv_len;			\
+	else						\
 		skip = __v.bv_len;			\
-		n -= __v.bv_len;			\
-	}						\
-	n = wanted;					\
 }
 
 #define iterate_all_kinds(i, n, v, I, B, K) {			\
 	size_t skip = i->iov_offset;				\
 	if (unlikely(i->type & ITER_BVEC)) {			\
 		const struct bio_vec *bvec;			\
-		struct bio_vec v;				\
+		struct bio_vec v = { 0 };			\
 		iterate_bvec(i, n, v, bvec, skip, (B))		\
 	} else if (unlikely(i->type & ITER_KVEC)) {		\
 		const struct kvec *kvec;			\
@@ -102,7 +92,7 @@
 	size_t skip = i->iov_offset;				\
 	if (unlikely(i->type & ITER_BVEC)) {			\
 		const struct bio_vec *bvec;			\
-		struct bio_vec v;				\
+		struct bio_vec v = { 0 };			\
 		iterate_bvec(i, n, v, bvec, skip, (B))		\
 		if (skip == bvec->bv_len) {			\
 			bvec++;					\
-- 
1.9.1

[toc] | [prev] | [next] | [standalone]


#1370258 — [PATCH v2 3/8] block: mark 1st parameter of bvec_iter_advance as const

FromMing Lei <ming.lei@canonical.com>
Date2016-04-03 18:40 +0200
Subject[PATCH v2 3/8] block: mark 1st parameter of bvec_iter_advance as const
Message-ID<rjTeb-6bQ-39@gated-at.bofh.it>
In reply to#1370255
bvec_iter_advance() only writes the parameter of iterator,
so the base address of bvec can be marked as const safely.

Without the change, we can see compiling warning in the
following patch for implementing iterate_bvec(): lib/iov_iter.c
with bvec iterator.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 include/linux/bvec.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/bvec.h b/include/linux/bvec.h
index e111124..0c6fa42 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -63,7 +63,8 @@ struct bvec_iter {
 	.bv_offset	= bvec_iter_offset((bvec), (iter)),	\
 })
 
-static inline void bvec_iter_advance(struct bio_vec *bv, struct bvec_iter *iter,
+static inline void bvec_iter_advance(const struct bio_vec *bv,
+				     struct bvec_iter *iter,
 				     unsigned bytes)
 {
 	WARN_ONCE(bytes > iter->bi_size,
-- 
1.9.1

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web