Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3974138pxf; Mon, 29 Mar 2021 17:21:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJwGhZK/v1H2TK/pOkCGgMyEWXWjHHIri6pWU6IbyrbvcWIOvu6ngj+L7p3Vz+4Qe8Tqiz X-Received: by 2002:a17:906:3952:: with SMTP id g18mr30865800eje.104.1617063665994; Mon, 29 Mar 2021 17:21:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617063665; cv=none; d=google.com; s=arc-20160816; b=vK+S/TtoP+53F/6y2Glu2wqoAtPs3VkRsfkGkqGWExazXAc8pWGcHlOHqfO+4yUIl4 dTiGcKt14U/oewP4kTIFjB1WZk9j7Kn5D3wtFyy/woAAfhFFo6bSx4Ugn6aF+DcCaoDv qL+tpb9Yx0FCz8uV8TJCYN1mEwBOr2soPHW1juXn9k8odNF3B+I5qwhLVdc2zXLaEnYq CYXRl/tnycYJJahiCS5VsIMyCWNAmx4DxFgNAXDcx50TNAI/M4sitL/FoCn/ck+8IyT9 jp1k/Iq9+xHvtTt/tmDdCs25bRPRTn1NJaRcAG8GUHdYfWY8uPRoQ9HGB5KnukA8fwI8 SsJg== 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:to:from :dkim-signature; bh=GF1+b4+BMhpcN9rlpOEn2NHgjT7t9s/cQsSBfJiWFUw=; b=JCkFZrArJANWV5tM6p9zwEo20QS/26Y7NSpa3fn1L1TVcINlJzSAcLKOFF9ITASIdX HoSHT3S1KwV1etnowsixlqlVLE4JufGTm3KLwxckjaYF47vUlbUL4qIfLvgKyiJvfMnB xBlbAHwQuA1frYTrZ2mIXWpHByyxxqXReYJlYv1iLspjWR0JAqZICcb+43PDSDjTi5Wt W4AS4hngTkad8d1hDoU3bIExA7UhEswu9oVjgJG13p4JSGZkqUJiXWhnoc0w8M41UdA9 x+X3NamRMaQl57zpTWTrscBawXddLrzu2zNaQhRx3CZ6r7jltK0GfikyoWlznqfm+xCG 1kpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j+5Lw6ax; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t19si14028570ejx.42.2021.03.29.17.20.44; Mon, 29 Mar 2021 17:21:05 -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=@kernel.org header.s=k20201202 header.b=j+5Lw6ax; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229861AbhC3ATN (ORCPT + 99 others); Mon, 29 Mar 2021 20:19:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:50376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229911AbhC3ASo (ORCPT ); Mon, 29 Mar 2021 20:18:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D4F9161985 for ; Tue, 30 Mar 2021 00:18:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617063523; bh=6MtErt9FfUDl52MMK2uZItzbolaPS6ow/Og4Mbj4Rvk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=j+5Lw6ax411uYxJ32FGtItyocjLtwHlGSfpnVbe5D8XZJKBC+DQ2vKcjxbVylNoxr GROaKdJs9m+pJ4kDhPzCNTCRvhgTRbKI2BeW6HN8Qx9N7C34HqRPHMeWNXnm3bxDYp yrBm5I0S6NDsd/tykneZPE6cSVwSfGROEMhSVFQB/xNBb741nXcDsLS7J5B7pjFBOm L8m0NGcOETcFEQSpEQeo1DyFHPKPNc2eTGmNNymbUtCR+LarTJZ8Haorczy2F6obM9 +VabJ8v/IMVJB3/K/yP9wflP8XDzdFIBSLaqe7t2W2SIV6Dn0wpYqsvoTL8gKc9mvP 68EBqFh0UFpAw== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH 07/17] NFS: Fix up statx() results Date: Mon, 29 Mar 2021 20:18:25 -0400 Message-Id: <20210330001835.41914-8-trondmy@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210330001835.41914-7-trondmy@kernel.org> References: <20210330001835.41914-1-trondmy@kernel.org> <20210330001835.41914-2-trondmy@kernel.org> <20210330001835.41914-3-trondmy@kernel.org> <20210330001835.41914-4-trondmy@kernel.org> <20210330001835.41914-5-trondmy@kernel.org> <20210330001835.41914-6-trondmy@kernel.org> <20210330001835.41914-7-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust If statx has valid attributes available that weren't asked for, then return them and set the result mask appropriately. Signed-off-by: Trond Myklebust --- fs/nfs/inode.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 5280f28a67a7..538ea8a0e171 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -806,6 +806,28 @@ static bool nfs_need_revalidate_inode(struct inode *inode) return false; } +static u32 nfs_get_valid_attrmask(struct inode *inode) +{ + unsigned long cache_validity = READ_ONCE(NFS_I(inode)->cache_validity); + u32 reply_mask = STATX_INO | STATX_TYPE; + + if (!(cache_validity & NFS_INO_INVALID_ATIME)) + reply_mask |= STATX_ATIME; + if (!(cache_validity & NFS_INO_REVAL_PAGECACHE)) { + if (!(cache_validity & NFS_INO_INVALID_CTIME)) + reply_mask |= STATX_CTIME; + if (!(cache_validity & NFS_INO_INVALID_MTIME)) + reply_mask |= STATX_MTIME; + if (!(cache_validity & NFS_INO_INVALID_SIZE)) + reply_mask |= STATX_SIZE; + } + if (!(cache_validity & NFS_INO_INVALID_OTHER)) + reply_mask |= STATX_UID | STATX_GID | STATX_MODE | STATX_NLINK; + if (!(cache_validity & NFS_INO_INVALID_BLOCKS)) + reply_mask |= STATX_BLOCKS; + return reply_mask; +} + int nfs_getattr(struct user_namespace *mnt_userns, const struct path *path, struct kstat *stat, u32 request_mask, unsigned int query_flags) { @@ -824,7 +846,7 @@ int nfs_getattr(struct user_namespace *mnt_userns, const struct path *path, if ((query_flags & AT_STATX_DONT_SYNC) && !force_sync) { nfs_readdirplus_parent_cache_hit(path->dentry); - goto out_no_update; + goto out_no_revalidate; } /* Flush out writes to the server in order to update c/mtime. */ @@ -870,6 +892,7 @@ int nfs_getattr(struct user_namespace *mnt_userns, const struct path *path, do_update |= cache_validity & NFS_INO_INVALID_OTHER; if (request_mask & STATX_BLOCKS) do_update |= cache_validity & NFS_INO_INVALID_BLOCKS; + if (do_update) { /* Update the attribute cache */ if (!(server->flags & NFS_MOUNT_NOAC)) @@ -883,8 +906,8 @@ int nfs_getattr(struct user_namespace *mnt_userns, const struct path *path, nfs_readdirplus_parent_cache_hit(path->dentry); out_no_revalidate: /* Only return attributes that were revalidated. */ - stat->result_mask &= request_mask; -out_no_update: + stat->result_mask = nfs_get_valid_attrmask(inode) | request_mask; + generic_fillattr(&init_user_ns, inode, stat); stat->ino = nfs_compat_user_ino64(NFS_FILEID(inode)); if (S_ISDIR(inode->i_mode)) -- 2.30.2