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 /include/linux/fscache.h | |
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 'include/linux/fscache.h')
-rw-r--r-- | include/linux/fscache.h | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/include/linux/fscache.h b/include/linux/fscache.h index a2d3a2116248..eb38f39cf832 100644 --- a/include/linux/fscache.h +++ b/include/linux/fscache.h | |||
@@ -83,22 +83,15 @@ struct fscache_cookie_def { | |||
83 | const void *parent_netfs_data, | 83 | const void *parent_netfs_data, |
84 | const void *cookie_netfs_data); | 84 | const void *cookie_netfs_data); |
85 | 85 | ||
86 | /* get certain file attributes from the netfs data | ||
87 | * - this function can be absent for an index | ||
88 | * - not permitted to return an error | ||
89 | * - the netfs data from the cookie being used as the source is | ||
90 | * presented | ||
91 | */ | ||
92 | void (*get_attr)(const void *cookie_netfs_data, uint64_t *size); | ||
93 | |||
94 | /* consult the netfs about the state of an object | 86 | /* consult the netfs about the state of an object |
95 | * - this function can be absent if the index carries no state data | 87 | * - this function can be absent if the index carries no state data |
96 | * - the netfs data from the cookie being used as the target is | 88 | * - the netfs data from the cookie being used as the target is |
97 | * presented, as is the auxiliary data | 89 | * presented, as is the auxiliary data and the object size |
98 | */ | 90 | */ |
99 | enum fscache_checkaux (*check_aux)(void *cookie_netfs_data, | 91 | enum fscache_checkaux (*check_aux)(void *cookie_netfs_data, |
100 | const void *data, | 92 | const void *data, |
101 | uint16_t datalen); | 93 | uint16_t datalen, |
94 | loff_t object_size); | ||
102 | 95 | ||
103 | /* get an extra reference on a read context | 96 | /* get an extra reference on a read context |
104 | * - this function can be absent if the completion function doesn't | 97 | * - this function can be absent if the completion function doesn't |
@@ -200,7 +193,7 @@ extern struct fscache_cookie *__fscache_acquire_cookie( | |||
200 | const struct fscache_cookie_def *, | 193 | const struct fscache_cookie_def *, |
201 | const void *, size_t, | 194 | const void *, size_t, |
202 | const void *, size_t, | 195 | const void *, size_t, |
203 | void *, bool); | 196 | void *, loff_t, bool); |
204 | extern void __fscache_relinquish_cookie(struct fscache_cookie *, const void *, bool); | 197 | extern void __fscache_relinquish_cookie(struct fscache_cookie *, const void *, bool); |
205 | extern int __fscache_check_consistency(struct fscache_cookie *, const void *); | 198 | extern int __fscache_check_consistency(struct fscache_cookie *, const void *); |
206 | extern void __fscache_update_cookie(struct fscache_cookie *, const void *); | 199 | extern void __fscache_update_cookie(struct fscache_cookie *, const void *); |
@@ -220,7 +213,7 @@ extern int __fscache_read_or_alloc_pages(struct fscache_cookie *, | |||
220 | void *, | 213 | void *, |
221 | gfp_t); | 214 | gfp_t); |
222 | extern int __fscache_alloc_page(struct fscache_cookie *, struct page *, gfp_t); | 215 | extern int __fscache_alloc_page(struct fscache_cookie *, struct page *, gfp_t); |
223 | extern int __fscache_write_page(struct fscache_cookie *, struct page *, gfp_t); | 216 | extern int __fscache_write_page(struct fscache_cookie *, struct page *, loff_t, gfp_t); |
224 | extern void __fscache_uncache_page(struct fscache_cookie *, struct page *); | 217 | extern void __fscache_uncache_page(struct fscache_cookie *, struct page *); |
225 | extern bool __fscache_check_page_write(struct fscache_cookie *, struct page *); | 218 | extern bool __fscache_check_page_write(struct fscache_cookie *, struct page *); |
226 | extern void __fscache_wait_on_page_write(struct fscache_cookie *, struct page *); | 219 | extern void __fscache_wait_on_page_write(struct fscache_cookie *, struct page *); |
@@ -231,7 +224,7 @@ extern void __fscache_uncache_all_inode_pages(struct fscache_cookie *, | |||
231 | extern void __fscache_readpages_cancel(struct fscache_cookie *cookie, | 224 | extern void __fscache_readpages_cancel(struct fscache_cookie *cookie, |
232 | struct list_head *pages); | 225 | struct list_head *pages); |
233 | extern void __fscache_disable_cookie(struct fscache_cookie *, const void *, bool); | 226 | extern void __fscache_disable_cookie(struct fscache_cookie *, const void *, bool); |
234 | extern void __fscache_enable_cookie(struct fscache_cookie *, const void *, | 227 | extern void __fscache_enable_cookie(struct fscache_cookie *, const void *, loff_t, |
235 | bool (*)(void *), void *); | 228 | bool (*)(void *), void *); |
236 | 229 | ||
237 | /** | 230 | /** |
@@ -315,6 +308,7 @@ void fscache_release_cache_tag(struct fscache_cache_tag *tag) | |||
315 | * @aux_data_len: Size of the auxiliary data buffer | 308 | * @aux_data_len: Size of the auxiliary data buffer |
316 | * @netfs_data: An arbitrary piece of data to be kept in the cookie to | 309 | * @netfs_data: An arbitrary piece of data to be kept in the cookie to |
317 | * represent the cache object to the netfs | 310 | * represent the cache object to the netfs |
311 | * @object_size: The initial size of object | ||
318 | * @enable: Whether or not to enable a data cookie immediately | 312 | * @enable: Whether or not to enable a data cookie immediately |
319 | * | 313 | * |
320 | * This function is used to inform FS-Cache about part of an index hierarchy | 314 | * This function is used to inform FS-Cache about part of an index hierarchy |
@@ -333,13 +327,14 @@ struct fscache_cookie *fscache_acquire_cookie( | |||
333 | const void *aux_data, | 327 | const void *aux_data, |
334 | size_t aux_data_len, | 328 | size_t aux_data_len, |
335 | void *netfs_data, | 329 | void *netfs_data, |
330 | loff_t object_size, | ||
336 | bool enable) | 331 | bool enable) |
337 | { | 332 | { |
338 | if (fscache_cookie_valid(parent) && fscache_cookie_enabled(parent)) | 333 | if (fscache_cookie_valid(parent) && fscache_cookie_enabled(parent)) |
339 | return __fscache_acquire_cookie(parent, def, | 334 | return __fscache_acquire_cookie(parent, def, |
340 | index_key, index_key_len, | 335 | index_key, index_key_len, |
341 | aux_data, aux_data_len, | 336 | aux_data, aux_data_len, |
342 | netfs_data, enable); | 337 | netfs_data, object_size, enable); |
343 | else | 338 | else |
344 | return NULL; | 339 | return NULL; |
345 | } | 340 | } |
@@ -660,6 +655,7 @@ void fscache_readpages_cancel(struct fscache_cookie *cookie, | |||
660 | * fscache_write_page - Request storage of a page in the cache | 655 | * fscache_write_page - Request storage of a page in the cache |
661 | * @cookie: The cookie representing the cache object | 656 | * @cookie: The cookie representing the cache object |
662 | * @page: The netfs page to store | 657 | * @page: The netfs page to store |
658 | * @object_size: Updated size of object | ||
663 | * @gfp: The conditions under which memory allocation should be made | 659 | * @gfp: The conditions under which memory allocation should be made |
664 | * | 660 | * |
665 | * Request the contents of the netfs page be written into the cache. This | 661 | * Request the contents of the netfs page be written into the cache. This |
@@ -677,10 +673,11 @@ void fscache_readpages_cancel(struct fscache_cookie *cookie, | |||
677 | static inline | 673 | static inline |
678 | int fscache_write_page(struct fscache_cookie *cookie, | 674 | int fscache_write_page(struct fscache_cookie *cookie, |
679 | struct page *page, | 675 | struct page *page, |
676 | loff_t object_size, | ||
680 | gfp_t gfp) | 677 | gfp_t gfp) |
681 | { | 678 | { |
682 | if (fscache_cookie_valid(cookie) && fscache_cookie_enabled(cookie)) | 679 | if (fscache_cookie_valid(cookie) && fscache_cookie_enabled(cookie)) |
683 | return __fscache_write_page(cookie, page, gfp); | 680 | return __fscache_write_page(cookie, page, object_size, gfp); |
684 | else | 681 | else |
685 | return -ENOBUFS; | 682 | return -ENOBUFS; |
686 | } | 683 | } |
@@ -819,6 +816,7 @@ void fscache_disable_cookie(struct fscache_cookie *cookie, | |||
819 | * fscache_enable_cookie - Reenable a cookie | 816 | * fscache_enable_cookie - Reenable a cookie |
820 | * @cookie: The cookie representing the cache object | 817 | * @cookie: The cookie representing the cache object |
821 | * @aux_data: The updated auxiliary data for the cookie (may be NULL) | 818 | * @aux_data: The updated auxiliary data for the cookie (may be NULL) |
819 | * @object_size: Current size of object | ||
822 | * @can_enable: A function to permit enablement once lock is held | 820 | * @can_enable: A function to permit enablement once lock is held |
823 | * @data: Data for can_enable() | 821 | * @data: Data for can_enable() |
824 | * | 822 | * |
@@ -833,11 +831,13 @@ void fscache_disable_cookie(struct fscache_cookie *cookie, | |||
833 | static inline | 831 | static inline |
834 | void fscache_enable_cookie(struct fscache_cookie *cookie, | 832 | void fscache_enable_cookie(struct fscache_cookie *cookie, |
835 | const void *aux_data, | 833 | const void *aux_data, |
834 | loff_t object_size, | ||
836 | bool (*can_enable)(void *data), | 835 | bool (*can_enable)(void *data), |
837 | void *data) | 836 | void *data) |
838 | { | 837 | { |
839 | if (fscache_cookie_valid(cookie) && !fscache_cookie_enabled(cookie)) | 838 | if (fscache_cookie_valid(cookie) && !fscache_cookie_enabled(cookie)) |
840 | __fscache_enable_cookie(cookie, aux_data, can_enable, data); | 839 | __fscache_enable_cookie(cookie, aux_data, object_size, |
840 | can_enable, data); | ||
841 | } | 841 | } |
842 | 842 | ||
843 | #endif /* _LINUX_FSCACHE_H */ | 843 | #endif /* _LINUX_FSCACHE_H */ |