Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH] btrfs: remove stub device info from messages when we have no fs_info
@ 2020-11-20 15:43 David Sterba
  2020-11-21  8:35 ` Anand Jain
  0 siblings, 1 reply; 2+ messages in thread
From: David Sterba @ 2020-11-20 15:43 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Without a NULL fs_info the helpers will print something like

	BTRFS error (device <unknown>): ...

This can happen in contexts where fs_info is not available at all or
it's potentially unsafe due to object lifetime. The <unknown> stub does
not bring much information and with the prefix makes the message
unnecessarily longer.

Remove it for the NULL fs_info case.

	BTRFS error: ...

Callers can add the device information to the message itself if needed.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/super.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 6693cfc14dfd..348f8899f4f4 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -240,9 +240,13 @@ void __cold btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, .
 	vaf.fmt = fmt;
 	vaf.va = &args;
 
-	if (__ratelimit(ratelimit))
-		printk("%sBTRFS %s (device %s): %pV\n", lvl, type,
-			fs_info ? fs_info->sb->s_id : "<unknown>", &vaf);
+	if (__ratelimit(ratelimit)) {
+		if (fs_info)
+			printk("%sBTRFS %s (device %s): %pV\n", lvl, type,
+				fs_info->sb->s_id, &vaf);
+		else
+			printk("%sBTRFS %s: %pV\n", lvl, type, &vaf);
+	}
 
 	va_end(args);
 }
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-21  8:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-20 15:43 [PATCH] btrfs: remove stub device info from messages when we have no fs_info David Sterba
2020-11-21  8:35 ` Anand Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox