Commit 020cc3b5e28c2e24f59f53a9154faf08564f308e

Authored by Joe Thornber
Committed by Mike Snitzer
1 parent 4a02b34e0c

dm thin: always fallback the pool mode if commit fails

Rename commit_or_fallback() to commit().  Now all previous calls to
commit() will trigger the pool mode to fallback if the commit fails.

Also, check the error returned from commit() in alloc_data_block().

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org

Showing 1 changed file with 15 additions and 22 deletions Side-by-side Diff

drivers/md/dm-thin.c
... ... @@ -883,32 +883,23 @@
883 883 }
884 884 }
885 885  
886   -static int commit(struct pool *pool)
887   -{
888   - int r;
889   -
890   - r = dm_pool_commit_metadata(pool->pmd);
891   - if (r)
892   - DMERR_LIMIT("%s: commit failed: error = %d",
893   - dm_device_name(pool->pool_md), r);
894   -
895   - return r;
896   -}
897   -
898 886 /*
899 887 * A non-zero return indicates read_only or fail_io mode.
900 888 * Many callers don't care about the return value.
901 889 */
902   -static int commit_or_fallback(struct pool *pool)
  890 +static int commit(struct pool *pool)
903 891 {
904 892 int r;
905 893  
906 894 if (get_pool_mode(pool) != PM_WRITE)
907 895 return -EINVAL;
908 896  
909   - r = commit(pool);
910   - if (r)
  897 + r = dm_pool_commit_metadata(pool->pmd);
  898 + if (r) {
  899 + DMERR_LIMIT("%s: dm_pool_commit_metadata failed: error = %d",
  900 + dm_device_name(pool->pool_md), r);
911 901 set_pool_mode(pool, PM_READ_ONLY);
  902 + }
912 903  
913 904 return r;
914 905 }
... ... @@ -945,7 +936,9 @@
945 936 * Try to commit to see if that will free up some
946 937 * more space.
947 938 */
948   - (void) commit_or_fallback(pool);
  939 + r = commit(pool);
  940 + if (r)
  941 + return r;
949 942  
950 943 r = dm_pool_get_free_block_count(pool->pmd, &free_blocks);
951 944 if (r)
... ... @@ -1359,7 +1352,7 @@
1359 1352 if (bio_list_empty(&bios) && !need_commit_due_to_time(pool))
1360 1353 return;
1361 1354  
1362   - if (commit_or_fallback(pool)) {
  1355 + if (commit(pool)) {
1363 1356 while ((bio = bio_list_pop(&bios)))
1364 1357 bio_io_error(bio);
1365 1358 return;
... ... @@ -2276,7 +2269,7 @@
2276 2269 return r;
2277 2270  
2278 2271 if (need_commit1 || need_commit2)
2279   - (void) commit_or_fallback(pool);
  2272 + (void) commit(pool);
2280 2273  
2281 2274 return 0;
2282 2275 }
... ... @@ -2303,7 +2296,7 @@
2303 2296  
2304 2297 cancel_delayed_work(&pool->waker);
2305 2298 flush_workqueue(pool->wq);
2306   - (void) commit_or_fallback(pool);
  2299 + (void) commit(pool);
2307 2300 }
2308 2301  
2309 2302 static int check_arg_count(unsigned argc, unsigned args_required)
... ... @@ -2437,7 +2430,7 @@
2437 2430 if (r)
2438 2431 return r;
2439 2432  
2440   - (void) commit_or_fallback(pool);
  2433 + (void) commit(pool);
2441 2434  
2442 2435 r = dm_pool_reserve_metadata_snap(pool->pmd);
2443 2436 if (r)
... ... @@ -2499,7 +2492,7 @@
2499 2492 DMWARN("Unrecognised thin pool target message received: %s", argv[0]);
2500 2493  
2501 2494 if (!r)
2502   - (void) commit_or_fallback(pool);
  2495 + (void) commit(pool);
2503 2496  
2504 2497 return r;
2505 2498 }
... ... @@ -2554,7 +2547,7 @@
2554 2547  
2555 2548 /* Commit to ensure statistics aren't out-of-date */
2556 2549 if (!(status_flags & DM_STATUS_NOFLUSH_FLAG) && !dm_suspended(ti))
2557   - (void) commit_or_fallback(pool);
  2550 + (void) commit(pool);
2558 2551  
2559 2552 r = dm_pool_get_metadata_transaction_id(pool->pmd, &transaction_id);
2560 2553 if (r) {