Commit 80fc015b authored by J. Bruce Fields's avatar J. Bruce Fields

nfsd4: use common rpc_cred for all callbacks

Callbacks are always made using the machine's identity, so we can use a
single auth_generic credential shared among callbacks to all clients and
let the rpc code take care of the rest.
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
parent 29ab23cc
...@@ -432,42 +432,29 @@ static const struct rpc_call_ops nfsd4_cb_probe_ops = { ...@@ -432,42 +432,29 @@ static const struct rpc_call_ops nfsd4_cb_probe_ops = {
.rpc_call_done = nfsd4_cb_probe_done, .rpc_call_done = nfsd4_cb_probe_done,
}; };
static struct rpc_cred *lookup_cb_cred(struct nfs4_cb_conn *cb) static struct rpc_cred *callback_cred;
int set_callback_cred(void)
{ {
struct auth_cred acred = { callback_cred = rpc_lookup_machine_cred();
.machine_cred = 1 if (!callback_cred)
}; return -ENOMEM;
struct rpc_auth *auth = cb->cb_client->cl_auth; return 0;
/*
* Note in the gss case this doesn't actually have to wait for a
* gss upcall (or any calls to the client); this just creates a
* non-uptodate cred which the rpc state machine will fill in with
* a refresh_upcall later.
*/
return auth->au_ops->lookup_cred(auth, &acred, RPCAUTH_LOOKUP_NEW);
} }
void do_probe_callback(struct nfs4_client *clp) void do_probe_callback(struct nfs4_client *clp)
{ {
struct nfs4_cb_conn *cb = &clp->cl_cb_conn; struct nfs4_cb_conn *cb = &clp->cl_cb_conn;
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_NULL], .rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_NULL],
.rpc_argp = clp, .rpc_argp = clp,
.rpc_cred = callback_cred
}; };
struct rpc_cred *cred;
int status; int status;
cred = lookup_cb_cred(cb);
if (IS_ERR(cred)) {
status = PTR_ERR(cred);
goto out;
}
cb->cb_cred = cred;
msg.rpc_cred = cb->cb_cred;
status = rpc_call_async(cb->cb_client, &msg, RPC_TASK_SOFT, status = rpc_call_async(cb->cb_client, &msg, RPC_TASK_SOFT,
&nfsd4_cb_probe_ops, (void *)clp); &nfsd4_cb_probe_ops, (void *)clp);
out:
if (status) { if (status) {
warn_no_callback_path(clp, status); warn_no_callback_path(clp, status);
put_nfs4_client(clp); put_nfs4_client(clp);
...@@ -550,7 +537,7 @@ nfsd4_cb_recall(struct nfs4_delegation *dp) ...@@ -550,7 +537,7 @@ nfsd4_cb_recall(struct nfs4_delegation *dp)
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_RECALL], .rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_RECALL],
.rpc_argp = dp, .rpc_argp = dp,
.rpc_cred = clp->cl_cb_conn.cb_cred .rpc_cred = callback_cred
}; };
int status; int status;
......
...@@ -696,10 +696,6 @@ shutdown_callback_client(struct nfs4_client *clp) ...@@ -696,10 +696,6 @@ shutdown_callback_client(struct nfs4_client *clp)
clp->cl_cb_conn.cb_client = NULL; clp->cl_cb_conn.cb_client = NULL;
rpc_shutdown_client(clnt); rpc_shutdown_client(clnt);
} }
if (clp->cl_cb_conn.cb_cred) {
put_rpccred(clp->cl_cb_conn.cb_cred);
clp->cl_cb_conn.cb_cred = NULL;
}
} }
static inline void static inline void
...@@ -4020,7 +4016,7 @@ __nfs4_state_start(void) ...@@ -4020,7 +4016,7 @@ __nfs4_state_start(void)
return -ENOMEM; return -ENOMEM;
queue_delayed_work(laundry_wq, &laundromat_work, grace_time); queue_delayed_work(laundry_wq, &laundromat_work, grace_time);
set_max_delegations(); set_max_delegations();
return 0; return set_callback_cred();
} }
int int
......
...@@ -89,7 +89,6 @@ struct nfs4_cb_conn { ...@@ -89,7 +89,6 @@ struct nfs4_cb_conn {
/* RPC client info */ /* RPC client info */
atomic_t cb_set; /* successful CB_NULL call */ atomic_t cb_set; /* successful CB_NULL call */
struct rpc_clnt * cb_client; struct rpc_clnt * cb_client;
struct rpc_cred * cb_cred;
}; };
/* Maximum number of slots per session. 160 is useful for long haul TCP */ /* Maximum number of slots per session. 160 is useful for long haul TCP */
...@@ -362,6 +361,7 @@ extern int nfs4_in_grace(void); ...@@ -362,6 +361,7 @@ extern int nfs4_in_grace(void);
extern __be32 nfs4_check_open_reclaim(clientid_t *clid); extern __be32 nfs4_check_open_reclaim(clientid_t *clid);
extern void put_nfs4_client(struct nfs4_client *clp); extern void put_nfs4_client(struct nfs4_client *clp);
extern void nfs4_free_stateowner(struct kref *kref); extern void nfs4_free_stateowner(struct kref *kref);
extern int set_callback_cred(void);
extern void nfsd4_probe_callback(struct nfs4_client *clp); extern void nfsd4_probe_callback(struct nfs4_client *clp);
extern void nfsd4_cb_recall(struct nfs4_delegation *dp); extern void nfsd4_cb_recall(struct nfs4_delegation *dp);
extern void nfs4_put_delegation(struct nfs4_delegation *dp); extern void nfs4_put_delegation(struct nfs4_delegation *dp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment