linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 0/8] block: prepare for multipage bvecs
@ 2016-05-30 13:34 Ming Lei
  2016-05-30 13:34 ` [PATCH v6 1/8] block: move bvec iterator into include/linux/bvec.h Ming Lei
                   ` (10 more replies)
  0 siblings, 11 replies; 23+ messages in thread
From: Ming Lei @ 2016-05-30 13:34 UTC (permalink / raw)
  To: Jens Axboe, linux-kernel
  Cc: linux-block, Christoph Hellwig, Ming Lei, Al Viro,
	open list:DRBD DRIVER, Jan Kara, Joe Thornber, Keith Busch,
	Kent Overstreet, Kirill A. Shutemov, Martin K. Petersen,
	Michal Hocko, Mike Snitzer, NeilBrown, Sagi Grimberg, Shaohua Li,
	Steven Whitehouse, Tejun Heo, open list:XFS FILESYSTEM


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 and makre BIO_MAX_SIZE as obsolete, 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.

The only functional change is iterate_bvec():lib/iov_iter.c

xfstests(-a auto) over loop aio is run for ext4/xfs to verify 
the change and no regression found with this patchset.

V6:
	- rebased on v4.7-rc1
	- add reviewed-by tag
	- mark BIO_MAX_SIZE as obsolete instead of removing because
	dm-tree adds one usage now

V5:
	- use bvec's iterator to figure new base vec address and
	update 'skip' correctly
	- run xfstests(-a auto) on loop aio/dio for verifying
	the change in iterate_bvec(), and no regression reported
	- use stree-ng to trigger heavy swap over swapfile to verify
	change in iterate_bvec() too, looks everything is fine
V4:
	- make xfstests cover xfs
	- rebase on for-next of block tree
V3:
	- include kenrel.h & bug.h in bvec.h for fix comiling failure on arm
	as reported by 0day ktest
	- build test on arm & arm64

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.'


Ming Lei (8):
  block: move bvec iterator into include/linux/bvec.h
  block: move two bvec structure into bvec.h
  block: mark 1st parameter of bvec_iter_advance as const
  iov_iter: use bvec iterator to implement iterate_bvec()
  fs: xfs: replace BIO_MAX_SECTORS with BIO_MAX_PAGES
  block: bio: remove BIO_MAX_SECTORS
  block: drbd: avoid to use BIO_MAX_SIZE
  block: mark BIO_MAX_SIZE as obsolete

 drivers/block/drbd/drbd_int.h |  4 +-
 fs/xfs/xfs_buf.c              |  4 +-
 include/linux/bio.h           | 58 ++++----------------------
 include/linux/blk_types.h     | 22 +---------
 include/linux/bvec.h          | 96 +++++++++++++++++++++++++++++++++++++++++++
 lib/iov_iter.c                | 45 +++++++-------------
 6 files changed, 122 insertions(+), 107 deletions(-)
 create mode 100644 include/linux/bvec.h

-- 
1.9.1

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v6 1/8] block: move bvec iterator into include/linux/bvec.h
  2016-05-30 13:34 [PATCH v6 0/8] block: prepare for multipage bvecs Ming Lei
@ 2016-05-30 13:34 ` Ming Lei
  2016-05-30 13:34 ` [PATCH v6 2/8] block: move two bvec structure into bvec.h Ming Lei
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 23+ messages in thread
From: Ming Lei @ 2016-05-30 13:34 UTC (permalink / raw)
  To: Jens Axboe, linux-kernel
  Cc: linux-block, Christoph Hellwig, Ming Lei, Keith Busch,
	Kirill A. Shutemov, Ming Lin, Mike Snitzer, Tejun Heo

bvec iterator helpers should be used to implement by
iterate_bvec():lib/iov_iter.c too, and move them into
one header, so that we can keep bvec iterator header
out of CONFIG_BLOCK. Then we can remove the reinventing
of wheel in iterate_bvec().

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 include/linux/bio.h  | 51 +-----------------------------------
 include/linux/bvec.h | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+), 50 deletions(-)
 create mode 100644 include/linux/bvec.h

diff --git a/include/linux/bio.h b/include/linux/bio.h
index 9faebf7..ed4bfb9 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -31,6 +31,7 @@
 
 /* struct bio, bio_vec and BIO_* flags are defined in blk_types.h */
 #include <linux/blk_types.h>
+#include <linux/bvec.h>
 
 #define BIO_DEBUG
 
@@ -57,29 +58,6 @@
 	(bio)->bi_rw |= ((unsigned long) (prio) << BIO_PRIO_SHIFT);	\
 } while (0)
 
-/*
- * various member access, note that bio_data should of course not be used
- * on highmem page vectors
- */
-#define __bvec_iter_bvec(bvec, iter)	(&(bvec)[(iter).bi_idx])
-
-#define bvec_iter_page(bvec, iter)				\
-	(__bvec_iter_bvec((bvec), (iter))->bv_page)
-
-#define bvec_iter_len(bvec, iter)				\
-	min((iter).bi_size,					\
-	    __bvec_iter_bvec((bvec), (iter))->bv_len - (iter).bi_bvec_done)
-
-#define bvec_iter_offset(bvec, iter)				\
-	(__bvec_iter_bvec((bvec), (iter))->bv_offset + (iter).bi_bvec_done)
-
-#define bvec_iter_bvec(bvec, iter)				\
-((struct bio_vec) {						\
-	.bv_page	= bvec_iter_page((bvec), (iter)),	\
-	.bv_len		= bvec_iter_len((bvec), (iter)),	\
-	.bv_offset	= bvec_iter_offset((bvec), (iter)),	\
-})
-
 #define bio_iter_iovec(bio, iter)				\
 	bvec_iter_bvec((bio)->bi_io_vec, (iter))
 
@@ -193,33 +171,6 @@ static inline void *bio_data(struct bio *bio)
 #define bio_for_each_segment_all(bvl, bio, i)				\
 	for (i = 0, bvl = (bio)->bi_io_vec; i < (bio)->bi_vcnt; i++, bvl++)
 
-static inline void bvec_iter_advance(struct bio_vec *bv, struct bvec_iter *iter,
-				     unsigned bytes)
-{
-	WARN_ONCE(bytes > iter->bi_size,
-		  "Attempted to advance past end of bvec iter\n");
-
-	while (bytes) {
-		unsigned len = min(bytes, bvec_iter_len(bv, *iter));
-
-		bytes -= len;
-		iter->bi_size -= len;
-		iter->bi_bvec_done += len;
-
-		if (iter->bi_bvec_done == __bvec_iter_bvec(bv, *iter)->bv_len) {
-			iter->bi_bvec_done = 0;
-			iter->bi_idx++;
-		}
-	}
-}
-
-#define for_each_bvec(bvl, bio_vec, iter, start)			\
-	for (iter = (start);						\
-	     (iter).bi_size &&						\
-		((bvl = bvec_iter_bvec((bio_vec), (iter))), 1);	\
-	     bvec_iter_advance((bio_vec), &(iter), (bvl).bv_len))
-
-
 static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter,
 				    unsigned bytes)
 {
diff --git a/include/linux/bvec.h b/include/linux/bvec.h
new file mode 100644
index 0000000..29c459d
--- /dev/null
+++ b/include/linux/bvec.h
@@ -0,0 +1,74 @@
+/*
+ * bvec iterator
+ *
+ * Copyright (C) 2001 Ming Lei <ming.lei@canonical.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public Licens
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-
+ */
+#ifndef __LINUX_BVEC_ITER_H
+#define __LINUX_BVEC_ITER_H
+
+#include <linux/blk_types.h>
+
+/*
+ * various member access, note that bio_data should of course not be used
+ * on highmem page vectors
+ */
+#define __bvec_iter_bvec(bvec, iter)	(&(bvec)[(iter).bi_idx])
+
+#define bvec_iter_page(bvec, iter)				\
+	(__bvec_iter_bvec((bvec), (iter))->bv_page)
+
+#define bvec_iter_len(bvec, iter)				\
+	min((iter).bi_size,					\
+	    __bvec_iter_bvec((bvec), (iter))->bv_len - (iter).bi_bvec_done)
+
+#define bvec_iter_offset(bvec, iter)				\
+	(__bvec_iter_bvec((bvec), (iter))->bv_offset + (iter).bi_bvec_done)
+
+#define bvec_iter_bvec(bvec, iter)				\
+((struct bio_vec) {						\
+	.bv_page	= bvec_iter_page((bvec), (iter)),	\
+	.bv_len		= bvec_iter_len((bvec), (iter)),	\
+	.bv_offset	= bvec_iter_offset((bvec), (iter)),	\
+})
+
+static inline void bvec_iter_advance(struct bio_vec *bv, struct bvec_iter *iter,
+				     unsigned bytes)
+{
+	WARN_ONCE(bytes > iter->bi_size,
+		  "Attempted to advance past end of bvec iter\n");
+
+	while (bytes) {
+		unsigned len = min(bytes, bvec_iter_len(bv, *iter));
+
+		bytes -= len;
+		iter->bi_size -= len;
+		iter->bi_bvec_done += len;
+
+		if (iter->bi_bvec_done == __bvec_iter_bvec(bv, *iter)->bv_len) {
+			iter->bi_bvec_done = 0;
+			iter->bi_idx++;
+		}
+	}
+}
+
+#define for_each_bvec(bvl, bio_vec, iter, start)			\
+	for (iter = (start);						\
+	     (iter).bi_size &&						\
+		((bvl = bvec_iter_bvec((bio_vec), (iter))), 1);	\
+	     bvec_iter_advance((bio_vec), &(iter), (bvl).bv_len))
+
+#endif /* __LINUX_BVEC_ITER_H */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v6 2/8] block: move two bvec structure into bvec.h
  2016-05-30 13:34 [PATCH v6 0/8] block: prepare for multipage bvecs Ming Lei
  2016-05-30 13:34 ` [PATCH v6 1/8] block: move bvec iterator into include/linux/bvec.h Ming Lei
@ 2016-05-30 13:34 ` Ming Lei
  2016-05-30 13:34 ` [PATCH v6 3/8] block: mark 1st parameter of bvec_iter_advance as const Ming Lei
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 23+ messages in thread
From: Ming Lei @ 2016-05-30 13:34 UTC (permalink / raw)
  To: Jens Axboe, linux-kernel
  Cc: linux-block, Christoph Hellwig, Ming Lei, Keith Busch,
	Kent Overstreet, Michal Hocko, Kirill A. Shutemov, Tejun Heo,
	Mike Snitzer, Jan Kara, Shaohua Li

This patch moves 'struct bio_vec' and 'struct bvec_iter'
into 'include/linux/bvec.h', then always include this header
into 'include/linux/blk_types.h'.

With this change, both 'struct bvec_iter' and bvec iterator
helpers don't depend on CONFIG_BLOCK any more, then we can
use bvec iterator to implement iterate_bvec(): lib/iov_iter.c.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 include/linux/bio.h       |  1 -
 include/linux/blk_types.h | 22 +---------------------
 include/linux/bvec.h      | 23 ++++++++++++++++++++++-
 3 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/include/linux/bio.h b/include/linux/bio.h
index ed4bfb9..8555b90 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -31,7 +31,6 @@
 
 /* struct bio, bio_vec and BIO_* flags are defined in blk_types.h */
 #include <linux/blk_types.h>
-#include <linux/bvec.h>
 
 #define BIO_DEBUG
 
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 77e5d81..dadc240 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -6,6 +6,7 @@
 #define __LINUX_BLK_TYPES_H
 
 #include <linux/types.h>
+#include <linux/bvec.h>
 
 struct bio_set;
 struct bio;
@@ -17,28 +18,7 @@ struct cgroup_subsys_state;
 typedef void (bio_end_io_t) (struct bio *);
 typedef void (bio_destructor_t) (struct bio *);
 
-/*
- * was unsigned short, but we might as well be ready for > 64kB I/O pages
- */
-struct bio_vec {
-	struct page	*bv_page;
-	unsigned int	bv_len;
-	unsigned int	bv_offset;
-};
-
 #ifdef CONFIG_BLOCK
-
-struct bvec_iter {
-	sector_t		bi_sector;	/* device address in 512 byte
-						   sectors */
-	unsigned int		bi_size;	/* residual I/O count */
-
-	unsigned int		bi_idx;		/* current index into bvl_vec */
-
-	unsigned int            bi_bvec_done;	/* number of bytes completed in
-						   current bvec */
-};
-
 /*
  * main unit of I/O for the block layer and lower layers (ie drivers and
  * stacking drivers)
diff --git a/include/linux/bvec.h b/include/linux/bvec.h
index 29c459d..096efd2 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -20,7 +20,28 @@
 #ifndef __LINUX_BVEC_ITER_H
 #define __LINUX_BVEC_ITER_H
 
-#include <linux/blk_types.h>
+#include <linux/kernel.h>
+#include <linux/bug.h>
+
+/*
+ * was unsigned short, but we might as well be ready for > 64kB I/O pages
+ */
+struct bio_vec {
+	struct page	*bv_page;
+	unsigned int	bv_len;
+	unsigned int	bv_offset;
+};
+
+struct bvec_iter {
+	sector_t		bi_sector;	/* device address in 512 byte
+						   sectors */
+	unsigned int		bi_size;	/* residual I/O count */
+
+	unsigned int		bi_idx;		/* current index into bvl_vec */
+
+	unsigned int            bi_bvec_done;	/* number of bytes completed in
+						   current bvec */
+};
 
 /*
  * various member access, note that bio_data should of course not be used
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v6 3/8] block: mark 1st parameter of bvec_iter_advance as const
  2016-05-30 13:34 [PATCH v6 0/8] block: prepare for multipage bvecs Ming Lei
  2016-05-30 13:34 ` [PATCH v6 1/8] block: move bvec iterator into include/linux/bvec.h Ming Lei
  2016-05-30 13:34 ` [PATCH v6 2/8] block: move two bvec structure into bvec.h Ming Lei
@ 2016-05-30 13:34 ` Ming Lei
  2016-05-30 13:34 ` [PATCH v6 4/8] iov_iter: use bvec iterator to implement iterate_bvec() Ming Lei
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 23+ messages in thread
From: Ming Lei @ 2016-05-30 13:34 UTC (permalink / raw)
  To: Jens Axboe, linux-kernel; +Cc: linux-block, Christoph Hellwig, Ming Lei

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 096efd2..701b64a 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -66,7 +66,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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v6 4/8] iov_iter: use bvec iterator to implement iterate_bvec()
  2016-05-30 13:34 [PATCH v6 0/8] block: prepare for multipage bvecs Ming Lei
                   ` (2 preceding siblings ...)
  2016-05-30 13:34 ` [PATCH v6 3/8] block: mark 1st parameter of bvec_iter_advance as const Ming Lei
@ 2016-05-30 13:34 ` Ming Lei
  2016-05-30 13:34 ` [PATCH v6 5/8] fs: xfs: replace BIO_MAX_SECTORS with BIO_MAX_PAGES Ming Lei
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 23+ messages in thread
From: Ming Lei @ 2016-05-30 13:34 UTC (permalink / raw)
  To: Jens Axboe, linux-kernel
  Cc: linux-block, Christoph Hellwig, Ming Lei, Al Viro

bvec has one native/mature iterator for long time, so not
necessary to use the reinvented wheel for iterating bvecs
in lib/iov_iter.c.

Two ITER_BVEC test cases are run:
	- xfstest(-g auto) on loop dio/aio, no regression found
	- swap file works well under extreme stress(stress-ng --all 64 -t
	  800 -v), and lots of OOMs are triggerd, and the whole
	system still survives

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 lib/iov_iter.c | 45 +++++++++++++++------------------------------
 1 file changed, 15 insertions(+), 30 deletions(-)

diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 0cd5227..d67c828 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -56,37 +56,24 @@
 	n = wanted;					\
 }
 
-#define iterate_bvec(i, n, __v, __p, skip, STEP) {	\
-	size_t wanted = n;				\
-	__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; 	\
-		(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))		\
+#define iterate_bvec(i, n, __v, __bi, skip, STEP) {	\
+	struct bvec_iter __start;			\
+	__start.bi_size = n;				\
+	__start.bi_bvec_done = skip;			\
+	__start.bi_idx = 0;				\
+	for_each_bvec(__v, i->bvec, __bi, __start) {	\
+		if (!__v.bv_len)			\
 			continue;			\
-		__v.bv_page = __p->bv_page;		\
-		__v.bv_offset = __p->bv_offset;		\
 		(void)(STEP);				\
-		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;				\
-		iterate_bvec(i, n, v, bvec, skip, (B))		\
+		struct bvec_iter __bi;				\
+		iterate_bvec(i, n, v, __bi, skip, (B))		\
 	} else if (unlikely(i->type & ITER_KVEC)) {		\
 		const struct kvec *kvec;			\
 		struct kvec v;					\
@@ -104,15 +91,13 @@
 	if (i->count) {						\
 		size_t skip = i->iov_offset;			\
 		if (unlikely(i->type & ITER_BVEC)) {		\
-			const struct bio_vec *bvec;		\
+			const struct bio_vec *bvec = i->bvec;	\
 			struct bio_vec v;			\
-			iterate_bvec(i, n, v, bvec, skip, (B))	\
-			if (skip == bvec->bv_len) {		\
-				bvec++;				\
-				skip = 0;			\
-			}					\
-			i->nr_segs -= bvec - i->bvec;		\
-			i->bvec = bvec;				\
+			struct bvec_iter __bi;			\
+			iterate_bvec(i, n, v, __bi, skip, (B))	\
+			i->bvec = __bvec_iter_bvec(i->bvec, __bi);	\
+			i->nr_segs -= i->bvec - bvec;		\
+			skip = __bi.bi_bvec_done;		\
 		} else if (unlikely(i->type & ITER_KVEC)) {	\
 			const struct kvec *kvec;		\
 			struct kvec v;				\
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v6 5/8] fs: xfs: replace BIO_MAX_SECTORS with BIO_MAX_PAGES
  2016-05-30 13:34 [PATCH v6 0/8] block: prepare for multipage bvecs Ming Lei
                   ` (3 preceding siblings ...)
  2016-05-30 13:34 ` [PATCH v6 4/8] iov_iter: use bvec iterator to implement iterate_bvec() Ming Lei
@ 2016-05-30 13:34 ` Ming Lei
  2016-06-01 13:48   ` Christoph Hellwig
  2016-05-30 13:34 ` [PATCH v6 6/8] block: bio: remove BIO_MAX_SECTORS Ming Lei
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 23+ messages in thread
From: Ming Lei @ 2016-05-30 13:34 UTC (permalink / raw)
  To: Jens Axboe, linux-kernel
  Cc: linux-block, Christoph Hellwig, Ming Lei, Dave Chinner,
	supporter:XFS FILESYSTEM

BIO_MAX_PAGES is used as maximum count of bvecs, so
replace BIO_MAX_SECTORS with BIO_MAX_PAGES since
BIO_MAX_SECTORS is to be removed.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 fs/xfs/xfs_buf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index e71cfbd..e5d713b 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1157,9 +1157,7 @@ xfs_buf_ioapply_map(
 
 next_chunk:
 	atomic_inc(&bp->b_io_remaining);
-	nr_pages = BIO_MAX_SECTORS >> (PAGE_SHIFT - BBSHIFT);
-	if (nr_pages > total_nr_pages)
-		nr_pages = total_nr_pages;
+	nr_pages = min(total_nr_pages, BIO_MAX_PAGES);
 
 	bio = bio_alloc(GFP_NOIO, nr_pages);
 	bio->bi_bdev = bp->b_target->bt_bdev;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v6 6/8] block: bio: remove BIO_MAX_SECTORS
  2016-05-30 13:34 [PATCH v6 0/8] block: prepare for multipage bvecs Ming Lei
                   ` (4 preceding siblings ...)
  2016-05-30 13:34 ` [PATCH v6 5/8] fs: xfs: replace BIO_MAX_SECTORS with BIO_MAX_PAGES Ming Lei
@ 2016-05-30 13:34 ` Ming Lei
  2016-05-30 13:34 ` [PATCH v6 7/8] block: drbd: avoid to use BIO_MAX_SIZE Ming Lei
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 23+ messages in thread
From: Ming Lei @ 2016-05-30 13:34 UTC (permalink / raw)
  To: Jens Axboe, linux-kernel
  Cc: linux-block, Christoph Hellwig, Ming Lei, Keith Busch, NeilBrown,
	Tejun Heo, Mike Snitzer

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 8555b90..fb59a06 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_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

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v6 7/8] block: drbd: avoid to use BIO_MAX_SIZE
  2016-05-30 13:34 [PATCH v6 0/8] block: prepare for multipage bvecs Ming Lei
                   ` (5 preceding siblings ...)
  2016-05-30 13:34 ` [PATCH v6 6/8] block: bio: remove BIO_MAX_SECTORS Ming Lei
@ 2016-05-30 13:34 ` Ming Lei
  2016-05-30 13:34 ` [PATCH v6 8/8] block: mark BIO_MAX_SIZE as obsolete Ming Lei
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 23+ messages in thread
From: Ming Lei @ 2016-05-30 13:34 UTC (permalink / raw)
  To: Jens Axboe, linux-kernel
  Cc: linux-block, Christoph Hellwig, Ming Lei, Philipp Reisner,
	Lars Ellenberg, open list:DRBD DRIVER

Use BIO_MAX_PAGES instead and we will remove BIO_MAX_SIZE.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 drivers/block/drbd/drbd_int.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 7a1cf7e..e6e4b08 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -1327,14 +1327,14 @@ struct bm_extent {
 #endif
 #endif
 
-/* BIO_MAX_SIZE is 256 * PAGE_SIZE,
+/* Estimate max bio size as 256 * PAGE_SIZE,
  * so for typical PAGE_SIZE of 4k, that is (1<<20) Byte.
  * Since we may live in a mixed-platform cluster,
  * we limit us to a platform agnostic constant here for now.
  * A followup commit may allow even bigger BIO sizes,
  * once we thought that through. */
 #define DRBD_MAX_BIO_SIZE (1U << 20)
-#if DRBD_MAX_BIO_SIZE > BIO_MAX_SIZE
+#if DRBD_MAX_BIO_SIZE > (BIO_MAX_PAGES << PAGE_SHIFT)
 #error Architecture not supported: DRBD_MAX_BIO_SIZE > BIO_MAX_SIZE
 #endif
 #define DRBD_MAX_BIO_SIZE_SAFE (1U << 12)       /* Works always = 4k */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v6 8/8] block: mark BIO_MAX_SIZE as obsolete
  2016-05-30 13:34 [PATCH v6 0/8] block: prepare for multipage bvecs Ming Lei
                   ` (6 preceding siblings ...)
  2016-05-30 13:34 ` [PATCH v6 7/8] block: drbd: avoid to use BIO_MAX_SIZE Ming Lei
@ 2016-05-30 13:34 ` Ming Lei
  2016-05-31 16:07   ` Jens Axboe
  2016-05-31 15:53 ` [PATCH v6 0/8] block: prepare for multipage bvecs Mike Snitzer
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 23+ messages in thread
From: Ming Lei @ 2016-05-30 13:34 UTC (permalink / raw)
  To: Jens Axboe, linux-kernel
  Cc: linux-block, Christoph Hellwig, Ming Lei, Keith Busch,
	Kirill A. Shutemov, Kent Overstreet, Mike Snitzer

Some in-tree drivers may use big bio which size is more
than BIO_MAX_SIZE, also the macro is seldom used in tree.

So mark it as obsolete now, and it doesn't make sense
after multipage bvec is introduced.

Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 include/linux/bio.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/bio.h b/include/linux/bio.h
index fb59a06..b284595 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -41,6 +41,13 @@
 #endif
 
 #define BIO_MAX_PAGES		256
+
+/*
+ * This is obsolete now and shouldn't be used, and the macro
+ * doesn't make any sense especially when multipage bvecs is
+ * supported. Even now some drivers may pass big bio which size
+ * is more than the value, such as bcache.
+ */
 #define BIO_MAX_SIZE		(BIO_MAX_PAGES << PAGE_SHIFT)
 
 /*
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH v6 0/8] block: prepare for multipage bvecs
  2016-05-30 13:34 [PATCH v6 0/8] block: prepare for multipage bvecs Ming Lei
                   ` (7 preceding siblings ...)
  2016-05-30 13:34 ` [PATCH v6 8/8] block: mark BIO_MAX_SIZE as obsolete Ming Lei
@ 2016-05-31 15:53 ` Mike Snitzer
  2016-06-01 12:38   ` Ming Lei
  2016-06-01 13:43 ` Christoph Hellwig
  2016-06-09 16:06 ` Jens Axboe
  10 siblings, 1 reply; 23+ messages in thread
From: Mike Snitzer @ 2016-05-31 15:53 UTC (permalink / raw)
  To: Ming Lei
  Cc: Jens Axboe, linux-kernel, linux-block, Christoph Hellwig,
	Al Viro, open list:DRBD DRIVER, Jan Kara, Joe Thornber,
	Keith Busch, Kent Overstreet, Kirill A. Shutemov,
	Martin K. Petersen, Michal Hocko, NeilBrown, Sagi Grimberg,
	Shaohua Li, Steven Whitehouse, Tejun Heo,
	open list:XFS FILESYSTEM

On Mon, May 30 2016 at  9:34am -0400,
Ming Lei <ming.lei@canonical.com> wrote:

> 
> 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 and makre BIO_MAX_SIZE as obsolete, 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.
> 
> The only functional change is iterate_bvec():lib/iov_iter.c
> 
> xfstests(-a auto) over loop aio is run for ext4/xfs to verify 
> the change and no regression found with this patchset.
> 
> V6:
> 	- rebased on v4.7-rc1
> 	- add reviewed-by tag
> 	- mark BIO_MAX_SIZE as obsolete instead of removing because
> 	dm-tree adds one usage now

Not sure what you're referring to here with "dm-tree" (since "dm-tree"
doesn't exist).  But only direct user of "BIO_MAX_SIZE" in DM appears to
be dm-crypt.c.  Maybe you've identified some indirect use of
BIO_MAX_SIZE?

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v6 8/8] block: mark BIO_MAX_SIZE as obsolete
  2016-05-30 13:34 ` [PATCH v6 8/8] block: mark BIO_MAX_SIZE as obsolete Ming Lei
@ 2016-05-31 16:07   ` Jens Axboe
  0 siblings, 0 replies; 23+ messages in thread
From: Jens Axboe @ 2016-05-31 16:07 UTC (permalink / raw)
  To: Ming Lei, Jens Axboe, linux-kernel
  Cc: linux-block, Christoph Hellwig, Keith Busch, Kirill A. Shutemov,
	Kent Overstreet, Mike Snitzer

On 05/30/2016 07:34 AM, Ming Lei wrote:
> Some in-tree drivers may use big bio which size is more
> than BIO_MAX_SIZE, also the macro is seldom used in tree.
>
> So mark it as obsolete now, and it doesn't make sense
> after multipage bvec is introduced.

Is it used in the tree after the patchset? If not, kill it, there's no 
such thing as a deprecated/obsolete define.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v6 0/8] block: prepare for multipage bvecs
  2016-05-31 15:53 ` [PATCH v6 0/8] block: prepare for multipage bvecs Mike Snitzer
@ 2016-06-01 12:38   ` Ming Lei
  2016-06-01 13:44     ` Christoph Hellwig
  0 siblings, 1 reply; 23+ messages in thread
From: Ming Lei @ 2016-06-01 12:38 UTC (permalink / raw)
  To: Mike Snitzer
  Cc: Jens Axboe, Linux Kernel Mailing List, linux-block,
	Christoph Hellwig, Al Viro, open list:DRBD DRIVER, Jan Kara,
	Joe Thornber, Keith Busch, Kent Overstreet, Kirill A. Shutemov,
	Martin K. Petersen, Michal Hocko, NeilBrown, Sagi Grimberg,
	Shaohua Li, Steven Whitehouse, Tejun Heo,
	open list:XFS FILESYSTEM

On Tue, May 31, 2016 at 11:53 PM, Mike Snitzer <snitzer@redhat.com> wrote:
> On Mon, May 30 2016 at  9:34am -0400,
> Ming Lei <ming.lei@canonical.com> wrote:
>
>>
>> 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 and makre BIO_MAX_SIZE as obsolete, 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.
>>
>> The only functional change is iterate_bvec():lib/iov_iter.c
>>
>> xfstests(-a auto) over loop aio is run for ext4/xfs to verify
>> the change and no regression found with this patchset.
>>
>> V6:
>>       - rebased on v4.7-rc1
>>       - add reviewed-by tag
>>       - mark BIO_MAX_SIZE as obsolete instead of removing because
>>       dm-tree adds one usage now
>
> Not sure what you're referring to here with "dm-tree" (since "dm-tree"
> doesn't exist).  But only direct user of "BIO_MAX_SIZE" in DM appears to

Looks it is from crypto tree:

   git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6

> be dm-crypt.c.  Maybe you've identified some indirect use of
> BIO_MAX_SIZE?

I mean the recently introduced BIO_MAX_SIZE in -next tree:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/drivers/md/dm-crypt.c?id=4ed89c97b0706477b822ea2182827640c0cec486

> --
> To unsubscribe from this list: send the line "unsubscribe linux-block" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v6 0/8] block: prepare for multipage bvecs
  2016-05-30 13:34 [PATCH v6 0/8] block: prepare for multipage bvecs Ming Lei
                   ` (8 preceding siblings ...)
  2016-05-31 15:53 ` [PATCH v6 0/8] block: prepare for multipage bvecs Mike Snitzer
@ 2016-06-01 13:43 ` Christoph Hellwig
  2016-06-01 13:53   ` Hannes Reinecke
  2016-06-09 16:06 ` Jens Axboe
  10 siblings, 1 reply; 23+ messages in thread
From: Christoph Hellwig @ 2016-06-01 13:43 UTC (permalink / raw)
  To: Ming Lei
  Cc: Jens Axboe, linux-kernel, linux-block, Christoph Hellwig,
	Al Viro, open list:DRBD DRIVER, Jan Kara, Joe Thornber,
	Keith Busch, Kent Overstreet, Kirill A. Shutemov,
	Martin K. Petersen, Michal Hocko, Mike Snitzer, NeilBrown,
	Sagi Grimberg, Shaohua Li, Steven Whitehouse, Tejun Heo,
	open list:XFS FILESYSTEM

These patches look good on their own.  They might be an easier sell
just as bio cleanups :)

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v6 0/8] block: prepare for multipage bvecs
  2016-06-01 12:38   ` Ming Lei
@ 2016-06-01 13:44     ` Christoph Hellwig
  2016-06-01 13:51       ` Mike Snitzer
  0 siblings, 1 reply; 23+ messages in thread
From: Christoph Hellwig @ 2016-06-01 13:44 UTC (permalink / raw)
  To: Ming Lei
  Cc: Mike Snitzer, Jens Axboe, Linux Kernel Mailing List, linux-block,
	Christoph Hellwig, Al Viro, open list:DRBD DRIVER, Jan Kara,
	Joe Thornber, Keith Busch, Kent Overstreet, Kirill A. Shutemov,
	Martin K. Petersen, Michal Hocko, NeilBrown, Sagi Grimberg,
	Shaohua Li, Steven Whitehouse, Tejun Heo,
	open list:XFS FILESYSTEM

On Wed, Jun 01, 2016 at 08:38:41PM +0800, Ming Lei wrote:
> > be dm-crypt.c.  Maybe you've identified some indirect use of
> > BIO_MAX_SIZE?
> 
> I mean the recently introduced BIO_MAX_SIZE in -next tree:
> 
> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/drivers/md/dm-crypt.c?id=4ed89c97b0706477b822ea2182827640c0cec486

The crazy bcache bios striking back once again.  I really think it's
harmful having a _MAX value and then having a minor driver
reinterpreting it and sending larger ones.  Until we can lift the
maximum limit in general nad have common code exercise it we really need
to stop bcache from sending these instead of littering the tree with
workarounds.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v6 5/8] fs: xfs: replace BIO_MAX_SECTORS with BIO_MAX_PAGES
  2016-05-30 13:34 ` [PATCH v6 5/8] fs: xfs: replace BIO_MAX_SECTORS with BIO_MAX_PAGES Ming Lei
@ 2016-06-01 13:48   ` Christoph Hellwig
  2016-06-02  3:32     ` Ming Lei
  0 siblings, 1 reply; 23+ messages in thread
From: Christoph Hellwig @ 2016-06-01 13:48 UTC (permalink / raw)
  To: Ming Lei
  Cc: Jens Axboe, linux-kernel, linux-block, Christoph Hellwig,
	Dave Chinner, supporter:XFS FILESYSTEM

On Mon, May 30, 2016 at 09:34:33PM +0800, Ming Lei wrote:
> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> index e71cfbd..e5d713b 100644
> --- a/fs/xfs/xfs_buf.c
> +++ b/fs/xfs/xfs_buf.c
> @@ -1157,9 +1157,7 @@ xfs_buf_ioapply_map(
>  
>  next_chunk:
>  	atomic_inc(&bp->b_io_remaining);
> -	nr_pages = BIO_MAX_SECTORS >> (PAGE_SHIFT - BBSHIFT);
> -	if (nr_pages > total_nr_pages)
> -		nr_pages = total_nr_pages;
> +	nr_pages = min(total_nr_pages, BIO_MAX_PAGES);
>  
>  	bio = bio_alloc(GFP_NOIO, nr_pages);

While I think this is a useful cleanup on it's own I think
you'd make everyones life easier if bio_alloc simply clamped down
the passed nr_pages value to the maximum allowed.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v6 0/8] block: prepare for multipage bvecs
  2016-06-01 13:44     ` Christoph Hellwig
@ 2016-06-01 13:51       ` Mike Snitzer
  2016-06-01 14:05         ` Christoph Hellwig
  2016-06-02  2:13         ` Ming Lei
  0 siblings, 2 replies; 23+ messages in thread
From: Mike Snitzer @ 2016-06-01 13:51 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Ming Lei, Jens Axboe, Linux Kernel Mailing List, linux-block,
	Al Viro, open list:DRBD DRIVER, Jan Kara, Joe Thornber,
	Keith Busch, Kent Overstreet, Kirill A. Shutemov,
	Martin K. Petersen, Michal Hocko, NeilBrown, Sagi Grimberg,
	Shaohua Li, Steven Whitehouse, Tejun Heo,
	open list:XFS FILESYSTEM

On Wed, Jun 01 2016 at  9:44am -0400,
Christoph Hellwig <hch@infradead.org> wrote:

> On Wed, Jun 01, 2016 at 08:38:41PM +0800, Ming Lei wrote:
> > > be dm-crypt.c.  Maybe you've identified some indirect use of
> > > BIO_MAX_SIZE?
> > 
> > I mean the recently introduced BIO_MAX_SIZE in -next tree:
> > 
> > https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/drivers/md/dm-crypt.c?id=4ed89c97b0706477b822ea2182827640c0cec486
> 
> The crazy bcache bios striking back once again.  I really think it's
> harmful having a _MAX value and then having a minor driver
> reinterpreting it and sending larger ones.  Until we can lift the
> maximum limit in general nad have common code exercise it we really need
> to stop bcache from sending these instead of littering the tree with
> workarounds.

So should I not push this type of fix to Linus now?  I was going to send
the above commit and this one to him this week:
https://git.kernel.org/cgit/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=dm-4.7&id=57b3001b240629ecc5266d28c845e23ca5f11719

Instead, should bcache be made to not do what it is doing?

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v6 0/8] block: prepare for multipage bvecs
  2016-06-01 13:43 ` Christoph Hellwig
@ 2016-06-01 13:53   ` Hannes Reinecke
  2016-06-01 13:57     ` Mike Snitzer
  0 siblings, 1 reply; 23+ messages in thread
From: Hannes Reinecke @ 2016-06-01 13:53 UTC (permalink / raw)
  To: Christoph Hellwig, Ming Lei
  Cc: Jens Axboe, linux-kernel, linux-block, Al Viro,
	open list:DRBD DRIVER, Jan Kara, Joe Thornber, Keith Busch,
	Kent Overstreet, Kirill A. Shutemov, Martin K. Petersen,
	Michal Hocko, Mike Snitzer, NeilBrown, Sagi Grimberg, Shaohua Li,
	Steven Whitehouse, Tejun Heo, open list:XFS FILESYSTEM

On 06/01/2016 03:43 PM, Christoph Hellwig wrote:
> These patches look good on their own.  They might be an easier sell
> just as bio cleanups :)

Fully agree. I've seen (some) improvements with those patches, so
I'd prefer to have them.

You can add:

Tested-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v6 0/8] block: prepare for multipage bvecs
  2016-06-01 13:53   ` Hannes Reinecke
@ 2016-06-01 13:57     ` Mike Snitzer
  0 siblings, 0 replies; 23+ messages in thread
From: Mike Snitzer @ 2016-06-01 13:57 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, Ming Lei, Jens Axboe, linux-kernel,
	linux-block, Al Viro, open list:DRBD DRIVER, Jan Kara,
	Joe Thornber, Keith Busch, Kent Overstreet, Kirill A. Shutemov,
	Martin K. Petersen, Michal Hocko, NeilBrown, Sagi Grimberg,
	Shaohua Li, Steven Whitehouse, Tejun Heo,
	open list:XFS FILESYSTEM

On Wed, Jun 01 2016 at  9:53am -0400,
Hannes Reinecke <hare@suse.de> wrote:

> On 06/01/2016 03:43 PM, Christoph Hellwig wrote:
> > These patches look good on their own.  They might be an easier sell
> > just as bio cleanups :)
> 
> Fully agree. I've seen (some) improvements with those patches, so
> I'd prefer to have them.

Can you be more specific on what improvements you've seen?

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v6 0/8] block: prepare for multipage bvecs
  2016-06-01 13:51       ` Mike Snitzer
@ 2016-06-01 14:05         ` Christoph Hellwig
  2016-06-02  2:13         ` Ming Lei
  1 sibling, 0 replies; 23+ messages in thread
From: Christoph Hellwig @ 2016-06-01 14:05 UTC (permalink / raw)
  To: Mike Snitzer
  Cc: Christoph Hellwig, Ming Lei, Jens Axboe,
	Linux Kernel Mailing List, linux-block, Al Viro,
	open list:DRBD DRIVER, Jan Kara, Joe Thornber, Keith Busch,
	Kent Overstreet, Kirill A. Shutemov, Martin K. Petersen,
	Michal Hocko, NeilBrown, Sagi Grimberg, Shaohua Li,
	Steven Whitehouse, Tejun Heo, open list:XFS FILESYSTEM

On Wed, Jun 01, 2016 at 09:51:51AM -0400, Mike Snitzer wrote:
> So should I not push this type of fix to Linus now?  I was going to send
> the above commit and this one to him this week:
> https://git.kernel.org/cgit/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=dm-4.7&id=57b3001b240629ecc5266d28c845e23ca5f11719
> 
> Instead, should bcache be made to not do what it is doing?

I think that's much preferably.  Otherwise we'll get a constant trickles
of patches like that whenever someone tries bcache on top of another
stacking driver.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v6 0/8] block: prepare for multipage bvecs
  2016-06-01 13:51       ` Mike Snitzer
  2016-06-01 14:05         ` Christoph Hellwig
@ 2016-06-02  2:13         ` Ming Lei
  1 sibling, 0 replies; 23+ messages in thread
From: Ming Lei @ 2016-06-02  2:13 UTC (permalink / raw)
  To: Mike Snitzer
  Cc: Christoph Hellwig, Jens Axboe, Linux Kernel Mailing List,
	linux-block, Al Viro, open list:DRBD DRIVER, Jan Kara,
	Joe Thornber, Keith Busch, Kent Overstreet, Kirill A. Shutemov,
	Martin K. Petersen, Michal Hocko, NeilBrown, Sagi Grimberg,
	Shaohua Li, Steven Whitehouse, Tejun Heo,
	open list:XFS FILESYSTEM

On Wed, Jun 1, 2016 at 9:51 PM, Mike Snitzer <snitzer@redhat.com> wrote:
> On Wed, Jun 01 2016 at  9:44am -0400,
> Christoph Hellwig <hch@infradead.org> wrote:
>
>> On Wed, Jun 01, 2016 at 08:38:41PM +0800, Ming Lei wrote:
>> > > be dm-crypt.c.  Maybe you've identified some indirect use of
>> > > BIO_MAX_SIZE?
>> >
>> > I mean the recently introduced BIO_MAX_SIZE in -next tree:
>> >
>> > https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/drivers/md/dm-crypt.c?id=4ed89c97b0706477b822ea2182827640c0cec486
>>
>> The crazy bcache bios striking back once again.  I really think it's
>> harmful having a _MAX value and then having a minor driver
>> reinterpreting it and sending larger ones.  Until we can lift the
>> maximum limit in general nad have common code exercise it we really need
>> to stop bcache from sending these instead of littering the tree with
>> workarounds.
>
> So should I not push this type of fix to Linus now?  I was going to send
> the above commit and this one to him this week:
> https://git.kernel.org/cgit/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=dm-4.7&id=57b3001b240629ecc5266d28c845e23ca5f11719

I don't suggest this kind of fix.

That fix should be in bcache or blk-core instead of other places.
Last time, I sent out the following fix([PATCH v1] block: make sure big bio is
splitted into at most 256 bvecs):

     https://lkml.org/lkml/2016/4/5/1046

But forget to clear the flag of REQ_NOMERGE for this case.

If Jens doesn't mind doing such thing in block-core, I can post v2
for this issue.

>
> Instead, should bcache be made to not do what it is doing?

It depends on if bcache is the only user of this kind of usage.
In theory, any driver can use external bvec table.

Thanks,
Ming

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v6 5/8] fs: xfs: replace BIO_MAX_SECTORS with BIO_MAX_PAGES
  2016-06-01 13:48   ` Christoph Hellwig
@ 2016-06-02  3:32     ` Ming Lei
  0 siblings, 0 replies; 23+ messages in thread
From: Ming Lei @ 2016-06-02  3:32 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jens Axboe, Linux Kernel Mailing List, linux-block, Dave Chinner,
	supporter:XFS FILESYSTEM

On Wed, Jun 1, 2016 at 9:48 PM, Christoph Hellwig <hch@infradead.org> wrote:
> On Mon, May 30, 2016 at 09:34:33PM +0800, Ming Lei wrote:
>> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
>> index e71cfbd..e5d713b 100644
>> --- a/fs/xfs/xfs_buf.c
>> +++ b/fs/xfs/xfs_buf.c
>> @@ -1157,9 +1157,7 @@ xfs_buf_ioapply_map(
>>
>>  next_chunk:
>>       atomic_inc(&bp->b_io_remaining);
>> -     nr_pages = BIO_MAX_SECTORS >> (PAGE_SHIFT - BBSHIFT);
>> -     if (nr_pages > total_nr_pages)
>> -             nr_pages = total_nr_pages;
>> +     nr_pages = min(total_nr_pages, BIO_MAX_PAGES);
>>
>>       bio = bio_alloc(GFP_NOIO, nr_pages);
>
> While I think this is a useful cleanup on it's own I think
> you'd make everyones life easier if bio_alloc simply clamped down
> the passed nr_pages value to the maximum allowed.

Yes, that looks a good cleanup, but need be careful because the
passed 'nr_pages' can be used after returning from bio_alloc() in
the current function, and it is easy to see this usage.

So we can do that in another patchset instead of this one.

Thanks,

> --
> To unsubscribe from this list: send the line "unsubscribe linux-block" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v6 0/8] block: prepare for multipage bvecs
  2016-05-30 13:34 [PATCH v6 0/8] block: prepare for multipage bvecs Ming Lei
                   ` (9 preceding siblings ...)
  2016-06-01 13:43 ` Christoph Hellwig
@ 2016-06-09 16:06 ` Jens Axboe
  2016-06-10  2:44   ` Ming Lei
  10 siblings, 1 reply; 23+ messages in thread
From: Jens Axboe @ 2016-06-09 16:06 UTC (permalink / raw)
  To: Ming Lei, Jens Axboe, linux-kernel
  Cc: linux-block, Christoph Hellwig, Al Viro, open list:DRBD DRIVER,
	Jan Kara, Joe Thornber, Keith Busch, Kent Overstreet,
	Kirill A. Shutemov, Martin K. Petersen, Michal Hocko,
	Mike Snitzer, NeilBrown, Sagi Grimberg, Shaohua Li,
	Steven Whitehouse, Tejun Heo, open list:XFS FILESYSTEM

On 05/30/2016 07:34 AM, Ming Lei wrote:
> 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 and makre BIO_MAX_SIZE as obsolete, 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.
>
> The only functional change is iterate_bvec():lib/iov_iter.c
>
> xfstests(-a auto) over loop aio is run for ext4/xfs to verify
> the change and no regression found with this patchset.

Added patches 1-7, still waiting for an answer on my reply to #8.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v6 0/8] block: prepare for multipage bvecs
  2016-06-09 16:06 ` Jens Axboe
@ 2016-06-10  2:44   ` Ming Lei
  0 siblings, 0 replies; 23+ messages in thread
From: Ming Lei @ 2016-06-10  2:44 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Jens Axboe, Linux Kernel Mailing List, linux-block,
	Christoph Hellwig, Al Viro, open list:DRBD DRIVER, Jan Kara,
	Joe Thornber, Keith Busch, Kent Overstreet, Kirill A. Shutemov,
	Martin K. Petersen, Michal Hocko, Mike Snitzer, NeilBrown,
	Sagi Grimberg, Shaohua Li, Steven Whitehouse, Tejun Heo,
	open list:XFS FILESYSTEM

On Fri, Jun 10, 2016 at 12:06 AM, Jens Axboe <axboe@kernel.dk> wrote:
> On 05/30/2016 07:34 AM, Ming Lei wrote:
>>
>> 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 and makre BIO_MAX_SIZE as obsolete, 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.
>>
>> The only functional change is iterate_bvec():lib/iov_iter.c
>>
>> xfstests(-a auto) over loop aio is run for ext4/xfs to verify
>> the change and no regression found with this patchset.
>
>
> Added patches 1-7, still waiting for an answer on my reply to #8.

Thanks for adding patches 1-7, and now I just found the added
BIO_MAX_SIZE usage in dm-crypt.c is droped from next, so it is
safe to kill it now.

I will send a new patch #8 against for-4.8/core.

Thanks,
Ming

>
> --
> Jens Axboe
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-block" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2016-06-10  2:44 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-30 13:34 [PATCH v6 0/8] block: prepare for multipage bvecs Ming Lei
2016-05-30 13:34 ` [PATCH v6 1/8] block: move bvec iterator into include/linux/bvec.h Ming Lei
2016-05-30 13:34 ` [PATCH v6 2/8] block: move two bvec structure into bvec.h Ming Lei
2016-05-30 13:34 ` [PATCH v6 3/8] block: mark 1st parameter of bvec_iter_advance as const Ming Lei
2016-05-30 13:34 ` [PATCH v6 4/8] iov_iter: use bvec iterator to implement iterate_bvec() Ming Lei
2016-05-30 13:34 ` [PATCH v6 5/8] fs: xfs: replace BIO_MAX_SECTORS with BIO_MAX_PAGES Ming Lei
2016-06-01 13:48   ` Christoph Hellwig
2016-06-02  3:32     ` Ming Lei
2016-05-30 13:34 ` [PATCH v6 6/8] block: bio: remove BIO_MAX_SECTORS Ming Lei
2016-05-30 13:34 ` [PATCH v6 7/8] block: drbd: avoid to use BIO_MAX_SIZE Ming Lei
2016-05-30 13:34 ` [PATCH v6 8/8] block: mark BIO_MAX_SIZE as obsolete Ming Lei
2016-05-31 16:07   ` Jens Axboe
2016-05-31 15:53 ` [PATCH v6 0/8] block: prepare for multipage bvecs Mike Snitzer
2016-06-01 12:38   ` Ming Lei
2016-06-01 13:44     ` Christoph Hellwig
2016-06-01 13:51       ` Mike Snitzer
2016-06-01 14:05         ` Christoph Hellwig
2016-06-02  2:13         ` Ming Lei
2016-06-01 13:43 ` Christoph Hellwig
2016-06-01 13:53   ` Hannes Reinecke
2016-06-01 13:57     ` Mike Snitzer
2016-06-09 16:06 ` Jens Axboe
2016-06-10  2:44   ` Ming Lei

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).