bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/89] fs: new accessor methods for inode atime and mtime
@ 2023-10-04 18:52 Jeff Layton
  2023-10-04 18:52 ` [PATCH v2 01/89] fs: new accessor methods for " Jeff Layton
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jeff Layton @ 2023-10-04 18:52 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,
	Kent Overstreet, Brian Foster
  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, linux-bcachefs

v2:
- bugfix in mtime handling
- incorporate _sec and _nsec accessor functions (Chuck Lever)
- move i_generation to plug hole after changing timestamps (Amir Goldstein)

While working on the multigrain timestamp changes, Linus suggested
adding some similar wrappers for accessing the atime and mtime that we
have for the ctime. With that, we could then move to using discrete
integers instead of struct timespec64 in struct inode and shrink it.

This patch implements this. Linus suggested using macros for the new
accessors, but the existing ctime wrappers were static inlines and since
there are only 3 different timestamps, I didn't see that trying to
fiddle with macros would gain us anything (other than less verbosity in
fs.h).

The second to last patch makes the conversion to discrete integers,
which shaves 8 bytes off of struct inode on my x86_64 kernel. The last
patch reshuffles things a little to keep the i_lock in the same
cacheline as the fields it protects.

About 75% of this conversion was done with coccinelle, with the rest
done by hand.

I think we probably ought to try to get everything but the last two
patches into v6.7 (though we could consider those too if we're feeling
lucky).

Jeff Layton (89):
  fs: new accessor methods for atime and mtime
  fs: convert core infrastructure to new timestamp accessors
  spufs: convert to new timestamp accessors
  hypfs: convert to new timestamp accessors
  android: convert to new timestamp accessors
  char: convert to new timestamp accessors
  qib: convert to new timestamp accessors
  ibmasm: convert to new timestamp accessors
  misc: convert to new timestamp accessors
  x86: convert to new timestamp accessors
  tty: convert to new timestamp accessors
  function: convert to new timestamp accessors
  legacy: convert to new timestamp accessors
  usb: convert to new timestamp accessors
  9p: convert to new timestamp accessors
  adfs: convert to new timestamp accessors
  affs: convert to new timestamp accessors
  afs: convert to new timestamp accessors
  autofs: convert to new timestamp accessors
  bcachefs: convert to new timestamp accessors
  befs: convert to new timestamp accessors
  bfs: convert to new timestamp accessors
  btrfs: convert to new timestamp accessors
  ceph: convert to new timestamp accessors
  coda: convert to new timestamp accessors
  configfs: convert to new timestamp accessors
  cramfs: convert to new timestamp accessors
  debugfs: convert to new timestamp accessors
  devpts: convert to new timestamp accessors
  efivarfs: convert to new timestamp accessors
  efs: convert to new timestamp accessors
  erofs: convert to new timestamp accessors
  exfat: convert to new timestamp accessors
  ext2: convert to new timestamp accessors
  ext4: convert to new timestamp accessors
  f2fs: convert to new timestamp accessors
  fat: convert to new timestamp accessors
  freevxfs: convert to new timestamp accessors
  fuse: convert to new timestamp accessors
  gfs2: convert to new timestamp accessors
  hfs: convert to new timestamp accessors
  hfsplus: convert to new timestamp accessors
  hostfs: convert to new timestamp accessors
  hpfs: convert to new timestamp accessors
  hugetlbfs: convert to new timestamp accessors
  isofs: convert to new timestamp accessors
  jffs2: convert to new timestamp accessors
  jfs: convert to new timestamp accessors
  kernfs: convert to new timestamp accessors
  minix: convert to new timestamp accessors
  nfs: convert to new timestamp accessors
  nfsd: convert to new timestamp accessors
  nilfs2: convert to new timestamp accessors
  ntfs: convert to new timestamp accessors
  ntfs3: convert to new timestamp accessors
  ocfs2: convert to new timestamp accessors
  omfs: convert to new timestamp accessors
  openpromfs: convert to new timestamp accessors
  orangefs: convert to new timestamp accessors
  overlayfs: convert to new timestamp accessors
  proc: convert to new timestamp accessors
  pstore: convert to new timestamp accessors
  qnx4: convert to new timestamp accessors
  qnx6: convert to new timestamp accessors
  ramfs: convert to new timestamp accessors
  reiserfs: convert to new timestamp accessors
  romfs: convert to new timestamp accessors
  client: convert to new timestamp accessors
  server: convert to new timestamp accessors
  squashfs: convert to new timestamp accessors
  sysv: convert to new timestamp accessors
  tracefs: convert to new timestamp accessors
  ubifs: convert to new timestamp accessors
  udf: convert to new timestamp accessors
  ufs: convert to new timestamp accessors
  vboxsf: convert to new timestamp accessors
  xfs: convert to new timestamp accessors
  zonefs: convert to new timestamp accessors
  linux: convert to new timestamp accessors
  ipc: convert to new timestamp accessors
  bpf: convert to new timestamp accessors
  mm: convert to new timestamp accessors
  sunrpc: convert to new timestamp accessors
  apparmor: convert to new timestamp accessors
  selinux: convert to new timestamp accessors
  security: convert to new timestamp accessors
  fs: rename inode i_atime and i_mtime fields
  fs: switch timespec64 fields in inode to discrete integers
  fs: move i_generation into new hole created after timestamp conversion

 arch/powerpc/platforms/cell/spufs/inode.c |   2 +-
 arch/s390/hypfs/inode.c                   |   4 +-
 drivers/android/binderfs.c                |   8 +-
 drivers/char/sonypi.c                     |   2 +-
 drivers/infiniband/hw/qib/qib_fs.c        |   4 +-
 drivers/misc/ibmasm/ibmasmfs.c            |   2 +-
 drivers/misc/ibmvmc.c                     |   2 +-
 drivers/platform/x86/sony-laptop.c        |   2 +-
 drivers/tty/tty_io.c                      |  10 +-
 drivers/usb/core/devio.c                  |  26 +++--
 drivers/usb/gadget/function/f_fs.c        |   4 +-
 drivers/usb/gadget/legacy/inode.c         |   2 +-
 fs/9p/vfs_inode.c                         |   6 +-
 fs/9p/vfs_inode_dotl.c                    |  16 +--
 fs/adfs/inode.c                           |  13 ++-
 fs/affs/amigaffs.c                        |   4 +-
 fs/affs/inode.c                           |  17 ++-
 fs/afs/dynroot.c                          |   2 +-
 fs/afs/inode.c                            |   8 +-
 fs/afs/write.c                            |   2 +-
 fs/attr.c                                 |   4 +-
 fs/autofs/inode.c                         |   2 +-
 fs/autofs/root.c                          |   6 +-
 fs/bad_inode.c                            |   2 +-
 fs/bcachefs/fs.c                          |  12 +--
 fs/befs/linuxvfs.c                        |  10 +-
 fs/bfs/dir.c                              |   9 +-
 fs/bfs/inode.c                            |  12 +--
 fs/binfmt_misc.c                          |   2 +-
 fs/btrfs/delayed-inode.c                  |  20 ++--
 fs/btrfs/file.c                           |  18 ++--
 fs/btrfs/inode.c                          |  43 ++++----
 fs/btrfs/reflink.c                        |   2 +-
 fs/btrfs/transaction.c                    |   3 +-
 fs/btrfs/tree-log.c                       |  12 +--
 fs/ceph/addr.c                            |  10 +-
 fs/ceph/caps.c                            |   4 +-
 fs/ceph/file.c                            |   2 +-
 fs/ceph/inode.c                           |  64 ++++++------
 fs/ceph/mds_client.c                      |   8 +-
 fs/ceph/snap.c                            |   4 +-
 fs/coda/coda_linux.c                      |   6 +-
 fs/coda/dir.c                             |   2 +-
 fs/coda/file.c                            |   2 +-
 fs/configfs/inode.c                       |   8 +-
 fs/cramfs/inode.c                         |   4 +-
 fs/debugfs/inode.c                        |   2 +-
 fs/devpts/inode.c                         |   6 +-
 fs/efivarfs/file.c                        |   2 +-
 fs/efivarfs/inode.c                       |   2 +-
 fs/efs/inode.c                            |   5 +-
 fs/erofs/inode.c                          |   3 +-
 fs/exfat/exfat_fs.h                       |   1 +
 fs/exfat/file.c                           |   7 +-
 fs/exfat/inode.c                          |  31 +++---
 fs/exfat/misc.c                           |   8 ++
 fs/exfat/namei.c                          |  31 +++---
 fs/exfat/super.c                          |   4 +-
 fs/ext2/dir.c                             |   6 +-
 fs/ext2/ialloc.c                          |   2 +-
 fs/ext2/inode.c                           |  13 ++-
 fs/ext2/super.c                           |   2 +-
 fs/ext4/ext4.h                            |  20 +++-
 fs/ext4/extents.c                         |  11 +-
 fs/ext4/ialloc.c                          |   4 +-
 fs/ext4/inline.c                          |   4 +-
 fs/ext4/inode.c                           |  19 ++--
 fs/ext4/ioctl.c                           |  13 ++-
 fs/ext4/namei.c                           |  10 +-
 fs/ext4/super.c                           |   2 +-
 fs/ext4/xattr.c                           |   8 +-
 fs/f2fs/dir.c                             |   6 +-
 fs/f2fs/f2fs.h                            |  10 +-
 fs/f2fs/file.c                            |  14 +--
 fs/f2fs/inline.c                          |   2 +-
 fs/f2fs/inode.c                           |  24 ++---
 fs/f2fs/namei.c                           |   4 +-
 fs/f2fs/recovery.c                        |   8 +-
 fs/f2fs/super.c                           |   2 +-
 fs/fat/inode.c                            |  25 +++--
 fs/fat/misc.c                             |   6 +-
 fs/freevxfs/vxfs_inode.c                  |   6 +-
 fs/fuse/control.c                         |   2 +-
 fs/fuse/dir.c                             |  10 +-
 fs/fuse/inode.c                           |  29 +++---
 fs/fuse/readdir.c                         |   6 +-
 fs/gfs2/bmap.c                            |  10 +-
 fs/gfs2/dir.c                             |  10 +-
 fs/gfs2/glops.c                           |  11 +-
 fs/gfs2/inode.c                           |   7 +-
 fs/gfs2/quota.c                           |   2 +-
 fs/gfs2/super.c                           |  12 +--
 fs/hfs/catalog.c                          |   8 +-
 fs/hfs/inode.c                            |  16 +--
 fs/hfs/sysdep.c                           |  10 +-
 fs/hfsplus/catalog.c                      |   8 +-
 fs/hfsplus/inode.c                        |  22 ++--
 fs/hostfs/hostfs_kern.c                   |  12 ++-
 fs/hpfs/dir.c                             |  12 ++-
 fs/hpfs/inode.c                           |  16 +--
 fs/hpfs/namei.c                           |  22 ++--
 fs/hpfs/super.c                           |  10 +-
 fs/hugetlbfs/inode.c                      |  10 +-
 fs/inode.c                                |  35 ++++---
 fs/isofs/inode.c                          |   4 +-
 fs/isofs/rock.c                           |  18 ++--
 fs/jffs2/dir.c                            |  35 ++++---
 fs/jffs2/file.c                           |   4 +-
 fs/jffs2/fs.c                             |  20 ++--
 fs/jffs2/os-linux.h                       |   4 +-
 fs/jfs/inode.c                            |   2 +-
 fs/jfs/jfs_imap.c                         |  20 ++--
 fs/jfs/jfs_inode.c                        |   4 +-
 fs/jfs/namei.c                            |  20 ++--
 fs/jfs/super.c                            |   2 +-
 fs/kernfs/inode.c                         |   6 +-
 fs/libfs.c                                |  41 ++++++--
 fs/minix/bitmap.c                         |   2 +-
 fs/minix/dir.c                            |   6 +-
 fs/minix/inode.c                          |  17 ++-
 fs/minix/itree_common.c                   |   2 +-
 fs/nfs/callback_proc.c                    |   2 +-
 fs/nfs/fscache.h                          |   4 +-
 fs/nfs/inode.c                            |  30 +++---
 fs/nfsd/blocklayout.c                     |   3 +-
 fs/nfsd/nfs3proc.c                        |   4 +-
 fs/nfsd/nfs4proc.c                        |   8 +-
 fs/nfsd/nfsctl.c                          |   2 +-
 fs/nfsd/vfs.c                             |   2 +-
 fs/nilfs2/dir.c                           |   6 +-
 fs/nilfs2/inode.c                         |  20 ++--
 fs/nsfs.c                                 |   2 +-
 fs/ntfs/inode.c                           |  25 ++---
 fs/ntfs/mft.c                             |   2 +-
 fs/ntfs3/file.c                           |   6 +-
 fs/ntfs3/frecord.c                        |  11 +-
 fs/ntfs3/inode.c                          |  25 +++--
 fs/ntfs3/namei.c                          |   4 +-
 fs/ocfs2/acl.c                            |   4 +-
 fs/ocfs2/alloc.c                          |   6 +-
 fs/ocfs2/aops.c                           |   6 +-
 fs/ocfs2/dir.c                            |   9 +-
 fs/ocfs2/dlmfs/dlmfs.c                    |   4 +-
 fs/ocfs2/dlmglue.c                        |  29 +++---
 fs/ocfs2/file.c                           |  30 +++---
 fs/ocfs2/inode.c                          |  28 ++---
 fs/ocfs2/move_extents.c                   |   4 +-
 fs/ocfs2/namei.c                          |  16 +--
 fs/ocfs2/refcounttree.c                   |  12 +--
 fs/ocfs2/xattr.c                          |   4 +-
 fs/omfs/inode.c                           |  12 +--
 fs/openpromfs/inode.c                     |   4 +-
 fs/orangefs/orangefs-utils.c              |  16 +--
 fs/overlayfs/file.c                       |   9 +-
 fs/overlayfs/inode.c                      |   3 +-
 fs/overlayfs/util.c                       |   4 +-
 fs/pipe.c                                 |   2 +-
 fs/proc/base.c                            |   2 +-
 fs/proc/inode.c                           |   2 +-
 fs/proc/proc_sysctl.c                     |   2 +-
 fs/proc/self.c                            |   2 +-
 fs/proc/thread_self.c                     |   2 +-
 fs/pstore/inode.c                         |   5 +-
 fs/qnx4/inode.c                           |   6 +-
 fs/qnx6/inode.c                           |   6 +-
 fs/ramfs/inode.c                          |   7 +-
 fs/reiserfs/inode.c                       |  26 ++---
 fs/reiserfs/namei.c                       |   8 +-
 fs/reiserfs/stree.c                       |   5 +-
 fs/reiserfs/super.c                       |   2 +-
 fs/romfs/super.c                          |   3 +-
 fs/smb/client/file.c                      |  18 ++--
 fs/smb/client/fscache.h                   |   6 +-
 fs/smb/client/inode.c                     |  17 ++-
 fs/smb/client/smb2ops.c                   |   6 +-
 fs/smb/server/smb2pdu.c                   |   8 +-
 fs/squashfs/inode.c                       |   6 +-
 fs/stack.c                                |   4 +-
 fs/stat.c                                 |   4 +-
 fs/sysv/dir.c                             |   6 +-
 fs/sysv/ialloc.c                          |   2 +-
 fs/sysv/inode.c                           |  12 +--
 fs/sysv/itree.c                           |   2 +-
 fs/tracefs/inode.c                        |   2 +-
 fs/ubifs/debug.c                          |  12 +--
 fs/ubifs/dir.c                            |  23 +++--
 fs/ubifs/file.c                           |  16 +--
 fs/ubifs/journal.c                        |  12 +--
 fs/ubifs/super.c                          |   8 +-
 fs/udf/ialloc.c                           |   4 +-
 fs/udf/inode.c                            |  38 ++++---
 fs/udf/namei.c                            |  16 +--
 fs/ufs/dir.c                              |   6 +-
 fs/ufs/ialloc.c                           |   2 +-
 fs/ufs/inode.c                            |  42 ++++----
 fs/vboxsf/utils.c                         |  15 +--
 fs/xfs/libxfs/xfs_inode_buf.c             |  10 +-
 fs/xfs/libxfs/xfs_rtbitmap.c              |   6 +-
 fs/xfs/libxfs/xfs_trans_inode.c           |   2 +-
 fs/xfs/xfs_bmap_util.c                    |   7 +-
 fs/xfs/xfs_inode.c                        |   4 +-
 fs/xfs/xfs_inode_item.c                   |   4 +-
 fs/xfs/xfs_iops.c                         |   8 +-
 fs/xfs/xfs_itable.c                       |  12 +--
 fs/xfs/xfs_rtalloc.c                      |  30 +++---
 fs/zonefs/super.c                         |  10 +-
 include/linux/fs.h                        | 120 +++++++++++++++++-----
 include/linux/fs_stack.h                  |   6 +-
 ipc/mqueue.c                              |  19 ++--
 kernel/bpf/inode.c                        |   5 +-
 mm/shmem.c                                |  20 ++--
 net/sunrpc/rpc_pipe.c                     |   2 +-
 security/apparmor/apparmorfs.c            |   7 +-
 security/apparmor/policy_unpack.c         |   4 +-
 security/inode.c                          |   2 +-
 security/selinux/selinuxfs.c              |   2 +-
 216 files changed, 1220 insertions(+), 1000 deletions(-)

-- 
2.41.0


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

* [PATCH v2 01/89] fs: new accessor methods for atime and mtime
  2023-10-04 18:52 [PATCH v2 00/89] fs: new accessor methods for inode atime and mtime Jeff Layton
@ 2023-10-04 18:52 ` Jeff Layton
  2023-10-04 18:52   ` [PATCH v2 02/89] fs: convert core infrastructure to new timestamp accessors Jeff Layton
       [not found] ` <20231004185347.80880-1-jlayton@kernel.org>
  2023-10-09 16:09 ` [PATCH v2 00/89] fs: new accessor methods for inode atime and mtime Christian Brauner
  2 siblings, 1 reply; 5+ messages in thread
From: Jeff Layton @ 2023-10-04 18:52 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,
	Kent Overstreet, Brian Foster
  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, linux-bcachefs

Recently, we converted the ctime accesses in the kernel to use new
accessor functions. Linus recently pointed out though that if we add
accessors for the atime and mtime, then that would allow us to
seamlessly change how these timestamps are stored in the inode.

Add new accessor functions for the atime and mtime that mirror the
accessors for the ctime.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/libfs.c         | 41 ++++++++++++++++------
 include/linux/fs.h | 85 +++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 102 insertions(+), 24 deletions(-)

diff --git a/fs/libfs.c b/fs/libfs.c
index 37f2d34ee090..abe2b5a40ba1 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -541,7 +541,8 @@ void simple_recursive_removal(struct dentry *dentry,
 				dput(victim);		// unpin it
 			}
 			if (victim == dentry) {
-				inode->i_mtime = inode_set_ctime_current(inode);
+				inode_set_mtime_to_ts(inode,
+						      inode_set_ctime_current(inode));
 				if (d_is_dir(dentry))
 					drop_nlink(inode);
 				inode_unlock(inode);
@@ -582,7 +583,7 @@ static int pseudo_fs_fill_super(struct super_block *s, struct fs_context *fc)
 	 */
 	root->i_ino = 1;
 	root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR;
-	root->i_atime = root->i_mtime = inode_set_ctime_current(root);
+	simple_inode_init_ts(root);
 	s->s_root = d_make_root(root);
 	if (!s->s_root)
 		return -ENOMEM;
@@ -638,8 +639,8 @@ int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *den
 {
 	struct inode *inode = d_inode(old_dentry);
 
-	dir->i_mtime = inode_set_ctime_to_ts(dir,
-					     inode_set_ctime_current(inode));
+	inode_set_mtime_to_ts(dir,
+			      inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode)));
 	inc_nlink(inode);
 	ihold(inode);
 	dget(dentry);
@@ -673,8 +674,8 @@ int simple_unlink(struct inode *dir, struct dentry *dentry)
 {
 	struct inode *inode = d_inode(dentry);
 
-	dir->i_mtime = inode_set_ctime_to_ts(dir,
-					     inode_set_ctime_current(inode));
+	inode_set_mtime_to_ts(dir,
+			      inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode)));
 	drop_nlink(inode);
 	dput(dentry);
 	return 0;
@@ -709,9 +710,10 @@ void simple_rename_timestamp(struct inode *old_dir, struct dentry *old_dentry,
 {
 	struct inode *newino = d_inode(new_dentry);
 
-	old_dir->i_mtime = inode_set_ctime_current(old_dir);
+	inode_set_mtime_to_ts(old_dir, inode_set_ctime_current(old_dir));
 	if (new_dir != old_dir)
-		new_dir->i_mtime = inode_set_ctime_current(new_dir);
+		inode_set_mtime_to_ts(new_dir,
+				      inode_set_ctime_current(new_dir));
 	inode_set_ctime_current(d_inode(old_dentry));
 	if (newino)
 		inode_set_ctime_current(newino);
@@ -926,7 +928,7 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
 	 */
 	inode->i_ino = 1;
 	inode->i_mode = S_IFDIR | 0755;
-	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+	simple_inode_init_ts(inode);
 	inode->i_op = &simple_dir_inode_operations;
 	inode->i_fop = &simple_dir_operations;
 	set_nlink(inode, 2);
@@ -952,7 +954,7 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
 			goto out;
 		}
 		inode->i_mode = S_IFREG | files->mode;
-		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+		simple_inode_init_ts(inode);
 		inode->i_fop = files->ops;
 		inode->i_ino = i;
 		d_add(dentry, inode);
@@ -1520,7 +1522,7 @@ struct inode *alloc_anon_inode(struct super_block *s)
 	inode->i_uid = current_fsuid();
 	inode->i_gid = current_fsgid();
 	inode->i_flags |= S_PRIVATE;
-	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+	simple_inode_init_ts(inode);
 	return inode;
 }
 EXPORT_SYMBOL(alloc_anon_inode);
@@ -1912,3 +1914,20 @@ ssize_t direct_write_fallback(struct kiocb *iocb, struct iov_iter *iter,
 	return direct_written + buffered_written;
 }
 EXPORT_SYMBOL_GPL(direct_write_fallback);
+
+/**
+ * simple_inode_init_ts - initialize the timestamps for a new inode
+ * @inode: inode to be initialized
+ *
+ * When a new inode is created, most filesystems set the timestamps to the
+ * current time. Add a helper to do this.
+ */
+struct timespec64 simple_inode_init_ts(struct inode *inode)
+{
+	struct timespec64 ts = inode_set_ctime_current(inode);
+
+	inode_set_atime_to_ts(inode, ts);
+	inode_set_mtime_to_ts(inode, ts);
+	return ts;
+}
+EXPORT_SYMBOL(simple_inode_init_ts);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 7b8c6a9d52ec..3ca610d42176 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1515,24 +1515,81 @@ static inline bool fsuidgid_has_mapping(struct super_block *sb,
 struct timespec64 current_time(struct inode *inode);
 struct timespec64 inode_set_ctime_current(struct inode *inode);
 
-/**
- * inode_get_ctime - fetch the current ctime from the inode
- * @inode: inode from which to fetch ctime
- *
- * Grab the current ctime from the inode and return it.
- */
+static inline time64_t inode_get_atime_sec(const struct inode *inode)
+{
+	return inode->i_atime.tv_sec;
+}
+
+static inline long inode_get_atime_nsec(const struct inode *inode)
+{
+	return inode->i_atime.tv_nsec;
+}
+
+static inline struct timespec64 inode_get_atime(const struct inode *inode)
+{
+	return inode->i_atime;
+}
+
+static inline struct timespec64 inode_set_atime_to_ts(struct inode *inode,
+						      struct timespec64 ts)
+{
+	inode->i_atime = ts;
+	return ts;
+}
+
+static inline struct timespec64 inode_set_atime(struct inode *inode,
+						time64_t sec, long nsec)
+{
+	struct timespec64 ts = { .tv_sec  = sec,
+				 .tv_nsec = nsec };
+	return inode_set_atime_to_ts(inode, ts);
+}
+
+static inline time64_t inode_get_mtime_sec(const struct inode *inode)
+{
+	return inode->i_mtime.tv_sec;
+}
+
+static inline long inode_get_mtime_nsec(const struct inode *inode)
+{
+	return inode->i_mtime.tv_nsec;
+}
+
+static inline struct timespec64 inode_get_mtime(const struct inode *inode)
+{
+	return inode->i_mtime;
+}
+
+static inline struct timespec64 inode_set_mtime_to_ts(struct inode *inode,
+						      struct timespec64 ts)
+{
+	inode->i_mtime = ts;
+	return ts;
+}
+
+static inline struct timespec64 inode_set_mtime(struct inode *inode,
+						time64_t sec, long nsec)
+{
+	struct timespec64 ts = { .tv_sec  = sec,
+				 .tv_nsec = nsec };
+	return inode_set_mtime_to_ts(inode, ts);
+}
+
+static inline time64_t inode_get_ctime_sec(const struct inode *inode)
+{
+	return inode->__i_ctime.tv_sec;
+}
+
+static inline long inode_get_ctime_nsec(const struct inode *inode)
+{
+	return inode->__i_ctime.tv_nsec;
+}
+
 static inline struct timespec64 inode_get_ctime(const struct inode *inode)
 {
 	return inode->__i_ctime;
 }
 
-/**
- * inode_set_ctime_to_ts - set the ctime in the inode
- * @inode: inode in which to set the ctime
- * @ts: value to set in the ctime field
- *
- * Set the ctime in @inode to @ts
- */
 static inline struct timespec64 inode_set_ctime_to_ts(struct inode *inode,
 						      struct timespec64 ts)
 {
@@ -1557,6 +1614,8 @@ static inline struct timespec64 inode_set_ctime(struct inode *inode,
 	return inode_set_ctime_to_ts(inode, ts);
 }
 
+struct timespec64 simple_inode_init_ts(struct inode *inode);
+
 /*
  * Snapshotting support.
  */
-- 
2.41.0


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

* [PATCH v2 02/89] fs: convert core infrastructure to new timestamp accessors
  2023-10-04 18:52 ` [PATCH v2 01/89] fs: new accessor methods for " Jeff Layton
@ 2023-10-04 18:52   ` Jeff Layton
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff Layton @ 2023-10-04 18:52 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,
	Kent Overstreet, Brian Foster
  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, linux-bcachefs

Convert the core vfs code to use the new timestamp accessor functions.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/attr.c        |  4 ++--
 fs/bad_inode.c   |  2 +-
 fs/binfmt_misc.c |  2 +-
 fs/inode.c       | 35 +++++++++++++++++++++--------------
 fs/nsfs.c        |  2 +-
 fs/pipe.c        |  2 +-
 fs/stack.c       |  4 ++--
 fs/stat.c        |  4 ++--
 8 files changed, 31 insertions(+), 24 deletions(-)

diff --git a/fs/attr.c b/fs/attr.c
index a8ae5f6d9b16..bdf5deb06ea9 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -308,9 +308,9 @@ void setattr_copy(struct mnt_idmap *idmap, struct inode *inode,
 	i_uid_update(idmap, attr, inode);
 	i_gid_update(idmap, attr, inode);
 	if (ia_valid & ATTR_ATIME)
-		inode->i_atime = attr->ia_atime;
+		inode_set_atime_to_ts(inode, attr->ia_atime);
 	if (ia_valid & ATTR_MTIME)
-		inode->i_mtime = attr->ia_mtime;
+		inode_set_mtime_to_ts(inode, attr->ia_mtime);
 	if (ia_valid & ATTR_CTIME)
 		inode_set_ctime_to_ts(inode, attr->ia_ctime);
 	if (ia_valid & ATTR_MODE) {
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 83f9566c973b..316d88da2ce1 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -208,7 +208,7 @@ void make_bad_inode(struct inode *inode)
 	remove_inode_hash(inode);
 
 	inode->i_mode = S_IFREG;
-	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+	simple_inode_init_ts(inode);
 	inode->i_op = &bad_inode_ops;	
 	inode->i_opflags &= ~IOP_XATTR;
 	inode->i_fop = &bad_file_ops;	
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index e0108d17b085..5d2be9b0a0a5 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -547,7 +547,7 @@ static struct inode *bm_get_inode(struct super_block *sb, int mode)
 	if (inode) {
 		inode->i_ino = get_next_ino();
 		inode->i_mode = mode;
-		inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+		simple_inode_init_ts(inode);
 	}
 	return inode;
 }
diff --git a/fs/inode.c b/fs/inode.c
index 3bb6193f436c..4f8984b97df0 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1837,27 +1837,29 @@ EXPORT_SYMBOL(bmap);
 static int relatime_need_update(struct vfsmount *mnt, struct inode *inode,
 			     struct timespec64 now)
 {
-	struct timespec64 ctime;
+	struct timespec64 atime, mtime, ctime;
 
 	if (!(mnt->mnt_flags & MNT_RELATIME))
 		return 1;
 	/*
 	 * Is mtime younger than or equal to atime? If yes, update atime:
 	 */
-	if (timespec64_compare(&inode->i_mtime, &inode->i_atime) >= 0)
+	atime = inode_get_atime(inode);
+	mtime = inode_get_mtime(inode);
+	if (timespec64_compare(&mtime, &atime) >= 0)
 		return 1;
 	/*
 	 * Is ctime younger than or equal to atime? If yes, update atime:
 	 */
 	ctime = inode_get_ctime(inode);
-	if (timespec64_compare(&ctime, &inode->i_atime) >= 0)
+	if (timespec64_compare(&ctime, &atime) >= 0)
 		return 1;
 
 	/*
 	 * Is the previous atime value older than a day? If yes,
 	 * update atime:
 	 */
-	if ((long)(now.tv_sec - inode->i_atime.tv_sec) >= 24*60*60)
+	if ((long)(now.tv_sec - atime.tv_sec) >= 24*60*60)
 		return 1;
 	/*
 	 * Good, we can skip the atime update:
@@ -1888,12 +1890,13 @@ int inode_update_timestamps(struct inode *inode, int flags)
 
 	if (flags & (S_MTIME|S_CTIME|S_VERSION)) {
 		struct timespec64 ctime = inode_get_ctime(inode);
+		struct timespec64 mtime = inode_get_mtime(inode);
 
 		now = inode_set_ctime_current(inode);
 		if (!timespec64_equal(&now, &ctime))
 			updated |= S_CTIME;
-		if (!timespec64_equal(&now, &inode->i_mtime)) {
-			inode->i_mtime = now;
+		if (!timespec64_equal(&now, &mtime)) {
+			inode_set_mtime_to_ts(inode, now);
 			updated |= S_MTIME;
 		}
 		if (IS_I_VERSION(inode) && inode_maybe_inc_iversion(inode, updated))
@@ -1903,8 +1906,10 @@ int inode_update_timestamps(struct inode *inode, int flags)
 	}
 
 	if (flags & S_ATIME) {
-		if (!timespec64_equal(&now, &inode->i_atime)) {
-			inode->i_atime = now;
+		struct timespec64 atime = inode_get_atime(inode);
+
+		if (!timespec64_equal(&now, &atime)) {
+			inode_set_atime_to_ts(inode, now);
 			updated |= S_ATIME;
 		}
 	}
@@ -1963,7 +1968,7 @@ EXPORT_SYMBOL(inode_update_time);
 bool atime_needs_update(const struct path *path, struct inode *inode)
 {
 	struct vfsmount *mnt = path->mnt;
-	struct timespec64 now;
+	struct timespec64 now, atime;
 
 	if (inode->i_flags & S_NOATIME)
 		return false;
@@ -1989,7 +1994,8 @@ bool atime_needs_update(const struct path *path, struct inode *inode)
 	if (!relatime_need_update(mnt, inode, now))
 		return false;
 
-	if (timespec64_equal(&inode->i_atime, &now))
+	atime = inode_get_atime(inode);
+	if (timespec64_equal(&atime, &now))
 		return false;
 
 	return true;
@@ -2106,17 +2112,18 @@ static int inode_needs_update_time(struct inode *inode)
 {
 	int sync_it = 0;
 	struct timespec64 now = current_time(inode);
-	struct timespec64 ctime;
+	struct timespec64 ts;
 
 	/* First try to exhaust all avenues to not sync */
 	if (IS_NOCMTIME(inode))
 		return 0;
 
-	if (!timespec64_equal(&inode->i_mtime, &now))
+	ts = inode_get_mtime(inode);
+	if (!timespec64_equal(&ts, &now))
 		sync_it = S_MTIME;
 
-	ctime = inode_get_ctime(inode);
-	if (!timespec64_equal(&ctime, &now))
+	ts = inode_get_ctime(inode);
+	if (!timespec64_equal(&ts, &now))
 		sync_it |= S_CTIME;
 
 	if (IS_I_VERSION(inode) && inode_iversion_need_inc(inode))
diff --git a/fs/nsfs.c b/fs/nsfs.c
index 647a22433bd8..9a4b228d42fa 100644
--- a/fs/nsfs.c
+++ b/fs/nsfs.c
@@ -84,7 +84,7 @@ static int __ns_get_path(struct path *path, struct ns_common *ns)
 		return -ENOMEM;
 	}
 	inode->i_ino = ns->inum;
-	inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
+	simple_inode_init_ts(inode);
 	inode->i_flags |= S_IMMUTABLE;
 	inode->i_mode = S_IFREG | S_IRUGO;
 	inode->i_fop = &ns_file_operations;
diff --git a/fs/pipe.c b/fs/pipe.c
index 485e3be8903c..8916c455a469 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -908,7 +908,7 @@ static struct inode * get_pipe_inode(void)
 	inode->i_mode = S_IFIFO | S_IRUSR | S_IWUSR;
 	inode->i_uid = current_fsuid();
 	inode->i_gid = current_fsgid();
-	inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
+	simple_inode_init_ts(inode);
 
 	return inode;
 
diff --git a/fs/stack.c b/fs/stack.c
index b5e01bdb5f5f..f18920119944 100644
--- a/fs/stack.c
+++ b/fs/stack.c
@@ -66,8 +66,8 @@ void fsstack_copy_attr_all(struct inode *dest, const struct inode *src)
 	dest->i_uid = src->i_uid;
 	dest->i_gid = src->i_gid;
 	dest->i_rdev = src->i_rdev;
-	dest->i_atime = src->i_atime;
-	dest->i_mtime = src->i_mtime;
+	inode_set_atime_to_ts(dest, inode_get_atime(src));
+	inode_set_mtime_to_ts(dest, inode_get_mtime(src));
 	inode_set_ctime_to_ts(dest, inode_get_ctime(src));
 	dest->i_blkbits = src->i_blkbits;
 	dest->i_flags = src->i_flags;
diff --git a/fs/stat.c b/fs/stat.c
index d43a5cc1bfa4..24bb0209e459 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -57,8 +57,8 @@ void generic_fillattr(struct mnt_idmap *idmap, u32 request_mask,
 	stat->gid = vfsgid_into_kgid(vfsgid);
 	stat->rdev = inode->i_rdev;
 	stat->size = i_size_read(inode);
-	stat->atime = inode->i_atime;
-	stat->mtime = inode->i_mtime;
+	stat->atime = inode_get_atime(inode);
+	stat->mtime = inode_get_mtime(inode);
 	stat->ctime = inode_get_ctime(inode);
 	stat->blksize = i_blocksize(inode);
 	stat->blocks = inode->i_blocks;
-- 
2.41.0


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

* [PATCH v2 81/89] bpf: convert to new timestamp accessors
       [not found] ` <20231004185347.80880-1-jlayton@kernel.org>
@ 2023-10-04 18:53   ` Jeff Layton
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff Layton @ 2023-10-04 18:53 UTC (permalink / raw)
  To: Alexander Viro, Christian Brauner, linux-fsdevel, linux-kernel
  Cc: Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, bpf

Convert to using the new inode timestamp accessor functions.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 kernel/bpf/inode.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index 99d0625b6c82..1aafb2ff2e95 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -118,8 +118,7 @@ static struct inode *bpf_get_inode(struct super_block *sb,
 		return ERR_PTR(-ENOSPC);
 
 	inode->i_ino = get_next_ino();
-	inode->i_atime = inode_set_ctime_current(inode);
-	inode->i_mtime = inode->i_atime;
+	simple_inode_init_ts(inode);
 
 	inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
 
@@ -147,7 +146,7 @@ static void bpf_dentry_finalize(struct dentry *dentry, struct inode *inode,
 	d_instantiate(dentry, inode);
 	dget(dentry);
 
-	dir->i_mtime = inode_set_ctime_current(dir);
+	inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
 }
 
 static int bpf_mkdir(struct mnt_idmap *idmap, struct inode *dir,
-- 
2.41.0


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

* Re: [PATCH v2 00/89] fs: new accessor methods for inode atime and mtime
  2023-10-04 18:52 [PATCH v2 00/89] fs: new accessor methods for inode atime and mtime Jeff Layton
  2023-10-04 18:52 ` [PATCH v2 01/89] fs: new accessor methods for " Jeff Layton
       [not found] ` <20231004185347.80880-1-jlayton@kernel.org>
@ 2023-10-09 16:09 ` Christian Brauner
  2 siblings, 0 replies; 5+ messages in thread
From: Christian Brauner @ 2023-10-09 16:09 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Christian Brauner, Alexander Viro, 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, 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.jarvinen, 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,
	Kent Overstreet, Brian Foster, 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, linux-bcachefs

On Wed, Oct 04, 2023 at 02:52:21PM -0400, Jeff Layton wrote:
> v2:
> - bugfix in mtime handling
> - incorporate _sec and _nsec accessor functions (Chuck Lever)
> - move i_generation to plug hole after changing timestamps (Amir Goldstein)
> 
> While working on the multigrain timestamp changes, Linus suggested
> adding some similar wrappers for accessing the atime and mtime that we
> have for the ctime. With that, we could then move to using discrete
> integers instead of struct timespec64 in struct inode and shrink it.
> 
> This patch implements this. Linus suggested using macros for the new
> accessors, but the existing ctime wrappers were static inlines and since
> there are only 3 different timestamps, I didn't see that trying to
> fiddle with macros would gain us anything (other than less verbosity in
> fs.h).
> 
> [...]

This was applied on top of -next but vfs.ctime is now based on v6.6-rc3
as stable tag otherwise this is too much of a moving target with other
stuff in -next. Anything that had to be dropped and requires fixups
should just be explained in the pr. The sooner this sees some -next, the
better, I think.

---

Applied to the vfs.ctime branch of the vfs/vfs.git tree.
Patches in the vfs.ctime branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.ctime

[01/86] fs: new accessor methods for atime and mtime
        https://git.kernel.org/vfs/vfs/c/22f45fee808d
[02/86] fs: convert core infrastructure to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/6ac95fb71485
[03/86] spufs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/9953073d5f20
[04/86] hypfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/1d64bfe22112
[05/86] android: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/a8a74b6b4f2c
[06/86] char: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/671ffa0775a7
[07/86] qib: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/ebd5458f3b52
[08/86] ibmasm: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/1d4257d57a41
[09/86] misc: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/d4bf8378b9cb
[10/86] x86: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/070601b1e496
[11/86] tty: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/5c9f26b87bed
[12/86] function: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/092f46404245
[13/86] legacy: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/5c51d80e51d0
[14/86] usb: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/4707a33afd6f
[15/86] 9p: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/20fc454b4493
[16/86] adfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/3e8d59046f6d
[17/86] affs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/60d4d0d37086
[18/86] afs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/6471772aa6fe
[19/86] autofs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/3eaad981548b
[20/86] befs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/21d0433caf69
[21/86] bfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/06e502c123a6
[22/86] btrfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/f62049d7838d
[23/86] ceph: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/ac7750d84e38
[24/86] coda: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/5c4bf2507baa
[25/86] configfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/3b930e187f16
[26/86] cramfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/bb0bf9d3bda8
[27/86] debugfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/7dc950e659d6
[28/86] devpts: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/a1eb5c26d5a1
[29/86] efivarfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/17b5652aa824
[30/86] efs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/a3cfbea29e7d
[31/86] erofs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/2beccde96d66
[32/86] exfat: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/522f3c42c9e7
[33/86] ext2: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/07be81fce412
[34/86] ext4: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/2ff285d78c4d
[35/86] f2fs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/c495130561ae
[36/86] fat: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/e57260ae3226
[37/86] freevxfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/a83513cd029e
[38/86] fuse: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/5f1e57582b4e
[39/86] gfs2: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/a5f1a9296668
[40/86] hfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/7ee8d53576e9
[41/86] hfsplus: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/2179ad3569f6
[42/86] hostfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/c3e1be490207
[43/86] hpfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/e08a2ea26b41
[44/86] hugetlbfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/a9701db0ca64
[45/86] isofs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/362d327da07e
[46/86] jffs2: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/36a8a5a63218
[47/86] jfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/acd529413de5
[48/86] kernfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/05acde68936b
[49/86] minix: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/34c1ca111ec1
[50/86] nfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/77e808456854
[51/86] nfsd: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/a800ed7ebbbf
[52/86] nilfs2: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/4ddc9518c2fa
[53/86] ntfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/0d15c2118b1a
[54/86] ntfs3: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/82f8d5fde753
[55/86] ocfs2: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/45251ebaca70
[56/86] omfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/e7c1ff814326
[57/86] openpromfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/cb62db1d3c61
[58/86] orangefs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/68e257a49aed
[59/86] overlayfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/d482d98dc1bd
[60/86] proc: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/8c8afe8a25fa
[61/86] pstore: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/b0be548328a2
[62/86] qnx4: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/c28589f2d838
[63/86] qnx6: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/ae0f3d29e728
[64/86] ramfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/6315fd97a8fc
[65/86] reiserfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/8eceb9b75a5b
[66/86] romfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/6d3dd456da31
[67/86] client: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/b14d4c14f51b
[68/86] server: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/bec3d7ffcecd
[69/86] squashfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/d7d5ff75af52
[70/86] sysv: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/39f012d8743e
[71/86] tracefs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/22ada3856de8
[72/86] ubifs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/af8b66e1d4b7
[73/86] udf: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/1da45142f95a
[74/86] ufs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/41c46d3bb9b3
[75/86] vboxsf: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/cc36ec7935eb
[76/86] xfs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/ee3be90b2ba7
[77/86] zonefs: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/8c798cc16b17
[78/86] linux: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/dd53b64b6f51
[79/86] ipc: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/f132b3723b71
[80/86] bpf: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/448a018f67a3
[81/86] mm: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/b6f5b3d5ffc9
[82/86] sunrpc: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/fc9db028b8d7
[83/86] apparmor: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/794ef2a745ec
[84/86] selinux: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/3d57ee3686d7
[85/86] security: convert to new timestamp accessors
        https://git.kernel.org/vfs/vfs/c/71f6d9ebaf43
[86/86] fs: rename inode i_atime and i_mtime fields
        https://git.kernel.org/vfs/vfs/c/fea0e8fc7829

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

end of thread, other threads:[~2023-10-09 16:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-04 18:52 [PATCH v2 00/89] fs: new accessor methods for inode atime and mtime Jeff Layton
2023-10-04 18:52 ` [PATCH v2 01/89] fs: new accessor methods for " Jeff Layton
2023-10-04 18:52   ` [PATCH v2 02/89] fs: convert core infrastructure to new timestamp accessors Jeff Layton
     [not found] ` <20231004185347.80880-1-jlayton@kernel.org>
2023-10-04 18:53   ` [PATCH v2 81/89] bpf: convert " Jeff Layton
2023-10-09 16:09 ` [PATCH v2 00/89] fs: new accessor methods for inode atime and mtime 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).