Re: [RFC PATCH 01/37] block: introduce bio_init_fields() helper

From
Christoph Hellwig <hch@lst.de>
Date
2021-01-19 06:29:39
Also in
linux-fsdevel, lkml
Reply to
Chaitanya Kulkarni, 2021-01-19
I don't think a helper just to initialize a few fields is very useful.
But there is something in this area I've wanted to do for a while:
quoted hunk ↗ jump to hunk
+static inline void bio_init_fields(struct bio *bio, struct block_device *bdev,
+				   sector_t sect, void *priv,
+				   bio_end_io_t *end_io,
+				   unsigned short prio, unsigned short whint)
+{
+	bio_set_dev(bio, bdev);
+	bio->bi_iter.bi_sector = sect;
+	bio->bi_private = priv;
+	bio->bi_end_io = end_io;
+	bio->bi_ioprio = prio;
+	bio->bi_write_hint = whint;
Ensuring that the device, sector and op are always initialized would
really helper some of the bio mapping helpers, so I'd rather
add a new

struct bio *bio_new(struct block_device *bdev, sector_t sector,
		unsigned int op, unsigned int max_bvecs, gfp_t gfp_mask)

helper, where max_bvecs is clamped to BIO_MAX_PAGES.

bi_private, bi_end_io, bi_ioprio and bi_write_hint on the other hand
are purely optional and can be easily set just by the users that care.
Thread (47 messages) 47 messages, 7 authors, last reply 2021-01-21
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help