diff --git a/fs/namespace.c b/fs/namespace.c
index 88aef45bcfa8..2b651003e6af 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -4167,6 +4167,15 @@ int fsinfo_generic_mount_info(struct path *path, struct fsinfo_context *ctx)
p->mnt_unique_id = m->mnt_unique_id;
p->mnt_id = m->mnt_id;
p->parent_id = m->mnt_parent->mnt_id;
+#ifdef CONFIG_SB_NOTIFICATIONS
+ p->sb_changes = atomic_read(&sb->s_change_counter);
+ p->sb_notifications = atomic_read(&sb->s_notify_counter);
+#endif
+#ifdef CONFIG_MOUNT_NOTIFICATIONS
+ p->mnt_attr_changes = atomic_read(&m->mnt_attr_changes);
+ p->mnt_topology_changes = atomic_read(&m->mnt_topology_changes);
+ p->mnt_subtree_notifications = atomic_read(&m->mnt_subtree_notifications);
+#endif
get_fs_root(current->fs, &root);
if (path->mnt == root.mnt) {@@ -4293,17 +4302,29 @@ int fsinfo_generic_mount_point_full(struct path *path, struct fsinfo_context *ct
static void fsinfo_store_mount(struct fsinfo_context *ctx, const struct mount *p)
{
struct fsinfo_mount_child record = {};
+ const struct super_block *sb = p->mnt.mnt_sb;
unsigned int usage = ctx->usage;
if (ctx->usage >= INT_MAX)
return;
ctx->usage = usage + sizeof(record);
+ if (!ctx->buffer || ctx->usage > ctx->buf_size)
+ return;
- if (ctx->buffer && ctx->usage <= ctx->buf_size) {
- record.mnt_unique_id = p->mnt_unique_id;
- record.mnt_id = p->mnt_id;
- memcpy(ctx->buffer + usage, &record, sizeof(record));
- }
+ record.mnt_unique_id = p->mnt_unique_id;
+ record.mnt_id = p->mnt_id;
+ record.notify_sum = 0;
+#ifdef CONFIG_SB_NOTIFICATIONS
+ record.notify_sum += (atomic_read(&sb->s_change_counter) +
+ atomic_read(&sb->s_notify_counter));
+#endif
+#ifdef CONFIG_MOUNT_NOTIFICATIONS
+ record.notify_sum += (atomic_read(&p->mnt_attr_changes) +
+ atomic_read(&p->mnt_topology_changes) +
+ atomic_read(&p->mnt_subtree_notifications));
+#endif
+
+ memcpy(ctx->buffer + usage, &record, sizeof(record));
}
/*diff --git a/include/uapi/linux/fsinfo.h b/include/uapi/linux/fsinfo.h
index 909d6104933b..826b788b0795 100644
--- a/include/uapi/linux/fsinfo.h
+++ b/include/uapi/linux/fsinfo.h
@@ -104,6 +104,11 @@ struct fsinfo_mount_info {
__u32 from_id; /* Slave propagated from ID */
__u32 attr; /* MOUNT_ATTR_* flags */
__u32 propagation; /* MOUNT_PROPAGATION_* flags */
+ __u32 sb_changes; /* Number of sb configuration changes */
+ __u32 sb_notifications; /* Number of other sb notifications */
+ __u32 mnt_attr_changes; /* Number of attribute changes to this mount. */
+ __u32 mnt_topology_changes; /* Number of topology changes to this mount. */
+ __u32 mnt_subtree_notifications; /* Number of notifications in mount subtree */
};
#define FSINFO_ATTR_MOUNT_INFO__STRUCT struct fsinfo_mount_info@@ -115,7 +120,9 @@ struct fsinfo_mount_info {
struct fsinfo_mount_child {
__u64 mnt_unique_id; /* Kernel-lifetime unique mount ID */
__u32 mnt_id; /* Mount identifier (use with AT_FSINFO_MOUNTID_PATH) */
- __u32 __padding[1];
+ __u32 notify_sum; /* Sum of sb_changes, sb_notifications, mnt_attr_changes,
+ * mnt_topology_changes and mnt_subtree_notifications.
+ */
};
#define FSINFO_ATTR_MOUNT_CHILDREN__STRUCT struct fsinfo_mount_childdiff --git a/samples/vfs/test-fsinfo.c b/samples/vfs/test-fsinfo.c
index bdc7ea952630..91434f459ba5 100644
--- a/samples/vfs/test-fsinfo.c
+++ b/samples/vfs/test-fsinfo.c
@@ -300,6 +300,9 @@ static void dump_fsinfo_generic_mount_info(void *reply, unsigned int size)
printf("\tgroup : %x\n", r->group_id);
printf("\tattr : %x\n", r->attr);
printf("\tpropag : %x\n", r->propagation);
+ printf("\tsb_nfy : changes=%u other=%u\n", r->sb_changes, r->sb_notifications);
+ printf("\tmnt_nfy : attr=%u topology=%u subtree=%u\n",
+ r->mnt_attr_changes, r->mnt_topology_changes, r->mnt_subtree_notifications);
}
static void dump_fsinfo_generic_mount_child(void *reply, unsigned int size)@@ -322,8 +325,8 @@ static void dump_fsinfo_generic_mount_child(void *reply, unsigned int size)
mp = "<this>";
}
- printf("%8x %16llx %s\n",
- r->mnt_id, (unsigned long long)r->mnt_unique_id, mp);
+ printf("%8x %16llx %10u %s\n",
+ r->mnt_id, (unsigned long long)r->mnt_unique_id, r->notify_sum, mp);
}
static void dump_string(void *reply, unsigned int size)