This allows fastmap to work, otherwise it fails on mapping_needs_writeback() check.
Signed-off-by: Kirill Tkhai <ktk...@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 be74b2ec344f..112fd92acb40 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; _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel