From patchwork Fri Mar 10 08:24:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 67280 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp757804wrd; Fri, 10 Mar 2023 00:52:49 -0800 (PST) X-Google-Smtp-Source: AK7set/QN6mVyWYdR0FMSRvsb1JMqBFjOtQz17wEsdAiFd8NqgJVmlAvhyJV6YeeSEjuXu9AEwmz X-Received: by 2002:a62:17d0:0:b0:5e2:da34:4aad with SMTP id 199-20020a6217d0000000b005e2da344aadmr21100750pfx.27.1678438369348; Fri, 10 Mar 2023 00:52:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1678438369; cv=pass; d=google.com; s=arc-20160816; b=Ozy3zOHgHL8tWtWwIcefMxk1eUvNLWR2bKNu+zqTjBbOTyFHQwyOtWZk0tqmVeIc5Y 0SMzA87hMdEpFieLMk97bphnmrgSJKAAZZ3wCrOkpNARw+EuqHTw1xKA97uWY2uTOWCt zchh/0zBNb6Ygf6Y/OC+aYBAIXD/tBY5/G8w6Hjpa9tiE/LOv4TQLQnr8b6nE6b0/Wjb G3mGVC5fk3FV67IZUBRQBQxALZqpjR4ry7l3Nd2waAdyZ/bdkpwFgLpOGi15x8kjIqVx WxEYYvhUOf1QYUkBPDOKPgalI7cVmGuuMQrLDmS/CX8G1tw3qZLfZMgcfEp8cN8Qgmyz ibNg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=YB24UzYT8fYvSZtDtqyFDzx4FEZM+BL/2udeGnDmwKA=; b=0sSsqkscCO0HmqGDBAt1kBdK0kX7RdHEk7FTuWPaXoSMlCXjgE11KNwY7lsV9clrdw 0bWQzO6+SJ80uGKmxMzzoTEOcGD6xCPG/qLta6vu3M8Sy2FdQXkm0R348EQGTUQjZiXe ELb/GkDTV36VziAftLyv1PxVmRsYmR6ZEGM6wzphx6aJZidDP7cFcV0DjMT9iTc0qor9 9aIFwbYHitpCk10UMlapQPTwNEY3A7FVx2bSFUhyu21mDqD0TyjJR2YFCgqvvQiuyoUx t/XAGKeFSCCCW/H2caMtEMEk0qJ3c2ZrGnBC+4y5PupFNeiymsgCvPD5ZE+iHEwoR2+k hjiA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=a31cEvM0; 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 m191-20020a633fc8000000b00502d6f5fb2dsi1494446pga.805.2023.03.10.00.52.36; Fri, 10 Mar 2023 00:52:49 -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=a31cEvM0; 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 S230300AbjCJIYd (ORCPT + 99 others); Fri, 10 Mar 2023 03:24:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbjCJIY3 (ORCPT ); Fri, 10 Mar 2023 03:24:29 -0500 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2100.outbound.protection.outlook.com [40.107.117.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D98A5FA8CC; Fri, 10 Mar 2023 00:24:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=maYJWKLGfXJK1xEoQgq6J7Ic2EL5msGt9Ut1Bb/pw3vtHnm/TUTwiV0wChIb8yXL62ggEZaar0U7G0oLwPCDMABdtM0ilINcAKJUb2E6ou/YATS04Vowb607npnQ0bnKCWZMCYw5dPrhp12epiLM9ef73fLXcPWyl8uflrW+kBtfcRXzLV9wKpiyX2qy04Bf2ADc/u3GH9FApWn+0YkHGQJfzLvoqehmFEcIoHVq7fyvYdAs5zNlcCtCsvTr82kPGYyhBTbVsTU44gQGFBnC5yu1RVj/9IQdJskeSV+roFc0vMFIBdW9nmHCYeZWTgfflIwDpBGGLcHXMv1+T5H72Q== 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=YB24UzYT8fYvSZtDtqyFDzx4FEZM+BL/2udeGnDmwKA=; b=YH1+IZO4iLEyeMU9rVNIPGBSWfzlfDcTd9mGghmqxT37ud1/X1T892hW5qUnb5yZ3PJIP+H2bUv1+a50T/xawN+8gR+Spy2iBJvL1UL7vor5igGAyx+4oAx+JvSGMAVPDXIwNkNiMo3PLwSpY08cg7MUqwPHGBfshcqa1JzU3kd15T0Vo33U/CpdulHCjZISoy0UjGF6kJL3jnRLZbBE3CvDWU+iCeIWRnzqAGxu3PDdiRZk/TiDpM6OMiEupSOkScur4GiG/R+UwkWyzZmao/Erk74lRUoytaKfOq1iHKi1uhid3oEdjaguHrwoZ1v+EbcdiDj0TdWL2dNMKLvU6g== 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=YB24UzYT8fYvSZtDtqyFDzx4FEZM+BL/2udeGnDmwKA=; b=a31cEvM0AcQ4v6cPwb3EHPBy9oCp/JUxlgm36fEVCJLlYSMY7QqOBOBywYjgXO4cCTAphB3vHrVxJUK7WIDgAHRImZXkyr8bVD8KnBl42j20PXfzvKp+pcroNZyH9fZVcDM1cAyS61LHEF/r3U53Ojw2Kmdct1GGrVF4uobo07rj74XSkVN5X37m61I9WA+2yyVn4ljBn4w8RnJjiO5T6qw5Ef6h9vbbOWV/k+dy/e5UsqAH73apXheZ/330/BukTDuptzI6SNy6xZMyULJ/kSGOXcwf6pX1d+uC1shblxCwmfdZkWGR9YXIXMmVZcBsBCe2+XHbxRwhQDZNScXeMQ== 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 PSAPR06MB4309.apcprd06.prod.outlook.com (2603:1096:301:8f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Fri, 10 Mar 2023 08:24:24 +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; Fri, 10 Mar 2023 08:24:24 +0000 From: Yangtao Li To: axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Yangtao Li Subject: [PATCH] block: add queue_logical_block_mask() and bdev_logical_block_mask() Date: Fri, 10 Mar 2023 16:24:13 +0800 Message-Id: <20230310082413.58141-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SG2PR04CA0199.apcprd04.prod.outlook.com (2603:1096:4:187::13) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|PSAPR06MB4309:EE_ X-MS-Office365-Filtering-Correlation-Id: b33c5f41-b69e-479e-71fd-08db2140db33 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JYR1iyLtonOk5q0x0Jw+sxJ1Lyfjh44vGST0h3TxxBcGsdHGoWKYfE9YQGGefM8qWA4+fDTPfTYKfbABSB7oxuS0zCnlwh8dfpwgs3QaKgKInbr91y6tsQ9MOFvidIdYCAUeF0UgcLMKeQIvtsOrO7PVzMmS64nrSdGdnKJ823sPer7U0za0pAsIkqkgSGPDd5G3Vn5iJq3pvi8aWazqs9pdUK9mc9U+x4X+lGe1M9kMQL57J5lMZzBt+Nomn/6E7xMpFj3NfYb0pGJ8jxD7jeAqx+7wWPvB5n4TB1iUeI8lDGMxFJk6IeuHavF/jQugg5JGN6SwCtIvKbxDB6l0miqi4Kt7bXtUDP82yrk/M8Ris3is6qiArLy+4UhDAOI8MZgSMBz9+Em6GYm27L1oEV6tR23siS2wHZgX+DVII0krMspW0kcLiVZVXR++QBShRhX6vMfxID+9KaTJ9e3GJQpfxP4YC/A3D7QjKxV80c1LJ3PcTWq0t0IYE7bCeSNlfK76ZiVxpbkRZK6wupW7XyJV1g5Zq5eH/CyTHvZ5k1h+ZHrLLCP5E7ghHZ8/O8M/uGBUh7pVLoN2m6H/dCeACFDkFgjdBTWfBkdvvbQ2vYqZCeseHbHeeqK04Nqu+Tee1peNkpN8ej37xp5L1xp1STgCBYeKXDOnHjmbTJY7wzop07d/hXNtzPTS2BI4mog0 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)(39860400002)(136003)(346002)(396003)(376002)(451199018)(316002)(36756003)(6506007)(38350700002)(86362001)(38100700002)(41300700001)(6512007)(1076003)(6666004)(26005)(107886003)(83380400001)(186003)(2616005)(8936002)(5660300002)(478600001)(52116002)(6486002)(966005)(6916009)(2906002)(4326008)(66556008)(66476007)(66946007)(8676002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: W3PgL9yhbeG4Nux0J2Vn+q/F9a0+qmv6uHn4TxjyRHvw6ZlzUyeyF1IBEWLuc0kpqvKtjtABaowujlbkCii4Qrwym5O7ur8QiH6K73/iShdoPwcVhbBgEc8IvJNjLoy29/xonehrA8AXWhlpmT6wFcF03CQTdcORblruQx76Bd2N3GvDTdfwLnErH13t4gCA8HmoaJKogq9wOyrDtF4vh54GJnL/W+tCj4BvQGsYE5v1az1krLuCcZ8pgkeP/PyMuOc2LhAH2tvMCQTyZoiFA+DUlRL/7htBravFnX/ZQwklWPpSkeUsri4CGmi4FKoUClWeGmOsHwVDBNdigoQmr2fC+Afgm2I7a1LtNd2gJ+WHipymR6Q33soQkMAI16uIlQnYLItc9kB2Hw4/IhJDdpEu4dIo73CxdZBnkD/vAUWipTCluZiwBYOY53WkwIm/s6eUFMPWHsiKRLyp14cpRRq/pcdow0DUT0mjvKpoA9Gmdfb8+3Ux/bupNCaGSrj/tFWkI0pUWDCOT2u32nrR1vOc9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exchange-CrossTenant-Network-Message-Id: b33c5f41-b69e-479e-71fd-08db2140db33 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 08:24:24.5230 (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: rs6203TA7g3jCAVdWnTxW9GnHWnNuYbIDthO82nII06aCiAF9AoXxyrmQkJRUVY3hbVH4pPfymA/fMT1H8K52g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PSAPR06MB4309 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED 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?1759970191726968570?= X-GMAIL-MSGID: =?utf-8?q?1759970191726968570?= Introduce queue_logical_block_mask() and bdev_logical_block_mask() to simplify code, which replace (queue_logical_block_size(q) - 1) and (bdev_logical_block_size(bdev) - 1). Signed-off-by: Yangtao Li --- Like wo done for fs. This round we add helpers and start converting in the next cycle. https://lore.kernel.org/lkml/20230309124035.15820-1-frank.li@vivo.com/ include/linux/blkdev.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index d1aee08f8c18..a68a704e5ea5 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1173,11 +1173,21 @@ static inline unsigned queue_logical_block_size(const struct request_queue *q) return retval; } +static inline unsigned int queue_logical_block_mask(const struct request_queue *q) +{ + return queue_logical_block_size(q) - 1; +} + static inline unsigned int bdev_logical_block_size(struct block_device *bdev) { return queue_logical_block_size(bdev_get_queue(bdev)); } +static inline unsigned int bdev_logical_block_mask(struct block_device *bdev) +{ + return bdev_logical_block_size(bdev) - 1; +} + static inline unsigned int queue_physical_block_size(const struct request_queue *q) { return q->limits.physical_block_size;