From c3ee24921ceae12e6a8981629e7d59be4239c8e8 Mon Sep 17 00:00:00 2001 From: Heinz Mauelshagen Date: Mon, 14 Oct 2013 17:07:28 +0200 Subject: [PATCH] dm-cache-target: use is_write_io() in more places Use is_write_io() consistently where it is makes sense. Signed-off-by: Heinz Mauelshagen Signed-off-by: Mike Snitzer --- drivers/md/dm-cache-target.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) Index: linux/drivers/md/dm-cache-target.c =================================================================== --- linux.orig/drivers/md/dm-cache-target.c +++ linux/drivers/md/dm-cache-target.c @@ -631,12 +631,17 @@ static void check_if_tick_bio_needed(str spin_unlock_irqrestore(&cache->lock, flags); } +static bool is_write_io(struct bio *bio) +{ + return bio_data_dir(bio) == WRITE; +} + static void remap_to_origin_clear_discard(struct cache *cache, struct bio *bio, dm_oblock_t oblock) { check_if_tick_bio_needed(cache, bio); remap_to_origin(cache, bio); - if (bio_data_dir(bio) == WRITE) + if (is_write_io(bio)) clear_discard(cache, oblock_to_dblock(cache, oblock)); } @@ -644,7 +649,7 @@ static void remap_to_cache_dirty(struct dm_oblock_t oblock, dm_cblock_t cblock) { remap_to_cache(cache, bio, cblock); - if (bio_data_dir(bio) == WRITE) { + if (is_write_io(bio)) { set_dirty(cache, oblock, cblock); clear_discard(cache, oblock_to_dblock(cache, oblock)); } @@ -1172,21 +1177,16 @@ static bool spare_migration_bandwidth(st return current_volume < cache->migration_threshold; } -static bool is_write_io(struct bio *bio) -{ - return bio_data_dir(bio) == WRITE; -} - static void inc_hit_counter(struct cache *cache, struct bio *bio) { - atomic_inc(bio_data_dir(bio) == READ ? - &cache->stats.read_hit : &cache->stats.write_hit); + atomic_inc(is_write_io(bio) ? + &cache->stats.write_hit : &cache->stats.read_hit); } static void inc_miss_counter(struct cache *cache, struct bio *bio) { - atomic_inc(bio_data_dir(bio) == READ ? - &cache->stats.read_miss : &cache->stats.write_miss); + atomic_inc(is_write_io(bio) ? + &cache->stats.write_miss : &cache->stats.read_miss); } static void issue_cache_bio(struct cache *cache, struct bio *bio,