@@ -15,7 +15,7 @@
#include "file-item.h"
#include "raid-stripe-tree.h"
-static struct bio_set btrfs_bioset;
+struct bio_set btrfs_bioset;
static struct bio_set btrfs_clone_bioset;
static struct bio_set btrfs_repair_bioset;
static mempool_t btrfs_failed_bio_pool;
@@ -15,6 +15,7 @@
struct btrfs_bio;
struct btrfs_fs_info;
struct btrfs_inode;
+extern struct bio_set btrfs_bioset;
#define BTRFS_BIO_INLINE_CSUM_SIZE 64
@@ -985,10 +985,39 @@ static int btrfs_read_iomap_begin(struct inode *inode, loff_t pos,
return 0;
}
+static void btrfs_read_endio(struct btrfs_bio *bbio)
+{
+ iomap_read_end_io(&bbio->bio);
+}
+
+static void btrfs_read_submit_io(struct inode *inode, struct bio *bio,
+ const struct iomap *iomap)
+{
+ struct btrfs_bio *bbio = btrfs_bio(bio);
+ struct folio_iter fi;
+
+ btrfs_bio_init(bbio, btrfs_sb(inode->i_sb), btrfs_read_endio, NULL);
+ bbio->inode = BTRFS_I(inode);
+
+ bio_first_folio(&fi, bio, 0);
+ bbio->file_offset = folio_pos(fi.folio);
+
+ if (iomap->type & IOMAP_ENCODED) {
+ bbio->bio.bi_iter.bi_sector = iomap->addr >> SECTOR_SHIFT;
+ btrfs_submit_compressed_read(bbio);
+ } else {
+ btrfs_submit_bbio(bbio, 0);
+ }
+}
+
static const struct iomap_ops btrfs_buffered_read_iomap_ops = {
.iomap_begin = btrfs_read_iomap_begin,
};
+static const struct iomap_read_folio_ops btrfs_iomap_read_folio_ops = {
+ .submit_io = btrfs_read_submit_io,
+ .bio_set = &btrfs_bioset,
+};
/*
* basic readpage implementation. Locked extent state structs are inserted