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/fscache | |
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/fscache')
-rw-r--r-- | fs/fscache/cookie.c | 18 | ||||
-rw-r--r-- | fs/fscache/fsdef.c | 6 | ||||
-rw-r--r-- | fs/fscache/object.c | 5 | ||||
-rw-r--r-- | fs/fscache/page.c | 5 |
4 files changed, 21 insertions, 13 deletions
diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c index 4d6210082a60..8ca9a932d225 100644 --- a/fs/fscache/cookie.c +++ b/fs/fscache/cookie.c | |||
@@ -21,7 +21,8 @@ struct kmem_cache *fscache_cookie_jar; | |||
21 | 21 | ||
22 | static atomic_t fscache_object_debug_id = ATOMIC_INIT(0); | 22 | static atomic_t fscache_object_debug_id = ATOMIC_INIT(0); |
23 | 23 | ||
24 | static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie); | 24 | static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie, |
25 | loff_t object_size); | ||
25 | static int fscache_alloc_object(struct fscache_cache *cache, | 26 | static int fscache_alloc_object(struct fscache_cache *cache, |
26 | struct fscache_cookie *cookie); | 27 | struct fscache_cookie *cookie); |
27 | static int fscache_attach_object(struct fscache_cookie *cookie, | 28 | static int fscache_attach_object(struct fscache_cookie *cookie, |
@@ -61,6 +62,7 @@ struct fscache_cookie *__fscache_acquire_cookie( | |||
61 | const void *index_key, size_t index_key_len, | 62 | const void *index_key, size_t index_key_len, |
62 | const void *aux_data, size_t aux_data_len, | 63 | const void *aux_data, size_t aux_data_len, |
63 | void *netfs_data, | 64 | void *netfs_data, |
65 | loff_t object_size, | ||
64 | bool enable) | 66 | bool enable) |
65 | { | 67 | { |
66 | struct fscache_cookie *cookie; | 68 | struct fscache_cookie *cookie; |
@@ -160,7 +162,7 @@ struct fscache_cookie *__fscache_acquire_cookie( | |||
160 | * - we create indices on disk when we need them as an index | 162 | * - we create indices on disk when we need them as an index |
161 | * may exist in multiple caches */ | 163 | * may exist in multiple caches */ |
162 | if (cookie->type != FSCACHE_COOKIE_TYPE_INDEX) { | 164 | if (cookie->type != FSCACHE_COOKIE_TYPE_INDEX) { |
163 | if (fscache_acquire_non_index_cookie(cookie) == 0) { | 165 | if (fscache_acquire_non_index_cookie(cookie, object_size) == 0) { |
164 | set_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags); | 166 | set_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags); |
165 | } else { | 167 | } else { |
166 | atomic_dec(&parent->n_children); | 168 | atomic_dec(&parent->n_children); |
@@ -194,6 +196,7 @@ EXPORT_SYMBOL(__fscache_acquire_cookie); | |||
194 | */ | 196 | */ |
195 | void __fscache_enable_cookie(struct fscache_cookie *cookie, | 197 | void __fscache_enable_cookie(struct fscache_cookie *cookie, |
196 | const void *aux_data, | 198 | const void *aux_data, |
199 | loff_t object_size, | ||
197 | bool (*can_enable)(void *data), | 200 | bool (*can_enable)(void *data), |
198 | void *data) | 201 | void *data) |
199 | { | 202 | { |
@@ -215,7 +218,7 @@ void __fscache_enable_cookie(struct fscache_cookie *cookie, | |||
215 | /* Wait for outstanding disablement to complete */ | 218 | /* Wait for outstanding disablement to complete */ |
216 | __fscache_wait_on_invalidate(cookie); | 219 | __fscache_wait_on_invalidate(cookie); |
217 | 220 | ||
218 | if (fscache_acquire_non_index_cookie(cookie) == 0) | 221 | if (fscache_acquire_non_index_cookie(cookie, object_size) == 0) |
219 | set_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags); | 222 | set_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags); |
220 | } else { | 223 | } else { |
221 | set_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags); | 224 | set_bit(FSCACHE_COOKIE_ENABLED, &cookie->flags); |
@@ -232,11 +235,11 @@ EXPORT_SYMBOL(__fscache_enable_cookie); | |||
232 | * - this must make sure the index chain is instantiated and instantiate the | 235 | * - this must make sure the index chain is instantiated and instantiate the |
233 | * object representation too | 236 | * object representation too |
234 | */ | 237 | */ |
235 | static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie) | 238 | static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie, |
239 | loff_t object_size) | ||
236 | { | 240 | { |
237 | struct fscache_object *object; | 241 | struct fscache_object *object; |
238 | struct fscache_cache *cache; | 242 | struct fscache_cache *cache; |
239 | uint64_t i_size; | ||
240 | int ret; | 243 | int ret; |
241 | 244 | ||
242 | _enter(""); | 245 | _enter(""); |
@@ -275,9 +278,6 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie) | |||
275 | return ret; | 278 | return ret; |
276 | } | 279 | } |
277 | 280 | ||
278 | /* pass on how big the object we're caching is supposed to be */ | ||
279 | cookie->def->get_attr(cookie->netfs_data, &i_size); | ||
280 | |||
281 | spin_lock(&cookie->lock); | 281 | spin_lock(&cookie->lock); |
282 | if (hlist_empty(&cookie->backing_objects)) { | 282 | if (hlist_empty(&cookie->backing_objects)) { |
283 | spin_unlock(&cookie->lock); | 283 | spin_unlock(&cookie->lock); |
@@ -287,7 +287,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie) | |||
287 | object = hlist_entry(cookie->backing_objects.first, | 287 | object = hlist_entry(cookie->backing_objects.first, |
288 | struct fscache_object, cookie_link); | 288 | struct fscache_object, cookie_link); |
289 | 289 | ||
290 | fscache_set_store_limit(object, i_size); | 290 | fscache_set_store_limit(object, object_size); |
291 | 291 | ||
292 | /* initiate the process of looking up all the objects in the chain | 292 | /* initiate the process of looking up all the objects in the chain |
293 | * (done by fscache_initialise_object()) */ | 293 | * (done by fscache_initialise_object()) */ |
diff --git a/fs/fscache/fsdef.c b/fs/fscache/fsdef.c index 1122e97d56e8..aa46e48d8c75 100644 --- a/fs/fscache/fsdef.c +++ b/fs/fscache/fsdef.c | |||
@@ -16,7 +16,8 @@ | |||
16 | static | 16 | static |
17 | enum fscache_checkaux fscache_fsdef_netfs_check_aux(void *cookie_netfs_data, | 17 | enum fscache_checkaux fscache_fsdef_netfs_check_aux(void *cookie_netfs_data, |
18 | const void *data, | 18 | const void *data, |
19 | uint16_t datalen); | 19 | uint16_t datalen, |
20 | loff_t object_size); | ||
20 | 21 | ||
21 | /* | 22 | /* |
22 | * The root index is owned by FS-Cache itself. | 23 | * The root index is owned by FS-Cache itself. |
@@ -76,7 +77,8 @@ struct fscache_cookie_def fscache_fsdef_netfs_def = { | |||
76 | static enum fscache_checkaux fscache_fsdef_netfs_check_aux( | 77 | static enum fscache_checkaux fscache_fsdef_netfs_check_aux( |
77 | void *cookie_netfs_data, | 78 | void *cookie_netfs_data, |
78 | const void *data, | 79 | const void *data, |
79 | uint16_t datalen) | 80 | uint16_t datalen, |
81 | loff_t object_size) | ||
80 | { | 82 | { |
81 | struct fscache_netfs *netfs = cookie_netfs_data; | 83 | struct fscache_netfs *netfs = cookie_netfs_data; |
82 | uint32_t version; | 84 | uint32_t version; |
diff --git a/fs/fscache/object.c b/fs/fscache/object.c index a7b28f876fde..1085ca12e25c 100644 --- a/fs/fscache/object.c +++ b/fs/fscache/object.c | |||
@@ -922,7 +922,8 @@ static void fscache_dequeue_object(struct fscache_object *object) | |||
922 | * and creation). | 922 | * and creation). |
923 | */ | 923 | */ |
924 | enum fscache_checkaux fscache_check_aux(struct fscache_object *object, | 924 | enum fscache_checkaux fscache_check_aux(struct fscache_object *object, |
925 | const void *data, uint16_t datalen) | 925 | const void *data, uint16_t datalen, |
926 | loff_t object_size) | ||
926 | { | 927 | { |
927 | enum fscache_checkaux result; | 928 | enum fscache_checkaux result; |
928 | 929 | ||
@@ -932,7 +933,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object, | |||
932 | } | 933 | } |
933 | 934 | ||
934 | result = object->cookie->def->check_aux(object->cookie->netfs_data, | 935 | result = object->cookie->def->check_aux(object->cookie->netfs_data, |
935 | data, datalen); | 936 | data, datalen, object_size); |
936 | switch (result) { | 937 | switch (result) { |
937 | /* entry okay as is */ | 938 | /* entry okay as is */ |
938 | case FSCACHE_CHECKAUX_OKAY: | 939 | case FSCACHE_CHECKAUX_OKAY: |
diff --git a/fs/fscache/page.c b/fs/fscache/page.c index 810b33aced1c..111349f67d98 100644 --- a/fs/fscache/page.c +++ b/fs/fscache/page.c | |||
@@ -963,6 +963,7 @@ void fscache_invalidate_writes(struct fscache_cookie *cookie) | |||
963 | */ | 963 | */ |
964 | int __fscache_write_page(struct fscache_cookie *cookie, | 964 | int __fscache_write_page(struct fscache_cookie *cookie, |
965 | struct page *page, | 965 | struct page *page, |
966 | loff_t object_size, | ||
966 | gfp_t gfp) | 967 | gfp_t gfp) |
967 | { | 968 | { |
968 | struct fscache_storage *op; | 969 | struct fscache_storage *op; |
@@ -1014,6 +1015,10 @@ int __fscache_write_page(struct fscache_cookie *cookie, | |||
1014 | /* add the page to the pending-storage radix tree on the backing | 1015 | /* add the page to the pending-storage radix tree on the backing |
1015 | * object */ | 1016 | * object */ |
1016 | spin_lock(&object->lock); | 1017 | spin_lock(&object->lock); |
1018 | |||
1019 | if (object->store_limit_l != object_size) | ||
1020 | fscache_set_store_limit(object, object_size); | ||
1021 | |||
1017 | spin_lock(&cookie->stores_lock); | 1022 | spin_lock(&cookie->stores_lock); |
1018 | 1023 | ||
1019 | _debug("store limit %llx", (unsigned long long) object->store_limit); | 1024 | _debug("store limit %llx", (unsigned long long) object->store_limit); |