From patchwork Tue Mar 31 13:27:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boaz Harrosh X-Patchwork-Id: 6129931 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3CF3E9F2EC for ; Tue, 31 Mar 2015 13:27:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 51093201ED for ; Tue, 31 Mar 2015 13:27:14 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 76E2F201E4 for ; Tue, 31 Mar 2015 13:27:13 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6D16D80F81; Tue, 31 Mar 2015 06:27:13 -0700 (PDT) X-Original-To: linux-nvdimm@ml01.01.org Delivered-To: linux-nvdimm@ml01.01.org Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 54F2280F80 for ; Tue, 31 Mar 2015 06:27:12 -0700 (PDT) Received: by wibgn9 with SMTP id gn9so26050811wib.1 for ; Tue, 31 Mar 2015 06:27:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=Ut8aiWu7NqaLIgkEXWFDlhHlVHFL2WA4unT9vzQ5IN0=; b=AZ2BFTjI+Q6DrKiS5aHc6dvJH1EbSUFlnzHW22hRejOgz2nbipmnZcIluPFciaFMNW N5SCUDr44CkVFfL5uID3jkd0gzHDlrPoQRWmIVy+vxPgAQhhSuZVL1qONJDFiXuUiXOT Lt71J7nETLMbASVGHUFQTPl9+uOYnND4iVvhgK7GumeezbdK2fAZwzV2+Wr365QDS/T5 Kti8x6RLcCxXtY09oiGi+XQTFVRPq5ZjdyZi1gNt5iftTX+iZzjuN6642C2Xr+Fj8YrV CZesxRRcYsOU1J+1G1+Ay1DV5IqY+nM+L4kZ7Pn2xzI416aYqaD2yoQZBnLD9m6SkEUY y0Bg== X-Gm-Message-State: ALoCoQkActKDc6Ts/HHPS341xwIIgEgIDkLn+Dyuew8QKdvbZL/CozTkxPc3RB7L73fj6CjF0rGz X-Received: by 10.180.206.13 with SMTP id lk13mr5301442wic.95.1427808430976; Tue, 31 Mar 2015 06:27:10 -0700 (PDT) Received: from [10.0.0.5] ([207.232.55.62]) by mx.google.com with ESMTPSA id k6sm20966785wia.6.2015.03.31.06.27.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Mar 2015 06:27:10 -0700 (PDT) Message-ID: <551AA0AD.4000604@plexistor.com> Date: Tue, 31 Mar 2015 16:27:09 +0300 From: Boaz Harrosh User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Christoph Hellwig References: <1427358764-6126-1-git-send-email-hch@lst.de> <55143A8B.2060304@plexistor.com> <20150331092526.GA25958@lst.de> <551A9EB3.8000605@plexistor.com> In-Reply-To: <551A9EB3.8000605@plexistor.com> Cc: axboe@kernel.dk, linux-nvdimm@ml01.01.org, x86@kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [Linux-nvdimm] [PATCH 4/6] SQUSHME: pmem: Micro cleaning X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_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 Some error checks had unlikely some did not. Put unlikely on all error handling paths. (I like unlikely for error paths specially for readability) Also use bio_data_dir() to extract away the READA flag Signed-off-by: Boaz Harrosh --- drivers/block/pmem.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/block/pmem.c b/drivers/block/pmem.c index 6a45fd5..209a410 100644 --- a/drivers/block/pmem.c +++ b/drivers/block/pmem.c @@ -76,7 +76,7 @@ static void pmem_make_request(struct request_queue *q, struct bio *bio) struct bvec_iter iter; int err = 0; - if (bio_end_sector(bio) > get_capacity(bdev->bd_disk)) { + if (unlikely(bio_end_sector(bio) > get_capacity(bdev->bd_disk))) { err = -EIO; goto out; } @@ -86,9 +86,7 @@ static void pmem_make_request(struct request_queue *q, struct bio *bio) goto out; } - rw = bio_rw(bio); - if (rw == READA) - rw = READ; + rw = bio_data_dir(bio); sector = bio->bi_iter.bi_sector; bio_for_each_segment(bvec, bio, iter) { @@ -124,7 +122,7 @@ static long pmem_direct_access(struct block_device *bdev, sector_t sector, struct pmem_device *pmem = bdev->bd_disk->private_data; size_t offset = sector << 9; - if (!pmem) + if (unlikely(!pmem)) return -ENODEV; *kaddr = pmem->virt_addr + offset; @@ -149,7 +147,7 @@ static int pmem_mapmem(struct pmem_device *pmem) res_mem = request_mem_region_exclusive(pmem->phys_addr, pmem->size, "pmem"); - if (!res_mem) { + if (unlikely(!res_mem)) { pr_warn("pmem: request_mem_region_exclusive phys=0x%llx size=0x%zx failed\n", pmem->phys_addr, pmem->size); return -EINVAL; @@ -192,7 +190,7 @@ static int pmem_probe(struct platform_device *pdev) return -ENXIO; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) + if (unlikely(!res)) return -ENXIO; pmem = kzalloc(sizeof(*pmem), GFP_KERNEL); @@ -273,11 +271,11 @@ static int __init pmem_init(void) int error; pmem_major = register_blkdev(0, "pmem"); - if (pmem_major < 0) + if (unlikely(pmem_major < 0)) return pmem_major; error = platform_driver_register(&pmem_driver); - if (error) + if (unlikely(error)) unregister_blkdev(pmem_major, "pmem"); return error; }