aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Thornber <ejt@redhat.com>2014-11-25 08:14:57 -0500
committerMike Snitzer <snitzer@redhat.com>2014-12-01 11:30:11 -0500
commit43c32bf2b0c16d292f4f214dfd16f9cb205e4e81 (patch)
tree3c6a8a4ea99883f16b94a177f7e54b6f286e1206
parent3e2e1c3098fcc02369f0eea822d0a7914b691567 (diff)
dm cache: fix a harmless race when working out if a block is discarded
It is more correct to hold the cell before checking the discard state. These flags are only used as hints to the policy so this change will have negligable effect. Signed-off-by: Joe Thornber <ejt@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
-rw-r--r--drivers/md/dm-cache-target.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index 2c66315553f2..161bbd6652f8 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -1432,9 +1432,8 @@ static void process_bio(struct cache *cache, struct prealloc *structs,
1432 dm_oblock_t block = get_bio_block(cache, bio); 1432 dm_oblock_t block = get_bio_block(cache, bio);
1433 struct dm_bio_prison_cell *cell_prealloc, *old_ocell, *new_ocell; 1433 struct dm_bio_prison_cell *cell_prealloc, *old_ocell, *new_ocell;
1434 struct policy_result lookup_result; 1434 struct policy_result lookup_result;
1435 bool discarded_block = is_discarded_oblock(cache, block);
1436 bool passthrough = passthrough_mode(&cache->features); 1435 bool passthrough = passthrough_mode(&cache->features);
1437 bool can_migrate = !passthrough && (discarded_block || spare_migration_bandwidth(cache)); 1436 bool discarded_block, can_migrate;
1438 1437
1439 /* 1438 /*
1440 * Check to see if that block is currently migrating. 1439 * Check to see if that block is currently migrating.
@@ -1446,6 +1445,9 @@ static void process_bio(struct cache *cache, struct prealloc *structs,
1446 if (r > 0) 1445 if (r > 0)
1447 return; 1446 return;
1448 1447
1448 discarded_block = is_discarded_oblock(cache, block);
1449 can_migrate = !passthrough && (discarded_block || spare_migration_bandwidth(cache));
1450
1449 r = policy_map(cache->policy, block, true, can_migrate, discarded_block, 1451 r = policy_map(cache->policy, block, true, can_migrate, discarded_block,
1450 bio, &lookup_result); 1452 bio, &lookup_result);
1451 1453