From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21010C47247 for ; Thu, 7 May 2020 07:56:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D87192083B for ; Thu, 7 May 2020 07:56:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D87192083B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2422C90000A; Thu, 7 May 2020 03:56:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1F771900009; Thu, 7 May 2020 03:56:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0441F90000A; Thu, 7 May 2020 03:56:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0175.hostedemail.com [216.40.44.175]) by kanga.kvack.org (Postfix) with ESMTP id D8284900009 for ; Thu, 7 May 2020 03:56:05 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A03D8124F for ; Thu, 7 May 2020 07:56:05 +0000 (UTC) X-FDA: 76789164690.20.error93_1808b6e418419 X-HE-Tag: error93_1808b6e418419 X-Filterd-Recvd-Size: 4203 Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 May 2020 07:56:05 +0000 (UTC) Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 9EE03EA0C306B46DD563; Thu, 7 May 2020 15:55:58 +0800 (CST) Received: from DESKTOP-C3MD9UG.china.huawei.com (10.166.215.55) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Thu, 7 May 2020 15:55:50 +0800 From: Zhen Lei To: Minchan Kim , Nitin Gupta , "Sergey Senozhatsky" , Matthew Wilcox , Jens Axboe , Coly Li , Kent Overstreet , "Alasdair Kergon" , Mike Snitzer , linux-block , Andrew Morton , linux-mm , dm-devel , Song Liu , linux-raid , linux-kernel CC: Zhen Lei Subject: [PATCH v2 07/10] block: use sectors_to_npage() and PAGE_SECTORS to clean up code Date: Thu, 7 May 2020 15:50:57 +0800 Message-ID: <20200507075100.1779-8-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 In-Reply-To: <20200507075100.1779-1-thunder.leizhen@huawei.com> References: <20200507075100.1779-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.166.215.55] X-CFilter-Loop: Reflected Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 1. Replace "1 << (PAGE_SHIFT - 9)" with PAGE_SECTORS 2. Replace ">> (PAGE_SHIFT - 9)" with sectors_to_npage() Suggested-by: Matthew Wilcox Signed-off-by: Zhen Lei --- block/blk-settings.c | 6 +++--- block/partitions/core.c | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/block/blk-settings.c b/block/blk-settings.c index 14397b4c4b53..171665ed8318 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -150,7 +150,7 @@ void blk_queue_max_hw_sectors(struct request_queue *q= , unsigned int max_hw_secto unsigned int max_sectors; =20 if ((max_hw_sectors << 9) < PAGE_SIZE) { - max_hw_sectors =3D 1 << (PAGE_SHIFT - 9); + max_hw_sectors =3D PAGE_SECTORS; printk(KERN_INFO "%s: set to minimum %d\n", __func__, max_hw_sectors); } @@ -159,7 +159,7 @@ void blk_queue_max_hw_sectors(struct request_queue *q= , unsigned int max_hw_secto max_sectors =3D min_not_zero(max_hw_sectors, limits->max_dev_sectors); max_sectors =3D min_t(unsigned int, max_sectors, BLK_DEF_MAX_SECTORS); limits->max_sectors =3D max_sectors; - q->backing_dev_info->io_pages =3D max_sectors >> (PAGE_SHIFT - 9); + q->backing_dev_info->io_pages =3D sectors_to_npage(max_sectors); } EXPORT_SYMBOL(blk_queue_max_hw_sectors); =20 @@ -630,7 +630,7 @@ void disk_stack_limits(struct gendisk *disk, struct b= lock_device *bdev, } =20 t->backing_dev_info->io_pages =3D - t->limits.max_sectors >> (PAGE_SHIFT - 9); + sectors_to_npage(t->limits.max_sectors); } EXPORT_SYMBOL(disk_stack_limits); =20 diff --git a/block/partitions/core.c b/block/partitions/core.c index 9ef48a8cff86..4859739a2414 100644 --- a/block/partitions/core.c +++ b/block/partitions/core.c @@ -640,8 +640,7 @@ void *read_part_sector(struct parsed_partitions *stat= e, sector_t n, Sector *p) return NULL; } =20 - page =3D read_mapping_page(mapping, - (pgoff_t)(n >> (PAGE_SHIFT - 9)), NULL); + page =3D read_mapping_page(mapping, (pgoff_t)sectors_to_npage(n), NULL)= ; if (IS_ERR(page)) goto out; if (PageError(page)) @@ -649,7 +648,7 @@ void *read_part_sector(struct parsed_partitions *stat= e, sector_t n, Sector *p) =20 p->v =3D page; return (unsigned char *)page_address(page) + - ((n & ((1 << (PAGE_SHIFT - 9)) - 1)) << SECTOR_SHIFT); + ((n & (PAGE_SECTORS - 1)) << SECTOR_SHIFT); out_put_page: put_page(page); out: --=20 2.26.0.106.g9fadedd