diff mbox series

[RFC,11/31] btrfs: Use submit_io to submit btrfs writeback bios

Message ID b281a2a58372728b86453a0cc6506d4bf5e68fa3.1623567940.git.rgoldwyn@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs buffered iomap support | expand

Commit Message

Goldwyn Rodrigues June 13, 2021, 1:39 p.m. UTC
From: Goldwyn Rodrigues <rgoldwyn@suse.com>

The submit_io sequence calls set_page_extent_mapped() for data
inodes to make sure that page->private is set. Depending on
the type of inode: metadata or data, the respective submit_bio
function is called.

This will also be used for readpage() sequence.
---
 fs/btrfs/inode.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

Comments

Nikolay Borisov June 16, 2021, 2:26 p.m. UTC | #1
On 13.06.21 г. 16:39, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
> 
> The submit_io sequence calls set_page_extent_mapped() for data
> inodes to make sure that page->private is set. Depending on
> the type of inode: metadata or data, the respective submit_bio
> function is called.
> 
> This will also be used for readpage() sequence.
> ---
>  fs/btrfs/inode.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index eff4ec44fecd..87d0730f59d8 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -8349,11 +8349,26 @@ static int btrfs_map_blocks(struct iomap_writepage_ctx *wpc,
>  	return btrfs_set_iomap(inode, offset, end - offset, &wpc->iomap);
>  }
>  
> +static void btrfs_buffered_submit_io(struct inode *inode, struct bio *bio)
> +{
> +	struct bio_vec *bvec;
> +	struct bvec_iter_all iter_all;
> +
> +	if (is_data_inode(inode))
> +		bio_for_each_segment_all(bvec, bio, iter_all)
> +			set_page_extent_mapped(bvec->bv_page);
> +
> +	if (is_data_inode(inode))
> +		btrfs_submit_data_bio(inode, bio, 0, 0);
> +	else
> +		btrfs_submit_metadata_bio(inode, bio, 0, 0);

Move the submit_data_bio into the first if() and then
submit_metadata_bio into an else clause. That way you'll have just a
single check in this function.

> +}
> +
>  static const struct iomap_writeback_ops btrfs_writeback_ops = {
>  	.map_blocks             = btrfs_map_blocks,
> +	.submit_io		= btrfs_buffered_submit_io,
>  };
>  
> -
>  static int btrfs_writepage(struct page *page, struct writeback_control *wbc)
>  {
>  	struct inode *inode = page->mapping->host;
>
diff mbox series

Patch

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index eff4ec44fecd..87d0730f59d8 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8349,11 +8349,26 @@  static int btrfs_map_blocks(struct iomap_writepage_ctx *wpc,
 	return btrfs_set_iomap(inode, offset, end - offset, &wpc->iomap);
 }
 
+static void btrfs_buffered_submit_io(struct inode *inode, struct bio *bio)
+{
+	struct bio_vec *bvec;
+	struct bvec_iter_all iter_all;
+
+	if (is_data_inode(inode))
+		bio_for_each_segment_all(bvec, bio, iter_all)
+			set_page_extent_mapped(bvec->bv_page);
+
+	if (is_data_inode(inode))
+		btrfs_submit_data_bio(inode, bio, 0, 0);
+	else
+		btrfs_submit_metadata_bio(inode, bio, 0, 0);
+}
+
 static const struct iomap_writeback_ops btrfs_writeback_ops = {
 	.map_blocks             = btrfs_map_blocks,
+	.submit_io		= btrfs_buffered_submit_io,
 };
 
-
 static int btrfs_writepage(struct page *page, struct writeback_control *wbc)
 {
 	struct inode *inode = page->mapping->host;