Skip to content

Commit 98f18c7

Browse files
Eric Sandeenjankara
authored andcommitted
ext2: create ext2_msg_fc for use during parsing
Rather than send a NULL sb to ext2_msg, which omits the s_id from messages, create a new ext2_msg_fc which is able to provide this information from the filesystem context *fc when parsing. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Jan Kara <jack@suse.cz> Link: https://patch.msgid.link/20250223201014.7541-3-sandeen@redhat.com
1 parent eab61d3 commit 98f18c7

File tree

1 file changed

+37
-13
lines changed

1 file changed

+37
-13
lines changed

fs/ext2/super.c

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,33 @@ void ext2_error(struct super_block *sb, const char *function,
8181
}
8282
}
8383

84+
static void ext2_msg_fc(struct fs_context *fc, const char *prefix,
85+
const char *fmt, ...)
86+
{
87+
struct va_format vaf;
88+
va_list args;
89+
const char *s_id;
90+
91+
if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) {
92+
s_id = fc->root->d_sb->s_id;
93+
} else {
94+
/* get last path component of source */
95+
s_id = strrchr(fc->source, '/');
96+
if (s_id)
97+
s_id++;
98+
else
99+
s_id = fc->source;
100+
}
101+
va_start(args, fmt);
102+
103+
vaf.fmt = fmt;
104+
vaf.va = &args;
105+
106+
printk("%sEXT2-fs (%s): %pV\n", prefix, s_id, &vaf);
107+
108+
va_end(args);
109+
}
110+
84111
void ext2_msg(struct super_block *sb, const char *prefix,
85112
const char *fmt, ...)
86113
{
@@ -92,10 +119,7 @@ void ext2_msg(struct super_block *sb, const char *prefix,
92119
vaf.fmt = fmt;
93120
vaf.va = &args;
94121

95-
if (sb)
96-
printk("%sEXT2-fs (%s): %pV\n", prefix, sb->s_id, &vaf);
97-
else
98-
printk("%sEXT2-fs: %pV\n", prefix, &vaf);
122+
printk("%sEXT2-fs (%s): %pV\n", prefix, sb->s_id, &vaf);
99123

100124
va_end(args);
101125
}
@@ -544,7 +568,7 @@ static int ext2_parse_param(struct fs_context *fc, struct fs_parameter *param)
544568
ctx_clear_mount_opt(ctx, EXT2_MOUNT_OLDALLOC);
545569
break;
546570
case Opt_nobh:
547-
ext2_msg(NULL, KERN_INFO, "nobh option not supported\n");
571+
ext2_msg_fc(fc, KERN_INFO, "nobh option not supported\n");
548572
break;
549573
#ifdef CONFIG_EXT2_FS_XATTR
550574
case Opt_user_xattr:
@@ -555,7 +579,7 @@ static int ext2_parse_param(struct fs_context *fc, struct fs_parameter *param)
555579
break;
556580
#else
557581
case Opt_user_xattr:
558-
ext2_msg(NULL, KERN_INFO, "(no)user_xattr options not supported");
582+
ext2_msg_fc(fc, KERN_INFO, "(no)user_xattr options not supported");
559583
break;
560584
#endif
561585
#ifdef CONFIG_EXT2_FS_POSIX_ACL
@@ -567,20 +591,20 @@ static int ext2_parse_param(struct fs_context *fc, struct fs_parameter *param)
567591
break;
568592
#else
569593
case Opt_acl:
570-
ext2_msg(NULL, KERN_INFO, "(no)acl options not supported");
594+
ext2_msg_fc(fc, KERN_INFO, "(no)acl options not supported");
571595
break;
572596
#endif
573597
case Opt_xip:
574-
ext2_msg(NULL, KERN_INFO, "use dax instead of xip");
598+
ext2_msg_fc(fc, KERN_INFO, "use dax instead of xip");
575599
ctx_set_mount_opt(ctx, EXT2_MOUNT_XIP);
576600
fallthrough;
577601
case Opt_dax:
578602
#ifdef CONFIG_FS_DAX
579-
ext2_msg(NULL, KERN_WARNING,
603+
ext2_msg_fc(fc, KERN_WARNING,
580604
"DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
581605
ctx_set_mount_opt(ctx, EXT2_MOUNT_DAX);
582606
#else
583-
ext2_msg(NULL, KERN_INFO, "dax option not supported");
607+
ext2_msg_fc(fc, KERN_INFO, "dax option not supported");
584608
#endif
585609
break;
586610

@@ -597,16 +621,16 @@ static int ext2_parse_param(struct fs_context *fc, struct fs_parameter *param)
597621
case Opt_quota:
598622
case Opt_usrquota:
599623
case Opt_grpquota:
600-
ext2_msg(NULL, KERN_INFO, "quota operations not supported");
624+
ext2_msg_fc(fc, KERN_INFO, "quota operations not supported");
601625
break;
602626
#endif
603627
case Opt_reservation:
604628
if (!result.negated) {
605629
ctx_set_mount_opt(ctx, EXT2_MOUNT_RESERVATION);
606-
ext2_msg(NULL, KERN_INFO, "reservations ON");
630+
ext2_msg_fc(fc, KERN_INFO, "reservations ON");
607631
} else {
608632
ctx_clear_mount_opt(ctx, EXT2_MOUNT_RESERVATION);
609-
ext2_msg(NULL, KERN_INFO, "reservations OFF");
633+
ext2_msg_fc(fc, KERN_INFO, "reservations OFF");
610634
}
611635
break;
612636
case Opt_ignore:

0 commit comments

Comments
 (0)