From patchwork Thu May 7 07:50:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 11532725 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 9640814B4 for ; Thu, 7 May 2020 07:56:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 639D32084D for ; Thu, 7 May 2020 07:56:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 639D32084D 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 881E1900004; Thu, 7 May 2020 03:56:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 83259900002; Thu, 7 May 2020 03:56:01 -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 66045900004; Thu, 7 May 2020 03:56:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0134.hostedemail.com [216.40.44.134]) by kanga.kvack.org (Postfix) with ESMTP id 4F58F900002 for ; Thu, 7 May 2020 03:56:01 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 070138248D51 for ; Thu, 7 May 2020 07:56:01 +0000 (UTC) X-FDA: 76789164522.03.sound75_1748fcfe38c3b X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,thunder.leizhen@huawei.com,,RULES_HIT: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: sound75_1748fcfe38c3b X-Filterd-Recvd-Size: 4420 Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 May 2020 07:55:59 +0000 (UTC) Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 5F976B5F71AE7B2ED715; Thu, 7 May 2020 15:55:53 +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:45 +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 01/10] block: move PAGE_SECTORS definition into Date: Thu, 7 May 2020 15:50:51 +0800 Message-ID: <20200507075100.1779-2-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: Too many duplicated PAGE_SECTORS definitions, eliminate it. Signed-off-by: Zhen Lei --- drivers/block/brd.c | 1 - drivers/block/null_blk_main.c | 1 - drivers/md/bcache/util.h | 2 -- include/linux/blkdev.h | 5 +++-- include/linux/device-mapper.h | 1 - 5 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 2fb25c348d53..30df6daa9dbc 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -26,7 +26,6 @@ #include #define PAGE_SECTORS_SHIFT (PAGE_SHIFT - SECTOR_SHIFT) -#define PAGE_SECTORS (1 << PAGE_SECTORS_SHIFT) /* * Each block ramdisk device has a radix_tree brd_pages of pages that stores diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 8efd8778e209..25048ff15858 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -12,7 +12,6 @@ #include "null_blk.h" #define PAGE_SECTORS_SHIFT (PAGE_SHIFT - SECTOR_SHIFT) -#define PAGE_SECTORS (1 << PAGE_SECTORS_SHIFT) #define SECTOR_MASK (PAGE_SECTORS - 1) #define FREE_BATCH 16 diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h index c029f7443190..55196e0f37c3 100644 --- a/drivers/md/bcache/util.h +++ b/drivers/md/bcache/util.h @@ -15,8 +15,6 @@ #include "closure.h" -#define PAGE_SECTORS (PAGE_SIZE / 512) - struct closure; #ifdef CONFIG_BCACHE_DEBUG diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 32868fbedc9e..934f31fc15cd 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -904,11 +904,12 @@ static inline struct request_queue *bdev_get_queue(struct block_device *bdev) * multiple of 512 bytes. Hence these two constants. */ #ifndef SECTOR_SHIFT -#define SECTOR_SHIFT 9 +#define SECTOR_SHIFT 9 #endif #ifndef SECTOR_SIZE -#define SECTOR_SIZE (1 << SECTOR_SHIFT) +#define SECTOR_SIZE (1 << SECTOR_SHIFT) #endif +#define PAGE_SECTORS (PAGE_SIZE / SECTOR_SIZE) /* * blk_rq_pos() : the current sector diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index af48d9da3916..83e018ed8c21 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -143,7 +143,6 @@ typedef size_t (*dm_dax_copy_iter_fn)(struct dm_target *ti, pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i); typedef int (*dm_dax_zero_page_range_fn)(struct dm_target *ti, pgoff_t pgoff, size_t nr_pages); -#define PAGE_SECTORS (PAGE_SIZE / 512) void dm_error(const char *message); From patchwork Thu May 7 07:50:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 11532727 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 D7B5A14B4 for ; Thu, 7 May 2020 07:56:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A504E2080D for ; Thu, 7 May 2020 07:56:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A504E2080D 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 3EF9B900005; Thu, 7 May 2020 03:56:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3C67A900002; Thu, 7 May 2020 03:56:03 -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 2DE42900005; Thu, 7 May 2020 03:56:03 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0096.hostedemail.com [216.40.44.96]) by kanga.kvack.org (Postfix) with ESMTP id 17499900002 for ; Thu, 7 May 2020 03:56:03 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id D39478248D51 for ; Thu, 7 May 2020 07:56:02 +0000 (UTC) X-FDA: 76789164564.07.sand41_17902600f0c36 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,thunder.leizhen@huawei.com,,RULES_HIT:30054:30090,0,RBL:45.249.212.32:@huawei.com:.lbl8.mailshell.net-64.95.201.95 62.18.2.100,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: sand41_17902600f0c36 X-Filterd-Recvd-Size: 3534 Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 May 2020 07:56:01 +0000 (UTC) Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 708B77979A8DA881C073; Thu, 7 May 2020 15:55:53 +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:46 +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 02/10] zram: abolish macro SECTORS_PER_PAGE Date: Thu, 7 May 2020 15:50:52 +0800 Message-ID: <20200507075100.1779-3-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: SECTORS_PER_PAGE is equivalent to PAGE_SECTORS. Although I prefer SECTORS_PER_PAGE better than PAGE_SECTORS, the former is more clearer, I think. But the latter was defined in before, rename it may impact users. Signed-off-by: Zhen Lei --- drivers/block/zram/zram_drv.c | 4 ++-- drivers/block/zram/zram_drv.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index ebb234f36909..e2fbf7a847e7 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1551,7 +1551,7 @@ static void __zram_make_request(struct zram *zram, struct bio *bio) index = bio->bi_iter.bi_sector >> SECTORS_PER_PAGE_SHIFT; offset = (bio->bi_iter.bi_sector & - (SECTORS_PER_PAGE - 1)) << SECTOR_SHIFT; + (PAGE_SECTORS - 1)) << SECTOR_SHIFT; switch (bio_op(bio)) { case REQ_OP_DISCARD: @@ -1645,7 +1645,7 @@ static int zram_rw_page(struct block_device *bdev, sector_t sector, } index = sector >> SECTORS_PER_PAGE_SHIFT; - offset = (sector & (SECTORS_PER_PAGE - 1)) << SECTOR_SHIFT; + offset = (sector & (PAGE_SECTORS - 1)) << SECTOR_SHIFT; bv.bv_page = page; bv.bv_len = PAGE_SIZE; diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h index f2fd46daa760..10fdf413dd6e 100644 --- a/drivers/block/zram/zram_drv.h +++ b/drivers/block/zram/zram_drv.h @@ -22,7 +22,6 @@ #include "zcomp.h" #define SECTORS_PER_PAGE_SHIFT (PAGE_SHIFT - SECTOR_SHIFT) -#define SECTORS_PER_PAGE (1 << SECTORS_PER_PAGE_SHIFT) #define ZRAM_LOGICAL_BLOCK_SHIFT 12 #define ZRAM_LOGICAL_BLOCK_SIZE (1 << ZRAM_LOGICAL_BLOCK_SHIFT) #define ZRAM_SECTOR_PER_LOGICAL_BLOCK \ From patchwork Thu May 7 07:50:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 11532723 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 28E9F913 for ; Thu, 7 May 2020 07:56:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F198C208E4 for ; Thu, 7 May 2020 07:56:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F198C208E4 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 2B6ED900003; Thu, 7 May 2020 03:55:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 266E2900002; Thu, 7 May 2020 03:55:58 -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 1560C900003; Thu, 7 May 2020 03:55:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0077.hostedemail.com [216.40.44.77]) by kanga.kvack.org (Postfix) with ESMTP id F13D2900002 for ; Thu, 7 May 2020 03:55:57 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B5FF313083 for ; Thu, 7 May 2020 07:55:57 +0000 (UTC) X-FDA: 76789164354.13.bun31_16d899c872a0a X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,thunder.leizhen@huawei.com,,RULES_HIT:30034:30054,0,RBL:45.249.212.32:@huawei.com:.lbl8.mailshell.net-64.95.201.95 62.18.2.100,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: bun31_16d899c872a0a X-Filterd-Recvd-Size: 2578 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:55:56 +0000 (UTC) Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 5797745993D5BE47473A; Thu, 7 May 2020 15:55:53 +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:47 +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 03/10] block: add sectors_to_npage()/npage_to_sectors() helpers Date: Thu, 7 May 2020 15:50:53 +0800 Message-ID: <20200507075100.1779-4-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: Provide the conversion of "number of sectors"/"sector number" and "number of pages"/"page number". Suggested-by: Matthew Wilcox Signed-off-by: Zhen Lei --- include/linux/blkdev.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 934f31fc15cd..5d8daaffc38b 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -910,6 +910,8 @@ static inline struct request_queue *bdev_get_queue(struct block_device *bdev) #define SECTOR_SIZE (1 << SECTOR_SHIFT) #endif #define PAGE_SECTORS (PAGE_SIZE / SECTOR_SIZE) +#define sectors_to_npage(nr) ((nr) / PAGE_SECTORS) +#define npage_to_sectors(nr) ((nr) * PAGE_SECTORS) /* * blk_rq_pos() : the current sector From patchwork Thu May 7 07:50:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 11532735 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 04CD714B4 for ; Thu, 7 May 2020 07:56:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CD66B2084D for ; Thu, 7 May 2020 07:56:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD66B2084D 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 24251900006; Thu, 7 May 2020 03:56:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 218AC900009; Thu, 7 May 2020 03:56:05 -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 15B28900006; Thu, 7 May 2020 03:56:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0166.hostedemail.com [216.40.44.166]) by kanga.kvack.org (Postfix) with ESMTP id E4EC4900009 for ; Thu, 7 May 2020 03:56:04 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A8125124F for ; Thu, 7 May 2020 07:56:04 +0000 (UTC) X-FDA: 76789164648.18.wheel50_17e35a4595e37 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,thunder.leizhen@huawei.com,,RULES_HIT:30029:30054,0,RBL:45.249.212.35:@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:6,LUA_SUMMARY:none X-HE-Tag: wheel50_17e35a4595e37 X-Filterd-Recvd-Size: 3389 Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf31.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.60]) by Forcepoint Email with ESMTP id 6EC65A859BAE067234FF; 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:47 +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 04/10] zram: abolish macro SECTORS_PER_PAGE_SHIFT Date: Thu, 7 May 2020 15:50:54 +0800 Message-ID: <20200507075100.1779-5-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 SECTORS_PER_PAGE_SHIFT is quite hard to read. So use sectors_to_npage() to replace ">> SECTORS_PER_PAGE_SHIFT" Suggested-by: Matthew Wilcox Signed-off-by: Zhen Lei --- drivers/block/zram/zram_drv.c | 4 ++-- drivers/block/zram/zram_drv.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index e2fbf7a847e7..918b77f9bce4 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1549,7 +1549,7 @@ static void __zram_make_request(struct zram *zram, struct bio *bio) struct bio_vec bvec; struct bvec_iter iter; - index = bio->bi_iter.bi_sector >> SECTORS_PER_PAGE_SHIFT; + index = sectors_to_npage(bio->bi_iter.bi_sector); offset = (bio->bi_iter.bi_sector & (PAGE_SECTORS - 1)) << SECTOR_SHIFT; @@ -1644,7 +1644,7 @@ static int zram_rw_page(struct block_device *bdev, sector_t sector, goto out; } - index = sector >> SECTORS_PER_PAGE_SHIFT; + index = sectors_to_npage(sector); offset = (sector & (PAGE_SECTORS - 1)) << SECTOR_SHIFT; bv.bv_page = page; diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h index 10fdf413dd6e..12309175d55e 100644 --- a/drivers/block/zram/zram_drv.h +++ b/drivers/block/zram/zram_drv.h @@ -21,7 +21,6 @@ #include "zcomp.h" -#define SECTORS_PER_PAGE_SHIFT (PAGE_SHIFT - SECTOR_SHIFT) #define ZRAM_LOGICAL_BLOCK_SHIFT 12 #define ZRAM_LOGICAL_BLOCK_SIZE (1 << ZRAM_LOGICAL_BLOCK_SHIFT) #define ZRAM_SECTOR_PER_LOGICAL_BLOCK \ 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)) { From patchwork Thu May 7 07:50:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 11532763 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 1095014B4 for ; Thu, 7 May 2020 07:56:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D026B2186A for ; Thu, 7 May 2020 07:56:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D026B2186A 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 F383490000D; Thu, 7 May 2020 03:56:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EEA0B90000B; Thu, 7 May 2020 03:56:45 -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 E26B290000D; Thu, 7 May 2020 03:56:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0183.hostedemail.com [216.40.44.183]) by kanga.kvack.org (Postfix) with ESMTP id CB49990000B for ; Thu, 7 May 2020 03:56:45 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 8E2D610F61 for ; Thu, 7 May 2020 07:56:45 +0000 (UTC) X-FDA: 76789166370.27.war74_1da74f2b28f12 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,thunder.leizhen@huawei.com,,RULES_HIT:30012:30054,0,RBL:45.249.212.35:@huawei.com:.lbl8.mailshell.net-64.95.201.95 62.18.2.100,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: war74_1da74f2b28f12 X-Filterd-Recvd-Size: 4385 Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 May 2020 07:56:43 +0000 (UTC) Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 65D8F75FC4DD6324E1FD; 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:49 +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 06/10] mm/swap: use npage_to_sectors() and PAGE_SECTORS to clean up code Date: Thu, 7 May 2020 15:50:56 +0800 Message-ID: <20200507075100.1779-7-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: 1. Replace "<<= (PAGE_SHIFT - 9)" with "*= PAGE_SECTORS" 2. Replace "<< (PAGE_SHIFT - 9)" with npage_to_sectors() Suggested-by: Matthew Wilcox Signed-off-by: Zhen Lei --- mm/page_io.c | 4 ++-- mm/swapfile.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/page_io.c b/mm/page_io.c index 76965be1d40e..23291a49ab91 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -38,7 +38,7 @@ static struct bio *get_swap_bio(gfp_t gfp_flags, bio->bi_iter.bi_sector = map_swap_page(page, &bdev); bio_set_dev(bio, bdev); - bio->bi_iter.bi_sector <<= PAGE_SHIFT - 9; + bio->bi_iter.bi_sector *= PAGE_SECTORS; bio->bi_end_io = end_io; bio_add_page(bio, page, PAGE_SIZE * hpage_nr_pages(page), 0); @@ -266,7 +266,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc) static sector_t swap_page_sector(struct page *page) { - return (sector_t)__page_file_index(page) << (PAGE_SHIFT - 9); + return npage_to_sectors((sector_t)__page_file_index(page)); } static inline void count_swpout_vm_event(struct page *page) diff --git a/mm/swapfile.c b/mm/swapfile.c index 5871a2aa86a5..c8be92f972a4 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -177,8 +177,8 @@ static int discard_swap(struct swap_info_struct *si) /* Do not discard the swap header page! */ se = first_se(si); - start_block = (se->start_block + 1) << (PAGE_SHIFT - 9); - nr_blocks = ((sector_t)se->nr_pages - 1) << (PAGE_SHIFT - 9); + start_block = npage_to_sectors(se->start_block + 1); + nr_blocks = npage_to_sectors((sector_t)se->nr_pages - 1); if (nr_blocks) { err = blkdev_issue_discard(si->bdev, start_block, nr_blocks, GFP_KERNEL, 0); @@ -188,8 +188,8 @@ static int discard_swap(struct swap_info_struct *si) } for (se = next_se(se); se; se = next_se(se)) { - start_block = se->start_block << (PAGE_SHIFT - 9); - nr_blocks = (sector_t)se->nr_pages << (PAGE_SHIFT - 9); + start_block = npage_to_sectors(se->start_block); + nr_blocks = npage_to_sectors((sector_t)se->nr_pages); err = blkdev_issue_discard(si->bdev, start_block, nr_blocks, GFP_KERNEL, 0); @@ -240,8 +240,8 @@ static void discard_swap_cluster(struct swap_info_struct *si, start_page += nr_blocks; nr_pages -= nr_blocks; - start_block <<= PAGE_SHIFT - 9; - nr_blocks <<= PAGE_SHIFT - 9; + start_block *= PAGE_SECTORS; + nr_blocks *= PAGE_SECTORS; if (blkdev_issue_discard(si->bdev, start_block, nr_blocks, GFP_NOIO, 0)) break; From patchwork Thu May 7 07:50:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 11532737 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 4FC87913 for ; Thu, 7 May 2020 07:56:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 26BA12083B for ; Thu, 7 May 2020 07:56:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26BA12083B 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) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1F771900009; Thu, 7 May 2020 03:56:06 -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 0441F90000A; Thu, 7 May 2020 03:56:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org 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-Spam-Summary: 1,0,0,,d41d8cd98f00b204,thunder.leizhen@huawei.com,,RULES_HIT:30012:30045:30054,0,RBL:45.249.212.32:@huawei.com:.lbl8.mailshell.net-64.95.201.95 62.18.2.100,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: 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 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 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; if ((max_hw_sectors << 9) < PAGE_SIZE) { - max_hw_sectors = 1 << (PAGE_SHIFT - 9); + max_hw_sectors = 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 = 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 = sectors_to_npage(max_sectors); } 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); + sectors_to_npage(t->limits.max_sectors); } EXPORT_SYMBOL(disk_stack_limits); 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 *state, sector_t n, Sector *p) return NULL; } - page = read_mapping_page(mapping, - (pgoff_t)(n >> (PAGE_SHIFT - 9)), NULL); + page = 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 *state, sector_t n, Sector *p) p->v = 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: From patchwork Thu May 7 07:50:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 11532741 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 7533B14B4 for ; Thu, 7 May 2020 07:56:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4BBCD2083B for ; Thu, 7 May 2020 07:56:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4BBCD2083B 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 7725C900009; Thu, 7 May 2020 03:56:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6FA9790000B; Thu, 7 May 2020 03:56:06 -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 59B50900009; Thu, 7 May 2020 03:56:06 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0220.hostedemail.com [216.40.44.220]) by kanga.kvack.org (Postfix) with ESMTP id 3A6F290000B for ; Thu, 7 May 2020 03:56:06 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id EC9788248D51 for ; Thu, 7 May 2020 07:56:05 +0000 (UTC) X-FDA: 76789164690.03.grain47_1807922939456 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,thunder.leizhen@huawei.com,,RULES_HIT:30012:30025:30046:30054,0,RBL:45.249.212.32:@huawei.com:.lbl8.mailshell.net-64.95.201.95 62.18.2.100,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: grain47_1807922939456 X-Filterd-Recvd-Size: 5819 Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf24.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 95A0B72A110D85664A36; 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:51 +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 08/10] md: use sectors_to_npage() and npage_to_sectors() to clean up code Date: Thu, 7 May 2020 15:50:58 +0800 Message-ID: <20200507075100.1779-9-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: 1. Replace ">> (PAGE_SHIFT - 9)" with sectors_to_npage() 2. Replace "<< (PAGE_SHIFT - 9)" with npage_to_sectors() Suggested-by: Matthew Wilcox Signed-off-by: Zhen Lei --- drivers/md/dm-table.c | 2 +- drivers/md/raid1.c | 2 +- drivers/md/raid10.c | 2 +- drivers/md/raid5-cache.c | 11 +++++------ 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 0a2cc197f62b..e1f176bda528 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1964,7 +1964,7 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, #endif /* Allow reads to exceed readahead limits */ - q->backing_dev_info->io_pages = limits->max_sectors >> (PAGE_SHIFT - 9); + q->backing_dev_info->io_pages = sectors_to_npage(limits->max_sectors); } unsigned int dm_table_get_num_targets(struct dm_table *t) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index cd810e195086..44ffe1b6d77a 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2129,7 +2129,7 @@ static void process_checks(struct r1bio *r1_bio) int vcnt; /* Fix variable parts of all bios */ - vcnt = (r1_bio->sectors + PAGE_SIZE / 512 - 1) >> (PAGE_SHIFT - 9); + vcnt = sectors_to_npage(r1_bio->sectors + PAGE_SIZE / 512 - 1); for (i = 0; i < conf->raid_disks * 2; i++) { blk_status_t status; struct bio *b = r1_bio->bios[i]; diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index ec136e44aef7..948afe720fca 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -2029,7 +2029,7 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio) fbio->bi_iter.bi_idx = 0; fpages = get_resync_pages(fbio)->pages; - vcnt = (r10_bio->sectors + (PAGE_SIZE >> 9) - 1) >> (PAGE_SHIFT - 9); + vcnt = sectors_to_npage(r10_bio->sectors + (PAGE_SIZE >> 9) - 1); /* now find blocks with errors */ for (i=0 ; i < conf->copies ; i++) { int j, d; diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c index 9b6da759dca2..0b9cd810466a 100644 --- a/drivers/md/raid5-cache.c +++ b/drivers/md/raid5-cache.c @@ -832,8 +832,7 @@ static void r5l_append_payload_meta(struct r5l_log *log, u16 type, payload = page_address(io->meta_page) + io->meta_offset; payload->header.type = cpu_to_le16(type); payload->header.flags = cpu_to_le16(0); - payload->size = cpu_to_le32((1 + !!checksum2_valid) << - (PAGE_SHIFT - 9)); + payload->size = cpu_to_le32(npage_to_sectors(1 + !!checksum2_valid)); payload->location = cpu_to_le64(location); payload->checksum[0] = cpu_to_le32(checksum1); if (checksum2_valid) @@ -1042,7 +1041,7 @@ int r5l_write_stripe(struct r5l_log *log, struct stripe_head *sh) mutex_lock(&log->io_mutex); /* meta + data */ - reserve = (1 + write_disks) << (PAGE_SHIFT - 9); + reserve = npage_to_sectors(1 + write_disks); if (log->r5c_journal_mode == R5C_JOURNAL_MODE_WRITE_THROUGH) { if (!r5l_has_free_space(log, reserve)) { @@ -2053,7 +2052,7 @@ r5l_recovery_verify_data_checksum_for_mb(struct r5l_log *log, le32_to_cpu(payload->size)); mb_offset += sizeof(struct r5l_payload_data_parity) + sizeof(__le32) * - (le32_to_cpu(payload->size) >> (PAGE_SHIFT - 9)); + sectors_to_npage(le32_to_cpu(payload->size)); } } @@ -2199,7 +2198,7 @@ r5c_recovery_analyze_meta_block(struct r5l_log *log, mb_offset += sizeof(struct r5l_payload_data_parity) + sizeof(__le32) * - (le32_to_cpu(payload->size) >> (PAGE_SHIFT - 9)); + sectors_to_npage(le32_to_cpu(payload->size)); } return 0; @@ -2916,7 +2915,7 @@ int r5c_cache_data(struct r5l_log *log, struct stripe_head *sh) mutex_lock(&log->io_mutex); /* meta + data */ - reserve = (1 + pages) << (PAGE_SHIFT - 9); + reserve = npage_to_sectors(1 + pages); if (test_bit(R5C_LOG_CRITICAL, &conf->cache_state) && sh->log_start == MaxSector) From patchwork Thu May 7 07:50:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 11532733 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 CE14214B4 for ; Thu, 7 May 2020 07:56:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A43772080D for ; Thu, 7 May 2020 07:56:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A43772080D 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 DDB46900008; 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 D64B1900006; 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 CA07A900008; 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 (smtprelay0078.hostedemail.com [216.40.44.78]) by kanga.kvack.org (Postfix) with ESMTP id B1B65900006 for ; Thu, 7 May 2020 03:56:04 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 79DA61450E for ; Thu, 7 May 2020 07:56:04 +0000 (UTC) X-FDA: 76789164648.06.table12_17dcf745eff3b X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,thunder.leizhen@huawei.com,,RULES_HIT:30003:30054,0,RBL:45.249.212.35:@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: table12_17dcf745eff3b X-Filterd-Recvd-Size: 3101 Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf06.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.60]) by Forcepoint Email with ESMTP id 7689DCDF2CE26A1BADFD; 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:52 +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 09/10] md: use existing definition RESYNC_SECTORS Date: Thu, 7 May 2020 15:50:59 +0800 Message-ID: <20200507075100.1779-10-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: "RESYNC_BLOCK_SIZE/512" is equal to "RESYNC_BLOCK_SIZE >> 9", replace it with RESYNC_SECTORS. Signed-off-by: Zhen Lei --- drivers/md/raid10.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 948afe720fca..ac4273f804e8 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -4483,8 +4483,8 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, last = conf->reshape_progress - 1; sector_nr = last & ~(sector_t)(conf->geo.chunk_mask & conf->prev.chunk_mask); - if (sector_nr + RESYNC_BLOCK_SIZE/512 < last) - sector_nr = last + 1 - RESYNC_BLOCK_SIZE/512; + if (sector_nr + RESYNC_SECTORS < last) + sector_nr = last + 1 - RESYNC_SECTORS; } else { /* 'next' is after the last device address that we * might write to for this chunk in the new layout @@ -4506,8 +4506,8 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, last = sector_nr | (conf->geo.chunk_mask & conf->prev.chunk_mask); - if (sector_nr + RESYNC_BLOCK_SIZE/512 <= last) - last = sector_nr + RESYNC_BLOCK_SIZE/512 - 1; + if (sector_nr + RESYNC_SECTORS <= last) + last = sector_nr + RESYNC_SECTORS - 1; } if (need_flush || From patchwork Thu May 7 07:51:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 11532743 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 D9F44913 for ; Thu, 7 May 2020 07:56:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8C7C52083B for ; Thu, 7 May 2020 07:56:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C7C52083B 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 C056C90000C; Thu, 7 May 2020 03:56:07 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BDCC090000B; Thu, 7 May 2020 03:56:07 -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 ACD2990000C; Thu, 7 May 2020 03:56:07 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0245.hostedemail.com [216.40.44.245]) by kanga.kvack.org (Postfix) with ESMTP id 9570490000B for ; Thu, 7 May 2020 03:56:07 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 4D47C181AEF3F for ; Thu, 7 May 2020 07:56:07 +0000 (UTC) X-FDA: 76789164774.17.wool49_1839317944e39 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,thunder.leizhen@huawei.com,,RULES_HIT:30012:30029:30046:30054:30070,0,RBL:45.249.212.32:@huawei.com:.lbl8.mailshell.net-64.95.201.95 62.18.2.100,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:25,LUA_SUMMARY:none X-HE-Tag: wool49_1839317944e39 X-Filterd-Recvd-Size: 11265 Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 May 2020 07:56:06 +0000 (UTC) Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 87404B39D9B1A9A81104; Thu, 7 May 2020 15:56:03 +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:52 +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 10/10] md: use PAGE_SECTORS to clean up code Date: Thu, 7 May 2020 15:51:00 +0800 Message-ID: <20200507075100.1779-11-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: Execute the following shell script: C_FILES=`find drivers/md/ -name "*.c"` for file in $C_FILES do #with brace sed -i 's/(PAGE_SIZE \/ 512)/PAGE_SECTORS/g' $file sed -i 's/(PAGE_SIZE\/512)/PAGE_SECTORS/g' $file sed -i 's/(PAGE_SIZE >> 9)/PAGE_SECTORS/g' $file sed -i 's/(PAGE_SIZE>>9)/PAGE_SECTORS/g' $file #without brace sed -i 's/PAGE_SIZE \/ 512/PAGE_SECTORS/g' $file sed -i 's/PAGE_SIZE\/512/PAGE_SECTORS/g' $file sed -i 's/PAGE_SIZE >> 9/PAGE_SECTORS/g' $file sed -i 's/PAGE_SIZE>>9/PAGE_SECTORS/g' $file done In addition, eliminate below scripts/checkpatch.pl warning: #44: FILE: drivers/md/dm-kcopyd.c:587: + unsigned nr_pages = dm_div_up(job->dests[0].count, PAGE_SECTORS); Change to "unsigned int nr_pages". Signed-off-by: Zhen Lei --- drivers/md/dm-kcopyd.c | 2 +- drivers/md/md-bitmap.c | 16 ++++++++-------- drivers/md/md.c | 6 +++--- drivers/md/raid1.c | 10 +++++----- drivers/md/raid10.c | 20 ++++++++++---------- drivers/md/raid5.c | 4 ++-- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/drivers/md/dm-kcopyd.c b/drivers/md/dm-kcopyd.c index 1bbe4a34ef4c..ad861a3d648e 100644 --- a/drivers/md/dm-kcopyd.c +++ b/drivers/md/dm-kcopyd.c @@ -584,7 +584,7 @@ static int run_io_job(struct kcopyd_job *job) static int run_pages_job(struct kcopyd_job *job) { int r; - unsigned nr_pages = dm_div_up(job->dests[0].count, PAGE_SIZE >> 9); + unsigned int nr_pages = dm_div_up(job->dests[0].count, PAGE_SECTORS); r = kcopyd_get_pages(job->kc, nr_pages, &job->pages); if (!r) { diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index b952bd45bd6a..12ccf1c81661 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -161,7 +161,7 @@ static int read_sb_page(struct mddev *mddev, loff_t offset, || test_bit(Bitmap_sync, &rdev->flags)) continue; - target = offset + index * (PAGE_SIZE/512); + target = offset + index * PAGE_SECTORS; if (sync_page_io(rdev, target, roundup(size, bdev_logical_block_size(rdev->bdev)), @@ -237,17 +237,17 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait) if (mddev->external) { /* Bitmap could be anywhere. */ if (rdev->sb_start + offset + (page->index - * (PAGE_SIZE/512)) + * PAGE_SECTORS) > rdev->data_offset && rdev->sb_start + offset < (rdev->data_offset + mddev->dev_sectors - + (PAGE_SIZE/512))) + + PAGE_SECTORS)) goto bad_alignment; } else if (offset < 0) { /* DATA BITMAP METADATA */ if (offset - + (long)(page->index * (PAGE_SIZE/512)) + + (long)(page->index * PAGE_SECTORS) + size/512 > 0) /* bitmap runs in to metadata */ goto bad_alignment; @@ -259,7 +259,7 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait) /* METADATA BITMAP DATA */ if (rdev->sb_start + offset - + page->index*(PAGE_SIZE/512) + size/512 + + page->index*PAGE_SECTORS + size/512 > rdev->data_offset) /* bitmap runs in to data */ goto bad_alignment; @@ -268,7 +268,7 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait) } md_super_write(mddev, rdev, rdev->sb_start + offset - + page->index * (PAGE_SIZE/512), + + page->index * PAGE_SECTORS, size, page); } @@ -1548,14 +1548,14 @@ int md_bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *block * pages, otherwise resync (which is very PAGE_SIZE based) will * get confused. * So call __bitmap_start_sync repeatedly (if needed) until - * At least PAGE_SIZE>>9 blocks are covered. + * At least PAGE_SECTORS blocks are covered. * Return the 'or' of the result. */ int rv = 0; sector_t blocks1; *blocks = 0; - while (*blocks < (PAGE_SIZE>>9)) { + while (*blocks < PAGE_SECTORS) { rv |= __bitmap_start_sync(bitmap, offset, &blocks1, degraded); offset += blocks1; diff --git a/drivers/md/md.c b/drivers/md/md.c index 271e8a587354..a7572b17cf2e 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1736,7 +1736,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_ __le64 *bbp; int i; int sectors = le16_to_cpu(sb->bblog_size); - if (sectors > (PAGE_SIZE / 512)) + if (sectors > PAGE_SECTORS) return -EINVAL; offset = le32_to_cpu(sb->bblog_offset); if (offset == 0) @@ -2223,7 +2223,7 @@ super_1_allow_new_offset(struct md_rdev *rdev, bitmap = rdev->mddev->bitmap; if (bitmap && !rdev->mddev->bitmap_info.file && rdev->sb_start + rdev->mddev->bitmap_info.offset + - bitmap->storage.file_pages * (PAGE_SIZE>>9) > new_offset) + bitmap->storage.file_pages * PAGE_SECTORS > new_offset) return 0; if (rdev->badblocks.sector + rdev->badblocks.size > new_offset) return 0; @@ -8734,7 +8734,7 @@ void md_do_sync(struct md_thread *thread) /* * Tune reconstruction: */ - window = 32 * (PAGE_SIZE / 512); + window = 32 * PAGE_SECTORS; pr_debug("md: using %dk window, over a total of %lluk.\n", window/2, (unsigned long long)max_sectors/2); diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 44ffe1b6d77a..717c6e397cad 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2021,8 +2021,8 @@ static int fix_sync_read_error(struct r1bio *r1_bio) int success = 0; int start; - if (s > (PAGE_SIZE>>9)) - s = PAGE_SIZE >> 9; + if (s > PAGE_SECTORS) + s = PAGE_SECTORS; do { if (r1_bio->bios[d]->bi_end_io == end_sync_read) { /* No rcu protection needed here devices @@ -2129,7 +2129,7 @@ static void process_checks(struct r1bio *r1_bio) int vcnt; /* Fix variable parts of all bios */ - vcnt = sectors_to_npage(r1_bio->sectors + PAGE_SIZE / 512 - 1); + vcnt = sectors_to_npage(r1_bio->sectors + PAGE_SECTORS - 1); for (i = 0; i < conf->raid_disks * 2; i++) { blk_status_t status; struct bio *b = r1_bio->bios[i]; @@ -2264,8 +2264,8 @@ static void fix_read_error(struct r1conf *conf, int read_disk, int start; struct md_rdev *rdev; - if (s > (PAGE_SIZE>>9)) - s = PAGE_SIZE >> 9; + if (s > PAGE_SECTORS) + s = PAGE_SECTORS; do { sector_t first_bad; diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index ac4273f804e8..21bc6e33c093 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -2029,7 +2029,7 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio) fbio->bi_iter.bi_idx = 0; fpages = get_resync_pages(fbio)->pages; - vcnt = sectors_to_npage(r10_bio->sectors + (PAGE_SIZE >> 9) - 1); + vcnt = sectors_to_npage(r10_bio->sectors + PAGE_SECTORS - 1); /* now find blocks with errors */ for (i=0 ; i < conf->copies ; i++) { int j, d; @@ -2163,8 +2163,8 @@ static void fix_recovery_read_error(struct r10bio *r10_bio) sector_t addr; int ok; - if (s > (PAGE_SIZE>>9)) - s = PAGE_SIZE >> 9; + if (s > PAGE_SECTORS) + s = PAGE_SECTORS; rdev = conf->mirrors[dr].rdev; addr = r10_bio->devs[0].addr + sect, @@ -2367,8 +2367,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10 int success = 0; int start; - if (s > (PAGE_SIZE>>9)) - s = PAGE_SIZE >> 9; + if (s > PAGE_SECTORS) + s = PAGE_SECTORS; rcu_read_lock(); do { @@ -3597,7 +3597,7 @@ static int setup_geo(struct geom *geo, struct mddev *mddev, enum geo_type new) } if (layout >> 19) return -1; - if (chunk < (PAGE_SIZE >> 9) || + if (chunk < PAGE_SECTORS || !is_power_of_2(chunk)) return -2; nc = layout & 255; @@ -4632,8 +4632,8 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, nr_sectors = 0; pages = get_resync_pages(r10_bio->devs[0].bio)->pages; - for (s = 0 ; s < max_sectors; s += PAGE_SIZE >> 9) { - struct page *page = pages[s / (PAGE_SIZE >> 9)]; + for (s = 0 ; s < max_sectors; s += PAGE_SECTORS) { + struct page *page = pages[s / PAGE_SECTORS]; int len = (max_sectors - s) << 9; if (len > PAGE_SIZE) len = PAGE_SIZE; @@ -4789,8 +4789,8 @@ static int handle_reshape_read_error(struct mddev *mddev, int success = 0; int first_slot = slot; - if (s > (PAGE_SIZE >> 9)) - s = PAGE_SIZE >> 9; + if (s > PAGE_SECTORS) + s = PAGE_SECTORS; rcu_read_lock(); while (!success) { diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index ba00e9877f02..5b316538b9ea 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -8197,7 +8197,7 @@ static int raid5_check_reshape(struct mddev *mddev) if (new_chunk > 0) { if (!is_power_of_2(new_chunk)) return -EINVAL; - if (new_chunk < (PAGE_SIZE>>9)) + if (new_chunk < PAGE_SECTORS) return -EINVAL; if (mddev->array_sectors & (new_chunk-1)) /* not factor of array size */ @@ -8231,7 +8231,7 @@ static int raid6_check_reshape(struct mddev *mddev) if (new_chunk > 0) { if (!is_power_of_2(new_chunk)) return -EINVAL; - if (new_chunk < (PAGE_SIZE >> 9)) + if (new_chunk < PAGE_SECTORS) return -EINVAL; if (mddev->array_sectors & (new_chunk-1)) /* not factor of array size */