diff options
author | J. Bruce Fields <bfields@redhat.com> | 2012-05-19 13:55:22 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-05-31 20:30:07 -0400 |
commit | 90d700b7792a1a7d57554620796df46246e26ce6 (patch) | |
tree | aaea6476800b50552166505938932cd9dc98e93c /fs/nfsd | |
parent | f3d03b9202e4303f0e687f93ffeab87724f6dcfb (diff) |
nfsd4: simpler ordering of setclientid_confirm checks
The cases here divide into two main categories:
- if there's an uncomfirmed record with a matching verifier,
then this is a "normal", succesful case: we're either creating
a new client, or updating an existing one.
- otherwise, this is a weird case: a replay, or a server reboot.
Reordering to reflect that makes the code a bit more concise and the
logic a lot easier to understand.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfs4state.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index e42b5670ddee..991a8a7414f7 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -2245,18 +2245,21 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp, | |||
2245 | if (conf && !same_creds(&conf->cl_cred, &rqstp->rq_cred)) | 2245 | if (conf && !same_creds(&conf->cl_cred, &rqstp->rq_cred)) |
2246 | goto out; | 2246 | goto out; |
2247 | /* cases below refer to rfc 3530 section 14.2.34: */ | 2247 | /* cases below refer to rfc 3530 section 14.2.34: */ |
2248 | if (conf && unconf && same_verf(&confirm, &unconf->cl_confirm)) { | 2248 | if (!unconf || !same_verf(&confirm, &unconf->cl_confirm)) { |
2249 | /* case 1: callback update */ | 2249 | if (conf && !unconf) /* case 2: probable retransmit */ |
2250 | status = nfs_ok; | ||
2251 | else /* case 4: client hasn't noticed we rebooted yet? */ | ||
2252 | status = nfserr_stale_clientid; | ||
2253 | goto out; | ||
2254 | } | ||
2255 | status = nfs_ok; | ||
2256 | if (conf) { /* case 1: callback update */ | ||
2250 | nfsd4_change_callback(conf, &unconf->cl_cb_conn); | 2257 | nfsd4_change_callback(conf, &unconf->cl_cb_conn); |
2251 | nfsd4_probe_callback(conf); | 2258 | nfsd4_probe_callback(conf); |
2252 | expire_client(unconf); | 2259 | expire_client(unconf); |
2253 | status = nfs_ok; | 2260 | } else { /* case 3: normal case; new or rebooted client */ |
2254 | } else if (conf && !unconf) { | ||
2255 | status = nfs_ok; | ||
2256 | } else if (!conf && unconf | ||
2257 | && same_verf(&unconf->cl_confirm, &confirm)) { | ||
2258 | /* case 3: normal case; new or rebooted client */ | ||
2259 | unsigned int hash = clientstr_hashval(unconf->cl_recdir); | 2261 | unsigned int hash = clientstr_hashval(unconf->cl_recdir); |
2262 | |||
2260 | conf = find_confirmed_client_by_str(unconf->cl_recdir, hash); | 2263 | conf = find_confirmed_client_by_str(unconf->cl_recdir, hash); |
2261 | if (conf) { | 2264 | if (conf) { |
2262 | nfsd4_client_record_remove(conf); | 2265 | nfsd4_client_record_remove(conf); |
@@ -2264,11 +2267,6 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp, | |||
2264 | } | 2267 | } |
2265 | move_to_confirmed(unconf); | 2268 | move_to_confirmed(unconf); |
2266 | nfsd4_probe_callback(unconf); | 2269 | nfsd4_probe_callback(unconf); |
2267 | status = nfs_ok; | ||
2268 | } else if ((!conf || !same_verf(&conf->cl_confirm, &confirm)) | ||
2269 | && (!unconf || !same_verf(&unconf->cl_confirm, &confirm))) { | ||
2270 | /* case 4: client hasn't noticed we rebooted yet? */ | ||
2271 | status = nfserr_stale_clientid; | ||
2272 | } | 2270 | } |
2273 | out: | 2271 | out: |
2274 | nfs4_unlock_state(); | 2272 | nfs4_unlock_state(); |