[RH7,2/4] ploop: Add @write argument to ->fastmap

Submitted by Kirill Tkhai on Aug. 6, 2020, 11:55 a.m.

Details

Message ID 159671492571.36238.2119905649639611043.stgit@localhost.localdomain
State New
Series "ploop: Protect fastmap against defrag and punch hole"
Headers show

Commit Message

Kirill Tkhai Aug. 6, 2020, 11:55 a.m.
This allows to differ READ and WRITE request. We need
that, since they are required to be protected differently.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/block/ploop/io_kaio.c |    3 ++-
 fs/ext4/file.c                |    2 +-
 include/linux/fs.h            |    2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index 89e39ff1b926..9cbe923b14bf 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -1206,7 +1206,8 @@  kaio_fastmap(struct ploop_io *io, struct bio *orig_bio,
 		return 0;
 	}
 
-	ret = inode->i_op->fastmap(inode, isec, orig_bio->bi_size, &phys_sec);
+	ret = inode->i_op->fastmap(inode, isec, orig_bio->bi_size, &phys_sec,
+				   orig_bio->bi_rw & REQ_WRITE);
 	if (ret < 0) {
 		io->plo->st.fast_neg_noem++;
 		return 1;
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index edaf966c9a2f..57a8cc2b8e3f 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -126,7 +126,7 @@  static bool ext4_overwrite_io(struct inode *inode, loff_t pos, loff_t len)
 }
 
 static int ext4_fastmap(struct inode *inode, sector_t lblk_sec,
-			unsigned int len, sector_t *pblk_sec)
+			unsigned int len, sector_t *pblk_sec, bool write)
 {
 	struct ext4_map_blocks map;
 	loff_t pos = lblk_sec << 9;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 598d7ec03578..bb3bab24fae1 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2013,7 +2013,7 @@  struct inode_operations {
 	int (*atomic_open)(struct inode *, struct dentry *,
 			   struct file *, unsigned open_flag,
 			   umode_t create_mode, int *opened);
-	int (*fastmap)(struct inode *, sector_t, unsigned int, sector_t *);
+	int (*fastmap)(struct inode *, sector_t, unsigned int, sector_t *, bool);
 } ____cacheline_aligned;