Message ID | 20230309152127.41427-4-frank.li@vivo.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp352480wrd; Thu, 9 Mar 2023 07:27:17 -0800 (PST) X-Google-Smtp-Source: AK7set+sTsRJkH1HW+gPy/CSLWZtV711lM9xjKMITHdSzAv5Ets0kfXLvo1w8PPBB57AHRbTybHv X-Received: by 2002:aa7:9546:0:b0:5d1:bb1a:f579 with SMTP id w6-20020aa79546000000b005d1bb1af579mr17711663pfq.4.1678375637633; Thu, 09 Mar 2023 07:27:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1678375637; cv=pass; d=google.com; s=arc-20160816; b=GOj0MzMwAiT8GGk4Z/e7cP+bZ4s9oIaeGCHvckLMk/FQOOloTDWLIZBPruTE8V71E7 DMK8f0DxLmbRpu0i/uy7wjRfzhTrM4ez3S/6My0U1cgVamCwZrgZV6pFcZKfESvTlLiZ Qsm51DTxvsL1gmyLuasbp2gC5S02i5JMFAhRiLNlXSbE8h6QUG9iCsECIf9afwUtnZmS Pc7xbwNK7lXr36n9oAYmJd65+3GfXty9DW71JGTvFZw2jPresX6f+FVDEGPXm7Hvu/t1 FGt+cJUbbqrYAbZmGOakH0bJaGXQzH7uysYXrYaiSphGg1rjg0rkSPv/Ucvrpz8jSlVe iGiA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=G74P5nAgOBnT3973GEAuaWOahRROTtd9l+A09L6rMFE=; b=YUkHY9rDAD08SHT7SdJBa5aC7e5pzl9x+aY9ioLDme3TclYd3WjS9AzT3xP8m1y/hj tm8bSMLB1BcN0mTxHriP0cH5DjwyNXuMGeVVn5JF709BNl4cjuIfO+kUN8cnDKQ8Y0EC c/6Hjjr75qoYp4oWt6NUK/32VrU8+KDl88lgX9GmKojNnsnZ0F3ajViGT5aWqeV5XGW/ OkGrR3gnHLvbMTKR1EkZIxpF5soU12xmJ0JW490TnHoOLT9PFBkjnt5TocWUo/2TBm5z O3blI8RyaI5hvIpeQTn/gbBjW3V2M27EC6MiPPfxjz+Y9ToTrzz1FGiXK+3xWiGTmFCk Hb9w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=rAZE++Ni; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z188-20020a6265c5000000b00593b8c172d8si16111388pfb.200.2023.03.09.07.27.02; Thu, 09 Mar 2023 07:27:17 -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; dkim=pass header.i=@vivo.com header.s=selector2 header.b=rAZE++Ni; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229544AbjCIPWc (ORCPT <rfc822;carlos.wei.hk@gmail.com> + 99 others); Thu, 9 Mar 2023 10:22:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229981AbjCIPWU (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 9 Mar 2023 10:22:20 -0500 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2100.outbound.protection.outlook.com [40.107.255.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ABF5ED68D; Thu, 9 Mar 2023 07:22:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fcE/kJOhXB5/1pcmhSTwMa833IWizB4BGSF1LfwQVo70NFrxvYYBuSEt4pyfvYG0TUtIz0sfJLaIjz6JsuI3fDM0AlX56wDcFqhPYKeR65U0ubfrhXfzKAyG7acBsnicfMjpAgu+ZrdQND+lHVaX0ygig8u1/RwAO1rJAwxkcXg70twWebrAhOc6NFzpQr+u4pzzygukujc5zHRLZ47PZUAOr5lFLUrJC2POc6Sf1iqd4d+9nrnOMxBs3naGiTCp2ufhi+xVX1cWnb1p1ZXtyx9iMTQUuNSXa8MgWGVLpryCaKTDp6ppq5/mpSZQj1s5E410JOdxZ/p6Pk8vTV++6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=G74P5nAgOBnT3973GEAuaWOahRROTtd9l+A09L6rMFE=; b=P1X1yguHqbUjxZC3QWtYQ4aYSQCQieiQ4MH9oYVuT1iRnTsxUt3klB68e9qW7bSLx6sLHC8Kr5GlOUukPUMDKrXyuC6R5Q4m4I/H5+G7+p51nSBCSR58Sp2r6My0/ElIZC1e5/S1+fr5zQnTJEoBFiNlTOK0InHlpQAcq6UJjB2mUb+9ulAiZqQKf9ZA0gczBa03OZ17H0CpDH5nRa9CKEYe65ChhaZJCRKcQuiHUFKVw00RJeRKCVsampITeR8IZMg97MqXQSg7eJ2ZBTySKFIa2Azft9UNsxBgUU8VLvkn11s5OuvoHIEJgFSvdi7th67ozCMasEV81twc7a2Lkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=G74P5nAgOBnT3973GEAuaWOahRROTtd9l+A09L6rMFE=; b=rAZE++Nip+T3xmn38Yj02pSeIhjtUtUNKbbaQq3fNVaeb7acz9fUbmqAtdWuGHhSCPNfciVwlP72UGZdUFIdEXPJydraUIgtjfVGeZTNEHs8Rk/y1atVqN+wC99w2am0WVnXyitLEQzQqR+XIO6E373/CUhKmkC2lTzquA66QtiMayyNRv8T+hrtjzG0j5eaFAtkyCa/SBmD1SVvtGZmYMI9M6IxjX+JHLToZM2XCLOGeG/WqPngz+hfKEDl1B3iE9/KZ41JaGqDwcre5R9BT4uru1YZRZC99h0LfunHdhFzfnYzK9WBeVv+XuwSLmROAUn1sKlJ+rKm6XuQIZkwwA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by SI2PR06MB4073.apcprd06.prod.outlook.com (2603:1096:4:f5::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Thu, 9 Mar 2023 15:22:16 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::daf6:5ebb:a93f:1869]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::daf6:5ebb:a93f:1869%9]) with mapi id 15.20.6178.019; Thu, 9 Mar 2023 15:22:16 +0000 From: Yangtao Li <frank.li@vivo.com> To: xiang@kernel.org, chao@kernel.org, huyue2@coolpad.com, jefflexu@linux.alibaba.com, tytso@mit.edu, adilger.kernel@dilger.ca, rpeterso@redhat.com, agruenba@redhat.com, mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com, viro@zeniv.linux.org.uk, brauner@kernel.org Cc: linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, cluster-devel@redhat.com, ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org, Yangtao Li <frank.li@vivo.com> Subject: [PATCH v3 4/6] ext4: convert to use i_blockmask() Date: Thu, 9 Mar 2023 23:21:25 +0800 Message-Id: <20230309152127.41427-4-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230309152127.41427-1-frank.li@vivo.com> References: <20230309152127.41427-1-frank.li@vivo.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR04CA0168.apcprd04.prod.outlook.com (2603:1096:4::30) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SI2PR06MB4073:EE_ X-MS-Office365-Filtering-Correlation-Id: 56a97193-f5e8-4681-cf1e-08db20b21104 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: au3ShEGDkB+EJng6ExCV4irih+z00QukWDh7Spxuy8qWzB/QKoK+CueEysS5/nkcABEu97dp/Qs1ayTZzhXvAsz9S9kDnJ9o4/dHCcLL6dw9SPf5Hh4swt8uLkao+3K7S5wwcpy1DLk4a8xtZArks1bPI5ZMPJeW0haZ57YnTWB0rRqryMEVq6DbIVnurNfBzQ5icFtLdtShWGbEMV43vrusCNvgtnRmBgKF6hE3XyLcbLfKIsz37ZcF+EChLDwf4/OCehLxwb21SCfphgueLuG74tRWKFUvywa+oU7Eb2NTNexAR+jwYzyX6c2TgKlLPmcYXDhfrCPNyGCrLOKYBNV8vBQvl89aPYa11VAuphzsWWcAe+egWE0zTbt3mAlePpoWWA2I4ys5K53VJOnHNia/q3EEhKNoHwnkMvnJaeVvPZfvg67OqGMl6MW/k7DHEK1gKJCO1K3VpMU6myXOcx14YWnXy6dEDMHRGm5ZFsRO6qxOH68vNA9azbeqackX2YB5T3dDUXQXpt7zMIxD5dSwIr57AlU7zZOAkXqHSDFTkqplNXvSpouJkFeXEqKJKwxJTMDb9QxBnXUB5HpmxQ5vLnn0lKbzJEnhKhEDSf82myryXjrQACiQ8cK0HRXVJ/u6rOA3uUeChqurd2UW+Q/cDRvDtN80GGof5sWWSigsnvE1Dy9RKEZpexV8NKFBT+96mHy47d1TUq+CaobJj7utACDMN30INvL0eQEUUsM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEZPR06MB5269.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(136003)(396003)(376002)(346002)(39860400002)(451199018)(316002)(36756003)(921005)(86362001)(38350700002)(38100700002)(1076003)(6506007)(26005)(107886003)(6512007)(83380400001)(6666004)(186003)(2616005)(8936002)(5660300002)(6486002)(478600001)(7416002)(52116002)(41300700001)(4744005)(66946007)(2906002)(66556008)(8676002)(4326008)(66476007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: J6UAysLpoBieQVl74u8AD7N6g9pZBKiK9aoHlx5UOs8MzLg5kLQAIpekTjxX4lkJHJycoA2byXmMFtjX2TsjltV0IDzQrko1CniKcojXQZ+v2TrQmQysu0ltzdXL8ljZdkocXRUHm/+ybfnnKpgETDprT1p9VBnwxemoD5uLM8RECM+N8sZ5naSyUzw+A8oLwjmvMA/eiWRruB22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nd/NJLAxIizoHT+bFdVp+ZKBfc8KsXg65Zui7vsYSmzn1rbWmPUgD21S1ab33ztL3fOsc88aUqYm/Z4V+A/DIjSyy7fWgSrwQVmsVwItUsU6v5AOMTSHiiZPME3doyCBxlVFwF3/m8L905Shz1ViGPUB9P6k7J85M6sYM++MuTYjzZd1nB2kfmRN+dL3OAwlAHyfPv3eSHnYzq+IUKxfuPhjA0JMFnciEOGmmBvrX7K9AAf+3b12H6LUMdpFjVEiMj2gVyrZtvXG7c0xlQiWx1yN5eil2jKEmXjrQY2L8XQIegV7cGVmF X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 56a97193-f5e8-4681-cf1e-08db20b21104 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 15:22:16.7352 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: faSx+15nOOVnxKx09cjuIr/fJZJg5x4PEYIAtclVHogsw9WqPzeR+hciF7EE/sTXuOlHCF7Jw70/lfFxIfKYDg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR06MB4073 X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL,SPF_HELO_PASS,SPF_PASS autolearn=no 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759904412811282478?= X-GMAIL-MSGID: =?utf-8?q?1759904412811282478?= |
Series | [v3,1/6] fs: add i_blockmask() | |
Commit Message
李扬韬
March 9, 2023, 3:21 p.m. UTC
Use i_blockmask() to simplify code.
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
v3:
-none
v2:
-convert to i_blockmask()
fs/ext4/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Thu, Mar 09, 2023 at 11:21:25PM +0800, Yangtao Li wrote: > Use i_blockmask() to simplify code. > > Signed-off-by: Yangtao Li <frank.li@vivo.com> > --- > v3: > -none > v2: > -convert to i_blockmask() > fs/ext4/inode.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index d251d705c276..eec36520e5e9 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -2218,7 +2218,7 @@ static int mpage_process_page_bufs(struct mpage_da_data *mpd, > { > struct inode *inode = mpd->inode; > int err; > - ext4_lblk_t blocks = (i_size_read(inode) + i_blocksize(inode) - 1) > + ext4_lblk_t blocks = (i_size_read(inode) + i_blockmask(inode)) > >> inode->i_blkbits; Umm... That actually asks for DIV_ROUND_UP(i_size_read_inode(), i_blocksize(inode)) - compiler should bloody well be able to figure out that division by (1 << n) is shift down by n and it's easier to follow that way...
On Fri, Mar 10, 2023 at 03:19:40AM +0000, Al Viro wrote: > On Thu, Mar 09, 2023 at 11:21:25PM +0800, Yangtao Li wrote: > > Use i_blockmask() to simplify code. > > > > Signed-off-by: Yangtao Li <frank.li@vivo.com> > > --- > > v3: > > -none > > v2: > > -convert to i_blockmask() > > fs/ext4/inode.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > > index d251d705c276..eec36520e5e9 100644 > > --- a/fs/ext4/inode.c > > +++ b/fs/ext4/inode.c > > @@ -2218,7 +2218,7 @@ static int mpage_process_page_bufs(struct mpage_da_data *mpd, > > { > > struct inode *inode = mpd->inode; > > int err; > > - ext4_lblk_t blocks = (i_size_read(inode) + i_blocksize(inode) - 1) > > + ext4_lblk_t blocks = (i_size_read(inode) + i_blockmask(inode)) > > >> inode->i_blkbits; > > Umm... That actually asks for DIV_ROUND_UP(i_size_read_inode(), i_blocksize(inode)) - > compiler should bloody well be able to figure out that division by (1 << n) is > shift down by n and it's easier to follow that way... BTW, here the fact that you are adding the mask is misleading - it's true, but we are not using it as a mask - it's straight arithmetics. One can do an equivalent code where it would've been used as a mask, but that would be harder to read - (((i_size_read(inode) - 1) | i_blockmask(inode)) + 1) >> inode->i_blkbits and I doubt anyone wants that kind of puzzles to stumble upon.
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index d251d705c276..eec36520e5e9 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2218,7 +2218,7 @@ static int mpage_process_page_bufs(struct mpage_da_data *mpd, { struct inode *inode = mpd->inode; int err; - ext4_lblk_t blocks = (i_size_read(inode) + i_blocksize(inode) - 1) + ext4_lblk_t blocks = (i_size_read(inode) + i_blockmask(inode)) >> inode->i_blkbits; if (ext4_verity_in_progress(inode))