[PATCH RFC] vfs: always log mount API fs context messages to dmesg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As filesystems are converted to the new mount API, informational messages,
errors, and warnings are being routed through infof, errorf, and warnf
type functions provided by the mount API, which places these messages in
the log buffer associated with the filesystem context rather than
in the kernel log / dmesg.

However, userspace is not yet extracting these messages, so they are
essentially getting lost. mount(8) still refers the user to dmesg(1)
on failure.

At least for now, modify logfc() to always log these messages to dmesg
as well as to the fileystem context. This way we can continue converting
filesystems to the new mount API interfaces without worrying about losing
this information until userspace can retrieve it.

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---

A few considerations/concerns:

* viro suggested that maybe this should be conditional - possibly config

* systemd is currently probing with a dummy mount option which will
  generate noise, see
  https://github.com/systemd/systemd/blob/main/src/basic/mountpoint-util.c#L759
  i.e. - 
  [   10.689256] proc: Unknown parameter 'adefinitelynotexistingmountoption'
  [   10.801045] tmpfs: Unknown parameter 'adefinitelynotexistingmountoption'
  [   11.119431] proc: Unknown parameter 'adefinitelynotexistingmountoption'
  [   11.692032] proc: Unknown parameter 'adefinitelynotexistingmountoption'

* will this generate other dmesg noise in general if the mount api messages
  are more noisy in general? (spot-checking old conversions, I don't think so.)

 fs/fs_context.c | 38 ++++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/fs/fs_context.c b/fs/fs_context.c
index 98589aae5208..3c78b99d5cae 100644
--- a/fs/fs_context.c
+++ b/fs/fs_context.c
@@ -427,8 +427,8 @@ struct fs_context *vfs_dup_fs_context(struct fs_context *src_fc)
 EXPORT_SYMBOL(vfs_dup_fs_context);
 
 /**
- * logfc - Log a message to a filesystem context
- * @log: The filesystem context to log to, or NULL to use printk.
+ * logfc - Log a message to dmesg and optionally a filesystem context
+ * @log: The filesystem context to log to, or NULL to use printk alone
  * @prefix: A string to prefix the output with, or NULL.
  * @level: 'w' for a warning, 'e' for an error.  Anything else is a notice.
  * @fmt: The format of the buffer.
@@ -439,22 +439,24 @@ void logfc(struct fc_log *log, const char *prefix, char level, const char *fmt,
 	struct va_format vaf = {.fmt = fmt, .va = &va};
 
 	va_start(va, fmt);
-	if (!log) {
-		switch (level) {
-		case 'w':
-			printk(KERN_WARNING "%s%s%pV\n", prefix ? prefix : "",
-						prefix ? ": " : "", &vaf);
-			break;
-		case 'e':
-			printk(KERN_ERR "%s%s%pV\n", prefix ? prefix : "",
-						prefix ? ": " : "", &vaf);
-			break;
-		default:
-			printk(KERN_NOTICE "%s%s%pV\n", prefix ? prefix : "",
-						prefix ? ": " : "", &vaf);
-			break;
-		}
-	} else {
+	switch (level) {
+	case 'w':
+		printk(KERN_WARNING "%s%s%pV\n", prefix ? prefix : "",
+					prefix ? ": " : "", &vaf);
+		break;
+	case 'e':
+		printk(KERN_ERR "%s%s%pV\n", prefix ? prefix : "",
+					prefix ? ": " : "", &vaf);
+		break;
+	default:
+		printk(KERN_NOTICE "%s%s%pV\n", prefix ? prefix : "",
+					prefix ? ": " : "", &vaf);
+		break;
+	}
+	va_end(va);
+
+	va_start(va, fmt);
+	if (log) {
 		unsigned int logsize = ARRAY_SIZE(log->buffer);
 		u8 index;
 		char *q = kasprintf(GFP_KERNEL, "%c %s%s%pV\n", level,
-- 
2.43.0





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux