diff mbox series

[v3,2/7] bvec/iter: disallow zero-length segment bvecs

Message ID 4570836cc62137a9ee788d9c820f58ed8efe9b37.1610170479.git.asml.silence@gmail.com
State New
Headers show
Series no-copy bvec | expand

Commit Message

Pavel Begunkov Jan. 9, 2021, 4:02 p.m. UTC
zero-length bvec segments are allowed in general, but not handled by bio
and down the block layer so filtered out. This inconsistency may be
confusing and prevent from optimisations. As zero-length segments are
useless and places that were generating them are patched, declare them
not allowed.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 Documentation/block/biovecs.rst       | 2 ++
 Documentation/filesystems/porting.rst | 7 +++++++
 lib/iov_iter.c                        | 2 --
 3 files changed, 9 insertions(+), 2 deletions(-)

Comments

Ming Lei Jan. 11, 2021, 2:49 a.m. UTC | #1
On Sat, Jan 09, 2021 at 04:02:58PM +0000, Pavel Begunkov wrote:
> zero-length bvec segments are allowed in general, but not handled by bio

> and down the block layer so filtered out. This inconsistency may be

> confusing and prevent from optimisations. As zero-length segments are

> useless and places that were generating them are patched, declare them

> not allowed.

> 

> Reviewed-by: Christoph Hellwig <hch@lst.de>

> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>

> ---

>  Documentation/block/biovecs.rst       | 2 ++

>  Documentation/filesystems/porting.rst | 7 +++++++

>  lib/iov_iter.c                        | 2 --

>  3 files changed, 9 insertions(+), 2 deletions(-)

> 

> diff --git a/Documentation/block/biovecs.rst b/Documentation/block/biovecs.rst

> index 36771a131b56..ddb867e0185b 100644

> --- a/Documentation/block/biovecs.rst

> +++ b/Documentation/block/biovecs.rst

> @@ -40,6 +40,8 @@ normal code doesn't have to deal with bi_bvec_done.

>     There is a lower level advance function - bvec_iter_advance() - which takes

>     a pointer to a biovec, not a bio; this is used by the bio integrity code.

>  

> +As of 5.12 bvec segments with zero bv_len are not supported.

> +

>  What's all this get us?

>  =======================

>  

> diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesystems/porting.rst

> index 867036aa90b8..c722d94f29ea 100644

> --- a/Documentation/filesystems/porting.rst

> +++ b/Documentation/filesystems/porting.rst

> @@ -865,3 +865,10 @@ no matter what.  Everything is handled by the caller.

>  

>  clone_private_mount() returns a longterm mount now, so the proper destructor of

>  its result is kern_unmount() or kern_unmount_array().

> +

> +---

> +

> +**mandatory**

> +

> +zero-length bvec segments are disallowed, they must be filtered out before

> +passed on to an iterator.

> diff --git a/lib/iov_iter.c b/lib/iov_iter.c

> index 1635111c5bd2..7de304269641 100644

> --- a/lib/iov_iter.c

> +++ b/lib/iov_iter.c

> @@ -72,8 +72,6 @@

>  	__start.bi_bvec_done = skip;			\

>  	__start.bi_idx = 0;				\

>  	for_each_bvec(__v, i->bvec, __bi, __start) {	\

> -		if (!__v.bv_len)			\

> -			continue;			\

>  		(void)(STEP);				\

>  	}						\

>  }

> -- 

> 2.24.0

> 


Reviewed-by: Ming Lei <ming.lei@redhat.com>


-- 
Ming
diff mbox series

Patch

diff --git a/Documentation/block/biovecs.rst b/Documentation/block/biovecs.rst
index 36771a131b56..ddb867e0185b 100644
--- a/Documentation/block/biovecs.rst
+++ b/Documentation/block/biovecs.rst
@@ -40,6 +40,8 @@  normal code doesn't have to deal with bi_bvec_done.
    There is a lower level advance function - bvec_iter_advance() - which takes
    a pointer to a biovec, not a bio; this is used by the bio integrity code.
 
+As of 5.12 bvec segments with zero bv_len are not supported.
+
 What's all this get us?
 =======================
 
diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesystems/porting.rst
index 867036aa90b8..c722d94f29ea 100644
--- a/Documentation/filesystems/porting.rst
+++ b/Documentation/filesystems/porting.rst
@@ -865,3 +865,10 @@  no matter what.  Everything is handled by the caller.
 
 clone_private_mount() returns a longterm mount now, so the proper destructor of
 its result is kern_unmount() or kern_unmount_array().
+
+---
+
+**mandatory**
+
+zero-length bvec segments are disallowed, they must be filtered out before
+passed on to an iterator.
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 1635111c5bd2..7de304269641 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -72,8 +72,6 @@ 
 	__start.bi_bvec_done = skip;			\
 	__start.bi_idx = 0;				\
 	for_each_bvec(__v, i->bvec, __bi, __start) {	\
-		if (!__v.bv_len)			\
-			continue;			\
 		(void)(STEP);				\
 	}						\
 }