[Devel] [PATCH RHEL9 COMMIT] ploop: Fallback to zero range for backing stores without punch hole support

Konstantin Khorenko khorenko at virtuozzo.com
Fri Apr 7 20:22:42 MSK 2023


The commit is pushed to "branch-rh9-5.14.0-162.18.1.vz9.19.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-162.18.1.vz9.19.3
------>
commit 25d321e91113f69e273c4c75192414126d9edd4a
Author: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
Date:   Fri Apr 7 18:58:56 2023 +0300

    ploop: Fallback to zero range for backing stores without punch hole support
    
    Using punch hole is on by default but it might not be supported by
    the backing store. Gracefully fall back to use zero range in that case.
    
    Ratelimit errors from punch hole/zero range to reduce log clutter.
    
    https://jira.vzint.dev/browse/PSBM-146678
    Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
    Feature: dm-ploop: ploop target driver
---
 drivers/md/dm-ploop-map.c | 11 ++++++++---
 drivers/md/dm-ploop.h     |  1 +
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 0882c714af72..640cf8428d9b 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -1050,12 +1050,17 @@ static int ploop_allocate_cluster(struct ploop *ploop, u32 *dst_clu)
 	if (pos < top->file_preallocated_area_start) {
 		/* Clu at @pos may contain dirty data */
 		off = min_t(loff_t, old_size, end);
-		if (!ploop->falloc_new_clu)
+		if (!ploop->falloc_new_clu) {
 			ret = ploop_punch_hole(file, pos, off - pos);
-		else
+			if (unlikely(ret == -EOPNOTSUPP)) {
+				ploop->falloc_new_clu = 1;
+				PL_WARN("punch hole unsupported - disabling");
+			}
+		} else
 			ret = ploop_zero_range(file, pos, off - pos);
 		if (ret) {
-			PL_ERR("punch/zero area: %d", ret);
+			if (printk_ratelimit())
+				PL_ERR("punch/zero area: %d", ret);
 			return ret;
 		}
 	}
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 2d1db3fc8c57..646b107c4300 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -550,6 +550,7 @@ static inline const char *ploop_device_name(struct ploop *ploop)
 
 #define PL_FMT(fmt) "ploop: %s: " fmt "\n"
 #define PL_ERR(fmt, ...) pr_err(PL_FMT(fmt), ploop_device_name(ploop), ##__VA_ARGS__)
+#define PL_WARN(fmt, ...) pr_warn(PL_FMT(fmt), ploop_device_name(ploop), ##__VA_ARGS__)
 #define PL_INFO(fmt, ...) pr_info(PL_FMT(fmt), ploop_device_name(ploop), ##__VA_ARGS__)
 
 extern void ploop_md_page_insert(struct ploop *ploop, struct md_page *md);


More information about the Devel mailing list