[Devel] [PATCH vz7 v2] ploop: rework logging when punch hole or zero range is unsupported

Alexander Atanasov alexander.atanasov at virtuozzo.com
Fri May 26 10:57:19 MSK 2023


We added a fallback to zero range if punch hole is not supported
but when zero range is not supported either the log gets flooded.

Rework logging and restrict unsupported log messages to just one.

https://jira.vzint.dev/browse/PSBM-147401
Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
 drivers/md/dm-ploop-map.c | 16 +++++++++-------
 drivers/md/dm-ploop.h     |  1 +
 2 files changed, 10 insertions(+), 7 deletions(-)

v1->v2: add missed change

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 640cf8428d9b..589d49429cf9 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -1050,17 +1050,19 @@ 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);
-			if (unlikely(ret == -EOPNOTSUPP)) {
-				ploop->falloc_new_clu = 1;
-				PL_WARN("punch hole unsupported - disabling");
-			}
-		} else
+		else
 			ret = ploop_zero_range(file, pos, off - pos);
 		if (ret) {
-			if (printk_ratelimit())
+			if (ret != -EOPNOTSUPP)
 				PL_ERR("punch/zero area: %d", ret);
+			else if (ploop->falloc_new_clu)
+				PL_ERR_ONCE("zero range unsupported");
+			else if (!ploop->falloc_new_clu) {
+				ploop->falloc_new_clu = 1;
+				PL_WARN("punch hole unsupported - disabling");
+			}
 			return ret;
 		}
 	}
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 646b107c4300..bde1d28c9436 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_ERR_ONCE(fmt, ...) pr_err_once(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__)
 
-- 
2.39.1



More information about the Devel mailing list