[Devel] [PATCH RHEL7 COMMIT] ms/NFSv4: Use the net namespace uniquifier if it is set

Vasily Averin vvs at virtuozzo.com
Tue Jan 25 12:38:40 MSK 2022


The commit is pushed to "branch-rh7-3.10.0-1160.53.1.vz7.185.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.53.1.vz7.185.2
------>
commit 4884a010dbbf5d458e9774cb2f91061dd95d6f50
Author: Trond Myklebust <trond.myklebust at hammerspace.com>
Date:   Tue Jan 25 12:38:40 2022 +0300

    ms/NFSv4: Use the net namespace uniquifier if it is set
    
    If a container sets a net namespace specific uniquifier, then use that
    in the setclientid/exchangeid process.
    
    Signed-off-by: Trond Myklebust <trond.myklebust at hammerspace.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker at Netapp.com>
    
    (cherry-picked from ms commit 39d43d164127da7fbc62d0ef73146e04e31a828d)
    https://jira.sw.ru/browse/PSBM-137154
    Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 fs/nfs/nfs4proc.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 7e629a8..50abfe6 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -61,6 +61,7 @@
 #include "callback.h"
 #include "pnfs.h"
 #include "netns.h"
+#include "sysfs.h"
 #include "nfs4idmap.h"
 #include "nfs4session.h"
 #include "fscache.h"
@@ -5489,11 +5490,23 @@ static void nfs4_init_boot_verifier(const struct nfs_client *clp,
 }
 
 static size_t
-nfs4_get_uniquifier(char *buf, size_t buflen)
+nfs4_get_uniquifier(struct nfs_client *clp, char *buf, size_t buflen)
 {
+	struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
+	struct nfs_netns_client *nn_clp = nn->nfs_client;
+	const char *id;
+
 	buf[0] = '\0';
 
-	if (nfs4_client_id_uniquifier[0] != '\0')
+	if (nn_clp) {
+		rcu_read_lock();
+		id = rcu_dereference(nn_clp->identifier);
+		if (id)
+			strscpy(buf, id, buflen);
+		rcu_read_unlock();
+	}
+
+	if (nfs4_client_id_uniquifier[0] != '\0' && buf[0] == '\0')
 		strscpy(buf, nfs4_client_id_uniquifier, buflen);
 
 	return strlen(buf);
@@ -5518,7 +5531,7 @@ nfs4_init_nonuniform_client_string(struct nfs_client *clp)
 		1;
 	rcu_read_unlock();
 
-	buflen = nfs4_get_uniquifier(buf, sizeof(buf));
+	buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf));
 	if (buflen)
 		len += buflen + 1;
 
@@ -5565,7 +5578,7 @@ nfs4_init_uniform_client_string(struct nfs_client *clp)
 	len = 10 + 10 + 1 + 10 + 1 +
 		strlen(clp->cl_rpcclient->cl_nodename) + 1;
 
-	buflen = nfs4_get_uniquifier(buf, sizeof(buf));
+	buflen = nfs4_get_uniquifier(clp, buf, sizeof(buf));
 	if (buflen)
 		len += buflen + 1;
 


More information about the Devel mailing list