Message ID | 20230202204428.3267832-5-willy@infradead.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp464816wrn; Thu, 2 Feb 2023 12:47:32 -0800 (PST) X-Google-Smtp-Source: AK7set91v4THOBMkJXC4eM2ineZyOtPsvnMe416zmHnK8FlTE0tFz0Ax3drmKbs/ifi9IBi1apTa X-Received: by 2002:a05:6a20:a8a1:b0:be:bea0:7139 with SMTP id ca33-20020a056a20a8a100b000bebea07139mr2878096pzb.9.1675370852619; Thu, 02 Feb 2023 12:47:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675370852; cv=none; d=google.com; s=arc-20160816; b=XOaf837nyzHuX37Jn+hY2Xcch1114BxNeYJmQlXF4/nTM/XDRK/dLBfccnEZF20Dgf UqzHR18pal737D/LaA30FvjQFwT5RfkfHSP8feiOilOnZA/sanGojNJj/pZMJKnva+x6 F1Aj6oB3d/5SXkHwQAen7anc7F5vDshC+8NMIuj1V3meirW/wKIhsrdlBOMjkktslxzV hY5wHksnejCJ2jX13oG7xG3i7+LEh8Y+l7937i7xFh6at3VOEOaeu9xi/l4VsU0PgI3P D1sWakUxVa57F3lF2zBAcTeVzRhHoaViVgGZJuPLFRRGTGcLakKKE1bqKGMBurj/7MjK q+6w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=74nszHLks+AFGqdfRGx6vNnWqXDqZ9xHI0qBKa9QcdI=; b=Rv/prI8PAEyIPgKn82K1c+MOzfc51QpCUXb4dikaZS0QQekF+/CMwP9t6Sle55jxko OpoTtHk0cbhZ62hj3Hn7mLcfhgBgod/3Zm5ddEfKe6K0iPWdoLHe9GMbwL+ygKOsd2NS F5tnrLQH9m/SEgxR1KEjxxMJ1U+rY67Swin0IgHnIxBfEuzggq0Nyc7tdyZfi52jE7Tr GLSCgGj+HC+rmVq/Y3F4PLGrs8DWsw5AlM5c6grHUa9wCQ9Z/FeM8P9sn4O9L5Rt7ahZ Oj+Vy2eAv38xA1XmYZJIhyfzSZdA7PWikPBDPZsKtBPPIioBJtmoHwkFuEiPKpaVujUj 6GGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="Bh63M/0n"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s7-20020a63af47000000b004e4b1b01366si495602pgo.805.2023.02.02.12.47.20; Thu, 02 Feb 2023 12:47:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="Bh63M/0n"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232067AbjBBUox (ORCPT <rfc822;il.mystafa@gmail.com> + 99 others); Thu, 2 Feb 2023 15:44:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232841AbjBBUof (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 2 Feb 2023 15:44:35 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6DAC76AB; Thu, 2 Feb 2023 12:44:33 -0800 (PST) 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)" <willy@infradead.org> To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>, linux-afs@lists.infradead.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, Hugh Dickins <hughd@google.com>, 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756753667207207466?= X-GMAIL-MSGID: =?utf-8?q?1756753667207207466?= |
Series |
Fix a minor POSIX conformance problem
|
|
Commit Message
Matthew Wilcox
Feb. 2, 2023, 8:44 p.m. UTC
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) <willy@infradead.org>
---
fs/afs/inode.c | 2 ++
1 file changed, 2 insertions(+)
Comments
Matthew Wilcox (Oracle) <willy@infradead.org> wrote: > 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) <willy@infradead.org> That seems to work. Do you want me to pass it on to Linus? If not: Acked-by: David Howells <dhowells@redhat.com>
On Mon, Feb 27, 2023 at 01:49:27PM +0000, David Howells wrote: > Matthew Wilcox (Oracle) <willy@infradead.org> wrote: > > > 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) <willy@infradead.org> > > That seems to work. Do you want me to pass it on to Linus? If not: > > Acked-by: David Howells <dhowells@redhat.com> I'll send a patch series with all of this; it doesn't seem terribly urgent. Do you think there's a similar problem for AFS that Brian noted with the generic patch?
Matthew Wilcox <willy@infradead.org> wrote: > I'll send a patch series with all of this; it doesn't seem terribly > urgent. Do you think there's a similar problem for AFS that Brian > noted with the generic patch? Do you have a link I can look at? David
Matthew Wilcox <willy@infradead.org> wrote: > I'll send a patch series with all of this; it doesn't seem terribly > urgent. Do you think there's a similar problem for AFS that Brian > noted with the generic patch? Probably not. To avoid deadlocking itself, afs uses a mutex to prevent writepages racing with truncate (vnode->validate_lock). commit ec0fa0b659144d9c68204d23f627b6a65fa53e50 afs: Fix deadlock between writeback and truncate the afs_setattr_edit_file() call that changes i_size and partially clears the pagecache is applied to the local inode before the mutex is dropped. David
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);