[Devel] [PATCH RH7] ploop: Sanity in kaio_open()

Kirill Tkhai ktkhai at virtuozzo.com
Thu Nov 18 13:08:16 MSK 2021


1)Check for kaio_invalidate_cache() return value.
2)Add sync for the case when userspace skipped
to do that (if userspace skipped, kaio_invalidate_cache()
will fail).

https://jira.sw.ru/browse/PSBM-135881
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/block/ploop/io_kaio.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index bc245ea3a5b3..e24952703549 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -962,9 +962,14 @@ static int kaio_open(struct ploop_io * io)
 	io->files.inode = io->files.mapping->host;
 	io->files.bdev = io->files.inode->i_sb->s_bdev;
 
+	err = io->ops->sync(io);
+	if (err)
+		return err;
+
 	mutex_lock(&io->files.inode->i_mutex);
-	kaio_invalidate_cache(io);
-	err = ploop_kaio_open(file, delta->flags & PLOOP_FMT_RDONLY);
+	err = kaio_invalidate_cache(io);
+	if (!err)
+		err = ploop_kaio_open(file, delta->flags & PLOOP_FMT_RDONLY);
 	mutex_unlock(&io->files.inode->i_mutex);
 
 	if (err)




More information about the Devel mailing list