From patchwork Fri Apr 21 19:58:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13220635 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A3E3C7618E for ; Fri, 21 Apr 2023 19:58:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5FA86B007D; Fri, 21 Apr 2023 15:58:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C907C6B0075; Fri, 21 Apr 2023 15:58:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 90DBB6B007E; Fri, 21 Apr 2023 15:58:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 423116B0075 for ; Fri, 21 Apr 2023 15:58:22 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 29747160680 for ; Fri, 21 Apr 2023 19:58:22 +0000 (UTC) X-FDA: 80706460044.22.5B4B36A Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf11.hostedemail.com (Postfix) with ESMTP id 7F1C94001B for ; Fri, 21 Apr 2023 19:58:19 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=DzgJIkzU; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=none (imf11.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682107099; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=74KqhpMHp5ljBuyIWW+6b9AuPyxaDpBnVwotQeAK7X8=; b=ii1Gpb5x+QGBh+8bqs8vHMNjD+GxPRALa6fIkt0TS1KDDjpjbjitUwxLcNi5cvaiPwPzMS sauzyXsedm2af3eGJ91J+Q87CmnRMnUHo0pfspX84mfK0bRKmEU6yN9fWVPRtrCUhDI1PF zP7hrNe0q2qZw/WQhFfJ79L/SlvHNEY= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=DzgJIkzU; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=none (imf11.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682107099; a=rsa-sha256; cv=none; b=yO5ijxgmtNxgw2BSv1VhUYLWrprIKvFLnMqvXjruT8z70CDNEFRsKFSVYbkJOSRYB2qyDh 0VQetqb/KYpYlfC4cek88AUJdNy9vkszlpy0mwS8584PrQ0hFuVcUV7+9ZnmTIjg95nBp7 lXyq1gurJ4RwZeYXjJqiz2BfMHgoVEI= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=74KqhpMHp5ljBuyIWW+6b9AuPyxaDpBnVwotQeAK7X8=; b=DzgJIkzUgKZlS2lZbWSyNPJKAX fJ02zvtu2wcM2DrLnEL1z7nGFJhWQvwx0ZwBONfF2vKqh9gW2iMSwkRFRy6mbGiWHd/jSQ2su2LMY Vg1njHfWWwn48um+f7MBerBHqbIfnt/XRDZ3iutZDQy8hUwy8N6Yh3vKPnhAmFE3nYJoRwN79EvZv tdJt0bXHBK0ddw7cry5Xwc3+fl7vlOOZWg4mFRKw3odez/kARFEZf3yQSfwQCVqea4Y8Q7KXQrNON m0DQiRTZm1Zq/OK4LTgJgai/TEYyHmUWvunLdAzqFTvAbW2mmA8qG/Di14CugGU7PsPFRhpLOzysJ 0Eq2Rsmw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1ppwtU-00Blaf-2A; Fri, 21 Apr 2023 19:58:08 +0000 From: Luis Chamberlain To: axboe@kernel.dk, agk@redhat.com, snitzer@kernel.org, philipp.reisner@linbit.com, lars.ellenberg@linbit.com, christoph.boehmwalder@linbit.com, hch@infradead.org, djwong@kernel.org, minchan@kernel.org, senozhatsky@chromium.org Cc: patches@lists.linux.dev, linux-block@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, dm-devel@redhat.com, drbd-dev@lists.linbit.com, linux-kernel@vger.kernel.org, willy@infradead.org, hare@suse.de, p.raghav@samsung.com, da.gomez@samsung.com, kbusch@kernel.org, mcgrof@kernel.org Subject: [PATCH 5/5] zram: use generic PAGE_SECTORS and PAGE_SECTORS_SHIFT Date: Fri, 21 Apr 2023 12:58:07 -0700 Message-Id: <20230421195807.2804512-6-mcgrof@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230421195807.2804512-1-mcgrof@kernel.org> References: <20230421195807.2804512-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 7F1C94001B X-Stat-Signature: 51h43mfss4bcd8753cepw9yox9a3uoqc X-HE-Tag: 1682107099-679301 X-HE-Meta: U2FsdGVkX180hcf5E20zioIfIygexumQF1IBGu+M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wOoWOjNTTpJJMygM/Bbk2v0hsOhTFkJ5nb2xVXb2syY4baTrI48Q0Wgf0qPgy/zW0HSj3qcppjkFLPiQ0y19nQOhmzz/CDHzZJeqnp//WuQj8SHhyTM8QzzO/9CzepjxfuL3sKan9gZtTfHEDyyZvg1L/c9xO0Gh7oPE6ZcmSHZ24PAn1IlIe4CAUxFo95mSHbo9UU2kVYXO8/qsEyQyvBagwK4DF1aGrZAlAcQcZ2lJUq0RaYe5kzyjwSEZKl0R7YRhv5rNE1lld5xJN92W/Mxzhi962Wjy1ydgSvcfWslKg 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: Instead of re-defining the already existing constants use the provided ones: So replace: o SECTORS_PER_PAGE_SHIFT with PAGE_SECTORS_SHIFT o SECTORS_PER_PAGE with PAGE_SECTORS This produces no functional changes. Signed-off-by: Luis Chamberlain Reviewed-by: Sergey Senozhatsky --- drivers/block/zram/zram_drv.c | 12 ++++++------ drivers/block/zram/zram_drv.h | 2 -- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index a84c4268257a..11c9b5a9ac7a 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1834,8 +1834,8 @@ static ssize_t recompress_store(struct device *dev, static void zram_bio_discard(struct zram *zram, struct bio *bio) { size_t n = bio->bi_iter.bi_size; - u32 index = bio->bi_iter.bi_sector >> SECTORS_PER_PAGE_SHIFT; - u32 offset = (bio->bi_iter.bi_sector & (SECTORS_PER_PAGE - 1)) << + u32 index = bio->bi_iter.bi_sector >> PAGE_SECTORS_SHIFT; + u32 offset = (bio->bi_iter.bi_sector & (PAGE_SECTORS - 1)) << SECTOR_SHIFT; /* @@ -1876,8 +1876,8 @@ static void zram_bio_read(struct zram *zram, struct bio *bio) start_time = bio_start_io_acct(bio); bio_for_each_segment(bv, bio, iter) { - u32 index = iter.bi_sector >> SECTORS_PER_PAGE_SHIFT; - u32 offset = (iter.bi_sector & (SECTORS_PER_PAGE - 1)) << + u32 index = iter.bi_sector >> PAGE_SECTORS_SHIFT; + u32 offset = (iter.bi_sector & (PAGE_SECTORS - 1)) << SECTOR_SHIFT; if (zram_bvec_read(zram, &bv, index, offset, bio) < 0) { @@ -1903,8 +1903,8 @@ static void zram_bio_write(struct zram *zram, struct bio *bio) start_time = bio_start_io_acct(bio); bio_for_each_segment(bv, bio, iter) { - u32 index = iter.bi_sector >> SECTORS_PER_PAGE_SHIFT; - u32 offset = (iter.bi_sector & (SECTORS_PER_PAGE - 1)) << + u32 index = iter.bi_sector >> PAGE_SECTORS_SHIFT; + u32 offset = (iter.bi_sector & (PAGE_SECTORS - 1)) << SECTOR_SHIFT; if (zram_bvec_write(zram, &bv, index, offset, bio) < 0) { diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h index ca7a15bd4845..9f2543af5c76 100644 --- a/drivers/block/zram/zram_drv.h +++ b/drivers/block/zram/zram_drv.h @@ -21,8 +21,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 \