Lines Matching refs:delegation
25 static void nfs_free_delegation(struct nfs_delegation *delegation) in nfs_free_delegation() argument
27 if (delegation->cred) { in nfs_free_delegation()
28 put_rpccred(delegation->cred); in nfs_free_delegation()
29 delegation->cred = NULL; in nfs_free_delegation()
31 kfree_rcu(delegation, rcu); in nfs_free_delegation()
39 void nfs_mark_delegation_referenced(struct nfs_delegation *delegation) in nfs_mark_delegation_referenced() argument
41 set_bit(NFS_DELEGATION_REFERENCED, &delegation->flags); in nfs_mark_delegation_referenced()
47 struct nfs_delegation *delegation; in nfs4_do_check_delegation() local
52 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs4_do_check_delegation()
53 if (delegation != NULL && (delegation->type & flags) == flags && in nfs4_do_check_delegation()
54 !test_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) { in nfs4_do_check_delegation()
56 nfs_mark_delegation_referenced(delegation); in nfs4_do_check_delegation()
168 struct nfs_delegation *delegation; in nfs_inode_reclaim_delegation() local
172 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs_inode_reclaim_delegation()
173 if (delegation != NULL) { in nfs_inode_reclaim_delegation()
174 spin_lock(&delegation->lock); in nfs_inode_reclaim_delegation()
175 if (delegation->inode != NULL) { in nfs_inode_reclaim_delegation()
176 nfs4_stateid_copy(&delegation->stateid, &res->delegation); in nfs_inode_reclaim_delegation()
177 delegation->type = res->delegation_type; in nfs_inode_reclaim_delegation()
178 delegation->maxsize = res->maxsize; in nfs_inode_reclaim_delegation()
179 oldcred = delegation->cred; in nfs_inode_reclaim_delegation()
180 delegation->cred = get_rpccred(cred); in nfs_inode_reclaim_delegation()
182 &delegation->flags); in nfs_inode_reclaim_delegation()
183 spin_unlock(&delegation->lock); in nfs_inode_reclaim_delegation()
189 spin_unlock(&delegation->lock); in nfs_inode_reclaim_delegation()
198 static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation *delegation, int iss… in nfs_do_return_delegation() argument
202 if (!test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) in nfs_do_return_delegation()
204 delegation->cred, in nfs_do_return_delegation()
205 &delegation->stateid, in nfs_do_return_delegation()
207 nfs_free_delegation(delegation); in nfs_do_return_delegation()
211 static struct inode *nfs_delegation_grab_inode(struct nfs_delegation *delegation) in nfs_delegation_grab_inode() argument
215 spin_lock(&delegation->lock); in nfs_delegation_grab_inode()
216 if (delegation->inode != NULL) in nfs_delegation_grab_inode()
217 inode = igrab(delegation->inode); in nfs_delegation_grab_inode()
218 spin_unlock(&delegation->lock); in nfs_delegation_grab_inode()
226 struct nfs_delegation *delegation = rcu_dereference(nfsi->delegation); in nfs_start_delegation_return_locked() local
228 if (delegation == NULL) in nfs_start_delegation_return_locked()
230 spin_lock(&delegation->lock); in nfs_start_delegation_return_locked()
231 if (!test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) in nfs_start_delegation_return_locked()
232 ret = delegation; in nfs_start_delegation_return_locked()
233 spin_unlock(&delegation->lock); in nfs_start_delegation_return_locked()
241 struct nfs_delegation *delegation; in nfs_start_delegation_return() local
244 delegation = nfs_start_delegation_return_locked(nfsi); in nfs_start_delegation_return()
246 return delegation; in nfs_start_delegation_return()
250 nfs_abort_delegation_return(struct nfs_delegation *delegation, in nfs_abort_delegation_return() argument
254 spin_lock(&delegation->lock); in nfs_abort_delegation_return()
255 clear_bit(NFS_DELEGATION_RETURNING, &delegation->flags); in nfs_abort_delegation_return()
256 set_bit(NFS_DELEGATION_RETURN, &delegation->flags); in nfs_abort_delegation_return()
257 spin_unlock(&delegation->lock); in nfs_abort_delegation_return()
263 struct nfs_delegation *delegation, in nfs_detach_delegation_locked() argument
267 rcu_dereference_protected(nfsi->delegation, in nfs_detach_delegation_locked()
270 if (deleg_cur == NULL || delegation != deleg_cur) in nfs_detach_delegation_locked()
273 spin_lock(&delegation->lock); in nfs_detach_delegation_locked()
274 set_bit(NFS_DELEGATION_RETURNING, &delegation->flags); in nfs_detach_delegation_locked()
275 list_del_rcu(&delegation->super_list); in nfs_detach_delegation_locked()
276 delegation->inode = NULL; in nfs_detach_delegation_locked()
277 rcu_assign_pointer(nfsi->delegation, NULL); in nfs_detach_delegation_locked()
278 spin_unlock(&delegation->lock); in nfs_detach_delegation_locked()
279 return delegation; in nfs_detach_delegation_locked()
283 struct nfs_delegation *delegation, in nfs_detach_delegation() argument
289 delegation = nfs_detach_delegation_locked(nfsi, delegation, clp); in nfs_detach_delegation()
291 return delegation; in nfs_detach_delegation()
299 struct nfs_delegation *delegation; in nfs_inode_detach_delegation() local
301 delegation = nfs_start_delegation_return(nfsi); in nfs_inode_detach_delegation()
302 if (delegation == NULL) in nfs_inode_detach_delegation()
304 return nfs_detach_delegation(nfsi, delegation, server); in nfs_inode_detach_delegation()
308 nfs_update_inplace_delegation(struct nfs_delegation *delegation, in nfs_update_inplace_delegation() argument
311 if (nfs4_stateid_is_newer(&update->stateid, &delegation->stateid)) { in nfs_update_inplace_delegation()
312 delegation->stateid.seqid = update->stateid.seqid; in nfs_update_inplace_delegation()
314 delegation->type = update->type; in nfs_update_inplace_delegation()
331 struct nfs_delegation *delegation, *old_delegation; in nfs_inode_set_delegation() local
335 delegation = kmalloc(sizeof(*delegation), GFP_NOFS); in nfs_inode_set_delegation()
336 if (delegation == NULL) in nfs_inode_set_delegation()
338 nfs4_stateid_copy(&delegation->stateid, &res->delegation); in nfs_inode_set_delegation()
339 delegation->type = res->delegation_type; in nfs_inode_set_delegation()
340 delegation->maxsize = res->maxsize; in nfs_inode_set_delegation()
341 delegation->change_attr = inode->i_version; in nfs_inode_set_delegation()
342 delegation->cred = get_rpccred(cred); in nfs_inode_set_delegation()
343 delegation->inode = inode; in nfs_inode_set_delegation()
344 delegation->flags = 1<<NFS_DELEGATION_REFERENCED; in nfs_inode_set_delegation()
345 spin_lock_init(&delegation->lock); in nfs_inode_set_delegation()
348 old_delegation = rcu_dereference_protected(nfsi->delegation, in nfs_inode_set_delegation()
353 &delegation->stateid)) { in nfs_inode_set_delegation()
355 delegation); in nfs_inode_set_delegation()
367 if (delegation->type == old_delegation->type || in nfs_inode_set_delegation()
368 !(delegation->type & FMODE_WRITE)) { in nfs_inode_set_delegation()
369 freeme = delegation; in nfs_inode_set_delegation()
370 delegation = NULL; in nfs_inode_set_delegation()
381 list_add_tail_rcu(&delegation->super_list, &server->delegations); in nfs_inode_set_delegation()
382 rcu_assign_pointer(nfsi->delegation, delegation); in nfs_inode_set_delegation()
383 delegation = NULL; in nfs_inode_set_delegation()
393 if (delegation != NULL) in nfs_inode_set_delegation()
394 nfs_free_delegation(delegation); in nfs_inode_set_delegation()
403 static int nfs_end_delegation_return(struct inode *inode, struct nfs_delegation *delegation, int is… in nfs_end_delegation_return() argument
409 if (delegation == NULL) in nfs_end_delegation_return()
412 if (test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) in nfs_end_delegation_return()
414 err = nfs_delegation_claim_opens(inode, &delegation->stateid); in nfs_end_delegation_return()
424 nfs_abort_delegation_return(delegation, clp); in nfs_end_delegation_return()
427 if (!nfs_detach_delegation(nfsi, delegation, NFS_SERVER(inode))) in nfs_end_delegation_return()
430 err = nfs_do_return_delegation(inode, delegation, issync); in nfs_end_delegation_return()
435 static bool nfs_delegation_need_return(struct nfs_delegation *delegation) in nfs_delegation_need_return() argument
439 if (test_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) in nfs_delegation_need_return()
441 if (test_and_clear_bit(NFS_DELEGATION_RETURN, &delegation->flags)) in nfs_delegation_need_return()
443 if (test_and_clear_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags) && !ret) { in nfs_delegation_need_return()
446 spin_lock(&delegation->lock); in nfs_delegation_need_return()
447 inode = delegation->inode; in nfs_delegation_need_return()
450 spin_unlock(&delegation->lock); in nfs_delegation_need_return()
468 struct nfs_delegation *delegation; in nfs_client_return_marked_delegations() local
476 list_for_each_entry_rcu(delegation, &server->delegations, in nfs_client_return_marked_delegations()
478 if (!nfs_delegation_need_return(delegation)) in nfs_client_return_marked_delegations()
482 inode = nfs_delegation_grab_inode(delegation); in nfs_client_return_marked_delegations()
488 delegation = nfs_start_delegation_return_locked(NFS_I(inode)); in nfs_client_return_marked_delegations()
491 err = nfs_end_delegation_return(inode, delegation, 0); in nfs_client_return_marked_delegations()
513 struct nfs_delegation *delegation; in nfs_inode_return_delegation_noreclaim() local
515 delegation = nfs_inode_detach_delegation(inode); in nfs_inode_return_delegation_noreclaim()
516 if (delegation != NULL) in nfs_inode_return_delegation_noreclaim()
517 nfs_do_return_delegation(inode, delegation, 1); in nfs_inode_return_delegation_noreclaim()
533 struct nfs_delegation *delegation; in nfs4_inode_return_delegation() local
537 delegation = nfs_start_delegation_return(nfsi); in nfs4_inode_return_delegation()
538 if (delegation != NULL) in nfs4_inode_return_delegation()
539 err = nfs_end_delegation_return(inode, delegation, 1); in nfs4_inode_return_delegation()
544 struct nfs_delegation *delegation) in nfs_mark_return_if_closed_delegation() argument
546 set_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags); in nfs_mark_return_if_closed_delegation()
551 struct nfs_delegation *delegation) in nfs_mark_return_delegation() argument
553 set_bit(NFS_DELEGATION_RETURN, &delegation->flags); in nfs_mark_return_delegation()
559 struct nfs_delegation *delegation; in nfs_server_mark_return_all_delegations() local
562 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_server_mark_return_all_delegations()
563 nfs_mark_return_delegation(server, delegation); in nfs_server_mark_return_all_delegations()
622 struct nfs_delegation *delegation; in nfs_mark_return_unused_delegation_types() local
624 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_mark_return_unused_delegation_types()
625 if ((delegation->type == (FMODE_READ|FMODE_WRITE)) && !(flags & FMODE_WRITE)) in nfs_mark_return_unused_delegation_types()
627 if (delegation->type & flags) in nfs_mark_return_unused_delegation_types()
628 nfs_mark_return_if_closed_delegation(server, delegation); in nfs_mark_return_unused_delegation_types()
645 struct nfs_delegation *delegation; in nfs_revoke_delegation() local
647 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs_revoke_delegation()
648 if (delegation != NULL) { in nfs_revoke_delegation()
649 set_bit(NFS_DELEGATION_REVOKED, &delegation->flags); in nfs_revoke_delegation()
650 nfs_mark_return_delegation(NFS_SERVER(inode), delegation); in nfs_revoke_delegation()
657 struct nfs_delegation *delegation; in nfs_remove_bad_delegation() local
660 delegation = nfs_inode_detach_delegation(inode); in nfs_remove_bad_delegation()
661 if (delegation) { in nfs_remove_bad_delegation()
662 nfs_inode_find_state_and_recover(inode, &delegation->stateid); in nfs_remove_bad_delegation()
663 nfs_free_delegation(delegation); in nfs_remove_bad_delegation()
682 struct nfs_delegation *delegation; in nfs_mark_return_unreferenced_delegations() local
684 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_mark_return_unreferenced_delegations()
685 if (test_and_clear_bit(NFS_DELEGATION_REFERENCED, &delegation->flags)) in nfs_mark_return_unreferenced_delegations()
687 nfs_mark_return_if_closed_delegation(server, delegation); in nfs_mark_return_unreferenced_delegations()
720 struct nfs_delegation *delegation; in nfs_async_inode_return_delegation() local
725 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs_async_inode_return_delegation()
726 if (delegation == NULL) in nfs_async_inode_return_delegation()
729 if (!clp->cl_mvops->match_stateid(&delegation->stateid, stateid)) in nfs_async_inode_return_delegation()
731 nfs_mark_return_delegation(server, delegation); in nfs_async_inode_return_delegation()
745 struct nfs_delegation *delegation; in nfs_delegation_find_inode_server() local
748 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_delegation_find_inode_server()
749 spin_lock(&delegation->lock); in nfs_delegation_find_inode_server()
750 if (delegation->inode != NULL && in nfs_delegation_find_inode_server()
751 nfs_compare_fh(fhandle, &NFS_I(delegation->inode)->fh) == 0) { in nfs_delegation_find_inode_server()
752 res = igrab(delegation->inode); in nfs_delegation_find_inode_server()
754 spin_unlock(&delegation->lock); in nfs_delegation_find_inode_server()
787 struct nfs_delegation *delegation; in nfs_delegation_mark_reclaim_server() local
789 list_for_each_entry_rcu(delegation, &server->delegations, super_list) in nfs_delegation_mark_reclaim_server()
790 set_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags); in nfs_delegation_mark_reclaim_server()
815 struct nfs_delegation *delegation; in nfs_delegation_reap_unclaimed() local
822 list_for_each_entry_rcu(delegation, &server->delegations, in nfs_delegation_reap_unclaimed()
825 &delegation->flags)) in nfs_delegation_reap_unclaimed()
828 &delegation->flags) == 0) in nfs_delegation_reap_unclaimed()
832 inode = nfs_delegation_grab_inode(delegation); in nfs_delegation_reap_unclaimed()
838 delegation = nfs_start_delegation_return_locked(NFS_I(inode)); in nfs_delegation_reap_unclaimed()
840 if (delegation != NULL) { in nfs_delegation_reap_unclaimed()
841 delegation = nfs_detach_delegation(NFS_I(inode), in nfs_delegation_reap_unclaimed()
842 delegation, server); in nfs_delegation_reap_unclaimed()
843 if (delegation != NULL) in nfs_delegation_reap_unclaimed()
844 nfs_free_delegation(delegation); in nfs_delegation_reap_unclaimed()
889 struct nfs_delegation *delegation; in nfs4_copy_delegation_stateid() local
894 delegation = rcu_dereference(nfsi->delegation); in nfs4_copy_delegation_stateid()
895 ret = (delegation != NULL && (delegation->type & flags) == flags); in nfs4_copy_delegation_stateid()
897 nfs4_stateid_copy(dst, &delegation->stateid); in nfs4_copy_delegation_stateid()
898 nfs_mark_delegation_referenced(delegation); in nfs4_copy_delegation_stateid()