bvec/iter: disallow zero-length segment bvecs
authorPavel Begunkov <asml.silence@gmail.com>
Sat, 9 Jan 2021 16:02:58 +0000 (16:02 +0000)
committerJens Axboe <axboe@kernel.dk>
Mon, 25 Jan 2021 15:58:24 +0000 (08:58 -0700)
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>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Documentation/block/biovecs.rst
Documentation/filesystems/porting.rst
lib/iov_iter.c

index 36771a131b566087fdbc2c4a92982ce7ac9abe9b..ddb867e0185b41e3816d0033974078e0da6b683c 100644 (file)
@@ -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?
 =======================
 
index 867036aa90b8394cea582fdbd183e747a630488a..c722d94f29ead3819e359e87fcfedf8b60125d8d 100644 (file)
@@ -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.
index a21e6a5792c5a53fcdb3ffd29328d9d5f6d5afad..6c597cdfcf5bc3978cebce5435b235131834b1e5 100644 (file)
@@ -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);                           \
        }                                               \
 }