Commit bf0c55c986540483c34ca640f2eef4c3314388b1
Committed by
Kent Overstreet
1 parent
d83353b319
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
bcache: fix crash with incomplete cache set
Change-Id: I6abde52afe917633480caaf4e2518f42a816d886
Showing 2 changed files with 8 additions and 0 deletions Side-by-side Diff
drivers/md/bcache/bcache.h
... | ... | @@ -477,9 +477,13 @@ |
477 | 477 | * CACHE_SET_STOPPING always gets set first when we're closing down a cache set; |
478 | 478 | * we'll continue to run normally for awhile with CACHE_SET_STOPPING set (i.e. |
479 | 479 | * flushing dirty data). |
480 | + * | |
481 | + * CACHE_SET_RUNNING means all cache devices have been registered and journal | |
482 | + * replay is complete. | |
480 | 483 | */ |
481 | 484 | #define CACHE_SET_UNREGISTERING 0 |
482 | 485 | #define CACHE_SET_STOPPING 1 |
486 | +#define CACHE_SET_RUNNING 2 | |
483 | 487 | |
484 | 488 | struct cache_set { |
485 | 489 | struct closure cl; |
drivers/md/bcache/super.c
... | ... | @@ -1284,6 +1284,9 @@ |
1284 | 1284 | if (test_bit(CACHE_SET_STOPPING, &c->flags)) |
1285 | 1285 | return -EINTR; |
1286 | 1286 | |
1287 | + if (!test_bit(CACHE_SET_RUNNING, &c->flags)) | |
1288 | + return -EPERM; | |
1289 | + | |
1287 | 1290 | u = uuid_find_empty(c); |
1288 | 1291 | if (!u) { |
1289 | 1292 | pr_err("Can't create volume, no room for UUID"); |
... | ... | @@ -1706,6 +1709,7 @@ |
1706 | 1709 | |
1707 | 1710 | flash_devs_run(c); |
1708 | 1711 | |
1712 | + set_bit(CACHE_SET_RUNNING, &c->flags); | |
1709 | 1713 | return; |
1710 | 1714 | err: |
1711 | 1715 | closure_sync(&cl); |