summaryrefslogtreecommitdiffstats
path: root/fs/ceph/cache.c
diff options
context:
space:
mode:
authorYan, Zheng <zyan@redhat.com>2015-12-29 22:32:46 -0500
committerIlya Dryomov <idryomov@gmail.com>2016-01-21 13:36:08 -0500
commit99c88e6900fb05d267ae9f6d5e15dc7192ba6f8d (patch)
tree025263471172932f2c0b332979cf56c60ae836db /fs/ceph/cache.c
parent5be0389dac662995eade757ec678931f0be23d33 (diff)
ceph: use i_size_{read,write} to get/set i_size
Cap message from MDS can update i_size. In that case, we don't hold i_mutex. So it's unsafe to directly access inode->i_size while holding i_mutex. Signed-off-by: Yan, Zheng <zyan@redhat.com>
Diffstat (limited to 'fs/ceph/cache.c')
-rw-r--r--fs/ceph/cache.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/fs/ceph/cache.c b/fs/ceph/cache.c
index a4766ded1ba7..16e7f7b60691 100644
--- a/fs/ceph/cache.c
+++ b/fs/ceph/cache.c
@@ -106,7 +106,7 @@ static uint16_t ceph_fscache_inode_get_aux(const void *cookie_netfs_data,
106 106
107 memset(&aux, 0, sizeof(aux)); 107 memset(&aux, 0, sizeof(aux));
108 aux.mtime = inode->i_mtime; 108 aux.mtime = inode->i_mtime;
109 aux.size = inode->i_size; 109 aux.size = i_size_read(inode);
110 110
111 memcpy(buffer, &aux, sizeof(aux)); 111 memcpy(buffer, &aux, sizeof(aux));
112 112
@@ -117,9 +117,7 @@ static void ceph_fscache_inode_get_attr(const void *cookie_netfs_data,
117 uint64_t *size) 117 uint64_t *size)
118{ 118{
119 const struct ceph_inode_info* ci = cookie_netfs_data; 119 const struct ceph_inode_info* ci = cookie_netfs_data;
120 const struct inode* inode = &ci->vfs_inode; 120 *size = i_size_read(&ci->vfs_inode);
121
122 *size = inode->i_size;
123} 121}
124 122
125static enum fscache_checkaux ceph_fscache_inode_check_aux( 123static enum fscache_checkaux ceph_fscache_inode_check_aux(
@@ -134,7 +132,7 @@ static enum fscache_checkaux ceph_fscache_inode_check_aux(
134 132
135 memset(&aux, 0, sizeof(aux)); 133 memset(&aux, 0, sizeof(aux));
136 aux.mtime = inode->i_mtime; 134 aux.mtime = inode->i_mtime;
137 aux.size = inode->i_size; 135 aux.size = i_size_read(inode);
138 136
139 if (memcmp(data, &aux, sizeof(aux)) != 0) 137 if (memcmp(data, &aux, sizeof(aux)) != 0)
140 return FSCACHE_CHECKAUX_OBSOLETE; 138 return FSCACHE_CHECKAUX_OBSOLETE;