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 * nfs4_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 (delegation->inode && in nfs_start_delegation_return_locked()
301 !test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) { in nfs_start_delegation_return_locked()
302 clear_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags); in nfs_start_delegation_return_locked()
304 ret = nfs_get_delegation(delegation); in nfs_start_delegation_return_locked()
306 spin_unlock(&delegation->lock); in nfs_start_delegation_return_locked()
316 struct nfs_delegation *delegation; in nfs_start_delegation_return() local
319 delegation = nfs_start_delegation_return_locked(nfsi); in nfs_start_delegation_return()
321 return delegation; in nfs_start_delegation_return()
324 static void nfs_abort_delegation_return(struct nfs_delegation *delegation, in nfs_abort_delegation_return() argument
328 spin_lock(&delegation->lock); in nfs_abort_delegation_return()
329 clear_bit(NFS_DELEGATION_RETURNING, &delegation->flags); in nfs_abort_delegation_return()
331 set_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags); in nfs_abort_delegation_return()
334 spin_unlock(&delegation->lock); in nfs_abort_delegation_return()
339 struct nfs_delegation *delegation, in nfs_detach_delegation_locked() argument
343 rcu_dereference_protected(nfsi->delegation, in nfs_detach_delegation_locked()
346 if (deleg_cur == NULL || delegation != deleg_cur) in nfs_detach_delegation_locked()
349 spin_lock(&delegation->lock); in nfs_detach_delegation_locked()
350 if (!delegation->inode) { in nfs_detach_delegation_locked()
351 spin_unlock(&delegation->lock); in nfs_detach_delegation_locked()
354 list_del_rcu(&delegation->super_list); in nfs_detach_delegation_locked()
355 delegation->inode = NULL; in nfs_detach_delegation_locked()
356 rcu_assign_pointer(nfsi->delegation, NULL); in nfs_detach_delegation_locked()
357 spin_unlock(&delegation->lock); in nfs_detach_delegation_locked()
358 return delegation; in nfs_detach_delegation_locked()
362 struct nfs_delegation *delegation, in nfs_detach_delegation() argument
368 delegation = nfs_detach_delegation_locked(nfsi, delegation, clp); in nfs_detach_delegation()
370 return delegation; in nfs_detach_delegation()
378 struct nfs_delegation *delegation; in nfs_inode_detach_delegation() local
381 delegation = rcu_dereference(nfsi->delegation); in nfs_inode_detach_delegation()
382 if (delegation != NULL) in nfs_inode_detach_delegation()
383 delegation = nfs_detach_delegation(nfsi, delegation, server); in nfs_inode_detach_delegation()
385 return delegation; in nfs_inode_detach_delegation()
389 nfs_update_delegation_cred(struct nfs_delegation *delegation, in nfs_update_delegation_cred() argument
394 if (cred_fscmp(delegation->cred, cred) != 0) { in nfs_update_delegation_cred()
395 old = xchg(&delegation->cred, get_cred(cred)); in nfs_update_delegation_cred()
401 nfs_update_inplace_delegation(struct nfs_delegation *delegation, in nfs_update_inplace_delegation() argument
404 if (nfs4_stateid_is_newer(&update->stateid, &delegation->stateid)) { in nfs_update_inplace_delegation()
405 delegation->stateid.seqid = update->stateid.seqid; in nfs_update_inplace_delegation()
407 delegation->type = update->type; in nfs_update_inplace_delegation()
408 delegation->pagemod_limit = update->pagemod_limit; in nfs_update_inplace_delegation()
409 if (test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { in nfs_update_inplace_delegation()
410 delegation->change_attr = update->change_attr; in nfs_update_inplace_delegation()
411 nfs_update_delegation_cred(delegation, update->cred); in nfs_update_inplace_delegation()
413 clear_bit(NFS_DELEGATION_REVOKED, &delegation->flags); in nfs_update_inplace_delegation()
420 * nfs_inode_set_delegation - set up a delegation on an inode
421 * @inode: inode to which delegation applies
422 * @cred: cred to use for subsequent delegation processing
423 * @type: delegation type
424 * @stateid: delegation stateid
425 * @pagemod_limit: write delegation "space_limit"
437 struct nfs_delegation *delegation, *old_delegation; in nfs_inode_set_delegation() local
441 delegation = kmalloc(sizeof(*delegation), GFP_KERNEL_ACCOUNT); in nfs_inode_set_delegation()
442 if (delegation == NULL) in nfs_inode_set_delegation()
444 nfs4_stateid_copy(&delegation->stateid, stateid); in nfs_inode_set_delegation()
445 refcount_set(&delegation->refcount, 1); in nfs_inode_set_delegation()
446 delegation->type = type; in nfs_inode_set_delegation()
447 delegation->pagemod_limit = pagemod_limit; in nfs_inode_set_delegation()
448 delegation->change_attr = inode_peek_iversion_raw(inode); in nfs_inode_set_delegation()
449 delegation->cred = get_cred(cred); in nfs_inode_set_delegation()
450 delegation->inode = inode; in nfs_inode_set_delegation()
451 delegation->flags = 1<<NFS_DELEGATION_REFERENCED; in nfs_inode_set_delegation()
452 spin_lock_init(&delegation->lock); in nfs_inode_set_delegation()
455 old_delegation = rcu_dereference_protected(nfsi->delegation, in nfs_inode_set_delegation()
459 /* Is this an update of the existing delegation? */ in nfs_inode_set_delegation()
461 &delegation->stateid)) { in nfs_inode_set_delegation()
464 delegation); in nfs_inode_set_delegation()
472 * Allow for upgrades to a WRITE delegation, but in nfs_inode_set_delegation()
476 "a duplicate delegation!\n", in nfs_inode_set_delegation()
478 if (delegation->type == old_delegation->type || in nfs_inode_set_delegation()
479 !(delegation->type & FMODE_WRITE)) { in nfs_inode_set_delegation()
480 freeme = delegation; in nfs_inode_set_delegation()
481 delegation = NULL; in nfs_inode_set_delegation()
494 * the delegation, then pre-emptively ask for a full attribute in nfs_inode_set_delegation()
508 list_add_tail_rcu(&delegation->super_list, &server->delegations); in nfs_inode_set_delegation()
509 rcu_assign_pointer(nfsi->delegation, delegation); in nfs_inode_set_delegation()
510 delegation = NULL; in nfs_inode_set_delegation()
517 if (delegation != NULL) in nfs_inode_set_delegation()
518 __nfs_free_delegation(delegation); in nfs_inode_set_delegation()
527 * Basic procedure for returning a delegation to the server
529 static int nfs_end_delegation_return(struct inode *inode, struct nfs_delegation *delegation, int is… in nfs_end_delegation_return() argument
535 if (delegation == NULL) in nfs_end_delegation_return()
544 if (test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) in nfs_end_delegation_return()
546 err = nfs_delegation_claim_opens(inode, &delegation->stateid, in nfs_end_delegation_return()
547 delegation->type); in nfs_end_delegation_return()
557 nfs_abort_delegation_return(delegation, clp, err); in nfs_end_delegation_return()
561 err = nfs_do_return_delegation(inode, delegation, issync); in nfs_end_delegation_return()
564 nfs_put_delegation(delegation); in nfs_end_delegation_return()
568 static bool nfs_delegation_need_return(struct nfs_delegation *delegation) in nfs_delegation_need_return() argument
572 if (test_and_clear_bit(NFS_DELEGATION_RETURN, &delegation->flags)) in nfs_delegation_need_return()
574 if (test_bit(NFS_DELEGATION_RETURNING, &delegation->flags) || in nfs_delegation_need_return()
575 test_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags) || in nfs_delegation_need_return()
576 test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) in nfs_delegation_need_return()
585 struct nfs_delegation *delegation; in nfs_server_return_marked_delegations() local
596 * list delegation in the server from the delegations in nfs_server_return_marked_delegations()
598 * prev is an RCU-protected pointer to a delegation which in nfs_server_return_marked_delegations()
603 delegation = NULL; in nfs_server_return_marked_delegations()
606 delegation = rcu_dereference(NFS_I(place_holder)->delegation); in nfs_server_return_marked_delegations()
607 if (!delegation || delegation != place_holder_deleg) in nfs_server_return_marked_delegations()
608 delegation = list_entry_rcu(server->delegations.next, in nfs_server_return_marked_delegations()
610 list_for_each_entry_from_rcu(delegation, &server->delegations, super_list) { in nfs_server_return_marked_delegations()
613 if (test_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags)) in nfs_server_return_marked_delegations()
615 if (!nfs_delegation_need_return(delegation)) { in nfs_server_return_marked_delegations()
616 if (nfs4_is_valid_delegation(delegation, 0)) in nfs_server_return_marked_delegations()
617 prev = delegation; in nfs_server_return_marked_delegations()
620 inode = nfs_delegation_grab_inode(delegation); in nfs_server_return_marked_delegations()
633 delegation = nfs_start_delegation_return_locked(NFS_I(inode)); in nfs_server_return_marked_delegations()
638 err = nfs_end_delegation_return(inode, delegation, 0); in nfs_server_return_marked_delegations()
707 * nfs_inode_evict_delegation - return delegation, don't reclaim opens
710 * Does not protect against delegation reclaims, therefore really only safe
712 * the delegation structure.
716 struct nfs_delegation *delegation; in nfs_inode_evict_delegation() local
718 delegation = nfs_inode_detach_delegation(inode); in nfs_inode_evict_delegation()
719 if (delegation != NULL) { in nfs_inode_evict_delegation()
720 set_bit(NFS_DELEGATION_RETURNING, &delegation->flags); in nfs_inode_evict_delegation()
721 set_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags); in nfs_inode_evict_delegation()
722 nfs_do_return_delegation(inode, delegation, 1); in nfs_inode_evict_delegation()
723 nfs_free_delegation(delegation); in nfs_inode_evict_delegation()
728 * nfs4_inode_return_delegation - synchronously return a delegation
732 * assumption that if we need to return the delegation, then
740 struct nfs_delegation *delegation; in nfs4_inode_return_delegation() local
742 delegation = nfs_start_delegation_return(nfsi); in nfs4_inode_return_delegation()
743 if (delegation != NULL) { in nfs4_inode_return_delegation()
748 return nfs_end_delegation_return(inode, delegation, 1); in nfs4_inode_return_delegation()
754 * nfs4_inode_return_delegation_on_close - asynchronously return a delegation
758 * inode delegation needs to be returned immediately.
762 struct nfs_delegation *delegation; in nfs4_inode_return_delegation_on_close() local
768 delegation = nfs4_get_valid_delegation(inode); in nfs4_inode_return_delegation_on_close()
769 if (!delegation) in nfs4_inode_return_delegation_on_close()
771 if (test_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags) || in nfs4_inode_return_delegation_on_close()
773 spin_lock(&delegation->lock); in nfs4_inode_return_delegation_on_close()
774 if (delegation->inode && in nfs4_inode_return_delegation_on_close()
776 !test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) { in nfs4_inode_return_delegation_on_close()
777 clear_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags); in nfs4_inode_return_delegation_on_close()
779 ret = nfs_get_delegation(delegation); in nfs4_inode_return_delegation_on_close()
781 spin_unlock(&delegation->lock); in nfs4_inode_return_delegation_on_close()
794 * Make the inode writeable by returning the delegation if necessary
800 struct nfs_delegation *delegation; in nfs4_inode_make_writeable() local
803 delegation = nfs4_get_valid_delegation(inode); in nfs4_inode_make_writeable()
804 if (delegation == NULL || in nfs4_inode_make_writeable()
806 (delegation->type & FMODE_WRITE))) { in nfs4_inode_make_writeable()
816 struct nfs_delegation *delegation) in nfs_mark_return_if_closed_delegation() argument
820 if (test_bit(NFS_DELEGATION_RETURN, &delegation->flags) || in nfs_mark_return_if_closed_delegation()
821 test_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags)) in nfs_mark_return_if_closed_delegation()
823 spin_lock(&delegation->lock); in nfs_mark_return_if_closed_delegation()
824 inode = delegation->inode; in nfs_mark_return_if_closed_delegation()
828 nfs_mark_return_delegation(server, delegation); in nfs_mark_return_if_closed_delegation()
830 set_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags); in nfs_mark_return_if_closed_delegation()
832 spin_unlock(&delegation->lock); in nfs_mark_return_if_closed_delegation()
837 struct nfs_delegation *delegation; in nfs_server_mark_return_all_delegations() local
840 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_server_mark_return_all_delegations()
841 nfs_mark_return_delegation(server, delegation); in nfs_server_mark_return_all_delegations()
900 struct nfs_delegation *delegation; in nfs_mark_return_unused_delegation_types() local
902 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_mark_return_unused_delegation_types()
903 if ((delegation->type == (FMODE_READ|FMODE_WRITE)) && !(flags & FMODE_WRITE)) in nfs_mark_return_unused_delegation_types()
905 if (delegation->type & flags) in nfs_mark_return_unused_delegation_types()
906 nfs_mark_return_if_closed_delegation(server, delegation); in nfs_mark_return_unused_delegation_types()
924 struct nfs_delegation *delegation; in nfs_revoke_delegation() local
929 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs_revoke_delegation()
930 if (delegation == NULL) in nfs_revoke_delegation()
933 nfs4_stateid_copy(&tmp, &delegation->stateid); in nfs_revoke_delegation()
936 if (!nfs4_stateid_match_other(stateid, &delegation->stateid)) in nfs_revoke_delegation()
938 spin_lock(&delegation->lock); in nfs_revoke_delegation()
940 if (nfs4_stateid_is_newer(&delegation->stateid, stateid)) { in nfs_revoke_delegation()
941 spin_unlock(&delegation->lock); in nfs_revoke_delegation()
944 delegation->stateid.seqid = stateid->seqid; in nfs_revoke_delegation()
946 spin_unlock(&delegation->lock); in nfs_revoke_delegation()
948 nfs_mark_delegation_revoked(delegation); in nfs_revoke_delegation()
966 struct nfs_delegation *delegation; in nfs_delegation_mark_returned() local
972 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs_delegation_mark_returned()
973 if (!delegation) in nfs_delegation_mark_returned()
976 spin_lock(&delegation->lock); in nfs_delegation_mark_returned()
977 if (!nfs4_stateid_match_other(stateid, &delegation->stateid)) in nfs_delegation_mark_returned()
980 /* If delegation->stateid is newer, dont mark as returned */ in nfs_delegation_mark_returned()
981 if (nfs4_stateid_is_newer(&delegation->stateid, stateid)) in nfs_delegation_mark_returned()
983 if (delegation->stateid.seqid != stateid->seqid) in nfs_delegation_mark_returned()
984 delegation->stateid.seqid = stateid->seqid; in nfs_delegation_mark_returned()
987 nfs_mark_delegation_revoked(delegation); in nfs_delegation_mark_returned()
988 clear_bit(NFS_DELEGATION_RETURNING, &delegation->flags); in nfs_delegation_mark_returned()
989 spin_unlock(&delegation->lock); in nfs_delegation_mark_returned()
990 if (nfs_detach_delegation(NFS_I(inode), delegation, NFS_SERVER(inode))) in nfs_delegation_mark_returned()
991 nfs_put_delegation(delegation); in nfs_delegation_mark_returned()
995 clear_bit(NFS_DELEGATION_RETURNING, &delegation->flags); in nfs_delegation_mark_returned()
997 spin_unlock(&delegation->lock); in nfs_delegation_mark_returned()
1007 * @flags: delegation types to expire
1018 struct nfs_delegation *delegation; in nfs_mark_return_unreferenced_delegations() local
1020 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_mark_return_unreferenced_delegations()
1021 if (test_and_clear_bit(NFS_DELEGATION_REFERENCED, &delegation->flags)) in nfs_mark_return_unreferenced_delegations()
1023 nfs_mark_return_if_closed_delegation(server, delegation); in nfs_mark_return_unreferenced_delegations()
1045 * nfs_async_inode_return_delegation - asynchronously return a delegation
1056 struct nfs_delegation *delegation; in nfs_async_inode_return_delegation() local
1059 delegation = nfs4_get_valid_delegation(inode); in nfs_async_inode_return_delegation()
1060 if (delegation == NULL) in nfs_async_inode_return_delegation()
1063 !clp->cl_mvops->match_stateid(&delegation->stateid, stateid)) in nfs_async_inode_return_delegation()
1065 nfs_mark_return_delegation(server, delegation); in nfs_async_inode_return_delegation()
1082 struct nfs_delegation *delegation; in nfs_delegation_find_inode_server() local
1086 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_delegation_find_inode_server()
1087 spin_lock(&delegation->lock); in nfs_delegation_find_inode_server()
1088 if (delegation->inode != NULL && in nfs_delegation_find_inode_server()
1089 !test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) && in nfs_delegation_find_inode_server()
1090 nfs_compare_fh(fhandle, &NFS_I(delegation->inode)->fh) == 0) { in nfs_delegation_find_inode_server()
1093 res = igrab(delegation->inode); in nfs_delegation_find_inode_server()
1095 spin_unlock(&delegation->lock); in nfs_delegation_find_inode_server()
1105 spin_unlock(&delegation->lock); in nfs_delegation_find_inode_server()
1111 * nfs_delegation_find_inode - retrieve the inode associated with a delegation
1113 * @fhandle: filehandle from a delegation recall
1138 struct nfs_delegation *delegation; in nfs_delegation_mark_reclaim_server() local
1140 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_delegation_mark_reclaim_server()
1142 * If the delegation may have been admin revoked, then we in nfs_delegation_mark_reclaim_server()
1145 if (test_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags)) in nfs_delegation_mark_reclaim_server()
1147 set_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags); in nfs_delegation_mark_reclaim_server()
1169 struct nfs_delegation *delegation; in nfs_server_reap_unclaimed_delegations() local
1173 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_server_reap_unclaimed_delegations()
1175 &delegation->flags) || in nfs_server_reap_unclaimed_delegations()
1177 &delegation->flags) || in nfs_server_reap_unclaimed_delegations()
1179 &delegation->flags) == 0) in nfs_server_reap_unclaimed_delegations()
1181 inode = nfs_delegation_grab_inode(delegation); in nfs_server_reap_unclaimed_delegations()
1184 delegation = nfs_start_delegation_return_locked(NFS_I(inode)); in nfs_server_reap_unclaimed_delegations()
1186 if (delegation != NULL) { in nfs_server_reap_unclaimed_delegations()
1187 if (nfs_detach_delegation(NFS_I(inode), delegation, in nfs_server_reap_unclaimed_delegations()
1189 nfs_free_delegation(delegation); in nfs_server_reap_unclaimed_delegations()
1191 nfs_put_delegation(delegation); in nfs_server_reap_unclaimed_delegations()
1220 struct nfs_delegation *delegation) in nfs_mark_test_expired_delegation() argument
1222 if (delegation->stateid.type == NFS4_INVALID_STATEID_TYPE) in nfs_mark_test_expired_delegation()
1224 clear_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags); in nfs_mark_test_expired_delegation()
1225 set_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags); in nfs_mark_test_expired_delegation()
1232 struct nfs_delegation *delegation; in nfs_inode_mark_test_expired_delegation() local
1235 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs_inode_mark_test_expired_delegation()
1236 if (delegation) in nfs_inode_mark_test_expired_delegation()
1237 nfs_mark_test_expired_delegation(server, delegation); in nfs_inode_mark_test_expired_delegation()
1244 struct nfs_delegation *delegation; in nfs_delegation_mark_test_expired_server() local
1246 list_for_each_entry_rcu(delegation, &server->delegations, super_list) in nfs_delegation_mark_test_expired_server()
1247 nfs_mark_test_expired_delegation(server, delegation); in nfs_delegation_mark_test_expired_server()
1298 struct nfs_delegation *delegation; in nfs_server_reap_expired_delegations() local
1304 list_for_each_entry_rcu(delegation, &server->delegations, super_list) { in nfs_server_reap_expired_delegations()
1306 &delegation->flags) || in nfs_server_reap_expired_delegations()
1308 &delegation->flags) || in nfs_server_reap_expired_delegations()
1310 &delegation->flags) == 0) in nfs_server_reap_expired_delegations()
1312 inode = nfs_delegation_grab_inode(delegation); in nfs_server_reap_expired_delegations()
1315 spin_lock(&delegation->lock); in nfs_server_reap_expired_delegations()
1316 cred = get_cred_rcu(delegation->cred); in nfs_server_reap_expired_delegations()
1317 nfs4_stateid_copy(&stateid, &delegation->stateid); in nfs_server_reap_expired_delegations()
1318 spin_unlock(&delegation->lock); in nfs_server_reap_expired_delegations()
1319 clear_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags); in nfs_server_reap_expired_delegations()
1355 struct nfs_delegation *delegation; in nfs_inode_find_delegation_state_and_recover() local
1359 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs_inode_find_delegation_state_and_recover()
1360 if (delegation && in nfs_inode_find_delegation_state_and_recover()
1361 nfs4_stateid_match_or_older(&delegation->stateid, stateid) && in nfs_inode_find_delegation_state_and_recover()
1362 !test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { in nfs_inode_find_delegation_state_and_recover()
1363 nfs_mark_test_expired_delegation(NFS_SERVER(inode), delegation); in nfs_inode_find_delegation_state_and_recover()
1394 * nfs4_refresh_delegation_stateid - Update delegation stateid seqid
1398 * Returns "true" and updates "dst->seqid" * if inode had a delegation
1399 * that matches our delegation stateid. Otherwise "false" is returned.
1403 struct nfs_delegation *delegation; in nfs4_refresh_delegation_stateid() local
1409 delegation = rcu_dereference(NFS_I(inode)->delegation); in nfs4_refresh_delegation_stateid()
1410 if (delegation != NULL && in nfs4_refresh_delegation_stateid()
1411 nfs4_stateid_match_other(dst, &delegation->stateid) && in nfs4_refresh_delegation_stateid()
1412 nfs4_stateid_is_newer(&delegation->stateid, dst) && in nfs4_refresh_delegation_stateid()
1413 !test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { in nfs4_refresh_delegation_stateid()
1414 dst->seqid = delegation->stateid.seqid; in nfs4_refresh_delegation_stateid()
1425 * @flags: delegation type requirement
1429 * Returns "true" and fills in "dst->data" * if inode had a delegation,
1436 struct nfs_delegation *delegation; in nfs4_copy_delegation_stateid() local
1441 delegation = rcu_dereference(nfsi->delegation); in nfs4_copy_delegation_stateid()
1442 if (!delegation) in nfs4_copy_delegation_stateid()
1444 spin_lock(&delegation->lock); in nfs4_copy_delegation_stateid()
1445 ret = nfs4_is_valid_delegation(delegation, flags); in nfs4_copy_delegation_stateid()
1447 nfs4_stateid_copy(dst, &delegation->stateid); in nfs4_copy_delegation_stateid()
1448 nfs_mark_delegation_referenced(delegation); in nfs4_copy_delegation_stateid()
1450 *cred = get_cred(delegation->cred); in nfs4_copy_delegation_stateid()
1452 spin_unlock(&delegation->lock); in nfs4_copy_delegation_stateid()
1463 * against the delegation 'space_limit' field to see if
1469 struct nfs_delegation *delegation; in nfs4_delegation_flush_on_close() local
1473 delegation = rcu_dereference(nfsi->delegation); in nfs4_delegation_flush_on_close()
1474 if (delegation == NULL || !(delegation->type & FMODE_WRITE)) in nfs4_delegation_flush_on_close()
1476 if (atomic_long_read(&nfsi->nrequests) < delegation->pagemod_limit) in nfs4_delegation_flush_on_close()