Skip to content

Commit

Permalink
nfsd: make client/ directory names small ints
Browse files Browse the repository at this point in the history
We want clientid's on the wire to be randomized for reasons explained in
ebd7c72 "nfsd: randomize SETCLIENTID reply to help distinguish
servers".  But I'd rather have mostly small integers for the clients/
directory.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
  • Loading branch information
J. Bruce Fields committed Jul 3, 2019
1 parent e8a79fb commit bf5ed3e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions fs/nfsd/netns.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ struct nfsd_net {
*/
unsigned int max_connections;

u32 clientid_base;
u32 clientid_counter;
u32 clverifier_counter;

Expand Down
2 changes: 1 addition & 1 deletion fs/nfsd/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -2242,7 +2242,7 @@ static struct nfs4_client *create_client(struct xdr_netobj name,
clp->cl_cb_session = NULL;
clp->net = net;
clp->cl_nfsd_dentry = nfsd_client_mkdir(nn, &clp->cl_nfsdfs,
clp->cl_clientid.cl_id);
clp->cl_clientid.cl_id - nn->clientid_base);
if (!clp->cl_nfsd_dentry) {
free_client(clp);
return NULL;
Expand Down
5 changes: 3 additions & 2 deletions fs/nfsd/nfsctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ struct dentry *nfsd_client_mkdir(struct nfsd_net *nn, struct nfsdfs_client *ncl,
{
char name[11];

sprintf(name, "%d", id++);
sprintf(name, "%u", id);

return nfsd_mkdir(nn->nfsd_client_dir, ncl, name);
}
Expand Down Expand Up @@ -1352,7 +1352,8 @@ static __net_init int nfsd_init_net(struct net *net)
nn->somebody_reclaimed = false;
nn->track_reclaim_completes = false;
nn->clverifier_counter = prandom_u32();
nn->clientid_counter = prandom_u32();
nn->clientid_base = prandom_u32();
nn->clientid_counter = nn->clientid_base + 1;
nn->s2s_cp_cl_id = nn->clientid_counter++;

atomic_set(&nn->ntf_refcnt, 0);
Expand Down

0 comments on commit bf5ed3e

Please sign in to comment.