bcachefs block layer prereqs
Subsystems (2)
cover bcachefs block layer prereqs
Hi Jens, here's the (hopefully final) bcachefs block layer prereqs, aiming for v6.6.
The "block: Don't block on s_umount from __invalidate_super()" patch has been dropped for now - but we may want this later as there's a real bug it addresses, and with the blockdev holder changes now landing I suspect other filesystems will be hitting the same issue as bcachefs.
But that can be a topic for another thread.
Can I get either acks or have you take them via your tree, your preference?
Kent Overstreet (3):
block: Add some exports for bcachefs
block: Allow bio_iov_iter_get_pages() with bio->bi_bdev unset
block: Bring back zero_fill_bio_iter
block/bio.c | 18 +++++++++++------- block/blk-core.c | 1 + block/blk.h | 1 - include/linux/bio.h | 7 ++++++- include/linux/blkdev.h | 1 + 5 files changed, 19 insertions(+), 9 deletions(-)
Signature · 1 line
2.40.1
PATCH 1/3 block: Add some exports for bcachefs
From: Kent Overstreet <[email protected]>
- bio_set_pages_dirty(), bio_check_pages_dirty() - dio path
- blk_status_to_str() - error messages
- bio_add_folio() - this should definitely be exported for everyone, it's the modern version of bio_add_page()
--- block/bio.c | 2 ++ block/blk-core.c | 1 + block/blk.h | 1 - include/linux/blkdev.h | 1 + 4 files changed, 4 insertions(+), 1 deletion(-)
block/bio.c +2 -0
@@ -1481,6 +1481,7 @@ void bio_set_pages_dirty(struct bio *bio)set_page_dirty_lock (bvec->bv_page); } } +EXPORT_SYMBOL_GPL (bio_set_pages_dirty);/* * bio_check_pages_dirty() will check that all the BIO's pages are still dirty.
@@ -1540,6 +1541,7 @@ void bio_check_pages_dirty(struct bio *bio)spin_unlock_irqrestore (&bio_dirty_lock, flags);schedule_work (&bio_dirty_work); } +EXPORT_SYMBOL_GPL (bio_check_pages_dirty);static inline bool bio_remaining_done (struct bio *bio) {
block/blk-core.c +1 -0
@@ -205,6 +205,7 @@ const char *blk_status_to_str(blk_status_t status)return "<null>" ;return blk_errors[idx].name; } +EXPORT_SYMBOL_GPL (blk_status_to_str);/** * blk_sync_queue - cancel any pending callbacks on a queue
block/blk.h +0 -1
@@ -251,7 +251,6 @@ static inline void bio_integrity_free(struct bio *bio)unsigned long blk_rq_timeout (unsigned long timeout);void blk_add_timer (struct request *req); -const char *blk_status_to_str (blk_status_t status);bool blk_attempt_plug_merge (struct request_queue *q,struct bio *bio,unsigned int nr_segs);
include/linux/blkdev.h +1 -0
@@ -854,6 +854,7 @@ extern const char *blk_op_str(enum req_op op);int blk_status_to_errno (blk_status_t status);blk_status_t errno_to_blk_status (int errno); +const char *blk_status_to_str (blk_status_t status);/* only poll the hardware once, don't continue until a completion was found */ #define BLK_POLL_ONESHOT (1 << 0)
Signature · 1 line
2.40.1
PATCH 2/3 block: Allow bio_iov_iter_get_pages() with bio->bi_bdev unset
In reply to Kent Overstreetbio_iov_iter_get_pages() trims the IO based on the block size of the block device the IO will be issued to.
However, bcachefs is a multi device filesystem; when we're creating the bio we don't yet know which block device the bio will be submitted to - we have to handle the alignment checks elsewhere.
Thus this is needed to avoid a null ptr deref.
--- block/bio.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
block/bio.c +6 -4
@@ -1245,7 +1245,7 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)struct page **pages = (struct page **)bv;ssize_t size, left;unsigned len, i =0 ; -size_t offset, trim; +size_t offset;int ret =0 ;/*
@@ -1274,10 +1274,12 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) nr_pages =DIV_ROUND_UP (offset + size,PAGE_SIZE ); - trim = size & (bdev_logical_block_size (bio->bi_bdev) -1 ); -iov_iter_revert (iter, trim); +if (bio->bi_bdev) { +size_t trim = size & (bdev_logical_block_size (bio->bi_bdev) -1 ); +iov_iter_revert (iter, trim); + size -= trim; + } - size -= trim;if (unlikely (!size)) { ret = -EFAULT ; goto out;
Signature · 1 line
2.40.1
PATCH 3/3 block: Bring back zero_fill_bio_iter
In reply to Kent OverstreetFrom: Kent Overstreet <[email protected]>
This reverts 6f822e1b5d9dda3d20e87365de138046e3baa03a - this helper is used by bcachefs.
--- block/bio.c | 6 +++--- include/linux/bio.h | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-)
block/bio.c +3 -3
@@ -606,15 +606,15 @@ struct bio *bio_kmalloc(unsigned short nr_vecs, gfp_t gfp_mask) }EXPORT_SYMBOL (bio_kmalloc); -void zero_fill_bio (struct bio *bio) +void zero_fill_bio_iter (struct bio *bio,struct bvec_iter start) {struct bio_vec bv;struct bvec_iter iter; -bio_for_each_segment (bv, bio, iter) +__bio_for_each_segment (bv, bio, iter, start)memzero_bvec (&bv); } -EXPORT_SYMBOL (zero_fill_bio); +EXPORT_SYMBOL (zero_fill_bio_iter);/** * bio_truncate - truncate the bio to small size of @new_size
include/linux/bio.h +6 -1
@@ -484,7 +484,12 @@ extern void bio_copy_data_iter(struct bio *dst, struct bvec_iter *dst_iter,extern void bio_copy_data (struct bio *dst,struct bio *src);extern void bio_free_pages (struct bio *bio);void guard_bio_eod (struct bio *bio); -void zero_fill_bio (struct bio *bio); +void zero_fill_bio_iter (struct bio *bio,struct bvec_iter iter); + +static inline void zero_fill_bio (struct bio *bio) +{ +zero_fill_bio_iter (bio, bio->bi_iter); +}static inline void bio_release_pages (struct bio *bio,bool mark_dirty) {
Signature · 1 line
2.40.1
Quoted 8 lines · Kent Overstreet
aiming for v6.6.
The "block: Don't block on
s_umountfrom__invalidate_super()" patch has been dropped for now - but we may want this later as there's a real bug it addresses, and with the blockdev holder changes now landing I suspect other filesystems will be hitting the same issue as bcachefs.[...]
Applied, thanks!
[1/3] block: Add some exports for bcachefs
commit: 7ba3792718709d410be5d971732b9251cbda67b6
[2/3] block: Allow bio_iov_iter_get_pages() with bio->bi_bdev unset
commit: 168145f617d57bf4e474901b7ffa869337a802e6
[3/3] block: Bring back zero_fill_bio_iter
commit: 649f070e69739d22c57c22dbce0788b72cd93facBest regards,
Signature · 1 line
Jens Axboe