aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/md/dm-thin.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 96ce36a1a764..53252d2af249 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -164,7 +164,7 @@ struct pool {
164 164
165 struct pool_features pf; 165 struct pool_features pf;
166 bool low_water_triggered:1; /* A dm event has been sent */ 166 bool low_water_triggered:1; /* A dm event has been sent */
167 bool no_free_space:1; /* A -ENOSPC warning has been issued */ 167 bool no_free_space:1; /* bios will be requeued if set */
168 168
169 struct dm_bio_prison *prison; 169 struct dm_bio_prison *prison;
170 struct dm_kcopyd_client *copier; 170 struct dm_kcopyd_client *copier;
@@ -982,6 +982,20 @@ static void retry_on_resume(struct bio *bio)
982 spin_unlock_irqrestore(&pool->lock, flags); 982 spin_unlock_irqrestore(&pool->lock, flags);
983} 983}
984 984
985static void handle_unserviceable_bio(struct pool *pool, struct bio *bio)
986{
987 /*
988 * When pool is read-only, no cell locking is needed because
989 * nothing is changing.
990 */
991 WARN_ON_ONCE(get_pool_mode(pool) != PM_READ_ONLY);
992
993 if (pool->no_free_space)
994 retry_on_resume(bio);
995 else
996 bio_io_error(bio);
997}
998
985static void retry_bios_on_resume(struct pool *pool, struct dm_bio_prison_cell *cell) 999static void retry_bios_on_resume(struct pool *pool, struct dm_bio_prison_cell *cell)
986{ 1000{
987 struct bio *bio; 1001 struct bio *bio;
@@ -991,7 +1005,7 @@ static void retry_bios_on_resume(struct pool *pool, struct dm_bio_prison_cell *c
991 cell_release(pool, cell, &bios); 1005 cell_release(pool, cell, &bios);
992 1006
993 while ((bio = bio_list_pop(&bios))) 1007 while ((bio = bio_list_pop(&bios)))
994 retry_on_resume(bio); 1008 handle_unserviceable_bio(pool, bio);
995} 1009}
996 1010
997static void process_discard(struct thin_c *tc, struct bio *bio) 1011static void process_discard(struct thin_c *tc, struct bio *bio)
@@ -1245,7 +1259,7 @@ static void process_bio_read_only(struct thin_c *tc, struct bio *bio)
1245 switch (r) { 1259 switch (r) {
1246 case 0: 1260 case 0:
1247 if (lookup_result.shared && (rw == WRITE) && bio->bi_size) 1261 if (lookup_result.shared && (rw == WRITE) && bio->bi_size)
1248 bio_io_error(bio); 1262 handle_unserviceable_bio(tc->pool, bio);
1249 else { 1263 else {
1250 inc_all_io_entry(tc->pool, bio); 1264 inc_all_io_entry(tc->pool, bio);
1251 remap_and_issue(tc, bio, lookup_result.block); 1265 remap_and_issue(tc, bio, lookup_result.block);
@@ -1254,7 +1268,7 @@ static void process_bio_read_only(struct thin_c *tc, struct bio *bio)
1254 1268
1255 case -ENODATA: 1269 case -ENODATA:
1256 if (rw != READ) { 1270 if (rw != READ) {
1257 bio_io_error(bio); 1271 handle_unserviceable_bio(tc->pool, bio);
1258 break; 1272 break;
1259 } 1273 }
1260 1274
@@ -1565,9 +1579,9 @@ static int thin_bio_map(struct dm_target *ti, struct bio *bio)
1565 if (get_pool_mode(tc->pool) == PM_READ_ONLY) { 1579 if (get_pool_mode(tc->pool) == PM_READ_ONLY) {
1566 /* 1580 /*
1567 * This block isn't provisioned, and we have no way 1581 * This block isn't provisioned, and we have no way
1568 * of doing so. Just error it. 1582 * of doing so.
1569 */ 1583 */
1570 bio_io_error(bio); 1584 handle_unserviceable_bio(tc->pool, bio);
1571 return DM_MAPIO_SUBMITTED; 1585 return DM_MAPIO_SUBMITTED;
1572 } 1586 }
1573 /* fall through */ 1587 /* fall through */