Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: add dmesg output when mounting and unmounting
Date: Thu, 2 Nov 2023 09:16:19 +0800	[thread overview]
Message-ID: <18fda4f8-8f3c-4dd1-8aca-667726e278df@oracle.com> (raw)
In-Reply-To: <215e7eea95459d1b0cc4fd9ce522dc7c8f5d4e02.1698873846.git.wqu@suse.com>

On 11/2/23 05:24, Qu Wenruo wrote:
> There is a feature request to add dmesg output when unmounting a btrfs.
> 
> There are several alternative methods to do the same thing, but with
> their problems:
> 
> - Use eBPF to watch btrfs_put_super()/open_ctree()
>    Not end user friendly, they have to dip their head into the source
>    code.
> 
> - Watch for /sys/fs/<uuid>/
>    This is way more simpler, but still requires some simple device -> uuid
>    lookups.
>    And a script needs to use inotify to watch /sys/fs/.
> 


> Compared to all these, directly outputting the information into dmesg
> would be the most simple one, with both device and UUID included.
> 

Well, I submitted a patch for this in 2017, but I'm not sure why it 
wasn't integrated or commented.

https://lore.kernel.org/linux-btrfs/3352043d-dbb1-0055-f50a-c91ca43aff1d@oracle.com/

Thanks, Anand


> And since we're here, also add the output when mounting a btrfs, to keep
> the dmesg paired.
> 
> Now mounting a btrfs with all default mkfs options would look like this:
> 
> [   81.906566] BTRFS info (device dm-8): mounting filesystem 633b5c16-afe3-4b79-b195-138fe145e4f2
> [   81.907494] BTRFS info (device dm-8): using crc32c (crc32c-intel) checksum algorithm
> [   81.908258] BTRFS info (device dm-8): using free space tree
> [   81.912644] BTRFS info (device dm-8): auto enabling async discard
> [   81.913277] BTRFS info (device dm-8): checking UUID tree
> [   91.668256] BTRFS info (device dm-8): unmounting filesystem 633b5c16-afe3-4b79-b195-138fe145e4f2
> 
> Link: https://github.com/kdave/btrfs-progs/issues/689
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>   fs/btrfs/disk-io.c | 1 +
>   fs/btrfs/super.c   | 6 +++++-
>   2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 350e1b02cc8e..2fef94bfa2ff 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -3209,6 +3209,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
>   		goto fail_alloc;
>   	}
>   
> +	btrfs_info(fs_info, "mounting filesystem %pU", disk_super->fsid);
>   	/*
>   	 * Verify the type first, if that or the checksum value are
>   	 * corrupted, we'll find out
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 6ecf78d09694..fbcd8c8d23dc 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -80,7 +80,11 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data);
>   
>   static void btrfs_put_super(struct super_block *sb)
>   {
> -	close_ctree(btrfs_sb(sb));
> +	struct btrfs_fs_info *fs_info = btrfs_sb(sb);
> +
> +	btrfs_info(fs_info, "unmounting filesystem %pU",
> +		   fs_info->fs_devices->fsid);
> +	close_ctree(fs_info);
>   }
>   
>   enum {


  reply	other threads:[~2023-11-02  1:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-01 21:24 [PATCH] btrfs: add dmesg output when mounting and unmounting Qu Wenruo
2023-11-02  1:16 ` Anand Jain [this message]
2023-11-02 20:18   ` David Sterba
2023-11-03  5:02     ` Qu Wenruo
2023-11-13 17:45 ` David Sterba
2023-11-13 20:07   ` Qu Wenruo
2023-11-13 21:09     ` David Sterba
2023-11-14  0:38       ` Anand Jain
2023-11-14 11:12         ` Anand Jain
2023-11-14 12:03           ` David Sterba
2023-11-21  5:18 ` Anand Jain
2023-11-21  7:27   ` Anand Jain
2023-11-21 12:38   ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18fda4f8-8f3c-4dd1-8aca-667726e278df@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox