bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 85/87] fs: rename i_atime and i_mtime fields to __i_atime and __i_mtime
@ 2023-09-28 11:05 Jeff Layton
  2023-09-28 11:05 ` [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers Jeff Layton
  2023-09-28 11:05 ` [PATCH 87/87] fs: move i_blocks up a few places in struct inode Jeff Layton
  0 siblings, 2 replies; 24+ messages in thread
From: Jeff Layton @ 2023-09-28 11:05 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner, Linus Torvalds, David Sterba,
	Amir Goldstein, Theodore Ts'o, Eric Biederman, Kees Cook,
	Jeremy Kerr, Arnd Bergmann, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas,
	Suren Baghdasaryan, Mattia Dongili, Dennis Dalessandro,
	Jason Gunthorpe, Leon Romanovsky, Brad Warrum, Ritu Agarwal,
	Hans de Goede, Ilpo Järvinen, Mark Gross, Jiri Slaby,
	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
	Christian Schoenebeck, David Sterba, David Howells, Marc Dionne,
	Ian Kent, Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J. Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Darrick J. Wong, Damien Le Moal, Naohiro Aota,
	Johannes Thumshirn, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Hugh Dickins, Andrew Morton, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, John Johansen, Paul Moore,
	James Morris, Serge E. Hallyn, Stephen Smalley, Eric Paris
  Cc: linux-fsdevel, linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, netdev,
	apparmor, linux-security-module, selinux

Make it clear that these fields are private now, and that the accessors
should be used instead.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 include/linux/fs.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 12d247b82aa0..831657011036 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -671,9 +671,9 @@ struct inode {
 	};
 	dev_t			i_rdev;
 	loff_t			i_size;
-	struct timespec64	i_atime;
-	struct timespec64	i_mtime;
-	struct timespec64	__i_ctime; /* use inode_*_ctime accessors! */
+	struct timespec64	__i_atime; /* use inode_*_atime accessors */
+	struct timespec64	__i_mtime; /* use inode_*_mtime accessors */
+	struct timespec64	__i_ctime; /* use inode_*_ctime accessors */
 	spinlock_t		i_lock;	/* i_blocks, i_bytes, maybe i_size */
 	unsigned short          i_bytes;
 	u8			i_blkbits;
@@ -1555,13 +1555,13 @@ static inline struct timespec64 inode_set_ctime(struct inode *inode,
 
 static inline struct timespec64 inode_get_atime(const struct inode *inode)
 {
-	return inode->i_atime;
+	return inode->__i_atime;
 }
 
 static inline struct timespec64 inode_set_atime_to_ts(struct inode *inode,
 						      struct timespec64 ts)
 {
-	inode->i_atime = ts;
+	inode->__i_atime = ts;
 	return ts;
 }
 
@@ -1575,13 +1575,13 @@ static inline struct timespec64 inode_set_atime(struct inode *inode,
 
 static inline struct timespec64 inode_get_mtime(const struct inode *inode)
 {
-	return inode->i_mtime;
+	return inode->__i_mtime;
 }
 
 static inline struct timespec64 inode_set_mtime_to_ts(struct inode *inode,
 						      struct timespec64 ts)
 {
-	inode->i_mtime = ts;
+	inode->__i_mtime = ts;
 	return ts;
 }
 
-- 
2.41.0


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

* [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers
  2023-09-28 11:05 [PATCH 85/87] fs: rename i_atime and i_mtime fields to __i_atime and __i_mtime Jeff Layton
@ 2023-09-28 11:05 ` Jeff Layton
  2023-09-28 15:48   ` Arnd Bergmann
  2023-09-28 17:09   ` Jeff Layton
  2023-09-28 11:05 ` [PATCH 87/87] fs: move i_blocks up a few places in struct inode Jeff Layton
  1 sibling, 2 replies; 24+ messages in thread
From: Jeff Layton @ 2023-09-28 11:05 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner, Linus Torvalds, David Sterba,
	Amir Goldstein, Theodore Ts'o, Eric Biederman, Kees Cook,
	Jeremy Kerr, Arnd Bergmann, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas,
	Suren Baghdasaryan, Mattia Dongili, Dennis Dalessandro,
	Jason Gunthorpe, Leon Romanovsky, Brad Warrum, Ritu Agarwal,
	Hans de Goede, Ilpo Järvinen, Mark Gross, Jiri Slaby,
	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
	Christian Schoenebeck, David Sterba, David Howells, Marc Dionne,
	Ian Kent, Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J. Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Darrick J. Wong, Damien Le Moal, Naohiro Aota,
	Johannes Thumshirn, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Hugh Dickins, Andrew Morton, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, John Johansen, Paul Moore,
	James Morris, Serge E. Hallyn, Stephen Smalley, Eric Paris
  Cc: linux-fsdevel, linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, netdev,
	apparmor, linux-security-module, selinux

This shaves 8 bytes off struct inode, according to pahole.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 include/linux/fs.h | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 831657011036..de902ff2938b 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -671,9 +671,12 @@ struct inode {
 	};
 	dev_t			i_rdev;
 	loff_t			i_size;
-	struct timespec64	__i_atime; /* use inode_*_atime accessors */
-	struct timespec64	__i_mtime; /* use inode_*_mtime accessors */
-	struct timespec64	__i_ctime; /* use inode_*_ctime accessors */
+	time64_t		i_atime_sec;
+	time64_t		i_mtime_sec;
+	time64_t		i_ctime_sec;
+	u32			i_atime_nsec;
+	u32			i_mtime_nsec;
+	u32			i_ctime_nsec;
 	spinlock_t		i_lock;	/* i_blocks, i_bytes, maybe i_size */
 	unsigned short          i_bytes;
 	u8			i_blkbits;
@@ -1519,7 +1522,9 @@ struct timespec64 inode_set_ctime_current(struct inode *inode);
  */
 static inline struct timespec64 inode_get_ctime(const struct inode *inode)
 {
-	return inode->__i_ctime;
+	struct timespec64 ts = { .tv_sec  = inode->i_ctime_sec,
+				 .tv_nsec = inode->i_ctime_nsec };
+	return ts;
 }
 
 /**
@@ -1532,7 +1537,8 @@ static inline struct timespec64 inode_get_ctime(const struct inode *inode)
 static inline struct timespec64 inode_set_ctime_to_ts(struct inode *inode,
 						      struct timespec64 ts)
 {
-	inode->__i_ctime = ts;
+	inode->i_ctime_sec = ts.tv_sec;
+	inode->i_ctime_nsec = ts.tv_sec;
 	return ts;
 }
 
@@ -1555,13 +1561,17 @@ static inline struct timespec64 inode_set_ctime(struct inode *inode,
 
 static inline struct timespec64 inode_get_atime(const struct inode *inode)
 {
-	return inode->__i_atime;
+	struct timespec64 ts = { .tv_sec  = inode->i_atime_sec,
+				 .tv_nsec = inode->i_atime_nsec };
+
+	return ts;
 }
 
 static inline struct timespec64 inode_set_atime_to_ts(struct inode *inode,
 						      struct timespec64 ts)
 {
-	inode->__i_atime = ts;
+	inode->i_atime_sec = ts.tv_sec;
+	inode->i_atime_nsec = ts.tv_sec;
 	return ts;
 }
 
@@ -1575,13 +1585,17 @@ static inline struct timespec64 inode_set_atime(struct inode *inode,
 
 static inline struct timespec64 inode_get_mtime(const struct inode *inode)
 {
-	return inode->__i_mtime;
+	struct timespec64 ts = { .tv_sec  = inode->i_mtime_sec,
+				 .tv_nsec = inode->i_mtime_nsec };
+
+	return ts;
 }
 
 static inline struct timespec64 inode_set_mtime_to_ts(struct inode *inode,
 						      struct timespec64 ts)
 {
-	inode->__i_mtime = ts;
+	inode->i_atime_sec = ts.tv_sec;
+	inode->i_atime_nsec = ts.tv_sec;
 	return ts;
 }
 
-- 
2.41.0


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

* [PATCH 87/87] fs: move i_blocks up a few places in struct inode
  2023-09-28 11:05 [PATCH 85/87] fs: rename i_atime and i_mtime fields to __i_atime and __i_mtime Jeff Layton
  2023-09-28 11:05 ` [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers Jeff Layton
@ 2023-09-28 11:05 ` Jeff Layton
  2023-09-28 11:35   ` Amir Goldstein
  2023-09-28 17:41   ` Linus Torvalds
  1 sibling, 2 replies; 24+ messages in thread
From: Jeff Layton @ 2023-09-28 11:05 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner, Linus Torvalds, David Sterba,
	Amir Goldstein, Theodore Ts'o, Eric Biederman, Kees Cook,
	Jeremy Kerr, Arnd Bergmann, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas,
	Suren Baghdasaryan, Mattia Dongili, Dennis Dalessandro,
	Jason Gunthorpe, Leon Romanovsky, Brad Warrum, Ritu Agarwal,
	Hans de Goede, Ilpo Järvinen, Mark Gross, Jiri Slaby,
	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
	Christian Schoenebeck, David Sterba, David Howells, Marc Dionne,
	Ian Kent, Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J. Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Darrick J. Wong, Damien Le Moal, Naohiro Aota,
	Johannes Thumshirn, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Hugh Dickins, Andrew Morton, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, John Johansen, Paul Moore,
	James Morris, Serge E. Hallyn, Stephen Smalley, Eric Paris
  Cc: linux-fsdevel, linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, netdev,
	apparmor, linux-security-module, selinux

The recent change to use discrete integers instead of struct timespec64
in struct inode shaved 8 bytes off of it, but it also moves the i_lock
into the previous cacheline, away from the fields that it protects.

Move i_blocks up above the i_lock, which moves the new 4 byte hole to
just after the timestamps, without changing the size of the structure.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 include/linux/fs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index de902ff2938b..3e0fe0f52e7c 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -677,11 +677,11 @@ struct inode {
 	u32			i_atime_nsec;
 	u32			i_mtime_nsec;
 	u32			i_ctime_nsec;
+	blkcnt_t		i_blocks;
 	spinlock_t		i_lock;	/* i_blocks, i_bytes, maybe i_size */
 	unsigned short          i_bytes;
 	u8			i_blkbits;
 	u8			i_write_hint;
-	blkcnt_t		i_blocks;
 
 #ifdef __NEED_I_SIZE_ORDERED
 	seqcount_t		i_size_seqcount;
-- 
2.41.0


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

* Re: [PATCH 87/87] fs: move i_blocks up a few places in struct inode
  2023-09-28 11:05 ` [PATCH 87/87] fs: move i_blocks up a few places in struct inode Jeff Layton
@ 2023-09-28 11:35   ` Amir Goldstein
  2023-09-28 12:01     ` Jeff Layton
  2023-09-28 17:41   ` Linus Torvalds
  1 sibling, 1 reply; 24+ messages in thread
From: Amir Goldstein @ 2023-09-28 11:35 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Alexander Viro, Christian Brauner, Linus Torvalds, David Sterba,
	Theodore Ts'o, Eric Biederman, Kees Cook, Jeremy Kerr,
	Arnd Bergmann, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas,
	Suren Baghdasaryan, Mattia Dongili, Dennis Dalessandro,
	Jason Gunthorpe, Leon Romanovsky, Brad Warrum, Ritu Agarwal,
	Hans de Goede, Ilpo Järvinen, Mark Gross, Jiri Slaby,
	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
	Christian Schoenebeck, David Sterba, David Howells, Marc Dionne,
	Ian Kent, Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J. Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Darrick J. Wong, Damien Le Moal, Naohiro Aota,
	Johannes Thumshirn, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Hugh Dickins, Andrew Morton, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, John Johansen, Paul Moore,
	James Morris, Serge E. Hallyn, Stephen Smalley, Eric Paris,
	linux-fsdevel, linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, netdev,
	apparmor, linux-security-module, selinux

On Thu, Sep 28, 2023 at 2:06 PM Jeff Layton <jlayton@kernel.org> wrote:
>
> The recent change to use discrete integers instead of struct timespec64
> in struct inode shaved 8 bytes off of it, but it also moves the i_lock
> into the previous cacheline, away from the fields that it protects.
>
> Move i_blocks up above the i_lock, which moves the new 4 byte hole to
> just after the timestamps, without changing the size of the structure.
>

Instead of creating an implicit hole, can you please move i_generation
to fill the 4 bytes hole.

It makes sense in the same cache line with i_ino and I could
use the vacant 4 bytes hole above i_fsnotify_mask to expand the
mask to 64bit (the 32bit event mask space is running out).

Thanks,
Amir.

> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  include/linux/fs.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index de902ff2938b..3e0fe0f52e7c 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -677,11 +677,11 @@ struct inode {
>         u32                     i_atime_nsec;
>         u32                     i_mtime_nsec;
>         u32                     i_ctime_nsec;
> +       blkcnt_t                i_blocks;
>         spinlock_t              i_lock; /* i_blocks, i_bytes, maybe i_size */
>         unsigned short          i_bytes;
>         u8                      i_blkbits;
>         u8                      i_write_hint;
> -       blkcnt_t                i_blocks;
>
>  #ifdef __NEED_I_SIZE_ORDERED
>         seqcount_t              i_size_seqcount;
> --
> 2.41.0
>

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

* Re: [PATCH 87/87] fs: move i_blocks up a few places in struct inode
  2023-09-28 11:35   ` Amir Goldstein
@ 2023-09-28 12:01     ` Jeff Layton
  0 siblings, 0 replies; 24+ messages in thread
From: Jeff Layton @ 2023-09-28 12:01 UTC (permalink / raw)
  To: Amir Goldstein
  Cc: Alexander Viro, Christian Brauner, Linus Torvalds, David Sterba,
	Theodore Ts'o, Eric Biederman, Kees Cook, Jeremy Kerr,
	Arnd Bergmann, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas,
	Suren Baghdasaryan, Mattia Dongili, Dennis Dalessandro,
	Jason Gunthorpe, Leon Romanovsky, Brad Warrum, Ritu Agarwal,
	Hans de Goede, Ilpo Järvinen, Mark Gross, Jiri Slaby,
	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
	Christian Schoenebeck, David Sterba, David Howells, Marc Dionne,
	Ian Kent, Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J. Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Darrick J. Wong, Damien Le Moal, Naohiro Aota,
	Johannes Thumshirn, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Hugh Dickins, Andrew Morton, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, John Johansen, Paul Moore,
	James Morris, Serge E. Hallyn, Stephen Smalley, Eric Paris,
	linux-fsdevel, linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, netdev,
	apparmor, linux-security-module, selinux

On Thu, 2023-09-28 at 14:35 +0300, Amir Goldstein wrote:
> On Thu, Sep 28, 2023 at 2:06 PM Jeff Layton <jlayton@kernel.org> wrote:
> > 
> > The recent change to use discrete integers instead of struct timespec64
> > in struct inode shaved 8 bytes off of it, but it also moves the i_lock
> > into the previous cacheline, away from the fields that it protects.
> > 
> > Move i_blocks up above the i_lock, which moves the new 4 byte hole to
> > just after the timestamps, without changing the size of the structure.
> > 
> 
> Instead of creating an implicit hole, can you please move i_generation
> to fill the 4 bytes hole.
> 
> It makes sense in the same cache line with i_ino and I could
> use the vacant 4 bytes hole above i_fsnotify_mask to expand the
> mask to 64bit (the 32bit event mask space is running out).
> 
> Thanks,
> Amir.
> 

Sounds like a plan. Resulting struct inode size is the same (616 bytes
with my kdevops kconfig). BTW: all of these changes are in my "amtime"
branch if anyone wants to pull them down.
--
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers
  2023-09-28 11:05 ` [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers Jeff Layton
@ 2023-09-28 15:48   ` Arnd Bergmann
  2023-09-28 17:06     ` Jeff Layton
  2023-09-28 17:09   ` Jeff Layton
  1 sibling, 1 reply; 24+ messages in thread
From: Arnd Bergmann @ 2023-09-28 15:48 UTC (permalink / raw)
  To: Jeff Layton, Alexander Viro, Christian Brauner, Linus Torvalds,
	David Sterba, Amir Goldstein, Theodore Ts'o,
	Eric W. Biederman, Kees Cook, Jeremy Kerr, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas,
	Suren Baghdasaryan, Mattia Dongili, Dennis Dalessandro,
	Jason Gunthorpe, Leon Romanovsky, Brad Warrum, Ritu Agarwal,
	Hans de Goede, Ilpo Järvinen, Mark Gross, Jiri Slaby,
	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
	Christian Schoenebeck, David Sterba, David Howells, Marc Dionne,
	Ian Kent, Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J . Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Darrick J. Wong, Damien Le Moal, Naohiro Aota,
	Johannes Thumshirn, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Hugh Dickins, Andrew Morton, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, John Johansen, Paul Moore,
	James Morris, Serge E. Hallyn, Stephen Smalley, Eric Paris
  Cc: linux-fsdevel, linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, Netdev,
	apparmor, linux-security-module, selinux

On Thu, Sep 28, 2023, at 07:05, Jeff Layton wrote:
> This shaves 8 bytes off struct inode, according to pahole.
>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

FWIW, this is similar to the approach that Deepa suggested
back in 2016:

https://lore.kernel.org/lkml/1452144972-15802-3-git-send-email-deepa.kernel@gmail.com/

It was NaKed at the time because of the added complexity,
though it would have been much easier to do it then,
as we had to touch all the timespec references anyway.

The approach still seems ok to me, but I'm not sure it's worth
doing it now if we didn't do it then.

     Arnd

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

* Re: [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers
  2023-09-28 15:48   ` Arnd Bergmann
@ 2023-09-28 17:06     ` Jeff Layton
  2023-09-28 17:19       ` Darrick J. Wong
  2023-09-29  9:44       ` Christian Brauner
  0 siblings, 2 replies; 24+ messages in thread
From: Jeff Layton @ 2023-09-28 17:06 UTC (permalink / raw)
  To: Arnd Bergmann, Alexander Viro, Christian Brauner, Linus Torvalds,
	David Sterba, Amir Goldstein, Theodore Ts'o,
	Eric W. Biederman, Kees Cook, Jeremy Kerr, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas,
	Suren Baghdasaryan, Mattia Dongili, Dennis Dalessandro,
	Jason Gunthorpe, Leon Romanovsky, Brad Warrum, Ritu Agarwal,
	Hans de Goede, Ilpo Järvinen, Mark Gross, Jiri Slaby,
	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
	Christian Schoenebeck, David Sterba, David Howells, Marc Dionne,
	Ian Kent, Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J . Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Darrick J. Wong, Damien Le Moal, Naohiro Aota,
	Johannes Thumshirn, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Hugh Dickins, Andrew Morton, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, John Johansen, Paul Moore,
	James Morris, Serge E. Hallyn, Stephen Smalley, Eric Paris
  Cc: linux-fsdevel, linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, Netdev,
	apparmor, linux-security-module, selinux

On Thu, 2023-09-28 at 11:48 -0400, Arnd Bergmann wrote:
> On Thu, Sep 28, 2023, at 07:05, Jeff Layton wrote:
> > This shaves 8 bytes off struct inode, according to pahole.
> > 
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> 
> FWIW, this is similar to the approach that Deepa suggested
> back in 2016:
> 
> https://lore.kernel.org/lkml/1452144972-15802-3-git-send-email-deepa.kernel@gmail.com/
> 
> It was NaKed at the time because of the added complexity,
> though it would have been much easier to do it then,
> as we had to touch all the timespec references anyway.
> 
> The approach still seems ok to me, but I'm not sure it's worth
> doing it now if we didn't do it then.
> 

I remember seeing those patches go by. I don't remember that change
being NaK'ed, but I wasn't paying close attention at the time 

Looking at it objectively now, I think it's worth it to recover 8 bytes
per inode and open a 4 byte hole that Amir can use to grow the
i_fsnotify_mask. We might even able to shave off another 12 bytes
eventually if we can move to a single 64-bit word per timestamp. 

It is a lot of churn though.
-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers
  2023-09-28 11:05 ` [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers Jeff Layton
  2023-09-28 15:48   ` Arnd Bergmann
@ 2023-09-28 17:09   ` Jeff Layton
  1 sibling, 0 replies; 24+ messages in thread
From: Jeff Layton @ 2023-09-28 17:09 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner, Linus Torvalds, David Sterba,
	Amir Goldstein, Theodore Ts'o, Eric Biederman, Kees Cook,
	Jeremy Kerr, Arnd Bergmann, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas,
	Suren Baghdasaryan, Mattia Dongili, Dennis Dalessandro,
	Jason Gunthorpe, Leon Romanovsky, Brad Warrum, Ritu Agarwal,
	Hans de Goede, Ilpo Järvinen, Mark Gross, Jiri Slaby,
	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
	Christian Schoenebeck, David Sterba, David Howells, Marc Dionne,
	Ian Kent, Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J. Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Darrick J. Wong, Damien Le Moal, Naohiro Aota,
	Johannes Thumshirn, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Hugh Dickins, Andrew Morton, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, John Johansen, Paul Moore,
	James Morris, Serge E. Hallyn, Stephen Smalley, Eric Paris
  Cc: linux-fsdevel, linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, netdev,
	apparmor, linux-security-module, selinux

On Thu, 2023-09-28 at 07:05 -0400, Jeff Layton wrote:
> This shaves 8 bytes off struct inode, according to pahole.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  include/linux/fs.h | 32 +++++++++++++++++++++++---------
>  1 file changed, 23 insertions(+), 9 deletions(-)
> 
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 831657011036..de902ff2938b 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -671,9 +671,12 @@ struct inode {
>  	};
>  	dev_t			i_rdev;
>  	loff_t			i_size;
> -	struct timespec64	__i_atime; /* use inode_*_atime accessors */
> -	struct timespec64	__i_mtime; /* use inode_*_mtime accessors */
> -	struct timespec64	__i_ctime; /* use inode_*_ctime accessors */
> +	time64_t		i_atime_sec;
> +	time64_t		i_mtime_sec;
> +	time64_t		i_ctime_sec;
> +	u32			i_atime_nsec;
> +	u32			i_mtime_nsec;
> +	u32			i_ctime_nsec;
>  	spinlock_t		i_lock;	/* i_blocks, i_bytes, maybe i_size */
>  	unsigned short          i_bytes;
>  	u8			i_blkbits;
> @@ -1519,7 +1522,9 @@ struct timespec64 inode_set_ctime_current(struct inode *inode);
>   */
>  static inline struct timespec64 inode_get_ctime(const struct inode *inode)
>  {
> -	return inode->__i_ctime;
> +	struct timespec64 ts = { .tv_sec  = inode->i_ctime_sec,
> +				 .tv_nsec = inode->i_ctime_nsec };
> +	return ts;
>  }
> 
>
>  
>  /**
> @@ -1532,7 +1537,8 @@ static inline struct timespec64 inode_get_ctime(const struct inode *inode)
>  static inline struct timespec64 inode_set_ctime_to_ts(struct inode *inode,
>  						      struct timespec64 ts)
>  {
> -	inode->__i_ctime = ts;
> +	inode->i_ctime_sec = ts.tv_sec;
> +	inode->i_ctime_nsec = ts.tv_sec;

Bug above and in the other inode_set_?time_to_ts() functions. This isn't
setting the nsec field correctly.

>  	return ts;
>  }
> 
> 


>  
> @@ -1555,13 +1561,17 @@ static inline struct timespec64 inode_set_ctime(struct inode *inode,
>  
>  static inline struct timespec64 inode_get_atime(const struct inode *inode)
>  {
> -	return inode->__i_atime;
> +	struct timespec64 ts = { .tv_sec  = inode->i_atime_sec,
> +				 .tv_nsec = inode->i_atime_nsec };
> +
> +	return ts;
>  }
>  
>  static inline struct timespec64 inode_set_atime_to_ts(struct inode *inode,
>  						      struct timespec64 ts)
>  {
> -	inode->__i_atime = ts;
> +	inode->i_atime_sec = ts.tv_sec;
> +	inode->i_atime_nsec = ts.tv_sec;
>  	return ts;
>  }
>  
> @@ -1575,13 +1585,17 @@ static inline struct timespec64 inode_set_atime(struct inode *inode,
>  
>  static inline struct timespec64 inode_get_mtime(const struct inode *inode)
>  {
> -	return inode->__i_mtime;
> +	struct timespec64 ts = { .tv_sec  = inode->i_mtime_sec,
> +				 .tv_nsec = inode->i_mtime_nsec };
> +
> +	return ts;
>  }
>  
>  static inline struct timespec64 inode_set_mtime_to_ts(struct inode *inode,
>  						      struct timespec64 ts)
>  {
> -	inode->__i_mtime = ts;
> +	inode->i_atime_sec = ts.tv_sec;
> +	inode->i_atime_nsec = ts.tv_sec;

Doh! s/atime/mtime/ in the above lines.

>  	return ts;
>  }
>  

Both bugs are fixed in my tree.
-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers
  2023-09-28 17:06     ` Jeff Layton
@ 2023-09-28 17:19       ` Darrick J. Wong
  2023-09-28 17:40         ` Jeff Layton
                           ` (2 more replies)
  2023-09-29  9:44       ` Christian Brauner
  1 sibling, 3 replies; 24+ messages in thread
From: Darrick J. Wong @ 2023-09-28 17:19 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Arnd Bergmann, Alexander Viro, Christian Brauner, Linus Torvalds,
	David Sterba, Amir Goldstein, Theodore Ts'o,
	Eric W. Biederman, Kees Cook, Jeremy Kerr, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas,
	Suren Baghdasaryan, Mattia Dongili, Dennis Dalessandro,
	Jason Gunthorpe, Leon Romanovsky, Brad Warrum, Ritu Agarwal,
	Hans de Goede, Ilpo Järvinen, Mark Gross, Jiri Slaby,
	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
	Christian Schoenebeck, David Sterba, David Howells, Marc Dionne,
	Ian Kent, Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J . Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Damien Le Moal, Naohiro Aota, Johannes Thumshirn,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Hugh Dickins,
	Andrew Morton, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, John Johansen, Paul Moore, James Morris,
	Serge E. Hallyn, Stephen Smalley, Eric Paris, linux-fsdevel,
	linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, Netdev,
	apparmor, linux-security-module, selinux

On Thu, Sep 28, 2023 at 01:06:03PM -0400, Jeff Layton wrote:
> On Thu, 2023-09-28 at 11:48 -0400, Arnd Bergmann wrote:
> > On Thu, Sep 28, 2023, at 07:05, Jeff Layton wrote:
> > > This shaves 8 bytes off struct inode, according to pahole.
> > > 
> > > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > 
> > FWIW, this is similar to the approach that Deepa suggested
> > back in 2016:
> > 
> > https://lore.kernel.org/lkml/1452144972-15802-3-git-send-email-deepa.kernel@gmail.com/
> > 
> > It was NaKed at the time because of the added complexity,
> > though it would have been much easier to do it then,
> > as we had to touch all the timespec references anyway.
> > 
> > The approach still seems ok to me, but I'm not sure it's worth
> > doing it now if we didn't do it then.
> > 
> 
> I remember seeing those patches go by. I don't remember that change
> being NaK'ed, but I wasn't paying close attention at the time 
> 
> Looking at it objectively now, I think it's worth it to recover 8 bytes
> per inode and open a 4 byte hole that Amir can use to grow the
> i_fsnotify_mask. We might even able to shave off another 12 bytes
> eventually if we can move to a single 64-bit word per timestamp. 

I don't think you can, since btrfs timestamps utilize s64 seconds
counting in both directions from the Unix epoch.  They also support ns
resolution:

	struct btrfs_timespec {
		__le64 sec;
		__le32 nsec;
	} __attribute__ ((__packed__));

--D

> It is a lot of churn though.
> -- 
> Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers
  2023-09-28 17:19       ` Darrick J. Wong
@ 2023-09-28 17:40         ` Jeff Layton
  2023-09-28 20:21           ` Arnd Bergmann
  2023-09-28 21:26           ` Theodore Ts'o
  2023-09-29  3:27         ` Amir Goldstein
  2023-09-29  6:32         ` David Howells
  2 siblings, 2 replies; 24+ messages in thread
From: Jeff Layton @ 2023-09-28 17:40 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: Arnd Bergmann, Alexander Viro, Christian Brauner, Linus Torvalds,
	David Sterba, Amir Goldstein, Theodore Ts'o,
	Eric W. Biederman, Kees Cook, Jeremy Kerr, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas,
	Suren Baghdasaryan, Mattia Dongili, Dennis Dalessandro,
	Jason Gunthorpe, Leon Romanovsky, Brad Warrum, Ritu Agarwal,
	Hans de Goede, Ilpo Järvinen, Mark Gross, Jiri Slaby,
	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
	Christian Schoenebeck, David Sterba, David Howells, Marc Dionne,
	Ian Kent, Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J . Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Damien Le Moal, Naohiro Aota, Johannes Thumshirn,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Hugh Dickins,
	Andrew Morton, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, John Johansen, Paul Moore, James Morris,
	Serge E. Hallyn, Stephen Smalley, Eric Paris, linux-fsdevel,
	linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, Netdev,
	apparmor, linux-security-module, selinux

On Thu, 2023-09-28 at 10:19 -0700, Darrick J. Wong wrote:
> On Thu, Sep 28, 2023 at 01:06:03PM -0400, Jeff Layton wrote:
> > On Thu, 2023-09-28 at 11:48 -0400, Arnd Bergmann wrote:
> > > On Thu, Sep 28, 2023, at 07:05, Jeff Layton wrote:
> > > > This shaves 8 bytes off struct inode, according to pahole.
> > > > 
> > > > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > > 
> > > FWIW, this is similar to the approach that Deepa suggested
> > > back in 2016:
> > > 
> > > https://lore.kernel.org/lkml/1452144972-15802-3-git-send-email-deepa.kernel@gmail.com/
> > > 
> > > It was NaKed at the time because of the added complexity,
> > > though it would have been much easier to do it then,
> > > as we had to touch all the timespec references anyway.
> > > 
> > > The approach still seems ok to me, but I'm not sure it's worth
> > > doing it now if we didn't do it then.
> > > 
> > 
> > I remember seeing those patches go by. I don't remember that change
> > being NaK'ed, but I wasn't paying close attention at the time 
> > 
> > Looking at it objectively now, I think it's worth it to recover 8 bytes
> > per inode and open a 4 byte hole that Amir can use to grow the
> > i_fsnotify_mask. We might even able to shave off another 12 bytes
> > eventually if we can move to a single 64-bit word per timestamp. 
> 
> I don't think you can, since btrfs timestamps utilize s64 seconds
> counting in both directions from the Unix epoch.  They also support ns
> resolution:
> 
> 	struct btrfs_timespec {
> 		__le64 sec;
> 		__le32 nsec;
> 	} __attribute__ ((__packed__));
> 

Correct. We'd lose some fidelity in currently stored timestamps, but as
Linus and Ted pointed out, anything below ~100ns granularity is
effectively just noise, as that's the floor overhead for calling into
the kernel. It's hard to argue that any application needs that sort of
timestamp resolution, at least with contemporary hardware. 

Doing that would mean that tests that store specific values in the
atime/mtime and expect to be able to fetch exactly that value back would
break though, so we'd have to be OK with that if we want to try it. The
good news is that it's relatively easy to experiment with new ways to
store timestamps with these wrappers in place.

-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH 87/87] fs: move i_blocks up a few places in struct inode
  2023-09-28 11:05 ` [PATCH 87/87] fs: move i_blocks up a few places in struct inode Jeff Layton
  2023-09-28 11:35   ` Amir Goldstein
@ 2023-09-28 17:41   ` Linus Torvalds
  2023-09-28 18:01     ` Jeff Layton
  2023-09-29  9:32     ` Christian Brauner
  1 sibling, 2 replies; 24+ messages in thread
From: Linus Torvalds @ 2023-09-28 17:41 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Alexander Viro, Christian Brauner, David Sterba, Amir Goldstein,
	Theodore Ts'o, Eric Biederman, Kees Cook, Jeremy Kerr,
	Arnd Bergmann, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas,
	Suren Baghdasaryan, Mattia Dongili, Dennis Dalessandro,
	Jason Gunthorpe, Leon Romanovsky, Brad Warrum, Ritu Agarwal,
	Hans de Goede, Ilpo Järvinen, Mark Gross, Jiri Slaby,
	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
	Christian Schoenebeck, David Sterba, David Howells, Marc Dionne,
	Ian Kent, Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J. Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Darrick J. Wong, Damien Le Moal, Naohiro Aota,
	Johannes Thumshirn, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Hugh Dickins, Andrew Morton, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, John Johansen, Paul Moore,
	James Morris, Serge E. Hallyn, Stephen Smalley, Eric Paris,
	linux-fsdevel, linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, netdev,
	apparmor, linux-security-module, selinux

On Thu, 28 Sept 2023 at 04:06, Jeff Layton <jlayton@kernel.org> wrote:
>
> Move i_blocks up above the i_lock, which moves the new 4 byte hole to
> just after the timestamps, without changing the size of the structure.

I'm sure others have mentioned this, but 'struct inode' is marked with
__randomize_layout, so the actual layout may end up being very
different.

I'm personally not convinced the whole structure randomization is
worth it - it's easy enough to figure out for any distro kernel since
the seed has to be the same across machines for modules to work, so
even if the seed isn't "public", any layout is bound to be fairly
easily discoverable.

So the whole randomization only really works for private kernel
builds, and it adds this kind of pain where "optimizing" the structure
layout is kind of pointless depending on various options.

I certainly *hope* no distro enables that pointless thing, but it's a worry.

               Linus

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

* Re: [PATCH 87/87] fs: move i_blocks up a few places in struct inode
  2023-09-28 17:41   ` Linus Torvalds
@ 2023-09-28 18:01     ` Jeff Layton
  2023-09-29  9:32     ` Christian Brauner
  1 sibling, 0 replies; 24+ messages in thread
From: Jeff Layton @ 2023-09-28 18:01 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Alexander Viro, Christian Brauner, David Sterba, Amir Goldstein,
	Theodore Ts'o, Eric Biederman, Kees Cook, Jeremy Kerr,
	Arnd Bergmann, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas,
	Suren Baghdasaryan, Mattia Dongili, Dennis Dalessandro,
	Jason Gunthorpe, Leon Romanovsky, Brad Warrum, Ritu Agarwal,
	Hans de Goede, Ilpo Järvinen, Mark Gross, Jiri Slaby,
	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
	Christian Schoenebeck, David Sterba, David Howells, Marc Dionne,
	Ian Kent, Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J. Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Darrick J. Wong, Damien Le Moal, Naohiro Aota,
	Johannes Thumshirn, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Hugh Dickins, Andrew Morton, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, John Johansen, Paul Moore,
	James Morris, Serge E. Hallyn, Stephen Smalley, Eric Paris,
	linux-fsdevel, linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, netdev,
	apparmor, linux-security-module, selinux

On Thu, 2023-09-28 at 10:41 -0700, Linus Torvalds wrote:
> On Thu, 28 Sept 2023 at 04:06, Jeff Layton <jlayton@kernel.org> wrote:
> > 
> > Move i_blocks up above the i_lock, which moves the new 4 byte hole to
> > just after the timestamps, without changing the size of the structure.
> 
> I'm sure others have mentioned this, but 'struct inode' is marked with
> __randomize_layout, so the actual layout may end up being very
> different.
> 
> I'm personally not convinced the whole structure randomization is
> worth it - it's easy enough to figure out for any distro kernel since
> the seed has to be the same across machines for modules to work, so
> even if the seed isn't "public", any layout is bound to be fairly
> easily discoverable.
> 
> So the whole randomization only really works for private kernel
> builds, and it adds this kind of pain where "optimizing" the structure
> layout is kind of pointless depending on various options.
> 
> I certainly *hope* no distro enables that pointless thing, but it's a worry.
> 

I've never enabled struct randomization and don't know anyone who does.
I figure if you turn that on, you get to keep all of the pieces when you
start seeing weird performance problems.

I think that we have to optimize for that being disabled. Even without
that though, turning on and off options can change the layout...and then
there are different arches, etc.

I'm using a config derived from the Fedora x86_64 kernel images and hope
that represents a reasonably common configuration. The only conditional
members before the timestamps are based on CONFIG_FS_POSIX_ACL and
CONFIG_SECURITY, which are almost always turned on with most distros.
-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers
  2023-09-28 17:40         ` Jeff Layton
@ 2023-09-28 20:21           ` Arnd Bergmann
  2023-09-28 21:26           ` Theodore Ts'o
  1 sibling, 0 replies; 24+ messages in thread
From: Arnd Bergmann @ 2023-09-28 20:21 UTC (permalink / raw)
  To: Jeff Layton, Darrick J. Wong
  Cc: Alexander Viro, Christian Brauner, Linus Torvalds, David Sterba,
	Amir Goldstein, Theodore Ts'o, Eric W. Biederman, Kees Cook,
	Jeremy Kerr, Michael Ellerman, Nicholas Piggin, Christophe Leroy,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Greg Kroah-Hartman,
	Arve Hjønnevåg, Todd Kjos, Martijn Coenen,
	Joel Fernandes, Carlos Llamas, Suren Baghdasaryan,
	Mattia Dongili, Dennis Dalessandro, Jason Gunthorpe,
	Leon Romanovsky, Brad Warrum, Ritu Agarwal, Hans de Goede,
	Ilpo Järvinen, Mark Gross, Jiri Slaby, Eric Van Hensbergen,
	Latchesar Ionkov, Dominique Martinet, Christian Schoenebeck,
	David Sterba, David Howells, Marc Dionne, Ian Kent,
	Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J . Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Damien Le Moal, Naohiro Aota, Johannes Thumshirn,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Hugh Dickins,
	Andrew Morton, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, John Johansen, Paul Moore, James Morris,
	Serge E. Hallyn, Stephen Smalley, Eric Paris, linux-fsdevel,
	linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, Netdev,
	apparmor, linux-security-module, selinux

On Thu, Sep 28, 2023, at 13:40, Jeff Layton wrote:
> On Thu, 2023-09-28 at 10:19 -0700, Darrick J. Wong wrote:
>>
>> > I remember seeing those patches go by. I don't remember that change
>> > being NaK'ed, but I wasn't paying close attention at the time 
>> > 
>> > Looking at it objectively now, I think it's worth it to recover 8 bytes
>> > per inode and open a 4 byte hole that Amir can use to grow the
>> > i_fsnotify_mask. We might even able to shave off another 12 bytes
>> > eventually if we can move to a single 64-bit word per timestamp. 
>> 
>> I don't think you can, since btrfs timestamps utilize s64 seconds
>> counting in both directions from the Unix epoch.  They also support ns
>> resolution:
>> 
>> 	struct btrfs_timespec {
>> 		__le64 sec;
>> 		__le32 nsec;
>> 	} __attribute__ ((__packed__));
>> 
>
> Correct. We'd lose some fidelity in currently stored timestamps, but as
> Linus and Ted pointed out, anything below ~100ns granularity is
> effectively just noise, as that's the floor overhead for calling into
> the kernel. It's hard to argue that any application needs that sort of
> timestamp resolution, at least with contemporary hardware. 

There are probably applications that have come up with creative
ways to use the timestamp fields of file systems that 94 bits
of data, with both the MSB of the seconds and the LSB of the
nanoseconds carrying information that they expect to be preserved.

Dropping any information in the nanoseconds other than the top two
bits would trivially change the 'ls -t' output when two files have
the same timestamp in one kernel but slightly different timestamps
in another one. For large values of 'tv_sec', there are fewer
obvious things that break, but if current kernels are able to
retrieve arbitrary times that were stored with utimensat(), then we
should probably make sure future kernels can see the same.

        Arnd

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

* Re: [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers
  2023-09-28 17:40         ` Jeff Layton
  2023-09-28 20:21           ` Arnd Bergmann
@ 2023-09-28 21:26           ` Theodore Ts'o
  2023-09-29  0:18             ` Linus Torvalds
  1 sibling, 1 reply; 24+ messages in thread
From: Theodore Ts'o @ 2023-09-28 21:26 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Darrick J. Wong, Arnd Bergmann, Alexander Viro,
	Christian Brauner, Linus Torvalds, David Sterba, Amir Goldstein,
	Eric W. Biederman, Kees Cook, Jeremy Kerr, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas,
	Suren Baghdasaryan, Mattia Dongili, Dennis Dalessandro,
	Jason Gunthorpe, Leon Romanovsky, Brad Warrum, Ritu Agarwal,
	Hans de Goede, Ilpo Järvinen, Mark Gross, Jiri Slaby,
	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
	Christian Schoenebeck, David Sterba, David Howells, Marc Dionne,
	Ian Kent, Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J . Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Damien Le Moal, Naohiro Aota, Johannes Thumshirn,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Hugh Dickins,
	Andrew Morton, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, John Johansen, Paul Moore, James Morris,
	Serge E. Hallyn, Stephen Smalley, Eric Paris, linux-fsdevel,
	linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, Netdev,
	apparmor, linux-security-module, selinux

On Thu, Sep 28, 2023 at 01:40:55PM -0400, Jeff Layton wrote:
> 
> Correct. We'd lose some fidelity in currently stored timestamps, but as
> Linus and Ted pointed out, anything below ~100ns granularity is
> effectively just noise, as that's the floor overhead for calling into
> the kernel. It's hard to argue that any application needs that sort of
> timestamp resolution, at least with contemporary hardware. 
> 
> Doing that would mean that tests that store specific values in the
> atime/mtime and expect to be able to fetch exactly that value back would
> break though, so we'd have to be OK with that if we want to try it. The
> good news is that it's relatively easy to experiment with new ways to
> store timestamps with these wrappers in place.

The reason why we store 1ns granularity in ext4's on-disk format (and
accept that we only support times only a couple of centuries into the
future, as opposed shooting for an on-disk format good for several
millennia :-), was in case there was userspace that might try to store
a very fine-grained timestamp and want to be able to get it back
bit-for-bit identical.

For example, what if someone was trying to implement some kind of
steganographic scheme where they going store a secret message (or more
likely, a 256-bit AES key) in the nanosecond fields of the file's
{c,m,a,cr}time timestamps, "hiding in plain sight".  Not that I think
that we have to support something like that, since the field is for
*timestamps* not cryptographic bits, so if we break someone who is
doing that, do we care?

I don't think anyone will complain about breaking the userspace API
--- especially since if, say, the CIA was using this for their spies'
drop boxes, they probably wouldn't want to admit it.  :-)

       	    	     	      	      	    - Ted

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

* Re: [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers
  2023-09-28 21:26           ` Theodore Ts'o
@ 2023-09-29  0:18             ` Linus Torvalds
  2023-09-29  3:50               ` Amir Goldstein
  0 siblings, 1 reply; 24+ messages in thread
From: Linus Torvalds @ 2023-09-29  0:18 UTC (permalink / raw)
  To: Theodore Ts'o
  Cc: Jeff Layton, Darrick J. Wong, Arnd Bergmann, Alexander Viro,
	Christian Brauner, David Sterba, Amir Goldstein,
	Eric W. Biederman, Kees Cook, Jeremy Kerr, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas,
	Suren Baghdasaryan, Mattia Dongili, Dennis Dalessandro,
	Jason Gunthorpe, Leon Romanovsky, Brad Warrum, Ritu Agarwal,
	Hans de Goede, Ilpo Järvinen, Mark Gross, Jiri Slaby,
	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
	Christian Schoenebeck, David Sterba, David Howells, Marc Dionne,
	Ian Kent, Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J . Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Damien Le Moal, Naohiro Aota, Johannes Thumshirn,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Hugh Dickins,
	Andrew Morton, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, John Johansen, Paul Moore, James Morris,
	Serge E. Hallyn, Stephen Smalley, Eric Paris, linux-fsdevel,
	linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, Netdev,
	apparmor, linux-security-module, selinux

On Thu, 28 Sept 2023 at 14:28, Theodore Ts'o <tytso@mit.edu> wrote:
>
> I don't think anyone will complain about breaking the userspace API
> --- especially since if, say, the CIA was using this for their spies'
> drop boxes, they probably wouldn't want to admit it.  :-)

Well, you will find that real apps do kind of of care.

Just to take a very real example, "git" will very much notice time
granularity issues and care - because git will cache the 'stat' times
in the index.

So if you get a different stat time (because the vfs layer has changed
some granularity), git will then have to check the files carefully
again and update the index.

You can simulate this "re-check all files" with something like this:

    $ time git diff

    real 0m0.040s
    user 0m0.035s
    sys 0m0.264s

    $ rm .git/index && git read-tree HEAD

    $ time git diff

    real 0m9.595s
    user 0m7.287s
    sys 0m2.810s

so the difference between just doing a "look, index information
matches current 'stat' information" and "oops, index does not have the
stat data" is "40 milliseconds" vs "10 seconds".

That's a big difference, and you'd see that each time the granularity
changes. But then once the index file has been updated, it's back to
the good case.

So yes, real programs to cache stat information, and it matters for performance.

But I don't think any actual reasonable program will have
*correctness* issues, though - because there are certainly filesystems
out there that don't do nanosecond resolution (and other operations
like copying trees around will obviously also change times).

Anybody doing steganography in the timestamps is already not going to
have a great time, really.

                 Linus

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

* Re: [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers
  2023-09-28 17:19       ` Darrick J. Wong
  2023-09-28 17:40         ` Jeff Layton
@ 2023-09-29  3:27         ` Amir Goldstein
  2023-09-29  6:32         ` David Howells
  2 siblings, 0 replies; 24+ messages in thread
From: Amir Goldstein @ 2023-09-29  3:27 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: Jeff Layton, Arnd Bergmann, Alexander Viro, Christian Brauner,
	Linus Torvalds, David Sterba, Theodore Ts'o,
	Eric W. Biederman, Kees Cook, Jeremy Kerr, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas,
	Suren Baghdasaryan, Mattia Dongili, Dennis Dalessandro,
	Jason Gunthorpe, Leon Romanovsky, Brad Warrum, Ritu Agarwal,
	Hans de Goede, Ilpo Järvinen, Mark Gross, Jiri Slaby,
	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
	Christian Schoenebeck, David Sterba, David Howells, Marc Dionne,
	Ian Kent, Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J . Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Damien Le Moal, Naohiro Aota, Johannes Thumshirn,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Hugh Dickins,
	Andrew Morton, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, John Johansen, Paul Moore, James Morris,
	Serge E. Hallyn, Stephen Smalley, Eric Paris, linux-fsdevel,
	linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, Netdev,
	apparmor, linux-security-module, selinux

On Thu, Sep 28, 2023 at 8:19 PM Darrick J. Wong <djwong@kernel.org> wrote:
>
> On Thu, Sep 28, 2023 at 01:06:03PM -0400, Jeff Layton wrote:
> > On Thu, 2023-09-28 at 11:48 -0400, Arnd Bergmann wrote:
> > > On Thu, Sep 28, 2023, at 07:05, Jeff Layton wrote:
> > > > This shaves 8 bytes off struct inode, according to pahole.
> > > >
> > > > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > >
> > > FWIW, this is similar to the approach that Deepa suggested
> > > back in 2016:
> > >
> > > https://lore.kernel.org/lkml/1452144972-15802-3-git-send-email-deepa.kernel@gmail.com/
> > >
> > > It was NaKed at the time because of the added complexity,
> > > though it would have been much easier to do it then,
> > > as we had to touch all the timespec references anyway.
> > >
> > > The approach still seems ok to me, but I'm not sure it's worth
> > > doing it now if we didn't do it then.
> > >
> >
> > I remember seeing those patches go by. I don't remember that change
> > being NaK'ed, but I wasn't paying close attention at the time
> >
> > Looking at it objectively now, I think it's worth it to recover 8 bytes
> > per inode and open a 4 byte hole that Amir can use to grow the
> > i_fsnotify_mask. We might even able to shave off another 12 bytes
> > eventually if we can move to a single 64-bit word per timestamp.
>
> I don't think you can, since btrfs timestamps utilize s64 seconds
> counting in both directions from the Unix epoch.  They also support ns
> resolution:
>
>         struct btrfs_timespec {
>                 __le64 sec;
>                 __le32 nsec;
>         } __attribute__ ((__packed__));
>
> --D
>

Sure we can.
That's what btrfs_inode is for.
vfs inode also does not store i_otime (birth time) and there is even a
precedent of vfs/btrfs variable size mismatch:

        /* full 64 bit generation number, struct vfs_inode doesn't have a big
         * enough field for this.
         */
        u64 generation;

If we decide that vfs should use "bigtime", btrfs pre-historic
timestamps are not a show stopper.

Thanks,
Amir.

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

* Re: [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers
  2023-09-29  0:18             ` Linus Torvalds
@ 2023-09-29  3:50               ` Amir Goldstein
  2023-09-29 16:22                 ` Linus Torvalds
  0 siblings, 1 reply; 24+ messages in thread
From: Amir Goldstein @ 2023-09-29  3:50 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Theodore Ts'o, Jeff Layton, Darrick J. Wong, Arnd Bergmann,
	Alexander Viro, Christian Brauner, David Sterba,
	Eric W. Biederman, Kees Cook, Jeremy Kerr, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas,
	Suren Baghdasaryan, Mattia Dongili, Dennis Dalessandro,
	Jason Gunthorpe, Leon Romanovsky, Brad Warrum, Ritu Agarwal,
	Hans de Goede, Ilpo Järvinen, Mark Gross, Jiri Slaby,
	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
	Christian Schoenebeck, David Sterba, David Howells, Marc Dionne,
	Ian Kent, Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J . Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Damien Le Moal, Naohiro Aota, Johannes Thumshirn,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Hugh Dickins,
	Andrew Morton, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, John Johansen, Paul Moore, James Morris,
	Serge E. Hallyn, Stephen Smalley, Eric Paris, linux-fsdevel,
	linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, Netdev,
	apparmor, linux-security-module, selinux

On Fri, Sep 29, 2023 at 3:19 AM Linus Torvalds
<torvalds@linux-foundation.org> wrote:
...
> So yes, real programs to cache stat information, and it matters for performance.
>
> But I don't think any actual reasonable program will have
> *correctness* issues, though -

I beg to disagree.

> because there are certainly filesystems
> out there that don't do nanosecond resolution (and other operations
> like copying trees around will obviously also change times).
>
> Anybody doing steganography in the timestamps is already not going to
> have a great time, really.
>

Your thesis implies that all applications are portable across different
filesystems and all applications are expected to cope with copying
trees around.

There are applications that work on specific filesystems and those
applications are very much within sanity if they expect that past
observed values of nsec will not to change if the file was not changed.

But even if we agree that will "only" hurt performance, your example of
performance hit (10s of git diff) is nowhere close to the performance
hit of invalidating the mtime cache of billions of files at once (i.e. after
kernel upgrade), which means that rsync-like programs need to
re-read all the data from remote locations.

I am not saying that filesystems cannot decide to *stop storing nsec
granularity* from this day forth, but like btrfs pre-historic timestamps,
those fs have an obligation to preserve existing metadata, unless
users opted to throw it away.

OTOH, it is perfectly fine if the vfs wants to stop providing sub 100ns
services to filesystems. It's just going to be the fs problem and the
preserved pre-historic/fine-grained time on existing files would only
need to be provided in getattr(). It does not need to be in __i_mtime.

Thanks,
Amir.

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

* Re: [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers
  2023-09-28 17:19       ` Darrick J. Wong
  2023-09-28 17:40         ` Jeff Layton
  2023-09-29  3:27         ` Amir Goldstein
@ 2023-09-29  6:32         ` David Howells
  2023-09-30 14:50           ` Steve French
  2 siblings, 1 reply; 24+ messages in thread
From: David Howells @ 2023-09-29  6:32 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Darrick J. Wong, Arnd Bergmann, Alexander Viro,
	Christian Brauner, Linus Torvalds, David Sterba, Amir Goldstein,
	Theodore Ts'o, Eric W. Biederman, Kees Cook, Jeremy Kerr,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Greg Kroah-Hartman,
	Arve Hjønnevåg, Todd Kjos, Martijn Coenen,
	Joel Fernandes, Carlos Llamas, Suren Baghdasaryan,
	Mattia Dongili, Dennis Dalessandro, Jason Gunthorpe,
	Leon Romanovsky, Brad Warrum, Ritu Agarwal, Hans de Goede,
	Ilpo Järvinen, Mark Gross, Jiri Slaby, Eric Van Hensbergen,
	Latchesar Ionkov, Dominique Martinet, Christian Schoenebeck,
	David Sterba, David Howells, Marc Dionne, Ian Kent,
	Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J . Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Damien Le Moal, Naohiro Aota, Johannes Thumshirn,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Hugh Dickins,
	Andrew Morton, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, John Johansen, Paul Moore, James Morris,
	Serge E. Hallyn, Stephen Smalley, Eric Paris, linux-fsdevel,
	linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, Netdev,
	apparmor, linux-security-module, selinux


Jeff Layton <jlayton@kernel.org> wrote:

> Correct. We'd lose some fidelity in currently stored timestamps, but as
> Linus and Ted pointed out, anything below ~100ns granularity is
> effectively just noise, as that's the floor overhead for calling into
> the kernel. It's hard to argue that any application needs that sort of
> timestamp resolution, at least with contemporary hardware. 

Albeit with the danger of making Steve French very happy;-), would it make
sense to switch internally to Microsoft-style 64-bit timestamps with their
100ns granularity?

David


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

* Re: [PATCH 87/87] fs: move i_blocks up a few places in struct inode
  2023-09-28 17:41   ` Linus Torvalds
  2023-09-28 18:01     ` Jeff Layton
@ 2023-09-29  9:32     ` Christian Brauner
  1 sibling, 0 replies; 24+ messages in thread
From: Christian Brauner @ 2023-09-29  9:32 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Jeff Layton, Alexander Viro, David Sterba, Amir Goldstein,
	Theodore Ts'o, Eric Biederman, Kees Cook, Jeremy Kerr,
	Arnd Bergmann, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas,
	Suren Baghdasaryan, Mattia Dongili, Dennis Dalessandro,
	Jason Gunthorpe, Leon Romanovsky, Brad Warrum, Ritu Agarwal,
	Hans de Goede, Ilpo Järvinen, Mark Gross, Jiri Slaby,
	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
	Christian Schoenebeck, David Sterba, David Howells, Marc Dionne,
	Ian Kent, Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J. Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Darrick J. Wong, Damien Le Moal, Naohiro Aota,
	Johannes Thumshirn, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Hugh Dickins, Andrew Morton, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, John Johansen, Paul Moore,
	James Morris, Serge E. Hallyn, Stephen Smalley, Eric Paris,
	linux-fsdevel, linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, netdev,
	apparmor, linux-security-module, selinux

On Thu, Sep 28, 2023 at 10:41:34AM -0700, Linus Torvalds wrote:
> On Thu, 28 Sept 2023 at 04:06, Jeff Layton <jlayton@kernel.org> wrote:
> >
> > Move i_blocks up above the i_lock, which moves the new 4 byte hole to
> > just after the timestamps, without changing the size of the structure.
> 
> I'm sure others have mentioned this, but 'struct inode' is marked with
> __randomize_layout, so the actual layout may end up being very
> different.
> 
> I'm personally not convinced the whole structure randomization is
> worth it - it's easy enough to figure out for any distro kernel since
> the seed has to be the same across machines for modules to work, so
> even if the seed isn't "public", any layout is bound to be fairly
> easily discoverable.
> 
> So the whole randomization only really works for private kernel
> builds, and it adds this kind of pain where "optimizing" the structure
> layout is kind of pointless depending on various options.
> 
> I certainly *hope* no distro enables that pointless thing, but it's a worry.

They don't last we checked. Just last cycle we moved stuff in struct
file around to optimize things and we explicitly said we don't give a
damn about struct randomization. Anyone who enables this will bleed
performance pretty badly, I would reckon.

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

* Re: [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers
  2023-09-28 17:06     ` Jeff Layton
  2023-09-28 17:19       ` Darrick J. Wong
@ 2023-09-29  9:44       ` Christian Brauner
  2023-09-29 10:16         ` Jeff Layton
  1 sibling, 1 reply; 24+ messages in thread
From: Christian Brauner @ 2023-09-29  9:44 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Arnd Bergmann, Alexander Viro, Linus Torvalds, David Sterba,
	Amir Goldstein, Theodore Ts'o, Eric W. Biederman, Kees Cook,
	Jeremy Kerr, Michael Ellerman, Nicholas Piggin, Christophe Leroy,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Greg Kroah-Hartman,
	Arve Hjønnevåg, Todd Kjos, Martijn Coenen,
	Joel Fernandes, Carlos Llamas, Suren Baghdasaryan,
	Mattia Dongili, Dennis Dalessandro, Jason Gunthorpe,
	Leon Romanovsky, Brad Warrum, Ritu Agarwal, Hans de Goede,
	Ilpo Järvinen, Mark Gross, Jiri Slaby, Eric Van Hensbergen,
	Latchesar Ionkov, Dominique Martinet, Christian Schoenebeck,
	David Sterba, David Howells, Marc Dionne, Ian Kent,
	Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J . Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Darrick J. Wong, Damien Le Moal, Naohiro Aota,
	Johannes Thumshirn, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Hugh Dickins, Andrew Morton, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, John Johansen, Paul Moore,
	James Morris, Serge E. Hallyn, Stephen Smalley, Eric Paris,
	linux-fsdevel, linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, Netdev,
	apparmor, linux-security-module, selinux

> It is a lot of churn though.

I think that i_{a,c,m}time shouldn't be accessed directly by
filesystems same as no filesystem should really access i_{g,u}id which
we also provide i_{g,u}id_{read,write}() accessors for. The mode is
another example where really most often should use helpers because of all
the set*id stripping that we need to do (and the bugs that we had
because of this...).

The interdependency between ctime and mtime is enough to hide this in
accessors. The other big advantage is simply grepability. So really I
would like to see this change even without the type switch.

In other words, there's no need to lump the two changes together. Do the
conversion part and we can argue about the switch to discrete integers
separately.

The other adavantage is that we have a cycle to see any possible
regression from the conversion.

Thoughts anyone?

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

* Re: [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers
  2023-09-29  9:44       ` Christian Brauner
@ 2023-09-29 10:16         ` Jeff Layton
  0 siblings, 0 replies; 24+ messages in thread
From: Jeff Layton @ 2023-09-29 10:16 UTC (permalink / raw)
  To: Christian Brauner
  Cc: Arnd Bergmann, Alexander Viro, Linus Torvalds, David Sterba,
	Amir Goldstein, Theodore Ts'o, Eric W. Biederman, Kees Cook,
	Jeremy Kerr, Michael Ellerman, Nicholas Piggin, Christophe Leroy,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Greg Kroah-Hartman,
	Arve Hjønnevåg, Todd Kjos, Martijn Coenen,
	Joel Fernandes, Carlos Llamas, Suren Baghdasaryan,
	Mattia Dongili, Dennis Dalessandro, Jason Gunthorpe,
	Leon Romanovsky, Brad Warrum, Ritu Agarwal, Hans de Goede,
	Ilpo Järvinen, Mark Gross, Jiri Slaby, Eric Van Hensbergen,
	Latchesar Ionkov, Dominique Martinet, Christian Schoenebeck,
	David Sterba, David Howells, Marc Dionne, Ian Kent,
	Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J . Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Darrick J. Wong, Damien Le Moal, Naohiro Aota,
	Johannes Thumshirn, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Hugh Dickins, Andrew Morton, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, John Johansen, Paul Moore,
	James Morris, Serge E. Hallyn, Stephen Smalley, Eric Paris,
	linux-fsdevel, linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, Netdev,
	apparmor, linux-security-module, selinux

On Fri, 2023-09-29 at 11:44 +0200, Christian Brauner wrote:
> > It is a lot of churn though.
> 
> I think that i_{a,c,m}time shouldn't be accessed directly by
> filesystems same as no filesystem should really access i_{g,u}id which
> we also provide i_{g,u}id_{read,write}() accessors for. The mode is
> another example where really most often should use helpers because of all
> the set*id stripping that we need to do (and the bugs that we had
> because of this...).
> 
> The interdependency between ctime and mtime is enough to hide this in
> accessors. The other big advantage is simply grepability. So really I
> would like to see this change even without the type switch.
> 
> In other words, there's no need to lump the two changes together. Do the
> conversion part and we can argue about the switch to discrete integers
> separately.
> 
> The other adavantage is that we have a cycle to see any possible
> regression from the conversion.
> 
> Thoughts anyone?

That works for me, and sort of what I was planning anyway. I mostly just
did the change to timestamp storage to see what it would look like
afterward.

FWIW, I'm planning to do a v2 patchbomb early next week, with the
changes that Chuck suggested (specific helpers for fetching the _sec and
_nsec fields). For now, I'll drop the change from timespec64 to discrete
fields. We can do that in a separate follow-on set.
-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers
  2023-09-29  3:50               ` Amir Goldstein
@ 2023-09-29 16:22                 ` Linus Torvalds
  0 siblings, 0 replies; 24+ messages in thread
From: Linus Torvalds @ 2023-09-29 16:22 UTC (permalink / raw)
  To: Amir Goldstein
  Cc: Theodore Ts'o, Jeff Layton, Darrick J. Wong, Arnd Bergmann,
	Alexander Viro, Christian Brauner, David Sterba,
	Eric W. Biederman, Kees Cook, Jeremy Kerr, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Carlos Llamas,
	Suren Baghdasaryan, Mattia Dongili, Dennis Dalessandro,
	Jason Gunthorpe, Leon Romanovsky, Brad Warrum, Ritu Agarwal,
	Hans de Goede, Ilpo Järvinen, Mark Gross, Jiri Slaby,
	Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
	Christian Schoenebeck, David Sterba, David Howells, Marc Dionne,
	Ian Kent, Luis de Bethencourt, Salah Triki, Tigran A. Aivazian,
	Chris Mason, Josef Bacik, Xiubo Li, Ilya Dryomov, Jan Harkes,
	coda, Joel Becker, Christoph Hellwig, Nicolas Pitre,
	Rafael J . Wysocki, Ard Biesheuvel, Gao Xiang, Chao Yu, Yue Hu,
	Jeffle Xu, Namjae Jeon, Sungjong Seo, Jan Kara, Andreas Dilger,
	Jaegeuk Kim, OGAWA Hirofumi, Christoph Hellwig, Miklos Szeredi,
	Bob Peterson, Andreas Gruenbacher, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Mikulas Patocka, Mike Kravetz,
	Muchun Song, Jan Kara, David Woodhouse, Dave Kleikamp, Tejun Heo,
	Trond Myklebust, Anna Schumaker, Chuck Lever, Neil Brown,
	Olga Kornievskaia, Dai Ngo, Tom Talpey, Ryusuke Konishi,
	Anton Altaparmakov, Konstantin Komarov, Mark Fasheh, Joseph Qi,
	Bob Copeland, Mike Marshall, Martin Brandenburg,
	Luis Chamberlain, Iurii Zaikin, Tony Luck, Guilherme G. Piccoli,
	Anders Larsen, Steve French, Paulo Alcantara, Ronnie Sahlberg,
	Shyam Prasad N, Sergey Senozhatsky, Phillip Lougher,
	Steven Rostedt, Masami Hiramatsu, Evgeniy Dushistov,
	Chandan Babu R, Damien Le Moal, Naohiro Aota, Johannes Thumshirn,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Hugh Dickins,
	Andrew Morton, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, John Johansen, Paul Moore, James Morris,
	Serge E. Hallyn, Stephen Smalley, Eric Paris, linux-fsdevel,
	linux-kernel, linux-mm, linuxppc-dev, linux-s390,
	platform-driver-x86, linux-rdma, linux-serial, linux-usb, v9fs,
	linux-afs, autofs, linux-btrfs, ceph-devel, codalist, linux-efi,
	linux-erofs, linux-ext4, linux-f2fs-devel, gfs2, linux-um,
	linux-mtd, jfs-discussion, linux-nfs, linux-nilfs,
	linux-ntfs-dev, ntfs3, ocfs2-devel, linux-karma-devel, devel,
	linux-unionfs, linux-hardening, reiserfs-devel, linux-cifs,
	samba-technical, linux-trace-kernel, linux-xfs, bpf, Netdev,
	apparmor, linux-security-module, selinux

On Thu, 28 Sept 2023 at 20:50, Amir Goldstein <amir73il@gmail.com> wrote:
>
> OTOH, it is perfectly fine if the vfs wants to stop providing sub 100ns
> services to filesystems. It's just going to be the fs problem and the
> preserved pre-historic/fine-grained time on existing files would only
> need to be provided in getattr(). It does not need to be in __i_mtime.

Hmm. That sounds technically sane, but for one thing: if the aim is to try to do

 (a) atomic timestamp access

 (b) shrink the inode

then having the filesystem maintain its own timestamp for fine-grained
data will break both of those goals.

Yes, we'd make 'struct inode' smaller if we pack the times into one
64-bit entity, but if btrfs responds by adding mtime fields to "struct
btrfs_inode", we lost the size advantage and only made things worse.

And if ->getattr() then reads those fields without locking (and we
definitely don't want locking in that path), then we lost the
atomicity thing too.

So no. A "but the filesystem can maintain finer granularity" model is
not acceptable, I think.

If we do require nanoseconds for compatibility, what we could possibly
do is say "we guarantee nanosecond values for *legacy* dates", and say
that future dates use 100ns resolution. We'd define "legacy dates" to
be the traditional 32-bit signed time_t.

So with a 64-bit fstime_t, we'd have the "legacy format":

 - top 32 bits are seconds, bottom 32 bits are ns

which gives us that ns format.

Then, because only 30 bits are needed for nanosecond resolution, we
use the top two bits of that ns field as flags. '00' means that legacy
format, and '01' would mean "we're not doing nanosecond resolution,
we're doing 64ns resolution, and the low 6 bits of the ns field are
actually bits 32-37 of the seconds field".

That still gives us some extensibility (unless the multi-grain code
still wants to use the other top bit), and it gives us 40 bits of
seconds, which is quite a lot.

And all the conversion functions will be simple bit field
manipulations, so there are no expensive ops here.

Anyway, I agree with the "let's introduce the accessor functions
first, we can do the 'pack into one word' decisions later".

                Linus

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

* Re: [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers
  2023-09-29  6:32         ` David Howells
@ 2023-09-30 14:50           ` Steve French
  2023-10-01  5:01             ` [OT] " Gabriel Paubert
  0 siblings, 1 reply; 24+ messages in thread
From: Steve French @ 2023-09-30 14:50 UTC (permalink / raw)
  To: David Howells
  Cc: Jeff Layton, Latchesar Ionkov, Konstantin Komarov,
	Rafael J . Wysocki, Darrick J. Wong, Anders Larsen,
	Carlos Llamas, Andrii Nakryiko, Mattia Dongili, Hugh Dickins,
	John Johansen, Yonghong Song, Alexander Gordeev,
	Christoph Hellwig, Mike Marshall, Paulo Alcantara, linux-xfs,
	Michael Ellerman, James Morris, Christophe Leroy,
	Christian Borntraeger, devel, Shyam Prasad N, linux-um,
	Nicholas Piggin, Alexander Viro, Eric Van Hensbergen,
	Suren Baghdasaryan, Trond Myklebust, Anton Altaparmakov,
	Christian Brauner, Greg Kroah-Hartman, Stephen Smalley,
	linux-usb, linux-kernel, Ronnie Sahlberg, Sergey Senozhatsky,
	Arve Hjønnevåg, Chuck Lever, Sven Schnelle, Jiri Olsa,
	Jan Kara, Tejun Heo, Andrew Morton, linux-trace-kernel,
	Linus Torvalds, Dave Kleikamp, linux-mm, Joel Fernandes,
	Eric Dumazet, Stanislav Fomichev, linux-s390, linux-nilfs,
	Paul Moore, Leon Romanovsky, John Fastabend, Luis Chamberlain,
	codalist, Iurii Zaikin, Namjae Jeon, Masami Hiramatsu, Todd Kjos,
	Vasily Gorbik, selinux, linuxppc-dev, reiserfs-devel,
	Miklos Szeredi, Yue Hu, Jaegeuk Kim, Martijn Coenen,
	OGAWA Hirofumi, Hao Luo, Tony Luck, Theodore Ts'o,
	Nicolas Pitre, linux-ntfs-dev, Muchun Song, linux-f2fs-devel,
	Guilherme G. Piccoli, gfs2, Eric W. Biederman, Anna Schumaker,
	Brad Warrum, Mike Kravetz, linux-efi, Martin Brandenburg,
	ocfs2-devel, Alexei Starovoitov, platform-driver-x86,
	Chris Mason, linux-mtd, linux-hardening, Marc Dionne, Jiri Slaby,
	linux-afs, Ian Kent, Naohiro Aota, Daniel Borkmann,
	Dennis Dalessandro, linux-rdma, coda, Ilpo Järvinen,
	Ilya Dryomov, Paolo Abeni, Serge E. Hallyn,
	Christian Schoenebeck, Kees Cook, Arnd Bergmann, autofs,
	Steven Rostedt, Mark Gross, Damien Le Moal, Eric Paris,
	ceph-devel, Gao Xiang, Jan Harkes, linux-nfs, linux-ext4,
	Olga Kornievskaia, Song Liu, samba-technical, Steve French,
	Jeremy Kerr, Netdev, Bob Peterson, linux-fsdevel, bpf, ntfs3,
	linux-erofs, David S . Miller, Chandan Babu R, jfs-discussion,
	Jan Kara, Neil Brown, Dominique Martinet, Amir Goldstein,
	Bob Copeland, KP Singh, linux-unionfs, Joseph Qi, Andreas Dilger,
	Mikulas Patocka, Ard Biesheuvel, Anton Ivanov,
	Andreas Gruenbacher, Richard Weinberger, Mark Fasheh, Dai Ngo,
	Jason Gunthorpe, linux-serial, Jakub Kicinski, Salah Triki,
	Evgeniy Dushistov, linux-cifs, Heiko Carstens, Chao Yu, apparmor,
	Josef Bacik, Tom Talpey, Hans de Goede, Tigran A. Aivazian,
	David Sterba, Xiubo Li, Ryusuke Konishi, Johannes Thumshirn,
	Ritu Agarwal, Luis de Bethencourt, Martin KaFai Lau, v9fs,
	David Sterba, linux-security-module, Jeffle Xu, Phillip Lougher,
	Johannes Berg, Sungjong Seo, David Woodhouse, linux-karma-devel,
	linux-btrfs, Joel Becker

On Fri, Sep 29, 2023 at 3:06 AM David Howells via samba-technical
<samba-technical@lists.samba.org> wrote:
>
>
> Jeff Layton <jlayton@kernel.org> wrote:
>
> > Correct. We'd lose some fidelity in currently stored timestamps, but as
> > Linus and Ted pointed out, anything below ~100ns granularity is
> > effectively just noise, as that's the floor overhead for calling into
> > the kernel. It's hard to argue that any application needs that sort of
> > timestamp resolution, at least with contemporary hardware.
>
> Albeit with the danger of making Steve French very happy;-), would it make
> sense to switch internally to Microsoft-style 64-bit timestamps with their
> 100ns granularity?

100ns granularity does seem to make sense and IIRC was used by various
DCE standards in the 90s and 2000s (not just used for SMB2/SMB3 protocol and
various Windows filesystems)


-- 
Thanks,

Steve

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

* [OT] Re: [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers
  2023-09-30 14:50           ` Steve French
@ 2023-10-01  5:01             ` Gabriel Paubert
  0 siblings, 0 replies; 24+ messages in thread
From: Gabriel Paubert @ 2023-10-01  5:01 UTC (permalink / raw)
  To: Steve French
  Cc: David Howells, Latchesar Ionkov, Rafael J . Wysocki,
	Darrick J. Wong, Anders Larsen, Carlos Llamas, Sven Schnelle,
	Mattia Dongili, Yonghong Song, Alexander Gordeev,
	Christoph Hellwig, Mike Marshall, Paulo Alcantara,
	Jason Gunthorpe, James Morris, Christian Borntraeger, devel,
	Shyam Prasad N, Jan Harkes, linux-um, Nicholas Piggin,
	Alexander Viro, Eric Van Hensbergen, Suren Baghdasaryan,
	Trond Myklebust, Anton Altaparmakov, Christian Brauner,
	Greg Kr oah-Hartman, Stephen Smalley, linux-usb, linux-kernel,
	Ronnie Sahlberg, Sergey Senozhatsky, Luis Chamberlain,
	Chuck Lever, Masami Hiramatsu, Jiri Olsa, Jan Kara, Tejun Heo,
	Andrew Morton, Linus Torvalds, Dave Kleikamp, samba-technical,
	Marc Dionne, Eric Dumazet, Stanislav Fomichev, linux-s390,
	linux-nilfs, Paul Moore, Leon Romanovsky, Hugh Dickins,
	Andrii Nakryiko, codalist, Iurii Zaikin, Namjae Jeon,
	linux-trace-kernel, Todd Kjos, Vasily Gorbik, selinux,
	reiserfs-devel, Sungjong Seo, ocfs2-devel, Yue Hu, Jaegeuk Kim,
	Martijn Coenen, OGAWA Hirofumi, Hao Luo, Tony Luck,
	Theodore Ts'o, Nicolas Pitre, linux-ntfs-dev, Muchun Song,
	linux-f2fs-devel, Guilherme G. Piccoli, Eric W. Biederman,
	Anna Schumaker, David Woodhouse, Brad Warrum, Mike Kravetz,
	linux-efi, Martin Brandenburg, Alexei Starovoitov,
	platform-driver-x86, Joseph Qi, Chris Mason, linux-mtd,
	linux-hardening, Joel Fernandes, Jiri Slaby, linux-afs, Ian Kent,
	Naohiro Aota, Daniel Borkmann, Miklos Szeredi, linux-rdma, coda,
	Ilpo Järvinen, Ilya Dryomov, Paolo Abeni, Serge E. Hallyn,
	Amir Goldstein, Kees Cook, Arnd Bergmann, autofs, Steven Rostedt,
	Mark Gross, Damien Le Moal, Eric Paris, ceph-devel, Gao Xiang,
	gfs2, linux-nfs, linux-ext4, Olga Kornievskaia, Song Liu,
	Jeff Layton, Martin KaFai Lau, linux-xfs, Jeremy Kerr,
	Bob Peterson, linux-fsdevel, bpf, ntfs3, linux-erofs,
	David S . Miller, Chandan Babu R, jfs-discussion, Jan Kara,
	Neil Brown, Dominique Martinet, Christian Schoenebeck,
	Bob Copeland, KP Singh, David Sterba, Konstantin Komarov,
	linux-mm, Andreas Dilger, Arve Hjønnevåg,
	Mikulas Patocka, Ard Biesheuvel, Anton Ivanov,
	Andreas Gruenbacher, Richard Weinberger, Mark Fasheh, Dai Ngo,
	Steve French, linux-serial, Jakub Kicinski, Salah Triki,
	John Fastabend, Evgeniy Dushistov, linux-cifs, Heiko Carstens,
	Chao Yu, apparmor, Josef Bacik, Tom Talpey, Hans de Goede,
	Tigran A. Aivazian, David Sterba, Xiubo Li, Ryusuke Konishi,
	Dennis Dalessandro, John Johansen, Ritu Agarwal,
	Luis de Bethencourt, Netdev, v9fs, linux-unionfs,
	linux-security-module, Jeffle Xu, Phillip Lougher, Johannes Berg,
	Johannes Thumshirn, linuxppc-dev, linux-karma-devel, linux-btrfs,
	Joel Becker

On Sat, Sep 30, 2023 at 09:50:41AM -0500, Steve French wrote:
> On Fri, Sep 29, 2023 at 3:06 AM David Howells via samba-technical
> <samba-technical@lists.samba.org> wrote:
> >
> >
> > Jeff Layton <jlayton@kernel.org> wrote:
> >
> > > Correct. We'd lose some fidelity in currently stored timestamps, but as
> > > Linus and Ted pointed out, anything below ~100ns granularity is
> > > effectively just noise, as that's the floor overhead for calling into
> > > the kernel. It's hard to argue that any application needs that sort of
> > > timestamp resolution, at least with contemporary hardware.
> >
> > Albeit with the danger of making Steve French very happy;-), would it make
> > sense to switch internally to Microsoft-style 64-bit timestamps with their
> > 100ns granularity?
> 
> 100ns granularity does seem to make sense and IIRC was used by various
> DCE standards in the 90s and 2000s (not just used for SMB2/SMB3 protocol and
> various Windows filesystems)

Historically it probably comes from VMS, where system time and file
timestamps were a 64 bit integer counting in 100ns units starting on MJD
2400000.5 (Nov 17th 1858).

Gabriel

> 
> 
> -- 
> Thanks,
> 
> Steve



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

end of thread, other threads:[~2023-10-01  6:21 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-28 11:05 [PATCH 85/87] fs: rename i_atime and i_mtime fields to __i_atime and __i_mtime Jeff Layton
2023-09-28 11:05 ` [PATCH 86/87] fs: switch timespec64 fields in inode to discrete integers Jeff Layton
2023-09-28 15:48   ` Arnd Bergmann
2023-09-28 17:06     ` Jeff Layton
2023-09-28 17:19       ` Darrick J. Wong
2023-09-28 17:40         ` Jeff Layton
2023-09-28 20:21           ` Arnd Bergmann
2023-09-28 21:26           ` Theodore Ts'o
2023-09-29  0:18             ` Linus Torvalds
2023-09-29  3:50               ` Amir Goldstein
2023-09-29 16:22                 ` Linus Torvalds
2023-09-29  3:27         ` Amir Goldstein
2023-09-29  6:32         ` David Howells
2023-09-30 14:50           ` Steve French
2023-10-01  5:01             ` [OT] " Gabriel Paubert
2023-09-29  9:44       ` Christian Brauner
2023-09-29 10:16         ` Jeff Layton
2023-09-28 17:09   ` Jeff Layton
2023-09-28 11:05 ` [PATCH 87/87] fs: move i_blocks up a few places in struct inode Jeff Layton
2023-09-28 11:35   ` Amir Goldstein
2023-09-28 12:01     ` Jeff Layton
2023-09-28 17:41   ` Linus Torvalds
2023-09-28 18:01     ` Jeff Layton
2023-09-29  9:32     ` Christian Brauner

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).