@@ -3214,6 +3214,7 @@ void btrfs_inode_unlock(struct inode *inode, unsigned int ilock_flags);
void btrfs_update_inode_bytes(struct btrfs_inode *inode,
const u64 add_bytes,
const u64 del_bytes);
+void btrfs_buffered_submit_io(struct inode *inode, struct bio *bio);
/* ioctl.c */
long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
@@ -7284,3 +7284,13 @@ void btrfs_readahead_node_child(struct extent_buffer *node, int slot)
btrfs_node_ptr_generation(node, slot),
btrfs_header_level(node) - 1);
}
+
+static struct bio *btrfs_readpage_alloc_bio(gfp_t gfp_mask, unsigned short nr)
+{
+ return btrfs_io_bio_alloc(nr);
+}
+
+const struct iomap_readpage_ops btrfs_iomap_readpage_ops = {
+ .alloc_bio = btrfs_readpage_alloc_bio,
+ .submit_io = btrfs_buffered_submit_io,
+};
@@ -7,6 +7,7 @@
#include <linux/refcount.h>
#include <linux/fiemap.h>
#include <linux/btrfs_tree.h>
+#include <linux/iomap.h>
#include "ulist.h"
/*
@@ -313,6 +314,8 @@ int btrfs_repair_one_sector(struct inode *inode,
u64 start, int failed_mirror,
submit_bio_hook_t *submit_bio_hook);
+extern const struct iomap_readpage_ops btrfs_iomap_readpage_ops;
+
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
bool find_lock_delalloc_range(struct inode *inode,
struct page *locked_page, u64 *start,
@@ -35,6 +35,7 @@
#include "misc.h"
#include "ctree.h"
#include "disk-io.h"
+#include "extent_io.h"
#include "transaction.h"
#include "btrfs_inode.h"
#include "print-tree.h"
@@ -8431,7 +8432,7 @@ static void btrfs_writepage_endio(struct bio *bio)
iomap_writepage_end_bio(bio);
}
-static void btrfs_buffered_submit_io(struct inode *inode, struct bio *bio)
+void btrfs_buffered_submit_io(struct inode *inode, struct bio *bio)
{
struct bio_vec *bvec;
struct bvec_iter_all iter_all;
@@ -8440,7 +8441,11 @@ static void btrfs_buffered_submit_io(struct inode *inode, struct bio *bio)
bio_for_each_segment_all(bvec, bio, iter_all)
set_page_extent_mapped(bvec->bv_page);
- bio->bi_end_io = btrfs_writepage_endio;
+ if (bio_op(bio) == REQ_OP_WRITE)
+ bio->bi_end_io = btrfs_writepage_endio;
+ else
+ bio->bi_end_io = btrfs_readpage_endio;
+
if (is_data_inode(inode))
btrfs_submit_data_bio(inode, bio, 0, 0);
else