diff mbox series

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

Message ID b46b8c1943bbefcb90ea5c4dd9beaad8bbc15448.1609461359.git.asml.silence@gmail.com (mailing list archive)
State New, archived
Headers show
Series no-copy bvec | expand

Commit Message

Pavel Begunkov Jan. 2, 2021, 3:17 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.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 Documentation/filesystems/porting.rst | 7 +++++++
 lib/iov_iter.c                        | 2 --
 2 files changed, 7 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig Jan. 4, 2021, 4:18 p.m. UTC | #1
On Sat, Jan 02, 2021 at 03:17:34PM +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.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
Matthew Wilcox Jan. 4, 2021, 4:37 p.m. UTC | #2
On Sat, Jan 02, 2021 at 03:17:34PM +0000, Pavel Begunkov wrote:
> --- 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.

Why are you putting this in filesystems/porting?  Filesystems don't usually
generate bvecs ... there's nothing in this current series that stops them.
I'd suggest Documentation/block/biovecs.rst or biodoc.rst (and frankly,
biodoc.rst needs a good cleanup)
Pavel Begunkov Jan. 4, 2021, 5:23 p.m. UTC | #3
On 04/01/2021 16:37, Matthew Wilcox wrote:
> On Sat, Jan 02, 2021 at 03:17:34PM +0000, Pavel Begunkov wrote:
>> --- 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.
> 
> Why are you putting this in filesystems/porting?  Filesystems don't usually

At least splice and a dozen of others do. As block apriori doesn't have them,
it's mainly addressed to fs + net. 

> generate bvecs ... there's nothing in this current series that stops them.

Yes, just mixing it with splice changes, which did all the work, looks
awkward to me. Would you suggest another segregation for the patches?

> I'd suggest Documentation/block/biovecs.rst or biodoc.rst (and frankly,
> biodoc.rst needs a good cleanup)

I'll add a note to biovecs.rst
diff mbox series

Patch

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);				\
 	}						\
 }