From patchwork Tue May 2 16:35:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 89427 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp775648vqo; Tue, 2 May 2023 10:17:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4T0GG12umZEtbMq2bwegRrrZjHOjLU7WYd862FTKR5Yw1c+eMy+XHOztapchCrqdHMthqm X-Received: by 2002:a17:902:b490:b0:1a8:431:9e14 with SMTP id y16-20020a170902b49000b001a804319e14mr15662246plr.25.1683047876034; Tue, 02 May 2023 10:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683047876; cv=none; d=google.com; s=arc-20160816; b=l7k0FEK+SmDJg0gq98J3UnY+3CvyEHypgFeIyZJ5TUQyXXbbuntpuYCsrOYshvDzn7 uQLSnmMEYV8jYrxEooFVqhLuUWfwvRIheiG93dSKFQfJ2xwvbGONQUD5KZaZhiPBxHxM ZF544uisfcixbvDHGNBq+098y85ToWHXFI8+wYeSmNQmwGg842hA9yGf5PdIvzf6Cngq TM/EcBadr39wksthEoGEcfJzCJRH2VBEWJcfERSCLNLRA7VkSvx2AVawI3txL85y8fXX hU2UY2R67Ld6Z3kIKP0W00cxeglTT0Htc55ME7hbLcSfwdS2y2wfU65VVBNENnjw5j9e 8LSQ== 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=wV8lRfszHcQUBFiJ03SQYtrFihBDDfl7rukuI3tTTP0=; b=nkTEEKUbIYshjLWEuykhQG/c/lZMTnapJWpXe+kIC1y3iCVGx7Y/kDGQStIr+t/2mb iGlmq98GmHrtgk9AAvXH/YgnrTsQ8MJNfJApyHEQau0P323AtF1xE74sMmZfuXUw42kZ dMzNKHezmmyL9xu6tb+gtyD9O6B6BnChU8djJyqXT9hQLDPYfLJbGQ8iGgwwANZU27ba 2+PIappAI9WfI2i7sJcH+ZVbwjM/c3OS3qnQWx+Rop4dZehse4sXVkzkms33vpL3J3Cp s88P+kCsQsz6DBXeF1oxqUMAgMJsgsqNlgFRh9oOnhnKVtTu41gMGg2bf57GQL2DrgZD Eipw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fDwS8hTQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j17-20020a170902759100b001a511921c06si29549962pll.358.2023.05.02.10.17.42; Tue, 02 May 2023 10:17:56 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=fDwS8hTQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234328AbjEBQhu (ORCPT + 99 others); Tue, 2 May 2023 12:37:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233869AbjEBQhV (ORCPT ); Tue, 2 May 2023 12:37:21 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73FDB448F for ; Tue, 2 May 2023 09:35:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683045343; 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=wV8lRfszHcQUBFiJ03SQYtrFihBDDfl7rukuI3tTTP0=; b=fDwS8hTQ4/cMdI8fLtr4yHNWl5sr8nHJxH22GAL0KGZU3FYo9AnbgX09v85II+XGso9pHM NUyGBjiDMsuSkWFGs+vn1YF02r816PQv0ma2Uv/FFEI0EOU3Qjq+BqU0/xpFknb4hFTgWF 61c2GgPZsIfhjeg4Qdr+zIfbpXODvus= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-641-T2kRHgaYOKieljbTt65cPA-1; Tue, 02 May 2023 12:35:40 -0400 X-MC-Unique: T2kRHgaYOKieljbTt65cPA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 92C48101A550; Tue, 2 May 2023 16:35:39 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id C17D52166B26; Tue, 2 May 2023 16:35:38 +0000 (UTC) From: David Howells To: Linus Torvalds Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] afs: Fix getattr to report server i_size on dirs, not local size Date: Tue, 2 May 2023 17:35:27 +0100 Message-Id: <20230502163528.1564398-3-dhowells@redhat.com> In-Reply-To: <20230502163528.1564398-1-dhowells@redhat.com> References: <20230502163528.1564398-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764803609541141596?= X-GMAIL-MSGID: =?utf-8?q?1764803609541141596?= Fix afs_getattr() to report the server's idea of the file size of a directory rather than the local size. The local size may differ as we edit the local copy to avoid having to redownload it and we may end up with a differently structured blob of a different size. However, if the directory is discarded from the pagecache we then download it again and the user may see the directory file size apparently change. Fixes: 63a4681ff39c ("afs: Locally edit directory data for mkdir/create/unlink/...") Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/inode.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/afs/inode.c b/fs/afs/inode.c index 82edd3351734..866bab860a88 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -450,7 +450,7 @@ static void afs_get_inode_cache(struct afs_vnode *vnode) 0 : FSCACHE_ADV_SINGLE_CHUNK, &key, sizeof(key), &aux, sizeof(aux), - vnode->status.size)); + i_size_read(&vnode->netfs.inode))); #endif } @@ -777,6 +777,13 @@ int afs_getattr(struct mnt_idmap *idmap, const struct path *path, if (test_bit(AFS_VNODE_SILLY_DELETED, &vnode->flags) && stat->nlink > 0) stat->nlink -= 1; + + /* Lie about the size of directories. We maintain a locally + * edited copy and may make different allocation decisions on + * it, but we need to give userspace the server's size. + */ + if (S_ISDIR(inode->i_mode)) + stat->size = vnode->netfs.remote_i_size; } while (need_seqretry(&vnode->cb_lock, seq)); done_seqretry(&vnode->cb_lock, seq);