]> www.infradead.org Git - users/hch/block.git/commitdiff
block: add a bdev_read_cache_page helper
authorChristoph Hellwig <hch@lst.de>
Tue, 12 Oct 2021 08:01:51 +0000 (10:01 +0200)
committerChristoph Hellwig <hch@lst.de>
Tue, 12 Oct 2021 08:29:36 +0000 (10:29 +0200)
Add a helper to read a pagecache page from a block device.  This allows
to hide accesses to ->bd_inode.

Signed-off-by: Christoph Hellwig <hch@lst.de>
block/bdev.c
include/linux/blkdev.h

index 567534c63f3d541f5e850d606ddb565f1b8793eb..9528b4cc2ffac619453e74a31a39616c8537bb1a 100644 (file)
@@ -1057,3 +1057,10 @@ void iterate_bdevs(void (*func)(struct block_device *, void *), void *arg)
        spin_unlock(&blockdev_superblock->s_inode_list_lock);
        iput(old_inode);
 }
+
+struct page *bdev_read_cache_page(struct block_device *bdev, pgoff_t index,
+               gfp_t gfp)
+{
+       return read_cache_page_gfp(bdev->bd_inode->i_mapping, index, gfp);
+}
+EXPORT_SYMBOL_GPL(bdev_read_cache_page);
index 17705c970d7e1871f92811c2460e980267a6fbe0..86a7884fe5f408fece8fadefcff1055285a9233d 100644 (file)
@@ -1206,6 +1206,9 @@ extern int blkdev_compat_ptr_ioctl(struct block_device *, fmode_t,
 #define blkdev_compat_ptr_ioctl NULL
 #endif
 
+struct page *bdev_read_cache_page(struct block_device *bdev, pgoff_t index,
+               gfp_t gfp);
+
 extern int bdev_read_page(struct block_device *, sector_t, struct page *);
 extern int bdev_write_page(struct block_device *, sector_t, struct page *,
                                                struct writeback_control *);