From patchwork Sat Feb 4 09:30:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gao Xiang X-Patchwork-Id: 52750 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1278451wrn; Sat, 4 Feb 2023 01:37:09 -0800 (PST) X-Google-Smtp-Source: AK7set/Kfg98eri+SUUfSVJCH/r0SGryNvPbjBejM/J4dF+eyNiUhuBpCYdCC+ebWZoya+xZbl3Z X-Received: by 2002:a17:902:cf48:b0:192:9550:339a with SMTP id e8-20020a170902cf4800b001929550339amr11179209plg.52.1675503429734; Sat, 04 Feb 2023 01:37:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675503429; cv=none; d=google.com; s=arc-20160816; b=0K6C9d9iUqJRa7hexV0d0RlhfI3UgBVP04UTjmCqmCoxfkLU9p70S+xx5DZSdnUzBw 0oT7am+Hyivl9Dl/2Ba0YFXLWeyvDqNHhULlCU9aU6gNAXQP8P017lZ5hJi8Qp0i+lpe xQYzPSSAijwJlAKxk13jwQygP0Gojv3maswlNLYYtWZc5wAjbECFSt65JKeEwr5NGjTV klWjqE1UmZCYiJDkFbsSnO7kGFUA8eES2t0SNNV9CK2MS3gKOMtkshu7/lOwkCRE+5KA KFzpxSkBfCW/BdQExREoKDt9SEGunDeKNx79tXGPnOC5K4ssUxw3Jd3FoIIzPfQCt/Es fUkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=64FZs36ZZextzXijgvbI7DcEZPUzvwpU/2FV/XU6ZY4=; b=0EvMRPSR3DrmGEZ0u3k9W0vYm8R1ihvtZXndBdV0lZGAmaO6hQPDjIW5RcqUFSXbR7 7yU1tzyGAbHr2VIjq3KNUi8dVFWScq5omzL/cw2T2fehsmlzRnYBPWtK9y2vX5q/xqLV ZEBzBk8WoSNmRTeBay4t3NCwX76EHs68PED6FVvDKBogS5AnQpQNHeFfgF4C6zd7DoKl rgTznknupWXG8DgSIP6v53CLEZt/xM6KBbudHmddBvpFyGv5RAQfD9hQaU9BheBkl/6Z D5vWcOfN2vsEzr/yBR0M8kgkH/1VlFTQRCXJwiAgfP7nHhGG/DYMRgwS6aAknK61rvxo wb5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b10-20020a170903228a00b0019305638dfdsi2810789plh.77.2023.02.04.01.36.57; Sat, 04 Feb 2023 01:37:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233223AbjBDJaw (ORCPT + 99 others); Sat, 4 Feb 2023 04:30:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230118AbjBDJav (ORCPT ); Sat, 4 Feb 2023 04:30:51 -0500 Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54066279B8 for ; Sat, 4 Feb 2023 01:30:49 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VarVFIX_1675503041; Received: from e18g06460.et15sqa.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0VarVFIX_1675503041) by smtp.aliyun-inc.com; Sat, 04 Feb 2023 17:30:46 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org, Chao Yu , Yue Hu , Jeffle Xu Cc: LKML , Gao Xiang Subject: [PATCH 1/6] erofs: get rid of erofs_inode_datablocks() Date: Sat, 4 Feb 2023 17:30:35 +0800 Message-Id: <20230204093040.97967-1-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.24.4 MIME-Version: 1.0 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756892684583475818?= X-GMAIL-MSGID: =?utf-8?q?1756892684583475818?= erofs_inode_datablocks() has the only one caller, let's just get rid of it entirely. No logic changes. Signed-off-by: Gao Xiang Reviewed-by: Yue Hu Reviewed-by: Jingbo Xu Reviewed-by: Chao Yu --- fs/erofs/internal.h | 6 ------ fs/erofs/namei.c | 18 +++++------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 08ba817d6551..c18af21ba9c4 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -344,12 +344,6 @@ static inline erofs_off_t erofs_iloc(struct inode *inode) (EROFS_I(inode)->nid << sbi->islotbits); } -static inline unsigned long erofs_inode_datablocks(struct inode *inode) -{ - /* since i_size cannot be changed */ - return DIV_ROUND_UP(inode->i_size, EROFS_BLKSIZ); -} - static inline unsigned int erofs_bitrange(unsigned int value, unsigned int bit, unsigned int bits) { diff --git a/fs/erofs/namei.c b/fs/erofs/namei.c index b64a108fac92..966eabc61c13 100644 --- a/fs/erofs/namei.c +++ b/fs/erofs/namei.c @@ -5,7 +5,6 @@ * Copyright (C) 2022, Alibaba Cloud */ #include "xattr.h" - #include struct erofs_qstr { @@ -87,19 +86,13 @@ static struct erofs_dirent *find_target_dirent(struct erofs_qstr *name, return ERR_PTR(-ENOENT); } -static void *find_target_block_classic(struct erofs_buf *target, - struct inode *dir, - struct erofs_qstr *name, - int *_ndirents) +static void *erofs_find_target_block(struct erofs_buf *target, + struct inode *dir, struct erofs_qstr *name, int *_ndirents) { - unsigned int startprfx, endprfx; - int head, back; + int head = 0, back = DIV_ROUND_UP(dir->i_size, EROFS_BLKSIZ) - 1; + unsigned int startprfx = 0, endprfx = 0; void *candidate = ERR_PTR(-ENOENT); - startprfx = endprfx = 0; - head = 0; - back = erofs_inode_datablocks(dir) - 1; - while (head <= back) { const int mid = head + (back - head) / 2; struct erofs_buf buf = __EROFS_BUF_INITIALIZER; @@ -180,8 +173,7 @@ int erofs_namei(struct inode *dir, const struct qstr *name, erofs_nid_t *nid, qn.end = name->name + name->len; ndirents = 0; - - de = find_target_block_classic(&buf, dir, &qn, &ndirents); + de = erofs_find_target_block(&buf, dir, &qn, &ndirents); if (IS_ERR(de)) return PTR_ERR(de);