diff options
author | Mike Snitzer <snitzer@redhat.com> | 2014-05-22 14:32:51 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2014-06-03 13:44:08 -0400 |
commit | af91805a497d3aa694704172b41ba953be3738ed (patch) | |
tree | 44c0ba130abac57125d7aff148b07d0f2d3e3f0b /drivers/md/dm-thin.c | |
parent | e7a3e871d8954c636b6cd2db7c7ece7ffe405986 (diff) |
dm thin: return ENOSPC instead of EIO when error_if_no_space enabled
Update the DM thin provisioning target's allocation failure error to be
consistent with commit a9d6ceb8 ("[SCSI] return ENOSPC on thin
provisioning failure").
The DM thin target now returns -ENOSPC rather than -EIO when
block allocation fails due to the pool being out of data space (and
the 'error_if_no_space' thin-pool feature is enabled).
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Acked-By: Joe Thornber <ejt@redhat.com>
Diffstat (limited to 'drivers/md/dm-thin.c')
-rw-r--r-- | drivers/md/dm-thin.c | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index 7694988fb806..a0bdd562e026 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c | |||
@@ -310,13 +310,18 @@ static void cell_defer_no_holder_no_free(struct thin_c *tc, | |||
310 | wake_worker(pool); | 310 | wake_worker(pool); |
311 | } | 311 | } |
312 | 312 | ||
313 | static void cell_error(struct pool *pool, | 313 | static void cell_error_with_code(struct pool *pool, |
314 | struct dm_bio_prison_cell *cell) | 314 | struct dm_bio_prison_cell *cell, int error_code) |
315 | { | 315 | { |
316 | dm_cell_error(pool->prison, cell); | 316 | dm_cell_error(pool->prison, cell, error_code); |
317 | dm_bio_prison_free_cell(pool->prison, cell); | 317 | dm_bio_prison_free_cell(pool->prison, cell); |
318 | } | 318 | } |
319 | 319 | ||
320 | static void cell_error(struct pool *pool, struct dm_bio_prison_cell *cell) | ||
321 | { | ||
322 | cell_error_with_code(pool, cell, -EIO); | ||
323 | } | ||
324 | |||
320 | /*----------------------------------------------------------------*/ | 325 | /*----------------------------------------------------------------*/ |
321 | 326 | ||
322 | /* | 327 | /* |
@@ -1027,7 +1032,7 @@ static void retry_on_resume(struct bio *bio) | |||
1027 | spin_unlock_irqrestore(&tc->lock, flags); | 1032 | spin_unlock_irqrestore(&tc->lock, flags); |
1028 | } | 1033 | } |
1029 | 1034 | ||
1030 | static bool should_error_unserviceable_bio(struct pool *pool) | 1035 | static int should_error_unserviceable_bio(struct pool *pool) |
1031 | { | 1036 | { |
1032 | enum pool_mode m = get_pool_mode(pool); | 1037 | enum pool_mode m = get_pool_mode(pool); |
1033 | 1038 | ||
@@ -1035,25 +1040,27 @@ static bool should_error_unserviceable_bio(struct pool *pool) | |||
1035 | case PM_WRITE: | 1040 | case PM_WRITE: |
1036 | /* Shouldn't get here */ | 1041 | /* Shouldn't get here */ |
1037 | DMERR_LIMIT("bio unserviceable, yet pool is in PM_WRITE mode"); | 1042 | DMERR_LIMIT("bio unserviceable, yet pool is in PM_WRITE mode"); |
1038 | return true; | 1043 | return -EIO; |
1039 | 1044 | ||
1040 | case PM_OUT_OF_DATA_SPACE: | 1045 | case PM_OUT_OF_DATA_SPACE: |
1041 | return pool->pf.error_if_no_space; | 1046 | return pool->pf.error_if_no_space ? -ENOSPC : 0; |
1042 | 1047 | ||
1043 | case PM_READ_ONLY: | 1048 | case PM_READ_ONLY: |
1044 | case PM_FAIL: | 1049 | case PM_FAIL: |
1045 | return true; | 1050 | return -EIO; |
1046 | default: | 1051 | default: |
1047 | /* Shouldn't get here */ | 1052 | /* Shouldn't get here */ |
1048 | DMERR_LIMIT("bio unserviceable, yet pool has an unknown mode"); | 1053 | DMERR_LIMIT("bio unserviceable, yet pool has an unknown mode"); |
1049 | return true; | 1054 | return -EIO; |
1050 | } | 1055 | } |
1051 | } | 1056 | } |
1052 | 1057 | ||
1053 | static void handle_unserviceable_bio(struct pool *pool, struct bio *bio) | 1058 | static void handle_unserviceable_bio(struct pool *pool, struct bio *bio) |
1054 | { | 1059 | { |
1055 | if (should_error_unserviceable_bio(pool)) | 1060 | int error = should_error_unserviceable_bio(pool); |
1056 | bio_io_error(bio); | 1061 | |
1062 | if (error) | ||
1063 | bio_endio(bio, error); | ||
1057 | else | 1064 | else |
1058 | retry_on_resume(bio); | 1065 | retry_on_resume(bio); |
1059 | } | 1066 | } |
@@ -1062,18 +1069,21 @@ static void retry_bios_on_resume(struct pool *pool, struct dm_bio_prison_cell *c | |||
1062 | { | 1069 | { |
1063 | struct bio *bio; | 1070 | struct bio *bio; |
1064 | struct bio_list bios; | 1071 | struct bio_list bios; |
1072 | int error; | ||
1065 | 1073 | ||
1066 | if (should_error_unserviceable_bio(pool)) { | 1074 | error = should_error_unserviceable_bio(pool); |
1067 | cell_error(pool, cell); | 1075 | if (error) { |
1076 | cell_error_with_code(pool, cell, error); | ||
1068 | return; | 1077 | return; |
1069 | } | 1078 | } |
1070 | 1079 | ||
1071 | bio_list_init(&bios); | 1080 | bio_list_init(&bios); |
1072 | cell_release(pool, cell, &bios); | 1081 | cell_release(pool, cell, &bios); |
1073 | 1082 | ||
1074 | if (should_error_unserviceable_bio(pool)) | 1083 | error = should_error_unserviceable_bio(pool); |
1084 | if (error) | ||
1075 | while ((bio = bio_list_pop(&bios))) | 1085 | while ((bio = bio_list_pop(&bios))) |
1076 | bio_io_error(bio); | 1086 | bio_endio(bio, error); |
1077 | else | 1087 | else |
1078 | while ((bio = bio_list_pop(&bios))) | 1088 | while ((bio = bio_list_pop(&bios))) |
1079 | retry_on_resume(bio); | 1089 | retry_on_resume(bio); |