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

Alexander Atanasov alexander.atanasov at virtuozzo.com
Tue May 23 21:08:41 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 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

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;
 		}
 	}
-- 
2.39.1



More information about the Devel mailing list