[RHEL7,COMMIT] ploop kaio: successfull alloc should adjust alloc_head

Submitted by Konstantin Khorenko on Nov. 6, 2018, 8:24 a.m.

Details

Message ID 201811060824.wA68OmcJ032127@finist-ce7.sw.ru
State New
Series "ploop kaio: successfull alloc should adjust alloc_head"
Headers show

Commit Message

Konstantin Khorenko Nov. 6, 2018, 8:24 a.m.
The commit is pushed to "branch-rh7-3.10.0-862.14.4.vz7.72.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.14.4.vz7.72.20
------>
commit 109f7fa5d2099ac94c705a42cf2cec677a458201
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Tue Nov 6 11:24:48 2018 +0300

    ploop kaio: successfull alloc should adjust alloc_head
    
    Patch fixes data corruptiopn after online resize of empty ploop image located
    on vstorage.
    
    Online ploop grow for on vstorage does not update ploop_io->alloc_head
    therefore following write requests incorrectly recognizes location of first
    data block, and can write data into metadata section of image.
    
    https://pmc.acronis.com/browse/VSTOR-15471
    
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
    Reviewed-by: Denis V. Lunev <den@openvz.org>
---
 drivers/block/ploop/io_kaio.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index 8a1fbe6f7b6e..e97e8e1a334d 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -858,7 +858,12 @@  kaio_sync_write(struct ploop_io * io, struct page * page, unsigned int len,
 
 static int kaio_alloc_sync(struct ploop_io * io, loff_t pos, loff_t len)
 {
-	return __kaio_truncate(io, io->files.file, pos + len);
+	int err = __kaio_truncate(io, io->files.file, pos + len);
+
+	if (!err)
+		io->alloc_head = (pos + len) >> (io->plo->cluster_log + 9);
+
+	return err;
 }
 
 static int kaio_open(struct ploop_io * io)