diff options
author | Yan, Zheng <zyan@redhat.com> | 2017-06-01 05:08:00 -0400 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2017-06-14 13:37:23 -0400 |
commit | 4ca2fea6f8277ab381bd08b996d641255b6f7b00 (patch) | |
tree | 41f6e229a7e7c5279f94512e72b088adc30bd66a | |
parent | 56199016e8672feb7b903eda003a863d5bf2b8c4 (diff) |
ceph: unify inode i_ctime update
Current __ceph_setattr() can set inode's i_ctime to current_time(),
req->r_stamp or attr->ia_ctime. These time stamps may have minor
differences. It may cause potential problem.
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
-rw-r--r-- | fs/ceph/acl.c | 1 | ||||
-rw-r--r-- | fs/ceph/inode.c | 5 |
2 files changed, 3 insertions, 3 deletions
diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c index 987044bca1c2..59cb307b15fb 100644 --- a/fs/ceph/acl.c +++ b/fs/ceph/acl.c | |||
@@ -131,6 +131,7 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type) | |||
131 | } | 131 | } |
132 | 132 | ||
133 | if (new_mode != old_mode) { | 133 | if (new_mode != old_mode) { |
134 | newattrs.ia_ctime = current_time(inode); | ||
134 | newattrs.ia_mode = new_mode; | 135 | newattrs.ia_mode = new_mode; |
135 | newattrs.ia_valid = ATTR_MODE; | 136 | newattrs.ia_valid = ATTR_MODE; |
136 | ret = __ceph_setattr(inode, &newattrs); | 137 | ret = __ceph_setattr(inode, &newattrs); |
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index dcce79b84406..4de6cdddf059 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c | |||
@@ -2022,7 +2022,6 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr) | |||
2022 | attr->ia_size > inode->i_size) { | 2022 | attr->ia_size > inode->i_size) { |
2023 | i_size_write(inode, attr->ia_size); | 2023 | i_size_write(inode, attr->ia_size); |
2024 | inode->i_blocks = calc_inode_blocks(attr->ia_size); | 2024 | inode->i_blocks = calc_inode_blocks(attr->ia_size); |
2025 | inode->i_ctime = attr->ia_ctime; | ||
2026 | ci->i_reported_size = attr->ia_size; | 2025 | ci->i_reported_size = attr->ia_size; |
2027 | dirtied |= CEPH_CAP_FILE_EXCL; | 2026 | dirtied |= CEPH_CAP_FILE_EXCL; |
2028 | } else if ((issued & CEPH_CAP_FILE_SHARED) == 0 || | 2027 | } else if ((issued & CEPH_CAP_FILE_SHARED) == 0 || |
@@ -2044,7 +2043,6 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr) | |||
2044 | inode->i_ctime.tv_sec, inode->i_ctime.tv_nsec, | 2043 | inode->i_ctime.tv_sec, inode->i_ctime.tv_nsec, |
2045 | attr->ia_ctime.tv_sec, attr->ia_ctime.tv_nsec, | 2044 | attr->ia_ctime.tv_sec, attr->ia_ctime.tv_nsec, |
2046 | only ? "ctime only" : "ignored"); | 2045 | only ? "ctime only" : "ignored"); |
2047 | inode->i_ctime = attr->ia_ctime; | ||
2048 | if (only) { | 2046 | if (only) { |
2049 | /* | 2047 | /* |
2050 | * if kernel wants to dirty ctime but nothing else, | 2048 | * if kernel wants to dirty ctime but nothing else, |
@@ -2067,7 +2065,7 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr) | |||
2067 | if (dirtied) { | 2065 | if (dirtied) { |
2068 | inode_dirty_flags = __ceph_mark_dirty_caps(ci, dirtied, | 2066 | inode_dirty_flags = __ceph_mark_dirty_caps(ci, dirtied, |
2069 | &prealloc_cf); | 2067 | &prealloc_cf); |
2070 | inode->i_ctime = current_time(inode); | 2068 | inode->i_ctime = attr->ia_ctime; |
2071 | } | 2069 | } |
2072 | 2070 | ||
2073 | release &= issued; | 2071 | release &= issued; |
@@ -2085,6 +2083,7 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr) | |||
2085 | req->r_inode_drop = release; | 2083 | req->r_inode_drop = release; |
2086 | req->r_args.setattr.mask = cpu_to_le32(mask); | 2084 | req->r_args.setattr.mask = cpu_to_le32(mask); |
2087 | req->r_num_caps = 1; | 2085 | req->r_num_caps = 1; |
2086 | req->r_stamp = attr->ia_ctime; | ||
2088 | err = ceph_mdsc_do_request(mdsc, NULL, req); | 2087 | err = ceph_mdsc_do_request(mdsc, NULL, req); |
2089 | } | 2088 | } |
2090 | dout("setattr %p result=%d (%s locally, %d remote)\n", inode, err, | 2089 | dout("setattr %p result=%d (%s locally, %d remote)\n", inode, err, |