diff options
author | Deepa Dinamani <deepa.kernel@gmail.com> | 2016-02-22 10:17:53 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-03-29 13:11:44 -0400 |
commit | 3a3a5fece6f28c14d3d05c74fb7696412e53a067 (patch) | |
tree | 9668de3af8008ff45cceda5c820711afead4bf1a | |
parent | 1b48b530dac3e600d92854d98a2a519243661f6c (diff) |
fs: kernfs: Replace CURRENT_TIME by current_fs_time()
This is in preparation for the series that transitions
filesystem timestamps to use 64 bit time and hence make
them y2038 safe.
CURRENT_TIME macro will be deleted before merging the
aforementioned series.
Use current_fs_time() instead of CURRENT_TIME for inode
timestamps.
struct kernfs_node is associated with a sysfs file/ directory.
Truncate the values to appropriate time granularity when
writing to inode timestamps of the files.
ktime_get_real_ts() is used to obtain times for
struct kernfs_iattrs. Since these times are later assigned to
inode times using timespec_truncate() for all filesystem based
operations, we can save the supers list traversal time here by
using ktime_get_real_ts() directly.
Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | fs/kernfs/dir.c | 8 | ||||
-rw-r--r-- | fs/kernfs/inode.c | 15 |
2 files changed, 15 insertions, 8 deletions
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index 03b688d19f69..eb2c58732bcf 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c | |||
@@ -753,7 +753,8 @@ int kernfs_add_one(struct kernfs_node *kn) | |||
753 | ps_iattr = parent->iattr; | 753 | ps_iattr = parent->iattr; |
754 | if (ps_iattr) { | 754 | if (ps_iattr) { |
755 | struct iattr *ps_iattrs = &ps_iattr->ia_iattr; | 755 | struct iattr *ps_iattrs = &ps_iattr->ia_iattr; |
756 | ps_iattrs->ia_ctime = ps_iattrs->ia_mtime = CURRENT_TIME; | 756 | ktime_get_real_ts(&ps_iattrs->ia_ctime); |
757 | ps_iattrs->ia_mtime = ps_iattrs->ia_ctime; | ||
757 | } | 758 | } |
758 | 759 | ||
759 | mutex_unlock(&kernfs_mutex); | 760 | mutex_unlock(&kernfs_mutex); |
@@ -1279,8 +1280,9 @@ static void __kernfs_remove(struct kernfs_node *kn) | |||
1279 | 1280 | ||
1280 | /* update timestamps on the parent */ | 1281 | /* update timestamps on the parent */ |
1281 | if (ps_iattr) { | 1282 | if (ps_iattr) { |
1282 | ps_iattr->ia_iattr.ia_ctime = CURRENT_TIME; | 1283 | ktime_get_real_ts(&ps_iattr->ia_iattr.ia_ctime); |
1283 | ps_iattr->ia_iattr.ia_mtime = CURRENT_TIME; | 1284 | ps_iattr->ia_iattr.ia_mtime = |
1285 | ps_iattr->ia_iattr.ia_ctime; | ||
1284 | } | 1286 | } |
1285 | 1287 | ||
1286 | kernfs_put(pos); | 1288 | kernfs_put(pos); |
diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c index 16405ae88d2d..1ac1dbae5aba 100644 --- a/fs/kernfs/inode.c +++ b/fs/kernfs/inode.c | |||
@@ -54,7 +54,10 @@ static struct kernfs_iattrs *kernfs_iattrs(struct kernfs_node *kn) | |||
54 | iattrs->ia_mode = kn->mode; | 54 | iattrs->ia_mode = kn->mode; |
55 | iattrs->ia_uid = GLOBAL_ROOT_UID; | 55 | iattrs->ia_uid = GLOBAL_ROOT_UID; |
56 | iattrs->ia_gid = GLOBAL_ROOT_GID; | 56 | iattrs->ia_gid = GLOBAL_ROOT_GID; |
57 | iattrs->ia_atime = iattrs->ia_mtime = iattrs->ia_ctime = CURRENT_TIME; | 57 | |
58 | ktime_get_real_ts(&iattrs->ia_atime); | ||
59 | iattrs->ia_mtime = iattrs->ia_atime; | ||
60 | iattrs->ia_ctime = iattrs->ia_atime; | ||
58 | 61 | ||
59 | simple_xattrs_init(&kn->iattr->xattrs); | 62 | simple_xattrs_init(&kn->iattr->xattrs); |
60 | out_unlock: | 63 | out_unlock: |
@@ -236,16 +239,18 @@ ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size) | |||
236 | static inline void set_default_inode_attr(struct inode *inode, umode_t mode) | 239 | static inline void set_default_inode_attr(struct inode *inode, umode_t mode) |
237 | { | 240 | { |
238 | inode->i_mode = mode; | 241 | inode->i_mode = mode; |
239 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 242 | inode->i_atime = inode->i_mtime = |
243 | inode->i_ctime = current_fs_time(inode->i_sb); | ||
240 | } | 244 | } |
241 | 245 | ||
242 | static inline void set_inode_attr(struct inode *inode, struct iattr *iattr) | 246 | static inline void set_inode_attr(struct inode *inode, struct iattr *iattr) |
243 | { | 247 | { |
248 | struct super_block *sb = inode->i_sb; | ||
244 | inode->i_uid = iattr->ia_uid; | 249 | inode->i_uid = iattr->ia_uid; |
245 | inode->i_gid = iattr->ia_gid; | 250 | inode->i_gid = iattr->ia_gid; |
246 | inode->i_atime = iattr->ia_atime; | 251 | inode->i_atime = timespec_trunc(iattr->ia_atime, sb->s_time_gran); |
247 | inode->i_mtime = iattr->ia_mtime; | 252 | inode->i_mtime = timespec_trunc(iattr->ia_mtime, sb->s_time_gran); |
248 | inode->i_ctime = iattr->ia_ctime; | 253 | inode->i_ctime = timespec_trunc(iattr->ia_ctime, sb->s_time_gran); |
249 | } | 254 | } |
250 | 255 | ||
251 | static void kernfs_refresh_inode(struct kernfs_node *kn, struct inode *inode) | 256 | static void kernfs_refresh_inode(struct kernfs_node *kn, struct inode *inode) |