[Devel] [PATCH RHEL7 COMMIT] ploop: do not use fiemap beyond eof

Konstantin Khorenko khorenko at virtuozzo.com
Thu Oct 8 07:40:44 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-229.7.2.vz7.8.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.8.4
------>
commit ec4f6defee626918fb28b89b939fd239c97e7145
Author: Maxim Patlasov <MPatlasov at openvz.org>
Date:   Thu Oct 8 18:40:43 2015 +0400

    ploop: do not use fiemap beyond eof
    
    map_extent_get_block() optimizes I/O by merging adjacent ext4 extents. However,
    it's useless to ask ext4 about layout beyond EOF because ploop always extends
    image file by fallocate() w/o FALLOC_FL_KEEP_SIZE flag.
    
    And more than that -- it can be also dangerous because userspace merge
    utility may race with us extending image file by ordinary write-s resulting
    in (temporary) FIEMAP_EXTENT_DELALLOC extents.
    
    https://jira.sw.ru/browse/PSBM-26762
    https://jira.sw.ru/browse/PSBM-39251
    
    Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
---
 drivers/block/ploop/io_direct_map.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/block/ploop/io_direct_map.c b/drivers/block/ploop/io_direct_map.c
index c1d889b..977adc2 100644
--- a/drivers/block/ploop/io_direct_map.c
+++ b/drivers/block/ploop/io_direct_map.c
@@ -776,6 +776,11 @@ struct extent_map *map_extent_get_block(struct ploop_io *io,
 	 * something bigger.
 	 */
 	do {
+		/* avoid race with userspace merge */
+		if (em->end >=
+		    ((sector_t)io->alloc_head << io->plo->cluster_log))
+			break;
+
 		last = em->end;
 		extent_put(em);
 		em = __map_extent(io, mapping, last, len, create,



More information about the Devel mailing list