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()
86 nfs4_is_valid_delegation(const struct nfs_delegation *delegation, in nfs4_is_valid_delegation() argument
89 if (delegation != NULL && (delegation->type & flags) == flags && in nfs4_is_valid_delegation()
90 !test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) && in nfs4_is_valid_delegation()
91 !test_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) in nfs4_is_valid_delegation()
98 struct nfs_delegation *delegation; in nfs4_get_valid_delegation() local
100 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs4_get_valid_delegation()
101 if (nfs4_is_valid_delegation(delegation, 0)) in nfs4_get_valid_delegation()
102 return delegation; in nfs4_get_valid_delegation()
109 struct nfs_delegation *delegation; in nfs4_do_check_delegation() local
114 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs4_do_check_delegation()
115 if (nfs4_is_valid_delegation(delegation, flags)) { in nfs4_do_check_delegation()
117 nfs_mark_delegation_referenced(delegation); in nfs4_do_check_delegation()
124 * nfs_have_delegation - check if inode has a delegation, mark it
127 * @flags: delegation types to check for
129 * Returns one if inode has the indicated delegation, otherwise zero.
137 * nfs4_check_delegation - check if inode has a delegation, do not mark
222 * nfs_inode_reclaim_delegation - process a delegation reclaim request
225 * @type: delegation type
226 * @stateid: delegation stateid
227 * @pagemod_limit: write delegation "space_limit"
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()
246 clear_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags); in nfs_inode_reclaim_delegation()
248 &delegation->flags)) in nfs_inode_reclaim_delegation()
250 spin_unlock(&delegation->lock); in nfs_inode_reclaim_delegation()
261 static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation *delegation, int iss… in nfs_do_return_delegation() argument
266 if (!test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { in nfs_do_return_delegation()
267 spin_lock(&delegation->lock); in nfs_do_return_delegation()
268 cred = get_cred(delegation->cred); in nfs_do_return_delegation()
269 spin_unlock(&delegation->lock); in nfs_do_return_delegation()
271 &delegation->stateid, in nfs_do_return_delegation()
278 static struct inode *nfs_delegation_grab_inode(struct nfs_delegation *delegation) in nfs_delegation_grab_inode() argument
282 spin_lock(&delegation->lock); in nfs_delegation_grab_inode()
283 if (delegation->inode != NULL) in nfs_delegation_grab_inode()
284 inode = igrab(delegation->inode); in nfs_delegation_grab_inode()
286 set_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags); in nfs_delegation_grab_inode()
287 spin_unlock(&delegation->lock); in nfs_delegation_grab_inode()
295 struct nfs_delegation *delegation = rcu_dereference(nfsi->delegation); in nfs_start_delegation_return_locked() local
297 if (delegation == NULL) in nfs_start_delegation_return_locked()
299 spin_lock(&delegation->lock); in nfs_start_delegation_return_locked()
300 if (!test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) { in nfs_start_delegation_return_locked()
301 clear_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags); in nfs_start_delegation_return_locked()
303 ret = nfs_get_delegation(delegation); in nfs_start_delegation_return_locked()
305 spin_unlock(&delegation->lock); in nfs_start_delegation_return_locked()
315 struct nfs_delegation *delegation; in nfs_start_delegation_return() local
318 delegation = nfs_start_delegation_return_locked(nfsi); in nfs_start_delegation_return()
320 return delegation; in nfs_start_delegation_return()
323 static void nfs_abort_delegation_return(struct nfs_delegation *delegation, in nfs_abort_delegation_return() argument
327 spin_lock(&delegation->lock); in nfs_abort_delegation_return()
328 clear_bit(NFS_DELEGATION_RETURNING, &delegation->flags); in nfs_abort_delegation_return()
330 set_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags); in nfs_abort_delegation_return()
333 spin_unlock(&delegation->lock); in nfs_abort_delegation_return()
338 struct nfs_delegation *delegation, in nfs_detach_delegation_locked() argument
342 rcu_dereference_protected(nfsi->delegation, in nfs_detach_delegation_locked()
345 if (deleg_cur == NULL || delegation != deleg_cur) in nfs_detach_delegation_locked()
348 spin_lock(&delegation->lock); in nfs_detach_delegation_locked()
349 if (!delegation->inode) { in nfs_detach_delegation_locked()
350 spin_unlock(&delegation->lock); in nfs_detach_delegation_locked()
353 list_del_rcu(&delegation->super_list); in nfs_detach_delegation_locked()
354 delegation->inode = NULL; in nfs_detach_delegation_locked()
355 rcu_assign_pointer(nfsi->delegation, NULL); in nfs_detach_delegation_locked()
356 spin_unlock(&delegation->lock); in nfs_detach_delegation_locked()
357 return delegation; in nfs_detach_delegation_locked()
361 struct nfs_delegation *delegation, in nfs_detach_delegation() argument
367 delegation = nfs_detach_delegation_locked(nfsi, delegation, clp); in nfs_detach_delegation()
369 return delegation; in nfs_detach_delegation()
377 struct nfs_delegation *delegation; in nfs_inode_detach_delegation() local
380 delegation = rcu_dereference(nfsi->delegation); in nfs_inode_detach_delegation()
381 if (delegation != NULL) in nfs_inode_detach_delegation()
382 delegation = nfs_detach_delegation(nfsi, delegation, server); in nfs_inode_detach_delegation()
384 return delegation; in nfs_inode_detach_delegation()
388 nfs_update_delegation_cred(struct nfs_delegation *delegation, in nfs_update_delegation_cred() argument
393 if (cred_fscmp(delegation->cred, cred) != 0) { in nfs_update_delegation_cred()
394 old = xchg(&delegation->cred, get_cred(cred)); in nfs_update_delegation_cred()
400 nfs_update_inplace_delegation(struct nfs_delegation *delegation, in nfs_update_inplace_delegation() argument
403 if (nfs4_stateid_is_newer(&update->stateid, &delegation->stateid)) { in nfs_update_inplace_delegation()
404 delegation->stateid.seqid = update->stateid.seqid; in nfs_update_inplace_delegation()
406 delegation->type = update->type; in nfs_update_inplace_delegation()
407 delegation->pagemod_limit = update->pagemod_limit; in nfs_update_inplace_delegation()
408 if (test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { in nfs_update_inplace_delegation()
409 delegation->change_attr = update->change_attr; in nfs_update_inplace_delegation()
410 nfs_update_delegation_cred(delegation, update->cred); in nfs_update_inplace_delegation()
412 clear_bit(NFS_DELEGATION_REVOKED, &delegation->flags); in nfs_update_inplace_delegation()
419 * nfs_inode_set_delegation - set up a delegation on an inode
420 * @inode: inode to which delegation applies
421 * @cred: cred to use for subsequent delegation processing
422 * @type: delegation type
423 * @stateid: delegation stateid
424 * @pagemod_limit: write delegation "space_limit"
436 struct nfs_delegation *delegation, *old_delegation; in nfs_inode_set_delegation() local
440 delegation = kmalloc(sizeof(*delegation), GFP_NOFS); in nfs_inode_set_delegation()
441 if (delegation == NULL) in nfs_inode_set_delegation()
443 nfs4_stateid_copy(&delegation->stateid, stateid); in nfs_inode_set_delegation()
444 refcount_set(&delegation->refcount, 1); in nfs_inode_set_delegation()
445 delegation->type = type; in nfs_inode_set_delegation()
446 delegation->pagemod_limit = pagemod_limit; in nfs_inode_set_delegation()
447 delegation->change_attr = inode_peek_iversion_raw(inode); in nfs_inode_set_delegation()
448 delegation->cred = get_cred(cred); in nfs_inode_set_delegation()
449 delegation->inode = inode; in nfs_inode_set_delegation()
450 delegation->flags = 1<<NFS_DELEGATION_REFERENCED; in nfs_inode_set_delegation()
451 spin_lock_init(&delegation->lock); in nfs_inode_set_delegation()
454 old_delegation = rcu_dereference_protected(nfsi->delegation, in nfs_inode_set_delegation()
458 /* Is this an update of the existing delegation? */ in nfs_inode_set_delegation()
460 &delegation->stateid)) { in nfs_inode_set_delegation()
463 delegation); in nfs_inode_set_delegation()
471 * Allow for upgrades to a WRITE delegation, but in nfs_inode_set_delegation()
475 "a duplicate delegation!\n", in nfs_inode_set_delegation()
477 if (delegation->type == old_delegation->type || in nfs_inode_set_delegation()
478 !(delegation->type & FMODE_WRITE)) { in nfs_inode_set_delegation()
479 freeme = delegation; in nfs_inode_set_delegation()
480 delegation = NULL; in nfs_inode_set_delegation()
491 list_add_tail_rcu(&delegation->super_list, &server->delegations); in nfs_inode_set_delegation()
492 rcu_assign_pointer(nfsi->delegation, delegation); in nfs_inode_set_delegation()
493 delegation = NULL; in nfs_inode_set_delegation()
505 if (delegation != NULL) in nfs_inode_set_delegation()
506 __nfs_free_delegation(delegation); in nfs_inode_set_delegation()
515 * Basic procedure for returning a delegation to the server
517 static int nfs_end_delegation_return(struct inode *inode, struct nfs_delegation *delegation, int is… in nfs_end_delegation_return() argument
522 if (delegation == NULL) in nfs_end_delegation_return()
525 if (test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) in nfs_end_delegation_return()
527 err = nfs_delegation_claim_opens(inode, &delegation->stateid, in nfs_end_delegation_return()
528 delegation->type); in nfs_end_delegation_return()
538 nfs_abort_delegation_return(delegation, clp, err); in nfs_end_delegation_return()
542 err = nfs_do_return_delegation(inode, delegation, issync); in nfs_end_delegation_return()
545 nfs_put_delegation(delegation); in nfs_end_delegation_return()
549 static bool nfs_delegation_need_return(struct nfs_delegation *delegation) in nfs_delegation_need_return() argument
553 if (test_and_clear_bit(NFS_DELEGATION_RETURN, &delegation->flags)) in nfs_delegation_need_return()
555 else if (test_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags)) { in nfs_delegation_need_return()
558 spin_lock(&delegation->lock); in nfs_delegation_need_return()
559 inode = delegation->inode; in nfs_delegation_need_return()
562 spin_unlock(&delegation->lock); in nfs_delegation_need_return()
565 clear_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags); in nfs_delegation_need_return()
566 if (test_bit(NFS_DELEGATION_RETURNING, &delegation->flags) || in nfs_delegation_need_return()
567 test_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags) || in nfs_delegation_need_return()
568 test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) in nfs_delegation_need_return()
577 struct nfs_delegation *delegation; in nfs_server_return_marked_delegations() local
588 * list delegation in the server from the delegations in nfs_server_return_marked_delegations()
590 * prev is an RCU-protected pointer to a delegation which in nfs_server_return_marked_delegations()
595 delegation = NULL; in nfs_server_return_marked_delegations()
598 delegation = rcu_dereference(NFS_I(place_holder)->delegation); in nfs_server_return_marked_delegations()
599 if (!delegation || delegation != place_holder_deleg) in nfs_server_return_marked_delegations()
600 delegation = list_entry_rcu(server->delegations.next, in nfs_server_return_marked_delegations()
602 list_for_each_entry_from_rcu(delegation, &server->delegations, super_list) { in nfs_server_return_marked_delegations()
605 if (test_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags)) in nfs_server_return_marked_delegations()
607 if (!nfs_delegation_need_return(delegation)) { in nfs_server_return_marked_delegations()
608 if (nfs4_is_valid_delegation(delegation, 0)) in nfs_server_return_marked_delegations()
609 prev = delegation; in nfs_server_return_marked_delegations()
622 inode = nfs_delegation_grab_inode(delegation); in nfs_server_return_marked_delegations()
628 delegation = nfs_start_delegation_return_locked(NFS_I(inode)); in nfs_server_return_marked_delegations()
633 err = nfs_end_delegation_return(inode, delegation, 0); in nfs_server_return_marked_delegations()
702 * nfs_inode_evict_delegation - return delegation, don't reclaim opens
705 * Does not protect against delegation reclaims, therefore really only safe
707 * the delegation structure.
711 struct nfs_delegation *delegation; in nfs_inode_evict_delegation() local
713 delegation = nfs_inode_detach_delegation(inode); in nfs_inode_evict_delegation()
714 if (delegation != NULL) { in nfs_inode_evict_delegation()
715 set_bit(NFS_DELEGATION_RETURNING, &delegation->flags); in nfs_inode_evict_delegation()
716 set_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags); in nfs_inode_evict_delegation()
717 nfs_do_return_delegation(inode, delegation, 1); in nfs_inode_evict_delegation()
718 nfs_free_delegation(delegation); in nfs_inode_evict_delegation()
723 * nfs_inode_return_delegation - synchronously return a delegation
727 * assumption that if we need to return the delegation, then
735 struct nfs_delegation *delegation; in nfs4_inode_return_delegation() local
739 delegation = nfs_start_delegation_return(nfsi); in nfs4_inode_return_delegation()
740 if (delegation != NULL) in nfs4_inode_return_delegation()
741 err = nfs_end_delegation_return(inode, delegation, 1); in nfs4_inode_return_delegation()
746 * nfs_inode_return_delegation_on_close - asynchronously return a delegation
750 * inode delegation needs to be returned immediately.
754 struct nfs_delegation *delegation; in nfs4_inode_return_delegation_on_close() local
760 delegation = nfs4_get_valid_delegation(inode); in nfs4_inode_return_delegation_on_close()
761 if (!delegation) in nfs4_inode_return_delegation_on_close()
763 if (test_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags) || in nfs4_inode_return_delegation_on_close()
765 spin_lock(&delegation->lock); in nfs4_inode_return_delegation_on_close()
766 if (delegation->inode && in nfs4_inode_return_delegation_on_close()
768 !test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) { in nfs4_inode_return_delegation_on_close()
769 clear_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags); in nfs4_inode_return_delegation_on_close()
771 ret = nfs_get_delegation(delegation); in nfs4_inode_return_delegation_on_close()
773 spin_unlock(&delegation->lock); in nfs4_inode_return_delegation_on_close()
786 * Make the inode writeable by returning the delegation if necessary
792 struct nfs_delegation *delegation; in nfs4_inode_make_writeable() local
795 delegation = nfs4_get_valid_delegation(inode); in nfs4_inode_make_writeable()
796 if (delegation == NULL || in nfs4_inode_make_writeable()
798 (delegation->type & FMODE_WRITE))) { in nfs4_inode_make_writeable()
807 struct nfs_delegation *delegation) in nfs_mark_return_if_closed_delegation() argument
809 set_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags); in nfs_mark_return_if_closed_delegation()
815 struct nfs_delegation *delegation; in nfs_server_mark_return_all_delegations() local
818 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_server_mark_return_all_delegations()
819 nfs_mark_return_delegation(server, delegation); in nfs_server_mark_return_all_delegations()
878 struct nfs_delegation *delegation; in nfs_mark_return_unused_delegation_types() local
880 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_mark_return_unused_delegation_types()
881 if ((delegation->type == (FMODE_READ|FMODE_WRITE)) && !(flags & FMODE_WRITE)) in nfs_mark_return_unused_delegation_types()
883 if (delegation->type & flags) in nfs_mark_return_unused_delegation_types()
884 nfs_mark_return_if_closed_delegation(server, delegation); in nfs_mark_return_unused_delegation_types()
902 struct nfs_delegation *delegation; in nfs_revoke_delegation() local
907 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs_revoke_delegation()
908 if (delegation == NULL) in nfs_revoke_delegation()
911 nfs4_stateid_copy(&tmp, &delegation->stateid); in nfs_revoke_delegation()
914 if (!nfs4_stateid_match_other(stateid, &delegation->stateid)) in nfs_revoke_delegation()
916 spin_lock(&delegation->lock); in nfs_revoke_delegation()
918 if (nfs4_stateid_is_newer(&delegation->stateid, stateid)) { in nfs_revoke_delegation()
919 spin_unlock(&delegation->lock); in nfs_revoke_delegation()
922 delegation->stateid.seqid = stateid->seqid; in nfs_revoke_delegation()
924 spin_unlock(&delegation->lock); in nfs_revoke_delegation()
926 nfs_mark_delegation_revoked(delegation); in nfs_revoke_delegation()
944 struct nfs_delegation *delegation; in nfs_delegation_mark_returned() local
950 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs_delegation_mark_returned()
951 if (!delegation) in nfs_delegation_mark_returned()
954 spin_lock(&delegation->lock); in nfs_delegation_mark_returned()
955 if (!nfs4_stateid_match_other(stateid, &delegation->stateid)) in nfs_delegation_mark_returned()
958 /* If delegation->stateid is newer, dont mark as returned */ in nfs_delegation_mark_returned()
959 if (nfs4_stateid_is_newer(&delegation->stateid, stateid)) in nfs_delegation_mark_returned()
961 if (delegation->stateid.seqid != stateid->seqid) in nfs_delegation_mark_returned()
962 delegation->stateid.seqid = stateid->seqid; in nfs_delegation_mark_returned()
965 nfs_mark_delegation_revoked(delegation); in nfs_delegation_mark_returned()
968 clear_bit(NFS_DELEGATION_RETURNING, &delegation->flags); in nfs_delegation_mark_returned()
970 spin_unlock(&delegation->lock); in nfs_delegation_mark_returned()
980 * @flags: delegation types to expire
991 struct nfs_delegation *delegation; in nfs_mark_return_unreferenced_delegations() local
993 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_mark_return_unreferenced_delegations()
994 if (test_and_clear_bit(NFS_DELEGATION_REFERENCED, &delegation->flags)) in nfs_mark_return_unreferenced_delegations()
996 nfs_mark_return_if_closed_delegation(server, delegation); in nfs_mark_return_unreferenced_delegations()
1018 * nfs_async_inode_return_delegation - asynchronously return a delegation
1029 struct nfs_delegation *delegation; in nfs_async_inode_return_delegation() local
1032 delegation = nfs4_get_valid_delegation(inode); in nfs_async_inode_return_delegation()
1033 if (delegation == NULL) in nfs_async_inode_return_delegation()
1036 !clp->cl_mvops->match_stateid(&delegation->stateid, stateid)) in nfs_async_inode_return_delegation()
1038 nfs_mark_return_delegation(server, delegation); in nfs_async_inode_return_delegation()
1052 struct nfs_delegation *delegation; in nfs_delegation_find_inode_server() local
1056 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_delegation_find_inode_server()
1057 spin_lock(&delegation->lock); in nfs_delegation_find_inode_server()
1058 if (delegation->inode != NULL && in nfs_delegation_find_inode_server()
1059 !test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) && in nfs_delegation_find_inode_server()
1060 nfs_compare_fh(fhandle, &NFS_I(delegation->inode)->fh) == 0) { in nfs_delegation_find_inode_server()
1063 res = igrab(delegation->inode); in nfs_delegation_find_inode_server()
1065 spin_unlock(&delegation->lock); in nfs_delegation_find_inode_server()
1075 spin_unlock(&delegation->lock); in nfs_delegation_find_inode_server()
1081 * nfs_delegation_find_inode - retrieve the inode associated with a delegation
1083 * @fhandle: filehandle from a delegation recall
1108 struct nfs_delegation *delegation; in nfs_delegation_mark_reclaim_server() local
1110 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_delegation_mark_reclaim_server()
1112 * If the delegation may have been admin revoked, then we in nfs_delegation_mark_reclaim_server()
1115 if (test_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags)) in nfs_delegation_mark_reclaim_server()
1117 set_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags); in nfs_delegation_mark_reclaim_server()
1139 struct nfs_delegation *delegation; in nfs_server_reap_unclaimed_delegations() local
1144 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_server_reap_unclaimed_delegations()
1146 &delegation->flags) || in nfs_server_reap_unclaimed_delegations()
1148 &delegation->flags) || in nfs_server_reap_unclaimed_delegations()
1150 &delegation->flags) == 0) in nfs_server_reap_unclaimed_delegations()
1152 inode = nfs_delegation_grab_inode(delegation); in nfs_server_reap_unclaimed_delegations()
1155 delegation = nfs_start_delegation_return_locked(NFS_I(inode)); in nfs_server_reap_unclaimed_delegations()
1157 if (delegation != NULL) { in nfs_server_reap_unclaimed_delegations()
1158 if (nfs_detach_delegation(NFS_I(inode), delegation, in nfs_server_reap_unclaimed_delegations()
1160 nfs_free_delegation(delegation); in nfs_server_reap_unclaimed_delegations()
1162 nfs_put_delegation(delegation); in nfs_server_reap_unclaimed_delegations()
1191 struct nfs_delegation *delegation) in nfs_mark_test_expired_delegation() argument
1193 if (delegation->stateid.type == NFS4_INVALID_STATEID_TYPE) in nfs_mark_test_expired_delegation()
1195 clear_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags); in nfs_mark_test_expired_delegation()
1196 set_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags); in nfs_mark_test_expired_delegation()
1203 struct nfs_delegation *delegation; in nfs_inode_mark_test_expired_delegation() local
1206 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs_inode_mark_test_expired_delegation()
1207 if (delegation) in nfs_inode_mark_test_expired_delegation()
1208 nfs_mark_test_expired_delegation(server, delegation); in nfs_inode_mark_test_expired_delegation()
1215 struct nfs_delegation *delegation; in nfs_delegation_mark_test_expired_server() local
1217 list_for_each_entry_rcu(delegation, &server->delegations, super_list) in nfs_delegation_mark_test_expired_server()
1218 nfs_mark_test_expired_delegation(server, delegation); in nfs_delegation_mark_test_expired_server()
1269 struct nfs_delegation *delegation; in nfs_server_reap_expired_delegations() local
1276 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_server_reap_expired_delegations()
1278 &delegation->flags) || in nfs_server_reap_expired_delegations()
1280 &delegation->flags) || in nfs_server_reap_expired_delegations()
1282 &delegation->flags) == 0) in nfs_server_reap_expired_delegations()
1284 inode = nfs_delegation_grab_inode(delegation); in nfs_server_reap_expired_delegations()
1287 spin_lock(&delegation->lock); in nfs_server_reap_expired_delegations()
1288 cred = get_cred_rcu(delegation->cred); in nfs_server_reap_expired_delegations()
1289 nfs4_stateid_copy(&stateid, &delegation->stateid); in nfs_server_reap_expired_delegations()
1290 spin_unlock(&delegation->lock); in nfs_server_reap_expired_delegations()
1291 clear_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags); in nfs_server_reap_expired_delegations()
1327 struct nfs_delegation *delegation; in nfs_inode_find_delegation_state_and_recover() local
1331 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs_inode_find_delegation_state_and_recover()
1332 if (delegation && in nfs_inode_find_delegation_state_and_recover()
1333 nfs4_stateid_match_or_older(&delegation->stateid, stateid) && in nfs_inode_find_delegation_state_and_recover()
1334 !test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { in nfs_inode_find_delegation_state_and_recover()
1335 nfs_mark_test_expired_delegation(NFS_SERVER(inode), delegation); in nfs_inode_find_delegation_state_and_recover()
1366 * nfs4_refresh_delegation_stateid - Update delegation stateid seqid
1370 * Returns "true" and updates "dst->seqid" * if inode had a delegation
1371 * that matches our delegation stateid. Otherwise "false" is returned.
1375 struct nfs_delegation *delegation; in nfs4_refresh_delegation_stateid() local
1381 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs4_refresh_delegation_stateid()
1382 if (delegation != NULL && in nfs4_refresh_delegation_stateid()
1383 nfs4_stateid_match_other(dst, &delegation->stateid) && in nfs4_refresh_delegation_stateid()
1384 nfs4_stateid_is_newer(&delegation->stateid, dst) && in nfs4_refresh_delegation_stateid()
1385 !test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { in nfs4_refresh_delegation_stateid()
1386 dst->seqid = delegation->stateid.seqid; in nfs4_refresh_delegation_stateid()
1397 * @flags: delegation type requirement
1401 * Returns "true" and fills in "dst->data" * if inode had a delegation,
1408 struct nfs_delegation *delegation; in nfs4_copy_delegation_stateid() local
1413 delegation = rcu_dereference(nfsi->delegation); in nfs4_copy_delegation_stateid()
1414 if (!delegation) in nfs4_copy_delegation_stateid()
1416 spin_lock(&delegation->lock); in nfs4_copy_delegation_stateid()
1417 ret = nfs4_is_valid_delegation(delegation, flags); in nfs4_copy_delegation_stateid()
1419 nfs4_stateid_copy(dst, &delegation->stateid); in nfs4_copy_delegation_stateid()
1420 nfs_mark_delegation_referenced(delegation); in nfs4_copy_delegation_stateid()
1422 *cred = get_cred(delegation->cred); in nfs4_copy_delegation_stateid()
1424 spin_unlock(&delegation->lock); in nfs4_copy_delegation_stateid()
1435 * against the delegation 'space_limit' field to see if
1441 struct nfs_delegation *delegation; in nfs4_delegation_flush_on_close() local
1445 delegation = rcu_dereference(nfsi->delegation); in nfs4_delegation_flush_on_close()
1446 if (delegation == NULL || !(delegation->type & FMODE_WRITE)) in nfs4_delegation_flush_on_close()
1448 if (atomic_long_read(&nfsi->nrequests) < delegation->pagemod_limit) in nfs4_delegation_flush_on_close()