]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
bcache: Fix a sysfs splat on shutdown
authorKent Overstreet <kmo@daterainc.com>
Thu, 11 Jul 2013 04:25:02 +0000 (21:25 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 28 Jul 2013 23:30:10 +0000 (16:30 -0700)
commit c9502ea4424b31728703d113fc6b30bfead14633 upstream.

If we stopped a bcache device when we were already detaching (or
something like that), bcache_device_unlink() would try to remove a
symlink from sysfs that was already gone because the bcache dev kobject
had already been removed from sysfs.

So keep track of whether we've removed stuff from sysfs.

Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/bcache/bcache.h
drivers/md/bcache/super.c

index d3e15b42a4ab97655d989c3fe8240b09613acdc4..c42b14b2304cceb0c5dde84660f63de6b57daca2 100644 (file)
@@ -437,6 +437,7 @@ struct bcache_device {
 
        /* If nonzero, we're detaching/unregistering from cache set */
        atomic_t                detaching;
+       int                     flush_done;
 
        atomic_long_t           sectors_dirty;
        unsigned long           sectors_dirty_gc;
index 88113fe57fed63aa87eb27392c7f1b799a3b8bd8..b4713cea1913dea2e7759d6c56c5df6859bf8b65 100644 (file)
@@ -704,7 +704,8 @@ static void bcache_device_detach(struct bcache_device *d)
                atomic_set(&d->detaching, 0);
        }
 
-       bcache_device_unlink(d);
+       if (!d->flush_done)
+               bcache_device_unlink(d);
 
        d->c->devices[d->id] = NULL;
        closure_put(&d->c->caching);
@@ -1016,6 +1017,14 @@ static void cached_dev_flush(struct closure *cl)
        struct cached_dev *dc = container_of(cl, struct cached_dev, disk.cl);
        struct bcache_device *d = &dc->disk;
 
+       mutex_lock(&bch_register_lock);
+       d->flush_done = 1;
+
+       if (d->c)
+               bcache_device_unlink(d);
+
+       mutex_unlock(&bch_register_lock);
+
        bch_cache_accounting_destroy(&dc->accounting);
        kobject_del(&d->kobj);