[Devel] [PATCH RHEL7 COMMIT] ploop: io_direct must fsync after fallocate
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Apr 8 02:14:59 PDT 2016
The commit is pushed to "branch-rh7-3.10.0-327.10.1.vz7.12.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.10.1.vz7.12.6
------>
commit 290460b9ae7a6add1de0ed4fcfba13ed0cbd9234
Author: Maxim Patlasov <mpatlasov at virtuozzo.com>
Date: Fri Apr 8 13:14:59 2016 +0400
ploop: io_direct must fsync after fallocate
While handling fallocate(), ext4 firstly calls ext4_update_inode_size(),
then ext4_mark_inode_dirty(). Both update only in-core state. After
fallocate(), ploop updates BAT bypassing vfs layer (submit bio to
underlying block device). Hence, it's possible that BAT is already
updated, but i_size in now written to the disk yet. If a crash happens
in the middle, BAT points beyond end-of-file, i.e. ploop image is
corrupted.
The patch fixes the problem by ordinary fsync(). This is OK because
we fallocate relatively seldom (PLOOP_MAX_PREALLOC=128MB) and also
because no dirty pages to sync (all I/O is direct).
https://jira.sw.ru/browse/PSBM-45326
Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
Acked-by: Dmitry Monakhov <dmonakhov at virtuozzo.com>
---
drivers/block/ploop/io_direct.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/block/ploop/io_direct.c b/drivers/block/ploop/io_direct.c
index 0c7e0c4..8032999 100644
--- a/drivers/block/ploop/io_direct.c
+++ b/drivers/block/ploop/io_direct.c
@@ -376,6 +376,7 @@ cached_submit(struct ploop_io *io, iblock_t iblk, struct ploop_request * preq,
loff_t new_size;
loff_t used_pos;
bool may_fallocate = io->files.file->f_op->fallocate &&
+ io->files.file->f_op->fsync &&
io->files.flags & EXT4_EXTENTS_FL;
trace_cached_submit(preq);
@@ -404,6 +405,11 @@ try_again:
}
}
+ /* flush new i_size to disk */
+ err = io->files.file->f_op->FOP_FSYNC(io->files.file, 0);
+ if (err)
+ goto end_write;
+
io->prealloced_size = prealloc;
}
More information about the Devel
mailing list