linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guowei Du <duguoweisz@gmail.com>
To: jack@suse.cz, amir73il@gmail.com, repnop@google.com, brauner@kernel.org
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	duguowei <duguowei@xiaomi.com>
Subject: [PATCH 6/6] fanotify: add current_user_instances node
Date: Tue, 28 Jun 2022 18:14:13 +0800	[thread overview]
Message-ID: <20220628101413.10432-1-duguoweisz@gmail.com> (raw)

From: duguowei <duguowei@xiaomi.com>

Add a node of sysctl, which is current_user_instances.
It shows current initialized group counts of system.

Signed-off-by: duguowei <duguowei@xiaomi.com>
---
 fs/notify/fanotify/fanotify_user.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index c2255b440df9..39674fbffc4f 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -51,6 +51,8 @@
 
 /* configurable via /proc/sys/fs/fanotify/ */
 static int fanotify_max_queued_events __read_mostly;
+/* current initialized group count */
+static int fanotify_user_instances __read_mostly;
 
 #ifdef CONFIG_SYSCTL
 
@@ -86,6 +88,14 @@ static struct ctl_table fanotify_table[] = {
 		.proc_handler	= proc_dointvec_minmax,
 		.extra1		= SYSCTL_ZERO
 	},
+	{
+		.procname	= "current_user_instances",
+		.data		= &fanotify_user_instances,
+		.maxlen		= sizeof(int),
+		.mode		= 0444,
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= SYSCTL_ZERO
+	},
 	{ }
 };
 
@@ -905,6 +915,8 @@ static int fanotify_release(struct inode *ignored, struct file *file)
 	/* matches the fanotify_init->fsnotify_alloc_group */
 	fsnotify_destroy_group(group);
 
+	fanotify_user_instances--;
+
 	return 0;
 }
 
@@ -1459,6 +1471,8 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
 	if (fd < 0)
 		goto out_destroy_group;
 
+	fanotify_user_instances++;
+
 	return fd;
 
 out_destroy_group:
-- 
2.36.1


             reply	other threads:[~2022-06-28 10:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-28 10:14 Guowei Du [this message]
2022-06-28 10:45 ` [PATCH 6/6] fanotify: add current_user_instances node Jan Kara
2022-06-28 10:48   ` Christian Brauner
     [not found]     ` <CAC+1NxtAfbKOcW1hykyygScJgN7DsPKxLeuqNNZXLqekHgsG=Q@mail.gmail.com>
2022-06-28 12:29       ` Amir Goldstein
2022-06-28 12:56         ` Jan Kara
2022-06-28 13:55           ` Amir Goldstein
2022-06-28 14:25             ` Christian Brauner
2022-06-28 15:36               ` Amir Goldstein

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=20220628101413.10432-1-duguoweisz@gmail.com \
    --to=duguoweisz@gmail.com \
    --cc=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=duguowei@xiaomi.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=repnop@google.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;
as well as URLs for NNTP newsgroup(s).