* [PATCH] btrfs: add mount umount logs
@ 2017-05-16 8:41 Anand Jain
2017-05-16 9:25 ` Qu Wenruo
2017-05-16 11:23 ` David Sterba
0 siblings, 2 replies; 5+ messages in thread
From: Anand Jain @ 2017-05-16 8:41 UTC (permalink / raw)
To: linux-btrfs; +Cc: dsterba
By looking at the logs we should be able to know when the FS was
mounted and unmounted and the options used, so to help forensic
investigations.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/super.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 827a8305da50..a123bc46b521 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1408,6 +1408,17 @@ static char *setup_root_args(char *args)
return buf;
}
+static void print_mount_info(struct btrfs_fs_info *info, int flag, char *opt,
+ char *prefix)
+{
+ char f[10] = {0};
+
+ if (flag & MS_RDONLY)
+ strcpy(f, "rdonly");
+
+ btrfs_notice(info, "%s: flags:%s opt:%s\n", prefix, f, opt);
+}
+
static struct dentry *mount_subvol(const char *subvol_name, u64 subvol_objectid,
int flags, const char *device_name,
char *data)
@@ -1502,6 +1513,8 @@ static struct dentry *mount_subvol(const char *subvol_name, u64 subvol_objectid,
dput(root);
root = ERR_PTR(ret);
deactivate_locked_super(s);
+ } else {
+ print_mount_info(fs_info, flags, data, "mount");
}
}
@@ -1882,6 +1895,9 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
out:
wake_up_process(fs_info->transaction_kthread);
btrfs_remount_cleanup(fs_info, old_opts);
+
+ print_mount_info(fs_info, *flags, data, "remount");
+
return 0;
restore:
@@ -2212,6 +2228,7 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
static void btrfs_kill_super(struct super_block *sb)
{
struct btrfs_fs_info *fs_info = btrfs_sb(sb);
+ btrfs_notice(fs_info, "%s\n", "unmount");
kill_anon_super(sb);
free_fs_info(fs_info);
}
--
2.10.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs: add mount umount logs
2017-05-16 8:41 [PATCH] btrfs: add mount umount logs Anand Jain
@ 2017-05-16 9:25 ` Qu Wenruo
2017-05-18 9:34 ` Anand Jain
2017-05-16 11:23 ` David Sterba
1 sibling, 1 reply; 5+ messages in thread
From: Qu Wenruo @ 2017-05-16 9:25 UTC (permalink / raw)
To: Anand Jain, linux-btrfs; +Cc: dsterba
Yes, this is indeed a nice feature.
But what about only outputting this info when BTRFS_DEBUG is selected?
I'm sure there will be some guys not liking such kernel message flooding
everywhere when doing testing.
Thanks,
Qu
At 05/16/2017 04:41 PM, Anand Jain wrote:
> By looking at the logs we should be able to know when the FS was
> mounted and unmounted and the options used, so to help forensic
> investigations.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> fs/btrfs/super.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 827a8305da50..a123bc46b521 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -1408,6 +1408,17 @@ static char *setup_root_args(char *args)
> return buf;
> }
>
> +static void print_mount_info(struct btrfs_fs_info *info, int flag, char *opt,
> + char *prefix)
> +{
> + char f[10] = {0};
> +
> + if (flag & MS_RDONLY)
> + strcpy(f, "rdonly");
Isn't "ro" more common?
Thanks,
Qu
> +
> + btrfs_notice(info, "%s: flags:%s opt:%s\n", prefix, f, opt);
> +}
> +
> static struct dentry *mount_subvol(const char *subvol_name, u64 subvol_objectid,
> int flags, const char *device_name,
> char *data)
> @@ -1502,6 +1513,8 @@ static struct dentry *mount_subvol(const char *subvol_name, u64 subvol_objectid,
> dput(root);
> root = ERR_PTR(ret);
> deactivate_locked_super(s);
> + } else {
> + print_mount_info(fs_info, flags, data, "mount");
> }
> }
>
> @@ -1882,6 +1895,9 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
> out:
> wake_up_process(fs_info->transaction_kthread);
> btrfs_remount_cleanup(fs_info, old_opts);
> +
> + print_mount_info(fs_info, *flags, data, "remount");
> +
> return 0;
>
> restore:
> @@ -2212,6 +2228,7 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
> static void btrfs_kill_super(struct super_block *sb)
> {
> struct btrfs_fs_info *fs_info = btrfs_sb(sb);
> + btrfs_notice(fs_info, "%s\n", "unmount");
> kill_anon_super(sb);
> free_fs_info(fs_info);
> }
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs: add mount umount logs
2017-05-16 8:41 [PATCH] btrfs: add mount umount logs Anand Jain
2017-05-16 9:25 ` Qu Wenruo
@ 2017-05-16 11:23 ` David Sterba
2017-05-18 10:31 ` Anand Jain
1 sibling, 1 reply; 5+ messages in thread
From: David Sterba @ 2017-05-16 11:23 UTC (permalink / raw)
To: Anand Jain; +Cc: linux-btrfs
On Tue, May 16, 2017 at 04:41:49PM +0800, Anand Jain wrote:
> By looking at the logs we should be able to know when the FS was
> mounted and unmounted and the options used, so to help forensic
> investigations.
Could be a useful feature, but you're adding it to the wrong layer.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs: add mount umount logs
2017-05-16 9:25 ` Qu Wenruo
@ 2017-05-18 9:34 ` Anand Jain
0 siblings, 0 replies; 5+ messages in thread
From: Anand Jain @ 2017-05-18 9:34 UTC (permalink / raw)
To: Qu Wenruo, linux-btrfs; +Cc: dsterba
On 05/16/2017 05:25 PM, Qu Wenruo wrote:
> Yes, this is indeed a nice feature.
>
> But what about only outputting this info when BTRFS_DEBUG is selected?
> I'm sure there will be some guys not liking such kernel message flooding
> everywhere when doing testing.
Thanks. Will keep in mind to make that changes if received confirmed
objection.
Thanks. Anand
> Thanks,
> Qu
>
> At 05/16/2017 04:41 PM, Anand Jain wrote:
>> By looking at the logs we should be able to know when the FS was
>> mounted and unmounted and the options used, so to help forensic
>> investigations.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>> fs/btrfs/super.c | 17 +++++++++++++++++
>> 1 file changed, 17 insertions(+)
>>
>> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
>> index 827a8305da50..a123bc46b521 100644
>> --- a/fs/btrfs/super.c
>> +++ b/fs/btrfs/super.c
>> @@ -1408,6 +1408,17 @@ static char *setup_root_args(char *args)
>> return buf;
>> }
>> +static void print_mount_info(struct btrfs_fs_info *info, int flag,
>> char *opt,
>> + char *prefix)
>> +{
>> + char f[10] = {0};
>> +
>> + if (flag & MS_RDONLY)
>> + strcpy(f, "rdonly");
>
> Isn't "ro" more common?
>
> Thanks,
> Qu
>
>> +
>> + btrfs_notice(info, "%s: flags:%s opt:%s\n", prefix, f, opt);
>> +}
>> +
>> static struct dentry *mount_subvol(const char *subvol_name, u64
>> subvol_objectid,
>> int flags, const char *device_name,
>> char *data)
>> @@ -1502,6 +1513,8 @@ static struct dentry *mount_subvol(const char
>> *subvol_name, u64 subvol_objectid,
>> dput(root);
>> root = ERR_PTR(ret);
>> deactivate_locked_super(s);
>> + } else {
>> + print_mount_info(fs_info, flags, data, "mount");
>> }
>> }
>> @@ -1882,6 +1895,9 @@ static int btrfs_remount(struct super_block
>> *sb, int *flags, char *data)
>> out:
>> wake_up_process(fs_info->transaction_kthread);
>> btrfs_remount_cleanup(fs_info, old_opts);
>> +
>> + print_mount_info(fs_info, *flags, data, "remount");
>> +
>> return 0;
>> restore:
>> @@ -2212,6 +2228,7 @@ static int btrfs_statfs(struct dentry *dentry,
>> struct kstatfs *buf)
>> static void btrfs_kill_super(struct super_block *sb)
>> {
>> struct btrfs_fs_info *fs_info = btrfs_sb(sb);
>> + btrfs_notice(fs_info, "%s\n", "unmount");
>> kill_anon_super(sb);
>> free_fs_info(fs_info);
>> }
>>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] btrfs: add mount umount logs
2017-05-16 11:23 ` David Sterba
@ 2017-05-18 10:31 ` Anand Jain
0 siblings, 0 replies; 5+ messages in thread
From: Anand Jain @ 2017-05-18 10:31 UTC (permalink / raw)
To: dsterba, linux-btrfs
On 05/16/2017 07:23 PM, David Sterba wrote:
> On Tue, May 16, 2017 at 04:41:49PM +0800, Anand Jain wrote:
>> By looking at the logs we should be able to know when the FS was
>> mounted and unmounted and the options used, so to help forensic
>> investigations.
>
> Could be a useful feature, but you're adding it to the wrong layer.
Ok proposing to be added to the vfs layer.
Thanks, Anand
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-05-18 10:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-16 8:41 [PATCH] btrfs: add mount umount logs Anand Jain
2017-05-16 9:25 ` Qu Wenruo
2017-05-18 9:34 ` Anand Jain
2017-05-16 11:23 ` David Sterba
2017-05-18 10:31 ` Anand Jain
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.