From: Greg Kroah-Hartman <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>
To: Ivan Babrou <ivan-lDpJ742SOEtZroRs9YW3xA@public.gmane.org>
Cc: linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kernel-team-lDpJ742SOEtZroRs9YW3xA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Hugh Dickins <hughd-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
Andrew Morton
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
Amir Goldstein <amir73il-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>,
Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org>,
Zefan Li <lizefan.x-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>,
Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>
Subject: Re: [PATCH] kernfs: attach uuid for every kernfs and report it in fsid
Date: Tue, 11 Jul 2023 16:04:03 +0200 [thread overview]
Message-ID: <2023071159-unsigned-salvation-405d@gregkh> (raw)
In-Reply-To: <CABWYdi39+TJd1qV3nWs_eYc7XMC0RvxG22ihfq7rzuPaNvn1cQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On Mon, Jul 10, 2023 at 02:21:10PM -0700, Ivan Babrou wrote:
> On Mon, Jul 10, 2023 at 12:40 PM Greg Kroah-Hartman
> <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> wrote:
> >
> > On Mon, Jul 10, 2023 at 11:33:38AM -0700, Ivan Babrou wrote:
> > > The following two commits added the same thing for tmpfs:
> > >
> > > * commit 2b4db79618ad ("tmpfs: generate random sb->s_uuid")
> > > * commit 59cda49ecf6c ("shmem: allow reporting fanotify events with file handles on tmpfs")
> > >
> > > Having fsid allows using fanotify, which is especially handy for cgroups,
> > > where one might be interested in knowing when they are created or removed.
> > >
> > > Signed-off-by: Ivan Babrou <ivan-lDpJ742SOEtZroRs9YW3xA@public.gmane.org>
> > > ---
> > > fs/kernfs/mount.c | 13 ++++++++++++-
> > > 1 file changed, 12 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c
> > > index d49606accb07..930026842359 100644
> > > --- a/fs/kernfs/mount.c
> > > +++ b/fs/kernfs/mount.c
> > > @@ -16,6 +16,8 @@
> > > #include <linux/namei.h>
> > > #include <linux/seq_file.h>
> > > #include <linux/exportfs.h>
> > > +#include <linux/uuid.h>
> > > +#include <linux/statfs.h>
> > >
> > > #include "kernfs-internal.h"
> > >
> > > @@ -45,8 +47,15 @@ static int kernfs_sop_show_path(struct seq_file *sf, struct dentry *dentry)
> > > return 0;
> > > }
> > >
> > > +int kernfs_statfs(struct dentry *dentry, struct kstatfs *buf)
> > > +{
> > > + simple_statfs(dentry, buf);
> > > + buf->f_fsid = uuid_to_fsid(dentry->d_sb->s_uuid.b);
> > > + return 0;
> > > +}
> > > +
> > > const struct super_operations kernfs_sops = {
> > > - .statfs = simple_statfs,
> > > + .statfs = kernfs_statfs,
> > > .drop_inode = generic_delete_inode,
> > > .evict_inode = kernfs_evict_inode,
> > >
> > > @@ -351,6 +360,8 @@ int kernfs_get_tree(struct fs_context *fc)
> > > }
> > > sb->s_flags |= SB_ACTIVE;
> > >
> > > + uuid_gen(&sb->s_uuid);
> >
> > Since kernfs has as lot of nodes (like hundreds of thousands if not more
> > at times, being created at boot time), did you just slow down creating
> > them all, and increase the memory usage in a measurable way?
>
> This is just for the superblock, not every inode. The memory increase
> is one UUID per kernfs instance (there are maybe 10 of them on a basic
> system), which is trivial. Same goes for CPU usage.
Ah, ok, my fault, thanks for clearing that up.
thanks,
greg k-h
next prev parent reply other threads:[~2023-07-11 14:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-10 18:33 [PATCH] kernfs: attach uuid for every kernfs and report it in fsid Ivan Babrou
[not found] ` <20230710183338.58531-1-ivan-lDpJ742SOEtZroRs9YW3xA@public.gmane.org>
2023-07-10 18:43 ` Ignat Korchagin
2023-07-10 19:40 ` Greg Kroah-Hartman
2023-07-10 19:41 ` Greg Kroah-Hartman
2023-07-10 21:21 ` Ivan Babrou
2023-07-11 9:49 ` Amir Goldstein
2023-07-11 22:04 ` Ivan Babrou
2023-07-12 5:43 ` Amir Goldstein
[not found] ` <CAOQ4uxgLp+gwJPTWj9uwhncx8RD5-mZY7qOaD2C6pbu7c4+srw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-07-13 21:34 ` Ivan Babrou
[not found] ` <CAOQ4uxiFhkSM2pSNLCE6cLz6mhYOvk5D7vDsghVTqy9cDqeqew-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-07-31 13:46 ` Jan Kara
2023-07-31 18:49 ` Ivan Babrou
[not found] ` <CABWYdi39+TJd1qV3nWs_eYc7XMC0RvxG22ihfq7rzuPaNvn1cQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-07-11 14:04 ` Greg Kroah-Hartman [this message]
2023-07-25 14:07 ` Michal Koutný
2023-07-25 23:58 ` Ivan Babrou
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=2023071159-unsigned-salvation-405d@gregkh \
--to=gregkh-hqyy1w1ycw8ekmwlsbkhg0b+6bgklq7r@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=amir73il-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
--cc=hch-jcswGhMUV9g@public.gmane.org \
--cc=hughd-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=ivan-lDpJ742SOEtZroRs9YW3xA@public.gmane.org \
--cc=jack-AlSwsSmVLrQ@public.gmane.org \
--cc=kernel-team-lDpJ742SOEtZroRs9YW3xA@public.gmane.org \
--cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=lizefan.x-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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).