Skip to content

Commit 078cd82

Browse files
deepa-hubAl Viro
authored andcommitted
fs: Replace CURRENT_TIME with current_time() for inode timestamps
CURRENT_TIME macro is not appropriate for filesystems as it doesn't use the right granularity for filesystem timestamps. Use current_time() instead. CURRENT_TIME is also not y2038 safe. This is also in preparation for the patch that transitions vfs timestamps to use 64 bit time and hence make them y2038 safe. As part of the effort current_time() will be extended to do range checks. Hence, it is necessary for all file system timestamps to use current_time(). Also, current_time() will be transitioned along with vfs to be y2038 safe. Note that whenever a single call to current_time() is used to change timestamps in different inodes, it is because they share the same time granularity. Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Felipe Balbi <balbi@kernel.org> Acked-by: Steven Whitehouse <swhiteho@redhat.com> Acked-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> Acked-by: David Sterba <dsterba@suse.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 2554c72 commit 078cd82

76 files changed

Lines changed: 182 additions & 182 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

arch/powerpc/platforms/cell/spufs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ spufs_new_inode(struct super_block *sb, umode_t mode)
103103
inode->i_mode = mode;
104104
inode->i_uid = current_fsuid();
105105
inode->i_gid = current_fsgid();
106-
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
106+
inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
107107
out:
108108
return inode;
109109
}

arch/s390/hypfs/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static void hypfs_update_update(struct super_block *sb)
5151
struct inode *inode = d_inode(sb_info->update_file);
5252

5353
sb_info->last_update = get_seconds();
54-
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
54+
inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
5555
}
5656

5757
/* directory tree removal functions */
@@ -99,7 +99,7 @@ static struct inode *hypfs_make_inode(struct super_block *sb, umode_t mode)
9999
ret->i_mode = mode;
100100
ret->i_uid = hypfs_info->uid;
101101
ret->i_gid = hypfs_info->gid;
102-
ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
102+
ret->i_atime = ret->i_mtime = ret->i_ctime = current_time(ret);
103103
if (S_ISDIR(mode))
104104
set_nlink(ret, 2);
105105
}

drivers/infiniband/hw/qib/qib_fs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static int qibfs_mknod(struct inode *dir, struct dentry *dentry,
6464
inode->i_uid = GLOBAL_ROOT_UID;
6565
inode->i_gid = GLOBAL_ROOT_GID;
6666
inode->i_blocks = 0;
67-
inode->i_atime = CURRENT_TIME;
67+
inode->i_atime = current_time(inode);
6868
inode->i_mtime = inode->i_atime;
6969
inode->i_ctime = inode->i_atime;
7070
inode->i_private = data;

drivers/misc/ibmasm/ibmasmfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode)
144144
if (ret) {
145145
ret->i_ino = get_next_ino();
146146
ret->i_mode = mode;
147-
ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
147+
ret->i_atime = ret->i_mtime = ret->i_ctime = current_time(ret);
148148
}
149149
return ret;
150150
}

drivers/oprofile/oprofilefs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static struct inode *oprofilefs_get_inode(struct super_block *sb, int mode)
3030
if (inode) {
3131
inode->i_ino = get_next_ino();
3232
inode->i_mode = mode;
33-
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
33+
inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
3434
}
3535
return inode;
3636
}

drivers/usb/core/devio.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,21 +2409,21 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
24092409
snoop(&dev->dev, "%s: CONTROL\n", __func__);
24102410
ret = proc_control(ps, p);
24112411
if (ret >= 0)
2412-
inode->i_mtime = CURRENT_TIME;
2412+
inode->i_mtime = current_time(inode);
24132413
break;
24142414

24152415
case USBDEVFS_BULK:
24162416
snoop(&dev->dev, "%s: BULK\n", __func__);
24172417
ret = proc_bulk(ps, p);
24182418
if (ret >= 0)
2419-
inode->i_mtime = CURRENT_TIME;
2419+
inode->i_mtime = current_time(inode);
24202420
break;
24212421

24222422
case USBDEVFS_RESETEP:
24232423
snoop(&dev->dev, "%s: RESETEP\n", __func__);
24242424
ret = proc_resetep(ps, p);
24252425
if (ret >= 0)
2426-
inode->i_mtime = CURRENT_TIME;
2426+
inode->i_mtime = current_time(inode);
24272427
break;
24282428

24292429
case USBDEVFS_RESET:
@@ -2435,7 +2435,7 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
24352435
snoop(&dev->dev, "%s: CLEAR_HALT\n", __func__);
24362436
ret = proc_clearhalt(ps, p);
24372437
if (ret >= 0)
2438-
inode->i_mtime = CURRENT_TIME;
2438+
inode->i_mtime = current_time(inode);
24392439
break;
24402440

24412441
case USBDEVFS_GETDRIVER:
@@ -2462,22 +2462,22 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
24622462
snoop(&dev->dev, "%s: SUBMITURB\n", __func__);
24632463
ret = proc_submiturb(ps, p);
24642464
if (ret >= 0)
2465-
inode->i_mtime = CURRENT_TIME;
2465+
inode->i_mtime = current_time(inode);
24662466
break;
24672467

24682468
#ifdef CONFIG_COMPAT
24692469
case USBDEVFS_CONTROL32:
24702470
snoop(&dev->dev, "%s: CONTROL32\n", __func__);
24712471
ret = proc_control_compat(ps, p);
24722472
if (ret >= 0)
2473-
inode->i_mtime = CURRENT_TIME;
2473+
inode->i_mtime = current_time(inode);
24742474
break;
24752475

24762476
case USBDEVFS_BULK32:
24772477
snoop(&dev->dev, "%s: BULK32\n", __func__);
24782478
ret = proc_bulk_compat(ps, p);
24792479
if (ret >= 0)
2480-
inode->i_mtime = CURRENT_TIME;
2480+
inode->i_mtime = current_time(inode);
24812481
break;
24822482

24832483
case USBDEVFS_DISCSIGNAL32:
@@ -2489,7 +2489,7 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
24892489
snoop(&dev->dev, "%s: SUBMITURB32\n", __func__);
24902490
ret = proc_submiturb_compat(ps, p);
24912491
if (ret >= 0)
2492-
inode->i_mtime = CURRENT_TIME;
2492+
inode->i_mtime = current_time(inode);
24932493
break;
24942494

24952495
case USBDEVFS_IOCTL32:
@@ -2552,7 +2552,7 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
25522552
done:
25532553
usb_unlock_device(dev);
25542554
if (ret >= 0)
2555-
inode->i_atime = CURRENT_TIME;
2555+
inode->i_atime = current_time(inode);
25562556
return ret;
25572557
}
25582558

drivers/usb/gadget/function/f_fs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,15 +1193,15 @@ ffs_sb_make_inode(struct super_block *sb, void *data,
11931193
inode = new_inode(sb);
11941194

11951195
if (likely(inode)) {
1196-
struct timespec current_time = CURRENT_TIME;
1196+
struct timespec ts = current_time(inode);
11971197

11981198
inode->i_ino = get_next_ino();
11991199
inode->i_mode = perms->mode;
12001200
inode->i_uid = perms->uid;
12011201
inode->i_gid = perms->gid;
1202-
inode->i_atime = current_time;
1203-
inode->i_mtime = current_time;
1204-
inode->i_ctime = current_time;
1202+
inode->i_atime = ts;
1203+
inode->i_mtime = ts;
1204+
inode->i_ctime = ts;
12051205
inode->i_private = data;
12061206
if (fops)
12071207
inode->i_fop = fops;

drivers/usb/gadget/legacy/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,7 @@ gadgetfs_make_inode (struct super_block *sb,
19131913
inode->i_uid = make_kuid(&init_user_ns, default_uid);
19141914
inode->i_gid = make_kgid(&init_user_ns, default_gid);
19151915
inode->i_atime = inode->i_mtime = inode->i_ctime
1916-
= CURRENT_TIME;
1916+
= current_time(inode);
19171917
inode->i_private = data;
19181918
inode->i_fop = fops;
19191919
}

fs/9p/vfs_inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ int v9fs_init_inode(struct v9fs_session_info *v9ses,
276276
inode_init_owner(inode, NULL, mode);
277277
inode->i_blocks = 0;
278278
inode->i_rdev = rdev;
279-
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
279+
inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
280280
inode->i_mapping->a_ops = &v9fs_addr_operations;
281281

282282
switch (mode & S_IFMT) {

fs/adfs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ adfs_adfs2unix_time(struct timespec *tv, struct inode *inode)
199199
return;
200200

201201
cur_time:
202-
*tv = CURRENT_TIME;
202+
*tv = current_time(inode);
203203
return;
204204

205205
too_early:

0 commit comments

Comments
 (0)