2022-04-12 22:17:08

by Gabriel Krisman Bertazi

[permalink] [raw]
Subject: Re: [RFC PATCH] ext4: add unmount filesystem message

Zhang Yi <[email protected]> writes:

> Now that we have kernel message at mount time, system administrator
> could acquire the mount time, device and options easily. But we don't
> have corresponding unmounting message at umount time, so we cannot know
> if someone umount a filesystem easily. Some of the modern filesystems
> (e.g. xfs) have the umounting kernel message, so add one for ext4
> filesystem for convenience.
>
> EXT4-fs (sdb): mounted filesystem with ordered data mode. Quota mode: none.
> EXT4-fs (sdb): unmounting filesystem.

I don't think sysadmins should be relying on the kernel log for this,
since the information can easily be overwritten by new messages there.
Is there a reason why you can't just monitor /proc/self/mountinfo?

> Signed-off-by: Zhang Yi <[email protected]>
> ---
> fs/ext4/super.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 81749eaddf4c..bdecf62f4b55 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -1199,6 +1199,9 @@ static void ext4_put_super(struct super_block *sb)
> int aborted = 0;
> int i, err;
>
> + if (___ratelimit(&ext4_mount_msg_ratelimit, "EXT4-fs unmount"))
> + ext4_msg(sb, KERN_INFO, "unmounting filesystem.");
> +
> ext4_unregister_li_request(sb);
> ext4_quota_off_umount(sb);

--
Gabriel Krisman Bertazi


2022-04-13 09:50:23

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [RFC PATCH] ext4: add unmount filesystem message

On Tue, Apr 12, 2022 at 12:01:37PM -0400, Gabriel Krisman Bertazi wrote:
> Zhang Yi <[email protected]> writes:
>
> > Now that we have kernel message at mount time, system administrator

"Now that we have...." is a bit misleading, since (at least to an
English speaker) that this is something that was recently added, and
that's not the case.

> > could acquire the mount time, device and options easily. But we don't
> > have corresponding unmounting message at umount time, so we cannot know
> > if someone umount a filesystem easily. Some of the modern filesystems
> > (e.g. xfs) have the umounting kernel message, so add one for ext4
> > filesystem for convenience.
> >
> > EXT4-fs (sdb): mounted filesystem with ordered data mode. Quota mode: none.
> > EXT4-fs (sdb): unmounting filesystem.
>
> I don't think sysadmins should be relying on the kernel log for this,
> since the information can easily be overwritten by new messages there.
> Is there a reason why you can't just monitor /proc/self/mountinfo?

You're right that it can be dangerous for sysadmins to be relying on
the kernel log for mount and umount notifications --- but it depends
on what they think it means, and the potential pitfalls are there for
both the mount and unmount messages. The problem of course, is that
bind mounts, and mount name spaces, so if the question is whether a
file system is available at a particular mount point, then using the
kernel log is definitely not going to be reliable.

But if the goal is to determine whether a particular device is safe to
run fsck or otherwise access directly, or for the purposes of
debugging the kernel and looking at the logs to understand when the
device is being accessed by the kernel and when the file system is
done with the device, I can see how it might be useful.

Cheers,

- Ted