[Devel] [PATCH RHEL7 COMMIT] ploop: Add debug check on truncation to kaio_fsync_thread

Konstantin Khorenko khorenko at virtuozzo.com
Tue Feb 11 15:59:23 MSK 2020


The commit is pushed to "branch-rh7-3.10.0-1062.12.1.vz7.131.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1062.12.1.vz7.131.1
------>
commit 68da776196b3c34cce53207cbdbb3b522a1350ab
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Tue Feb 11 15:59:23 2020 +0300

    ploop: Add debug check on truncation to kaio_fsync_thread
    
    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 beafc0a68c2ba..9ed448bf00261 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