• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/fs/nfs/

Lines Matching refs:delegation

2  * linux/fs/nfs/delegation.c
6 * NFS file delegation management
22 #include "delegation.h"
25 static void nfs_do_free_delegation(struct nfs_delegation *delegation)
27 kfree(delegation);
32 struct nfs_delegation *delegation = container_of(head, struct nfs_delegation, rcu);
34 nfs_do_free_delegation(delegation);
37 static void nfs_free_delegation(struct nfs_delegation *delegation)
39 if (delegation->cred) {
40 put_rpccred(delegation->cred);
41 delegation->cred = NULL;
43 call_rcu(&delegation->rcu, nfs_free_delegation_callback);
46 void nfs_mark_delegation_referenced(struct nfs_delegation *delegation)
48 set_bit(NFS_DELEGATION_REFERENCED, &delegation->flags);
53 struct nfs_delegation *delegation;
58 delegation = rcu_dereference(NFS_I(inode)->delegation);
59 if (delegation != NULL && (delegation->type & flags) == flags) {
60 nfs_mark_delegation_referenced(delegation);
126 * Set up a delegation on an inode
130 struct nfs_delegation *delegation;
134 delegation = rcu_dereference(NFS_I(inode)->delegation);
135 if (delegation != NULL) {
136 spin_lock(&delegation->lock);
137 if (delegation->inode != NULL) {
138 memcpy(delegation->stateid.data, res->delegation.data,
139 sizeof(delegation->stateid.data));
140 delegation->type = res->delegation_type;
141 delegation->maxsize = res->maxsize;
142 oldcred = delegation->cred;
143 delegation->cred = get_rpccred(cred);
145 &delegation->flags);
146 NFS_I(inode)->delegation_state = delegation->type;
147 spin_unlock(&delegation->lock);
151 /* We appear to have raced with a delegation return. */
152 spin_unlock(&delegation->lock);
161 static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation *delegation, int issync)
165 res = nfs4_proc_delegreturn(inode, delegation->cred, &delegation->stateid, issync);
166 nfs_free_delegation(delegation);
170 static struct inode *nfs_delegation_grab_inode(struct nfs_delegation *delegation)
174 spin_lock(&delegation->lock);
175 if (delegation->inode != NULL)
176 inode = igrab(delegation->inode);
177 spin_unlock(&delegation->lock);
185 struct nfs_delegation *delegation =
186 rcu_dereference_protected(nfsi->delegation,
189 if (delegation == NULL)
191 spin_lock(&delegation->lock);
192 if (stateid != NULL && memcmp(delegation->stateid.data, stateid->data,
193 sizeof(delegation->stateid.data)) != 0)
195 list_del_rcu(&delegation->super_list);
196 delegation->inode = NULL;
198 rcu_assign_pointer(nfsi->delegation, NULL);
199 spin_unlock(&delegation->lock);
200 return delegation;
202 spin_unlock(&delegation->lock);
208 * Set up a delegation on an inode
214 struct nfs_delegation *delegation, *old_delegation;
218 delegation = kmalloc(sizeof(*delegation), GFP_NOFS);
219 if (delegation == NULL)
221 memcpy(delegation->stateid.data, res->delegation.data,
222 sizeof(delegation->stateid.data));
223 delegation->type = res->delegation_type;
224 delegation->maxsize = res->maxsize;
225 delegation->change_attr = nfsi->change_attr;
226 delegation->cred = get_rpccred(cred);
227 delegation->inode = inode;
228 delegation->flags = 1<<NFS_DELEGATION_REFERENCED;
229 spin_lock_init(&delegation->lock);
232 old_delegation = rcu_dereference_protected(nfsi->delegation,
235 if (memcmp(&delegation->stateid, &old_delegation->stateid,
237 delegation->type == old_delegation->type) {
245 "a duplicate delegation!\n",
247 if (delegation->type <= old_delegation->type) {
248 freeme = delegation;
249 delegation = NULL;
254 list_add_rcu(&delegation->super_list, &clp->cl_delegations);
255 nfsi->delegation_state = delegation->type;
256 rcu_assign_pointer(nfsi->delegation, delegation);
257 delegation = NULL;
266 if (delegation != NULL)
267 nfs_free_delegation(delegation);
274 * Basic procedure for returning a delegation to the server
276 static int __nfs_inode_return_delegation(struct inode *inode, struct nfs_delegation *delegation, int issync)
286 err = nfs_delegation_claim_opens(inode, &delegation->stateid);
291 err = nfs_do_return_delegation(inode, delegation, issync);
301 struct nfs_delegation *delegation;
307 list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) {
308 if (!test_and_clear_bit(NFS_DELEGATION_RETURN, &delegation->flags))
310 inode = nfs_delegation_grab_inode(delegation);
314 delegation = nfs_detach_delegation_locked(NFS_I(inode), NULL, clp);
317 if (delegation != NULL) {
319 err = __nfs_inode_return_delegation(inode, delegation, 0);
332 * This function returns the delegation without reclaiming opens
333 * or protecting against delegation reclaims.
341 struct nfs_delegation *delegation;
343 if (rcu_access_pointer(nfsi->delegation) != NULL) {
345 delegation = nfs_detach_delegation_locked(nfsi, NULL, clp);
347 if (delegation != NULL)
348 nfs_do_return_delegation(inode, delegation, 0);
356 struct nfs_delegation *delegation;
359 if (rcu_access_pointer(nfsi->delegation) != NULL) {
361 delegation = nfs_detach_delegation_locked(nfsi, NULL, clp);
363 if (delegation != NULL) {
365 err = __nfs_inode_return_delegation(inode, delegation, 1);
371 static void nfs_mark_return_delegation(struct nfs_client *clp, struct nfs_delegation *delegation)
373 set_bit(NFS_DELEGATION_RETURN, &delegation->flags);
383 struct nfs_delegation *delegation;
388 list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) {
389 spin_lock(&delegation->lock);
390 if (delegation->inode != NULL && delegation->inode->i_sb == sb)
391 set_bit(NFS_DELEGATION_RETURN, &delegation->flags);
392 spin_unlock(&delegation->lock);
402 struct nfs_delegation *delegation;
405 list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) {
406 if ((delegation->type == (FMODE_READ|FMODE_WRITE)) && !(flags & FMODE_WRITE))
408 if (delegation->type & flags)
409 nfs_mark_return_delegation(clp, delegation);
448 struct nfs_delegation *delegation;
451 list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) {
452 if (test_and_clear_bit(NFS_DELEGATION_REFERENCED, &delegation->flags))
454 nfs_mark_return_delegation(clp, delegation);
466 * Asynchronous delegation recall!
471 struct nfs_delegation *delegation;
474 delegation = rcu_dereference(NFS_I(inode)->delegation);
476 if (!clp->cl_mvops->validate_stateid(delegation, stateid)) {
481 nfs_mark_return_delegation(clp, delegation);
488 * Retrieve the inode associated with a delegation
492 struct nfs_delegation *delegation;
495 list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) {
496 spin_lock(&delegation->lock);
497 if (delegation->inode != NULL &&
498 nfs_compare_fh(fhandle, &NFS_I(delegation->inode)->fh) == 0) {
499 res = igrab(delegation->inode);
501 spin_unlock(&delegation->lock);
514 struct nfs_delegation *delegation;
516 list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list)
517 set_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags);
526 struct nfs_delegation *delegation;
530 list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) {
531 if (test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags) == 0)
533 inode = nfs_delegation_grab_inode(delegation);
537 delegation = nfs_detach_delegation_locked(NFS_I(inode), NULL, clp);
540 if (delegation != NULL)
541 nfs_free_delegation(delegation);
551 struct nfs_delegation *delegation;
555 delegation = rcu_dereference(nfsi->delegation);
556 if (delegation != NULL) {
557 memcpy(dst->data, delegation->stateid.data, sizeof(dst->data));