diff options
author | David Howells <dhowells@redhat.com> | 2018-04-04 08:41:28 -0400 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2018-04-06 09:05:14 -0400 |
commit | ee1235a9a06813429c201bf186397a6feeea07bf (patch) | |
tree | 444566605bfafce0b155a76e061a73c264329424 /fs/9p | |
parent | 402cb8dda949d9b8c0df20ad2527d139faad7ca1 (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/9p')
-rw-r--r-- | fs/9p/cache.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/fs/9p/cache.c b/fs/9p/cache.c index 9d0030af5672..9eb34701a566 100644 --- a/fs/9p/cache.c +++ b/fs/9p/cache.c | |||
@@ -75,7 +75,7 @@ void v9fs_cache_session_get_cookie(struct v9fs_session_info *v9ses) | |||
75 | v9ses->cachetag, | 75 | v9ses->cachetag, |
76 | strlen(v9ses->cachetag), | 76 | strlen(v9ses->cachetag), |
77 | NULL, 0, | 77 | NULL, 0, |
78 | v9ses, true); | 78 | v9ses, 0, true); |
79 | p9_debug(P9_DEBUG_FSC, "session %p get cookie %p\n", | 79 | p9_debug(P9_DEBUG_FSC, "session %p get cookie %p\n", |
80 | v9ses, v9ses->fscache); | 80 | v9ses, v9ses->fscache); |
81 | } | 81 | } |
@@ -88,20 +88,11 @@ void v9fs_cache_session_put_cookie(struct v9fs_session_info *v9ses) | |||
88 | v9ses->fscache = NULL; | 88 | v9ses->fscache = NULL; |
89 | } | 89 | } |
90 | 90 | ||
91 | static void v9fs_cache_inode_get_attr(const void *cookie_netfs_data, | ||
92 | uint64_t *size) | ||
93 | { | ||
94 | const struct v9fs_inode *v9inode = cookie_netfs_data; | ||
95 | *size = i_size_read(&v9inode->vfs_inode); | ||
96 | |||
97 | p9_debug(P9_DEBUG_FSC, "inode %p get attr %llu\n", | ||
98 | &v9inode->vfs_inode, *size); | ||
99 | } | ||
100 | |||
101 | static enum | 91 | static enum |
102 | fscache_checkaux v9fs_cache_inode_check_aux(void *cookie_netfs_data, | 92 | fscache_checkaux v9fs_cache_inode_check_aux(void *cookie_netfs_data, |
103 | const void *buffer, | 93 | const void *buffer, |
104 | uint16_t buflen) | 94 | uint16_t buflen, |
95 | loff_t object_size) | ||
105 | { | 96 | { |
106 | const struct v9fs_inode *v9inode = cookie_netfs_data; | 97 | const struct v9fs_inode *v9inode = cookie_netfs_data; |
107 | 98 | ||
@@ -118,7 +109,6 @@ fscache_checkaux v9fs_cache_inode_check_aux(void *cookie_netfs_data, | |||
118 | const struct fscache_cookie_def v9fs_cache_inode_index_def = { | 109 | const struct fscache_cookie_def v9fs_cache_inode_index_def = { |
119 | .name = "9p.inode", | 110 | .name = "9p.inode", |
120 | .type = FSCACHE_COOKIE_TYPE_DATAFILE, | 111 | .type = FSCACHE_COOKIE_TYPE_DATAFILE, |
121 | .get_attr = v9fs_cache_inode_get_attr, | ||
122 | .check_aux = v9fs_cache_inode_check_aux, | 112 | .check_aux = v9fs_cache_inode_check_aux, |
123 | }; | 113 | }; |
124 | 114 | ||
@@ -141,7 +131,9 @@ void v9fs_cache_inode_get_cookie(struct inode *inode) | |||
141 | sizeof(v9inode->qid.path), | 131 | sizeof(v9inode->qid.path), |
142 | &v9inode->qid.version, | 132 | &v9inode->qid.version, |
143 | sizeof(v9inode->qid.version), | 133 | sizeof(v9inode->qid.version), |
144 | v9inode, true); | 134 | v9inode, |
135 | i_size_read(&v9inode->vfs_inode), | ||
136 | true); | ||
145 | 137 | ||
146 | p9_debug(P9_DEBUG_FSC, "inode %p get cookie %p\n", | 138 | p9_debug(P9_DEBUG_FSC, "inode %p get cookie %p\n", |
147 | inode, v9inode->fscache); | 139 | inode, v9inode->fscache); |
@@ -212,7 +204,9 @@ void v9fs_cache_inode_reset_cookie(struct inode *inode) | |||
212 | sizeof(v9inode->qid.path), | 204 | sizeof(v9inode->qid.path), |
213 | &v9inode->qid.version, | 205 | &v9inode->qid.version, |
214 | sizeof(v9inode->qid.version), | 206 | sizeof(v9inode->qid.version), |
215 | v9inode, true); | 207 | v9inode, |
208 | i_size_read(&v9inode->vfs_inode), | ||
209 | true); | ||
216 | p9_debug(P9_DEBUG_FSC, "inode %p revalidating cookie old %p new %p\n", | 210 | p9_debug(P9_DEBUG_FSC, "inode %p revalidating cookie old %p new %p\n", |
217 | inode, old, v9inode->fscache); | 211 | inode, old, v9inode->fscache); |
218 | 212 | ||
@@ -338,7 +332,8 @@ void __v9fs_readpage_to_fscache(struct inode *inode, struct page *page) | |||
338 | const struct v9fs_inode *v9inode = V9FS_I(inode); | 332 | const struct v9fs_inode *v9inode = V9FS_I(inode); |
339 | 333 | ||
340 | p9_debug(P9_DEBUG_FSC, "inode %p page %p\n", inode, page); | 334 | p9_debug(P9_DEBUG_FSC, "inode %p page %p\n", inode, page); |
341 | ret = fscache_write_page(v9inode->fscache, page, GFP_KERNEL); | 335 | ret = fscache_write_page(v9inode->fscache, page, |
336 | i_size_read(&v9inode->vfs_inode), GFP_KERNEL); | ||
342 | p9_debug(P9_DEBUG_FSC, "ret = %d\n", ret); | 337 | p9_debug(P9_DEBUG_FSC, "ret = %d\n", ret); |
343 | if (ret != 0) | 338 | if (ret != 0) |
344 | v9fs_uncache_page(inode, page); | 339 | v9fs_uncache_page(inode, page); |