FS-Cache: Check that there are no read ops when cookie relinquished
authorDavid Howells <dhowells@redhat.com>
Thu, 20 Dec 2012 21:52:33 +0000 (21:52 +0000)
committerDavid Howells <dhowells@redhat.com>
Thu, 20 Dec 2012 21:58:25 +0000 (21:58 +0000)
Check that the netfs isn't trying to relinquish a cookie that still has read
operations in progress upon it.  If there are, then give log a warning and BUG.

Signed-off-by: David Howells <dhowells@redhat.com>
fs/fscache/cookie.c

index 990535071a8aeadf4a67e646b6fdcad86403d63b..0666996adf807190cfa220fe000b5011264ca673 100644 (file)
@@ -452,6 +452,14 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
 
                _debug("RELEASE OBJ%x", object->debug_id);
 
+               if (atomic_read(&object->n_reads)) {
+                       spin_unlock(&cookie->lock);
+                       printk(KERN_ERR "FS-Cache:"
+                              " Cookie '%s' still has %d outstanding reads\n",
+                              cookie->def->name, atomic_read(&object->n_reads));
+                       BUG();
+               }
+
                /* detach each cache object from the object cookie */
                spin_lock(&object->lock);
                hlist_del_init(&object->cookie_link);