From patchwork Thu Feb 2 20:44:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13126700 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 B16C2C636D7 for ; Thu, 2 Feb 2023 20:44:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5212A6B0072; Thu, 2 Feb 2023 15:44:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F8E16B0073; Thu, 2 Feb 2023 15:44:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3E8B96B0074; Thu, 2 Feb 2023 15:44:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 317B46B0072 for ; Thu, 2 Feb 2023 15:44:39 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 078FE1203CC for ; Thu, 2 Feb 2023 20:44:39 +0000 (UTC) X-FDA: 80423530278.13.B8AA948 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf28.hostedemail.com (Postfix) with ESMTP id 12200C0015 for ; Thu, 2 Feb 2023 20:44:36 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="Bh63M/0n"; dmarc=none; spf=none (imf28.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675370677; h=from:from: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=74nszHLks+AFGqdfRGx6vNnWqXDqZ9xHI0qBKa9QcdI=; b=1ySYXp9vXiF4b/ciBf9Okd8BD0jm5GWm+aV6+Mg23uX51SsmN3oAtFzMYwr25tQ9crGpRC qw7mJzzkaVwhnGXVdIuRxTZWKgJoDtFHDG4hEmPQIXdWhzf70Zont2JYGrL52zU1d00OL9 eh4z7khBbziX/IMoT8ZyCD3eunFsfuw= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="Bh63M/0n"; dmarc=none; spf=none (imf28.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675370677; a=rsa-sha256; cv=none; b=VMY8veWgXG21AcXnd6gCZanaCqHJ+HjTy+bfySqNO5gSvpZwtSSxQzpnsjmGhvuCNkTHZP DTQEayCcGOdnghFfqjJaEty0NIK3cCVS8Yfbij1m+bDbgEnIroOxL/rsWX4f704ubA/05u Os8JyDYH9UBZUi78EXfdoumaDac+154= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=74nszHLks+AFGqdfRGx6vNnWqXDqZ9xHI0qBKa9QcdI=; b=Bh63M/0nqGUZZvEkwrwA6JtjLg 6o8uQmpPAbwbDBcLTYskUV04rtjVxAbkRI8ywM/Cpg4QgkiduK6adIw3ab64Pf5IMVgLHdPjVDTBl aFg3fWxnpxmnDgfKBu03xsCHOnK4kcN7ZNcdNL6rFyRosOEDWxJ2OH3HyqGJPOB9okC+kK4RFv5JW x710OIFndtSvYOt8aghfbiSUMaoLwhFO3gM1DyXoahA8R0FHcoR780FR7VUl6VjqZywykxzxsTZsT z7NGee99rYn2z4rassj8Q+UR5edf87SIIhF/tDMjeQicVliVbhgeiEiraaTJYPSgPnMq8cG0Ud4/t ULWEZsfQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNgRb-00Di7d-Ga; Thu, 02 Feb 2023 20:44:31 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-afs@lists.infradead.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, Hugh Dickins , linux-kernel@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 4/5] afs: Zero bytes after 'oldsize' if we're expanding the file Date: Thu, 2 Feb 2023 20:44:26 +0000 Message-Id: <20230202204428.3267832-5-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230202204428.3267832-1-willy@infradead.org> References: <20230202204428.3267832-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 12200C0015 X-Stat-Signature: opcr7u5gpop3qhbmyrkhp4byoq9mw5re X-HE-Tag: 1675370676-159948 X-HE-Meta: U2FsdGVkX1+xaLDAvQbM5nYIYJxKYzeUln+uTYuSlRcTa3gK7KwFgqdT/6tdJDuR2C74ejQk54ckCGaOgAHvna4DpqtRaxfYpsjVSbWdX8wa72YJxVcjgOmwtG5i+kiZOZfoaHSdgvy6ckIKQhrnWyRVsCeVRmoWkoRXGXsuYqv40ilPSn8KTY0uA9FZ8iM0FeqR5ZtGyxy9HrfBDyo1t/J3LPXWo9L4XRrsEVqyL6ZjZgRkmh6t/Ersaalv3AedAzmL2GcQq8oCzCGT9QUVKl7Qftp3bStZWQ5/G9M0CE+5yVi632y0qj3hW4A8qLyiHvMjoH3NfLDI3PqSoDUeJrB7bexI9BQDXEwgAFnsZWhLLrh+Kh0oiT32QU+calMJj1yCTjejQAojyj79I2KpGQZJTzpilcCy9ZJB9uDg0668/tMvPwS8u2YNuVlzPMPuBUd47zv1os+KJn1xhsBENbbvMpiL+1JuNLQsOfTf8lngE9Vac9B91EkuTStvgDT71HBqQ9GCfPvEPdhd2l0ZXIVGq6oTdWwekseo/wZrcG2CR6CIdN0DTR5PRkL7h64MGDOmv8mADw5K4lK/hNA5KDaCX61smTGs1dNZElyUZlTTGaiylyJXJ4MYxbpkvc4zqxGLxobEWND8nvKQm0VzAD68Q/xkRB82ivRjtTsQIH8oWj7249u2G2Z67cji4szVFc/pbfYSWm5qP6+XYjD5eq7VYx8mGDB5fUIZc8xx2pB70WDBUx5/3N9bD9bGASgCwyjZIx2PALPDgxAad8rp729YMewImHATOBvURt6khs5rwZuXoeIrJd5yaevNEWpxNONp61JABBmj+MgI+xz73WIEOGtppRWsZsFcYnavkFvC41Kll1E8htRjmRR3hF+mYMXNCMEca9vB5faYbh1o6B/5s7/OOz1xPROYFo5ERBte9gfvSJKcIiIQVE9DV+K2lZW7tw8kR+1UGTGe+ck lP5U1aDY VRHCm3TxN2S8AFuawcX2mWaUwIErYEr5pxzTscM+Dtq0HTL+i/CsrIvXhoBCoiEKaNd8wdKJ1UESi647cC/8LbQykUEyLScw5tNKAbnc+iTfsMapYXyz5mDfP/tWFuSdoJhWrPU8e5OHffTKJ5c3rRl/wF/ko2w69gAjgKLt+UdrdcAyXOf6sX/pqDuiKvhOXT1k9QWELJFSgeL7FCf2DSMyoujNFV1oIvgaXvyAQTyJPuwM= 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: POSIX requires that "If the file size is increased, the extended area shall appear as if it were zero-filled". It is possible to use mmap to write past EOF and that data will become visible instead of zeroes. Signed-off-by: Matthew Wilcox (Oracle) Acked-by: David Howells --- fs/afs/inode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/afs/inode.c b/fs/afs/inode.c index 6d3a3dbe4928..92e2ba7625de 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -854,6 +854,8 @@ static void afs_setattr_edit_file(struct afs_operation *op) if (size < i_size) truncate_pagecache(inode, size); + else + truncate_pagecache(inode, i_size); if (size != i_size) fscache_resize_cookie(afs_vnode_cache(vp->vnode), vp->scb.status.size);