Skip to content

Commit

Permalink
fs: Replace CURRENT_TIME_SEC with current_time() for inode timestamps
Browse files Browse the repository at this point in the history
CURRENT_TIME_SEC is not y2038 safe. current_time() will
be transitioned to use 64 bit time along with vfs in a
separate patch.
There is no plan to transistion CURRENT_TIME_SEC to use
y2038 safe time interfaces.

current_time() will also be extended to use superblock
range checking parameters when range checking is introduced.

This works because alloc_super() fills in the the s_time_gran
in super block to NSEC_PER_SEC.

Signed-off-by: Deepa Dinamani <[email protected]>
Acked-by: Jan Kara <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
deepa-hub authored and Al Viro committed Sep 28, 2016
1 parent 078cd82 commit 02027d4
Show file tree
Hide file tree
Showing 47 changed files with 105 additions and 105 deletions.
6 changes: 3 additions & 3 deletions fs/affs/amigaffs.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,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 = dir->i_ctime = CURRENT_TIME_SEC;
dir->i_mtime = dir->i_ctime = current_time(dir);
dir->i_version++;
mark_inode_dirty(dir);

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

affs_brelse(bh);

dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
dir->i_mtime = dir->i_ctime = current_time(dir);
dir->i_version++;
mark_inode_dirty(dir);

Expand Down Expand Up @@ -313,7 +313,7 @@ affs_remove_header(struct dentry *dentry)
else
clear_nlink(inode);
affs_unlock_link(inode);
inode->i_ctime = CURRENT_TIME_SEC;
inode->i_ctime = current_time(inode);
mark_inode_dirty(inode);

done:
Expand Down
2 changes: 1 addition & 1 deletion fs/affs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,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->i_ctime = CURRENT_TIME_SEC;
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
atomic_set(&AFFS_I(inode)->i_opencnt, 0);
AFFS_I(inode)->i_blkcnt = 0;
AFFS_I(inode)->i_lc = NULL;
Expand Down
14 changes: 7 additions & 7 deletions fs/bfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static int bfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
set_bit(ino, info->si_imap);
info->si_freei--;
inode_init_owner(inode, dir, mode);
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
inode->i_blocks = 0;
inode->i_op = &bfs_file_inops;
inode->i_fop = &bfs_file_operations;
Expand Down Expand Up @@ -165,7 +165,7 @@ static int bfs_link(struct dentry *old, struct inode *dir,
return err;
}
inc_nlink(inode);
inode->i_ctime = CURRENT_TIME_SEC;
inode->i_ctime = current_time(inode);
mark_inode_dirty(inode);
ihold(inode);
d_instantiate(new, inode);
Expand Down Expand Up @@ -194,7 +194,7 @@ static int bfs_unlink(struct inode *dir, struct dentry *dentry)
}
de->ino = 0;
mark_buffer_dirty_inode(bh, dir);
dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
dir->i_ctime = dir->i_mtime = current_time(dir);
mark_inode_dirty(dir);
inode->i_ctime = dir->i_ctime;
inode_dec_link_count(inode);
Expand Down Expand Up @@ -249,10 +249,10 @@ static int bfs_rename(struct inode *old_dir, struct dentry *old_dentry,
goto end_rename;
}
old_de->ino = 0;
old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME_SEC;
old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir);
mark_inode_dirty(old_dir);
if (new_inode) {
new_inode->i_ctime = CURRENT_TIME_SEC;
new_inode->i_ctime = current_time(new_inode);
inode_dec_link_count(new_inode);
}
mark_buffer_dirty_inode(old_bh, old_dir);
Expand Down Expand Up @@ -300,9 +300,9 @@ static int bfs_add_entry(struct inode *dir, const unsigned char *name,
pos = (block - sblock) * BFS_BSIZE + off;
if (pos >= dir->i_size) {
dir->i_size += BFS_DIRENT_SIZE;
dir->i_ctime = CURRENT_TIME_SEC;
dir->i_ctime = current_time(dir);
}
dir->i_mtime = CURRENT_TIME_SEC;
dir->i_mtime = current_time(dir);
mark_inode_dirty(dir);
de->ino = cpu_to_le16((u16)ino);
for (i = 0; i < BFS_NAMELEN; i++)
Expand Down
2 changes: 1 addition & 1 deletion fs/coda/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static inline void coda_dir_update_mtime(struct inode *dir)
/* optimistically we can also act as if our nose bleeds. The
* granularity of the mtime is coarse anyways so we might actually be
* right most of the time. Note: we only do this for directories. */
dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
dir->i_mtime = dir->i_ctime = current_time(dir);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion fs/coda/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ coda_file_write_iter(struct kiocb *iocb, struct iov_iter *to)
ret = vfs_iter_write(cfi->cfi_container, to, &iocb->ki_pos);
coda_inode->i_size = file_inode(host_file)->i_size;
coda_inode->i_blocks = (coda_inode->i_size + 511) >> 9;
coda_inode->i_mtime = coda_inode->i_ctime = CURRENT_TIME_SEC;
coda_inode->i_mtime = coda_inode->i_ctime = current_time(coda_inode);
inode_unlock(coda_inode);
file_end_write(host_file);
return ret;
Expand Down
2 changes: 1 addition & 1 deletion fs/coda/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ int coda_setattr(struct dentry *de, struct iattr *iattr)

memset(&vattr, 0, sizeof(vattr));

inode->i_ctime = CURRENT_TIME_SEC;
inode->i_ctime = current_time(inode);
coda_iattr_to_vattr(iattr, &vattr);
vattr.va_type = C_VNON; /* cannot set type */

Expand Down
2 changes: 1 addition & 1 deletion fs/ext2/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
if (error < 0)
return error;
else {
inode->i_ctime = CURRENT_TIME_SEC;
inode->i_ctime = current_time(inode);
mark_inode_dirty(inode);
if (error == 0)
acl = NULL;
Expand Down
6 changes: 3 additions & 3 deletions fs/ext2/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
err = ext2_commit_chunk(page, pos, len);
ext2_put_page(page);
if (update_times)
dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
dir->i_mtime = dir->i_ctime = current_time(dir);
EXT2_I(dir)->i_flags &= ~EXT2_BTREE_FL;
mark_inode_dirty(dir);
}
Expand Down Expand Up @@ -561,7 +561,7 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode)
de->inode = cpu_to_le32(inode->i_ino);
ext2_set_de_type (de, inode);
err = ext2_commit_chunk(page, pos, rec_len);
dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
dir->i_mtime = dir->i_ctime = current_time(dir);
EXT2_I(dir)->i_flags &= ~EXT2_BTREE_FL;
mark_inode_dirty(dir);
/* OFFSET_CACHE */
Expand Down Expand Up @@ -610,7 +610,7 @@ int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page )
pde->rec_len = ext2_rec_len_to_disk(to - from);
dir->inode = 0;
err = ext2_commit_chunk(page, pos, to - from);
inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
inode->i_ctime = inode->i_mtime = current_time(inode);
EXT2_I(inode)->i_flags &= ~EXT2_BTREE_FL;
mark_inode_dirty(inode);
out:
Expand Down
2 changes: 1 addition & 1 deletion fs/ext2/ialloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ struct inode *ext2_new_inode(struct inode *dir, umode_t mode,

inode->i_ino = ino;
inode->i_blocks = 0;
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
memset(ei->i_data, 0, sizeof(ei->i_data));
ei->i_flags =
ext2_mask_flags(mode, EXT2_I(dir)->i_flags & EXT2_FL_INHERITED);
Expand Down
4 changes: 2 additions & 2 deletions fs/ext2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ static void ext2_splice_branch(struct inode *inode,
if (where->bh)
mark_buffer_dirty_inode(where->bh, inode);

inode->i_ctime = CURRENT_TIME_SEC;
inode->i_ctime = current_time(inode);
mark_inode_dirty(inode);
}

Expand Down Expand Up @@ -1236,7 +1236,7 @@ static int ext2_setsize(struct inode *inode, loff_t newsize)
__ext2_truncate_blocks(inode, newsize);
dax_sem_up_write(EXT2_I(inode));

inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
inode->i_mtime = inode->i_ctime = current_time(inode);
if (inode_needs_sync(inode)) {
sync_mapping_buffers(inode->i_mapping);
sync_inode_metadata(inode, 1);
Expand Down
4 changes: 2 additions & 2 deletions fs/ext2/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
ei->i_flags = flags;

ext2_set_inode_flags(inode);
inode->i_ctime = CURRENT_TIME_SEC;
inode->i_ctime = current_time(inode);
inode_unlock(inode);

mark_inode_dirty(inode);
Expand All @@ -103,7 +103,7 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
}

inode_lock(inode);
inode->i_ctime = CURRENT_TIME_SEC;
inode->i_ctime = current_time(inode);
inode->i_generation = generation;
inode_unlock(inode);

Expand Down
6 changes: 3 additions & 3 deletions fs/ext2/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir,
if (err)
return err;

inode->i_ctime = CURRENT_TIME_SEC;
inode->i_ctime = current_time(inode);
inode_inc_link_count(inode);
ihold(inode);

Expand Down Expand Up @@ -372,7 +372,7 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
if (!new_de)
goto out_dir;
ext2_set_link(new_dir, new_de, new_page, old_inode, 1);
new_inode->i_ctime = CURRENT_TIME_SEC;
new_inode->i_ctime = current_time(new_inode);
if (dir_de)
drop_nlink(new_inode);
inode_dec_link_count(new_inode);
Expand All @@ -388,7 +388,7 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
* Like most other Unix systems, set the ctime for inodes on a
* rename.
*/
old_inode->i_ctime = CURRENT_TIME_SEC;
old_inode->i_ctime = current_time(old_inode);
mark_inode_dirty(old_inode);

ext2_delete_entry (old_de, old_page);
Expand Down
2 changes: 1 addition & 1 deletion fs/ext2/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,

/* Update the inode. */
EXT2_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
inode->i_ctime = CURRENT_TIME_SEC;
inode->i_ctime = current_time(inode);
if (IS_SYNC(inode)) {
error = sync_inode_metadata(inode, 1);
/* In case sync failed due to ENOSPC the inode was actually
Expand Down
2 changes: 1 addition & 1 deletion fs/fat/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ int fat_remove_entries(struct inode *dir, struct fat_slot_info *sinfo)
}
}

dir->i_mtime = dir->i_atime = CURRENT_TIME_SEC;
dir->i_mtime = dir->i_atime = current_time(dir);
if (IS_DIRSYNC(dir))
(void)fat_sync_inode(dir);
else
Expand Down
4 changes: 2 additions & 2 deletions fs/fat/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ static int fat_cont_expand(struct inode *inode, loff_t size)
if (err)
goto out;

inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
inode->i_ctime = inode->i_mtime = current_time(inode);
mark_inode_dirty(inode);
if (IS_SYNC(inode)) {
int err2;
Expand Down Expand Up @@ -297,7 +297,7 @@ static int fat_free(struct inode *inode, int skip)
MSDOS_I(inode)->i_logstart = 0;
}
MSDOS_I(inode)->i_attrs |= ATTR_ARCH;
inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
inode->i_ctime = inode->i_mtime = current_time(inode);
if (wait) {
err = fat_sync_inode(inode);
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion fs/fat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ static int fat_write_end(struct file *file, struct address_space *mapping,
if (err < len)
fat_write_failed(mapping, pos + len);
if (!(err < 0) && !(MSDOS_I(inode)->i_attrs & ATTR_ARCH)) {
inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
inode->i_mtime = inode->i_ctime = current_time(inode);
MSDOS_I(inode)->i_attrs |= ATTR_ARCH;
mark_inode_dirty(inode);
}
Expand Down
12 changes: 6 additions & 6 deletions fs/fat/namei_msdos.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode,
goto out;
}

ts = CURRENT_TIME_SEC;
ts = current_time(dir);
err = msdos_add_entry(dir, msdos_name, 0, is_hid, 0, &ts, &sinfo);
if (err)
goto out;
Expand Down Expand Up @@ -330,7 +330,7 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry)
drop_nlink(dir);

clear_nlink(inode);
inode->i_ctime = CURRENT_TIME_SEC;
inode->i_ctime = current_time(inode);
fat_detach(inode);
out:
mutex_unlock(&MSDOS_SB(sb)->s_lock);
Expand Down Expand Up @@ -364,7 +364,7 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
goto out;
}

ts = CURRENT_TIME_SEC;
ts = current_time(dir);
cluster = fat_alloc_new_dir(dir, &ts);
if (cluster < 0) {
err = cluster;
Expand Down Expand Up @@ -416,7 +416,7 @@ static int msdos_unlink(struct inode *dir, struct dentry *dentry)
if (err)
goto out;
clear_nlink(inode);
inode->i_ctime = CURRENT_TIME_SEC;
inode->i_ctime = current_time(inode);
fat_detach(inode);
out:
mutex_unlock(&MSDOS_SB(sb)->s_lock);
Expand Down Expand Up @@ -481,7 +481,7 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
mark_inode_dirty(old_inode);

old_dir->i_version++;
old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME_SEC;
old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir);
if (IS_DIRSYNC(old_dir))
(void)fat_sync_inode(old_dir);
else
Expand All @@ -490,7 +490,7 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
}
}

ts = CURRENT_TIME_SEC;
ts = current_time(old_inode);
if (new_inode) {
if (err)
goto out;
Expand Down
10 changes: 5 additions & 5 deletions fs/fat/namei_vfat.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ static int vfat_create(struct inode *dir, struct dentry *dentry, umode_t mode,

mutex_lock(&MSDOS_SB(sb)->s_lock);

ts = CURRENT_TIME_SEC;
ts = current_time(dir);
err = vfat_add_entry(dir, &dentry->d_name, 0, 0, &ts, &sinfo);
if (err)
goto out;
Expand Down Expand Up @@ -821,7 +821,7 @@ static int vfat_rmdir(struct inode *dir, struct dentry *dentry)
drop_nlink(dir);

clear_nlink(inode);
inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC;
inode->i_mtime = inode->i_atime = current_time(inode);
fat_detach(inode);
dentry->d_time = dir->i_version;
out:
Expand All @@ -847,7 +847,7 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry)
if (err)
goto out;
clear_nlink(inode);
inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC;
inode->i_mtime = inode->i_atime = current_time(inode);
fat_detach(inode);
dentry->d_time = dir->i_version;
out:
Expand All @@ -866,7 +866,7 @@ static int vfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)

mutex_lock(&MSDOS_SB(sb)->s_lock);

ts = CURRENT_TIME_SEC;
ts = current_time(dir);
cluster = fat_alloc_new_dir(dir, &ts);
if (cluster < 0) {
err = cluster;
Expand Down Expand Up @@ -931,7 +931,7 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
}
}

ts = CURRENT_TIME_SEC;
ts = current_time(old_dir);
if (new_inode) {
if (is_dir) {
err = fat_dir_empty(new_inode);
Expand Down
Loading

0 comments on commit 02027d4

Please sign in to comment.