|
|
@@ -1307,3 +1307,37 @@ int iomap_swapfile_activate(struct swap_info_struct *sis,
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(iomap_swapfile_activate);
|
|
|
#endif /* CONFIG_SWAP */
|
|
|
+
|
|
|
+static loff_t
|
|
|
+iomap_bmap_actor(struct inode *inode, loff_t pos, loff_t length,
|
|
|
+ void *data, struct iomap *iomap)
|
|
|
+{
|
|
|
+ sector_t *bno = data, addr;
|
|
|
+
|
|
|
+ if (iomap->type == IOMAP_MAPPED) {
|
|
|
+ addr = (pos - iomap->offset + iomap->addr) >> inode->i_blkbits;
|
|
|
+ if (addr > INT_MAX)
|
|
|
+ WARN(1, "would truncate bmap result\n");
|
|
|
+ else
|
|
|
+ *bno = addr;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+/* legacy ->bmap interface. 0 is the error return (!) */
|
|
|
+sector_t
|
|
|
+iomap_bmap(struct address_space *mapping, sector_t bno,
|
|
|
+ const struct iomap_ops *ops)
|
|
|
+{
|
|
|
+ struct inode *inode = mapping->host;
|
|
|
+ loff_t pos = bno >> inode->i_blkbits;
|
|
|
+ unsigned blocksize = i_blocksize(inode);
|
|
|
+
|
|
|
+ if (filemap_write_and_wait(mapping))
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ bno = 0;
|
|
|
+ iomap_apply(inode, pos, blocksize, 0, ops, &bno, iomap_bmap_actor);
|
|
|
+ return bno;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL_GPL(iomap_bmap);
|