From: Greg KH <gregkh@linuxfoundation.org>
To: Max Kellermann <max.kellermann@ionos.com>
Cc: tj@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs/kernfs: implement STATX_BTIME
Date: Tue, 6 May 2025 19:43:28 +0200 [thread overview]
Message-ID: <2025050600-economist-display-2d25@gregkh> (raw)
In-Reply-To: <20250506164017.249149-1-max.kellermann@ionos.com>
On Tue, May 06, 2025 at 06:40:17PM +0200, Max Kellermann wrote:
> This allows finding out when an inode was initially created, for
> example:
>
> - when was a device plugged in (and its node in sysfs was created)?
> - when was a cgroup created?
>
> kernfs currently only implements `atime`, `mtime` and `ctime`. All of
> these are volatile (`mtime` and `ctime` get updated automatically, and
> `atime` can be mainpulated using utime()). Therefore, I suggest
> implementing STATX_BTIME to have a reliable birth time in userspace.
>
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
> ---
> fs/kernfs/dir.c | 2 ++
> fs/kernfs/inode.c | 6 ++++++
> include/linux/kernfs.h | 7 +++++++
> 3 files changed, 15 insertions(+)
>
> diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
> index fc70d72c3fe8..9a6857f2f3d7 100644
> --- a/fs/kernfs/dir.c
> +++ b/fs/kernfs/dir.c
> @@ -678,6 +678,8 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
> goto err_out3;
> }
>
> + ktime_get_real_ts64(&kn->btime);
> +
> return kn;
>
> err_out3:
> diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
> index b83054da68b3..1ff2ee62bfe6 100644
> --- a/fs/kernfs/inode.c
> +++ b/fs/kernfs/inode.c
> @@ -189,6 +189,12 @@ int kernfs_iop_getattr(struct mnt_idmap *idmap,
> struct kernfs_root *root = kernfs_root(kn);
>
> down_read(&root->kernfs_iattr_rwsem);
> +
> + if (request_mask & STATX_BTIME) {
> + stat->result_mask |= STATX_BTIME;
> + stat->btime = kn->btime;
> + }
> +
> kernfs_refresh_inode(kn, inode);
> generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
> up_read(&root->kernfs_iattr_rwsem);
> diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
> index b5a5f32fdfd1..9332aadf4b48 100644
> --- a/include/linux/kernfs.h
> +++ b/include/linux/kernfs.h
> @@ -229,6 +229,13 @@ struct kernfs_node {
> void *priv;
> struct kernfs_iattrs *iattr;
>
> + /*
> + * The birth time (for STATX_BTIME). It lives here and not in
> + * struct kernfs_iattrs because the latter is only created on
> + * demand, not at actual node birth time.
> + */
> + struct timespec64 btime;
You did just make this structure bigger, which has a real effect on many
systems (think 32bit s390 systems with 30k disks.) Are you sure this is
really needed?
What userspace tools want this in such that they can not determine this
any other way? What do they want this information for? What is going
to depend and require this to warrent it being added like this?
I'm loath to increase the size of this structure just for "it would be
nice" type of things. We need to see a real user and a real use case
for this please.
And knowing when a device shows up in the system isn't that, sorry, the
kernel log shows that for you already, right?
thanks,
greg k-h
next prev parent reply other threads:[~2025-05-06 17:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-06 16:40 [PATCH] fs/kernfs: implement STATX_BTIME Max Kellermann
2025-05-06 17:43 ` Greg KH [this message]
2025-05-06 18:30 ` Max Kellermann
2025-05-21 11:24 ` Greg KH
2025-05-21 16:18 ` Tejun Heo
2025-05-21 20:19 ` Max Kellermann
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=2025050600-economist-display-2d25@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=max.kellermann@ionos.com \
--cc=tj@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