Skip to content

Commit

Permalink
nfsd: set the server_scope during service startup
Browse files Browse the repository at this point in the history
Currently, nfsd4_encode_exchange_id() encodes the utsname nodename
string in the server_scope field.  In a multi-host container
environemnt, if an nfsd container is restarted on a different host than
it was originally running on, clients will see a server_scope mismatch
and will not attempt to reclaim opens.

Instead, set the server_scope while we're in a process context during
service startup, so we get the utsname nodename of the current process
and store that in nfsd_net.

Signed-off-by: Scott Mayhew <[email protected]>
[bfields: fix up major_id too]
Signed-off-by: J. Bruce Fields <[email protected]>
Signed-off-by: Chuck Lever <[email protected]>
  • Loading branch information
scottmayhew authored and chucklever committed Mar 16, 2020
1 parent fb33c65 commit 7627d7d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions fs/nfsd/netns.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ struct nfsd_net {
unsigned int longest_chain_cachesize;

struct shrinker nfsd_reply_cache_shrinker;
/* utsname taken from the the process that starts the server */
char nfsd_name[UNX_MAXNODENAME+1];
};

/* Simple check to find out if a given net was properly initialized */
Expand Down
9 changes: 5 additions & 4 deletions fs/nfsd/nfs4xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -4005,11 +4005,12 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr,
int major_id_sz;
int server_scope_sz;
uint64_t minor_id = 0;
struct nfsd_net *nn = net_generic(SVC_NET(resp->rqstp), nfsd_net_id);

major_id = utsname()->nodename;
major_id_sz = strlen(major_id);
server_scope = utsname()->nodename;
server_scope_sz = strlen(server_scope);
major_id = nn->nfsd_name;
major_id_sz = strlen(nn->nfsd_name);
server_scope = nn->nfsd_name;
server_scope_sz = strlen(nn->nfsd_name);

p = xdr_reserve_space(xdr,
8 /* eir_clientid */ +
Expand Down
3 changes: 3 additions & 0 deletions fs/nfsd/nfssvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,9 @@ nfsd_svc(int nrservs, struct net *net, const struct cred *cred)
if (nrservs == 0 && nn->nfsd_serv == NULL)
goto out;

strlcpy(nn->nfsd_name, utsname()->nodename,
sizeof(nn->nfsd_name));

error = nfsd_create_serv(net);
if (error)
goto out;
Expand Down

0 comments on commit 7627d7d

Please sign in to comment.