Skip to content

Commit

Permalink
bcache: Fix a sysfs splat on shutdown
Browse files Browse the repository at this point in the history
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>
Cc: linux-stable <stable@vger.kernel.org> # >= v3.10
  • Loading branch information
Kent Overstreet committed Jul 12, 2013
1 parent 54d12f2 commit c9502ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions drivers/md/bcache/bcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ struct bcache_device {

/* If nonzero, we're detaching/unregistering from cache set */
atomic_t detaching;
int flush_done;

uint64_t nr_stripes;
unsigned stripe_size_bits;
Expand Down
11 changes: 10 additions & 1 deletion drivers/md/bcache/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,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);
Expand Down Expand Up @@ -1055,6 +1056,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);

Expand Down

0 comments on commit c9502ea

Please sign in to comment.