From patchwork Sun Jul 1 06:18:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huaisheng Ye X-Patchwork-Id: 10498517 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9256260325 for ; Sun, 1 Jul 2018 06:19:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 803A128BCF for ; Sun, 1 Jul 2018 06:19:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73F6528BD3; Sun, 1 Jul 2018 06:19:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 330F828BCF for ; Sun, 1 Jul 2018 06:19:59 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1A2A320336AD5; Sat, 30 Jun 2018 23:19:59 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=135.84.80.237; helo=sender-pp-092.zoho.com; envelope-from=yehs2007@zoho.com; receiver=linux-nvdimm@lists.01.org Received: from sender-pp-092.zoho.com (sender-pp-092.zoho.com [135.84.80.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7F6E220336ADB for ; Sat, 30 Jun 2018 23:19:57 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=from:to:cc:subject:date:message-id:in-reply-to:references; b=lxGD/iRtqfWLBDgU6hOsOAMk94+QUcRBPZP46qbQl8sfruoUsal2muMGapcVsfbWc1ps0m2yojBh 6j7cn/NXZbQASvpAP2H1+2HwEb8MCVJ9ydikgFS+bXx0zOcgPT7c Received: from YEHS1XR956R00D1.lenovo.com (111.197.253.128 [111.197.253.128]) by mx.zohomail.com with SMTPS id 1530425992341132.68424756262527; Sat, 30 Jun 2018 23:19:52 -0700 (PDT) From: Huaisheng Ye To: dan.j.williams@intel.com Subject: [PATCH 3/3] fs/ext2/inode: Optimize the condition for iomap_begin Date: Sun, 1 Jul 2018 14:18:48 +0800 Message-Id: <20180701061848.7036-3-yehs2007@zoho.com> X-Mailer: git-send-email 2.17.0.windows.1 In-Reply-To: <20180701061848.7036-1-yehs2007@zoho.com> References: <20180701061848.7036-1-yehs2007@zoho.com> X-ZohoMailClient: External X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-nvdimm@lists.01.org, chengnt@lenovo.com, jack@suse.com, linux-kernel@vger.kernel.org, willy@infradead.org, linux-ext4@vger.kernel.org MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP From: Huaisheng Ye If ext2_get_blocks returns negative result, ext2_iomap_begin will return for error case. Adjust the judging condition of ret value will be useful for code simplification. Signed-off-by: Huaisheng Ye --- fs/ext2/inode.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index ca211bd..9b1004d 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -819,15 +819,15 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length, iomap->offset = (loff_t)first_block << blkbits; iomap->dax_dev = sbi->s_daxdev; - if (ret == 0) { - iomap->type = IOMAP_HOLE; - iomap->addr = IOMAP_NULL_ADDR; - iomap->length = 1 << blkbits; - } else { + if (ret) { iomap->type = IOMAP_MAPPED; iomap->addr = (u64)bno << blkbits; iomap->length = (u64)ret << blkbits; iomap->flags |= IOMAP_F_MERGED; + } else { + iomap->type = IOMAP_HOLE; + iomap->addr = IOMAP_NULL_ADDR; + iomap->length = 1 << blkbits; } if (new)