Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp230720rwe; Fri, 14 Apr 2023 01:43:22 -0700 (PDT) X-Google-Smtp-Source: AKy350Zd3GIKS6be/mN31ypvQgLAS3hxLIx3zanJPL/iiquK34ORuGyy060yLJFMFFRc95vXbAtT X-Received: by 2002:a17:903:454:b0:1a0:50bd:31c0 with SMTP id iw20-20020a170903045400b001a050bd31c0mr1776560plb.24.1681461802100; Fri, 14 Apr 2023 01:43:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681461802; cv=none; d=google.com; s=arc-20160816; b=aaM+4A7fNqNvpXAImqzEk8iuTjvHxiUcFRzV4jeQ3um6aze84FrXMua3zCbzOfF1LC 19Gmb63ZZPOfzzx1ryYsnzlIbzgUQZwx7dpgt5mY/uIBhhSjbUzVPZ/g5WuT0DiMYyxQ uICMZwD8ahI/4ARum/uEgTaNlwAp9gqKz8tp/UU3HHgOQta35+fmKrTRkyk1KEhcdPwH UujAESWu8hFKsjhnTXc5DqA1YM8VCOtWGAFwdqPCad6Io3DGaEfG+ovUuX+JVdkgJoE6 RQ8v8gIqbJZyjb+5Y9IN7DGw0PU117w2RXwlcMlPoWQa7v6LWS5wYgRl4RgG64yteIdo e8hQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=u1kwXe+s/ny1fqmCSdMry8uIsfMKbr0H8f0hd6fE/xk=; b=c+xrG/bwiGtvjw9l2RXwB7otQFPro8u9ovyA5Z4kL475uLvj3AcaToyXHYNT1vU14m d4kdxRqcFY38aQSaSNyYIqfhHtbyqd3JlHdhaw/RIj2esSSCyLu2Y3jJKMeROQI+6R3Y zaumMHR9nqJo/0TZEukpgdtQZetxD2iStcO3/EQzFr5Xy2qJZhkX1qVCHXV5gqUqQ2p4 LXrBe9v8nYnUOQnRnP4Mlohuz1YjHGk0bkyRb3ySrhLdo/gGnaNBhKmaZ7t4tF6LZ4JW IZZldLsm6yZbJOE68JRrA2HAHpIoh60ua2RfXm11Ws0l7g3e2+JfpiMEvmt4rRzoVcmX Q3RA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k14-20020a170902c40e00b001a63a7b7025si4543618plk.30.2023.04.14.01.43.08; Fri, 14 Apr 2023 01:43:22 -0700 (PDT) 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 S229591AbjDNIa7 (ORCPT + 99 others); Fri, 14 Apr 2023 04:30:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230331AbjDNIam (ORCPT ); Fri, 14 Apr 2023 04:30:42 -0400 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 B5CF59ED8 for ; Fri, 14 Apr 2023 01:30:37 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R701e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046056;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0Vg2zKY5_1681461034; Received: from e18g06460.et15sqa.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0Vg2zKY5_1681461034) by smtp.aliyun-inc.com; Fri, 14 Apr 2023 16:30:35 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org Cc: LKML , Gao Xiang Subject: [PATCH 2/2] erofs: cleanup i_format-related stuffs Date: Fri, 14 Apr 2023 16:30:27 +0800 Message-Id: <20230414083027.12307-2-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.24.4 In-Reply-To: <20230414083027.12307-1-hsiangkao@linux.alibaba.com> References: <20230414083027.12307-1-hsiangkao@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,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 Switch EROFS_I_{VERSION,DATALAYOUT}_BITS into EROFS_I_{VERSION,DATALAYOUT}_MASK. Also avoid erofs_bitrange() since its functionality is simple enough. Signed-off-by: Gao Xiang --- fs/erofs/erofs_fs.h | 8 ++++---- fs/erofs/internal.h | 18 ++++-------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h index 4ec422c2b74f..2c7b16e340fe 100644 --- a/fs/erofs/erofs_fs.h +++ b/fs/erofs/erofs_fs.h @@ -109,14 +109,14 @@ static inline bool erofs_inode_is_data_compressed(unsigned int datamode) } /* bit definitions of inode i_format */ -#define EROFS_I_VERSION_BITS 1 -#define EROFS_I_DATALAYOUT_BITS 3 +#define EROFS_I_VERSION_MASK 0x01 +#define EROFS_I_DATALAYOUT_MASK 0x07 #define EROFS_I_VERSION_BIT 0 #define EROFS_I_DATALAYOUT_BIT 1 +#define EROFS_I_ALL_BIT 4 -#define EROFS_I_ALL \ - ((1 << (EROFS_I_DATALAYOUT_BIT + EROFS_I_DATALAYOUT_BITS)) - 1) +#define EROFS_I_ALL ((1 << EROFS_I_ALL_BIT) - 1) /* indicate chunk blkbits, thus 'chunksize = blocksize << chunk blkbits' */ #define EROFS_CHUNK_FORMAT_BLKBITS_MASK 0x001F diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 6c8c0504032e..e7b7d3f581c4 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -343,24 +343,14 @@ static inline erofs_off_t erofs_iloc(struct inode *inode) (EROFS_I(inode)->nid << sbi->islotbits); } -static inline unsigned int erofs_bitrange(unsigned int value, unsigned int bit, - unsigned int bits) +static inline unsigned int erofs_inode_version(unsigned int ifmt) { - - return (value >> bit) & ((1 << bits) - 1); -} - - -static inline unsigned int erofs_inode_version(unsigned int value) -{ - return erofs_bitrange(value, EROFS_I_VERSION_BIT, - EROFS_I_VERSION_BITS); + return (ifmt >> EROFS_I_VERSION_BIT) & EROFS_I_VERSION_MASK; } -static inline unsigned int erofs_inode_datalayout(unsigned int value) +static inline unsigned int erofs_inode_datalayout(unsigned int ifmt) { - return erofs_bitrange(value, EROFS_I_DATALAYOUT_BIT, - EROFS_I_DATALAYOUT_BITS); + return (ifmt >> EROFS_I_DATALAYOUT_BIT) & EROFS_I_DATALAYOUT_MASK; } /* -- 2.24.4