aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/filesystems/caching
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 /Documentation/filesystems/caching
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 'Documentation/filesystems/caching')
-rw-r--r--Documentation/filesystems/caching/netfs-api.txt61
1 files changed, 31 insertions, 30 deletions
diff --git a/Documentation/filesystems/caching/netfs-api.txt b/Documentation/filesystems/caching/netfs-api.txt
index 332840ad4151..2a6f7399c1f3 100644
--- a/Documentation/filesystems/caching/netfs-api.txt
+++ b/Documentation/filesystems/caching/netfs-api.txt
@@ -129,12 +129,10 @@ To define an object, a structure of the following type should be filled out:
129 const void *parent_netfs_data, 129 const void *parent_netfs_data,
130 const void *cookie_netfs_data); 130 const void *cookie_netfs_data);
131 131
132 void (*get_attr)(const void *cookie_netfs_data,
133 uint64_t *size);
134
135 enum fscache_checkaux (*check_aux)(void *cookie_netfs_data, 132 enum fscache_checkaux (*check_aux)(void *cookie_netfs_data,
136 const void *data, 133 const void *data,
137 uint16_t datalen); 134 uint16_t datalen,
135 loff_t object_size);
138 136
139 void (*get_context)(void *cookie_netfs_data, void *context); 137 void (*get_context)(void *cookie_netfs_data, void *context);
140 138
@@ -179,16 +177,7 @@ This has the following fields:
179 cache in the parent's list will be chosen, or failing that, the first 177 cache in the parent's list will be chosen, or failing that, the first
180 cache in the master list. 178 cache in the master list.
181 179
182 (4) A function to retrieve attribute data from the netfs [optional]. 180 (4) A function to check the auxiliary data [optional].
183
184 This function will be called with the netfs data that was passed to the
185 cookie acquisition function. It should return the size of the file if
186 this is a data file. The size may be used to govern how much cache must
187 be reserved for this file in the cache.
188
189 If the function is absent, a file size of 0 is assumed.
190
191 (5) A function to check the auxiliary data [optional].
192 181
193 This function will be called to check that a match found in the cache for 182 This function will be called to check that a match found in the cache for
194 this object is valid. For instance with AFS it could check the auxiliary 183 this object is valid. For instance with AFS it could check the auxiliary
@@ -198,6 +187,9 @@ This has the following fields:
198 If this function is absent, it will be assumed that matching objects in a 187 If this function is absent, it will be assumed that matching objects in a
199 cache are always valid. 188 cache are always valid.
200 189
190 The function is also passed the cache's idea of the object size and may
191 use this to manage coherency also.
192
201 If present, the function should return one of the following values: 193 If present, the function should return one of the following values:
202 194
203 (*) FSCACHE_CHECKAUX_OKAY - the entry is okay as is 195 (*) FSCACHE_CHECKAUX_OKAY - the entry is okay as is
@@ -207,7 +199,7 @@ This has the following fields:
207 This function can also be used to extract data from the auxiliary data in 199 This function can also be used to extract data from the auxiliary data in
208 the cache and copy it into the netfs's structures. 200 the cache and copy it into the netfs's structures.
209 201
210 (6) A pair of functions to manage contexts for the completion callback 202 (5) A pair of functions to manage contexts for the completion callback
211 [optional]. 203 [optional].
212 204
213 The cache read/write functions are passed a context which is then passed 205 The cache read/write functions are passed a context which is then passed
@@ -221,7 +213,7 @@ This has the following fields:
221 required for indices as indices may not contain data. These functions may 213 required for indices as indices may not contain data. These functions may
222 be called in interrupt context and so may not sleep. 214 be called in interrupt context and so may not sleep.
223 215
224 (7) A function to mark a page as retaining cache metadata [optional]. 216 (6) A function to mark a page as retaining cache metadata [optional].
225 217
226 This is called by the cache to indicate that it is retaining in-memory 218 This is called by the cache to indicate that it is retaining in-memory
227 information for this page and that the netfs should uncache the page when 219 information for this page and that the netfs should uncache the page when
@@ -233,7 +225,7 @@ This has the following fields:
233 225
234 This function is not required for indices as they're not permitted data. 226 This function is not required for indices as they're not permitted data.
235 227
236 (8) A function to unmark all the pages retaining cache metadata [mandatory]. 228 (7) A function to unmark all the pages retaining cache metadata [mandatory].
237 229
238 This is called by FS-Cache to indicate that a backing store is being 230 This is called by FS-Cache to indicate that a backing store is being
239 unbound from a cookie and that all the marks on the pages should be 231 unbound from a cookie and that all the marks on the pages should be
@@ -310,6 +302,7 @@ the path to the file:
310 const void *aux_data, 302 const void *aux_data,
311 size_t aux_data_len, 303 size_t aux_data_len,
312 void *netfs_data, 304 void *netfs_data,
305 loff_t object_size,
313 bool enable); 306 bool enable);
314 307
315This function creates an index entry in the index represented by parent, 308This function creates an index entry in the index represented by parent,
@@ -326,6 +319,10 @@ The netfs may pass an arbitrary value in netfs_data and this will be presented
326to it in the event of any calling back. This may also be used in tracing or 319to it in the event of any calling back. This may also be used in tracing or
327logging of messages. 320logging of messages.
328 321
322The cache tracks the size of the data attached to an object and this set to be
323object_size. For indices, this should be 0. This value will be passed to the
324->check_aux() callback.
325
329Note that this function never returns an error - all errors are handled 326Note that this function never returns an error - all errors are handled
330internally. It may, however, return NULL to indicate no cookie. It is quite 327internally. It may, however, return NULL to indicate no cookie. It is quite
331acceptable to pass this token back to this function as the parent to another 328acceptable to pass this token back to this function as the parent to another
@@ -349,7 +346,7 @@ entry would have a dependent inode containing volume mappings within this cell:
349 &afs_cell_cache_index_def, 346 &afs_cell_cache_index_def,
350 cell->name, strlen(cell->name), 347 cell->name, strlen(cell->name),
351 NULL, 0, 348 NULL, 0,
352 cell, true); 349 cell, 0, true);
353 350
354And then a particular volume could be added to that index by ID, creating 351And then a particular volume could be added to that index by ID, creating
355another index for vnodes (AFS inode equivalents): 352another index for vnodes (AFS inode equivalents):
@@ -359,7 +356,7 @@ another index for vnodes (AFS inode equivalents):
359 &afs_volume_cache_index_def, 356 &afs_volume_cache_index_def,
360 &volume->vid, sizeof(volume->vid), 357 &volume->vid, sizeof(volume->vid),
361 NULL, 0, 358 NULL, 0,
362 volume, true); 359 volume, 0, true);
363 360
364 361
365====================== 362======================
@@ -375,7 +372,7 @@ the object definition should be something other than index type.
375 &afs_vnode_cache_object_def, 372 &afs_vnode_cache_object_def,
376 &key, sizeof(key), 373 &key, sizeof(key),
377 &aux, sizeof(aux), 374 &aux, sizeof(aux),
378 vnode, true); 375 vnode, vnode->status.size, true);
379 376
380 377
381================================= 378=================================
@@ -393,7 +390,7 @@ it would be some other type of object such as a data file.
393 &afs_xattr_cache_object_def, 390 &afs_xattr_cache_object_def,
394 &xattr->name, strlen(xattr->name), 391 &xattr->name, strlen(xattr->name),
395 NULL, 0, 392 NULL, 0,
396 xattr, true); 393 xattr, strlen(xattr->val), true);
397 394
398Miscellaneous objects might be used to store extended attributes or directory 395Miscellaneous objects might be used to store extended attributes or directory
399entries for example. 396entries for example.
@@ -410,8 +407,7 @@ cache to adjust its metadata for data tracking appropriately:
410 int fscache_attr_changed(struct fscache_cookie *cookie); 407 int fscache_attr_changed(struct fscache_cookie *cookie);
411 408
412The cache will return -ENOBUFS if there is no backing cache or if there is no 409The cache will return -ENOBUFS if there is no backing cache or if there is no
413space to allocate any extra metadata required in the cache. The attributes 410space to allocate any extra metadata required in the cache.
414will be accessed with the get_attr() cookie definition operation.
415 411
416Note that attempts to read or write data pages in the cache over this size may 412Note that attempts to read or write data pages in the cache over this size may
417be rebuffed with -ENOBUFS. 413be rebuffed with -ENOBUFS.
@@ -536,12 +532,13 @@ written back to the cache:
536 532
537 int fscache_write_page(struct fscache_cookie *cookie, 533 int fscache_write_page(struct fscache_cookie *cookie,
538 struct page *page, 534 struct page *page,
535 loff_t object_size,
539 gfp_t gfp); 536 gfp_t gfp);
540 537
541The cookie argument must specify a data file cookie, the page specified should 538The cookie argument must specify a data file cookie, the page specified should
542contain the data to be written (and is also used to specify the page number), 539contain the data to be written (and is also used to specify the page number),
543and the gfp argument is used to control how any memory allocations made are 540object_size is the revised size of the object and the gfp argument is used to
544satisfied. 541control how any memory allocations made are satisfied.
545 542
546The page must have first been read or allocated successfully and must not have 543The page must have first been read or allocated successfully and must not have
547been uncached before writing is performed. 544been uncached before writing is performed.
@@ -735,11 +732,11 @@ still possible to uncache pages and relinquish the cookie.
735 732
736The initial enablement state is set by fscache_acquire_cookie(), but the cookie 733The initial enablement state is set by fscache_acquire_cookie(), but the cookie
737can be enabled or disabled later. To disable a cookie, call: 734can be enabled or disabled later. To disable a cookie, call:
738 735
739 void fscache_disable_cookie(struct fscache_cookie *cookie, 736 void fscache_disable_cookie(struct fscache_cookie *cookie,
740 const void *aux_data, 737 const void *aux_data,
741 bool invalidate); 738 bool invalidate);
742 739
743If the cookie is not already disabled, this locks the cookie against other 740If the cookie is not already disabled, this locks the cookie against other
744enable and disable ops, marks the cookie as being disabled, discards or 741enable and disable ops, marks the cookie as being disabled, discards or
745invalidates any backing objects and waits for cessation of activity on any 742invalidates any backing objects and waits for cessation of activity on any
@@ -748,14 +745,15 @@ associated object before unlocking the cookie.
748All possible failures are handled internally. The caller should consider 745All possible failures are handled internally. The caller should consider
749calling fscache_uncache_all_inode_pages() afterwards to make sure all page 746calling fscache_uncache_all_inode_pages() afterwards to make sure all page
750markings are cleared up. 747markings are cleared up.
751 748
752Cookies can be enabled or reenabled with: 749Cookies can be enabled or reenabled with:
753 750
754 void fscache_enable_cookie(struct fscache_cookie *cookie, 751 void fscache_enable_cookie(struct fscache_cookie *cookie,
755 const void *aux_data, 752 const void *aux_data,
753 loff_t object_size,
756 bool (*can_enable)(void *data), 754 bool (*can_enable)(void *data),
757 void *data) 755 void *data)
758 756
759If the cookie is not already enabled, this locks the cookie against other 757If the cookie is not already enabled, this locks the cookie against other
760enable and disable ops, invokes can_enable() and, if the cookie is not an index 758enable and disable ops, invokes can_enable() and, if the cookie is not an index
761cookie, will begin the procedure of acquiring backing objects. 759cookie, will begin the procedure of acquiring backing objects.
@@ -766,6 +764,9 @@ ruling as to whether or not enablement should actually be permitted to begin.
766All possible failures are handled internally. The cookie will only be marked 764All possible failures are handled internally. The cookie will only be marked
767as enabled if provisional backing objects are allocated. 765as enabled if provisional backing objects are allocated.
768 766
767The object's data size is updated from object_size and is passed to the
768->check_aux() function.
769
769In both cases, the cookie's auxiliary data buffer is updated from aux_data if 770In both cases, the cookie's auxiliary data buffer is updated from aux_data if
770that is non-NULL inside the enablement lock before proceeding. 771that is non-NULL inside the enablement lock before proceeding.
771 772