Skip to contentSkip to conversation

SUNRPC: make rpcbind clients allocated and destroyed dynamically

PATCH Superseded Stanislav Kinsbursky 2 participants 18 messages Sep 13, 2011 – Sep 20, 2011

Subsystems (4)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v3 cover SUNRPC: make rpcbind clients allocated and destroyed dynamically

v3:
1) rebased to v3.1-rc6 (against branch
git://git.linux-nfs.org/projects/trondmy/nfs-2.6.git)
2) creation and destruction on rpcbind clients now depends on service type

This patch is required for further RPC layer virtualization, because rpcbind clients have to be per network namespace.
To achive this, we have to untie network namespace from rpcbind clients sockets. The idea of this patch set is to make rpcbind clients non-static. I.e. rpcbind clients will be created during first RPC service creation, and destroyed when last RPC service is stopped.
With this patch set rpcbind clients can be virtualized easely.

The following series consists of:

---

Stanislav Kinsbursky (11):
SUNRPC: introduce helpers for reference counted rpcbind clients
SUNRPC: use rpcbind reference counting helpers
SUNRPC: introduce svc helpers for prepairing rpcbind infrastructure
SUNRPC: parametrize svc creation calls with portmapper flag
SUNRPC: cleanup service destruction
Lockd: force creation of rpcbind clients during service creation
NFS: avoid rpcbind clients creation during service creation
NFSd: force creation of rpcbind clients during service creation
NFSd: call svc rpcbind cleanup explicitly
SUNRPC: remove rpcbind clients creation during service registering
SUNRPC: remove rpcbind clients destruction on module cleanup

 fs/lockd/svc.c              |    2 +
 fs/nfs/callback.c           |    2 +
 fs/nfsd/nfssvc.c            |    4 ++
 include/linux/sunrpc/clnt.h |    2 +
 include/linux/sunrpc/svc.h  |    3 ++
 net/sunrpc/rpcb_clnt.c      |   85 ++++++++++++++++++++++++++++---------------
 net/sunrpc/sunrpc_syms.c    |    3 --
 net/sunrpc/svc.c            |   41 +++++++++++++++++----
 8 files changed, 98 insertions(+), 44 deletions(-)
Signature · 1 line
Signature
#1 lore raw

PATCH v3 1/11 SUNRPC: introduce helpers for reference counted rpcbind clients

This helpers will be used for dynamical creation and destruction of rpcbind clients.
Variable rpcb_users is actually a counter of lauched RPC services. If rpcbind clients has been created already, then we just increase rpcb_users.

---
 net/sunrpc/rpcb_clnt.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)
net/sunrpc/rpcb_clnt.c +50 -0
index e45d2fb..3f2bb8a 100644
@@ -114,6 +114,9 @@ static struct rpc_program	rpcb_program;
 static struct rpc_clnt *	rpcb_local_clnt;
 static struct rpc_clnt *	rpcb_local_clnt4;
 
+DEFINE_SPINLOCK(rpcb_clnt_lock);
+unsigned int			rpcb_users;
+
 struct rpcbind_args {
 	struct rpc_xprt *	r_xprt;
 
@@ -161,6 +164,53 @@ static void rpcb_map_release(void *data)
 	kfree(map);
 }
 
+static int rpcb_get_local(void)
+{
+	spin_lock(&rpcb_clnt_lock);
+	if (rpcb_users)
+		rpcb_users++;
+	spin_unlock(&rpcb_clnt_lock);
+
+	return rpcb_users;
+}
+
+void rpcb_put_local(void)
+{
+	struct rpc_clnt *clnt = rpcb_local_clnt;
+	struct rpc_clnt *clnt4 = rpcb_local_clnt4;
+	int shutdown;
+
+	spin_lock(&rpcb_clnt_lock);
+	if (--rpcb_users == 0) {
+		rpcb_local_clnt = NULL;
+		rpcb_local_clnt4 = NULL;
+	}
+	shutdown = !rpcb_users;
+	spin_unlock(&rpcb_clnt_lock);
+
+	if (shutdown) {
+		/*
+		 * cleanup_rpcb_clnt - remove xprtsock's sysctls, unregister
+		 */
+		if (clnt4)
+			rpc_shutdown_client(clnt4);
+		if (clnt)
+			rpc_shutdown_client(clnt);
+	}
+	return;
+}
+
+static void rpcb_set_local(struct rpc_clnt *clnt, struct rpc_clnt *clnt4)
+{
+	/* Protected by rpcb_create_local_mutex */
+	rpcb_local_clnt = clnt;
+	rpcb_local_clnt4 = clnt4;
+	rpcb_users++;
+	dprintk("RPC:       created new rpcb local clients (rpcb_local_clnt: "
+			"0x%p, rpcb_local_clnt4: 0x%p)\n", rpcb_local_clnt,
+			rpcb_local_clnt4);
+}
+
 /*
  * Returns zero on success, otherwise a negative errno value
  * is returned.
#2 lore raw

PATCH v3 2/11 SUNRPC: use rpcbind reference counting helpers

In reply to Stanislav Kinsbursky

All is simple: we just increase users counter if rpcbind clients has been created already. Otherwise we create them and set users counter to 1.

---
 net/sunrpc/rpcb_clnt.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)
net/sunrpc/rpcb_clnt.c +4 -8
index 3f2bb8a..b3ac194 100644
@@ -255,9 +255,7 @@ static int rpcb_create_local_unix(void)
 		clnt4 = NULL;
 	}
 
-	/* Protected by rpcb_create_local_mutex */
-	rpcb_local_clnt = clnt;
-	rpcb_local_clnt4 = clnt4;
+	rpcb_set_local(clnt, clnt4);
 
 out:
 	return result;
@@ -309,9 +307,7 @@ static int rpcb_create_local_net(void)
 		clnt4 = NULL;
 	}
 
-	/* Protected by rpcb_create_local_mutex */
-	rpcb_local_clnt = clnt;
-	rpcb_local_clnt4 = clnt4;
+	rpcb_set_local(clnt, clnt4);
 
 out:
 	return result;
@@ -326,11 +322,11 @@ static int rpcb_create_local(void)
 	static DEFINE_MUTEX(rpcb_create_local_mutex);
 	int result = 0;
 
-	if (rpcb_local_clnt)
+	if (rpcb_get_local())
 		return result;
 
 	mutex_lock(&rpcb_create_local_mutex);
-	if (rpcb_local_clnt)
+	if (rpcb_get_local())
 		goto out;
 
 	if (rpcb_create_local_unix() != 0)
#3 lore raw

PATCH v3 3/11 SUNRPC: introduce svc helpers for prepairing rpcbind infrastructure

In reply to Stanislav Kinsbursky

This helpers will be used only for those services, that will send portmapper registration calls.

---
 include/linux/sunrpc/clnt.h |    2 ++
 net/sunrpc/rpcb_clnt.c      |    2 +-
 net/sunrpc/svc.c            |   18 ++++++++++++++++++
 3 files changed, 21 insertions(+), 1 deletions(-)
include/linux/sunrpc/clnt.h +2 -0
index db7bcaf..1eb437d 100644
@@ -135,6 +135,8 @@ void		rpc_shutdown_client(struct rpc_clnt *);
 void		rpc_release_client(struct rpc_clnt *);
 void		rpc_task_release_client(struct rpc_task *);
 
+int		rpcb_create_local(void);
+void		rpcb_put_local(void);
 int		rpcb_register(u32, u32, int, unsigned short);
 int		rpcb_v4_register(const u32 program, const u32 version,
 				 const struct sockaddr *address,
net/sunrpc/rpcb_clnt.c +1 -1
index b3ac194..d42b642 100644
@@ -317,7 +317,7 @@ out:
  * Returns zero on success, otherwise a negative errno value
  * is returned.
  */
-static int rpcb_create_local(void)
+int rpcb_create_local(void)
 {
 	static DEFINE_MUTEX(rpcb_create_local_mutex);
 	int result = 0;
net/sunrpc/svc.c +18 -0
index 6a69a11..f31e5cc 100644
@@ -354,6 +354,24 @@ svc_pool_for_cpu(struct svc_serv *serv, int cpu)
 	return &serv->sv_pools[pidx % serv->sv_nrpools];
 }
 
+static int svc_rpcb_setup(struct svc_serv *serv)
+{
+	int err;
+
+	err = rpcb_create_local();
+	if (err)
+		return err;
+
+	/* Remove any stale portmap registrations */
+	svc_unregister(serv);
+	return 0;
+}
+
+static void svc_rpcb_cleanup(struct svc_serv *serv)
+{
+	svc_unregister(serv);
+	rpcb_put_local();
+}
 
 /*
  * Create an RPC service
#4 lore raw

PATCH v3 4/11 SUNRPC: parametrize svc creation calls with portmapper flag

In reply to Stanislav Kinsbursky

This new flag ("setup_rpcbind) will be used to detect, that new service will send portmapper register calls. For such services we will create rpcbind clients and remove all stale portmap registrations.
Also, svc_rpcb_cleanup() will be set as sv_shutdown callback for such services in case of this field wasn't initialized earlier. This will allow to destroy rpcbind clients when no other users of them left.

---
 include/linux/sunrpc/svc.h |    2 ++
 net/sunrpc/svc.c           |   21 ++++++++++++++-------
 2 files changed, 16 insertions(+), 7 deletions(-)
include/linux/sunrpc/svc.h +2 -0
index 223588a..528952a 100644
@@ -402,11 +402,13 @@ struct svc_procedure {
  * Function prototypes.
  */
 struct svc_serv *svc_create(struct svc_program *, unsigned int,
+			    int setup_rpcbind,
 			    void (*shutdown)(struct svc_serv *));
 struct svc_rqst *svc_prepare_thread(struct svc_serv *serv,
 					struct svc_pool *pool);
 void		   svc_exit_thread(struct svc_rqst *);
 struct svc_serv *  svc_create_pooled(struct svc_program *, unsigned int,
+			int setup_rpcbind,
 			void (*shutdown)(struct svc_serv *),
 			svc_thread_fn, struct module *);
 int		   svc_set_num_threads(struct svc_serv *, struct svc_pool *, int);
net/sunrpc/svc.c +14 -7
index f31e5cc..03231d5 100644
@@ -378,7 +378,7 @@ static void svc_rpcb_cleanup(struct svc_serv *serv)
  */
 static struct svc_serv *
 __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
-	     void (*shutdown)(struct svc_serv *serv))
+	     int setup_rpcbind, void (*shutdown)(struct svc_serv *serv))
 {
 	struct svc_serv	*serv;
 	unsigned int vers;
@@ -437,29 +437,36 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
 		spin_lock_init(&pool->sp_lock);
 	}
 
-	/* Remove any stale portmap registrations */
-	svc_unregister(serv);
+	if (setup_rpcbind) {
+	       	if (svc_rpcb_setup(serv) < 0) {
+			kfree(serv->sv_pools);
+			kfree(serv);
+			return NULL;
+		}
+		if (!serv->sv_shutdown)
+			serv->sv_shutdown = svc_rpcb_cleanup;
+	}
 
 	return serv;
 }
 
 struct svc_serv *
 svc_create(struct svc_program *prog, unsigned int bufsize,
-	   void (*shutdown)(struct svc_serv *serv))
+	   int setup_rpcbind, void (*shutdown)(struct svc_serv *serv))
 {
-	return __svc_create(prog, bufsize, /*npools*/1, shutdown);
+	return __svc_create(prog, bufsize, /*npools*/1, setup_rpcbind, shutdown);
 }
 EXPORT_SYMBOL_GPL(svc_create);
 
 struct svc_serv *
 svc_create_pooled(struct svc_program *prog, unsigned int bufsize,
-		  void (*shutdown)(struct svc_serv *serv),
+		  int setup_rpcbind, void (*shutdown)(struct svc_serv *serv),
 		  svc_thread_fn func, struct module *mod)
 {
 	struct svc_serv *serv;
 	unsigned int npools = svc_pool_map_get();
 
-	serv = __svc_create(prog, bufsize, npools, shutdown);
+	serv = __svc_create(prog, bufsize, npools, setup_rpcbind, shutdown);
 
 	if (serv != NULL) {
 		serv->sv_function = func;

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw

PATCH v3 6/11 Lockd: force creation of rpcbind clients during service creation

In reply to Stanislav Kinsbursky

Lockd sends requests to portmapper and thus requires rpcbind clients.

---
 fs/lockd/svc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/lockd/svc.c +1 -1
index abfff9d..bdf79dc 100644
@@ -269,7 +269,7 @@ int lockd_up(void)
 			"lockd_up: no pid, %d users??\n", nlmsvc_users);
 
 	error = -ENOMEM;
-	serv = svc_create(&nlmsvc_program, LOCKD_BUFSIZE, NULL);
+	serv = svc_create(&nlmsvc_program, LOCKD_BUFSIZE, 1, NULL);
 	if (!serv) {
 		printk(KERN_WARNING "lockd_up: create service failed\n");
 		goto out;
#11 lore raw

PATCH v3 5/11 SUNRPC: cleanup service destruction

In reply to Stanislav Kinsbursky

svc_unregister() call have to be removed from svc_destroy() since it will be called in sv_shutdown callback.

---
 net/sunrpc/svc.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
net/sunrpc/svc.c +0 -1
index 03231d5..1bf1b1a 100644
@@ -513,7 +513,6 @@ svc_destroy(struct svc_serv *serv)
 	if (svc_serv_is_pooled(serv))
 		svc_pool_map_put();
 
-	svc_unregister(serv);
 	kfree(serv->sv_pools);
 	kfree(serv);
 }
#14 lore raw

PATCH v3 8/11 NFSd: force creation of rpcbind clients during service creation

In reply to Stanislav Kinsbursky

NFSd sends requests to portmapper and thus requires rpcbind clients.

---
 fs/nfsd/nfssvc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/nfsd/nfssvc.c +1 -1
index dc5a1bf..88faab8 100644
@@ -332,7 +332,7 @@ int nfsd_create_serv(void)
 	nfsd_reset_versions();
 
 	nfsd_serv = svc_create_pooled(&nfsd_program, nfsd_max_blksize,
-				      nfsd_last_thread, nfsd, THIS_MODULE);
+				      1, nfsd_last_thread, nfsd, THIS_MODULE);
 	if (nfsd_serv == NULL)
 		return -ENOMEM;
 
#15 lore raw

PATCH v3 9/11 NFSd: call svc rpcbind cleanup explicitly

In reply to Stanislav Kinsbursky

We have to call svc_rpcb_cleanup() explicitly from nfsd_last_thread() since this function is registered as service shutdown callback and thus nobody else will done it for us.

---
 fs/nfsd/nfssvc.c           |    2 ++
 include/linux/sunrpc/svc.h |    1 +
 net/sunrpc/svc.c           |    3 ++-
 3 files changed, 5 insertions(+), 1 deletions(-)
fs/nfsd/nfssvc.c +2 -0
index 88faab8..fe14cd2 100644
@@ -256,6 +256,8 @@ static void nfsd_last_thread(struct svc_serv *serv)
 	nfsd_serv = NULL;
 	nfsd_shutdown();
 
+	svc_rpcb_cleanup(serv);
+
 	printk(KERN_WARNING "nfsd: last server has exited, flushing export "
 			    "cache\n");
 	nfsd_export_flush();
include/linux/sunrpc/svc.h +1 -0
index 528952a..35fa9ca 100644
@@ -401,6 +401,7 @@ struct svc_procedure {
 /*
  * Function prototypes.
  */
+void svc_rpcb_cleanup(struct svc_serv *serv);
 struct svc_serv *svc_create(struct svc_program *, unsigned int,
 			    int setup_rpcbind,
 			    void (*shutdown)(struct svc_serv *));
net/sunrpc/svc.c +2 -1
index 1bf1b1a..71dd439 100644
@@ -367,11 +367,12 @@ static int svc_rpcb_setup(struct svc_serv *serv)
 	return 0;
 }
 
-static void svc_rpcb_cleanup(struct svc_serv *serv)
+void svc_rpcb_cleanup(struct svc_serv *serv)
 {
 	svc_unregister(serv);
 	rpcb_put_local();
 }
+EXPORT_SYMBOL_GPL(svc_rpcb_cleanup);
 
 /*
  * Create an RPC service
#13 lore raw

PATCH v3 7/11 NFS: avoid rpcbind clients creation during service creation

In reply to Stanislav Kinsbursky

NFS callbacks doesn't communicate portmapper and thus doesn't need rpcbind clients.

---
 fs/nfs/callback.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/nfs/callback.c +1 -1
index e3d2942..2715c02 100644
@@ -259,7 +259,7 @@ int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt)
 		nfs_callback_bc_serv(minorversion, xprt, cb_info);
 		goto out;
 	}
-	serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE, NULL);
+	serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE, 0, NULL);
 	if (!serv) {
 		ret = -ENOMEM;
 		goto out_err;
#16 lore raw

PATCH v3 10/11 SUNRPC: remove rpcbind clients creation during service registering

In reply to Stanislav Kinsbursky

We don't need this code since rpcbind clients are creating during RPC service creation.

---
 net/sunrpc/rpcb_clnt.c |    9 ---------
 1 files changed, 0 insertions(+), 9 deletions(-)
net/sunrpc/rpcb_clnt.c +0 -9
index d42b642..e5c936d 100644
@@ -428,11 +428,6 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port)
 	struct rpc_message msg = {
 		.rpc_argp	= &map,
 	};
-	int error;
-
-	error = rpcb_create_local();
-	if (error)
-		return error;
 
 	dprintk("RPC:       %sregistering (%u, %u, %d, %u) with local "
 			"rpcbind\n", (port ? "" : "un"),
@@ -568,11 +563,7 @@ int rpcb_v4_register(const u32 program, const u32 version,
 	struct rpc_message msg = {
 		.rpc_argp	= &map,
 	};
-	int error;
 
-	error = rpcb_create_local();
-	if (error)
-		return error;
 	if (rpcb_local_clnt4 == NULL)
 		return -EPROTONOSUPPORT;
 
#17 lore raw

PATCH v3 11/11 SUNRPC: remove rpcbind clients destruction on module cleanup

In reply to Stanislav Kinsbursky

Rpcbind clients destruction during SUNRPC module removing is obsolete since now those clients are destroying during last RPC service shutdown.

---
 net/sunrpc/rpcb_clnt.c   |   12 ------------
 net/sunrpc/sunrpc_syms.c |    3 ---
 2 files changed, 0 insertions(+), 15 deletions(-)
net/sunrpc/rpcb_clnt.c +0 -12
index e5c936d..fc6c59b 100644
@@ -1097,15 +1097,3 @@ static struct rpc_program rpcb_program = {
 	.version	= rpcb_version,
 	.stats		= &rpcb_stats,
 };
-
-/**
- * cleanup_rpcb_clnt - remove xprtsock's sysctls, unregister
- *
- */
-void cleanup_rpcb_clnt(void)
-{
-	if (rpcb_local_clnt4)
-		rpc_shutdown_client(rpcb_local_clnt4);
-	if (rpcb_local_clnt)
-		rpc_shutdown_client(rpcb_local_clnt);
-}
net/sunrpc/sunrpc_syms.c +0 -3
index 9d08091..8ec9778 100644
@@ -61,8 +61,6 @@ static struct pernet_operations sunrpc_net_ops = {
 
 extern struct cache_detail unix_gid_cache;
 
-extern void cleanup_rpcb_clnt(void);
-
 static int __init
 init_sunrpc(void)
 {
@@ -102,7 +100,6 @@ out:
 static void __exit
 cleanup_sunrpc(void)
 {
-	cleanup_rpcb_clnt();
 	rpcauth_remove_module();
 	cleanup_socket_xprt();
 	svc_cleanup_xprt_sock();
#5 lore raw

Re: [PATCH v3 04/11] SUNRPC: parametrize svc creation calls with portmapper flag

In reply to Stanislav Kinsbursky
Quoted 19 lines · On Tue, 13 Sep 2011 22:13:51 +0400 Stanislav Kinsbursky…

This new flag ("setup_rpcbind) will be used to detect, that new service will send portmapper register calls. For such services we will create rpcbind clients and remove all stale portmap registrations.
Also, svc_rpcb_cleanup() will be set as sv_shutdown callback for such services in case of this field wasn't initialized earlier. This will allow to destroy rpcbind clients when no other users of them left.

---
 include/linux/sunrpc/svc.h |    2 ++
 net/sunrpc/svc.c           |   21 ++++++++++++++-------
 2 files changed, 16 insertions(+), 7 deletions(-)
include/linux/sunrpc/svc.h +0 -0
index 223588a..528952a 100644

include/linux/sunrpc/svc.h struct svc_procedure { · line 405

Quoted 4 lines
include/linux/sunrpc/svc.h +1 -0
@@ -402,11 +402,13 @@ struct svc_procedure {
  * Function prototypes.
  */
 struct svc_serv *svc_create(struct svc_program *, unsigned int,
+			    int setup_rpcbind,

^^^
Instead of adding this parameter, why not base this on the vs_hidden flag in the svc_version? IOW, have a function that looks at all the svc_versions for a particular svc_program, and returns "true" if any of them have vs_hidden unset? The mechanism you're proposing here has the potential to be out of sync with the vs_hidden flag.

Also, if you're adding an argument to a function like this, you you really ought to change the callers in the same patch. Otherwise you'll cause a build break if someone tries to bisect and ends up between the patch that changes the function and the one that changes the callers.

Quoted 70 lines
include/linux/sunrpc/svc.h +1 -0
 			    void (*shutdown)(struct svc_serv *));
 struct svc_rqst *svc_prepare_thread(struct svc_serv *serv,
 					struct svc_pool *pool);
 void		   svc_exit_thread(struct svc_rqst *);
 struct svc_serv *  svc_create_pooled(struct svc_program *, unsigned int,
+			int setup_rpcbind,
 			void (*shutdown)(struct svc_serv *),
 			svc_thread_fn, struct module *);
 int		   svc_set_num_threads(struct svc_serv *, struct svc_pool *, int);
net/sunrpc/svc.c +14 -8
index f31e5cc..03231d5 100644
@@ -378,7 +378,7 @@ static void svc_rpcb_cleanup(struct svc_serv *serv)
  */
 static struct svc_serv *
 __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
-	     void (*shutdown)(struct svc_serv *serv))
+	     int setup_rpcbind, void (*shutdown)(struct svc_serv *serv))
 {
 	struct svc_serv	*serv;
 	unsigned int vers;
@@ -437,29 +437,36 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
 		spin_lock_init(&pool->sp_lock);
 	}
 
-	/* Remove any stale portmap registrations */
-	svc_unregister(serv);
+	if (setup_rpcbind) {
+	       	if (svc_rpcb_setup(serv) < 0) {
+			kfree(serv->sv_pools);
+			kfree(serv);
+			return NULL;
+		}
+		if (!serv->sv_shutdown)
+			serv->sv_shutdown = svc_rpcb_cleanup;
+	}
 
 	return serv;
 }
 
 struct svc_serv *
 svc_create(struct svc_program *prog, unsigned int bufsize,
-	   void (*shutdown)(struct svc_serv *serv))
+	   int setup_rpcbind, void (*shutdown)(struct svc_serv *serv))
 {
-	return __svc_create(prog, bufsize, /*npools*/1, shutdown);
+	return __svc_create(prog, bufsize, /*npools*/1, setup_rpcbind, shutdown);
 }
 EXPORT_SYMBOL_GPL(svc_create);
 
 struct svc_serv *
 svc_create_pooled(struct svc_program *prog, unsigned int bufsize,
-		  void (*shutdown)(struct svc_serv *serv),
+		  int setup_rpcbind, void (*shutdown)(struct svc_serv *serv),
 		  svc_thread_fn func, struct module *mod)
 {
 	struct svc_serv *serv;
 	unsigned int npools = svc_pool_map_get();
 
-	serv = __svc_create(prog, bufsize, npools, shutdown);
+	serv = __svc_create(prog, bufsize, npools, setup_rpcbind, shutdown);
 
 	if (serv != NULL) {
 		serv->sv_function = func;
 
--

To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 5 lines
Jeff Layton <[email protected]>
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw

Re: [PATCH v3 04/11] SUNRPC: parametrize svc creation calls with portmapper flag

19.09.2011 18:08, Jeff Layton пишет:

Quoted 27 lines
Quoted 19 lines · On Tue, 13 Sep 2011 22:13:51 +0400 Stanislav…

This new flag ("setup_rpcbind) will be used to detect, that new service will send portmapper register calls. For such services we will create rpcbind clients and remove all stale portmap registrations.
Also, svc_rpcb_cleanup() will be set as sv_shutdown callback for such services in case of this field wasn't initialized earlier. This will allow to destroy rpcbind clients when no other users of them left.

---
  include/linux/sunrpc/svc.h |    2 ++
  net/sunrpc/svc.c           |   21 ++++++++++++++-------
  2 files changed, 16 insertions(+), 7 deletions(-)
include/linux/sunrpc/svc.h +0 -0
index 223588a..528952a 100644

include/linux/sunrpc/svc.h struct svc_procedure { · line 405

Quoted 4 lines
include/linux/sunrpc/svc.h +1 -0
@@ -402,11 +402,13 @@ struct svc_procedure {
   * Function prototypes.
   */
  struct svc_serv *svc_create(struct svc_program *, unsigned int,
+			    int setup_rpcbind,

^^^

Quoted 9 lines

Instead of adding this parameter, why not base this on the vs_hidden flag in the svc_version? IOW, have a function that looks at all the svc_versions for a particular svc_program, and returns "true" if any of them have vs_hidden unset? The mechanism you're proposing here has the potential to be out of sync with the vs_hidden flag.

Could you, please, clarify me this vs_hidden flag?
I understand, that it's used to avoid portmap registration.
But as I see, it's set only for nfs_callback_version1. But this svc_version is a part of nfs4_callback_program with nfs_callback_version4, which is not hidden. Does this flag is missed here? If not, how we can return "true" from your proposed function if any of them have vs_hidden unset?

Also sockets for this program are created with SVC_SOCK_ANONYMOUS flag and we will not register any of this program versions with portmapper. Thus, from my pow, this vs_hidden flag affects only svc_unregister. And only nfs_callback_version1. This looks really strange.

I.e. if we use this flag only for passing through this versions during svc_(un)register, and we actually also want to pass through nfs_callback_version4 as well (but just missed this vs_hidden flag for it), then with current patch-set we can move this flag from (vs_hidden) svc_version to svc_program and check it during svc_create instead of my home-brew "setup_rpcbind" variable.

Quoted 80 lines

Also, if you're adding an argument to a function like this, you you really ought to change the callers in the same patch. Otherwise you'll cause a build break if someone tries to bisect and ends up between the patch that changes the function and the one that changes the callers.

Quoted 70 lines
include/linux/sunrpc/svc.h +1 -0
  			void (*shutdown)(struct svc_serv *));
  struct svc_rqst *svc_prepare_thread(struct svc_serv *serv,
  					struct svc_pool *pool);
  void		   svc_exit_thread(struct svc_rqst *);
  struct svc_serv *  svc_create_pooled(struct svc_program *, unsigned int,
+			int setup_rpcbind,
  			void (*shutdown)(struct svc_serv *),
  			svc_thread_fn, struct module *);
  int		   svc_set_num_threads(struct svc_serv *, struct svc_pool *, int);
net/sunrpc/svc.c +14 -8
index f31e5cc..03231d5 100644
@@ -378,7 +378,7 @@ static void svc_rpcb_cleanup(struct svc_serv *serv)
   */
  static struct svc_serv *
  __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
-	     void (*shutdown)(struct svc_serv *serv))
+	     int setup_rpcbind, void (*shutdown)(struct svc_serv *serv))
  {
  	struct svc_serv	*serv;
  	unsigned int vers;
@@ -437,29 +437,36 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
  		spin_lock_init(&pool->sp_lock);
  	}
 
-	/* Remove any stale portmap registrations */
-	svc_unregister(serv);
+	if (setup_rpcbind) {
+	       	if (svc_rpcb_setup(serv)<  0) {
+			kfree(serv->sv_pools);
+			kfree(serv);
+			return NULL;
+		}
+		if (!serv->sv_shutdown)
+			serv->sv_shutdown = svc_rpcb_cleanup;
+	}
 
  	return serv;
  }
 
  struct svc_serv *
  svc_create(struct svc_program *prog, unsigned int bufsize,
-	   void (*shutdown)(struct svc_serv *serv))
+	   int setup_rpcbind, void (*shutdown)(struct svc_serv *serv))
  {
-	return __svc_create(prog, bufsize, /*npools*/1, shutdown);
+	return __svc_create(prog, bufsize, /*npools*/1, setup_rpcbind, shutdown);
  }
  EXPORT_SYMBOL_GPL(svc_create);
 
  struct svc_serv *
  svc_create_pooled(struct svc_program *prog, unsigned int bufsize,
-		  void (*shutdown)(struct svc_serv *serv),
+		  int setup_rpcbind, void (*shutdown)(struct svc_serv *serv),
  		  svc_thread_fn func, struct module *mod)
  {
  	struct svc_serv *serv;
  	unsigned int npools = svc_pool_map_get();
 
-	serv = __svc_create(prog, bufsize, npools, shutdown);
+	serv = __svc_create(prog, bufsize, npools, setup_rpcbind, shutdown);
 
  	if (serv != NULL) {
  		serv->sv_function = func;
 
--

To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Best regards,
Stanislav Kinsbursky
#7 lore raw

Re: [PATCH v3 04/11] SUNRPC: parametrize svc creation calls with portmapper flag

Quoted 50 lines · On Mon, 19 Sep 2011 18:51:31 +0400 Stanislav Kinsbursky…

19.09.2011 18:08, Jeff Layton пишет:

Quoted 27 lines
Quoted 19 lines · On Tue, 13 Sep 2011 22:13:51 +0400 Stanislav…

This new flag ("setup_rpcbind) will be used to detect, that new service will send portmapper register calls. For such services we will create rpcbind clients and remove all stale portmap registrations.
Also, svc_rpcb_cleanup() will be set as sv_shutdown callback for such services in case of this field wasn't initialized earlier. This will allow to destroy rpcbind clients when no other users of them left.

---
  include/linux/sunrpc/svc.h |    2 ++
  net/sunrpc/svc.c           |   21 ++++++++++++++-------
  2 files changed, 16 insertions(+), 7 deletions(-)
include/linux/sunrpc/svc.h +0 -0
index 223588a..528952a 100644

include/linux/sunrpc/svc.h struct svc_procedure { · line 405

Quoted 4 lines
include/linux/sunrpc/svc.h +1 -0
@@ -402,11 +402,13 @@ struct svc_procedure {
   * Function prototypes.
   */
  struct svc_serv *svc_create(struct svc_program *, unsigned int,
+			    int setup_rpcbind,

^^^

Quoted 9 lines

Instead of adding this parameter, why not base this on the vs_hidden flag in the svc_version? IOW, have a function that looks at all the svc_versions for a particular svc_program, and returns "true" if any of them have vs_hidden unset? The mechanism you're proposing here has the potential to be out of sync with the vs_hidden flag.

Could you, please, clarify me this vs_hidden flag?
I understand, that it's used to avoid portmap registration.
But as I see, it's set only for nfs_callback_version1. But this svc_version is a part of nfs4_callback_program with nfs_callback_version4, which is not hidden. Does this flag is missed here? If not, how we can return "true" from your proposed function if any of them have vs_hidden unset?

Also sockets for this program are created with SVC_SOCK_ANONYMOUS flag and we will not register any of this program versions with portmapper. Thus, from my pow, this vs_hidden flag affects only svc_unregister. And only nfs_callback_version1. This looks really strange.

Quoted 7 lines

I.e. if we use this flag only for passing through this versions during svc_(un)register, and we actually also want to pass through nfs_callback_version4 as well (but just missed this vs_hidden flag for it), then with current patch-set we can move this flag from (vs_hidden) svc_version to svc_program and check it during svc_create instead of my home-brew "setup_rpcbind" variable.

Agreed. The current situation is a mess, which is why I suggested a cleanup and overhaul before you do this...

The vs_hidden flag is intended to show that a particular program version should not be registered with (or unregistered from) the portmapper. Unfortunately, nothing looks at vs_hidden during registration time, only when unregistering (as you mention).

It's quite possible that several svc_versions declared in the kernel do not have this set correctly. One thing that would be good is to audit each of those.

We currently rely on SVC_SOCK_ANONYMOUS for registration, but that wasn't its original intent. It's was just convenient to use it there too.

SVC_SOCK_ANONYMOUS was (as best I can tell) originally intended for use on temporary sockets that we establish on receive. So for instance...when a client connects to nfsd, we need to create a new socket for nfsd, but obviously we don't want to register that socket with the portmapper (since nfsd should already be registered there). SVC_SOCK_ANONYMOUS ensures that that socket is not registered.

The whole scheme could probably use a fundamental re-think. I'm not sure I have a great idea to propose in lieu of it, but I think adding yet another flag here is probably not the best way to go.

Quoted 82 lines
Quoted 80 lines

Also, if you're adding an argument to a function like this, you you really ought to change the callers in the same patch. Otherwise you'll cause a build break if someone tries to bisect and ends up between the patch that changes the function and the one that changes the callers.

Quoted 70 lines
include/linux/sunrpc/svc.h +1 -0
  			void (*shutdown)(struct svc_serv *));
  struct svc_rqst *svc_prepare_thread(struct svc_serv *serv,
  					struct svc_pool *pool);
  void		   svc_exit_thread(struct svc_rqst *);
  struct svc_serv *  svc_create_pooled(struct svc_program *, unsigned int,
+			int setup_rpcbind,
  			void (*shutdown)(struct svc_serv *),
  			svc_thread_fn, struct module *);
  int		   svc_set_num_threads(struct svc_serv *, struct svc_pool *, int);
net/sunrpc/svc.c +14 -8
index f31e5cc..03231d5 100644
@@ -378,7 +378,7 @@ static void svc_rpcb_cleanup(struct svc_serv *serv)
   */
  static struct svc_serv *
  __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
-	     void (*shutdown)(struct svc_serv *serv))
+	     int setup_rpcbind, void (*shutdown)(struct svc_serv *serv))
  {
  	struct svc_serv	*serv;
  	unsigned int vers;
@@ -437,29 +437,36 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
  		spin_lock_init(&pool->sp_lock);
  	}
 
-	/* Remove any stale portmap registrations */
-	svc_unregister(serv);
+	if (setup_rpcbind) {
+	       	if (svc_rpcb_setup(serv)<  0) {
+			kfree(serv->sv_pools);
+			kfree(serv);
+			return NULL;
+		}
+		if (!serv->sv_shutdown)
+			serv->sv_shutdown = svc_rpcb_cleanup;
+	}
 
  	return serv;
  }
 
  struct svc_serv *
  svc_create(struct svc_program *prog, unsigned int bufsize,
-	   void (*shutdown)(struct svc_serv *serv))
+	   int setup_rpcbind, void (*shutdown)(struct svc_serv *serv))
  {
-	return __svc_create(prog, bufsize, /*npools*/1, shutdown);
+	return __svc_create(prog, bufsize, /*npools*/1, setup_rpcbind, shutdown);
  }
  EXPORT_SYMBOL_GPL(svc_create);
 
  struct svc_serv *
  svc_create_pooled(struct svc_program *prog, unsigned int bufsize,
-		  void (*shutdown)(struct svc_serv *serv),
+		  int setup_rpcbind, void (*shutdown)(struct svc_serv *serv),
  		  svc_thread_fn func, struct module *mod)
  {
  	struct svc_serv *serv;
  	unsigned int npools = svc_pool_map_get();
 
-	serv = __svc_create(prog, bufsize, npools, shutdown);
+	serv = __svc_create(prog, bufsize, npools, setup_rpcbind, shutdown);
 
  	if (serv != NULL) {
  		serv->sv_function = func;
 
--

To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 5 lines
Jeff Layton <[email protected]>
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#8 lore raw

Re: [PATCH v3 04/11] SUNRPC: parametrize svc creation calls with portmapper flag

19.09.2011 19:07, Jeff Layton пишет:

Quoted 84 lines
Quoted 50 lines · On Mon, 19 Sep 2011 18:51:31 +0400 Stanislav…

19.09.2011 18:08, Jeff Layton пишет:

Quoted 27 lines
Quoted 19 lines · On Tue, 13 Sep 2011 22:13:51 +0400 Stanislav…

This new flag ("setup_rpcbind) will be used to detect, that new service will send portmapper register calls. For such services we will create rpcbind clients and remove all stale portmap registrations.
Also, svc_rpcb_cleanup() will be set as sv_shutdown callback for such services in case of this field wasn't initialized earlier. This will allow to destroy rpcbind clients when no other users of them left.

---
   include/linux/sunrpc/svc.h |    2 ++
   net/sunrpc/svc.c           |   21 ++++++++++++++-------
   2 files changed, 16 insertions(+), 7 deletions(-)
include/linux/sunrpc/svc.h +0 -0
index 223588a..528952a 100644

include/linux/sunrpc/svc.h struct svc_procedure { · line 405

Quoted 4 lines
include/linux/sunrpc/svc.h +1 -0
@@ -402,11 +402,13 @@ struct svc_procedure {
    * Function prototypes.
    */
   struct svc_serv *svc_create(struct svc_program *, unsigned int,
+			    int setup_rpcbind,

^^^

Quoted 9 lines

Instead of adding this parameter, why not base this on the vs_hidden flag in the svc_version? IOW, have a function that looks at all the svc_versions for a particular svc_program, and returns "true" if any of them have vs_hidden unset? The mechanism you're proposing here has the potential to be out of sync with the vs_hidden flag.

Could you, please, clarify me this vs_hidden flag?
I understand, that it's used to avoid portmap registration.
But as I see, it's set only for nfs_callback_version1. But this svc_version is a part of nfs4_callback_program with nfs_callback_version4, which is not hidden. Does this flag is missed here? If not, how we can return "true" from your proposed function if any of them have vs_hidden unset?

Also sockets for this program are created with SVC_SOCK_ANONYMOUS flag and we will not register any of this program versions with portmapper. Thus, from my pow, this vs_hidden flag affects only svc_unregister. And only nfs_callback_version1. This looks really strange.

Quoted 7 lines

I.e. if we use this flag only for passing through this versions during svc_(un)register, and we actually also want to pass through nfs_callback_version4 as well (but just missed this vs_hidden flag for it), then with current patch-set we can move this flag from (vs_hidden) svc_version to svc_program and check it during svc_create instead of my home-brew "setup_rpcbind" variable.

Agreed. The current situation is a mess, which is why I suggested a cleanup and overhaul before you do this...

The vs_hidden flag is intended to show that a particular program version should not be registered with (or unregistered from) the portmapper. Unfortunately, nothing looks at vs_hidden during registration time, only when unregistering (as you mention).

It's quite possible that several svc_versions declared in the kernel do not have this set correctly. One thing that would be good is to audit each of those.

We currently rely on SVC_SOCK_ANONYMOUS for registration, but that wasn't its original intent. It's was just convenient to use it there too.

SVC_SOCK_ANONYMOUS was (as best I can tell) originally intended for use on temporary sockets that we establish on receive. So for instance...when a client connects to nfsd, we need to create a new socket for nfsd, but obviously we don't want to register that socket with the portmapper (since nfsd should already be registered there). SVC_SOCK_ANONYMOUS ensures that that socket is not registered.

Quoted 4 lines

The whole scheme could probably use a fundamental re-think. I'm not sure I have a great idea to propose in lieu of it, but I think adding yet another flag here is probably not the best way to go.

Ok, thank you, Jeff.
It looks like no mentions about portmapper are present in RFC's for NFS versions 4.* after a brief look.
This SVC_SOCK_ANONYMOUS is understandable and can't be removed with this patch-set from my pow.
But now I strongly believe, that we can move this vs_hidden flag from svc_version to svc_program structure and set it for both NFSv4.* programs. Hope, someone else will confirm of refute this statement.

Signature · 2 lines
Best regards,
Stanislav Kinsbursky
#9 lore raw

Re: [PATCH v3 04/11] SUNRPC: parametrize svc creation calls with portmapper flag

Quoted 90 lines · On Mon, 19 Sep 2011 19:42:12 +0400 Stanislav Kinsbursky…

19.09.2011 19:07, Jeff Layton пишет:

Quoted 84 lines
Quoted 50 lines · On Mon, 19 Sep 2011 18:51:31 +0400 Stanislav…

19.09.2011 18:08, Jeff Layton пишет:

Quoted 27 lines
Quoted 19 lines · On Tue, 13 Sep 2011 22:13:51 +0400 Stanislav…

This new flag ("setup_rpcbind) will be used to detect, that new service will send portmapper register calls. For such services we will create rpcbind clients and remove all stale portmap registrations.
Also, svc_rpcb_cleanup() will be set as sv_shutdown callback for such services in case of this field wasn't initialized earlier. This will allow to destroy rpcbind clients when no other users of them left.

---
   include/linux/sunrpc/svc.h |    2 ++
   net/sunrpc/svc.c           |   21 ++++++++++++++-------
   2 files changed, 16 insertions(+), 7 deletions(-)
include/linux/sunrpc/svc.h +0 -0
index 223588a..528952a 100644

include/linux/sunrpc/svc.h struct svc_procedure { · line 405

Quoted 4 lines
include/linux/sunrpc/svc.h +1 -0
@@ -402,11 +402,13 @@ struct svc_procedure {
    * Function prototypes.
    */
   struct svc_serv *svc_create(struct svc_program *, unsigned int,
+			    int setup_rpcbind,

^^^

Quoted 9 lines

Instead of adding this parameter, why not base this on the vs_hidden flag in the svc_version? IOW, have a function that looks at all the svc_versions for a particular svc_program, and returns "true" if any of them have vs_hidden unset? The mechanism you're proposing here has the potential to be out of sync with the vs_hidden flag.

Could you, please, clarify me this vs_hidden flag?
I understand, that it's used to avoid portmap registration.
But as I see, it's set only for nfs_callback_version1. But this svc_version is a part of nfs4_callback_program with nfs_callback_version4, which is not hidden. Does this flag is missed here? If not, how we can return "true" from your proposed function if any of them have vs_hidden unset?

Also sockets for this program are created with SVC_SOCK_ANONYMOUS flag and we will not register any of this program versions with portmapper. Thus, from my pow, this vs_hidden flag affects only svc_unregister. And only nfs_callback_version1. This looks really strange.

Quoted 7 lines

I.e. if we use this flag only for passing through this versions during svc_(un)register, and we actually also want to pass through nfs_callback_version4 as well (but just missed this vs_hidden flag for it), then with current patch-set we can move this flag from (vs_hidden) svc_version to svc_program and check it during svc_create instead of my home-brew "setup_rpcbind" variable.

Agreed. The current situation is a mess, which is why I suggested a cleanup and overhaul before you do this...

The vs_hidden flag is intended to show that a particular program version should not be registered with (or unregistered from) the portmapper. Unfortunately, nothing looks at vs_hidden during registration time, only when unregistering (as you mention).

It's quite possible that several svc_versions declared in the kernel do not have this set correctly. One thing that would be good is to audit each of those.

We currently rely on SVC_SOCK_ANONYMOUS for registration, but that wasn't its original intent. It's was just convenient to use it there too.

SVC_SOCK_ANONYMOUS was (as best I can tell) originally intended for use on temporary sockets that we establish on receive. So for instance...when a client connects to nfsd, we need to create a new socket for nfsd, but obviously we don't want to register that socket with the portmapper (since nfsd should already be registered there). SVC_SOCK_ANONYMOUS ensures that that socket is not registered.

Quoted 4 lines

The whole scheme could probably use a fundamental re-think. I'm not sure I have a great idea to propose in lieu of it, but I think adding yet another flag here is probably not the best way to go.

Quoted 9 lines

Ok, thank you, Jeff.
It looks like no mentions about portmapper are present in RFC's for NFS versions 4.* after a brief look.
This SVC_SOCK_ANONYMOUS is understandable and can't be removed with this patch-set from my pow.
But now I strongly believe, that we can move this vs_hidden flag from svc_version to svc_program structure and set it for both NFSv4.* programs. Hope, someone else will confirm of refute this statement.

The problem is nfsd. In principle, there's no real reason we have to register NFSv4 with the portmapper at all. One could envision a setup where a v4-only server doesn't need to run rpcbind at all. Making it per-program may hamstring you from doing that later.

It think it would be a good thing to keep it per-version, and it's trivial to write a routine to do what I've described. svc_creates only happen rarely.

Just walk the pg_vers array for the program and look at each vs_hidden value. Return true when you hit one that has vs_hidden unset. Return false if none do. Then use that return value to replace your new flag in this patch.

Signature · 5 lines
Jeff Layton <[email protected]>
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw

Re: [PATCH v3 04/11] SUNRPC: parametrize svc creation calls with portmapper flag

19.09.2011 22:11, Jeff Layton пишет:

Quoted 108 lines
Quoted 90 lines · On Mon, 19 Sep 2011 19:42:12 +0400 Stanislav…

19.09.2011 19:07, Jeff Layton пишет:

Quoted 84 lines
Quoted 50 lines · On Mon, 19 Sep 2011 18:51:31 +0400 Stanislav…

19.09.2011 18:08, Jeff Layton пишет:

Quoted 27 lines
Quoted 19 lines · On Tue, 13 Sep 2011 22:13:51 +0400 Stanislav…

This new flag ("setup_rpcbind) will be used to detect, that new service will send portmapper register calls. For such services we will create rpcbind clients and remove all stale portmap registrations.
Also, svc_rpcb_cleanup() will be set as sv_shutdown callback for such services in case of this field wasn't initialized earlier. This will allow to destroy rpcbind clients when no other users of them left.

---
    include/linux/sunrpc/svc.h |    2 ++
    net/sunrpc/svc.c           |   21 ++++++++++++++-------
    2 files changed, 16 insertions(+), 7 deletions(-)
include/linux/sunrpc/svc.h +0 -0
index 223588a..528952a 100644

include/linux/sunrpc/svc.h struct svc_procedure { · line 405

Quoted 4 lines
include/linux/sunrpc/svc.h +1 -0
@@ -402,11 +402,13 @@ struct svc_procedure {
     * Function prototypes.
     */
    struct svc_serv *svc_create(struct svc_program *, unsigned int,
+			    int setup_rpcbind,

^^^

Quoted 9 lines

Instead of adding this parameter, why not base this on the vs_hidden flag in the svc_version? IOW, have a function that looks at all the svc_versions for a particular svc_program, and returns "true" if any of them have vs_hidden unset? The mechanism you're proposing here has the potential to be out of sync with the vs_hidden flag.

Could you, please, clarify me this vs_hidden flag?
I understand, that it's used to avoid portmap registration.
But as I see, it's set only for nfs_callback_version1. But this svc_version is a part of nfs4_callback_program with nfs_callback_version4, which is not hidden. Does this flag is missed here? If not, how we can return "true" from your proposed function if any of them have vs_hidden unset?

Also sockets for this program are created with SVC_SOCK_ANONYMOUS flag and we will not register any of this program versions with portmapper. Thus, from my pow, this vs_hidden flag affects only svc_unregister. And only nfs_callback_version1. This looks really strange.

Quoted 7 lines

I.e. if we use this flag only for passing through this versions during svc_(un)register, and we actually also want to pass through nfs_callback_version4 as well (but just missed this vs_hidden flag for it), then with current patch-set we can move this flag from (vs_hidden) svc_version to svc_program and check it during svc_create instead of my home-brew "setup_rpcbind" variable.

Agreed. The current situation is a mess, which is why I suggested a cleanup and overhaul before you do this...

The vs_hidden flag is intended to show that a particular program version should not be registered with (or unregistered from) the portmapper. Unfortunately, nothing looks at vs_hidden during registration time, only when unregistering (as you mention).

It's quite possible that several svc_versions declared in the kernel do not have this set correctly. One thing that would be good is to audit each of those.

We currently rely on SVC_SOCK_ANONYMOUS for registration, but that wasn't its original intent. It's was just convenient to use it there too.

SVC_SOCK_ANONYMOUS was (as best I can tell) originally intended for use on temporary sockets that we establish on receive. So for instance...when a client connects to nfsd, we need to create a new socket for nfsd, but obviously we don't want to register that socket with the portmapper (since nfsd should already be registered there). SVC_SOCK_ANONYMOUS ensures that that socket is not registered.

Quoted 4 lines

The whole scheme could probably use a fundamental re-think. I'm not sure I have a great idea to propose in lieu of it, but I think adding yet another flag here is probably not the best way to go.

Quoted 9 lines

Ok, thank you, Jeff.
It looks like no mentions about portmapper are present in RFC's for NFS versions 4.* after a brief look.
This SVC_SOCK_ANONYMOUS is understandable and can't be removed with this patch-set from my pow.
But now I strongly believe, that we can move this vs_hidden flag from svc_version to svc_program structure and set it for both NFSv4.* programs. Hope, someone else will confirm of refute this statement.

The problem is nfsd. In principle, there's no real reason we have to register NFSv4 with the portmapper at all. One could envision a setup where a v4-only server doesn't need to run rpcbind at all. Making it per-program may hamstring you from doing that later.

Quoted 9 lines

It think it would be a good thing to keep it per-version, and it's trivial to write a routine to do what I've described. svc_creates only happen rarely.

Just walk the pg_vers array for the program and look at each vs_hidden value. Return true when you hit one that has vs_hidden unset. Return false if none do. Then use that return value to replace your new flag in this patch.

Done. I've sent v4 patch-set.

Signature · 2 lines
Best regards,
Stanislav Kinsbursky