diff mbox series

[2/5] bio.h: Declare the arguments of bio iteration functions const

Message ID 20200516001914.17138-3-bvanassche@acm.org (mailing list archive)
State New, archived
Headers show
Series Block layer patches for kernel v5.8 | expand

Commit Message

Bart Van Assche May 16, 2020, 12:19 a.m. UTC
This change makes it possible to pass 'const struct bio *' arguments to
these functions.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Damien Le Moal <damien.lemoal@wdc.com>
Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Cc: Alexander Potapenko <glider@google.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 include/linux/bio.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Alexander Potapenko May 16, 2020, 8:55 a.m. UTC | #1
On Sat, May 16, 2020 at 2:19 AM Bart Van Assche <bvanassche@acm.org> wrote:
>
> This change makes it possible to pass 'const struct bio *' arguments to
> these functions.
>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Damien Le Moal <damien.lemoal@wdc.com>
> Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> Cc: Alexander Potapenko <glider@google.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  include/linux/bio.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/bio.h b/include/linux/bio.h
> index a0ee494a6329..58e6134b1c05 100644
> --- a/include/linux/bio.h
> +++ b/include/linux/bio.h
> @@ -70,7 +70,7 @@ static inline bool bio_has_data(struct bio *bio)
>         return false;
>  }
>
> -static inline bool bio_no_advance_iter(struct bio *bio)
> +static inline bool bio_no_advance_iter(const struct bio *bio)
>  {
>         return bio_op(bio) == REQ_OP_DISCARD ||
>                bio_op(bio) == REQ_OP_SECURE_ERASE ||
> @@ -138,8 +138,8 @@ static inline bool bio_next_segment(const struct bio *bio,
>  #define bio_for_each_segment_all(bvl, bio, iter) \
>         for (bvl = bvec_init_iter_all(&iter); bio_next_segment((bio), &iter); )
>
> -static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter,
> -                                   unsigned bytes)
> +static inline void bio_advance_iter(const struct bio *bio,
> +                                   struct bvec_iter *iter, unsigned bytes)
>  {
>         iter->bi_sector += bytes >> 9;
On a related note, should this 9 be SECTOR_SHIFT?
Christoph Hellwig May 16, 2020, 12:42 p.m. UTC | #2
On Fri, May 15, 2020 at 05:19:11PM -0700, Bart Van Assche wrote:
> This change makes it possible to pass 'const struct bio *' arguments to
> these functions.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
Bart Van Assche May 16, 2020, 5:10 p.m. UTC | #3
On 2020-05-16 01:55, Alexander Potapenko wrote:
> On Sat, May 16, 2020 at 2:19 AM Bart Van Assche <bvanassche@acm.org> wrote:
>> -static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter,
>> -                                   unsigned bytes)
>> +static inline void bio_advance_iter(const struct bio *bio,
>> +                                   struct bvec_iter *iter, unsigned bytes)
>>  {
>>         iter->bi_sector += bytes >> 9;
>
> On a related note, should this 9 be SECTOR_SHIFT?

Hi Alexander,

I think a patch series is already under review for replacing "9" with
SECTOR_SHIFT. See also
https://lore.kernel.org/linux-block/20200507075100.1779-1-thunder.leizhen@huawei.com/.

Thanks,

Bart.
Chaitanya Kulkarni May 17, 2020, 10:46 p.m. UTC | #4
On 5/15/20 5:19 PM, Bart Van Assche wrote:
> This change makes it possible to pass 'const struct bio *' arguments to
> these functions.
> 
> Cc: Christoph Hellwig<hch@lst.de>
> Cc: Ming Lei<ming.lei@redhat.com>
> Cc: Damien Le Moal<damien.lemoal@wdc.com>
> Cc: Chaitanya Kulkarni<chaitanya.kulkarni@wdc.com>
> Cc: Alexander Potapenko<glider@google.com>
> Signed-off-by: Bart Van Assche<bvanassche@acm.org>

Looks good.

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
diff mbox series

Patch

diff --git a/include/linux/bio.h b/include/linux/bio.h
index a0ee494a6329..58e6134b1c05 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -70,7 +70,7 @@  static inline bool bio_has_data(struct bio *bio)
 	return false;
 }
 
-static inline bool bio_no_advance_iter(struct bio *bio)
+static inline bool bio_no_advance_iter(const struct bio *bio)
 {
 	return bio_op(bio) == REQ_OP_DISCARD ||
 	       bio_op(bio) == REQ_OP_SECURE_ERASE ||
@@ -138,8 +138,8 @@  static inline bool bio_next_segment(const struct bio *bio,
 #define bio_for_each_segment_all(bvl, bio, iter) \
 	for (bvl = bvec_init_iter_all(&iter); bio_next_segment((bio), &iter); )
 
-static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter,
-				    unsigned bytes)
+static inline void bio_advance_iter(const struct bio *bio,
+				    struct bvec_iter *iter, unsigned bytes)
 {
 	iter->bi_sector += bytes >> 9;