Re: [Y2038] [PATCH 02/21] fs: ext4: Use current_fs_time() for inode timestamps
On Fri, Jun 10, 2016 at 3:19 PM, Arnd Bergmannwrote: > On Thursday, June 9, 2016 11:45:01 AM CEST Linus Torvalds wrote: >> On Wed, Jun 8, 2016 at 10:04 PM, Deepa Dinamani >> wrote: >> > CURRENT_TIME_SEC and CURRENT_TIME are not y2038 safe. >> > current_fs_time() will be transitioned to be y2038 safe >> > along with vfs. >> > >> > current_fs_time() returns timestamps according to the >> > granularities set in the super_block. >> >> All existing users and all the ones in this patch (and the others too, >> although I didn't go through them very carefully) really would prefer >> just passing in the inode directly, rather than the superblock. >> >> So I don't want to add more users of this broken interface. It was a >> mistake to use the superblock. The fact that the time granularity >> exists there is pretty much irrelevant. If every single user wants to >> use an inode pointer, then that is what the function should get. > > I guess it would help to give the function a new name in the process, > if only to avoid possible conflicts. That new name of course needs to > be at least as intuitive as the old one. How about > > struct timespec fs_timestamp(struct inode *); Would moving the function to fs/ directory (filesystems.c/ super.c / inode.c) and calling it current_time() or fs_current_time() make sense? The declaration is already part of fs.h. This is actually a vfs function. And, the time functions it uses are already exported. Leaving it in the time.c by renaming to current_time() would be confusing in spite of the struct inode* argument. -Deepa ___ Y2038 mailing list Y2038@lists.linaro.org https://lists.linaro.org/mailman/listinfo/y2038
Re: [Y2038] [PATCH 02/21] fs: ext4: Use current_fs_time() for inode timestamps
On Thursday, June 9, 2016 11:45:01 AM CEST Linus Torvalds wrote: > On Wed, Jun 8, 2016 at 10:04 PM, Deepa Dinamani> wrote: > > CURRENT_TIME_SEC and CURRENT_TIME are not y2038 safe. > > current_fs_time() will be transitioned to be y2038 safe > > along with vfs. > > > > current_fs_time() returns timestamps according to the > > granularities set in the super_block. > > All existing users and all the ones in this patch (and the others too, > although I didn't go through them very carefully) really would prefer > just passing in the inode directly, rather than the superblock. > > So I don't want to add more users of this broken interface. It was a > mistake to use the superblock. The fact that the time granularity > exists there is pretty much irrelevant. If every single user wants to > use an inode pointer, then that is what the function should get. I guess it would help to give the function a new name in the process, if only to avoid possible conflicts. That new name of course needs to be at least as intuitive as the old one. How about struct timespec fs_timestamp(struct inode *); ? Arnd ___ Y2038 mailing list Y2038@lists.linaro.org https://lists.linaro.org/mailman/listinfo/y2038
Re: [Y2038] [PATCH 02/21] fs: ext4: Use current_fs_time() for inode timestamps
On Wed, Jun 8, 2016 at 10:04 PM, Deepa Dinamaniwrote: > CURRENT_TIME_SEC and CURRENT_TIME are not y2038 safe. > current_fs_time() will be transitioned to be y2038 safe > along with vfs. > > current_fs_time() returns timestamps according to the > granularities set in the super_block. All existing users and all the ones in this patch (and the others too, although I didn't go through them very carefully) really would prefer just passing in the inode directly, rather than the superblock. So I don't want to add more users of this broken interface. It was a mistake to use the superblock. The fact that the time granularity exists there is pretty much irrelevant. If every single user wants to use an inode pointer, then that is what the function should get. Linus ___ Y2038 mailing list Y2038@lists.linaro.org https://lists.linaro.org/mailman/listinfo/y2038
[Y2038] [PATCH 02/21] fs: ext4: Use current_fs_time() for inode timestamps
CURRENT_TIME_SEC and CURRENT_TIME are not y2038 safe. current_fs_time() will be transitioned to be y2038 safe along with vfs. current_fs_time() returns timestamps according to the granularities set in the super_block. The granularity check to call current_fs_time() or CURRENT_TIME_SEC is not required. Use current_fs_time() to obtain timestamps unconditionally. Quota files are assumed to be on the same filesystem. Hence, use current_fs_time() for these files as well. Signed-off-by: Deepa DinamaniCc: "Theodore Ts'o" Cc: Andreas Dilger Cc: linux-e...@vger.kernel.org --- fs/ext4/acl.c | 2 +- fs/ext4/ext4.h| 6 -- fs/ext4/extents.c | 10 +- fs/ext4/ialloc.c | 2 +- fs/ext4/inline.c | 4 ++-- fs/ext4/inode.c | 6 +++--- fs/ext4/ioctl.c | 8 fs/ext4/namei.c | 24 +--- fs/ext4/super.c | 2 +- fs/ext4/xattr.c | 2 +- 10 files changed, 31 insertions(+), 35 deletions(-) diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c index c6601a4..f9469cc 100644 --- a/fs/ext4/acl.c +++ b/fs/ext4/acl.c @@ -197,7 +197,7 @@ __ext4_set_acl(handle_t *handle, struct inode *inode, int type, if (error < 0) return error; else { - inode->i_ctime = ext4_current_time(inode); + inode->i_ctime = current_fs_time(inode->i_sb); ext4_mark_inode_dirty(handle, inode); if (error == 0) acl = NULL; diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index b84aa1c..14e5cf4 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1523,12 +1523,6 @@ static inline struct ext4_inode_info *EXT4_I(struct inode *inode) return container_of(inode, struct ext4_inode_info, vfs_inode); } -static inline struct timespec ext4_current_time(struct inode *inode) -{ - return (inode->i_sb->s_time_gran < NSEC_PER_SEC) ? - current_fs_time(inode->i_sb) : CURRENT_TIME_SEC; -} - static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino) { return ino == EXT4_ROOT_INO || diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 2a2eef9..ac303be 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4722,7 +4722,7 @@ retry: map.m_lblk += ret; map.m_len = len = len - ret; epos = (loff_t)map.m_lblk << inode->i_blkbits; - inode->i_ctime = ext4_current_time(inode); + inode->i_ctime = current_fs_time(inode->i_sb); if (new_size) { if (epos > new_size) epos = new_size; @@ -4850,7 +4850,7 @@ static long ext4_zero_range(struct file *file, loff_t offset, } /* Now release the pages and zero block aligned part of pages */ truncate_pagecache_range(inode, start, end - 1); - inode->i_mtime = inode->i_ctime = ext4_current_time(inode); + inode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb); ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size, flags, mode); @@ -4875,7 +4875,7 @@ static long ext4_zero_range(struct file *file, loff_t offset, goto out_dio; } - inode->i_mtime = inode->i_ctime = ext4_current_time(inode); + inode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb); if (new_size) { ext4_update_inode_size(inode, new_size); } else { @@ -5574,7 +5574,7 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len) up_write(_I(inode)->i_data_sem); if (IS_SYNC(inode)) ext4_handle_sync(handle); - inode->i_mtime = inode->i_ctime = ext4_current_time(inode); + inode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb); ext4_mark_inode_dirty(handle, inode); out_stop: @@ -5684,7 +5684,7 @@ int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len) /* Expand file to avoid data loss if there is error while shifting */ inode->i_size += len; EXT4_I(inode)->i_disksize += len; - inode->i_mtime = inode->i_ctime = ext4_current_time(inode); + inode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb); ret = ext4_mark_inode_dirty(handle, inode); if (ret) goto out_stop; diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 3da4cf8..152ef38 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -1039,7 +1039,7 @@ got: /* This is the optimal IO size (for stat), not the fs block size */ inode->i_blocks = 0; inode->i_mtime = inode->i_atime = inode->i_ctime = ei->i_crtime = -