summaryrefslogtreecommitdiff
path: root/fs/nfsd
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2019-03-14 16:20:19 -0400
committerJ. Bruce Fields <bfields@redhat.com>2019-07-03 17:52:50 -0400
commitbf5ed3e3bb84c39d70ad10b2f8e47ec62f4c63b1 (patch)
tree5d6020fc70f39343c50ded4f575cb905c50db922 /fs/nfsd
parente8a79fb14f6b76b502218fce10696f4df9ff19b1 (diff)
nfsd: make client/ directory names small ints
We want clientid's on the wire to be randomized for reasons explained in ebd7c72c63ac "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>
Diffstat (limited to 'fs/nfsd')
-rw-r--r--fs/nfsd/netns.h1
-rw-r--r--fs/nfsd/nfs4state.c2
-rw-r--r--fs/nfsd/nfsctl.c5
3 files changed, 5 insertions, 3 deletions
diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h
index ad1d74383d67..bdfe5bcb3dcd 100644
--- a/fs/nfsd/netns.h
+++ b/fs/nfsd/netns.h
@@ -111,6 +111,7 @@ struct nfsd_net {
*/
unsigned int max_connections;
+ u32 clientid_base;
u32 clientid_counter;
u32 clverifier_counter;
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 7d8d1fcc8831..8f9747d84525 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -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;
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 5a1920a2de27..599d600f0658 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -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);
}
@@ -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);