All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] tmpfs: support for file creation time
@ 2022-02-28  8:43 ` Xavier Roche
  0 siblings, 0 replies; 7+ messages in thread
From: Xavier Roche @ 2022-02-11 21:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Hugh Dickins, Andrew Morton, Jean Delvare, Xavier Roche, linux-mm

Various filesystems (including ext4) now support file creation time.
This patch adds such support for tmpfs-based filesystems.

Signed-off-by: Xavier Roche <xavier.roche@algolia.com>
Tested-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
---
 include/linux/shmem_fs.h |  1 +
 mm/shmem.c               | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index e65b80ed09e7..29787767c3b9 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -25,6 +25,7 @@ struct shmem_inode_info {
 	struct simple_xattrs	xattrs;		/* list of xattrs */
 	atomic_t		stop_eviction;	/* hold when working on inode */
 	struct inode		vfs_inode;
+	struct timespec64	i_crtime;	/* file creation time */
 };
 
 struct shmem_sb_info {
diff --git a/mm/shmem.c b/mm/shmem.c
index a09b29ec2b45..5a3907712c4f 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1061,6 +1061,12 @@ static int shmem_getattr(struct user_namespace *mnt_userns,
 	if (shmem_is_huge(NULL, inode, 0))
 		stat->blksize = HPAGE_PMD_SIZE;
 
+	if ((request_mask & STATX_BTIME)) {
+		stat->result_mask |= STATX_BTIME;
+		stat->btime.tv_sec = info->i_crtime.tv_sec;
+		stat->btime.tv_nsec = info->i_crtime.tv_nsec;
+	}
+
 	return 0;
 }
 
@@ -2265,6 +2271,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode
 		atomic_set(&info->stop_eviction, 0);
 		info->seals = F_SEAL_SEAL;
 		info->flags = flags & VM_NORESERVE;
+		info->i_crtime = inode->i_mtime;
 		INIT_LIST_HEAD(&info->shrinklist);
 		INIT_LIST_HEAD(&info->swaplist);
 		simple_xattrs_init(&info->xattrs);
@@ -3196,6 +3203,7 @@ static ssize_t shmem_listxattr(struct dentry *dentry, char *buffer, size_t size)
 #endif /* CONFIG_TMPFS_XATTR */
 
 static const struct inode_operations shmem_short_symlink_operations = {
+	.getattr	= shmem_getattr,
 	.get_link	= simple_get_link,
 #ifdef CONFIG_TMPFS_XATTR
 	.listxattr	= shmem_listxattr,
@@ -3203,6 +3211,7 @@ static const struct inode_operations shmem_short_symlink_operations = {
 };
 
 static const struct inode_operations shmem_symlink_inode_operations = {
+	.getattr	= shmem_getattr,
 	.get_link	= shmem_get_link,
 #ifdef CONFIG_TMPFS_XATTR
 	.listxattr	= shmem_listxattr,
@@ -3790,6 +3799,7 @@ static const struct inode_operations shmem_inode_operations = {
 
 static const struct inode_operations shmem_dir_inode_operations = {
 #ifdef CONFIG_TMPFS
+	.getattr	= shmem_getattr,
 	.create		= shmem_create,
 	.lookup		= simple_lookup,
 	.link		= shmem_link,
@@ -3811,6 +3821,7 @@ static const struct inode_operations shmem_dir_inode_operations = {
 };
 
 static const struct inode_operations shmem_special_inode_operations = {
+	.getattr	= shmem_getattr,
 #ifdef CONFIG_TMPFS_XATTR
 	.listxattr	= shmem_listxattr,
 #endif
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH mmotm] tmpfs: three tweaks to creation time patch
  2022-02-28  8:43 ` [PATCH v3] " Xavier Roche
  (?)
@ 2022-02-27  6:30 ` Hugh Dickins
  -1 siblings, 0 replies; 7+ messages in thread
From: Hugh Dickins @ 2022-02-27  6:30 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Xavier Roche, Jean Delvare, linux-kernel, linux-mm

Thank you to Xavier Roche for his tmpfs file creation time patch.
Please apply these 3 tweaks on top (and fold in when sending to Linus):

1. Move vfs_inode back to being last element of shmem_inode_info.
2. Remove unnecessary parentheses from condition in shmem_getattr().
3. Using shmem_getattr() on other file types than regular requires that
   shmem_is_huge() check type, to stop incorrect HPAGE_PMD_SIZE blksize.

Signed-off-by: Hugh Dickins <hughd@google.com>
---
Cleanups and fix to tmpfs-support-for-file-creation-time.patch

 include/linux/shmem_fs.h |    2 +-
 mm/shmem.c               |    7 +++----
 2 files changed, 4 insertions(+), 5 deletions(-)

--- mmotm/include/linux/shmem_fs.h
+++ linux/include/linux/shmem_fs.h
@@ -24,8 +24,8 @@ struct shmem_inode_info {
 	struct shared_policy	policy;		/* NUMA memory alloc policy */
 	struct simple_xattrs	xattrs;		/* list of xattrs */
 	atomic_t		stop_eviction;	/* hold when working on inode */
-	struct inode		vfs_inode;
 	struct timespec64	i_crtime;	/* file creation time */
+	struct inode		vfs_inode;
 };
 
 struct shmem_sb_info {
--- mmotm/mm/shmem.c
+++ linux/mm/shmem.c
@@ -476,6 +476,8 @@ bool shmem_is_huge(struct vm_area_struct
 {
 	loff_t i_size;
 
+	if (!S_ISREG(inode->i_mode))
+		return false;
 	if (shmem_huge == SHMEM_HUGE_DENY)
 		return false;
 	if (vma && ((vma->vm_flags & VM_NOHUGEPAGE) ||
@@ -1061,7 +1063,7 @@ static int shmem_getattr(struct user_nam
 	if (shmem_is_huge(NULL, inode, 0))
 		stat->blksize = HPAGE_PMD_SIZE;
 
-	if ((request_mask & STATX_BTIME)) {
+	if (request_mask & STATX_BTIME) {
 		stat->result_mask |= STATX_BTIME;
 		stat->btime.tv_sec = info->i_crtime.tv_sec;
 		stat->btime.tv_nsec = info->i_crtime.tv_nsec;
@@ -1860,9 +1862,6 @@ repeat:
 		return 0;
 	}
 
-	/* Never use a huge page for shmem_symlink() */
-	if (S_ISLNK(inode->i_mode))
-		goto alloc_nohuge;
 	if (!shmem_is_huge(vma, inode, index))
 		goto alloc_nohuge;
 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3] tmpfs: support for file creation time
@ 2022-02-28  8:43 ` Xavier Roche
  0 siblings, 0 replies; 7+ messages in thread
From: Xavier Roche @ 2022-02-28  8:43 UTC (permalink / raw)
  To: torvalds
  Cc: linux-kernel, Hugh Dickins, Andrew Morton, Jean Delvare,
	Xavier Roche, linux-mm

Various filesystems (including ext4) now support file creation time.
This patch adds such support for tmpfs-based filesystems.

Signed-off-by: Xavier Roche <xavier.roche@algolia.com>
Signed-off-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Tested-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Cc: Xavier Roche <xavier.roche@algolia.com>
Cc: Jean Delvare <jdelvare@suse.de>
---
 include/linux/shmem_fs.h |  1 +
 mm/shmem.c               | 11 +++++++++++
 2 files changed, 12 insertions(+)

Index: linux/include/linux/shmem_fs.h
===================================================================
--- linux.orig/include/linux/shmem_fs.h
+++ linux/include/linux/shmem_fs.h
@@ -24,6 +24,7 @@ struct shmem_inode_info {
 	struct shared_policy	policy;		/* NUMA memory alloc policy */
 	struct simple_xattrs	xattrs;		/* list of xattrs */
 	atomic_t		stop_eviction;	/* hold when working on inode */
+	struct timespec64	i_crtime;	/* file creation time */
 	struct inode		vfs_inode;
 };
 
Index: linux/mm/shmem.c
===================================================================
--- linux.orig/mm/shmem.c
+++ linux/mm/shmem.c
@@ -476,6 +476,8 @@ bool shmem_is_huge(struct vm_area_struct
 {
 	loff_t i_size;
 
+	if (!S_ISREG(inode->i_mode))
+		return false;
 	if (shmem_huge == SHMEM_HUGE_DENY)
 		return false;
 	if (vma && ((vma->vm_flags & VM_NOHUGEPAGE) ||
@@ -1061,6 +1063,12 @@ static int shmem_getattr(struct user_nam
 	if (shmem_is_huge(NULL, inode, 0))
 		stat->blksize = HPAGE_PMD_SIZE;
 
+	if (request_mask & STATX_BTIME) {
+		stat->result_mask |= STATX_BTIME;
+		stat->btime.tv_sec = info->i_crtime.tv_sec;
+		stat->btime.tv_nsec = info->i_crtime.tv_nsec;
+	}
+
 	return 0;
 }
 
@@ -1854,9 +1862,6 @@ repeat:
 		return 0;
 	}
 
-	/* Never use a huge page for shmem_symlink() */
-	if (S_ISLNK(inode->i_mode))
-		goto alloc_nohuge;
 	if (!shmem_is_huge(vma, inode, index))
 		goto alloc_nohuge;
 
@@ -2265,6 +2270,7 @@ static struct inode *shmem_get_inode(str
 		atomic_set(&info->stop_eviction, 0);
 		info->seals = F_SEAL_SEAL;
 		info->flags = flags & VM_NORESERVE;
+		info->i_crtime = inode->i_mtime;
 		INIT_LIST_HEAD(&info->shrinklist);
 		INIT_LIST_HEAD(&info->swaplist);
 		simple_xattrs_init(&info->xattrs);
@@ -3196,6 +3202,7 @@ static ssize_t shmem_listxattr(struct de
 #endif /* CONFIG_TMPFS_XATTR */
 
 static const struct inode_operations shmem_short_symlink_operations = {
+	.getattr	= shmem_getattr,
 	.get_link	= simple_get_link,
 #ifdef CONFIG_TMPFS_XATTR
 	.listxattr	= shmem_listxattr,
@@ -3203,6 +3210,7 @@ static const struct inode_operations shm
 };
 
 static const struct inode_operations shmem_symlink_inode_operations = {
+	.getattr	= shmem_getattr,
 	.get_link	= shmem_get_link,
 #ifdef CONFIG_TMPFS_XATTR
 	.listxattr	= shmem_listxattr,
@@ -3790,6 +3798,7 @@ static const struct inode_operations shm
 
 static const struct inode_operations shmem_dir_inode_operations = {
 #ifdef CONFIG_TMPFS
+	.getattr	= shmem_getattr,
 	.create		= shmem_create,
 	.lookup		= simple_lookup,
 	.link		= shmem_link,
@@ -3811,6 +3820,7 @@ static const struct inode_operations shm
 };
 
 static const struct inode_operations shmem_special_inode_operations = {
+	.getattr	= shmem_getattr,
 #ifdef CONFIG_TMPFS_XATTR
 	.listxattr	= shmem_listxattr,
 #endif

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] tmpfs: support for file creation time
  2022-02-28  8:43 ` [PATCH v3] " Xavier Roche
  (?)
  (?)
@ 2022-03-02 19:43 ` Linus Torvalds
  2022-03-02 19:59   ` Andrew Morton
  2022-03-02 20:17   ` Hugh Dickins
  -1 siblings, 2 replies; 7+ messages in thread
From: Linus Torvalds @ 2022-03-02 19:43 UTC (permalink / raw)
  To: Xavier Roche
  Cc: Linux Kernel Mailing List, Hugh Dickins, Andrew Morton,
	Jean Delvare, Linux-MM

On Mon, Feb 28, 2022 at 12:43 AM Xavier Roche <xavier.roche@algolia.com> wrote:
>
> Various filesystems (including ext4) now support file creation time.
> This patch adds such support for tmpfs-based filesystems.

What's the odd huge-page noise in this patch?

Other oddities:

    Reply-To: b954973a-b8d1-cab8-63bd-6ea8063de3@google.com

WHAT?

And finally - if we really want to treat btime as a first-class entity
and expect things like tmpfs to support it, then we should just bite
the bullet and put it in 'struct inode' along with the other times.

              Linus

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] tmpfs: support for file creation time
  2022-03-02 19:43 ` [PATCH v3] tmpfs: support for file creation time Linus Torvalds
@ 2022-03-02 19:59   ` Andrew Morton
  2022-03-02 20:17   ` Hugh Dickins
  1 sibling, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2022-03-02 19:59 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Xavier Roche, Linux Kernel Mailing List, Hugh Dickins,
	Jean Delvare, Linux-MM

On Wed, 2 Mar 2022 11:43:02 -0800 Linus Torvalds <torvalds@linux-foundation.org> wrote:

> On Mon, Feb 28, 2022 at 12:43 AM Xavier Roche <xavier.roche@algolia.com> wrote:
> >
> > Various filesystems (including ext4) now support file creation time.
> > This patch adds such support for tmpfs-based filesystems.
> 
> What's the odd huge-page noise in this patch?

I can't see such changes?

This v3 patch is the v2 patch plus Hugh's changes
(https://lkml.kernel.org/r/b954973a-b8d1-cab8-63bd-6ea8063de3@google.com).

I won't be merging v3 because this changelog lacks appropriate
decription of Hugh's changes and lacks a Link: tag to Hugh's change.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] tmpfs: support for file creation time
  2022-03-02 19:43 ` [PATCH v3] tmpfs: support for file creation time Linus Torvalds
  2022-03-02 19:59   ` Andrew Morton
@ 2022-03-02 20:17   ` Hugh Dickins
  2022-03-14 21:08     ` Xavier Roche
  1 sibling, 1 reply; 7+ messages in thread
From: Hugh Dickins @ 2022-03-02 20:17 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Xavier Roche, Linux Kernel Mailing List, Hugh Dickins,
	Andrew Morton, Jean Delvare, Linux-MM

On Wed, 2 Mar 2022, Linus Torvalds wrote:
> On Mon, Feb 28, 2022 at 12:43 AM Xavier Roche <xavier.roche@algolia.com> wrote:
> >
> > Various filesystems (including ext4) now support file creation time.
> > This patch adds such support for tmpfs-based filesystems.

Please ignore this patch for now: I presume Xavier did not understand
the "from akpm to Linus in next merge window" flow, and thought he had
to resend the patch to you.

> 
> What's the odd huge-page noise in this patch?

That was one of the fixups I added, which akpm is holding in a -fix
patch to be merged in, and maybe he'll include my comment from it:

3. Using shmem_getattr() on other file types than regular requires that
   shmem_is_huge() check type, to stop incorrect HPAGE_PMD_SIZE blksize.

(shmem_getattr() was only on regular files before: Xavier's patch
added it to directories etc, to provide btime for them too; but
shmem_getattr() can also include a dubious adjustment to blksize.)

> 
> Other oddities:
> 
>     Reply-To: b954973a-b8d1-cab8-63bd-6ea8063de3@google.com
> 
> WHAT?

No comment from me.

> 
> And finally - if we really want to treat btime as a first-class entity
> and expect things like tmpfs to support it, then we should just bite
> the bullet and put it in 'struct inode' along with the other times.

I've no objection if someone does that later.  I've no investment
in btime myself (my instinctive reaction was, is this thing worth
another 16 bytes of inode space?), but Xavier thought it worth doing,
and Andrew worth taking, so go with the flow.

Ah, Andrew has replied meanwhile, I hope I'm not contradicting!

Hugh

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] tmpfs: support for file creation time
  2022-03-02 20:17   ` Hugh Dickins
@ 2022-03-14 21:08     ` Xavier Roche
  0 siblings, 0 replies; 7+ messages in thread
From: Xavier Roche @ 2022-03-14 21:08 UTC (permalink / raw)
  To: Hugh Dickins
  Cc: Linus Torvalds, Linux Kernel Mailing List, Andrew Morton,
	Jean Delvare, Linux-MM

On Wed, Mar 02, 2022 at 12:17:30PM -0800, Hugh Dickins wrote:
> Please ignore this patch for now: I presume Xavier did not understand
> the "from akpm to Linus in next merge window" flow, and thought he had
> to resend the patch to you.

I will resend a fixed v4 version in a moment, sorry for the noise (and
I indeed did not fully understand the flow).

> > And finally - if we really want to treat btime as a first-class entity
> > and expect things like tmpfs to support it, then we should just bite
> > the bullet and put it in 'struct inode' along with the other times.
> I've no objection if someone does that later.

I might give it a try if this is something that can be of interest.

The idea of having btime in 'struct inode' would make the btime a
first-class citizen, allowing to have more consistent (w.r.t filesystem
types) behavior.

This would also mean allowing to _change_ it, typically to allow archivers
to set the creation time as they do for {a,c,m}time.

Currently, birth time semantic is bound to the current filesystem's
life cycle and as such is irrelevant after a restore, or a 'tar xf'.

The only gray area to me is whether or not we "can" always change this
property without unforeseen consequences, typically for ext4.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-03-14 21:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-11 21:36 [PATCH v2] tmpfs: support for file creation time Xavier Roche
2022-02-28  8:43 ` [PATCH v3] " Xavier Roche
2022-02-27  6:30 ` [PATCH mmotm] tmpfs: three tweaks to creation time patch Hugh Dickins
2022-03-02 19:43 ` [PATCH v3] tmpfs: support for file creation time Linus Torvalds
2022-03-02 19:59   ` Andrew Morton
2022-03-02 20:17   ` Hugh Dickins
2022-03-14 21:08     ` Xavier Roche

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.