Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2165459iof; Tue, 7 Jun 2022 21:55:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQ9BgUmsvxLjXzpz/A8YTZXzsgiQnaRe2YzkjLVXxq1l4J9X7HAtlEE9fAw9EIAop0i3td X-Received: by 2002:a63:6bc7:0:b0:3fd:1b8d:d114 with SMTP id g190-20020a636bc7000000b003fd1b8dd114mr22930299pgc.308.1654664144323; Tue, 07 Jun 2022 21:55:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654664144; cv=none; d=google.com; s=arc-20160816; b=fYSIqt+ZtZ+ESCsuSRrsTOl9zx+J00b6KJrcFy7he4hkRj0Bv1D1hqkjzzjq1M0T9w 3bra+xa9CDtj7UpRXh1l2rcGWdu+/YsQ2O/BfVvdCx0DpiI0KC9GRjkqesAAARXpOrJI XyMSwydaU7K+3PZWZgupFrU3ZW5WEPw0wB6W49CUwlUxRgJxQ0P9UbtK5Ndv2TICLqWV 8/WNNY5lKIi+wQI65ZFPsvyutdrzuBLV1K3NQQlJgG04d7Pak1tT9orRbe7qCl8kMd/x BPZCpczCCNs7EId7zAbkuXgNgyAY7p1AWCjFpfW5KfY9NsKni42IoLpxq+cOIfADAKko F6nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DYQbKERnqn/43VSH+HGmWwOM83/LA+tz5FgYwMg3cEM=; b=Mm2B7IETEuZQ0uF8toQcTHvgF9GGu2EWuvPH/j7jt661FvM39KZ1mfjeuByccZu3Ov spOu0r4KWir0eKwQoTTzPySM/S9IYvGdp5p0UdF0YzINq4scfMF4KrBI/5Pp3gQIF8cV JjT/fji9xUg605Y5/si4Rhjc+x6dpzGXkLhknlYrrw7ZNMvVrdSuTg2TOgn5NMZzSgx6 6VkKkgv1KzHhU9o6xKnbZ1JpqH3kCClCwSNi3hJ85wD743+pSk0GPgsxlnnSMUD1nTBY eRKnJDpKZPNnb2Y7BGUqVUtyefUbh+8mU9KpvAzbsKNMyrNUExUlj//dcfekMIpXnk3a l0gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1ZmsVHeM; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n6-20020a170903110600b00158b603b0aesi33147454plh.589.2022.06.07.21.55.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:55:44 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1ZmsVHeM; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A1D8D436273; Tue, 7 Jun 2022 21:37:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385178AbiFGWpd (ORCPT + 99 others); Tue, 7 Jun 2022 18:45:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381236AbiFGVbu (ORCPT ); Tue, 7 Jun 2022 17:31:50 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6556B1790AD; Tue, 7 Jun 2022 12:04:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 49F85B822C0; Tue, 7 Jun 2022 19:04:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8A19C385A2; Tue, 7 Jun 2022 19:04:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628648; bh=r3icwYRqpz0dj79jo25jtxszgMSr1JFy/3yvGTETjr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1ZmsVHeMY5KWjs6FU7RD9x9tzOvhW2bDCLvFZUUqbWezgxEqfQ6AZMScTd4vGjNpH T486Sc9zHBv7bPIH0tDL6qjOFyRUcurnkubbdf4FYVW1q4ulM9XfzM9x+mgSjrbibX Ke6JduKAYWNq1rh/ZlTYnDRj9RvcyxHNqeAAKALE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andreas Gruenbacher , "Darrick J. Wong" , Sasha Levin Subject: [PATCH 5.18 404/879] iomap: iomap_write_failed fix Date: Tue, 7 Jun 2022 18:58:42 +0200 Message-Id: <20220607165014.588980201@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: Andreas Gruenbacher [ Upstream commit b71450e2cc4b3c79f33c5bd276d152af9bd54f79 ] The @lend parameter of truncate_pagecache_range() should be the offset of the last byte of the hole, not the first byte beyond it. Fixes: ae259a9c8593 ("fs: introduce iomap infrastructure") Signed-off-by: Andreas Gruenbacher Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Sasha Levin --- 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 8ce8720093b9..358ee1fb6f0d 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -531,7 +531,8 @@ iomap_write_failed(struct inode *inode, loff_t pos, unsigned len) * write started inside the existing inode size. */ if (pos + len > i_size) - truncate_pagecache_range(inode, max(pos, i_size), pos + len); + truncate_pagecache_range(inode, max(pos, i_size), + pos + len - 1); } static int iomap_read_folio_sync(loff_t block_start, struct folio *folio, -- 2.35.1