Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3092802pxb; Mon, 18 Oct 2021 08:06:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzB58+KyORxQ1wNLtYvFvlgzweLhEg6f+kGGKu7pdcNDf8T3ya4pViod6uH2uOAW7b7YWLE X-Received: by 2002:a17:90a:7d0f:: with SMTP id g15mr47989112pjl.227.1634569577685; Mon, 18 Oct 2021 08:06:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634569577; cv=none; d=google.com; s=arc-20160816; b=yuydZRe2SqRd4YXS3J+CLdus5qNfdbMkeH9SbnjG1jRVQOYuLBTG4jIyxUh23miY5F kmnBXkmo/U1qK1GqYiKl21AmuxjjwgKRO5H+1qFGlwUPvooogOebbpOTc6u3EgPe/HQL 2TeA9CR5KpvzoDWLYuQLYY98Nh9ofgK1NnawC4E997MN3m9CdAJm+KX1OuhZz2qXRM35 gvOR1TT0GmsVZiiTbit31DqO2njWds7RtWJWONWLiAzbNvPTf2ogmTiwmzSXac+5BO4k eazcUsAe7xouSBA0OvBRVKYWMKRNUsyHdJ5GW5GP+RwlkrcnYpm3cyNwXN5ViZ9B0uKm +9vw== 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:cc:to:from :subject:organization:dkim-signature; bh=34+aPebgzzHxYJ84OQLGkAmjt/20nxAv2uPWKUz1+/c=; b=XTai8EmGJ2tHm4K5HFWCcOQTKNa5uMm3mfz9oxz1pdzfJU4Kwe6osdeIeKVl2IaNUz EDX7tJXOj3joYbSbCb8TmuTAFnDMQn1IAAsBQEbswWX+TgWJY1NMrmhjIk9lNTbrgOsn lIkQtfQEuiLNqkUdLua6TDVE/aHXmId78XZ8JJCota3VgPcidxN2m+JhXewJ6K7yC5zX H1pX4QtorynLXdC7ORegXHIWzEwlvgyCnFQRsG4RtrC8IX1nzbBi9nfYd18zRh/TGWyB irFpLMFocNQbdSHMItN4MlD5MoD9cGfdhClCBtGa1ZmCttjv4RnXxbQMbzTUdbz6Idzj NBIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Z/EozGy7"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h11si22561209plk.113.2021.10.18.08.06.00; Mon, 18 Oct 2021 08:06:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Z/EozGy7"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232161AbhJRPH5 (ORCPT + 99 others); Mon, 18 Oct 2021 11:07:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58546 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232860AbhJRPHI (ORCPT ); Mon, 18 Oct 2021 11:07:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634569496; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=34+aPebgzzHxYJ84OQLGkAmjt/20nxAv2uPWKUz1+/c=; b=Z/EozGy7qjJmMztf1Ejgkqi2YA/4CD5F8Q2asQ9o+hkmExa+wKANKcgHr0DkXRkz1B57iY WzBq6Qegqc67rvJ39Kv1AKBMD4I/7EsL6fFzD36EQNxYXk7LjPQujO0OShBMqeLbBIFhXu YuErtphcVd0vz57PgNAUS3uNkof/aBM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-596-ouOaMab7MBK4Y2RN2Uc4WA-1; Mon, 18 Oct 2021 11:04:53 -0400 X-MC-Unique: ouOaMab7MBK4Y2RN2Uc4WA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 21E2E80982E; Mon, 18 Oct 2021 15:04:51 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id B868F108D7; Mon, 18 Oct 2021 15:04:09 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 53/67] afs: Invoke fscache_resize_cookie() when handling ATTR_SIZE for setattr From: David Howells To: linux-cachefs@redhat.com Cc: Marc Dionne , linux-afs@lists.infradead.org, dhowells@redhat.com, Trond Myklebust , Anna Schumaker , Steve French , Dominique Martinet , Jeff Layton , Matthew Wilcox , Alexander Viro , Omar Sandoval , Linus Torvalds , linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 18 Oct 2021 16:04:08 +0100 Message-ID: <163456944892.2614702.6257175032771958470.stgit@warthog.procyon.org.uk> In-Reply-To: <163456861570.2614702.14754548462706508617.stgit@warthog.procyon.org.uk> References: <163456861570.2614702.14754548462706508617.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Invoke fscache_resize_cookie() to adjust the size of the backing cache object when setattr is called with ATTR_SIZE. This discards any data that then lies beyond the revised EOF and frees up space. Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/inode.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/afs/inode.c b/fs/afs/inode.c index 311df66c64d0..c4af4fda37dd 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -829,6 +829,9 @@ static void afs_setattr_edit_file(struct afs_operation *op) if (size < i_size) truncate_pagecache(inode, size); + if (size != i_size) + fscache_resize_cookie(afs_vnode_cache(vp->vnode), + vp->scb.status.size); } } @@ -872,6 +875,8 @@ int afs_setattr(struct user_namespace *mnt_userns, struct dentry *dentry, attr->ia_valid &= ~ATTR_SIZE; } + fscache_use_cookie(afs_vnode_cache(vnode), true); + /* flush any dirty data outstanding on a regular file */ if (S_ISREG(vnode->vfs_inode.i_mode)) filemap_write_and_wait(vnode->vfs_inode.i_mapping); @@ -903,6 +908,7 @@ int afs_setattr(struct user_namespace *mnt_userns, struct dentry *dentry, out_unlock: up_write(&vnode->validate_lock); + fscache_unuse_cookie(afs_vnode_cache(vnode), NULL, NULL); _leave(" = %d", ret); return ret; }