From patchwork Wed Dec 18 02:26:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13912924 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 BE2EAE77187 for ; Wed, 18 Dec 2024 02:26:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 34AF36B0082; Tue, 17 Dec 2024 21:26:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FAE46B0083; Tue, 17 Dec 2024 21:26:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C2A56B0085; Tue, 17 Dec 2024 21:26:34 -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 F293A6B0082 for ; Tue, 17 Dec 2024 21:26:33 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 94A67C0B17 for ; Wed, 18 Dec 2024 02:26:33 +0000 (UTC) X-FDA: 82906490142.24.4A63225 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf15.hostedemail.com (Postfix) with ESMTP id 976EEA0008 for ; Wed, 18 Dec 2024 02:25:46 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=3qaC05k7; spf=none (imf15.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=1734488770; 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=KAcXP1LLN9RIr4LUuyxBmqGvK7FM1npzcMSwryY+7ME=; b=H7z0ZxOVAwDsMkAlP+4M5GwnhELRA31KkOxsDpRs7Ljiy7sek8VAaXmk9uWZAUJeFKVV/S H2qgQpUYHdNVz9WQrD18ZSETqeqm5U+53Sn+OA8n8cdY6qFemtxOJBefXyq944YKnfIu8R YY0FaMqN7Y6U6WPMxcflTRDYAXRBX6U= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=3qaC05k7; spf=none (imf15.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=1734488770; a=rsa-sha256; cv=none; b=hgRLqOLfNL+cjaUvwDVAKuFpa2lortR6x1DoFnCN3yuCn54x1mc64UZxhj2ZO9YbN6ypAW yFZ5Jl1VFxhzOVqx8e/G2QnANn+HhhmzNh9gejYT+clDWZ62y/6byW9IKBtJuJV+pmzaop HsI5DDRQZ1z++z0Y7JVTdRdswKn4L4Q= 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=KAcXP1LLN9RIr4LUuyxBmqGvK7FM1npzcMSwryY+7ME=; b=3qaC05k7YgxBzQwXc9ZAOl7DAT k61pID00MJyziEMK2a/rV9rNOMTAiDPENc2QdtSsXU1PRi68fxGTFDy8dAn848eYwuVU4g6SzLUFN vwenXhO4VWLRUjJOHA3Z7Qyf6Yy6knyLtBAB/LupK9s0sdcSjpz8D53qvxjRTzgIcHp/10eV1u5jO lrh0jIW2l6IJq0zzB1AqB3idKyQzCI2cWnmBL4YFePKdAnGbpv/fMBW6odvahgNV7DTzfDcS2NF8b dghX2PPebP4c53s6nR+FcNy2avvEOLCpIjKRipbwyxpSMp2nQsdx43cWKgWU/lxo2IP9GVtm1W1/m BHnGwU/A==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tNjlc-0000000FOFU-168x; Wed, 18 Dec 2024 02:26:28 +0000 From: Luis Chamberlain To: hare@suse.de, willy@infradead.org, dave@stgolabs.net, david@fromorbit.com, djwong@kernel.org, kbusch@kernel.org Cc: john.g.garry@oracle.com, hch@lst.de, ritesh.list@gmail.com, 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 Subject: [PATCH 2/5] fs/buffer: simplify block_read_full_folio() with bh_offset() Date: Tue, 17 Dec 2024 18:26:23 -0800 Message-ID: <20241218022626.3668119-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241218022626.3668119-1-mcgrof@kernel.org> References: <20241218022626.3668119-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 976EEA0008 X-Stat-Signature: h6c1fqhkhubfww48gfjkrec3z4gjb7wp X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam-User: X-Rspam: Yes X-HE-Tag: 1734488746-523641 X-HE-Meta: U2FsdGVkX1/WK7zuCzucOuGyRd/pyUVE05qkEQiNDxii1gBsMRtCCBBshXLkX2hKts/F4iQz57F2CBhflzJhLIDLpd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mixSHoqGJU6JraZ6PESR+Fm9xRM8wG+4cKmX++U2gtmtiz8vhi49IltfUe5EUqofPbTtJo3SGupM3akNWFp+oCsRLaRg4h2qfNdm0XmXpMeW+yxif46MM6V/Np8L4wAdkSJ0coaI2pGtB9cl9WIAFwiS/sq4r4dwkBHp8vqpZjTAUtAXiGcdsyhIgeIwtu4BaSxJbkeMhuGRV2RfK3th9ZQn6skfik8zBC1Dz7m2+EaLK2FqJ8IC3svV023uDxzQuzmXEJej2XqX1oBaKs0+PjwASsBBVPzdJulqpjnMXrg8uabyjp5EkIR85wSpaZdDJJH9LXSasmn+zrZl6WkmPDk1UaIGE5vD5YsEUo5nsxxhKUxHAlJ8t72v154aVqsn0atlZ12+8V7saF4/NSodnz9BK0maxTNIhUxDfZkK8rul X-Bogosity: Ham, tests=bogofilter, spamicity=0.001249, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Remove the temporary variable i on the iteration of all buffer heads on a folio and just use bh_offset(bh) to simplify the loop. Suggested-by: Matthew Wilcox Signed-off-by: Luis Chamberlain --- fs/buffer.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 7c6aac0742a6..8baf87db110d 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2410,7 +2410,7 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block) sector_t iblock, lblock; struct buffer_head *bh, *head, *arr[MAX_BUF_PER_PAGE]; size_t blocksize; - int nr, i; + int nr; int fully_mapped = 1; bool page_error = false; loff_t limit = i_size_read(inode); @@ -2428,7 +2428,6 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block) lblock = div_u64(limit + blocksize - 1, blocksize); bh = head; nr = 0; - i = 0; /* Stage one - collect buffer heads we need issue a read for */ do { @@ -2446,7 +2445,7 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block) page_error = true; } if (!buffer_mapped(bh)) { - folio_zero_range(folio, i * blocksize, + folio_zero_range(folio, bh_offset(bh), blocksize); if (!err) set_buffer_uptodate(bh); @@ -2460,7 +2459,7 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block) continue; } arr[nr++] = bh; - } while (i++, iblock++, (bh = bh->b_this_page) != head); + } while (iblock++, (bh = bh->b_this_page) != head); bh_read_batch_async(folio, nr, arr, fully_mapped, nr == 0, page_error);