[Devel] [PATCH RHEL7 COMMIT] ploop: Invalidate pagecache on service operations

Vasily Averin vvs at virtuozzo.com
Tue Nov 10 13:43:52 MSK 2020


The commit is pushed to "branch-rh7-3.10.0-1160.2.2.vz7.170.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.2.2.el7
------>
commit 24aef273109a6076d82eceb8f9417cdb2e9149fd
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Tue Nov 10 13:43:52 2020 +0300

    ploop: Invalidate pagecache on service operations
    
    This allows fastmap to work, otherwise it fails on
    mapping_needs_writeback() check.
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/block/ploop/io_kaio.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index be74b2e..112fd92 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -937,6 +937,15 @@ static int kaio_alloc_sync(struct ploop_io * io, loff_t pos, loff_t len)
 
 	return err;
 }
+static int kaio_invalidate_cache(struct ploop_io *io)
+{
+	struct inode *inode = io->files.inode;
+
+	if (!inode->i_op->fastmap)
+		return 0;
+
+	return invalidate_inode_pages2(io->files.mapping);
+}
 
 static int kaio_open(struct ploop_io * io)
 {
@@ -952,6 +961,7 @@ static int kaio_open(struct ploop_io * io)
 	io->files.bdev = io->files.inode->i_sb->s_bdev;
 
 	mutex_lock(&io->files.inode->i_mutex);
+	kaio_invalidate_cache(io);
 	err = ploop_kaio_open(file, delta->flags & PLOOP_FMT_RDONLY);
 	mutex_unlock(&io->files.inode->i_mutex);
 
@@ -1004,6 +1014,10 @@ static int kaio_prepare_snapshot(struct ploop_io * io, struct ploop_snapdata *sd
 		return err;
 	}
 
+	mutex_lock(&io->files.inode->i_mutex);
+	kaio_invalidate_cache(io);
+	mutex_unlock(&io->files.inode->i_mutex);
+
 	sd->file = file;
 	return 0;
 }
@@ -1024,6 +1038,10 @@ static int kaio_complete_snapshot(struct ploop_io * io, struct ploop_snapdata *s
 
 	ploop_kaio_downgrade(io->files.mapping);
 
+	mutex_lock(&io->files.inode->i_mutex);
+	kaio_invalidate_cache(io);
+	mutex_unlock(&io->files.inode->i_mutex);
+
 	if (io->fsync_thread) {
 		kthread_stop(io->fsync_thread);
 		io->fsync_thread = NULL;
@@ -1057,6 +1075,10 @@ static int kaio_prepare_merge(struct ploop_io * io, struct ploop_snapdata *sd)
 	if (err)
 		goto prep_merge_done;
 
+	mutex_lock(&io->files.inode->i_mutex);
+	kaio_invalidate_cache(io);
+	mutex_unlock(&io->files.inode->i_mutex);
+
 	err = ploop_kaio_upgrade(io->files.mapping);
 	if (err)
 		goto prep_merge_done;


More information about the Devel mailing list