Skip to contentSkip to conversation

buffer_io_error: Use dev_err_ratelimited

PATCH New Tony Asleson 1 participant 1 message Nov 17, 2020 VFS

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 buffer_io_error: Use dev_err_ratelimited

Replace printk_ratelimited with dev_err_ratelimited which adds dev_printk meta data. This is used by journald to add disk ID information to the journal entry.

---

V2:

- Move change log to after marker line (Andy Shevchenko)
- Remove printk cast (Andy Shevchenko)

V1:

This re-worked change is from a different patch series and utilizes the following suggestions.

- Reduce indentation level (Andy Shevchenko)
- Remove unneeded () for conditional operator (Sergei Shtylyov)

 fs/buffer.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
fs/buffer.c +11 -4
index 50bbc99e3d96..32f237e350bf 100644
@@ -125,10 +125,17 @@ EXPORT_SYMBOL(__wait_on_buffer);
 
 static void buffer_io_error(struct buffer_head *bh, char *msg)
 {
-	if (!test_bit(BH_Quiet, &bh->b_state))
-		printk_ratelimited(KERN_ERR
-			"Buffer I/O error on dev %pg, logical block %llu%s\n",
-			bh->b_bdev, (unsigned long long)bh->b_blocknr, msg);
+	struct device *gendev;
+
+	if (test_bit(BH_Quiet, &bh->b_state))
+		return;
+
+	gendev = bh->b_bdev->bd_disk ?
+		disk_to_dev(bh->b_bdev->bd_disk) : NULL;
+
+	dev_err_ratelimited(gendev,
+		"Buffer I/O error, logical block %llu%s\n",
+		bh->b_blocknr, msg);
 }
 
 /*

base-commit: bbf5c979011a099af5dc76498918ed7df445635b

Signature · 1 line
2.26.2