Skip to content

Commit

Permalink
Merge tag 'vfs-6.7.ctime' of gitolite.kernel.org:pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/vfs/vfs

Pull vfs inode time accessor updates from Christian Brauner:
 "This finishes the conversion of all inode time fields to accessor
  functions as discussed on list. Changing timestamps manually as we
  used to do before is error prone. Using accessors function makes this
  robust.

  It does not contain the switch of the time fields to discrete 64 bit
  integers to replace struct timespec and free up space in struct inode.
  But after this, the switch can be trivially made and the patch should
  only affect the vfs if we decide to do it"

* tag 'vfs-6.7.ctime' of gitolite.kernel.org:pub/scm/linux/kernel/git/vfs/vfs: (86 commits)
  fs: rename inode i_atime and i_mtime fields
  security: convert to new timestamp accessors
  selinux: convert to new timestamp accessors
  apparmor: convert to new timestamp accessors
  sunrpc: convert to new timestamp accessors
  mm: convert to new timestamp accessors
  bpf: convert to new timestamp accessors
  ipc: convert to new timestamp accessors
  linux: convert to new timestamp accessors
  zonefs: convert to new timestamp accessors
  xfs: convert to new timestamp accessors
  vboxsf: convert to new timestamp accessors
  ufs: convert to new timestamp accessors
  udf: convert to new timestamp accessors
  ubifs: convert to new timestamp accessors
  tracefs: convert to new timestamp accessors
  sysv: convert to new timestamp accessors
  squashfs: convert to new timestamp accessors
  server: convert to new timestamp accessors
  client: convert to new timestamp accessors
  ...
  • Loading branch information
torvalds committed Oct 30, 2023
2 parents 7352a67 + 12cd440 commit 14ab6d4
Show file tree
Hide file tree
Showing 215 changed files with 1,194 additions and 983 deletions.
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/cell/spufs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ spufs_new_inode(struct super_block *sb, umode_t mode)
inode->i_mode = mode;
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);
out:
return inode;
}
Expand Down
4 changes: 2 additions & 2 deletions arch/s390/hypfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static void hypfs_update_update(struct super_block *sb)
struct inode *inode = d_inode(sb_info->update_file);

sb_info->last_update = ktime_get_seconds();
inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
simple_inode_init_ts(inode);
}

/* directory tree removal functions */
Expand Down Expand Up @@ -101,7 +101,7 @@ static struct inode *hypfs_make_inode(struct super_block *sb, umode_t mode)
ret->i_mode = mode;
ret->i_uid = hypfs_info->uid;
ret->i_gid = hypfs_info->gid;
ret->i_atime = ret->i_mtime = inode_set_ctime_current(ret);
simple_inode_init_ts(ret);
if (S_ISDIR(mode))
set_nlink(ret, 2);
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/android/binderfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static int binderfs_binder_device_create(struct inode *ref_inode,
goto err;

inode->i_ino = minor + INODE_OFFSET;
inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
simple_inode_init_ts(inode);
init_special_inode(inode, S_IFCHR | 0600,
MKDEV(MAJOR(binderfs_dev), minor));
inode->i_fop = &binder_fops;
Expand Down Expand Up @@ -431,7 +431,7 @@ static int binderfs_binder_ctl_create(struct super_block *sb)
}

inode->i_ino = SECOND_INODE;
inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
simple_inode_init_ts(inode);
init_special_inode(inode, S_IFCHR | 0600,
MKDEV(MAJOR(binderfs_dev), minor));
inode->i_fop = &binder_ctl_fops;
Expand Down Expand Up @@ -473,7 +473,7 @@ static struct inode *binderfs_make_inode(struct super_block *sb, int mode)
if (ret) {
ret->i_ino = iunique(sb, BINDERFS_MAX_MINOR + INODE_OFFSET);
ret->i_mode = mode;
ret->i_atime = ret->i_mtime = inode_set_ctime_current(ret);
simple_inode_init_ts(ret);
}
return ret;
}
Expand Down Expand Up @@ -702,7 +702,7 @@ static int binderfs_fill_super(struct super_block *sb, struct fs_context *fc)
inode->i_ino = FIRST_INODE;
inode->i_fop = &simple_dir_operations;
inode->i_mode = S_IFDIR | 0755;
inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
simple_inode_init_ts(inode);
inode->i_op = &binderfs_dir_inode_operations;
set_nlink(inode, 2);

Expand Down
2 changes: 1 addition & 1 deletion drivers/char/sonypi.c
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,

if (ret > 0) {
struct inode *inode = file_inode(file);
inode->i_atime = current_time(inode);
inode_set_atime_to_ts(inode, current_time(inode));
}

return ret;
Expand Down
4 changes: 2 additions & 2 deletions drivers/infiniband/hw/qib/qib_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ static int qibfs_mknod(struct inode *dir, struct dentry *dentry,
inode->i_uid = GLOBAL_ROOT_UID;
inode->i_gid = GLOBAL_ROOT_GID;
inode->i_blocks = 0;
inode->i_atime = inode_set_ctime_current(inode);
inode->i_mtime = inode->i_atime;
simple_inode_init_ts(inode);

inode->i_private = data;
if (S_ISDIR(mode)) {
inode->i_op = &simple_dir_inode_operations;
Expand Down
2 changes: 1 addition & 1 deletion drivers/misc/ibmasm/ibmasmfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode)
if (ret) {
ret->i_ino = get_next_ino();
ret->i_mode = mode;
ret->i_atime = ret->i_mtime = inode_set_ctime_current(ret);
simple_inode_init_ts(ret);
}
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/misc/ibmvmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ static ssize_t ibmvmc_write(struct file *file, const char *buffer,
goto out;

inode = file_inode(file);
inode->i_mtime = inode_set_ctime_current(inode);
inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
mark_inode_dirty(inode);

dev_dbg(adapter->dev, "write: file = 0x%lx, count = 0x%lx\n",
Expand Down
2 changes: 1 addition & 1 deletion drivers/platform/x86/sony-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -4092,7 +4092,7 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,

if (ret > 0) {
struct inode *inode = file_inode(file);
inode->i_atime = current_time(inode);
inode_set_atime_to_ts(inode, current_time(inode));
}

return ret;
Expand Down
10 changes: 7 additions & 3 deletions drivers/tty/tty_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -818,16 +818,20 @@ static void tty_update_time(struct tty_struct *tty, bool mtime)
spin_lock(&tty->files_lock);
list_for_each_entry(priv, &tty->tty_files, list) {
struct inode *inode = file_inode(priv->file);
struct timespec64 *time = mtime ? &inode->i_mtime : &inode->i_atime;
struct timespec64 time = mtime ? inode_get_mtime(inode) : inode_get_atime(inode);

/*
* We only care if the two values differ in anything other than the
* lower three bits (i.e every 8 seconds). If so, then we can update
* the time of the tty device, otherwise it could be construded as a
* security leak to let userspace know the exact timing of the tty.
*/
if ((sec ^ time->tv_sec) & ~7)
time->tv_sec = sec;
if ((sec ^ time.tv_sec) & ~7) {
if (mtime)
inode_set_mtime(inode, sec, 0);
else
inode_set_atime(inode, sec, 0);
}
}
spin_unlock(&tty->files_lock);
}
Expand Down
26 changes: 17 additions & 9 deletions drivers/usb/core/devio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2642,21 +2642,24 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
snoop(&dev->dev, "%s: CONTROL\n", __func__);
ret = proc_control(ps, p);
if (ret >= 0)
inode->i_mtime = inode_set_ctime_current(inode);
inode_set_mtime_to_ts(inode,
inode_set_ctime_current(inode));
break;

case USBDEVFS_BULK:
snoop(&dev->dev, "%s: BULK\n", __func__);
ret = proc_bulk(ps, p);
if (ret >= 0)
inode->i_mtime = inode_set_ctime_current(inode);
inode_set_mtime_to_ts(inode,
inode_set_ctime_current(inode));
break;

case USBDEVFS_RESETEP:
snoop(&dev->dev, "%s: RESETEP\n", __func__);
ret = proc_resetep(ps, p);
if (ret >= 0)
inode->i_mtime = inode_set_ctime_current(inode);
inode_set_mtime_to_ts(inode,
inode_set_ctime_current(inode));
break;

case USBDEVFS_RESET:
Expand All @@ -2668,7 +2671,8 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
snoop(&dev->dev, "%s: CLEAR_HALT\n", __func__);
ret = proc_clearhalt(ps, p);
if (ret >= 0)
inode->i_mtime = inode_set_ctime_current(inode);
inode_set_mtime_to_ts(inode,
inode_set_ctime_current(inode));
break;

case USBDEVFS_GETDRIVER:
Expand All @@ -2695,22 +2699,25 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
snoop(&dev->dev, "%s: SUBMITURB\n", __func__);
ret = proc_submiturb(ps, p);
if (ret >= 0)
inode->i_mtime = inode_set_ctime_current(inode);
inode_set_mtime_to_ts(inode,
inode_set_ctime_current(inode));
break;

#ifdef CONFIG_COMPAT
case USBDEVFS_CONTROL32:
snoop(&dev->dev, "%s: CONTROL32\n", __func__);
ret = proc_control_compat(ps, p);
if (ret >= 0)
inode->i_mtime = inode_set_ctime_current(inode);
inode_set_mtime_to_ts(inode,
inode_set_ctime_current(inode));
break;

case USBDEVFS_BULK32:
snoop(&dev->dev, "%s: BULK32\n", __func__);
ret = proc_bulk_compat(ps, p);
if (ret >= 0)
inode->i_mtime = inode_set_ctime_current(inode);
inode_set_mtime_to_ts(inode,
inode_set_ctime_current(inode));
break;

case USBDEVFS_DISCSIGNAL32:
Expand All @@ -2722,7 +2729,8 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
snoop(&dev->dev, "%s: SUBMITURB32\n", __func__);
ret = proc_submiturb_compat(ps, p);
if (ret >= 0)
inode->i_mtime = inode_set_ctime_current(inode);
inode_set_mtime_to_ts(inode,
inode_set_ctime_current(inode));
break;

case USBDEVFS_IOCTL32:
Expand Down Expand Up @@ -2804,7 +2812,7 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
done:
usb_unlock_device(dev);
if (ret >= 0)
inode->i_atime = current_time(inode);
inode_set_atime_to_ts(inode, current_time(inode));
return ret;
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/usb/gadget/function/f_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1383,8 +1383,8 @@ ffs_sb_make_inode(struct super_block *sb, void *data,
inode->i_mode = perms->mode;
inode->i_uid = perms->uid;
inode->i_gid = perms->gid;
inode->i_atime = ts;
inode->i_mtime = ts;
inode_set_atime_to_ts(inode, ts);
inode_set_mtime_to_ts(inode, ts);
inode->i_private = data;
if (fops)
inode->i_fop = fops;
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/legacy/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,7 @@ gadgetfs_make_inode (struct super_block *sb,
inode->i_mode = mode;
inode->i_uid = make_kuid(&init_user_ns, default_uid);
inode->i_gid = make_kgid(&init_user_ns, default_gid);
inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
simple_inode_init_ts(inode);
inode->i_private = data;
inode->i_fop = fops;
}
Expand Down
6 changes: 3 additions & 3 deletions fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ int v9fs_init_inode(struct v9fs_session_info *v9ses,
inode_init_owner(&nop_mnt_idmap, inode, NULL, mode);
inode->i_blocks = 0;
inode->i_rdev = rdev;
inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode);
simple_inode_init_ts(inode);
inode->i_mapping->a_ops = &v9fs_addr_operations;
inode->i_private = NULL;

Expand Down Expand Up @@ -1150,8 +1150,8 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,

set_nlink(inode, 1);

inode->i_atime.tv_sec = stat->atime;
inode->i_mtime.tv_sec = stat->mtime;
inode_set_atime(inode, stat->atime, 0);
inode_set_mtime(inode, stat->mtime, 0);
inode_set_ctime(inode, stat->mtime, 0);

inode->i_uid = v9ses->dfltuid;
Expand Down
16 changes: 8 additions & 8 deletions fs/9p/vfs_inode_dotl.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,10 +641,10 @@ v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode,
struct v9fs_inode *v9inode = V9FS_I(inode);

if ((stat->st_result_mask & P9_STATS_BASIC) == P9_STATS_BASIC) {
inode->i_atime.tv_sec = stat->st_atime_sec;
inode->i_atime.tv_nsec = stat->st_atime_nsec;
inode->i_mtime.tv_sec = stat->st_mtime_sec;
inode->i_mtime.tv_nsec = stat->st_mtime_nsec;
inode_set_atime(inode, stat->st_atime_sec,
stat->st_atime_nsec);
inode_set_mtime(inode, stat->st_mtime_sec,
stat->st_mtime_nsec);
inode_set_ctime(inode, stat->st_ctime_sec,
stat->st_ctime_nsec);
inode->i_uid = stat->st_uid;
Expand All @@ -660,12 +660,12 @@ v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode,
inode->i_blocks = stat->st_blocks;
} else {
if (stat->st_result_mask & P9_STATS_ATIME) {
inode->i_atime.tv_sec = stat->st_atime_sec;
inode->i_atime.tv_nsec = stat->st_atime_nsec;
inode_set_atime(inode, stat->st_atime_sec,
stat->st_atime_nsec);
}
if (stat->st_result_mask & P9_STATS_MTIME) {
inode->i_mtime.tv_sec = stat->st_mtime_sec;
inode->i_mtime.tv_nsec = stat->st_mtime_nsec;
inode_set_mtime(inode, stat->st_mtime_sec,
stat->st_mtime_nsec);
}
if (stat->st_result_mask & P9_STATS_CTIME) {
inode_set_ctime(inode, stat->st_ctime_sec,
Expand Down
13 changes: 8 additions & 5 deletions fs/adfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ struct inode *
adfs_iget(struct super_block *sb, struct object_info *obj)
{
struct inode *inode;
struct timespec64 ts;

inode = new_inode(sb);
if (!inode)
Expand All @@ -268,9 +269,10 @@ adfs_iget(struct super_block *sb, struct object_info *obj)
ADFS_I(inode)->attr = obj->attr;

inode->i_mode = adfs_atts2mode(sb, inode);
adfs_adfs2unix_time(&inode->i_mtime, inode);
inode->i_atime = inode->i_mtime;
inode_set_ctime_to_ts(inode, inode->i_mtime);
adfs_adfs2unix_time(&ts, inode);
inode_set_atime_to_ts(inode, ts);
inode_set_mtime_to_ts(inode, ts);
inode_set_ctime_to_ts(inode, ts);

if (S_ISDIR(inode->i_mode)) {
inode->i_op = &adfs_dir_inode_operations;
Expand Down Expand Up @@ -321,15 +323,16 @@ adfs_notify_change(struct mnt_idmap *idmap, struct dentry *dentry,

if (ia_valid & ATTR_MTIME && adfs_inode_is_stamped(inode)) {
adfs_unix2adfs_time(inode, &attr->ia_mtime);
adfs_adfs2unix_time(&inode->i_mtime, inode);
adfs_adfs2unix_time(&attr->ia_mtime, inode);
inode_set_mtime_to_ts(inode, attr->ia_mtime);
}

/*
* FIXME: should we make these == to i_mtime since we don't
* have the ability to represent them in our filesystem?
*/
if (ia_valid & ATTR_ATIME)
inode->i_atime = attr->ia_atime;
inode_set_atime_to_ts(inode, attr->ia_atime);
if (ia_valid & ATTR_CTIME)
inode_set_ctime_to_ts(inode, attr->ia_ctime);
if (ia_valid & ATTR_MODE) {
Expand Down
4 changes: 2 additions & 2 deletions fs/affs/amigaffs.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ affs_insert_hash(struct inode *dir, struct buffer_head *bh)
mark_buffer_dirty_inode(dir_bh, dir);
affs_brelse(dir_bh);

dir->i_mtime = inode_set_ctime_current(dir);
inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
inode_inc_iversion(dir);
mark_inode_dirty(dir);

Expand Down Expand Up @@ -114,7 +114,7 @@ affs_remove_hash(struct inode *dir, struct buffer_head *rem_bh)

affs_brelse(bh);

dir->i_mtime = inode_set_ctime_current(dir);
inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
inode_inc_iversion(dir);
mark_inode_dirty(dir);

Expand Down
17 changes: 7 additions & 10 deletions fs/affs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,9 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino)
break;
}

inode->i_mtime.tv_sec = inode->i_atime.tv_sec =
inode_set_ctime(inode,
(be32_to_cpu(tail->change.days) * 86400LL +
be32_to_cpu(tail->change.mins) * 60 +
be32_to_cpu(tail->change.ticks) / 50 + AFFS_EPOCH_DELTA)
+ sys_tz.tz_minuteswest * 60, 0).tv_sec;
inode->i_mtime.tv_nsec = inode->i_atime.tv_nsec = 0;
inode_set_mtime(inode,
inode_set_atime(inode, inode_set_ctime(inode, (be32_to_cpu(tail->change.days) * 86400LL + be32_to_cpu(tail->change.mins) * 60 + be32_to_cpu(tail->change.ticks) / 50 + AFFS_EPOCH_DELTA) + sys_tz.tz_minuteswest * 60, 0).tv_sec, 0).tv_sec,
0);
affs_brelse(bh);
unlock_new_inode(inode);
return inode;
Expand Down Expand Up @@ -187,12 +183,13 @@ affs_write_inode(struct inode *inode, struct writeback_control *wbc)
}
tail = AFFS_TAIL(sb, bh);
if (tail->stype == cpu_to_be32(ST_ROOT)) {
affs_secs_to_datestamp(inode->i_mtime.tv_sec,
affs_secs_to_datestamp(inode_get_mtime_sec(inode),
&AFFS_ROOT_TAIL(sb, bh)->root_change);
} else {
tail->protect = cpu_to_be32(AFFS_I(inode)->i_protect);
tail->size = cpu_to_be32(inode->i_size);
affs_secs_to_datestamp(inode->i_mtime.tv_sec, &tail->change);
affs_secs_to_datestamp(inode_get_mtime_sec(inode),
&tail->change);
if (!(inode->i_ino == AFFS_SB(sb)->s_root_block)) {
uid = i_uid_read(inode);
gid = i_gid_read(inode);
Expand Down Expand Up @@ -314,7 +311,7 @@ affs_new_inode(struct inode *dir)
inode->i_gid = current_fsgid();
inode->i_ino = block;
set_nlink(inode, 1);
inode->i_mtime = inode->i_atime = inode_set_ctime_current(inode);
simple_inode_init_ts(inode);
atomic_set(&AFFS_I(inode)->i_opencnt, 0);
AFFS_I(inode)->i_blkcnt = 0;
AFFS_I(inode)->i_lc = NULL;
Expand Down
Loading

0 comments on commit 14ab6d4

Please sign in to comment.