From patchwork Thu May 7 07:50:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 11532731 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 A8A22913 for ; Thu, 7 May 2020 07:56:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 74A5920CC7 for ; Thu, 7 May 2020 07:56:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74A5920CC7 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 79BF1900007; Thu, 7 May 2020 03:56:04 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 72369900006; Thu, 7 May 2020 03:56:04 -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 66080900007; Thu, 7 May 2020 03:56:04 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0251.hostedemail.com [216.40.44.251]) by kanga.kvack.org (Postfix) with ESMTP id 46CE3900006 for ; Thu, 7 May 2020 03:56:04 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 019AE180AD811 for ; Thu, 7 May 2020 07:56:04 +0000 (UTC) X-FDA: 76789164648.04.slip63_17ca24df61849 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,thunder.leizhen@huawei.com,,RULES_HIT:30029:30054,0,RBL:45.249.212.32:@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:23,LUA_SUMMARY:none X-HE-Tag: slip63_17ca24df61849 X-Filterd-Recvd-Size: 5050 Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 May 2020 07:56:03 +0000 (UTC) Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A7051CED3291C742681E; 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:48 +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 05/10] block: abolish macro PAGE_SECTORS_SHIFT Date: Thu, 7 May 2020 15:50:55 +0800 Message-ID: <20200507075100.1779-6-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 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: The name of PAGE_SECTORS_SHIFT is quite hard to read. 1. use sectors_to_npage() to replace ">> PAGE_SECTORS_SHIFT" 2. use npage_to_sectors() to replace "<< PAGE_SECTORS_SHIFT" Suggested-by: Matthew Wilcox Signed-off-by: Zhen Lei --- drivers/block/brd.c | 6 ++---- drivers/block/null_blk_main.c | 9 ++++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 30df6daa9dbc..051c5a50497f 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -25,8 +25,6 @@ #include -#define PAGE_SECTORS_SHIFT (PAGE_SHIFT - SECTOR_SHIFT) - /* * Each block ramdisk device has a radix_tree brd_pages of pages that stores * the pages containing the block device's contents. A brd page's ->index is @@ -69,7 +67,7 @@ static struct page *brd_lookup_page(struct brd_device *brd, sector_t sector) * here, only deletes). */ rcu_read_lock(); - idx = sector >> PAGE_SECTORS_SHIFT; /* sector to page index */ + idx = sectors_to_npage(sector); page = radix_tree_lookup(&brd->brd_pages, idx); rcu_read_unlock(); @@ -108,7 +106,7 @@ static struct page *brd_insert_page(struct brd_device *brd, sector_t sector) } spin_lock(&brd->brd_lock); - idx = sector >> PAGE_SECTORS_SHIFT; + idx = sectors_to_npage(sector); page->index = idx; if (radix_tree_insert(&brd->brd_pages, idx, page)) { __free_page(page); diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 25048ff15858..81485f47dcf0 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -11,7 +11,6 @@ #include #include "null_blk.h" -#define PAGE_SECTORS_SHIFT (PAGE_SHIFT - SECTOR_SHIFT) #define SECTOR_MASK (PAGE_SECTORS - 1) #define FREE_BATCH 16 @@ -737,7 +736,7 @@ static void null_free_sector(struct nullb *nullb, sector_t sector, struct radix_tree_root *root; root = is_cache ? &nullb->dev->cache : &nullb->dev->data; - idx = sector >> PAGE_SECTORS_SHIFT; + idx = sectors_to_npage(sector); sector_bit = (sector & SECTOR_MASK); t_page = radix_tree_lookup(root, idx); @@ -808,7 +807,7 @@ static struct nullb_page *__null_lookup_page(struct nullb *nullb, struct nullb_page *t_page; struct radix_tree_root *root; - idx = sector >> PAGE_SECTORS_SHIFT; + idx = sectors_to_npage(sector); sector_bit = (sector & SECTOR_MASK); root = is_cache ? &nullb->dev->cache : &nullb->dev->data; @@ -855,7 +854,7 @@ static struct nullb_page *null_insert_page(struct nullb *nullb, goto out_freepage; spin_lock_irq(&nullb->lock); - idx = sector >> PAGE_SECTORS_SHIFT; + idx = sectors_to_npage(sector); t_page->page->index = idx; t_page = null_radix_tree_insert(nullb, idx, t_page, !ignore_cache); radix_tree_preload_end(); @@ -878,7 +877,7 @@ static int null_flush_cache_page(struct nullb *nullb, struct nullb_page *c_page) idx = c_page->page->index; - t_page = null_insert_page(nullb, idx << PAGE_SECTORS_SHIFT, true); + t_page = null_insert_page(nullb, npage_to_sectors(idx), true); __clear_bit(NULLB_PAGE_LOCK, c_page->bitmap); if (test_bit(NULLB_PAGE_FREE, c_page->bitmap)) {