@@ -129,12 +129,10 @@ To define an object, a structure of the following type should be filled out:
129
129
const void *parent_netfs_data,
130
130
const void *cookie_netfs_data);
131
131
132
- void (*get_attr)(const void *cookie_netfs_data,
133
- uint64_t *size);
134
-
135
132
enum fscache_checkaux (*check_aux)(void *cookie_netfs_data,
136
133
const void *data,
137
- uint16_t datalen);
134
+ uint16_t datalen,
135
+ loff_t object_size);
138
136
139
137
void (*get_context)(void *cookie_netfs_data, void *context);
140
138
@@ -179,16 +177,7 @@ This has the following fields:
179
177
cache in the parent's list will be chosen, or failing that, the first
180
178
cache in the master list.
181
179
182
- (4) A function to retrieve attribute data from the netfs [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].
180
+ (4) A function to check the auxiliary data [optional].
192
181
193
182
This function will be called to check that a match found in the cache for
194
183
this object is valid. For instance with AFS it could check the auxiliary
@@ -198,6 +187,9 @@ This has the following fields:
198
187
If this function is absent, it will be assumed that matching objects in a
199
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
193
If present, the function should return one of the following values:
202
194
203
195
(*) FSCACHE_CHECKAUX_OKAY - the entry is okay as is
@@ -207,7 +199,7 @@ This has the following fields:
207
199
This function can also be used to extract data from the auxiliary data in
208
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
203
[optional].
212
204
213
205
The cache read/write functions are passed a context which is then passed
@@ -221,7 +213,7 @@ This has the following fields:
221
213
required for indices as indices may not contain data. These functions may
222
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
218
This is called by the cache to indicate that it is retaining in-memory
227
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
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
230
This is called by FS-Cache to indicate that a backing store is being
239
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
302
const void *aux_data,
311
303
size_t aux_data_len,
312
304
void *netfs_data,
305
+ loff_t object_size,
313
306
bool enable);
314
307
315
308
This 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
326
319
to it in the event of any calling back. This may also be used in tracing or
327
320
logging of messages.
328
321
322
+ The cache tracks the size of the data attached to an object and this set to be
323
+ object_size. For indices, this should be 0. This value will be passed to the
324
+ ->check_aux() callback.
325
+
329
326
Note that this function never returns an error - all errors are handled
330
327
internally. It may, however, return NULL to indicate no cookie. It is quite
331
328
acceptable 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
346
&afs_cell_cache_index_def,
350
347
cell->name, strlen(cell->name),
351
348
NULL, 0,
352
- cell, true);
349
+ cell, 0, true);
353
350
354
351
And then a particular volume could be added to that index by ID, creating
355
352
another index for vnodes (AFS inode equivalents):
@@ -359,7 +356,7 @@ another index for vnodes (AFS inode equivalents):
359
356
&afs_volume_cache_index_def,
360
357
&volume->vid, sizeof(volume->vid),
361
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
372
&afs_vnode_cache_object_def,
376
373
&key, sizeof(key),
377
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
390
&afs_xattr_cache_object_def,
394
391
&xattr->name, strlen(xattr->name),
395
392
NULL, 0,
396
- xattr, true);
393
+ xattr, strlen(xattr->val), true);
397
394
398
395
Miscellaneous objects might be used to store extended attributes or directory
399
396
entries for example.
@@ -410,8 +407,7 @@ cache to adjust its metadata for data tracking appropriately:
410
407
int fscache_attr_changed(struct fscache_cookie *cookie);
411
408
412
409
The cache will return -ENOBUFS if there is no backing cache or if there is no
413
- space to allocate any extra metadata required in the cache. The attributes
414
- will be accessed with the get_attr() cookie definition operation.
410
+ space to allocate any extra metadata required in the cache.
415
411
416
412
Note that attempts to read or write data pages in the cache over this size may
417
413
be rebuffed with -ENOBUFS.
@@ -536,12 +532,13 @@ written back to the cache:
536
532
537
533
int fscache_write_page(struct fscache_cookie *cookie,
538
534
struct page *page,
535
+ loff_t object_size,
539
536
gfp_t gfp);
540
537
541
538
The cookie argument must specify a data file cookie, the page specified should
542
539
contain the data to be written (and is also used to specify the page number),
543
- and the gfp argument is used to control how any memory allocations made are
544
- satisfied.
540
+ object_size is the revised size of the object and the gfp argument is used to
541
+ control how any memory allocations made are satisfied.
545
542
546
543
The page must have first been read or allocated successfully and must not have
547
544
been uncached before writing is performed.
@@ -735,11 +732,11 @@ still possible to uncache pages and relinquish the cookie.
735
732
736
733
The initial enablement state is set by fscache_acquire_cookie(), but the cookie
737
734
can be enabled or disabled later. To disable a cookie, call:
738
-
735
+
739
736
void fscache_disable_cookie(struct fscache_cookie *cookie,
740
737
const void *aux_data,
741
738
bool invalidate);
742
-
739
+
743
740
If the cookie is not already disabled, this locks the cookie against other
744
741
enable and disable ops, marks the cookie as being disabled, discards or
745
742
invalidates any backing objects and waits for cessation of activity on any
@@ -748,14 +745,15 @@ associated object before unlocking the cookie.
748
745
All possible failures are handled internally. The caller should consider
749
746
calling fscache_uncache_all_inode_pages() afterwards to make sure all page
750
747
markings are cleared up.
751
-
748
+
752
749
Cookies can be enabled or reenabled with:
753
-
750
+
754
751
void fscache_enable_cookie(struct fscache_cookie *cookie,
755
752
const void *aux_data,
753
+ loff_t object_size,
756
754
bool (*can_enable)(void *data),
757
755
void *data)
758
-
756
+
759
757
If the cookie is not already enabled, this locks the cookie against other
760
758
enable and disable ops, invokes can_enable() and, if the cookie is not an index
761
759
cookie, 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.
766
764
All possible failures are handled internally. The cookie will only be marked
767
765
as enabled if provisional backing objects are allocated.
768
766
767
+ The object's data size is updated from object_size and is passed to the
768
+ ->check_aux() function.
769
+
769
770
In both cases, the cookie's auxiliary data buffer is updated from aux_data if
770
771
that is non-NULL inside the enablement lock before proceeding.
771
772
0 commit comments