From patchwork Wed Nov 13 09:47:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13895559 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 AFAA4E7716D for ; Thu, 5 Dec 2024 15:25:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0EC036B00DA; Thu, 5 Dec 2024 10:19:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 420E46B0122; Thu, 5 Dec 2024 10:19:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 29CC16B00E3; Thu, 5 Dec 2024 10:19:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id CD31D6B00C5 for ; Wed, 13 Nov 2024 04:47:36 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6F548AB107 for ; Wed, 13 Nov 2024 09:47:36 +0000 (UTC) X-FDA: 82780593210.23.B3CBF6A Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf29.hostedemail.com (Postfix) with ESMTP id 8D370120022 for ; Wed, 13 Nov 2024 09:46:36 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=MrW0mugs; spf=none (imf29.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731491080; 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=7+8+iZm+tjxOB43GQOsTAsoBbae92Ry/J8rdhLVaHLE=; b=qvvH8Ar18nI2eq5dQB4l/FfD/qY8HgneiTChD9uI0QpUB4TVEbmtyK52o0u8FYiUG7LB29 EnO0XIXAQ0in/q+O1tuegkOhJ4NIHv/d++JCLBThrk083F91Kiu42uoYP8YWZTdMUnSwq9 wigwLSwa65DVvGZ2UIXFDunYTBjsD68= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=MrW0mugs; spf=none (imf29.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731491080; a=rsa-sha256; cv=none; b=Pm0LdxXSOJjJV27zDa0gl3GxTGOmtkk4zbxUn1HHvJhGv9mzLPp2Mfkeg0FrsyQ5N2Kdaj qtELmibhhiM68i62wO/9OU+Sqar6RL24QoF9Gh3TVH3EiIisVAR6E1VJQZtcEtNv2tBFWI 61kyhz7Veh2DMM39RnZR5+0OjUal8Jc= 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=7+8+iZm+tjxOB43GQOsTAsoBbae92Ry/J8rdhLVaHLE=; b=MrW0mugsJonnAulp8nZ/Goql0i dlieZ5TByws+pcxXO9uzei7XrUnTJIaPGtXcmT7M28XbIRQNf8WfjJyrEBMnLUb18awyz5G+zOp3o zasJqs8/WFw10/x/u9WEXX8tgHRVMwegKqXwPlbK0yGoR10GXWRzKSH8YzezgZ1p6SyBdZmc0f1+d zvkmwdLq4VgNTo8RnuoLrYc1EMhcJZRZ+vfG5n0WOPSGNTGK4zwf4CKDI426pbHRYyeJnPc3SuWqG i+VtckgYCCV1qo5rIAcAcGq0g5Y5cgCEP9SSSI7Q9MEPDLApZpyGJGXy+WfxgWOsPRkqxVneAc5ET J4oaxmZQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tB9yC-00000006Hd2-44oO; Wed, 13 Nov 2024 09:47:28 +0000 From: Luis Chamberlain To: willy@infradead.org, hch@lst.de, hare@suse.de, david@fromorbit.com, djwong@kernel.org Cc: john.g.garry@oracle.com, ritesh.list@gmail.com, kbusch@kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-block@vger.kernel.org, gost.dev@samsung.com, p.raghav@samsung.com, da.gomez@samsung.com, kernel@pankajraghav.com, mcgrof@kernel.org, Hannes Reinecke Subject: [RFC 2/8] fs/mpage: avoid negative shift for large blocksize Date: Wed, 13 Nov 2024 01:47:21 -0800 Message-ID: <20241113094727.1497722-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241113094727.1497722-1-mcgrof@kernel.org> References: <20241113094727.1497722-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 8D370120022 X-Stat-Signature: c8o7k9f7et18o5bypy1yhejntts6sa61 X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam-User: X-Rspam: Yes X-HE-Tag: 1731491196-938129 X-HE-Meta: U2FsdGVkX18LmiWTinfFigXCU3UTosW2rtyvuvhENLV23e/uwvaPiwf/1AMrSosN8+mV7GzVyEQZHiiSe5VkSPtRWjm3jdS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dDOe5bwHWNGo5k9tOagF4P2i/dBsImzcph+P9t28crIklzv+B6K1Y9SBrXdrVTyRiPc8S6dWFXZFg2Ge7gNvaRDKLl0svTj2rREtpguzwWPH2TmyoIvFH1gD+MiLeDEqBIeQOqeSmqATOyrx0e/aXeuhk1mmx/uXwiQb4aQf0nLxm98Iofkbvr1cYNW2A6eK18uMvSmFTW1kIkXNUc75Yuqx1Tu9tihQ5Y7kRUvFyH7zWHhoCjiYA38uZGVvRvgog0ez0PjBIr7i7K8wNuGhwoBVsWGnxjD9DQ3uIY3WimLXd9ehzIX85n9vyIKI1Hg== 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: List-Subscribe: List-Unsubscribe: From: Hannes Reinecke For large blocksizes the number of block bits is larger than PAGE_SHIFT, so use shift to calculate the sector number from the page cache index. With this in place we can now enable large folios on with buffer-heads. Signed-off-by: Hannes Reinecke --- fs/mpage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/mpage.c b/fs/mpage.c index 5b5989c7c2a0..ff76600380ca 100644 --- a/fs/mpage.c +++ b/fs/mpage.c @@ -181,7 +181,7 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args) if (folio_buffers(folio)) goto confused; - block_in_file = (sector_t)folio->index << (PAGE_SHIFT - blkbits); + block_in_file = (sector_t)(((loff_t)folio->index << PAGE_SHIFT) >> blkbits); last_block = block_in_file + args->nr_pages * blocks_per_folio; last_block_in_file = (i_size_read(inode) + blocksize - 1) >> blkbits; if (last_block > last_block_in_file) @@ -527,7 +527,7 @@ static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc, * The page has no buffers: map it to disk */ BUG_ON(!folio_test_uptodate(folio)); - block_in_file = (sector_t)folio->index << (PAGE_SHIFT - blkbits); + block_in_file = (sector_t)(((loff_t)folio->index << PAGE_SHIFT) >> blkbits); /* * Whole page beyond EOF? Skip allocating blocks to avoid leaking * space.