Message ID | 20240820232105.3792638-3-dhowells@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 61B10C5321D for <linux-mm@archiver.kernel.org>; Tue, 20 Aug 2024 23:21:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E54496B008C; Tue, 20 Aug 2024 19:21:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E04E56B0092; Tue, 20 Aug 2024 19:21:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CCC046B0093; Tue, 20 Aug 2024 19:21:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id ACDCF6B008C for <linux-mm@kvack.org>; Tue, 20 Aug 2024 19:21:39 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5DC3CC063D for <linux-mm@kvack.org>; Tue, 20 Aug 2024 23:21:39 +0000 (UTC) X-FDA: 82474197918.12.6C4D64B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 9E87BA0004 for <linux-mm@kvack.org>; Tue, 20 Aug 2024 23:21:37 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=C8FHukd7; spf=pass (imf25.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724196057; a=rsa-sha256; cv=none; b=AKchdeTrRr9YbO/t24Ju/0+JL8hOeihOsX47/Gofx3PhJdStLCrZUhz6+dpji3my6uIILn 1yR2vi3GLX5dvLaoJtHLlXt6gCh18iEByc2PNSZBuU7Wrio4yk8NdzefWUXE5bZwUB5xjV WHRYahYM4kbskzEp9SsKzZqsaIZIShQ= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=C8FHukd7; spf=pass (imf25.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724196057; 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=LLNXobqu9Lr51n4CzgcItZvbbRppxWdYVF89daxGYJk=; b=F2wrLzd9KgOjOwPGRgSwbONhFYClj3RPJglX5xnGeTRYEjbLXp4iqkBD5/bsKrO4/1GQDP e7C0qGjtosk3gPQzx2nmcPdIQutsNF8zQnmVpQ+vxKjroi2Q/emt3Fuzuj7t9t69TtLZN2 KxkjUi8C1wuoquVxof7S3elE60owWtM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724196096; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LLNXobqu9Lr51n4CzgcItZvbbRppxWdYVF89daxGYJk=; b=C8FHukd7rmJ6on+u0PHuCKBwcfCn4I3ndGc3+HIn7MJagFXu41+7/MYNBdk9X0N98c8b27 UrVOaOnmHP7KurEw5mX6bbF2XPXmLGoug9uAz47i/qSAN1ihjaWheyWg3N0rBHhGB22s3r a8wwC9dVhlxCpxTOG3+4ge7ZFi76uqw= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-34-12CfHN9WNkObG7tnXd9WhA-1; Tue, 20 Aug 2024 19:21:29 -0400 X-MC-Unique: 12CfHN9WNkObG7tnXd9WhA-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3436B195608A; Tue, 20 Aug 2024 23:21:25 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.30]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 09A0F1955E8C; Tue, 20 Aug 2024 23:21:20 +0000 (UTC) From: David Howells <dhowells@redhat.com> To: Christian Brauner <christian@brauner.io> Cc: David Howells <dhowells@redhat.com>, Pankaj Raghav <p.raghav@samsung.com>, Jeff Layton <jlayton@kernel.org>, Matthew Wilcox <willy@infradead.org>, netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Marc Dionne <marc.dionne@auristor.com> Subject: [PATCH 2/4] afs: Fix post-setattr file edit to do truncation correctly Date: Wed, 21 Aug 2024 00:20:56 +0100 Message-ID: <20240820232105.3792638-3-dhowells@redhat.com> In-Reply-To: <20240820232105.3792638-1-dhowells@redhat.com> References: <20240820232105.3792638-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Stat-Signature: mgpkyyeqee1sf7dr38qq7uncfn7oq1n8 X-Rspamd-Queue-Id: 9E87BA0004 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1724196097-13594 X-HE-Meta: U2FsdGVkX19awzC28NHh9j8cxzCU23aWvzlj5zLtUMJo8354DmBsW/NQwRLFRosuEytPvGaqCv/Csax3hQ3WF1w/WvrD/CzEljPPke926v3hT/cE5ELCiOGKa/moVslsfj7UUXKLpfHw4qSuJgiFiyWp7JCQoWdYgxJO3hG9dbvbHpjqqLkBG0RbrcMO5u9hbYqNbiwcbDwAop1gGW5on/fuxRntJrdm6cNeZvM6MPfBbKSebpfZX79bDYHK/IXKI0qFtM56ptylG6ZXDmsvRKNCjOrMhQCtAeZu8jJudxwx0nQDO4hJaoteHQOBQ7By/h7E00rr6EsZ01ZPno5Xpka3Uq95b/NumcQkyJ86nprcRQmDD2jIH9A1Jdye/Gm45qQR1wwQsGP53JaFo1BRWJEusP+s4Fz2d6U7FECOD++ZcQWd0dcMeRBpgObN7X5cvD0ulAItLA8rd3n6gr71itSmkT7JrLWnCHcEnalQgopDukqusdojBKCzO28OYBz+SWbAN2TRTMDVHV1spBJBafo9iSfbfkUOr0Nw/UzmvBIf7pPLjCJOOfrzkU38dpC6K1MIYRv955X9qTIPH7p34VTX68FEM0Q4A09ByoRNsUPJLtrcSCXXATMtbP9XlP4Ro7oU/U3Tmwk6cLJcvCQf0VuSFY8S+X9Uncc9kvip6mMtreTneY99jZmQq6gdGs+GRAjT9pwbZBZX4r9z2038gFQEKO+OXnptS6tzsqWW2CoBNz3XF+c8aW7SN6XvJSHjANEvn/J3GpXOkCwDVUQ8SBxIy53s5q2pUUljNhmfLFY+Wrp44NG02ur84d34cw+WCOlLH8mi4vp5qiws6Z4Fc5DA7TlM7gWi0+h95Z4jYiVBDCDKMMJ5b5FP8r0RWAbFAodSIZxAtQZ3/XqLQZhW9noqazEH2x9BtERtljmeAG08cjyQs1PLKd+1hrehmjjyJeVi7Ba15BO8h6sWp9x AaBTvOp2 uxrN0kpiIUKYlpdDTewPhuhSXwRtXmxigSUh6m+IZysl88clYmLKxKd6dzm9LKbvd21k+dHrxbrQmlvFPa4LJN+pIDOhho9UZ0ajeBW8bujBmV5YD7/ANTxONnY8qvHe/SR5+i0xNdnJy35OEHzG1CTASiGsXMtsOURkIlE9C07RT0vqjkF8zW6B2Xx+hg9gZELvWHwW+1/NFLav/x7hYmP0Em2wr9N4jW+peHl8RoKdb+a3QpAm/3Iacb8ME3I9nyieRg0AUrWYROyvkrU1JkW2qHJplVODAc+9zlzQ/DfbL5sGWPQyG2fXHTiimFmRActgeNRJVWirs+5UsZMlYu6I6H0TTgMojfLHF0d3elmejBWwJjDMnXASdNl8t7bZaJ2lFIZspA84DB74XNfHV+G8q/gee9+SUolkwv5iBSzweN1t5iaTEdgnWC3HjTL7ZpY2YByH8sFG4U1XVIGL16YO6e/4AsgMJM4zwkVDwuyk2ZkIvAv0bqwFuxq8e1pDeX/fsWGSLDcbXgT9g1RnWSoBZvMVoHMI2wAxnDhyOKhYGJDCE7gcYqNnwJA== 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
mm, netfs, afs: Truncation fixes
|
expand
|
diff --git a/fs/afs/inode.c b/fs/afs/inode.c index 3acf5e050072..a95e77670b49 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -695,13 +695,18 @@ static void afs_setattr_edit_file(struct afs_operation *op) { struct afs_vnode_param *vp = &op->file[0]; struct afs_vnode *vnode = vp->vnode; + struct inode *inode = &vnode->netfs.inode; if (op->setattr.attr->ia_valid & ATTR_SIZE) { loff_t size = op->setattr.attr->ia_size; - loff_t i_size = op->setattr.old_i_size; + loff_t old = op->setattr.old_i_size; + + /* Note: inode->i_size was updated by afs_apply_status() inside + * the I/O and callback locks. + */ - if (size != i_size) { - truncate_setsize(&vnode->netfs.inode, size); + if (size != old) { + truncate_pagecache(inode, size); netfs_resize_file(&vnode->netfs, size, true); fscache_resize_cookie(afs_vnode_cache(vnode), size); }
At the end of an kAFS RPC operation, there is an "edit" phase (originally intended for post-directory modification ops to edit the local image) that the setattr VFS op uses to fix up the pagecache if the RPC that requested truncation of a file was successful. afs_setattr_edit_file() calls truncate_setsize() which sets i_size, expands the pagecache if needed and truncates the pagecache. The first two of those, however, are redundant as they've already been done by afs_setattr_success() under the io_lock and the first is also done under the callback lock (cb_lock). Fix afs_setattr_edit_file() to call truncate_pagecache() instead (which is called by truncate_setsize(), thereby skipping the redundant parts. Fixes: 100ccd18bb41 ("netfs: Optimise away reads above the point at which there can be no data") Signed-off-by: David Howells <dhowells@redhat.com> cc: Matthew Wilcox (Oracle) <willy@infradead.org> cc: Pankaj Raghav <p.raghav@samsung.com> cc: Jeff Layton <jlayton@kernel.org> cc: Marc Dionne <marc.dionne@auristor.com> cc: linux-afs@lists.infradead.org cc: netfs@lists.linux.dev cc: linux-mm@kvack.org cc: linux-fsdevel@vger.kernel.org --- fs/afs/inode.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)