aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ntfs/inode.c
diff options
context:
space:
mode:
authorDeepa Dinamani <deepa.kernel@gmail.com>2018-05-08 22:36:02 -0400
committerDeepa Dinamani <deepa.kernel@gmail.com>2018-06-05 19:57:31 -0400
commit95582b00838837fc07e042979320caf917ce3fe6 (patch)
treeda001bc61ee76d836b91d3d80a77dbd302be222b /fs/ntfs/inode.c
parent7aaa822ed060719bd4ea012609883b6bc6950508 (diff)
vfs: change inode times to use struct timespec64
struct timespec is not y2038 safe. Transition vfs to use y2038 safe struct timespec64 instead. The change was made with the help of the following cocinelle script. This catches about 80% of the changes. All the header file and logic changes are included in the first 5 rules. The rest are trivial substitutions. I avoid changing any of the function signatures or any other filesystem specific data structures to keep the patch simple for review. The script can be a little shorter by combining different cases. But, this version was sufficient for my usecase. virtual patch @ depends on patch @ identifier now; @@ - struct timespec + struct timespec64 current_time ( ... ) { - struct timespec now = current_kernel_time(); + struct timespec64 now = current_kernel_time64(); ... - return timespec_trunc( + return timespec64_trunc( ... ); } @ depends on patch @ identifier xtime; @@ struct \( iattr \| inode \| kstat \) { ... - struct timespec xtime; + struct timespec64 xtime; ... } @ depends on patch @ identifier t; @@ struct inode_operations { ... int (*update_time) (..., - struct timespec t, + struct timespec64 t, ...); ... } @ depends on patch @ identifier t; identifier fn_update_time =~ "update_time$"; @@ fn_update_time (..., - struct timespec *t, + struct timespec64 *t, ...) { ... } @ depends on patch @ identifier t; @@ lease_get_mtime( ... , - struct timespec *t + struct timespec64 *t ) { ... } @te depends on patch forall@ identifier ts; local idexpression struct inode *inode_node; identifier i_xtime =~ "^i_[acm]time$"; identifier ia_xtime =~ "^ia_[acm]time$"; identifier fn_update_time =~ "update_time$"; identifier fn; expression e, E3; local idexpression struct inode *node1; local idexpression struct inode *node2; local idexpression struct iattr *attr1; local idexpression struct iattr *attr2; local idexpression struct iattr attr; identifier i_xtime1 =~ "^i_[acm]time$"; identifier i_xtime2 =~ "^i_[acm]time$"; identifier ia_xtime1 =~ "^ia_[acm]time$"; identifier ia_xtime2 =~ "^ia_[acm]time$"; @@ ( ( - struct timespec ts; + struct timespec64 ts; | - struct timespec ts = current_time(inode_node); + struct timespec64 ts = current_time(inode_node); ) <+... when != ts ( - timespec_equal(&inode_node->i_xtime, &ts) + timespec64_equal(&inode_node->i_xtime, &ts) | - timespec_equal(&ts, &inode_node->i_xtime) + timespec64_equal(&ts, &inode_node->i_xtime) | - timespec_compare(&inode_node->i_xtime, &ts) + timespec64_compare(&inode_node->i_xtime, &ts) | - timespec_compare(&ts, &inode_node->i_xtime) + timespec64_compare(&ts, &inode_node->i_xtime) | ts = current_time(e) | fn_update_time(..., &ts,...) | inode_node->i_xtime = ts | node1->i_xtime = ts | ts = inode_node->i_xtime | <+... attr1->ia_xtime ...+> = ts | ts = attr1->ia_xtime | ts.tv_sec | ts.tv_nsec | btrfs_set_stack_timespec_sec(..., ts.tv_sec) | btrfs_set_stack_timespec_nsec(..., ts.tv_nsec) | - ts = timespec64_to_timespec( + ts = ... -) | - ts = ktime_to_timespec( + ts = ktime_to_timespec64( ...) | - ts = E3 + ts = timespec_to_timespec64(E3) | - ktime_get_real_ts(&ts) + ktime_get_real_ts64(&ts) | fn(..., - ts + timespec64_to_timespec(ts) ,...) ) ...+> ( <... when != ts - return ts; + return timespec64_to_timespec(ts); ...> ) | - timespec_equal(&node1->i_xtime1, &node2->i_xtime2) + timespec64_equal(&node1->i_xtime2, &node2->i_xtime2) | - timespec_equal(&node1->i_xtime1, &attr2->ia_xtime2) + timespec64_equal(&node1->i_xtime2, &attr2->ia_xtime2) | - timespec_compare(&node1->i_xtime1, &node2->i_xtime2) + timespec64_compare(&node1->i_xtime1, &node2->i_xtime2) | node1->i_xtime1 = - timespec_trunc(attr1->ia_xtime1, + timespec64_trunc(attr1->ia_xtime1, ...) | - attr1->ia_xtime1 = timespec_trunc(attr2->ia_xtime2, + attr1->ia_xtime1 = timespec64_trunc(attr2->ia_xtime2, ...) | - ktime_get_real_ts(&attr1->ia_xtime1) + ktime_get_real_ts64(&attr1->ia_xtime1) | - ktime_get_real_ts(&attr.ia_xtime1) + ktime_get_real_ts64(&attr.ia_xtime1) ) @ depends on patch @ struct inode *node; struct iattr *attr; identifier fn; identifier i_xtime =~ "^i_[acm]time$"; identifier ia_xtime =~ "^ia_[acm]time$"; expression e; @@ ( - fn(node->i_xtime); + fn(timespec64_to_timespec(node->i_xtime)); | fn(..., - node->i_xtime); + timespec64_to_timespec(node->i_xtime)); | - e = fn(attr->ia_xtime); + e = fn(timespec64_to_timespec(attr->ia_xtime)); ) @ depends on patch forall @ struct inode *node; struct iattr *attr; identifier i_xtime =~ "^i_[acm]time$"; identifier ia_xtime =~ "^ia_[acm]time$"; identifier fn; @@ { + struct timespec ts; <+... ( + ts = timespec64_to_timespec(node->i_xtime); fn (..., - &node->i_xtime, + &ts, ...); | + ts = timespec64_to_timespec(attr->ia_xtime); fn (..., - &attr->ia_xtime, + &ts, ...); ) ...+> } @ depends on patch forall @ struct inode *node; struct iattr *attr; struct kstat *stat; identifier ia_xtime =~ "^ia_[acm]time$"; identifier i_xtime =~ "^i_[acm]time$"; identifier xtime =~ "^[acm]time$"; identifier fn, ret; @@ { + struct timespec ts; <+... ( + ts = timespec64_to_timespec(node->i_xtime); ret = fn (..., - &node->i_xtime, + &ts, ...); | + ts = timespec64_to_timespec(node->i_xtime); ret = fn (..., - &node->i_xtime); + &ts); | + ts = timespec64_to_timespec(attr->ia_xtime); ret = fn (..., - &attr->ia_xtime, + &ts, ...); | + ts = timespec64_to_timespec(attr->ia_xtime); ret = fn (..., - &attr->ia_xtime); + &ts); | + ts = timespec64_to_timespec(stat->xtime); ret = fn (..., - &stat->xtime); + &ts); ) ...+> } @ depends on patch @ struct inode *node; struct inode *node2; identifier i_xtime1 =~ "^i_[acm]time$"; identifier i_xtime2 =~ "^i_[acm]time$"; identifier i_xtime3 =~ "^i_[acm]time$"; struct iattr *attrp; struct iattr *attrp2; struct iattr attr ; identifier ia_xtime1 =~ "^ia_[acm]time$"; identifier ia_xtime2 =~ "^ia_[acm]time$"; struct kstat *stat; struct kstat stat1; struct timespec64 ts; identifier xtime =~ "^[acmb]time$"; expression e; @@ ( ( node->i_xtime2 \| attrp->ia_xtime2 \| attr.ia_xtime2 \) = node->i_xtime1 ; | node->i_xtime2 = \( node2->i_xtime1 \| timespec64_trunc(...) \); | node->i_xtime2 = node->i_xtime1 = node->i_xtime3 = \(ts \| current_time(...) \); | node->i_xtime1 = node->i_xtime3 = \(ts \| current_time(...) \); | stat->xtime = node2->i_xtime1; | stat1.xtime = node2->i_xtime1; | ( node->i_xtime2 \| attrp->ia_xtime2 \) = attrp->ia_xtime1 ; | ( attrp->ia_xtime1 \| attr.ia_xtime1 \) = attrp2->ia_xtime2; | - e = node->i_xtime1; + e = timespec64_to_timespec( node->i_xtime1 ); | - e = attrp->ia_xtime1; + e = timespec64_to_timespec( attrp->ia_xtime1 ); | node->i_xtime1 = current_time(...); | node->i_xtime2 = node->i_xtime1 = node->i_xtime3 = - e; + timespec_to_timespec64(e); | node->i_xtime1 = node->i_xtime3 = - e; + timespec_to_timespec64(e); | - node->i_xtime1 = e; + node->i_xtime1 = timespec_to_timespec64(e); ) Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com> Cc: <anton@tuxera.com> Cc: <balbi@kernel.org> Cc: <bfields@fieldses.org> Cc: <darrick.wong@oracle.com> Cc: <dhowells@redhat.com> Cc: <dsterba@suse.com> Cc: <dwmw2@infradead.org> Cc: <hch@lst.de> Cc: <hirofumi@mail.parknet.co.jp> Cc: <hubcap@omnibond.com> Cc: <jack@suse.com> Cc: <jaegeuk@kernel.org> Cc: <jaharkes@cs.cmu.edu> Cc: <jslaby@suse.com> Cc: <keescook@chromium.org> Cc: <mark@fasheh.com> Cc: <miklos@szeredi.hu> Cc: <nico@linaro.org> Cc: <reiserfs-devel@vger.kernel.org> Cc: <richard@nod.at> Cc: <sage@redhat.com> Cc: <sfrench@samba.org> Cc: <swhiteho@redhat.com> Cc: <tj@kernel.org> Cc: <trond.myklebust@primarydata.com> Cc: <tytso@mit.edu> Cc: <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ntfs/inode.c')
-rw-r--r--fs/ntfs/inode.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index 1c1ee489284b..decaf75d1cd5 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -667,18 +667,18 @@ static int ntfs_read_locked_inode(struct inode *vi)
667 * mtime is the last change of the data within the file. Not changed 667 * mtime is the last change of the data within the file. Not changed
668 * when only metadata is changed, e.g. a rename doesn't affect mtime. 668 * when only metadata is changed, e.g. a rename doesn't affect mtime.
669 */ 669 */
670 vi->i_mtime = ntfs2utc(si->last_data_change_time); 670 vi->i_mtime = timespec_to_timespec64(ntfs2utc(si->last_data_change_time));
671 /* 671 /*
672 * ctime is the last change of the metadata of the file. This obviously 672 * ctime is the last change of the metadata of the file. This obviously
673 * always changes, when mtime is changed. ctime can be changed on its 673 * always changes, when mtime is changed. ctime can be changed on its
674 * own, mtime is then not changed, e.g. when a file is renamed. 674 * own, mtime is then not changed, e.g. when a file is renamed.
675 */ 675 */
676 vi->i_ctime = ntfs2utc(si->last_mft_change_time); 676 vi->i_ctime = timespec_to_timespec64(ntfs2utc(si->last_mft_change_time));
677 /* 677 /*
678 * Last access to the data within the file. Not changed during a rename 678 * Last access to the data within the file. Not changed during a rename
679 * for example but changed whenever the file is written to. 679 * for example but changed whenever the file is written to.
680 */ 680 */
681 vi->i_atime = ntfs2utc(si->last_access_time); 681 vi->i_atime = timespec_to_timespec64(ntfs2utc(si->last_access_time));
682 682
683 /* Find the attribute list attribute if present. */ 683 /* Find the attribute list attribute if present. */
684 ntfs_attr_reinit_search_ctx(ctx); 684 ntfs_attr_reinit_search_ctx(ctx);
@@ -2804,11 +2804,11 @@ done:
2804 * for real. 2804 * for real.
2805 */ 2805 */
2806 if (!IS_NOCMTIME(VFS_I(base_ni)) && !IS_RDONLY(VFS_I(base_ni))) { 2806 if (!IS_NOCMTIME(VFS_I(base_ni)) && !IS_RDONLY(VFS_I(base_ni))) {
2807 struct timespec now = current_time(VFS_I(base_ni)); 2807 struct timespec64 now = current_time(VFS_I(base_ni));
2808 int sync_it = 0; 2808 int sync_it = 0;
2809 2809
2810 if (!timespec_equal(&VFS_I(base_ni)->i_mtime, &now) || 2810 if (!timespec64_equal(&VFS_I(base_ni)->i_mtime, &now) ||
2811 !timespec_equal(&VFS_I(base_ni)->i_ctime, &now)) 2811 !timespec64_equal(&VFS_I(base_ni)->i_ctime, &now))
2812 sync_it = 1; 2812 sync_it = 1;
2813 VFS_I(base_ni)->i_mtime = now; 2813 VFS_I(base_ni)->i_mtime = now;
2814 VFS_I(base_ni)->i_ctime = now; 2814 VFS_I(base_ni)->i_ctime = now;
@@ -2923,14 +2923,14 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr)
2923 } 2923 }
2924 } 2924 }
2925 if (ia_valid & ATTR_ATIME) 2925 if (ia_valid & ATTR_ATIME)
2926 vi->i_atime = timespec_trunc(attr->ia_atime, 2926 vi->i_atime = timespec64_trunc(attr->ia_atime,
2927 vi->i_sb->s_time_gran); 2927 vi->i_sb->s_time_gran);
2928 if (ia_valid & ATTR_MTIME) 2928 if (ia_valid & ATTR_MTIME)
2929 vi->i_mtime = timespec_trunc(attr->ia_mtime, 2929 vi->i_mtime = timespec64_trunc(attr->ia_mtime,
2930 vi->i_sb->s_time_gran); 2930 vi->i_sb->s_time_gran);
2931 if (ia_valid & ATTR_CTIME) 2931 if (ia_valid & ATTR_CTIME)
2932 vi->i_ctime = timespec_trunc(attr->ia_ctime, 2932 vi->i_ctime = timespec64_trunc(attr->ia_ctime,
2933 vi->i_sb->s_time_gran); 2933 vi->i_sb->s_time_gran);
2934 mark_inode_dirty(vi); 2934 mark_inode_dirty(vi);
2935out: 2935out:
2936 return err; 2936 return err;
@@ -2997,7 +2997,7 @@ int __ntfs_write_inode(struct inode *vi, int sync)
2997 si = (STANDARD_INFORMATION*)((u8*)ctx->attr + 2997 si = (STANDARD_INFORMATION*)((u8*)ctx->attr +
2998 le16_to_cpu(ctx->attr->data.resident.value_offset)); 2998 le16_to_cpu(ctx->attr->data.resident.value_offset));
2999 /* Update the access times if they have changed. */ 2999 /* Update the access times if they have changed. */
3000 nt = utc2ntfs(vi->i_mtime); 3000 nt = utc2ntfs(timespec64_to_timespec(vi->i_mtime));
3001 if (si->last_data_change_time != nt) { 3001 if (si->last_data_change_time != nt) {
3002 ntfs_debug("Updating mtime for inode 0x%lx: old = 0x%llx, " 3002 ntfs_debug("Updating mtime for inode 0x%lx: old = 0x%llx, "
3003 "new = 0x%llx", vi->i_ino, (long long) 3003 "new = 0x%llx", vi->i_ino, (long long)
@@ -3006,7 +3006,7 @@ int __ntfs_write_inode(struct inode *vi, int sync)
3006 si->last_data_change_time = nt; 3006 si->last_data_change_time = nt;
3007 modified = true; 3007 modified = true;
3008 } 3008 }
3009 nt = utc2ntfs(vi->i_ctime); 3009 nt = utc2ntfs(timespec64_to_timespec(vi->i_ctime));
3010 if (si->last_mft_change_time != nt) { 3010 if (si->last_mft_change_time != nt) {
3011 ntfs_debug("Updating ctime for inode 0x%lx: old = 0x%llx, " 3011 ntfs_debug("Updating ctime for inode 0x%lx: old = 0x%llx, "
3012 "new = 0x%llx", vi->i_ino, (long long) 3012 "new = 0x%llx", vi->i_ino, (long long)
@@ -3015,7 +3015,7 @@ int __ntfs_write_inode(struct inode *vi, int sync)
3015 si->last_mft_change_time = nt; 3015 si->last_mft_change_time = nt;
3016 modified = true; 3016 modified = true;
3017 } 3017 }
3018 nt = utc2ntfs(vi->i_atime); 3018 nt = utc2ntfs(timespec64_to_timespec(vi->i_atime));
3019 if (si->last_access_time != nt) { 3019 if (si->last_access_time != nt) {
3020 ntfs_debug("Updating atime for inode 0x%lx: old = 0x%llx, " 3020 ntfs_debug("Updating atime for inode 0x%lx: old = 0x%llx, "
3021 "new = 0x%llx", vi->i_ino, 3021 "new = 0x%llx", vi->i_ino,