Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp382108lqh; Tue, 7 May 2024 01:56:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXxb0C/tLnzuUWzcvvkTIIEObxi41deENwqWwZcNWO49XxHnZynwf4XoknielcHT7IQ3VyetvqG526gXG6tWByrPkNGkj04Nu3bXvEqDQ== X-Google-Smtp-Source: AGHT+IE8X7PppPHDBCcRwdYjTnF/eqWfkpnAT/jJy+7FGKdGQDUqkrHvLkzQD7oaqKiLPPErtgCi X-Received: by 2002:a17:907:9447:b0:a59:ccb9:846d with SMTP id dl7-20020a170907944700b00a59ccb9846dmr4209221ejc.37.1715072170907; Tue, 07 May 2024 01:56:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715072170; cv=pass; d=google.com; s=arc-20160816; b=nS+hEd/YxZR7oFq1/ojvLeEripF5MsWjgUTF5GK6eqDgJ7/O41orEyexXgIFPYFMWD AeFPVIr8oFVrdk3nPk/PLv+MFO7HfuOlgxXVXjm8fxR3GiF73u9hfqxsYUDX3tVzm+Pv QlgyVuwXQKDDwJE7DMjP811moF2wKuH5VFaTIKRXL1Cpjx3k8pW4ahEWgSWaI3/deymw tR101sq2SVAPSgW/C4vP4mr9xQUty6WCmniMLspQHUTeuuoHUz2EjYMgCVaHELuE7j0J Con+7D5gEy/slAkrS4xs3OyP8qSiIO0GOexXVkfsNDaDs6kjCavH4tHsCVM6pq+kE9e1 sJ8w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=e57mtgQJCyrMor2wdEaqG/4Lmj2DaZNgeRnrm29BCyg=; fh=4dOvfvdFPgGlmHwKtZhw2UyIj7cCDrbGC04w5+gM4fo=; b=YQfJ16neo59cY6IDlStHbMT+M1vo7S1K0VjEnq1d2Qm+vdzDII0QVlwp0jool9Gvey ZFb+5Tz8but7zoR4nDm4IYxpqm34Mh9w/7TCfBJYQTBB4ok9fIS14UvHm6fH9CPg8cOW bv9DG25OCEE+hWRy4qgQAbAMR/6lHAx7g65+v0zGHRVyQidUJY2hF9V70twFxHvSaqrv lD8oDnnxrr4fazVW2f5Fplwmn1CLJUlWWpy69gi81k1wfyEFmHWFPe6TWPLLxeDgqDM8 tzSBMtH/ysqqg7nMmDkNvEgWiy4tchyAjDOZTJEkZINYHaOdqTq63eL3IPxvEnwuej6B LM5g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WegJBcKW; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-ext4+bounces-2339-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2339-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id la26-20020a170906ad9a00b00a59c4c21276si2833501ejb.393.2024.05.07.01.56.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 01:56:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2339-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WegJBcKW; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-ext4+bounces-2339-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2339-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9F1D01F23426 for ; Tue, 7 May 2024 08:56:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EE37514D6F5; Tue, 7 May 2024 08:55:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WegJBcKW" X-Original-To: linux-ext4@vger.kernel.org Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D8BD14D2B6; Tue, 7 May 2024 08:55:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715072158; cv=none; b=WZlXrecdmLq6vWI+T2TfLF5KfHn4lbTdVgsVxSPE/NLMLtLyVNvgKg3KNaYD8wQE3fDRRW2Vi6UtLpPKGx7jHYtPZtJrrPa36DKb4/5s09GBDxFVWgVI+gqjClVX/O6OgAQYrO+tQmKDn42BvKmn8kfbOvvpsSNof+gtvIBW2BM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715072158; c=relaxed/simple; bh=jFcnH9HqLEggeqAB2KGmVQnYPco7e2fsq97konYOI6s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qTyFqPzjf2bu2Ncw3iFmKCIuIBhxLTgxipwG2vCb3A5X0e7h5mm6T4osaGcFs+6CzmA7Fpb46r2cQbZtdkOECvH/tc7tUGRd2yrCMwlIcupU58MxA0FTyuIZOnzFWFURl9+nGcJ9HrvrNWcQt2xzwgXpgJ8hhLLLUncJkOzUXfo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WegJBcKW; arc=none smtp.client-ip=209.85.215.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-5d8b519e438so2326931a12.1; Tue, 07 May 2024 01:55:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715072156; x=1715676956; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e57mtgQJCyrMor2wdEaqG/4Lmj2DaZNgeRnrm29BCyg=; b=WegJBcKW8Zcpl0wCdtgI4dcHSS27HrU6dXC0V7mn95HF8JHwRLcONl6tHF0cZyRUIC ttfcTvthPy1XsfRyYNUbWdVxBuPsR1Qa0TOktsDSmgabqDdX1akVUQVwHmOlO409u6kX QwwyTWXD9x+rSmqVM7ZszESll/qqbi6PW79ckwF1LBhmoFsjZZsWR52xcnzVr53Cdl23 FU+/OKPbVWPYeQzBj8PU2qjBDLggCaUmDLD/v5Xj96C9k/2jiFPpqe/XlDfAaNkmAdVQ ++Jwrv83r/YI7GyJEyk6SbQbiFPzzksKpWSZGMNUgqst+v25mcx8SHsQkszf19PTloTy qsMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715072156; x=1715676956; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e57mtgQJCyrMor2wdEaqG/4Lmj2DaZNgeRnrm29BCyg=; b=k/ACvZ1tB/L/4lRzl/DX+T33lb2qFQJSYyQyleGSOOgxSzWO8gbfD/vDhVYbWePeK9 S6KrFjHMmL2Ap74D4ca2ueBjT7EUPwtKcHdel3WLQ4NZKfSgtBZ12v3ImM1RTloF1P5I gTrrs2QupCFcT1hixWBZZLK9VslYEFDVcjM7fjPKFCs9lUN09ibti9sJpNSn83P8KtAd f/cvjrspGkDCC1E60IVjqaWd6s90ZN0++bw435fXn6YZl1yygKoXF2QXawiwvAy0HKei NHQTMu8TnxzgJ0WcepS4MN7+uDy3Nii4eP0i1oRkl5Z3PcPNCjJkylhZbN5e2jz+ZWwu U3Hw== X-Forwarded-Encrypted: i=1; AJvYcCVZr/zVakVDzjukqEYI8b4zHMNa6Y/CZsWDPaZfhYkt/qEr4NJZ7WLrQ2pd4WbLuEIQ4R81FeNFGl2LWNvRBzBc39/lrSKCTwgfGw9x5Q== X-Gm-Message-State: AOJu0Yy3SGwYRmuzO2XcIF/mDeF7hIrYvYSCzfGUE6iUltqw+RVHkmAO LedNL8HnhjkKxg1hvDRIKrxUql71ixwkMiXLV3VLTP8tx0fn+53MeGFeqjGK X-Received: by 2002:a05:6a20:9f9a:b0:1af:93b0:f007 with SMTP id mm26-20020a056a209f9a00b001af93b0f007mr8846151pzb.1.1715072155903; Tue, 07 May 2024 01:55:55 -0700 (PDT) Received: from dw-tp.ibmuc.com ([171.76.81.176]) by smtp.gmail.com with ESMTPSA id kg3-20020a170903060300b001ed53267795sm7262030plb.152.2024.05.07.01.55.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 01:55:55 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linux-xfs@vger.kernel.org Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, Matthew Wilcox , "Darrick J . Wong" , Ojaswin Mujoo , Ritesh Harjani , Jan Kara , Christoph Hellwig Subject: [PATCHv2 1/2] iomap: Fix iomap_adjust_read_range for plen calculation Date: Tue, 7 May 2024 14:25:42 +0530 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit If the extent spans the block that contains i_size, we need to handle both halves separately so that we properly zero data in the page cache for blocks that are entirely outside of i_size. But this is needed only when i_size is within the current folio under processing. "orig_pos + length > isize" can be true for all folios if the mapped extent length is greater than the folio size. That is making plen to break for every folio instead of only the last folio. So use orig_plen for checking if "orig_pos + orig_plen > isize". Signed-off-by: Ritesh Harjani (IBM) cc: Ojaswin Mujoo Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/iomap/buffered-io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 4e8e41c8b3c0..9f79c82d1f73 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -241,6 +241,7 @@ static void iomap_adjust_read_range(struct inode *inode, struct folio *folio, unsigned block_size = (1 << block_bits); size_t poff = offset_in_folio(folio, *pos); size_t plen = min_t(loff_t, folio_size(folio) - poff, length); + size_t orig_plen = plen; unsigned first = poff >> block_bits; unsigned last = (poff + plen - 1) >> block_bits; @@ -277,7 +278,7 @@ static void iomap_adjust_read_range(struct inode *inode, struct folio *folio, * handle both halves separately so that we properly zero data in the * page cache for blocks that are entirely outside of i_size. */ - if (orig_pos <= isize && orig_pos + length > isize) { + if (orig_pos <= isize && orig_pos + orig_plen > isize) { unsigned end = offset_in_folio(folio, isize - 1) >> block_bits; if (first <= end && last > end) -- 2.44.0