Lines Matching full:delegation

3  * linux/fs/nfs/delegation.c
7 * NFS file delegation management
24 #include "delegation.h"
33 static void __nfs_free_delegation(struct nfs_delegation *delegation) in __nfs_free_delegation() argument
35 put_cred(delegation->cred); in __nfs_free_delegation()
36 delegation->cred = NULL; in __nfs_free_delegation()
37 kfree_rcu(delegation, rcu); in __nfs_free_delegation()
40 static void nfs_mark_delegation_revoked(struct nfs_delegation *delegation) in nfs_mark_delegation_revoked() argument
42 if (!test_and_set_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { in nfs_mark_delegation_revoked()
43 delegation->stateid.type = NFS4_INVALID_STATEID_TYPE; in nfs_mark_delegation_revoked()
45 if (!test_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) in nfs_mark_delegation_revoked()
46 nfs_clear_verifier_delegated(delegation->inode); in nfs_mark_delegation_revoked()
50 static struct nfs_delegation *nfs_get_delegation(struct nfs_delegation *delegation) in nfs_get_delegation() argument
52 refcount_inc(&delegation->refcount); in nfs_get_delegation()
53 return delegation; in nfs_get_delegation()
56 static void nfs_put_delegation(struct nfs_delegation *delegation) in nfs_put_delegation() argument
58 if (refcount_dec_and_test(&delegation->refcount)) in nfs_put_delegation()
59 __nfs_free_delegation(delegation); in nfs_put_delegation()
62 static void nfs_free_delegation(struct nfs_delegation *delegation) in nfs_free_delegation() argument
64 nfs_mark_delegation_revoked(delegation); in nfs_free_delegation()
65 nfs_put_delegation(delegation); in nfs_free_delegation()
69 * nfs_mark_delegation_referenced - set delegation's REFERENCED flag
70 * @delegation: delegation to process
73 void nfs_mark_delegation_referenced(struct nfs_delegation *delegation) in nfs_mark_delegation_referenced() argument
75 set_bit(NFS_DELEGATION_REFERENCED, &delegation->flags); in nfs_mark_delegation_referenced()
79 struct nfs_delegation *delegation) in nfs_mark_return_delegation() argument
81 set_bit(NFS_DELEGATION_RETURN, &delegation->flags); in nfs_mark_return_delegation()
85 static bool nfs4_is_valid_delegation(const struct nfs_delegation *delegation, in nfs4_is_valid_delegation() argument
88 if (delegation != NULL && (delegation->type & type) == type && in nfs4_is_valid_delegation()
89 !test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) && in nfs4_is_valid_delegation()
90 !test_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) in nfs4_is_valid_delegation()
97 struct nfs_delegation *delegation; in nfs4_get_valid_delegation() local
99 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs4_get_valid_delegation()
100 if (nfs4_is_valid_delegation(delegation, 0)) in nfs4_get_valid_delegation()
101 return delegation; in nfs4_get_valid_delegation()
108 struct nfs_delegation *delegation; in nfs4_do_check_delegation() local
113 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs4_do_check_delegation()
114 if (nfs4_is_valid_delegation(delegation, type)) { in nfs4_do_check_delegation()
116 nfs_mark_delegation_referenced(delegation); in nfs4_do_check_delegation()
119 !test_bit(NFS_DELEGATION_DELEGTIME, &delegation->flags)) in nfs4_do_check_delegation()
126 * nfs4_have_delegation - check if inode has a delegation, mark it
129 * @type: delegation types to check for
132 * Returns one if inode has the indicated delegation, otherwise zero.
140 * nfs4_check_delegation - check if inode has a delegation, do not mark
221 * nfs_inode_reclaim_delegation - process a delegation reclaim request
224 * @type: delegation type
225 * @stateid: delegation stateid
226 * @pagemod_limit: write delegation "space_limit"
227 * @deleg_type: raw delegation type
234 struct nfs_delegation *delegation; in nfs_inode_reclaim_delegation() local
238 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs_inode_reclaim_delegation()
239 if (delegation != NULL) { in nfs_inode_reclaim_delegation()
240 spin_lock(&delegation->lock); in nfs_inode_reclaim_delegation()
241 nfs4_stateid_copy(&delegation->stateid, stateid); in nfs_inode_reclaim_delegation()
242 delegation->type = type; in nfs_inode_reclaim_delegation()
243 delegation->pagemod_limit = pagemod_limit; in nfs_inode_reclaim_delegation()
244 oldcred = delegation->cred; in nfs_inode_reclaim_delegation()
245 delegation->cred = get_cred(cred); in nfs_inode_reclaim_delegation()
249 set_bit(NFS_DELEGATION_DELEGTIME, &delegation->flags); in nfs_inode_reclaim_delegation()
252 clear_bit(NFS_DELEGATION_DELEGTIME, &delegation->flags); in nfs_inode_reclaim_delegation()
254 clear_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags); in nfs_inode_reclaim_delegation()
256 &delegation->flags)) in nfs_inode_reclaim_delegation()
258 spin_unlock(&delegation->lock); in nfs_inode_reclaim_delegation()
270 struct nfs_delegation *delegation, in nfs_do_return_delegation() argument
276 if (!test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { in nfs_do_return_delegation()
277 spin_lock(&delegation->lock); in nfs_do_return_delegation()
278 cred = get_cred(delegation->cred); in nfs_do_return_delegation()
279 spin_unlock(&delegation->lock); in nfs_do_return_delegation()
280 res = nfs4_proc_delegreturn(inode, cred, &delegation->stateid, in nfs_do_return_delegation()
281 delegation, issync); in nfs_do_return_delegation()
287 static struct inode *nfs_delegation_grab_inode(struct nfs_delegation *delegation) in nfs_delegation_grab_inode() argument
291 spin_lock(&delegation->lock); in nfs_delegation_grab_inode()
292 if (delegation->inode != NULL) in nfs_delegation_grab_inode()
293 inode = igrab(delegation->inode); in nfs_delegation_grab_inode()
295 set_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags); in nfs_delegation_grab_inode()
296 spin_unlock(&delegation->lock); in nfs_delegation_grab_inode()
304 struct nfs_delegation *delegation = rcu_dereference(nfsi->delegation); in nfs_start_delegation_return_locked() local
306 if (delegation == NULL) in nfs_start_delegation_return_locked()
308 spin_lock(&delegation->lock); in nfs_start_delegation_return_locked()
309 if (!test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) { in nfs_start_delegation_return_locked()
310 clear_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags); in nfs_start_delegation_return_locked()
312 ret = nfs_get_delegation(delegation); in nfs_start_delegation_return_locked()
314 spin_unlock(&delegation->lock); in nfs_start_delegation_return_locked()
324 struct nfs_delegation *delegation; in nfs_start_delegation_return() local
327 delegation = nfs_start_delegation_return_locked(nfsi); in nfs_start_delegation_return()
329 return delegation; in nfs_start_delegation_return()
332 static void nfs_abort_delegation_return(struct nfs_delegation *delegation, in nfs_abort_delegation_return() argument
336 spin_lock(&delegation->lock); in nfs_abort_delegation_return()
337 clear_bit(NFS_DELEGATION_RETURNING, &delegation->flags); in nfs_abort_delegation_return()
339 set_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags); in nfs_abort_delegation_return()
342 spin_unlock(&delegation->lock); in nfs_abort_delegation_return()
347 struct nfs_delegation *delegation, in nfs_detach_delegation_locked() argument
351 rcu_dereference_protected(nfsi->delegation, in nfs_detach_delegation_locked()
354 if (deleg_cur == NULL || delegation != deleg_cur) in nfs_detach_delegation_locked()
357 spin_lock(&delegation->lock); in nfs_detach_delegation_locked()
358 if (!delegation->inode) { in nfs_detach_delegation_locked()
359 spin_unlock(&delegation->lock); in nfs_detach_delegation_locked()
362 list_del_rcu(&delegation->super_list); in nfs_detach_delegation_locked()
363 delegation->inode = NULL; in nfs_detach_delegation_locked()
364 rcu_assign_pointer(nfsi->delegation, NULL); in nfs_detach_delegation_locked()
365 spin_unlock(&delegation->lock); in nfs_detach_delegation_locked()
366 return delegation; in nfs_detach_delegation_locked()
370 struct nfs_delegation *delegation, in nfs_detach_delegation() argument
376 delegation = nfs_detach_delegation_locked(nfsi, delegation, clp); in nfs_detach_delegation()
378 return delegation; in nfs_detach_delegation()
386 struct nfs_delegation *delegation; in nfs_inode_detach_delegation() local
389 delegation = rcu_dereference(nfsi->delegation); in nfs_inode_detach_delegation()
390 if (delegation != NULL) in nfs_inode_detach_delegation()
391 delegation = nfs_detach_delegation(nfsi, delegation, server); in nfs_inode_detach_delegation()
393 return delegation; in nfs_inode_detach_delegation()
397 nfs_update_delegation_cred(struct nfs_delegation *delegation, in nfs_update_delegation_cred() argument
402 if (cred_fscmp(delegation->cred, cred) != 0) { in nfs_update_delegation_cred()
403 old = xchg(&delegation->cred, get_cred(cred)); in nfs_update_delegation_cred()
409 nfs_update_inplace_delegation(struct nfs_delegation *delegation, in nfs_update_inplace_delegation() argument
412 if (nfs4_stateid_is_newer(&update->stateid, &delegation->stateid)) { in nfs_update_inplace_delegation()
413 delegation->stateid.seqid = update->stateid.seqid; in nfs_update_inplace_delegation()
415 delegation->type = update->type; in nfs_update_inplace_delegation()
416 delegation->pagemod_limit = update->pagemod_limit; in nfs_update_inplace_delegation()
417 if (test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { in nfs_update_inplace_delegation()
418 delegation->change_attr = update->change_attr; in nfs_update_inplace_delegation()
419 nfs_update_delegation_cred(delegation, update->cred); in nfs_update_inplace_delegation()
421 clear_bit(NFS_DELEGATION_REVOKED, &delegation->flags); in nfs_update_inplace_delegation()
428 * nfs_inode_set_delegation - set up a delegation on an inode
429 * @inode: inode to which delegation applies
430 * @cred: cred to use for subsequent delegation processing
431 * @type: delegation type
432 * @stateid: delegation stateid
433 * @pagemod_limit: write delegation "space_limit"
434 * @deleg_type: raw delegation type
445 struct nfs_delegation *delegation, *old_delegation; in nfs_inode_set_delegation() local
449 delegation = kmalloc(sizeof(*delegation), GFP_KERNEL_ACCOUNT); in nfs_inode_set_delegation()
450 if (delegation == NULL) in nfs_inode_set_delegation()
452 nfs4_stateid_copy(&delegation->stateid, stateid); in nfs_inode_set_delegation()
453 refcount_set(&delegation->refcount, 1); in nfs_inode_set_delegation()
454 delegation->type = type; in nfs_inode_set_delegation()
455 delegation->pagemod_limit = pagemod_limit; in nfs_inode_set_delegation()
456 delegation->change_attr = inode_peek_iversion_raw(inode); in nfs_inode_set_delegation()
457 delegation->cred = get_cred(cred); in nfs_inode_set_delegation()
458 delegation->inode = inode; in nfs_inode_set_delegation()
459 delegation->flags = 1<<NFS_DELEGATION_REFERENCED; in nfs_inode_set_delegation()
463 delegation->flags |= BIT(NFS_DELEGATION_DELEGTIME); in nfs_inode_set_delegation()
465 delegation->test_gen = 0; in nfs_inode_set_delegation()
466 spin_lock_init(&delegation->lock); in nfs_inode_set_delegation()
469 old_delegation = rcu_dereference_protected(nfsi->delegation, in nfs_inode_set_delegation()
473 /* Is this an update of the existing delegation? */ in nfs_inode_set_delegation()
475 &delegation->stateid)) { in nfs_inode_set_delegation()
478 delegation); in nfs_inode_set_delegation()
486 * Allow for upgrades to a WRITE delegation, but in nfs_inode_set_delegation()
490 "a duplicate delegation!\n", in nfs_inode_set_delegation()
492 if (delegation->type == old_delegation->type || in nfs_inode_set_delegation()
493 !(delegation->type & FMODE_WRITE)) { in nfs_inode_set_delegation()
494 freeme = delegation; in nfs_inode_set_delegation()
495 delegation = NULL; in nfs_inode_set_delegation()
508 * the delegation, then pre-emptively ask for a full attribute in nfs_inode_set_delegation()
522 list_add_tail_rcu(&delegation->super_list, &server->delegations); in nfs_inode_set_delegation()
523 rcu_assign_pointer(nfsi->delegation, delegation); in nfs_inode_set_delegation()
524 delegation = NULL; in nfs_inode_set_delegation()
536 if (delegation != NULL) in nfs_inode_set_delegation()
537 __nfs_free_delegation(delegation); in nfs_inode_set_delegation()
546 * Basic procedure for returning a delegation to the server
548 static int nfs_end_delegation_return(struct inode *inode, struct nfs_delegation *delegation, int is… in nfs_end_delegation_return() argument
554 if (delegation == NULL) in nfs_end_delegation_return()
563 if (test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) in nfs_end_delegation_return()
565 err = nfs_delegation_claim_opens(inode, &delegation->stateid, in nfs_end_delegation_return()
566 delegation->type); in nfs_end_delegation_return()
576 nfs_abort_delegation_return(delegation, clp, err); in nfs_end_delegation_return()
580 err = nfs_do_return_delegation(inode, delegation, issync); in nfs_end_delegation_return()
583 nfs_put_delegation(delegation); in nfs_end_delegation_return()
587 static bool nfs_delegation_need_return(struct nfs_delegation *delegation) in nfs_delegation_need_return() argument
591 if (test_and_clear_bit(NFS_DELEGATION_RETURN, &delegation->flags)) in nfs_delegation_need_return()
593 else if (test_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags)) { in nfs_delegation_need_return()
596 spin_lock(&delegation->lock); in nfs_delegation_need_return()
597 inode = delegation->inode; in nfs_delegation_need_return()
600 spin_unlock(&delegation->lock); in nfs_delegation_need_return()
603 clear_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags); in nfs_delegation_need_return()
604 if (test_bit(NFS_DELEGATION_RETURNING, &delegation->flags) || in nfs_delegation_need_return()
605 test_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags) || in nfs_delegation_need_return()
606 test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) in nfs_delegation_need_return()
615 struct nfs_delegation *delegation; in nfs_server_return_marked_delegations() local
626 * list delegation in the server from the delegations in nfs_server_return_marked_delegations()
628 * prev is an RCU-protected pointer to a delegation which in nfs_server_return_marked_delegations()
633 delegation = NULL; in nfs_server_return_marked_delegations()
636 delegation = rcu_dereference(NFS_I(place_holder)->delegation); in nfs_server_return_marked_delegations()
637 if (!delegation || delegation != place_holder_deleg) in nfs_server_return_marked_delegations()
638 delegation = list_entry_rcu(server->delegations.next, in nfs_server_return_marked_delegations()
640 list_for_each_entry_from_rcu(delegation, &server->delegations, super_list) { in nfs_server_return_marked_delegations()
643 if (test_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags)) in nfs_server_return_marked_delegations()
645 if (!nfs_delegation_need_return(delegation)) { in nfs_server_return_marked_delegations()
646 if (nfs4_is_valid_delegation(delegation, 0)) in nfs_server_return_marked_delegations()
647 prev = delegation; in nfs_server_return_marked_delegations()
650 inode = nfs_delegation_grab_inode(delegation); in nfs_server_return_marked_delegations()
663 delegation = nfs_start_delegation_return_locked(NFS_I(inode)); in nfs_server_return_marked_delegations()
668 err = nfs_end_delegation_return(inode, delegation, 0); in nfs_server_return_marked_delegations()
737 * nfs_inode_evict_delegation - return delegation, don't reclaim opens
740 * Does not protect against delegation reclaims, therefore really only safe
742 * the delegation structure.
746 struct nfs_delegation *delegation; in nfs_inode_evict_delegation() local
748 delegation = nfs_inode_detach_delegation(inode); in nfs_inode_evict_delegation()
749 if (delegation != NULL) { in nfs_inode_evict_delegation()
750 set_bit(NFS_DELEGATION_RETURNING, &delegation->flags); in nfs_inode_evict_delegation()
751 set_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags); in nfs_inode_evict_delegation()
752 nfs_do_return_delegation(inode, delegation, 1); in nfs_inode_evict_delegation()
753 nfs_free_delegation(delegation); in nfs_inode_evict_delegation()
758 * nfs4_inode_return_delegation - synchronously return a delegation
762 * assumption that if we need to return the delegation, then
770 struct nfs_delegation *delegation; in nfs4_inode_return_delegation() local
772 delegation = nfs_start_delegation_return(nfsi); in nfs4_inode_return_delegation()
773 if (delegation != NULL) { in nfs4_inode_return_delegation()
778 return nfs_end_delegation_return(inode, delegation, 1); in nfs4_inode_return_delegation()
784 * nfs4_inode_return_delegation_on_close - asynchronously return a delegation
788 * inode delegation needs to be returned immediately.
792 struct nfs_delegation *delegation; in nfs4_inode_return_delegation_on_close() local
798 delegation = nfs4_get_valid_delegation(inode); in nfs4_inode_return_delegation_on_close()
799 if (!delegation) in nfs4_inode_return_delegation_on_close()
801 if (test_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags) || in nfs4_inode_return_delegation_on_close()
803 spin_lock(&delegation->lock); in nfs4_inode_return_delegation_on_close()
804 if (delegation->inode && in nfs4_inode_return_delegation_on_close()
806 !test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) { in nfs4_inode_return_delegation_on_close()
807 clear_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags); in nfs4_inode_return_delegation_on_close()
809 ret = nfs_get_delegation(delegation); in nfs4_inode_return_delegation_on_close()
811 spin_unlock(&delegation->lock); in nfs4_inode_return_delegation_on_close()
824 * Make the inode writeable by returning the delegation if necessary
830 struct nfs_delegation *delegation; in nfs4_inode_make_writeable() local
833 delegation = nfs4_get_valid_delegation(inode); in nfs4_inode_make_writeable()
834 if (delegation == NULL || in nfs4_inode_make_writeable()
836 (delegation->type & FMODE_WRITE))) { in nfs4_inode_make_writeable()
845 struct nfs_delegation *delegation) in nfs_mark_return_if_closed_delegation() argument
847 set_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags); in nfs_mark_return_if_closed_delegation()
853 struct nfs_delegation *delegation; in nfs_server_mark_return_all_delegations() local
856 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_server_mark_return_all_delegations()
857 nfs_mark_return_delegation(server, delegation); in nfs_server_mark_return_all_delegations()
916 struct nfs_delegation *delegation; in nfs_mark_return_unused_delegation_types() local
918 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_mark_return_unused_delegation_types()
919 if ((delegation->type == (FMODE_READ|FMODE_WRITE)) && !(flags & FMODE_WRITE)) in nfs_mark_return_unused_delegation_types()
921 if (delegation->type & flags) in nfs_mark_return_unused_delegation_types()
922 nfs_mark_return_if_closed_delegation(server, delegation); in nfs_mark_return_unused_delegation_types()
940 struct nfs_delegation *delegation; in nfs_revoke_delegation() local
945 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs_revoke_delegation()
946 if (delegation == NULL) in nfs_revoke_delegation()
949 nfs4_stateid_copy(&tmp, &delegation->stateid); in nfs_revoke_delegation()
952 if (!nfs4_stateid_match_other(stateid, &delegation->stateid)) in nfs_revoke_delegation()
954 spin_lock(&delegation->lock); in nfs_revoke_delegation()
956 if (nfs4_stateid_is_newer(&delegation->stateid, stateid)) { in nfs_revoke_delegation()
957 spin_unlock(&delegation->lock); in nfs_revoke_delegation()
960 delegation->stateid.seqid = stateid->seqid; in nfs_revoke_delegation()
962 spin_unlock(&delegation->lock); in nfs_revoke_delegation()
964 nfs_mark_delegation_revoked(delegation); in nfs_revoke_delegation()
982 struct nfs_delegation *delegation; in nfs_delegation_mark_returned() local
988 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs_delegation_mark_returned()
989 if (!delegation) in nfs_delegation_mark_returned()
992 spin_lock(&delegation->lock); in nfs_delegation_mark_returned()
993 if (!nfs4_stateid_match_other(stateid, &delegation->stateid)) in nfs_delegation_mark_returned()
996 /* If delegation->stateid is newer, dont mark as returned */ in nfs_delegation_mark_returned()
997 if (nfs4_stateid_is_newer(&delegation->stateid, stateid)) in nfs_delegation_mark_returned()
999 if (delegation->stateid.seqid != stateid->seqid) in nfs_delegation_mark_returned()
1000 delegation->stateid.seqid = stateid->seqid; in nfs_delegation_mark_returned()
1003 nfs_mark_delegation_revoked(delegation); in nfs_delegation_mark_returned()
1004 clear_bit(NFS_DELEGATION_RETURNING, &delegation->flags); in nfs_delegation_mark_returned()
1005 spin_unlock(&delegation->lock); in nfs_delegation_mark_returned()
1006 if (nfs_detach_delegation(NFS_I(inode), delegation, NFS_SERVER(inode))) in nfs_delegation_mark_returned()
1007 nfs_put_delegation(delegation); in nfs_delegation_mark_returned()
1011 clear_bit(NFS_DELEGATION_RETURNING, &delegation->flags); in nfs_delegation_mark_returned()
1013 spin_unlock(&delegation->lock); in nfs_delegation_mark_returned()
1023 * @flags: delegation types to expire
1034 struct nfs_delegation *delegation; in nfs_mark_return_unreferenced_delegations() local
1036 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_mark_return_unreferenced_delegations()
1037 if (test_and_clear_bit(NFS_DELEGATION_REFERENCED, &delegation->flags)) in nfs_mark_return_unreferenced_delegations()
1039 nfs_mark_return_if_closed_delegation(server, delegation); in nfs_mark_return_unreferenced_delegations()
1061 * nfs_async_inode_return_delegation - asynchronously return a delegation
1072 struct nfs_delegation *delegation; in nfs_async_inode_return_delegation() local
1075 delegation = nfs4_get_valid_delegation(inode); in nfs_async_inode_return_delegation()
1076 if (delegation == NULL) in nfs_async_inode_return_delegation()
1079 !clp->cl_mvops->match_stateid(&delegation->stateid, stateid)) in nfs_async_inode_return_delegation()
1081 nfs_mark_return_delegation(server, delegation); in nfs_async_inode_return_delegation()
1098 struct nfs_delegation *delegation; in nfs_delegation_find_inode_server() local
1102 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_delegation_find_inode_server()
1103 spin_lock(&delegation->lock); in nfs_delegation_find_inode_server()
1104 if (delegation->inode != NULL && in nfs_delegation_find_inode_server()
1105 !test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) && in nfs_delegation_find_inode_server()
1106 nfs_compare_fh(fhandle, &NFS_I(delegation->inode)->fh) == 0) { in nfs_delegation_find_inode_server()
1109 res = igrab(delegation->inode); in nfs_delegation_find_inode_server()
1111 spin_unlock(&delegation->lock); in nfs_delegation_find_inode_server()
1121 spin_unlock(&delegation->lock); in nfs_delegation_find_inode_server()
1127 * nfs_delegation_find_inode - retrieve the inode associated with a delegation
1129 * @fhandle: filehandle from a delegation recall
1154 struct nfs_delegation *delegation; in nfs_delegation_mark_reclaim_server() local
1156 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_delegation_mark_reclaim_server()
1158 * If the delegation may have been admin revoked, then we in nfs_delegation_mark_reclaim_server()
1161 if (test_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags)) in nfs_delegation_mark_reclaim_server()
1163 set_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags); in nfs_delegation_mark_reclaim_server()
1185 struct nfs_delegation *delegation; in nfs_server_reap_unclaimed_delegations() local
1189 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_server_reap_unclaimed_delegations()
1191 &delegation->flags) || in nfs_server_reap_unclaimed_delegations()
1193 &delegation->flags) || in nfs_server_reap_unclaimed_delegations()
1195 &delegation->flags) == 0) in nfs_server_reap_unclaimed_delegations()
1197 inode = nfs_delegation_grab_inode(delegation); in nfs_server_reap_unclaimed_delegations()
1200 delegation = nfs_start_delegation_return_locked(NFS_I(inode)); in nfs_server_reap_unclaimed_delegations()
1202 if (delegation != NULL) { in nfs_server_reap_unclaimed_delegations()
1203 if (nfs_detach_delegation(NFS_I(inode), delegation, in nfs_server_reap_unclaimed_delegations()
1205 nfs_free_delegation(delegation); in nfs_server_reap_unclaimed_delegations()
1207 nfs_put_delegation(delegation); in nfs_server_reap_unclaimed_delegations()
1236 struct nfs_delegation *delegation) in nfs_mark_test_expired_delegation() argument
1238 if (delegation->stateid.type == NFS4_INVALID_STATEID_TYPE) in nfs_mark_test_expired_delegation()
1240 clear_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags); in nfs_mark_test_expired_delegation()
1241 set_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags); in nfs_mark_test_expired_delegation()
1248 struct nfs_delegation *delegation; in nfs_inode_mark_test_expired_delegation() local
1251 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs_inode_mark_test_expired_delegation()
1252 if (delegation) in nfs_inode_mark_test_expired_delegation()
1253 nfs_mark_test_expired_delegation(server, delegation); in nfs_inode_mark_test_expired_delegation()
1260 struct nfs_delegation *delegation; in nfs_delegation_mark_test_expired_server() local
1262 list_for_each_entry_rcu(delegation, &server->delegations, super_list) in nfs_delegation_mark_test_expired_server()
1263 nfs_mark_test_expired_delegation(server, delegation); in nfs_delegation_mark_test_expired_server()
1314 struct nfs_delegation *delegation; in nfs_server_reap_expired_delegations() local
1322 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_server_reap_expired_delegations()
1324 &delegation->flags) || in nfs_server_reap_expired_delegations()
1326 &delegation->flags) || in nfs_server_reap_expired_delegations()
1328 &delegation->flags) == 0 || in nfs_server_reap_expired_delegations()
1329 delegation->test_gen == gen) in nfs_server_reap_expired_delegations()
1331 inode = nfs_delegation_grab_inode(delegation); in nfs_server_reap_expired_delegations()
1334 spin_lock(&delegation->lock); in nfs_server_reap_expired_delegations()
1335 cred = get_cred_rcu(delegation->cred); in nfs_server_reap_expired_delegations()
1336 nfs4_stateid_copy(&stateid, &delegation->stateid); in nfs_server_reap_expired_delegations()
1337 spin_unlock(&delegation->lock); in nfs_server_reap_expired_delegations()
1338 delegation->test_gen = gen; in nfs_server_reap_expired_delegations()
1339 clear_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags); in nfs_server_reap_expired_delegations()
1375 struct nfs_delegation *delegation; in nfs_inode_find_delegation_state_and_recover() local
1379 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs_inode_find_delegation_state_and_recover()
1380 if (delegation && in nfs_inode_find_delegation_state_and_recover()
1381 nfs4_stateid_match_or_older(&delegation->stateid, stateid) && in nfs_inode_find_delegation_state_and_recover()
1382 !test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { in nfs_inode_find_delegation_state_and_recover()
1383 nfs_mark_test_expired_delegation(NFS_SERVER(inode), delegation); in nfs_inode_find_delegation_state_and_recover()
1414 * nfs4_refresh_delegation_stateid - Update delegation stateid seqid
1418 * Returns "true" and updates "dst->seqid" * if inode had a delegation
1419 * that matches our delegation stateid. Otherwise "false" is returned.
1423 struct nfs_delegation *delegation; in nfs4_refresh_delegation_stateid() local
1429 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs4_refresh_delegation_stateid()
1430 if (delegation != NULL && in nfs4_refresh_delegation_stateid()
1431 nfs4_stateid_match_other(dst, &delegation->stateid) && in nfs4_refresh_delegation_stateid()
1432 nfs4_stateid_is_newer(&delegation->stateid, dst) && in nfs4_refresh_delegation_stateid()
1433 !test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { in nfs4_refresh_delegation_stateid()
1434 dst->seqid = delegation->stateid.seqid; in nfs4_refresh_delegation_stateid()
1445 * @flags: delegation type requirement
1449 * Returns "true" and fills in "dst->data" * if inode had a delegation,
1456 struct nfs_delegation *delegation; in nfs4_copy_delegation_stateid() local
1461 delegation = rcu_dereference(nfsi->delegation); in nfs4_copy_delegation_stateid()
1462 if (!delegation) in nfs4_copy_delegation_stateid()
1464 spin_lock(&delegation->lock); in nfs4_copy_delegation_stateid()
1465 ret = nfs4_is_valid_delegation(delegation, flags); in nfs4_copy_delegation_stateid()
1467 nfs4_stateid_copy(dst, &delegation->stateid); in nfs4_copy_delegation_stateid()
1468 nfs_mark_delegation_referenced(delegation); in nfs4_copy_delegation_stateid()
1470 *cred = get_cred(delegation->cred); in nfs4_copy_delegation_stateid()
1472 spin_unlock(&delegation->lock); in nfs4_copy_delegation_stateid()
1483 * against the delegation 'space_limit' field to see if
1489 struct nfs_delegation *delegation; in nfs4_delegation_flush_on_close() local
1493 delegation = rcu_dereference(nfsi->delegation); in nfs4_delegation_flush_on_close()
1494 if (delegation == NULL || !(delegation->type & FMODE_WRITE)) in nfs4_delegation_flush_on_close()
1496 if (atomic_long_read(&nfsi->nrequests) < delegation->pagemod_limit) in nfs4_delegation_flush_on_close()