On Thu, Nov 15, 2018 at 04:52:49PM +0800, Ming Lei wrote:
> This helper is used for iterating over multi-page bvec for bio
> split & merge code.
> 
> Cc: Dave Chinner <[email protected]>
> Cc: Kent Overstreet <[email protected]>
> Cc: Mike Snitzer <[email protected]>
> Cc: [email protected]
> Cc: Alexander Viro <[email protected]>
> Cc: [email protected]
> Cc: Shaohua Li <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: David Sterba <[email protected]>
> Cc: [email protected]
> Cc: Darrick J. Wong <[email protected]>
> Cc: [email protected]
> Cc: Gao Xiang <[email protected]>
> Cc: Christoph Hellwig <[email protected]>
> Cc: Theodore Ts'o <[email protected]>
> Cc: [email protected]
> Cc: Coly Li <[email protected]>
> Cc: [email protected]
> Cc: Boaz Harrosh <[email protected]>
> Cc: Bob Peterson <[email protected]>
> Cc: [email protected]

Reviewed-by: Omar Sandoval <[email protected]>

One comment below.

> Signed-off-by: Ming Lei <[email protected]>
> ---
>  include/linux/bio.h  | 34 +++++++++++++++++++++++++++++++---
>  include/linux/bvec.h | 36 ++++++++++++++++++++++++++++++++----
>  2 files changed, 63 insertions(+), 7 deletions(-)
> 
> diff --git a/include/linux/bio.h b/include/linux/bio.h
> index 056fb627edb3..1f0dcf109841 100644
> --- a/include/linux/bio.h
> +++ b/include/linux/bio.h
> @@ -76,6 +76,9 @@
>  #define bio_data_dir(bio) \
>       (op_is_write(bio_op(bio)) ? WRITE : READ)
>  
> +#define bio_iter_mp_iovec(bio, iter)                         \
> +     mp_bvec_iter_bvec((bio)->bi_io_vec, (iter))
> +
>  /*
>   * Check whether this bio carries any data or not. A NULL bio is allowed.
>   */
> @@ -135,18 +138,33 @@ static inline bool bio_full(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 bio_advance_iter(struct bio *bio, struct bvec_iter *iter,
> -                                 unsigned bytes)
> +static inline void __bio_advance_iter(struct bio *bio, struct bvec_iter 
> *iter,
> +                                   unsigned bytes, bool mp)
>  {
>       iter->bi_sector += bytes >> 9;
>  
>       if (bio_no_advance_iter(bio))
>               iter->bi_size -= bytes;
>       else
> -             bvec_iter_advance(bio->bi_io_vec, iter, bytes);
> +             if (!mp)
> +                     bvec_iter_advance(bio->bi_io_vec, iter, bytes);
> +             else
> +                     mp_bvec_iter_advance(bio->bi_io_vec, iter, bytes);

if (!foo) {} else {} hurts my brain, please do

                if (mp)
                        mp_bvec_iter_advance(bio->bi_io_vec, iter, bytes);
                else
                        bvec_iter_advance(bio->bi_io_vec, iter, bytes);

Reply via email to