diff options
author | Andy Adamson <andros@netapp.com> | 2009-04-01 09:22:30 -0400 |
---|---|---|
committer | Benny Halevy <bhalevy@panasas.com> | 2009-06-17 15:24:32 -0400 |
commit | 2050f0cc0703aab7cee798b3cb47037754f368bc (patch) | |
tree | 48a54e68af8e6fe9b72994013aeecbd812e0e4ea /fs/nfs/nfs4proc.c | |
parent | 99fe60d062cfecf382c036065b3278b82b6c5eff (diff) |
nfs41: get_lease_time
get_lease_time uses the FSINFO rpc operation to
get the lease time attribute.
nfs4_get_lease_time() is only called from the state manager on session setup
so don't recover from clientid or sequence level errors.
We do need to recover from NFS4ERR_DELAY or NFS4ERR_GRACE.
Use NFS4_POLL_RETRY_MIN - the Linux server returns NFS4ERR_DELAY when an
upcall is needed to resolve an uncached export referenced by a file handle.
[nfs41: sequence res use slotid]
Signed-off-by: Andy Adamson<andros@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[nfs41: remove extraneous rpc_clnt pointer]
Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[nfs41: have get_lease_time work on nfs_client]
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[nfs41: get_lease_time recover from NFS4ERR_DELAY]
Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[nfs41: pass *session in seq_args and seq_res]
[define nfs4_get_lease_time_{args,res}]
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4proc.c')
-rw-r--r-- | fs/nfs/nfs4proc.c | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 6f384e290753..eafc99afd356 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -4189,6 +4189,100 @@ static int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred) | |||
4189 | return status; | 4189 | return status; |
4190 | } | 4190 | } |
4191 | 4191 | ||
4192 | struct nfs4_get_lease_time_data { | ||
4193 | struct nfs4_get_lease_time_args *args; | ||
4194 | struct nfs4_get_lease_time_res *res; | ||
4195 | struct nfs_client *clp; | ||
4196 | }; | ||
4197 | |||
4198 | static void nfs4_get_lease_time_prepare(struct rpc_task *task, | ||
4199 | void *calldata) | ||
4200 | { | ||
4201 | int ret; | ||
4202 | struct nfs4_get_lease_time_data *data = | ||
4203 | (struct nfs4_get_lease_time_data *)calldata; | ||
4204 | |||
4205 | dprintk("--> %s\n", __func__); | ||
4206 | /* just setup sequence, do not trigger session recovery | ||
4207 | since we're invoked within one */ | ||
4208 | ret = nfs41_setup_sequence(data->clp->cl_session, | ||
4209 | &data->args->la_seq_args, | ||
4210 | &data->res->lr_seq_res, 0, task); | ||
4211 | |||
4212 | BUG_ON(ret == -EAGAIN); | ||
4213 | rpc_call_start(task); | ||
4214 | dprintk("<-- %s\n", __func__); | ||
4215 | } | ||
4216 | |||
4217 | /* | ||
4218 | * Called from nfs4_state_manager thread for session setup, so don't recover | ||
4219 | * from sequence operation or clientid errors. | ||
4220 | */ | ||
4221 | static void nfs4_get_lease_time_done(struct rpc_task *task, void *calldata) | ||
4222 | { | ||
4223 | struct nfs4_get_lease_time_data *data = | ||
4224 | (struct nfs4_get_lease_time_data *)calldata; | ||
4225 | |||
4226 | dprintk("--> %s\n", __func__); | ||
4227 | nfs41_sequence_done(data->clp, &data->res->lr_seq_res, task->tk_status); | ||
4228 | switch (task->tk_status) { | ||
4229 | case -NFS4ERR_DELAY: | ||
4230 | case -NFS4ERR_GRACE: | ||
4231 | dprintk("%s Retry: tk_status %d\n", __func__, task->tk_status); | ||
4232 | rpc_delay(task, NFS4_POLL_RETRY_MIN); | ||
4233 | task->tk_status = 0; | ||
4234 | rpc_restart_call(task); | ||
4235 | return; | ||
4236 | } | ||
4237 | nfs41_sequence_free_slot(data->clp, &data->res->lr_seq_res); | ||
4238 | dprintk("<-- %s\n", __func__); | ||
4239 | } | ||
4240 | |||
4241 | struct rpc_call_ops nfs4_get_lease_time_ops = { | ||
4242 | .rpc_call_prepare = nfs4_get_lease_time_prepare, | ||
4243 | .rpc_call_done = nfs4_get_lease_time_done, | ||
4244 | }; | ||
4245 | |||
4246 | int nfs4_proc_get_lease_time(struct nfs_client *clp, struct nfs_fsinfo *fsinfo) | ||
4247 | { | ||
4248 | struct rpc_task *task; | ||
4249 | struct nfs4_get_lease_time_args args; | ||
4250 | struct nfs4_get_lease_time_res res = { | ||
4251 | .lr_fsinfo = fsinfo, | ||
4252 | }; | ||
4253 | struct nfs4_get_lease_time_data data = { | ||
4254 | .args = &args, | ||
4255 | .res = &res, | ||
4256 | .clp = clp, | ||
4257 | }; | ||
4258 | struct rpc_message msg = { | ||
4259 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_GET_LEASE_TIME], | ||
4260 | .rpc_argp = &args, | ||
4261 | .rpc_resp = &res, | ||
4262 | }; | ||
4263 | struct rpc_task_setup task_setup = { | ||
4264 | .rpc_client = clp->cl_rpcclient, | ||
4265 | .rpc_message = &msg, | ||
4266 | .callback_ops = &nfs4_get_lease_time_ops, | ||
4267 | .callback_data = &data | ||
4268 | }; | ||
4269 | int status; | ||
4270 | |||
4271 | res.lr_seq_res.sr_slotid = NFS4_MAX_SLOT_TABLE; | ||
4272 | dprintk("--> %s\n", __func__); | ||
4273 | task = rpc_run_task(&task_setup); | ||
4274 | |||
4275 | if (IS_ERR(task)) | ||
4276 | status = PTR_ERR(task); | ||
4277 | else { | ||
4278 | status = task->tk_status; | ||
4279 | rpc_put_task(task); | ||
4280 | } | ||
4281 | dprintk("<-- %s return %d\n", __func__, status); | ||
4282 | |||
4283 | return status; | ||
4284 | } | ||
4285 | |||
4192 | /* Destroy the slot table */ | 4286 | /* Destroy the slot table */ |
4193 | static void nfs4_destroy_slot_table(struct nfs4_session *session) | 4287 | static void nfs4_destroy_slot_table(struct nfs4_session *session) |
4194 | { | 4288 | { |