Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2059571rwd; Fri, 26 May 2023 00:44:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7dmHnW607GR4JTsBq48eXBbP9QqqLSVYCk3IG8QMOcry1hMN3CNJlmmbh7toEPcH2qDgID X-Received: by 2002:a05:6a21:3992:b0:10f:6bf0:30d2 with SMTP id ad18-20020a056a21399200b0010f6bf030d2mr1374633pzc.33.1685087068984; Fri, 26 May 2023 00:44:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685087068; cv=none; d=google.com; s=arc-20160816; b=gnQcdXRoxGPqk7JW2Db7yfAEc7xQCVybTHT5P/VO9FCAyol+zk0Mul30dmtMpDMuSp iCxud7KxB/4JAu6uPuuGpFlH+M8HH/ss9TyW4KOU6gTG0h5JAFacXgVPalrWn1hKve4/ ZKOCtl9lrnM0vAOlr4vKqHSH8ww3dqLzOniyGxsc7H5K9pfkXc1fcQ+S+y1NDBV638N4 jY2DtMsoxRPp/22fG425AcWvjC6c+jXGymkm3BcHyFxjQ8ivEoabGtFjeAM/sADyfIuO yh+Z2RFKB8CjgpeoFdnAsl/fTHHPyxIIfGNk7FmlyHBnxmk1AzqMJ3qD6X3LN8Wcy+9T e6rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=l8SXSO/lmiFeJihMCTRRFm0o8Ak15fMAUhw4BXdB6WA=; b=zclZHupeIvBH2lR7GZe0Sp6L4lCt8q44ZGZtQemngGIRQw7PJdjpL5Yf2IUtvW6+ig WewX4aGduvx5me32DQ0fAbVDVhoMgaPAUBca7whkPQkZlwl0LzR5ADNQ997S3hbpgdHw IKgV8/ulYQO56+T9vgxnFgL2HB8RKqbPyOtzS3YpMVXG049lN+y3WzyKuO9d0h5sFVnX sLQfgLefGDxC3vEMJPkG/grGe9wtRNQTEByUy+wPOcw0OOGGL8Pyiu9pq9/+/NI+9mPG Va/6Hx4p3al9ixlqC94y1/vZV855N38ZIuOxyLDpgtvHy37abQEVM+YK+g4OALY/nFGJ KaKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=A0xPKQUo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d192-20020a6336c9000000b00528b49eacf1si2920442pga.135.2023.05.26.00.44.14; Fri, 26 May 2023 00:44:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=A0xPKQUo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230061AbjEZHeD (ORCPT + 99 others); Fri, 26 May 2023 03:34:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242431AbjEZHdp (ORCPT ); Fri, 26 May 2023 03:33:45 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F065412A; Fri, 26 May 2023 00:33:43 -0700 (PDT) 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=l8SXSO/lmiFeJihMCTRRFm0o8Ak15fMAUhw4BXdB6WA=; b=A0xPKQUoDsDrFgURMQlgZXIoK4 lF0smhhvDr9DIwh3hI5+Foy4jSB44qqYKTW9k2PV/7PuWcBUSeOo6jWJLU2DNhMOCi1CTP1Vr1qXN cB1zrc2ldkTJb0i1ydOhaeGCJSHRsdi8p9dUGm95225TqZGlE84F6Y3mfrRFtVU8AAk/LeILUvTzj DCxobQiHgxGi8mvk1uiSyIKFvEMqMniMXjlXlxhbRRhvWQ3LnJ21MPhaTWeTq5Fi6r/fGfhBlXjzW o+5/0Ft/FRALeNM171FNjOPX7gizDDJyiLwYYmSgprAWBoMr6t5XCcMourkOlUq8zpJCEwA9TAgAY J55czzyw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1q2RxB-001Rda-0i; Fri, 26 May 2023 07:33:37 +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, rohan.puri@samsung.com, rpuri.linux@gmail.com, kbusch@kernel.org, mcgrof@kernel.org Subject: [PATCH v2 5/5] zram: use generic PAGE_SECTORS and PAGE_SECTORS_SHIFT Date: Fri, 26 May 2023 00:33:36 -0700 Message-Id: <20230526073336.344543-6-mcgrof@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230526073336.344543-1-mcgrof@kernel.org> References: <20230526073336.344543-1-mcgrof@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Reviewed-by: Sergey Senozhatsky Signed-off-by: Luis Chamberlain --- 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 f6d90f1ba5cf..5fdeb78ace9a 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 \ -- 2.39.2