[Devel] [PATCH RHEL7 COMMIT] ploop: Add @write argument to ->fastmap

Vasily Averin vvs at virtuozzo.com
Fri Aug 7 09:01:34 MSK 2020


The commit is pushed to "branch-rh7-3.10.0-1127.18.2.vz7.163.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.18.2.vz7.163.1
------>
commit fe49ec7497b04d183eea8954bb21e06edc595d85
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Fri Aug 7 09:01:34 2020 +0300

    ploop: Add @write argument to ->fastmap
    
    Patchset descritpyion:
    ploop: Protect fastmap against defrag and punch hole
    https://jira.sw.ru/browse/PSBM-105347
    
    This protects fastmap against mapped extent disappearance,
    which may be a result of extenal actions (move extent and
    punch hole) on root.hds. Thus, root.hds becomes more "normal"
    file.
    
    Kirill Tkhai (4):
          ploop: Introduce ->fastmap_end_io
          ploop: Add @write argument to ->fastmap
          fs: Export mapping_needs_writeback()
          ploop: io_kaio: Protect ->fastmap against EXT4_IOC_MOVE_EXT and punch hole
    
    Current patch description:
    [PATCH 2/4] ploop: Add @write argument to ->fastmap
    
    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 at 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(-)

diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index 89e39ff..9cbe923 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 edaf966..57a8cc2 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 13bb2bc..f2daf45 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;
 
 


More information about the Devel mailing list