From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.cz
Subject: [PATCH] btrfs: add mount umount logs
Date: Tue, 16 May 2017 16:41:49 +0800 [thread overview]
Message-ID: <20170516084149.10147-1-anand.jain@oracle.com> (raw)
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
next reply other threads:[~2017-05-16 8:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-16 8:41 Anand Jain [this message]
2017-05-16 9:25 ` [PATCH] btrfs: add mount umount logs Qu Wenruo
2017-05-18 9:34 ` Anand Jain
2017-05-16 11:23 ` David Sterba
2017-05-18 10:31 ` Anand Jain
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=20170516084149.10147-1-anand.jain@oracle.com \
--to=anand.jain@oracle.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).