aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2018-04-04 08:41:28 -0400
committerDavid Howells <dhowells@redhat.com>2018-04-06 09:05:14 -0400
commitee1235a9a06813429c201bf186397a6feeea07bf (patch)
tree444566605bfafce0b155a76e061a73c264329424 /fs/ceph
parent402cb8dda949d9b8c0df20ad2527d139faad7ca1 (diff)
fscache: Pass object size in rather than calling back for it
Pass the object size in to fscache_acquire_cookie() and fscache_write_page() rather than the netfs providing a callback by which it can be received. This makes it easier to update the size of the object when a new page is written that extends the object. The current object size is also passed by fscache to the check_aux function, obviating the need to store it in the aux data. Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Anna Schumaker <anna.schumaker@netapp.com> Tested-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'fs/ceph')
-rw-r--r--fs/ceph/cache.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/fs/ceph/cache.c b/fs/ceph/cache.c
index fee869061f05..33a211b364ed 100644
--- a/fs/ceph/cache.c
+++ b/fs/ceph/cache.c
@@ -27,7 +27,6 @@
27struct ceph_aux_inode { 27struct ceph_aux_inode {
28 u64 version; 28 u64 version;
29 struct timespec mtime; 29 struct timespec mtime;
30 loff_t size;
31}; 30};
32 31
33struct fscache_netfs ceph_cache_netfs = { 32struct fscache_netfs ceph_cache_netfs = {
@@ -101,7 +100,7 @@ int ceph_fscache_register_fs(struct ceph_fs_client* fsc)
101 &ceph_fscache_fsid_object_def, 100 &ceph_fscache_fsid_object_def,
102 &ent->fsid, sizeof(ent->fsid) + uniq_len, 101 &ent->fsid, sizeof(ent->fsid) + uniq_len,
103 NULL, 0, 102 NULL, 0,
104 fsc, true); 103 fsc, 0, true);
105 104
106 if (fsc->fscache) { 105 if (fsc->fscache) {
107 ent->fscache = fsc->fscache; 106 ent->fscache = fsc->fscache;
@@ -117,27 +116,21 @@ out_unlock:
117 return err; 116 return err;
118} 117}
119 118
120static void ceph_fscache_inode_get_attr(const void *cookie_netfs_data,
121 uint64_t *size)
122{
123 const struct ceph_inode_info* ci = cookie_netfs_data;
124 *size = i_size_read(&ci->vfs_inode);
125}
126
127static enum fscache_checkaux ceph_fscache_inode_check_aux( 119static enum fscache_checkaux ceph_fscache_inode_check_aux(
128 void *cookie_netfs_data, const void *data, uint16_t dlen) 120 void *cookie_netfs_data, const void *data, uint16_t dlen,
121 loff_t object_size)
129{ 122{
130 struct ceph_aux_inode aux; 123 struct ceph_aux_inode aux;
131 struct ceph_inode_info* ci = cookie_netfs_data; 124 struct ceph_inode_info* ci = cookie_netfs_data;
132 struct inode* inode = &ci->vfs_inode; 125 struct inode* inode = &ci->vfs_inode;
133 126
134 if (dlen != sizeof(aux)) 127 if (dlen != sizeof(aux) ||
128 i_size_read(inode) != object_size)
135 return FSCACHE_CHECKAUX_OBSOLETE; 129 return FSCACHE_CHECKAUX_OBSOLETE;
136 130
137 memset(&aux, 0, sizeof(aux)); 131 memset(&aux, 0, sizeof(aux));
138 aux.version = ci->i_version; 132 aux.version = ci->i_version;
139 aux.mtime = inode->i_mtime; 133 aux.mtime = inode->i_mtime;
140 aux.size = i_size_read(inode);
141 134
142 if (memcmp(data, &aux, sizeof(aux)) != 0) 135 if (memcmp(data, &aux, sizeof(aux)) != 0)
143 return FSCACHE_CHECKAUX_OBSOLETE; 136 return FSCACHE_CHECKAUX_OBSOLETE;
@@ -149,7 +142,6 @@ static enum fscache_checkaux ceph_fscache_inode_check_aux(
149static const struct fscache_cookie_def ceph_fscache_inode_object_def = { 142static const struct fscache_cookie_def ceph_fscache_inode_object_def = {
150 .name = "CEPH.inode", 143 .name = "CEPH.inode",
151 .type = FSCACHE_COOKIE_TYPE_DATAFILE, 144 .type = FSCACHE_COOKIE_TYPE_DATAFILE,
152 .get_attr = ceph_fscache_inode_get_attr,
153 .check_aux = ceph_fscache_inode_check_aux, 145 .check_aux = ceph_fscache_inode_check_aux,
154}; 146};
155 147
@@ -172,12 +164,11 @@ void ceph_fscache_register_inode_cookie(struct inode *inode)
172 memset(&aux, 0, sizeof(aux)); 164 memset(&aux, 0, sizeof(aux));
173 aux.version = ci->i_version; 165 aux.version = ci->i_version;
174 aux.mtime = inode->i_mtime; 166 aux.mtime = inode->i_mtime;
175 aux.size = i_size_read(inode);
176 ci->fscache = fscache_acquire_cookie(fsc->fscache, 167 ci->fscache = fscache_acquire_cookie(fsc->fscache,
177 &ceph_fscache_inode_object_def, 168 &ceph_fscache_inode_object_def,
178 &ci->i_vino, sizeof(ci->i_vino), 169 &ci->i_vino, sizeof(ci->i_vino),
179 &aux, sizeof(aux), 170 &aux, sizeof(aux),
180 ci, false); 171 ci, i_size_read(inode), false);
181 } 172 }
182 inode_unlock(inode); 173 inode_unlock(inode);
183} 174}
@@ -214,7 +205,7 @@ void ceph_fscache_file_set_cookie(struct inode *inode, struct file *filp)
214 fscache_disable_cookie(ci->fscache, &ci->i_vino, false); 205 fscache_disable_cookie(ci->fscache, &ci->i_vino, false);
215 fscache_uncache_all_inode_pages(ci->fscache, inode); 206 fscache_uncache_all_inode_pages(ci->fscache, inode);
216 } else { 207 } else {
217 fscache_enable_cookie(ci->fscache, &ci->i_vino, 208 fscache_enable_cookie(ci->fscache, &ci->i_vino, i_size_read(inode),
218 ceph_fscache_can_enable, inode); 209 ceph_fscache_can_enable, inode);
219 if (fscache_cookie_enabled(ci->fscache)) { 210 if (fscache_cookie_enabled(ci->fscache)) {
220 dout("fscache_file_set_cookie %p %p enabling cache\n", 211 dout("fscache_file_set_cookie %p %p enabling cache\n",
@@ -308,7 +299,8 @@ void ceph_readpage_to_fscache(struct inode *inode, struct page *page)
308 if (!cache_valid(ci)) 299 if (!cache_valid(ci))
309 return; 300 return;
310 301
311 ret = fscache_write_page(ci->fscache, page, GFP_KERNEL); 302 ret = fscache_write_page(ci->fscache, page, i_size_read(inode),
303 GFP_KERNEL);
312 if (ret) 304 if (ret)
313 fscache_uncache_page(ci->fscache, page); 305 fscache_uncache_page(ci->fscache, page);
314} 306}