Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp367407pxu; Tue, 6 Oct 2020 08:16:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzWcKtdVKYC9UvYGpznWOtSKHxKDe1SlRC1+uYQ13bQB0MN+JRHBvQDXoQ4bAm7bG4305/ X-Received: by 2002:a05:6402:651:: with SMTP id u17mr5851579edx.206.1601997408677; Tue, 06 Oct 2020 08:16:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601997408; cv=none; d=google.com; s=arc-20160816; b=djCLLlY0p8Z53oL3McztSusl6fGIIm9xXDetV5VH2iXFtNWinA9GE1cu5IOjC9JMLN sHn0hwh3H4R2eueQi/cvHnfkFqRECWmkeaTFUhyGVYeBtql74/wa5mVvx2hgoPFN9gtU fWwaQd30xahXdClFYr08VVQnxTcXaHE7kAor26UqM6K8+cBPYuQkUacapEmO86gdrnK2 dp5fFP3icLW0tkWcTfJri4E+1xWUz7x/xu+jniIqIcolfziIRftPtPOTfqYC7pRJTuWN trBhTKnQE3pP7L0I1h/9Vh9uLhoMk4MxXb5tezGwCyaWwdtrgiOWy/dv+r28uAYIKrjP GkPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=O3wutOykn+qjv13+aIbbS9aviAcrhkTNsBYW/8APKCI=; b=l8CrUFG6q7u9VD9XC8YUuIWNNBar23lyoUlh7OWkTH1YV60Lx4wE6+EMSG5rJe4BT/ U+k8yejf/pKE3kwdRDfn+YEFhLDjXEi9G9Huv3hTiZQ8zerS5qti1c309YSLFClYeYKR kr713bRJnXl0ZMM6Rw2DenYX27LJeQoveqiolvC2Vf6nh9O+C/9qgJvzQrO53PlTnaa1 NHPseL1BUosNokcx51IoZvjMrDkUlqWB7OIww/KBDThjQeTga4WpZccgbYW91aXk1qC1 DJl13OK2XwmQTMQEbb8/FYEyW2SJUl/opDGSot7jm4o2APrvtzGAWPvjqgHg240dgadI WMHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ge7sc9DF; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y26si2113738edv.590.2020.10.06.08.16.21; Tue, 06 Oct 2020 08:16:48 -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=@gmail.com header.s=20161025 header.b=Ge7sc9DF; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726181AbgJFPPZ (ORCPT + 99 others); Tue, 6 Oct 2020 11:15:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725946AbgJFPPZ (ORCPT ); Tue, 6 Oct 2020 11:15:25 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E779EC061755; Tue, 6 Oct 2020 08:15:24 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id m15so1365407pls.8; Tue, 06 Oct 2020 08:15:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=O3wutOykn+qjv13+aIbbS9aviAcrhkTNsBYW/8APKCI=; b=Ge7sc9DFWYNmWKj/NId96QnjqS7divhkH2kHeTLILE/UPpyrCZ4IXU+0R3PRtbRyVH RVWsno4V7HbX1f1vratyfq6JlxSIHTI7s6CvK/KRkNviLAqBuNZBUxJZca8RdsURKy/t a6TubcGai1NF8WOXxKDBm8vNQsp8tbAJuPBzIpq5gazkyPhWnZj4Y3TWJ4ywE90xTQ0S wmhWCPeMv2RRIqEzNiSluNno3KwyBrVQZ4ZIkgGdZNeoEHL7m5LBhFDWvTa0fMCE7vSy ucoDTbq1s9IHd22dW7ECLT9QUIic0BEMjgQmzs9dDUkM9bVgdaLTvDzbOG83mGH2d1JV 9asQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=O3wutOykn+qjv13+aIbbS9aviAcrhkTNsBYW/8APKCI=; b=eCMN35Du900jj4OtMw5L8jCCimW/BUrODZc0Swqkr5VC6RDEuD7k/A8F5xUH1vbx4D mtGOxE0XgGYyc+CavrzIsOxCC3XHR/WFxugxMK0LheXaKlZKgkG9PvJTOpkDkg+osEKe p0dJ70efqbi+ZNkY2Q1iYSkF3MJj5A3YuVDxBasiWAngzdAyA9C9X7d/HMJB1axPaQ4r 2kdLFyWabDC/oiwS//z2Xx0T9igQ5yTGmKjrI+9s4sXXrYb6d1wBdZTDI88UF9juG2JU xNRZhL+MxjP5gbdB2XGN0TqFixqmL2emTA3fY/le5s3A5u9EqmCQmk9GoD0oOsSii+87 LL8Q== X-Gm-Message-State: AOAM5311GvGhky69XwpnQUKL/6PwhG6WxklbKFSlPb2lDDx7cwT6Yue2 cVD3vrG+U2lhL9WuUrdl93A= X-Received: by 2002:a17:902:b7ca:b029:d3:eca2:d221 with SMTP id v10-20020a170902b7cab02900d3eca2d221mr1808827plz.74.1601997324473; Tue, 06 Oct 2020 08:15:24 -0700 (PDT) Received: from ashish-sangwan.user.nutanix.com (mcp02.nutanix.com. [192.146.155.5]) by smtp.googlemail.com with ESMTPSA id x7sm2924159pgl.77.2020.10.06.08.15.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Oct 2020 08:15:23 -0700 (PDT) From: Ashish Sangwan To: Trond Myklebust Cc: ashishsangwan2@gmail.com, stable@vger.kernel.org, Anna Schumaker , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] NFS: Fix mode bits and nlink count for v4 referral dirs Date: Tue, 6 Oct 2020 08:14:56 -0700 Message-Id: <20201006151456.20875-1-ashishsangwan2@gmail.com> X-Mailer: git-send-email 2.16.3 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Request for mode bits and nlink count in the nfs4_get_referral call and if server returns them use them instead of hard coded values. CC: stable@vger.kernel.org Signed-off-by: Ashish Sangwan --- fs/nfs/nfs4proc.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 6e95c85fe395..efec05c5f535 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -266,7 +266,9 @@ const u32 nfs4_fs_locations_bitmap[3] = { | FATTR4_WORD0_FSID | FATTR4_WORD0_FILEID | FATTR4_WORD0_FS_LOCATIONS, - FATTR4_WORD1_OWNER + FATTR4_WORD1_MODE + | FATTR4_WORD1_NUMLINKS + | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP | FATTR4_WORD1_RAWDEV | FATTR4_WORD1_SPACE_USED @@ -7594,16 +7596,28 @@ nfs4_listxattr_nfs4_user(struct inode *inode, char *list, size_t list_len) */ static void nfs_fixup_referral_attributes(struct nfs_fattr *fattr) { + bool fix_mode = true, fix_nlink = true; + if (!(((fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) || (fattr->valid & NFS_ATTR_FATTR_FILEID)) && (fattr->valid & NFS_ATTR_FATTR_FSID) && (fattr->valid & NFS_ATTR_FATTR_V4_LOCATIONS))) return; + if (fattr->valid & NFS_ATTR_FATTR_MODE) + fix_mode = false; + if (fattr->valid & NFS_ATTR_FATTR_NLINK) + fix_nlink = false; fattr->valid |= NFS_ATTR_FATTR_TYPE | NFS_ATTR_FATTR_MODE | NFS_ATTR_FATTR_NLINK | NFS_ATTR_FATTR_V4_REFERRAL; - fattr->mode = S_IFDIR | S_IRUGO | S_IXUGO; - fattr->nlink = 2; + + if (fix_mode) + fattr->mode = S_IFDIR | S_IRUGO | S_IXUGO; + else + fattr->mode |= S_IFDIR; + + if (fix_nlink) + fattr->nlink = 2; } static int _nfs4_proc_fs_locations(struct rpc_clnt *client, struct inode *dir, -- 2.22.0