Message ID | 999c273a4d4fd73ecd9fe80a20e7008eb1124b35.1623567940.git.rgoldwyn@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs buffered iomap support | expand |
On 13.06.21 г. 16:39, Goldwyn Rodrigues wrote: > From: Goldwyn Rodrigues <rgoldwyn@suse.com> > > Filesystems such as btrfs need to perform pre and post bio operations > such as csum calculations, device mapping etc. > > Add a submit_io() function to writepage_ops so filesystems can control > how the bio is submitted. > > Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> > --- > fs/iomap/buffered-io.c | 11 ++++++++++- > include/linux/iomap.h | 6 ++++++ > 2 files changed, 16 insertions(+), 1 deletion(-) > > diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c > index d30683734d01..b6fd6d6118a6 100644 > --- a/fs/iomap/buffered-io.c > +++ b/fs/iomap/buffered-io.c > @@ -1209,7 +1209,11 @@ iomap_submit_ioend(struct iomap_writepage_ctx *wpc, struct iomap_ioend *ioend, > return error; > } > > - submit_bio(ioend->io_bio); > + if (wpc->ops->submit_io) > + wpc->ops->submit_io(ioend->io_inode, ioend->io_bio); > + else > + submit_bio(ioend->io_bio); > + > return 0; > } > > @@ -1305,8 +1309,13 @@ iomap_add_to_ioend(struct inode *inode, loff_t offset, struct page *page, > > if (!merged) { > if (bio_full(wpc->ioend->io_bio, len)) { > + struct bio *bio = wpc->ioend->io_bio; > wpc->ioend->io_bio = > iomap_chain_bio(wpc->ioend->io_bio); > + if (wpc->ops->submit_io) > + wpc->ops->submit_io(inode, bio); > + else > + submit_bio(bio); Why do you submit the bio here? It seems iomap_add_to_ioend is used to build a chain of ioend/bio structures which are then submitted by the loop in iomap_writepage_map. At the very least this change should go into a separate patch whose commit message should explain why do you introduce this new submission point. > } > bio_add_page(wpc->ioend->io_bio, page, len, poff); > } > diff --git a/include/linux/iomap.h b/include/linux/iomap.h > index c87d0cb0de6d..689d799b1915 100644 > --- a/include/linux/iomap.h > +++ b/include/linux/iomap.h > @@ -223,6 +223,12 @@ struct iomap_writeback_ops { > * we failed to submit any I/O. > */ > void (*discard_page)(struct page *page, loff_t fileoff); > + > + /* > + * Optional, allows the filesystem to perform a custom submission of > + * bio, such as csum calculations or multi-device bio split > + */ > + void (*submit_io)(struct inode *inode, struct bio *bio); nit: I'm wondering if we have the ->submit_bio callback doesn't it really subsume prepare_ioend. > }; > > struct iomap_writepage_ctx { >
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index d30683734d01..b6fd6d6118a6 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -1209,7 +1209,11 @@ iomap_submit_ioend(struct iomap_writepage_ctx *wpc, struct iomap_ioend *ioend, return error; } - submit_bio(ioend->io_bio); + if (wpc->ops->submit_io) + wpc->ops->submit_io(ioend->io_inode, ioend->io_bio); + else + submit_bio(ioend->io_bio); + return 0; } @@ -1305,8 +1309,13 @@ iomap_add_to_ioend(struct inode *inode, loff_t offset, struct page *page, if (!merged) { if (bio_full(wpc->ioend->io_bio, len)) { + struct bio *bio = wpc->ioend->io_bio; wpc->ioend->io_bio = iomap_chain_bio(wpc->ioend->io_bio); + if (wpc->ops->submit_io) + wpc->ops->submit_io(inode, bio); + else + submit_bio(bio); } bio_add_page(wpc->ioend->io_bio, page, len, poff); } diff --git a/include/linux/iomap.h b/include/linux/iomap.h index c87d0cb0de6d..689d799b1915 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -223,6 +223,12 @@ struct iomap_writeback_ops { * we failed to submit any I/O. */ void (*discard_page)(struct page *page, loff_t fileoff); + + /* + * Optional, allows the filesystem to perform a custom submission of + * bio, such as csum calculations or multi-device bio split + */ + void (*submit_io)(struct inode *inode, struct bio *bio); }; struct iomap_writepage_ctx {