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 8B85BC47247 for ; Thu, 7 May 2020 07:56:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2F8E12083B for ; Thu, 7 May 2020 07:56:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F8E12083B 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) Received: by kanga.kvack.org (Postfix, from userid 40) id BDCC090000B; Thu, 7 May 2020 03:56:07 -0400 (EDT) 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-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-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 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: Execute the following shell script: C_FILES=3D`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 =3D 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 =3D dm_div_up(job->dests[0].count, PAGE_SIZE >> 9); + unsigned int nr_pages =3D dm_div_up(job->dests[0].count, PAGE_SECTORS); =20 r =3D 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 o= ffset, || test_bit(Bitmap_sync, &rdev->flags)) continue; =20 - target =3D offset + index * (PAGE_SIZE/512); + target =3D offset + index * PAGE_SECTORS; =20 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, str= uct 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, struc= t 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, struc= t 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, s= ector_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 =3D 0; sector_t blocks1; =20 *blocks =3D 0; - while (*blocks < (PAGE_SIZE>>9)) { + while (*blocks < PAGE_SECTORS) { rv |=3D __bitmap_start_sync(bitmap, offset, &blocks1, degraded); offset +=3D 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, struc= t md_rdev *refdev, int minor_ __le64 *bbp; int i; int sectors =3D le16_to_cpu(sb->bblog_size); - if (sectors > (PAGE_SIZE / 512)) + if (sectors > PAGE_SECTORS) return -EINVAL; offset =3D le32_to_cpu(sb->bblog_offset); if (offset =3D=3D 0) @@ -2223,7 +2223,7 @@ super_1_allow_new_offset(struct md_rdev *rdev, bitmap =3D 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 =3D 32 * (PAGE_SIZE / 512); + window =3D 32 * PAGE_SECTORS; pr_debug("md: using %dk window, over a total of %lluk.\n", window/2, (unsigned long long)max_sectors/2); =20 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 =3D 0; int start; =20 - if (s > (PAGE_SIZE>>9)) - s =3D PAGE_SIZE >> 9; + if (s > PAGE_SECTORS) + s =3D PAGE_SECTORS; do { if (r1_bio->bios[d]->bi_end_io =3D=3D end_sync_read) { /* No rcu protection needed here devices @@ -2129,7 +2129,7 @@ static void process_checks(struct r1bio *r1_bio) int vcnt; =20 /* Fix variable parts of all bios */ - vcnt =3D sectors_to_npage(r1_bio->sectors + PAGE_SIZE / 512 - 1); + vcnt =3D sectors_to_npage(r1_bio->sectors + PAGE_SECTORS - 1); for (i =3D 0; i < conf->raid_disks * 2; i++) { blk_status_t status; struct bio *b =3D 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; =20 - if (s > (PAGE_SIZE>>9)) - s =3D PAGE_SIZE >> 9; + if (s > PAGE_SECTORS) + s =3D PAGE_SECTORS; =20 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 =3D 0; fpages =3D get_resync_pages(fbio)->pages; =20 - vcnt =3D sectors_to_npage(r10_bio->sectors + (PAGE_SIZE >> 9) - 1); + vcnt =3D sectors_to_npage(r10_bio->sectors + PAGE_SECTORS - 1); /* now find blocks with errors */ for (i=3D0 ; 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; =20 - if (s > (PAGE_SIZE>>9)) - s =3D PAGE_SIZE >> 9; + if (s > PAGE_SECTORS) + s =3D PAGE_SECTORS; =20 rdev =3D conf->mirrors[dr].rdev; addr =3D r10_bio->devs[0].addr + sect, @@ -2367,8 +2367,8 @@ static void fix_read_error(struct r10conf *conf, st= ruct mddev *mddev, struct r10 int success =3D 0; int start; =20 - if (s > (PAGE_SIZE>>9)) - s =3D PAGE_SIZE >> 9; + if (s > PAGE_SECTORS) + s =3D PAGE_SECTORS; =20 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 =3D layout & 255; @@ -4632,8 +4632,8 @@ static sector_t reshape_request(struct mddev *mddev= , sector_t sector_nr, =20 nr_sectors =3D 0; pages =3D get_resync_pages(r10_bio->devs[0].bio)->pages; - for (s =3D 0 ; s < max_sectors; s +=3D PAGE_SIZE >> 9) { - struct page *page =3D pages[s / (PAGE_SIZE >> 9)]; + for (s =3D 0 ; s < max_sectors; s +=3D PAGE_SECTORS) { + struct page *page =3D pages[s / PAGE_SECTORS]; int len =3D (max_sectors - s) << 9; if (len > PAGE_SIZE) len =3D PAGE_SIZE; @@ -4789,8 +4789,8 @@ static int handle_reshape_read_error(struct mddev *= mddev, int success =3D 0; int first_slot =3D slot; =20 - if (s > (PAGE_SIZE >> 9)) - s =3D PAGE_SIZE >> 9; + if (s > PAGE_SECTORS) + s =3D PAGE_SECTORS; =20 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 */ --=20 2.26.0.106.g9fadedd