Browse Source

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>
Joe Thornber 10 years ago
parent
commit
43c32bf2b0
1 changed files with 4 additions and 2 deletions
  1. 4 2
      drivers/md/dm-cache-target.c

+ 4 - 2
drivers/md/dm-cache-target.c

@@ -1432,9 +1432,8 @@ static void process_bio(struct cache *cache, struct prealloc *structs,
 	dm_oblock_t block = get_bio_block(cache, bio);
 	dm_oblock_t block = get_bio_block(cache, bio);
 	struct dm_bio_prison_cell *cell_prealloc, *old_ocell, *new_ocell;
 	struct dm_bio_prison_cell *cell_prealloc, *old_ocell, *new_ocell;
 	struct policy_result lookup_result;
 	struct policy_result lookup_result;
-	bool discarded_block = is_discarded_oblock(cache, block);
 	bool passthrough = passthrough_mode(&cache->features);
 	bool passthrough = passthrough_mode(&cache->features);
-	bool can_migrate = !passthrough && (discarded_block || spare_migration_bandwidth(cache));
+	bool discarded_block, can_migrate;
 
 
 	/*
 	/*
 	 * Check to see if that block is currently migrating.
 	 * Check to see if that block is currently migrating.
@@ -1446,6 +1445,9 @@ static void process_bio(struct cache *cache, struct prealloc *structs,
 	if (r > 0)
 	if (r > 0)
 		return;
 		return;
 
 
+	discarded_block = is_discarded_oblock(cache, block);
+	can_migrate = !passthrough && (discarded_block || spare_migration_bandwidth(cache));
+
 	r = policy_map(cache->policy, block, true, can_migrate, discarded_block,
 	r = policy_map(cache->policy, block, true, can_migrate, discarded_block,
 		       bio, &lookup_result);
 		       bio, &lookup_result);