Skip to contentSkip to conversation

block: rate-limit capacity change info log

PATCH Applied Li Chen 4 participants 4 messages Nov 17, 2025

Subsystems (2)
lore
Share & tools
lore

Li Chen

author
#0 lore raw

PATCH 1/1 block: rate-limit capacity change info log

From: Li Chen <[email protected]>

loop devices under heavy stress-ng loop streessor can trigger many capacity change events in a short time. Each event prints an info message from set_capacity_and_notify(), flooding the console and contributing to soft lockups on slow consoles.

Switch the printk in set_capacity_and_notify() to pr_info_ratelimited() so frequent capacity changes do not spam the log while still reporting occasional changes.

---
 block/genhd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/genhd.c +1 -1
index 9bbc38d12792..bd3a6841e5b5 100644
@@ -90,7 +90,7 @@ bool set_capacity_and_notify(struct gendisk *disk, sector_t size)
 	    (disk->flags & GENHD_FL_HIDDEN))
 		return false;
 
-	pr_info("%s: detected capacity change from %lld to %lld\n",
+	pr_info_ratelimited("%s: detected capacity change from %lld to %lld\n",
 		disk->disk_name, capacity, size);
 
 	/*
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 22 lines · Li Chen

From: Li Chen <[email protected]>

loop devices under heavy stress-ng loop streessor can trigger many capacity change events in a short time. Each event prints an info message from set_capacity_and_notify(), flooding the console and contributing to soft lockups on slow consoles.

Switch the printk in set_capacity_and_notify() to pr_info_ratelimited() so frequent capacity changes do not spam the log while still reporting occasional changes.

---
  block/genhd.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
block/genhd.c +0 -0
index 9bbc38d12792..bd3a6841e5b5 100644

block/genhd.c bool set_capacity_and_notify(struct gendisk *disk, sector_t size) · line 96

Quoted 8 lines
block/genhd.c +1 -1
@@ -90,7 +90,7 @@ bool set_capacity_and_notify(struct gendisk *disk, sector_t size)
  	    (disk->flags & GENHD_FL_HIDDEN))
  		return false;
 
-	pr_info("%s: detected capacity change from %lld to %lld\n",
+	pr_info_ratelimited("%s: detected capacity change from %lld to %lld\n",
  		disk->disk_name, capacity, size);
 
  	/*
Reviewed-by on v1 1/1
#2 lore raw
In reply to Li Chen
Quoted 7 lines · Li Chen

From: Li Chen<[email protected]>

loop devices under heavy stress-ng loop streessor can trigger many capacity change events in a short time. Each event prints an info message from set_capacity_and_notify(), flooding the console and contributing to soft lockups on slow consoles.

Quoted 6 lines

Switch the printk in set_capacity_and_notify() to pr_info_ratelimited() so frequent capacity changes do not spam the log while still reporting occasional changes.

Looks good.

-ck

maintainer Applied
#3 lore raw
In reply to Li Chen
Quoted 10 lines · Li Chen

loop devices under heavy stress-ng loop streessor can trigger many capacity change events in a short time. Each event prints an info message from set_capacity_and_notify(), flooding the console and contributing to soft lockups on slow consoles.

Switch the printk in set_capacity_and_notify() to pr_info_ratelimited() so frequent capacity changes do not spam the log while still reporting occasional changes.

[...]

Applied, thanks!

[1/1] block: rate-limit capacity change info log

      commit: 3179a5f7f86bcc3acd5d6fb2a29f891ef5615852

Best regards,

Signature · 1 line
Jens Axboe