NFSv4: Cache the NFSv4/v4.1 client owner_id in the struct nfs_client

Ensure that we cache the NFSv4/v4.1 client owner_id so that we can
verify it when we're doing trunking detection.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
This commit is contained in:
Trond Myklebust 2015-01-03 15:16:04 -05:00
parent 1fc0703af3
commit ceb3a16c07
3 changed files with 19 additions and 4 deletions

View file

@ -228,6 +228,7 @@ static void nfs4_shutdown_client(struct nfs_client *clp)
kfree(clp->cl_serverowner); kfree(clp->cl_serverowner);
kfree(clp->cl_serverscope); kfree(clp->cl_serverscope);
kfree(clp->cl_implid); kfree(clp->cl_implid);
kfree(clp->cl_owner_id);
} }
void nfs4_free_client(struct nfs_client *clp) void nfs4_free_client(struct nfs_client *clp)

View file

@ -4917,11 +4917,14 @@ static void nfs4_init_boot_verifier(const struct nfs_client *clp,
} }
static unsigned int static unsigned int
nfs4_init_nonuniform_client_string(const struct nfs_client *clp, nfs4_init_nonuniform_client_string(struct nfs_client *clp,
char *buf, size_t len) char *buf, size_t len)
{ {
unsigned int result; unsigned int result;
if (clp->cl_owner_id != NULL)
return strlcpy(buf, clp->cl_owner_id, len);
rcu_read_lock(); rcu_read_lock();
result = scnprintf(buf, len, "Linux NFSv4.0 %s/%s %s", result = scnprintf(buf, len, "Linux NFSv4.0 %s/%s %s",
clp->cl_ipaddr, clp->cl_ipaddr,
@ -4930,24 +4933,32 @@ nfs4_init_nonuniform_client_string(const struct nfs_client *clp,
rpc_peeraddr2str(clp->cl_rpcclient, rpc_peeraddr2str(clp->cl_rpcclient,
RPC_DISPLAY_PROTO)); RPC_DISPLAY_PROTO));
rcu_read_unlock(); rcu_read_unlock();
clp->cl_owner_id = kstrdup(buf, GFP_KERNEL);
return result; return result;
} }
static unsigned int static unsigned int
nfs4_init_uniform_client_string(const struct nfs_client *clp, nfs4_init_uniform_client_string(struct nfs_client *clp,
char *buf, size_t len) char *buf, size_t len)
{ {
const char *nodename = clp->cl_rpcclient->cl_nodename; const char *nodename = clp->cl_rpcclient->cl_nodename;
unsigned int result;
if (clp->cl_owner_id != NULL)
return strlcpy(buf, clp->cl_owner_id, len);
if (nfs4_client_id_uniquifier[0] != '\0') if (nfs4_client_id_uniquifier[0] != '\0')
return scnprintf(buf, len, "Linux NFSv%u.%u %s/%s", result = scnprintf(buf, len, "Linux NFSv%u.%u %s/%s",
clp->rpc_ops->version, clp->rpc_ops->version,
clp->cl_minorversion, clp->cl_minorversion,
nfs4_client_id_uniquifier, nfs4_client_id_uniquifier,
nodename); nodename);
return scnprintf(buf, len, "Linux NFSv%u.%u %s", else
result = scnprintf(buf, len, "Linux NFSv%u.%u %s",
clp->rpc_ops->version, clp->cl_minorversion, clp->rpc_ops->version, clp->cl_minorversion,
nodename); nodename);
clp->cl_owner_id = kstrdup(buf, GFP_KERNEL);
return result;
} }
/* /*

View file

@ -74,6 +74,9 @@ struct nfs_client {
/* idmapper */ /* idmapper */
struct idmap * cl_idmap; struct idmap * cl_idmap;
/* Client owner identifier */
const char * cl_owner_id;
/* Our own IP address, as a null-terminated string. /* Our own IP address, as a null-terminated string.
* This is used to generate the mv0 callback address. * This is used to generate the mv0 callback address.
*/ */