From: Christian Brauner <christian@brauner.io>
To: David Howells <dhowells@redhat.com>
Cc: viro@zeniv.linux.org.uk, raven@themaw.net, mszeredi@redhat.com,
linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 09/25] vfs: Add mount notification count [ver #14]
Date: Wed, 26 Jun 2019 11:52:58 +0200 [thread overview]
Message-ID: <20190626095257.yi5k667gxulztyzz@brauner.io> (raw)
In-Reply-To: <156138540611.25627.13279299200070977180.stgit@warthog.procyon.org.uk>
On Mon, Jun 24, 2019 at 03:10:06PM +0100, David Howells wrote:
> Add a notification count on mount objects so that the user can easily check
> to see if a mount has changed its attributes or its children.
>
> Future patches will:
>
> (1) Provide this value through fsinfo() attributes.
>
> (2) Hook into the notify_mount() function to provide a notification
> interface for userspace to monitor.
Sorry, I might have missed this. Is this based on your notification
patchset and thus presupposing that your notification patchset has been
merged?
(One further question below.)
>
> Signed-off-by: David Howells <dhowells@redhat.com>
> ---
>
> fs/mount.h | 22 ++++++++++++++++++++++
> fs/namespace.c | 13 +++++++++++++
> 2 files changed, 35 insertions(+)
>
> diff --git a/fs/mount.h b/fs/mount.h
> index 6250de544760..47795802f78e 100644
> --- a/fs/mount.h
> +++ b/fs/mount.h
> @@ -70,6 +70,7 @@ struct mount {
> struct hlist_head mnt_pins;
> struct fs_pin mnt_umount;
> struct dentry *mnt_ex_mountpoint;
> + atomic_t mnt_notify_counter; /* Number of notifications generated */
> } __randomize_layout;
>
> #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
> @@ -151,3 +152,24 @@ static inline bool is_anon_ns(struct mnt_namespace *ns)
> {
> return ns->seq == 0;
> }
> +
> +/*
> + * Type of mount topology change notification.
> + */
> +enum mount_notification_subtype {
> + NOTIFY_MOUNT_NEW_MOUNT = 0, /* New mount added */
> + NOTIFY_MOUNT_UNMOUNT = 1, /* Mount removed manually */
> + NOTIFY_MOUNT_EXPIRY = 2, /* Automount expired */
> + NOTIFY_MOUNT_READONLY = 3, /* Mount R/O state changed */
> + NOTIFY_MOUNT_SETATTR = 4, /* Mount attributes changed */
> + NOTIFY_MOUNT_MOVE_FROM = 5, /* Mount moved from here */
> + NOTIFY_MOUNT_MOVE_TO = 6, /* Mount moved to here (compare op_id) */
> +};
> +
> +static inline void notify_mount(struct mount *changed,
> + struct mount *aux,
> + enum mount_notification_subtype subtype,
> + u32 info_flags)
> +{
> + atomic_inc(&changed->mnt_notify_counter);
> +}
> diff --git a/fs/namespace.c b/fs/namespace.c
> index a49a7d9ed482..1450faab96b9 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -513,6 +513,8 @@ static int mnt_make_readonly(struct mount *mnt)
> smp_wmb();
> mnt->mnt.mnt_flags &= ~MNT_WRITE_HOLD;
> unlock_mount_hash();
> + if (ret == 0)
> + notify_mount(mnt, NULL, NOTIFY_MOUNT_READONLY, 0x10000);
> return ret;
> }
>
> @@ -521,6 +523,7 @@ static int __mnt_unmake_readonly(struct mount *mnt)
> lock_mount_hash();
> mnt->mnt.mnt_flags &= ~MNT_READONLY;
> unlock_mount_hash();
> + notify_mount(mnt, NULL, NOTIFY_MOUNT_READONLY, 0);
> return 0;
> }
>
> @@ -833,6 +836,7 @@ static void umount_mnt(struct mount *mnt)
> {
> /* old mountpoint will be dropped when we can do that */
> mnt->mnt_ex_mountpoint = mnt->mnt_mountpoint;
> + notify_mount(mnt->mnt_parent, mnt, NOTIFY_MOUNT_UNMOUNT, 0);
> unhash_mnt(mnt);
> }
>
> @@ -1472,6 +1476,7 @@ static void umount_tree(struct mount *mnt, enum umount_tree_flags how)
> p = list_first_entry(&tmp_list, struct mount, mnt_list);
> list_del_init(&p->mnt_expire);
> list_del_init(&p->mnt_list);
> +
> ns = p->mnt_ns;
> if (ns) {
> ns->mounts--;
> @@ -2095,7 +2100,10 @@ static int attach_recursive_mnt(struct mount *source_mnt,
> lock_mount_hash();
> }
> if (parent_path) {
> + notify_mount(source_mnt->mnt_parent, source_mnt,
> + NOTIFY_MOUNT_MOVE_FROM, 0);
> detach_mnt(source_mnt, parent_path);
> + notify_mount(dest_mnt, source_mnt, NOTIFY_MOUNT_MOVE_TO, 0);
> attach_mnt(source_mnt, dest_mnt, dest_mp);
> touch_mnt_namespace(source_mnt->mnt_ns);
> } else {
> @@ -2104,6 +2112,9 @@ static int attach_recursive_mnt(struct mount *source_mnt,
> list_del_init(&source_mnt->mnt_ns->list);
> }
> mnt_set_mountpoint(dest_mnt, dest_mp, source_mnt);
> + notify_mount(dest_mnt, source_mnt, NOTIFY_MOUNT_NEW_MOUNT,
> + source_mnt->mnt.mnt_sb->s_flags & SB_SUBMOUNT ?
> + 0x10000 : 0);
What's that magic 0x10000 mean?
> commit_tree(source_mnt);
> }
>
> @@ -2480,6 +2491,7 @@ static void set_mount_attributes(struct mount *mnt, unsigned int mnt_flags)
> mnt->mnt.mnt_flags = mnt_flags;
> touch_mnt_namespace(mnt->mnt_ns);
> unlock_mount_hash();
> + notify_mount(mnt, NULL, NOTIFY_MOUNT_SETATTR, 0);
> }
>
> /*
> @@ -2880,6 +2892,7 @@ void mark_mounts_for_expiry(struct list_head *mounts)
> if (!xchg(&mnt->mnt_expiry_mark, 1) ||
> propagate_mount_busy(mnt, 1))
> continue;
> + notify_mount(mnt, NULL, NOTIFY_MOUNT_EXPIRY, 0);
> list_move(&mnt->mnt_expire, &graveyard);
> }
> while (!list_empty(&graveyard)) {
>
next prev parent reply other threads:[~2019-06-26 9:53 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-24 14:08 [PATCH 00/25] VFS: Introduce filesystem information query syscall [ver #14] David Howells
2019-06-24 14:08 ` [PATCH 01/25] vfs: syscall: Add fsinfo() to query filesystem information " David Howells
2019-06-25 8:28 ` Christian Brauner
2019-06-26 9:49 ` David Howells
2019-06-26 9:58 ` Christian Brauner
2019-06-24 14:09 ` [PATCH 02/25] fsinfo: Add syscalls to other arches " David Howells
2019-06-25 9:31 ` Christian Brauner
2019-06-24 14:09 ` [PATCH 03/25] vfs: Allow fsinfo() to query what's in an fs_context " David Howells
2019-06-25 9:27 ` Christian Brauner
2019-06-26 10:02 ` David Howells
2019-06-26 10:06 ` Christian Brauner
2019-06-24 14:09 ` [PATCH 04/25] vfs: Allow fsinfo() to be used to query an fs parameter description " David Howells
2019-06-25 9:40 ` Christian Brauner
2019-06-24 14:09 ` [PATCH 05/25] vfs: Implement parameter value retrieval with fsinfo() " David Howells
2019-06-25 9:44 ` Christian Brauner
2019-06-24 14:09 ` [PATCH 06/25] fsinfo: Implement retrieval of LSM parameters " David Howells
2019-06-24 14:09 ` [PATCH 07/25] vfs: Introduce a non-repeating system-unique superblock ID " David Howells
2019-06-24 14:09 ` [PATCH 08/25] vfs: Allow fsinfo() to look up a mount object by " David Howells
2019-06-26 9:49 ` Christian Brauner
2019-06-24 14:10 ` [PATCH 09/25] vfs: Add mount notification count " David Howells
2019-06-26 9:52 ` Christian Brauner [this message]
2019-06-24 14:10 ` [PATCH 10/25] vfs: Allow mount information to be queried by fsinfo() " David Howells
2019-06-26 9:53 ` Christian Brauner
2019-06-24 14:10 ` [PATCH 11/25] vfs: fsinfo sample: Mount listing program " David Howells
2019-06-24 14:10 ` [PATCH 12/25] fsinfo: Add API documentation " David Howells
2019-06-24 14:10 ` [PATCH 13/25] hugetlbfs: Add support for fsinfo() " David Howells
2019-06-24 14:10 ` [PATCH 14/25] kernfs, cgroup: Add fsinfo support " David Howells
2019-06-24 14:11 ` [PATCH 15/25] fsinfo: Support SELinux superblock parameter retrieval " David Howells
2019-06-24 14:11 ` [PATCH 16/25] fsinfo: Support Smack " David Howells
2019-06-24 14:11 ` [PATCH 17/25] afs: Support fsinfo() " David Howells
2019-06-24 14:11 ` [PATCH 18/25] fsinfo: proc - add sb operation " David Howells
2019-06-24 14:11 ` [PATCH 19/25] fsinfo: autofs " David Howells
2019-06-24 14:11 ` [PATCH 20/25] fsinfo: shmem - add tmpfs " David Howells
2019-06-24 14:11 ` [PATCH 21/25] fsinfo: devpts - add " David Howells
2019-06-24 14:12 ` [PATCH 22/25] fsinfo: pstore " David Howells
2019-06-24 14:12 ` [PATCH 23/25] fsinfo: debugfs " David Howells
2019-06-24 14:12 ` [PATCH 24/25] fsinfo: bpf " David Howells
2019-06-24 14:12 ` [PATCH 25/25] fsinfo: ufs " David Howells
2019-06-26 10:05 ` [PATCH 00/25] VFS: Introduce filesystem information query syscall " Christian Brauner
2019-06-26 10:42 ` Ian Kent
2019-06-26 10:47 ` Christian Brauner
2019-06-27 0:38 ` Ian Kent
2019-06-26 13:19 ` Christian Brauner
2019-06-26 14:31 ` David Howells
2019-06-26 14:50 ` Christian Brauner
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=20190626095257.yi5k667gxulztyzz@brauner.io \
--to=christian@brauner.io \
--cc=dhowells@redhat.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mszeredi@redhat.com \
--cc=raven@themaw.net \
--cc=viro@zeniv.linux.org.uk \
/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).