From patchwork Thu Oct 24 18:30:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 3093251 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9C1F89F2B7 for ; Thu, 24 Oct 2013 18:35:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8432C204D2 for ; Thu, 24 Oct 2013 18:35:32 +0000 (UTC) Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mail.kernel.org (Postfix) with ESMTP id D877E201DD for ; Thu, 24 Oct 2013 18:35:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r9OIWI7C011207; Thu, 24 Oct 2013 14:32:18 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r9OIV2nm028397 for ; Thu, 24 Oct 2013 14:31:02 -0400 Received: from localhost (vpn-63-1.rdu2.redhat.com [10.10.63.1]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r9OIV0fx005796 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 24 Oct 2013 14:31:01 -0400 From: Mike Snitzer To: dm-devel@redhat.com Date: Thu, 24 Oct 2013 14:30:27 -0400 Message-Id: <1382639437-27007-15-git-send-email-snitzer@redhat.com> In-Reply-To: <1382639437-27007-1-git-send-email-snitzer@redhat.com> References: <1382639437-27007-1-git-send-email-snitzer@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: dm-devel@redhat.com Cc: Morgan Mears , Heinz Mauelshagen , Joe Thornber , Mike Snitzer Subject: [dm-devel] [PATCH 14/24] dm cache: use is_write_io() in more places X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Heinz Mauelshagen 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(-) diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c index 3bf8cc7..5fb4d64 100644 --- a/drivers/md/dm-cache-target.c +++ b/drivers/md/dm-cache-target.c @@ -631,12 +631,17 @@ static void check_if_tick_bio_needed(struct cache *cache, struct bio *bio) 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 cache *cache, struct bio *bio, 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(struct cache *cache) 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,