aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fscache/cookie.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2012-12-20 16:52:35 -0500
committerDavid Howells <dhowells@redhat.com>2012-12-20 16:58:25 -0500
commitef46ed888efb1e8da33be5d33c9b54476289a43b (patch)
treed538dc01a075162f95da416da1fb5d6fd676445a /fs/fscache/cookie.c
parent37491a1339df26259b06dfa33f30e574e9e52034 (diff)
FS-Cache: Make cookie relinquishment wait for outstanding reads
Make fscache_relinquish_cookie() log a warning and wait if there are any outstanding reads left on the cookie it was given. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs/fscache/cookie.c')
-rw-r--r--fs/fscache/cookie.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
index 0666996adf80..66be9eccede0 100644
--- a/fs/fscache/cookie.c
+++ b/fs/fscache/cookie.c
@@ -442,22 +442,32 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
442 442
443 event = retire ? FSCACHE_OBJECT_EV_RETIRE : FSCACHE_OBJECT_EV_RELEASE; 443 event = retire ? FSCACHE_OBJECT_EV_RETIRE : FSCACHE_OBJECT_EV_RELEASE;
444 444
445try_again:
445 spin_lock(&cookie->lock); 446 spin_lock(&cookie->lock);
446 447
447 /* break links with all the active objects */ 448 /* break links with all the active objects */
448 while (!hlist_empty(&cookie->backing_objects)) { 449 while (!hlist_empty(&cookie->backing_objects)) {
450 int n_reads;
449 object = hlist_entry(cookie->backing_objects.first, 451 object = hlist_entry(cookie->backing_objects.first,
450 struct fscache_object, 452 struct fscache_object,
451 cookie_link); 453 cookie_link);
452 454
453 _debug("RELEASE OBJ%x", object->debug_id); 455 _debug("RELEASE OBJ%x", object->debug_id);
454 456
455 if (atomic_read(&object->n_reads)) { 457 set_bit(FSCACHE_COOKIE_WAITING_ON_READS, &cookie->flags);
458 n_reads = atomic_read(&object->n_reads);
459 if (n_reads) {
460 int n_ops = object->n_ops;
461 int n_in_progress = object->n_in_progress;
456 spin_unlock(&cookie->lock); 462 spin_unlock(&cookie->lock);
457 printk(KERN_ERR "FS-Cache:" 463 printk(KERN_ERR "FS-Cache:"
458 " Cookie '%s' still has %d outstanding reads\n", 464 " Cookie '%s' still has %d outstanding reads (%d,%d)\n",
459 cookie->def->name, atomic_read(&object->n_reads)); 465 cookie->def->name,
460 BUG(); 466 n_reads, n_ops, n_in_progress);
467 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_WAITING_ON_READS,
468 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
469 printk("Wait finished\n");
470 goto try_again;
461 } 471 }
462 472
463 /* detach each cache object from the object cookie */ 473 /* detach each cache object from the object cookie */