aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2012-12-20 16:52:36 -0500
committerDavid Howells <dhowells@redhat.com>2012-12-20 17:04:07 -0500
commitef778e7ae67cd426c30cad43378b908f5eb0bad5 (patch)
tree4893f19487cb99e8ec0eb835ec4391d952641a9c /include
parent9f10523f891928330b7529da54c1a3cc65180b1a (diff)
FS-Cache: Provide proper invalidation
Provide a proper invalidation method rather than relying on the netfs retiring the cookie it has and getting a new one. The problem with this is that isn't easy for the netfs to make sure that it has completed/cancelled all its outstanding storage and retrieval operations on the cookie it is retiring. Instead, have the cache provide an invalidation method that will cancel or wait for all currently outstanding operations before invalidating the cache, and will cause new operations to queue up behind that. Whilst invalidation is in progress, some requests will be rejected until the cache can stack a barrier on the operation queue to cause new operations to be deferred behind it. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/fscache-cache.h8
-rw-r--r--include/linux/fscache.h38
2 files changed, 45 insertions, 1 deletions
diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
index f5facd1d333f..1e454ad7a832 100644
--- a/include/linux/fscache-cache.h
+++ b/include/linux/fscache-cache.h
@@ -254,6 +254,9 @@ struct fscache_cache_ops {
254 /* store the updated auxiliary data on an object */ 254 /* store the updated auxiliary data on an object */
255 void (*update_object)(struct fscache_object *object); 255 void (*update_object)(struct fscache_object *object);
256 256
257 /* Invalidate an object */
258 void (*invalidate_object)(struct fscache_operation *op);
259
257 /* discard the resources pinned by an object and effect retirement if 260 /* discard the resources pinned by an object and effect retirement if
258 * necessary */ 261 * necessary */
259 void (*drop_object)(struct fscache_object *object); 262 void (*drop_object)(struct fscache_object *object);
@@ -329,6 +332,7 @@ struct fscache_cookie {
329#define FSCACHE_COOKIE_FILLING 4 /* T if filling object incrementally */ 332#define FSCACHE_COOKIE_FILLING 4 /* T if filling object incrementally */
330#define FSCACHE_COOKIE_UNAVAILABLE 5 /* T if cookie is unavailable (error, etc) */ 333#define FSCACHE_COOKIE_UNAVAILABLE 5 /* T if cookie is unavailable (error, etc) */
331#define FSCACHE_COOKIE_WAITING_ON_READS 6 /* T if cookie is waiting on reads */ 334#define FSCACHE_COOKIE_WAITING_ON_READS 6 /* T if cookie is waiting on reads */
335#define FSCACHE_COOKIE_INVALIDATING 7 /* T if cookie is being invalidated */
332}; 336};
333 337
334extern struct fscache_cookie fscache_fsdef_index; 338extern struct fscache_cookie fscache_fsdef_index;
@@ -345,6 +349,7 @@ struct fscache_object {
345 /* active states */ 349 /* active states */
346 FSCACHE_OBJECT_AVAILABLE, /* cleaning up object after creation */ 350 FSCACHE_OBJECT_AVAILABLE, /* cleaning up object after creation */
347 FSCACHE_OBJECT_ACTIVE, /* object is usable */ 351 FSCACHE_OBJECT_ACTIVE, /* object is usable */
352 FSCACHE_OBJECT_INVALIDATING, /* object is invalidating */
348 FSCACHE_OBJECT_UPDATING, /* object is updating */ 353 FSCACHE_OBJECT_UPDATING, /* object is updating */
349 354
350 /* terminal states */ 355 /* terminal states */
@@ -378,7 +383,8 @@ struct fscache_object {
378#define FSCACHE_OBJECT_EV_RELEASE 4 /* T if netfs requested object release */ 383#define FSCACHE_OBJECT_EV_RELEASE 4 /* T if netfs requested object release */
379#define FSCACHE_OBJECT_EV_RETIRE 5 /* T if netfs requested object retirement */ 384#define FSCACHE_OBJECT_EV_RETIRE 5 /* T if netfs requested object retirement */
380#define FSCACHE_OBJECT_EV_WITHDRAW 6 /* T if cache requested object withdrawal */ 385#define FSCACHE_OBJECT_EV_WITHDRAW 6 /* T if cache requested object withdrawal */
381#define FSCACHE_OBJECT_EVENTS_MASK 0x7f /* mask of all events*/ 386#define FSCACHE_OBJECT_EV_INVALIDATE 7 /* T if cache requested object invalidation */
387#define FSCACHE_OBJECT_EVENTS_MASK 0xff /* mask of all events*/
382 388
383 unsigned long flags; 389 unsigned long flags;
384#define FSCACHE_OBJECT_LOCK 0 /* T if object is busy being processed */ 390#define FSCACHE_OBJECT_LOCK 0 /* T if object is busy being processed */
diff --git a/include/linux/fscache.h b/include/linux/fscache.h
index f4b6353543bf..7a086235da4b 100644
--- a/include/linux/fscache.h
+++ b/include/linux/fscache.h
@@ -185,6 +185,8 @@ extern struct fscache_cookie *__fscache_acquire_cookie(
185extern void __fscache_relinquish_cookie(struct fscache_cookie *, int); 185extern void __fscache_relinquish_cookie(struct fscache_cookie *, int);
186extern void __fscache_update_cookie(struct fscache_cookie *); 186extern void __fscache_update_cookie(struct fscache_cookie *);
187extern int __fscache_attr_changed(struct fscache_cookie *); 187extern int __fscache_attr_changed(struct fscache_cookie *);
188extern void __fscache_invalidate(struct fscache_cookie *);
189extern void __fscache_wait_on_invalidate(struct fscache_cookie *);
188extern int __fscache_read_or_alloc_page(struct fscache_cookie *, 190extern int __fscache_read_or_alloc_page(struct fscache_cookie *,
189 struct page *, 191 struct page *,
190 fscache_rw_complete_t, 192 fscache_rw_complete_t,
@@ -390,6 +392,42 @@ int fscache_attr_changed(struct fscache_cookie *cookie)
390} 392}
391 393
392/** 394/**
395 * fscache_invalidate - Notify cache that an object needs invalidation
396 * @cookie: The cookie representing the cache object
397 *
398 * Notify the cache that an object is needs to be invalidated and that it
399 * should abort any retrievals or stores it is doing on the cache. The object
400 * is then marked non-caching until such time as the invalidation is complete.
401 *
402 * This can be called with spinlocks held.
403 *
404 * See Documentation/filesystems/caching/netfs-api.txt for a complete
405 * description.
406 */
407static inline
408void fscache_invalidate(struct fscache_cookie *cookie)
409{
410 if (fscache_cookie_valid(cookie))
411 __fscache_invalidate(cookie);
412}
413
414/**
415 * fscache_wait_on_invalidate - Wait for invalidation to complete
416 * @cookie: The cookie representing the cache object
417 *
418 * Wait for the invalidation of an object to complete.
419 *
420 * See Documentation/filesystems/caching/netfs-api.txt for a complete
421 * description.
422 */
423static inline
424void fscache_wait_on_invalidate(struct fscache_cookie *cookie)
425{
426 if (fscache_cookie_valid(cookie))
427 __fscache_wait_on_invalidate(cookie);
428}
429
430/**
393 * fscache_reserve_space - Reserve data space for a cached object 431 * fscache_reserve_space - Reserve data space for a cached object
394 * @cookie: The cookie representing the cache object 432 * @cookie: The cookie representing the cache object
395 * @i_size: The amount of space to be reserved 433 * @i_size: The amount of space to be reserved