aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fscache/cookie.c
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 /fs/fscache/cookie.c
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 'fs/fscache/cookie.c')
-rw-r--r--fs/fscache/cookie.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
index 66be9eccede0..8dcb114758e3 100644
--- a/fs/fscache/cookie.c
+++ b/fs/fscache/cookie.c
@@ -370,6 +370,66 @@ cant_attach_object:
370} 370}
371 371
372/* 372/*
373 * Invalidate an object. Callable with spinlocks held.
374 */
375void __fscache_invalidate(struct fscache_cookie *cookie)
376{
377 struct fscache_object *object;
378
379 _enter("{%s}", cookie->def->name);
380
381 fscache_stat(&fscache_n_invalidates);
382
383 /* Only permit invalidation of data files. Invalidating an index will
384 * require the caller to release all its attachments to the tree rooted
385 * there, and if it's doing that, it may as well just retire the
386 * cookie.
387 */
388 ASSERTCMP(cookie->def->type, ==, FSCACHE_COOKIE_TYPE_DATAFILE);
389
390 /* We will be updating the cookie too. */
391 BUG_ON(!cookie->def->get_aux);
392
393 /* If there's an object, we tell the object state machine to handle the
394 * invalidation on our behalf, otherwise there's nothing to do.
395 */
396 if (!hlist_empty(&cookie->backing_objects)) {
397 spin_lock(&cookie->lock);
398
399 if (!hlist_empty(&cookie->backing_objects) &&
400 !test_and_set_bit(FSCACHE_COOKIE_INVALIDATING,
401 &cookie->flags)) {
402 object = hlist_entry(cookie->backing_objects.first,
403 struct fscache_object,
404 cookie_link);
405 if (object->state < FSCACHE_OBJECT_DYING)
406 fscache_raise_event(
407 object, FSCACHE_OBJECT_EV_INVALIDATE);
408 }
409
410 spin_unlock(&cookie->lock);
411 }
412
413 _leave("");
414}
415EXPORT_SYMBOL(__fscache_invalidate);
416
417/*
418 * Wait for object invalidation to complete.
419 */
420void __fscache_wait_on_invalidate(struct fscache_cookie *cookie)
421{
422 _enter("%p", cookie);
423
424 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_INVALIDATING,
425 fscache_wait_bit_interruptible,
426 TASK_UNINTERRUPTIBLE);
427
428 _leave("");
429}
430EXPORT_SYMBOL(__fscache_wait_on_invalidate);
431
432/*
373 * update the index entries backing a cookie 433 * update the index entries backing a cookie
374 */ 434 */
375void __fscache_update_cookie(struct fscache_cookie *cookie) 435void __fscache_update_cookie(struct fscache_cookie *cookie)