aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2012-03-04 18:13:56 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-03-06 10:32:44 -0500
commit36281caa839f4441c793c81d2e3cc5ea44ad5aa2 (patch)
treebe5471741713d77681fcf1e161b0748343748977 /fs/nfs
parent8e663f0e5fabf57065aed1cfdaff5b13057dce23 (diff)
NFSv4: Further clean-ups of delegation stateid validation
Change the name to reflect what we're really doing: testing two stateids for whether or not they match according the the rules in RFC3530 and RFC5661. Move the code from callback_proc.c to nfs4proc.c Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/callback_proc.c24
-rw-r--r--fs/nfs/delegation.c2
-rw-r--r--fs/nfs/nfs4_fs.h2
-rw-r--r--fs/nfs/nfs4proc.c27
4 files changed, 27 insertions, 28 deletions
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index ea8321923f28..1b5d809a105e 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -98,14 +98,6 @@ out:
98 return res; 98 return res;
99} 99}
100 100
101int nfs4_validate_delegation_stateid(struct nfs_delegation *delegation, const nfs4_stateid *stateid)
102{
103 if (delegation == NULL || memcmp(delegation->stateid.data, stateid->data,
104 sizeof(delegation->stateid.data)) != 0)
105 return 0;
106 return 1;
107}
108
109#if defined(CONFIG_NFS_V4_1) 101#if defined(CONFIG_NFS_V4_1)
110 102
111/* 103/*
@@ -319,22 +311,6 @@ out:
319 return res; 311 return res;
320} 312}
321 313
322int nfs41_validate_delegation_stateid(struct nfs_delegation *delegation, const nfs4_stateid *stateid)
323{
324 if (delegation == NULL)
325 return 0;
326
327 if (stateid->stateid.seqid != 0 &&
328 stateid->stateid.seqid != delegation->stateid.stateid.seqid)
329 return 0;
330 if (memcmp(delegation->stateid.stateid.other,
331 stateid->stateid.other,
332 NFS4_STATEID_OTHER_SIZE))
333 return 0;
334
335 return 1;
336}
337
338/* 314/*
339 * Validate the sequenceID sent by the server. 315 * Validate the sequenceID sent by the server.
340 * Return success if the sequenceID is one more than what we last saw on 316 * Return success if the sequenceID is one more than what we last saw on
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index c14512cea798..c7249e26e2e9 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -556,7 +556,7 @@ int nfs_async_inode_return_delegation(struct inode *inode,
556 rcu_read_lock(); 556 rcu_read_lock();
557 delegation = rcu_dereference(NFS_I(inode)->delegation); 557 delegation = rcu_dereference(NFS_I(inode)->delegation);
558 558
559 if (!clp->cl_mvops->validate_stateid(delegation, stateid)) { 559 if (!clp->cl_mvops->match_stateid(&delegation->stateid, stateid)) {
560 rcu_read_unlock(); 560 rcu_read_unlock();
561 return -ENOENT; 561 return -ENOENT;
562 } 562 }
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 7ddad3fa4074..624d4becf017 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -43,7 +43,7 @@ struct nfs4_minor_version_ops {
43 struct nfs4_sequence_args *args, 43 struct nfs4_sequence_args *args,
44 struct nfs4_sequence_res *res, 44 struct nfs4_sequence_res *res,
45 int cache_reply); 45 int cache_reply);
46 int (*validate_stateid)(struct nfs_delegation *, 46 bool (*match_stateid)(const nfs4_stateid *,
47 const nfs4_stateid *); 47 const nfs4_stateid *);
48 int (*find_root_sec)(struct nfs_server *, struct nfs_fh *, 48 int (*find_root_sec)(struct nfs_server *, struct nfs_fh *,
49 struct nfs_fsinfo *); 49 struct nfs_fsinfo *);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index f31fcea1af7e..b0647b387403 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -6271,8 +6271,31 @@ static int nfs41_free_stateid(struct nfs_server *server, nfs4_stateid *stateid)
6271 } while (exception.retry); 6271 } while (exception.retry);
6272 return err; 6272 return err;
6273} 6273}
6274
6275static bool nfs41_match_stateid(const nfs4_stateid *s1,
6276 const nfs4_stateid *s2)
6277{
6278 if (memcmp(s1->stateid.other, s2->stateid.other,
6279 sizeof(s1->stateid.other)) != 0)
6280 return false;
6281
6282 if (s1->stateid.seqid == s2->stateid.seqid)
6283 return true;
6284 if (s1->stateid.seqid == 0 || s2->stateid.seqid == 0)
6285 return true;
6286
6287 return false;
6288}
6289
6274#endif /* CONFIG_NFS_V4_1 */ 6290#endif /* CONFIG_NFS_V4_1 */
6275 6291
6292static bool nfs4_match_stateid(const nfs4_stateid *s1,
6293 const nfs4_stateid *s2)
6294{
6295 return memcmp(s1->data, s2->data, sizeof(s1->data)) == 0;
6296}
6297
6298
6276struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops = { 6299struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops = {
6277 .owner_flag_bit = NFS_OWNER_RECLAIM_REBOOT, 6300 .owner_flag_bit = NFS_OWNER_RECLAIM_REBOOT,
6278 .state_flag_bit = NFS_STATE_RECLAIM_REBOOT, 6301 .state_flag_bit = NFS_STATE_RECLAIM_REBOOT,
@@ -6331,7 +6354,7 @@ struct nfs4_state_maintenance_ops nfs41_state_renewal_ops = {
6331static const struct nfs4_minor_version_ops nfs_v4_0_minor_ops = { 6354static const struct nfs4_minor_version_ops nfs_v4_0_minor_ops = {
6332 .minor_version = 0, 6355 .minor_version = 0,
6333 .call_sync = _nfs4_call_sync, 6356 .call_sync = _nfs4_call_sync,
6334 .validate_stateid = nfs4_validate_delegation_stateid, 6357 .match_stateid = nfs4_match_stateid,
6335 .find_root_sec = nfs4_find_root_sec, 6358 .find_root_sec = nfs4_find_root_sec,
6336 .reboot_recovery_ops = &nfs40_reboot_recovery_ops, 6359 .reboot_recovery_ops = &nfs40_reboot_recovery_ops,
6337 .nograce_recovery_ops = &nfs40_nograce_recovery_ops, 6360 .nograce_recovery_ops = &nfs40_nograce_recovery_ops,
@@ -6342,7 +6365,7 @@ static const struct nfs4_minor_version_ops nfs_v4_0_minor_ops = {
6342static const struct nfs4_minor_version_ops nfs_v4_1_minor_ops = { 6365static const struct nfs4_minor_version_ops nfs_v4_1_minor_ops = {
6343 .minor_version = 1, 6366 .minor_version = 1,
6344 .call_sync = _nfs4_call_sync_session, 6367 .call_sync = _nfs4_call_sync_session,
6345 .validate_stateid = nfs41_validate_delegation_stateid, 6368 .match_stateid = nfs41_match_stateid,
6346 .find_root_sec = nfs41_find_root_sec, 6369 .find_root_sec = nfs41_find_root_sec,
6347 .reboot_recovery_ops = &nfs41_reboot_recovery_ops, 6370 .reboot_recovery_ops = &nfs41_reboot_recovery_ops,
6348 .nograce_recovery_ops = &nfs41_nograce_recovery_ops, 6371 .nograce_recovery_ops = &nfs41_nograce_recovery_ops,