From patchwork Tue May 5 11:55:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 11528879 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0C4A31668 for ; Tue, 5 May 2020 11:56:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D805F206A4 for ; Tue, 5 May 2020 11:56:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D805F206A4 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 BD23E8E00C2; Tue, 5 May 2020 07:56:09 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B81EC8E00C0; Tue, 5 May 2020 07:56:09 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A49818E00C2; Tue, 5 May 2020 07:56:09 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0243.hostedemail.com [216.40.44.243]) by kanga.kvack.org (Postfix) with ESMTP id 875628E00BF for ; Tue, 5 May 2020 07:56:09 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 48ACC180AD806 for ; Tue, 5 May 2020 11:56:09 +0000 (UTC) X-FDA: 76782512058.19.room80_6fe0e42d04e11 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,thunder.leizhen@huawei.com,,RULES_HIT:30012:30045:30054,0,RBL:45.249.212.191:@huawei.com:.lbl8.mailshell.net-62.18.2.100 64.95.201.95,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: room80_6fe0e42d04e11 X-Filterd-Recvd-Size: 4163 Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Tue, 5 May 2020 11:56:08 +0000 (UTC) Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id C87C3311B16D4642CC9A; Tue, 5 May 2020 19:56:03 +0800 (CST) Received: from DESKTOP-C3MD9UG.china.huawei.com (10.166.215.55) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Tue, 5 May 2020 19:55:57 +0800 From: Zhen Lei To: Minchan Kim , Nitin Gupta , "Sergey Senozhatsky" , Jens Axboe , linux-block , Andrew Morton , linux-mm , Alasdair Kergon , Mike Snitzer , dm-devel , Song Liu , linux-raid , linux-kernel CC: Zhen Lei Subject: [PATCH 3/4] block: use SECTORS_PER_PAGE_SHIFT and SECTORS_PER_PAGE to clean up code Date: Tue, 5 May 2020 19:55:42 +0800 Message-ID: <20200505115543.1660-4-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 In-Reply-To: <20200505115543.1660-1-thunder.leizhen@huawei.com> References: <20200505115543.1660-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.166.215.55] X-CFilter-Loop: Reflected 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 SECTORS_PER_PAGE 2. Replace "PAGE_SHIFT - 9" with SECTORS_PER_PAGE_SHIFT 3. Replace "9" with SECTOR_SHIFT Signed-off-by: Zhen Lei --- block/blk-settings.c | 8 ++++---- block/partitions/core.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/block/blk-settings.c b/block/blk-settings.c index 14397b4c4b53..a62037a7ff0f 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -149,8 +149,8 @@ void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_secto struct queue_limits *limits = &q->limits; unsigned int max_sectors; - if ((max_hw_sectors << 9) < PAGE_SIZE) { - max_hw_sectors = 1 << (PAGE_SHIFT - 9); + if ((max_hw_sectors << SECTOR_SHIFT) < PAGE_SIZE) { + max_hw_sectors = SECTORS_PER_PAGE; 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 = min_not_zero(max_hw_sectors, limits->max_dev_sectors); max_sectors = min_t(unsigned int, max_sectors, BLK_DEF_MAX_SECTORS); limits->max_sectors = max_sectors; - q->backing_dev_info->io_pages = max_sectors >> (PAGE_SHIFT - 9); + q->backing_dev_info->io_pages = max_sectors >> SECTORS_PER_PAGE_SHIFT; } EXPORT_SYMBOL(blk_queue_max_hw_sectors); @@ -630,7 +630,7 @@ void disk_stack_limits(struct gendisk *disk, struct block_device *bdev, } t->backing_dev_info->io_pages = - t->limits.max_sectors >> (PAGE_SHIFT - 9); + t->limits.max_sectors >> SECTORS_PER_PAGE_SHIFT; } EXPORT_SYMBOL(disk_stack_limits); diff --git a/block/partitions/core.c b/block/partitions/core.c index 9ef48a8cff86..6e44ac840ca0 100644 --- a/block/partitions/core.c +++ b/block/partitions/core.c @@ -641,7 +641,7 @@ void *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p) } page = read_mapping_page(mapping, - (pgoff_t)(n >> (PAGE_SHIFT - 9)), NULL); + (pgoff_t)(n >> SECTORS_PER_PAGE_SHIFT), NULL); if (IS_ERR(page)) goto out; if (PageError(page)) @@ -649,7 +649,7 @@ void *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p) p->v = page; return (unsigned char *)page_address(page) + - ((n & ((1 << (PAGE_SHIFT - 9)) - 1)) << SECTOR_SHIFT); + ((n & (SECTORS_PER_PAGE - 1)) << SECTOR_SHIFT); out_put_page: put_page(page); out: