Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7127622rwr; Tue, 2 May 2023 09:49:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ledW9STwsFLV/6HLfdr6vJCwiQco0oYzT4hR3o5jB4lXvwrQyGB7qtDbuxJLXmG0gpYTc X-Received: by 2002:a05:6a00:181d:b0:63b:2102:9fc8 with SMTP id y29-20020a056a00181d00b0063b21029fc8mr25918216pfa.21.1683046165192; Tue, 02 May 2023 09:49:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683046165; cv=none; d=google.com; s=arc-20160816; b=Lnfqo/geSklY1KsX7uQ3GPvkabFb/e7dM7mlhi+niDBHDao0ijYOtMjQDI6E2Rj9yR mf93iE/4sQPiLwXQBrwkbeSXY0v8d2TzJXbs+1QDA7NZZR2DErMFCH2O/AfaNA+MPdCI t1pjv57DYO0eQntnFDcSccPhBjMD0vnM4+Ws37n1skHQDwE2YwTnxp2LONJUYG4msmzk 1rtqOzdNPEUiXftwWBVH4D93QDgfXGONB0exdBRaAC36NPrHzkf5Fkwx2cMI8kOQaB5E /898KYqn4VctG3IWidMVT7rRlid6wxdwsCe6W7tZUZRaZagBuqsRin9fm8e5dOKxfdr/ Yekg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w5-20020a626205000000b00624ac1abef6si32307252pfb.218.2023.05.02.09.49.13; Tue, 02 May 2023 09:49:25 -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 S234325AbjEBQht (ORCPT + 99 others); Tue, 2 May 2023 12:37:49 -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 Content-Transfer-Encoding: 8bit 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 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);