[Devel] [PATCH rh7 2/2] ploop: Add debug check on truncation to kaio_fsync_thread

Kirill Tkhai ktkhai at virtuozzo.com
Fri Feb 7 13:23:09 MSK 2020


https://jira.sw.ru/browse/PSBM-101418

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/block/ploop/io_kaio.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index 9f391620a4f7..1cac861e9be0 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -479,6 +479,7 @@ static int kaio_fsync_thread(void * data)
 {
 	struct ploop_io * io = data;
 	struct ploop_device * plo = io->plo;
+	loff_t isize;
 
 	set_user_nice(current, -20);
 
@@ -512,6 +513,9 @@ static int kaio_fsync_thread(void * data)
 
 		/* trick: preq->prealloc_size is actually new pos of eof */
 		if (preq->prealloc_size) {
+			isize = i_size_read(io->files.inode);
+			if (WARN_ON_ONCE(preq->prealloc_size < isize))
+				goto out;
 			err = kaio_truncate(io, io->files.file,
 					    preq->prealloc_size >> (plo->cluster_log + 9));
 			if (err)
@@ -536,7 +540,7 @@ static int kaio_fsync_thread(void * data)
 				}
 			}
 		}
-
+out:
 		spin_lock_irq(&plo->lock);
 		list_add_tail(&preq->list, &plo->ready_queue);
 




More information about the Devel mailing list