• Home
  • Raw
  • Download

Lines Matching +full:embedded +full:- +full:trace +full:- +full:extension

54 #include "trace.h"
101 * A waitqueue for all in-progress 4.0 CLOSE operations that are waiting for
128 return ses->se_flags & NFS4_SESSION_DEAD; in is_session_dead()
133 if (atomic_read(&ses->se_ref) > ref_held_by_me) in mark_session_dead_locked()
135 ses->se_flags |= NFS4_SESSION_DEAD; in mark_session_dead_locked()
141 return clp->cl_time == 0; in is_client_expired()
146 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in get_client_locked()
148 lockdep_assert_held(&nn->client_lock); in get_client_locked()
152 atomic_inc(&clp->cl_rpc_users); in get_client_locked()
160 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in renew_client_locked()
166 clp->cl_clientid.cl_boot, in renew_client_locked()
167 clp->cl_clientid.cl_id); in renew_client_locked()
171 list_move_tail(&clp->cl_lru, &nn->client_lru); in renew_client_locked()
172 clp->cl_time = ktime_get_boottime_seconds(); in renew_client_locked()
177 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in put_client_renew_locked()
179 lockdep_assert_held(&nn->client_lock); in put_client_renew_locked()
181 if (!atomic_dec_and_test(&clp->cl_rpc_users)) in put_client_renew_locked()
191 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in put_client_renew()
193 if (!atomic_dec_and_lock(&clp->cl_rpc_users, &nn->client_lock)) in put_client_renew()
199 spin_unlock(&nn->client_lock); in put_client_renew()
208 status = get_client_locked(ses->se_client); in nfsd4_get_session_locked()
211 atomic_inc(&ses->se_ref); in nfsd4_get_session_locked()
217 struct nfs4_client *clp = ses->se_client; in nfsd4_put_session_locked()
218 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in nfsd4_put_session_locked()
220 lockdep_assert_held(&nn->client_lock); in nfsd4_put_session_locked()
222 if (atomic_dec_and_test(&ses->se_ref) && is_session_dead(ses)) in nfsd4_put_session_locked()
229 struct nfs4_client *clp = ses->se_client; in nfsd4_put_session()
230 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in nfsd4_put_session()
232 spin_lock(&nn->client_lock); in nfsd4_put_session()
234 spin_unlock(&nn->client_lock); in nfsd4_put_session()
243 spin_lock(&nn->blocked_locks_lock); in find_blocked_lock()
244 list_for_each_entry(cur, &lo->lo_blocked, nbl_list) { in find_blocked_lock()
245 if (fh_match(fh, &cur->nbl_fh)) { in find_blocked_lock()
246 list_del_init(&cur->nbl_list); in find_blocked_lock()
247 list_del_init(&cur->nbl_lru); in find_blocked_lock()
252 spin_unlock(&nn->blocked_locks_lock); in find_blocked_lock()
254 locks_delete_block(&found->nbl_lock); in find_blocked_lock()
268 INIT_LIST_HEAD(&nbl->nbl_list); in find_or_allocate_block()
269 INIT_LIST_HEAD(&nbl->nbl_lru); in find_or_allocate_block()
270 fh_copy_shallow(&nbl->nbl_fh, fh); in find_or_allocate_block()
271 locks_init_lock(&nbl->nbl_lock); in find_or_allocate_block()
272 nfsd4_init_cb(&nbl->nbl_cb, lo->lo_owner.so_client, in find_or_allocate_block()
283 locks_delete_block(&nbl->nbl_lock); in free_blocked_lock()
284 locks_release_private(&nbl->nbl_lock); in free_blocked_lock()
291 struct nfs4_client *clp = lo->lo_owner.so_client; in remove_blocked_locks()
292 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in remove_blocked_locks()
297 spin_lock(&nn->blocked_locks_lock); in remove_blocked_locks()
298 while (!list_empty(&lo->lo_blocked)) { in remove_blocked_locks()
299 nbl = list_first_entry(&lo->lo_blocked, in remove_blocked_locks()
302 list_del_init(&nbl->nbl_list); in remove_blocked_locks()
303 list_move(&nbl->nbl_lru, &reaplist); in remove_blocked_locks()
305 spin_unlock(&nn->blocked_locks_lock); in remove_blocked_locks()
311 list_del_init(&nbl->nbl_lru); in remove_blocked_locks()
321 locks_delete_block(&nbl->nbl_lock); in nfsd4_cb_notify_lock_prepare()
332 switch (task->tk_status) { in nfsd4_cb_notify_lock_done()
333 case -NFS4ERR_DELAY: in nfsd4_cb_notify_lock_done()
359 atomic_inc(&sop->so_count); in nfs4_get_stateowner()
366 return (sop->so_owner.len == owner->len) && in same_owner_str()
367 0 == memcmp(sop->so_owner.data, owner->data, owner->len); in same_owner_str()
376 lockdep_assert_held(&clp->cl_lock); in find_openstateowner_str_locked()
378 list_for_each_entry(so, &clp->cl_ownerstr_hashtbl[hashval], in find_openstateowner_str_locked()
380 if (!so->so_is_open_owner) in find_openstateowner_str_locked()
382 if (same_owner_str(so, &open->op_owner)) in find_openstateowner_str_locked()
394 spin_lock(&clp->cl_lock); in find_openstateowner_str()
396 spin_unlock(&clp->cl_lock); in find_openstateowner_str()
406 while (nbytes--) { in opaque_hashval()
425 if (refcount_dec_and_lock(&fi->fi_ref, &state_lock)) { in put_nfs4_file()
426 hlist_del_rcu(&fi->fi_hash); in put_nfs4_file()
428 WARN_ON_ONCE(!list_empty(&fi->fi_clnt_odstate)); in put_nfs4_file()
429 WARN_ON_ONCE(!list_empty(&fi->fi_delegations)); in put_nfs4_file()
430 call_rcu(&fi->fi_rcu, nfsd4_free_file_rcu); in put_nfs4_file()
437 if (f->fi_fds[oflag]) in __nfs4_get_fd()
438 return nfsd_file_get(f->fi_fds[oflag]); in __nfs4_get_fd()
447 lockdep_assert_held(&f->fi_lock); in find_writeable_file_locked()
460 spin_lock(&f->fi_lock); in find_writeable_file()
462 spin_unlock(&f->fi_lock); in find_writeable_file()
472 lockdep_assert_held(&f->fi_lock); in find_readable_file_locked()
485 spin_lock(&f->fi_lock); in find_readable_file()
487 spin_unlock(&f->fi_lock); in find_readable_file()
499 spin_lock(&f->fi_lock); in find_any_file()
506 spin_unlock(&f->fi_lock); in find_any_file()
512 lockdep_assert_held(&f->fi_lock); in find_any_file_locked()
514 if (f->fi_fds[O_RDWR]) in find_any_file_locked()
515 return f->fi_fds[O_RDWR]; in find_any_file_locked()
516 if (f->fi_fds[O_WRONLY]) in find_any_file_locked()
517 return f->fi_fds[O_WRONLY]; in find_any_file_locked()
518 if (f->fi_fds[O_RDONLY]) in find_any_file_locked()
519 return f->fi_fds[O_RDONLY]; in find_any_file_locked()
525 lockdep_assert_held(&f->fi_lock); in find_deleg_file_locked()
527 if (f->fi_deleg_file) in find_deleg_file_locked()
528 return f->fi_deleg_file; in find_deleg_file_locked()
542 #define OWNER_HASH_MASK (OWNER_HASH_SIZE - 1)
548 ret = opaque_hashval(ownername->data, ownername->len); in ownerstr_hashval()
558 return jhash2(fh->fh_base.fh_pad, XDR_QUADLEN(fh->fh_size), 0); in nfsd_fh_hashval()
563 return nfsd_fh_hashval(fh) & (FILE_HASH_SIZE - 1); in file_hashval()
571 lockdep_assert_held(&fp->fi_lock); in __nfs4_file_get_access()
574 atomic_inc(&fp->fi_access[O_WRONLY]); in __nfs4_file_get_access()
576 atomic_inc(&fp->fi_access[O_RDONLY]); in __nfs4_file_get_access()
582 lockdep_assert_held(&fp->fi_lock); in nfs4_file_get_access()
589 if ((access & fp->fi_share_deny) != 0) in nfs4_file_get_access()
605 atomic_read(&fp->fi_access[O_RDONLY])) in nfs4_file_check_deny()
609 atomic_read(&fp->fi_access[O_WRONLY])) in nfs4_file_check_deny()
617 might_lock(&fp->fi_lock); in __nfs4_file_put_access()
619 if (atomic_dec_and_lock(&fp->fi_access[oflag], &fp->fi_lock)) { in __nfs4_file_put_access()
623 swap(f1, fp->fi_fds[oflag]); in __nfs4_file_put_access()
624 if (atomic_read(&fp->fi_access[1 - oflag]) == 0) in __nfs4_file_put_access()
625 swap(f2, fp->fi_fds[O_RDWR]); in __nfs4_file_put_access()
626 spin_unlock(&fp->fi_lock); in __nfs4_file_put_access()
648 * Note that we only allocate it for pNFS-enabled exports, otherwise
658 co->co_client = clp; in alloc_clnt_odstate()
659 refcount_set(&co->co_odcount, 1); in alloc_clnt_odstate()
667 struct nfs4_file *fp = co->co_file; in hash_clnt_odstate_locked()
669 lockdep_assert_held(&fp->fi_lock); in hash_clnt_odstate_locked()
670 list_add(&co->co_perfile, &fp->fi_clnt_odstate); in hash_clnt_odstate_locked()
677 refcount_inc(&co->co_odcount); in get_clnt_odstate()
688 fp = co->co_file; in put_clnt_odstate()
689 if (refcount_dec_and_lock(&co->co_odcount, &fp->fi_lock)) { in put_clnt_odstate()
690 list_del(&co->co_perfile); in put_clnt_odstate()
691 spin_unlock(&fp->fi_lock); in put_clnt_odstate()
693 nfsd4_return_all_file_layouts(co->co_client, fp); in put_clnt_odstate()
707 cl = new->co_client; in find_or_hash_clnt_odstate()
709 spin_lock(&fp->fi_lock); in find_or_hash_clnt_odstate()
710 list_for_each_entry(co, &fp->fi_clnt_odstate, co_perfile) { in find_or_hash_clnt_odstate()
711 if (co->co_client == cl) { in find_or_hash_clnt_odstate()
717 co->co_file = fp; in find_or_hash_clnt_odstate()
720 spin_unlock(&fp->fi_lock); in find_or_hash_clnt_odstate()
735 spin_lock(&cl->cl_lock); in nfs4_alloc_stid()
737 new_id = idr_alloc_cyclic(&cl->cl_stateids, stid, 1, 0, GFP_NOWAIT); in nfs4_alloc_stid()
738 spin_unlock(&cl->cl_lock); in nfs4_alloc_stid()
743 stid->sc_free = sc_free; in nfs4_alloc_stid()
744 stid->sc_client = cl; in nfs4_alloc_stid()
745 stid->sc_stateid.si_opaque.so_id = new_id; in nfs4_alloc_stid()
746 stid->sc_stateid.si_opaque.so_clid = cl->cl_clientid; in nfs4_alloc_stid()
748 refcount_set(&stid->sc_count, 1); in nfs4_alloc_stid()
749 spin_lock_init(&stid->sc_lock); in nfs4_alloc_stid()
750 INIT_LIST_HEAD(&stid->sc_cp_list); in nfs4_alloc_stid()
775 stid->stid.si_opaque.so_clid.cl_boot = (u32)nn->boot_time; in nfs4_init_cp_state()
776 stid->stid.si_opaque.so_clid.cl_id = nn->s2s_cp_cl_id; in nfs4_init_cp_state()
777 stid->sc_type = sc_type; in nfs4_init_cp_state()
780 spin_lock(&nn->s2s_cp_lock); in nfs4_init_cp_state()
781 new_id = idr_alloc_cyclic(&nn->s2s_cp_stateids, stid, 0, 0, GFP_NOWAIT); in nfs4_init_cp_state()
782 stid->stid.si_opaque.so_id = new_id; in nfs4_init_cp_state()
783 stid->stid.si_generation = 1; in nfs4_init_cp_state()
784 spin_unlock(&nn->s2s_cp_lock); in nfs4_init_cp_state()
793 return nfs4_init_cp_state(nn, &copy->cp_stateid, NFS4_COPY_STID); in nfs4_init_copy_state()
804 cps->cpntf_time = ktime_get_boottime_seconds(); in nfs4_alloc_init_cpntf_state()
805 refcount_set(&cps->cp_stateid.sc_count, 1); in nfs4_alloc_init_cpntf_state()
806 if (!nfs4_init_cp_state(nn, &cps->cp_stateid, NFS4_COPYNOTIFY_STID)) in nfs4_alloc_init_cpntf_state()
808 spin_lock(&nn->s2s_cp_lock); in nfs4_alloc_init_cpntf_state()
809 list_add(&cps->cp_list, &p_stid->sc_cp_list); in nfs4_alloc_init_cpntf_state()
810 spin_unlock(&nn->s2s_cp_lock); in nfs4_alloc_init_cpntf_state()
821 WARN_ON_ONCE(copy->cp_stateid.sc_type != NFS4_COPY_STID); in nfs4_free_copy_state()
822 nn = net_generic(copy->cp_clp->net, nfsd_net_id); in nfs4_free_copy_state()
823 spin_lock(&nn->s2s_cp_lock); in nfs4_free_copy_state()
824 idr_remove(&nn->s2s_cp_stateids, in nfs4_free_copy_state()
825 copy->cp_stateid.stid.si_opaque.so_id); in nfs4_free_copy_state()
826 spin_unlock(&nn->s2s_cp_lock); in nfs4_free_copy_state()
835 spin_lock(&nn->s2s_cp_lock); in nfs4_free_cpntf_statelist()
836 while (!list_empty(&stid->sc_cp_list)) { in nfs4_free_cpntf_statelist()
837 cps = list_first_entry(&stid->sc_cp_list, in nfs4_free_cpntf_statelist()
841 spin_unlock(&nn->s2s_cp_lock); in nfs4_free_cpntf_statelist()
857 WARN_ON(!list_empty(&stid->sc_cp_list)); in nfs4_free_deleg()
874 * low 3 bytes as hash-table indices.
893 if (bd->entries == 0) in delegation_blocked()
895 if (ktime_get_seconds() - bd->swap_time > 30) { in delegation_blocked()
897 if (ktime_get_seconds() - bd->swap_time > 30) { in delegation_blocked()
898 bd->entries -= bd->old_entries; in delegation_blocked()
899 bd->old_entries = bd->entries; in delegation_blocked()
900 memset(bd->set[bd->new], 0, in delegation_blocked()
901 sizeof(bd->set[0])); in delegation_blocked()
902 bd->new = 1-bd->new; in delegation_blocked()
903 bd->swap_time = ktime_get_seconds(); in delegation_blocked()
907 hash = jhash(&fh->fh_base, fh->fh_size, 0); in delegation_blocked()
908 if (test_bit(hash&255, bd->set[0]) && in delegation_blocked()
909 test_bit((hash>>8)&255, bd->set[0]) && in delegation_blocked()
910 test_bit((hash>>16)&255, bd->set[0])) in delegation_blocked()
913 if (test_bit(hash&255, bd->set[1]) && in delegation_blocked()
914 test_bit((hash>>8)&255, bd->set[1]) && in delegation_blocked()
915 test_bit((hash>>16)&255, bd->set[1])) in delegation_blocked()
926 hash = jhash(&fh->fh_base, fh->fh_size, 0); in block_delegations()
929 __set_bit(hash&255, bd->set[bd->new]); in block_delegations()
930 __set_bit((hash>>8)&255, bd->set[bd->new]); in block_delegations()
931 __set_bit((hash>>16)&255, bd->set[bd->new]); in block_delegations()
932 if (bd->entries == 0) in block_delegations()
933 bd->swap_time = ktime_get_seconds(); in block_delegations()
934 bd->entries += 1; in block_delegations()
950 if (delegation_blocked(&current_fh->fh_handle)) in alloc_init_deleg()
961 dp->dl_stid.sc_stateid.si_generation = 1; in alloc_init_deleg()
962 INIT_LIST_HEAD(&dp->dl_perfile); in alloc_init_deleg()
963 INIT_LIST_HEAD(&dp->dl_perclnt); in alloc_init_deleg()
964 INIT_LIST_HEAD(&dp->dl_recall_lru); in alloc_init_deleg()
965 dp->dl_clnt_odstate = odstate; in alloc_init_deleg()
967 dp->dl_type = NFS4_OPEN_DELEGATE_READ; in alloc_init_deleg()
968 dp->dl_retries = 1; in alloc_init_deleg()
969 nfsd4_init_cb(&dp->dl_recall, dp->dl_stid.sc_client, in alloc_init_deleg()
972 dp->dl_stid.sc_file = fp; in alloc_init_deleg()
982 struct nfs4_file *fp = s->sc_file; in nfs4_put_stid()
983 struct nfs4_client *clp = s->sc_client; in nfs4_put_stid()
985 might_lock(&clp->cl_lock); in nfs4_put_stid()
987 if (!refcount_dec_and_lock(&s->sc_count, &clp->cl_lock)) { in nfs4_put_stid()
991 idr_remove(&clp->cl_stateids, s->sc_stateid.si_opaque.so_id); in nfs4_put_stid()
992 nfs4_free_cpntf_statelist(clp->net, s); in nfs4_put_stid()
993 spin_unlock(&clp->cl_lock); in nfs4_put_stid()
994 s->sc_free(s); in nfs4_put_stid()
1002 stateid_t *src = &stid->sc_stateid; in nfs4_inc_and_copy_stateid()
1004 spin_lock(&stid->sc_lock); in nfs4_inc_and_copy_stateid()
1005 if (unlikely(++src->si_generation == 0)) in nfs4_inc_and_copy_stateid()
1006 src->si_generation = 1; in nfs4_inc_and_copy_stateid()
1008 spin_unlock(&stid->sc_lock); in nfs4_inc_and_copy_stateid()
1015 spin_lock(&fp->fi_lock); in put_deleg_file()
1016 if (--fp->fi_delegees == 0) in put_deleg_file()
1017 swap(nf, fp->fi_deleg_file); in put_deleg_file()
1018 spin_unlock(&fp->fi_lock); in put_deleg_file()
1026 struct nfs4_file *fp = dp->dl_stid.sc_file; in nfs4_unlock_deleg_lease()
1027 struct nfsd_file *nf = fp->fi_deleg_file; in nfs4_unlock_deleg_lease()
1029 WARN_ON_ONCE(!fp->fi_delegees); in nfs4_unlock_deleg_lease()
1031 vfs_setlease(nf->nf_file, F_UNLCK, NULL, (void **)&dp); in nfs4_unlock_deleg_lease()
1037 put_clnt_odstate(dp->dl_clnt_odstate); in destroy_unhashed_deleg()
1039 nfs4_put_stid(&dp->dl_stid); in destroy_unhashed_deleg()
1044 s->sc_type = 0; in nfs4_unhash_stid()
1048 * nfs4_delegation_exists - Discover if this delegation already exists
1063 lockdep_assert_held(&fp->fi_lock); in nfs4_delegation_exists()
1065 list_for_each_entry(searchdp, &fp->fi_delegations, dl_perfile) { in nfs4_delegation_exists()
1066 searchclp = searchdp->dl_stid.sc_client; in nfs4_delegation_exists()
1075 * hash_delegation_locked - Add a delegation to the appropriate lists
1082 * On error: -EAGAIN if one was previously granted to this
1090 struct nfs4_client *clp = dp->dl_stid.sc_client; in hash_delegation_locked()
1093 lockdep_assert_held(&fp->fi_lock); in hash_delegation_locked()
1096 return -EAGAIN; in hash_delegation_locked()
1097 refcount_inc(&dp->dl_stid.sc_count); in hash_delegation_locked()
1098 dp->dl_stid.sc_type = NFS4_DELEG_STID; in hash_delegation_locked()
1099 list_add(&dp->dl_perfile, &fp->fi_delegations); in hash_delegation_locked()
1100 list_add(&dp->dl_perclnt, &clp->cl_delegations); in hash_delegation_locked()
1106 return !(list_empty(&dp->dl_perfile)); in delegation_hashed()
1112 struct nfs4_file *fp = dp->dl_stid.sc_file; in unhash_delegation_locked()
1119 dp->dl_stid.sc_type = NFS4_CLOSED_DELEG_STID; in unhash_delegation_locked()
1121 ++dp->dl_time; in unhash_delegation_locked()
1122 spin_lock(&fp->fi_lock); in unhash_delegation_locked()
1123 list_del_init(&dp->dl_perclnt); in unhash_delegation_locked()
1124 list_del_init(&dp->dl_recall_lru); in unhash_delegation_locked()
1125 list_del_init(&dp->dl_perfile); in unhash_delegation_locked()
1126 spin_unlock(&fp->fi_lock); in unhash_delegation_locked()
1143 struct nfs4_client *clp = dp->dl_stid.sc_client; in revoke_delegation()
1145 WARN_ON(!list_empty(&dp->dl_recall_lru)); in revoke_delegation()
1147 if (clp->cl_minorversion) { in revoke_delegation()
1148 spin_lock(&clp->cl_lock); in revoke_delegation()
1149 dp->dl_stid.sc_type = NFS4_REVOKED_DELEG_STID; in revoke_delegation()
1150 refcount_inc(&dp->dl_stid.sc_count); in revoke_delegation()
1151 list_add(&dp->dl_recall_lru, &clp->cl_revoked); in revoke_delegation()
1152 spin_unlock(&clp->cl_lock); in revoke_delegation()
1208 stp->st_access_bmap |= mask; in set_access()
1218 stp->st_access_bmap &= ~mask; in clear_access()
1227 return (bool)(stp->st_access_bmap & mask); in test_access()
1237 stp->st_deny_bmap |= mask; in set_deny()
1247 stp->st_deny_bmap &= ~mask; in clear_deny()
1256 return (bool)(stp->st_deny_bmap & mask); in test_deny()
1282 spin_lock(&fp->fi_lock); in recalculate_deny_mode()
1283 fp->fi_share_deny = 0; in recalculate_deny_mode()
1284 list_for_each_entry(stp, &fp->fi_stateids, st_perfile) in recalculate_deny_mode()
1285 fp->fi_share_deny |= bmap_to_share_mode(stp->st_deny_bmap); in recalculate_deny_mode()
1286 spin_unlock(&fp->fi_lock); in recalculate_deny_mode()
1302 /* Recalculate per-file deny mode if there was a change */ in reset_union_bmap_deny()
1304 recalculate_deny_mode(stp->st_stid.sc_file); in reset_union_bmap_deny()
1312 struct nfs4_file *fp = stp->st_stid.sc_file; in release_all_access()
1314 if (fp && stp->st_deny_bmap != 0) in release_all_access()
1319 nfs4_file_put_access(stp->st_stid.sc_file, i); in release_all_access()
1326 kfree(sop->so_owner.data); in nfs4_free_stateowner()
1327 sop->so_ops->so_free(sop); in nfs4_free_stateowner()
1332 struct nfs4_client *clp = sop->so_client; in nfs4_put_stateowner()
1334 might_lock(&clp->cl_lock); in nfs4_put_stateowner()
1336 if (!atomic_dec_and_lock(&sop->so_count, &clp->cl_lock)) in nfs4_put_stateowner()
1338 sop->so_ops->so_unhash(sop); in nfs4_put_stateowner()
1339 spin_unlock(&clp->cl_lock); in nfs4_put_stateowner()
1346 return list_empty(&stp->st_perfile); in nfs4_ol_stateid_unhashed()
1351 struct nfs4_file *fp = stp->st_stid.sc_file; in unhash_ol_stateid()
1353 lockdep_assert_held(&stp->st_stateowner->so_client->cl_lock); in unhash_ol_stateid()
1355 if (list_empty(&stp->st_perfile)) in unhash_ol_stateid()
1358 spin_lock(&fp->fi_lock); in unhash_ol_stateid()
1359 list_del_init(&stp->st_perfile); in unhash_ol_stateid()
1360 spin_unlock(&fp->fi_lock); in unhash_ol_stateid()
1361 list_del(&stp->st_perstateowner); in unhash_ol_stateid()
1369 put_clnt_odstate(stp->st_clnt_odstate); in nfs4_free_ol_stateid()
1371 if (stp->st_stateowner) in nfs4_free_ol_stateid()
1372 nfs4_put_stateowner(stp->st_stateowner); in nfs4_free_ol_stateid()
1373 WARN_ON(!list_empty(&stid->sc_cp_list)); in nfs4_free_ol_stateid()
1380 struct nfs4_lockowner *lo = lockowner(stp->st_stateowner); in nfs4_free_lock_stateid()
1383 nf = find_any_file(stp->st_stid.sc_file); in nfs4_free_lock_stateid()
1385 get_file(nf->nf_file); in nfs4_free_lock_stateid()
1386 filp_close(nf->nf_file, (fl_owner_t)lo); in nfs4_free_lock_stateid()
1400 struct nfs4_stid *s = &stp->st_stid; in put_ol_stateid_locked()
1401 struct nfs4_client *clp = s->sc_client; in put_ol_stateid_locked()
1403 lockdep_assert_held(&clp->cl_lock); in put_ol_stateid_locked()
1405 WARN_ON_ONCE(!list_empty(&stp->st_locks)); in put_ol_stateid_locked()
1407 if (!refcount_dec_and_test(&s->sc_count)) { in put_ol_stateid_locked()
1412 idr_remove(&clp->cl_stateids, s->sc_stateid.si_opaque.so_id); in put_ol_stateid_locked()
1413 list_add(&stp->st_locks, reaplist); in put_ol_stateid_locked()
1418 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock); in unhash_lock_stateid()
1422 list_del_init(&stp->st_locks); in unhash_lock_stateid()
1423 nfs4_unhash_stid(&stp->st_stid); in unhash_lock_stateid()
1429 struct nfs4_client *clp = stp->st_stid.sc_client; in release_lock_stateid()
1432 spin_lock(&clp->cl_lock); in release_lock_stateid()
1434 spin_unlock(&clp->cl_lock); in release_lock_stateid()
1436 nfs4_put_stid(&stp->st_stid); in release_lock_stateid()
1441 struct nfs4_client *clp = lo->lo_owner.so_client; in unhash_lockowner_locked()
1443 lockdep_assert_held(&clp->cl_lock); in unhash_lockowner_locked()
1445 list_del_init(&lo->lo_owner.so_strhash); in unhash_lockowner_locked()
1463 list_del(&stp->st_locks); in free_ol_stateid_reaplist()
1464 fp = stp->st_stid.sc_file; in free_ol_stateid_reaplist()
1465 stp->st_stid.sc_free(&stp->st_stid); in free_ol_stateid_reaplist()
1476 lockdep_assert_held(&open_stp->st_stid.sc_client->cl_lock); in release_open_stateid_locks()
1478 while (!list_empty(&open_stp->st_locks)) { in release_open_stateid_locks()
1479 stp = list_entry(open_stp->st_locks.next, in release_open_stateid_locks()
1489 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock); in unhash_open_stateid()
1501 spin_lock(&stp->st_stid.sc_client->cl_lock); in release_open_stateid()
1504 spin_unlock(&stp->st_stid.sc_client->cl_lock); in release_open_stateid()
1510 struct nfs4_client *clp = oo->oo_owner.so_client; in unhash_openowner_locked()
1512 lockdep_assert_held(&clp->cl_lock); in unhash_openowner_locked()
1514 list_del_init(&oo->oo_owner.so_strhash); in unhash_openowner_locked()
1515 list_del_init(&oo->oo_perclient); in unhash_openowner_locked()
1520 struct nfsd_net *nn = net_generic(oo->oo_owner.so_client->net, in release_last_closed_stateid()
1524 spin_lock(&nn->client_lock); in release_last_closed_stateid()
1525 s = oo->oo_last_closed_stid; in release_last_closed_stateid()
1527 list_del_init(&oo->oo_close_lru); in release_last_closed_stateid()
1528 oo->oo_last_closed_stid = NULL; in release_last_closed_stateid()
1530 spin_unlock(&nn->client_lock); in release_last_closed_stateid()
1532 nfs4_put_stid(&s->st_stid); in release_last_closed_stateid()
1538 struct nfs4_client *clp = oo->oo_owner.so_client; in release_openowner()
1543 spin_lock(&clp->cl_lock); in release_openowner()
1545 while (!list_empty(&oo->oo_owner.so_stateids)) { in release_openowner()
1546 stp = list_first_entry(&oo->oo_owner.so_stateids, in release_openowner()
1551 spin_unlock(&clp->cl_lock); in release_openowner()
1554 nfs4_put_stateowner(&oo->oo_owner); in release_openowner()
1562 return sid->sequence % SESSION_HASH_SIZE; in hash_sessionid()
1569 u32 *ptr = (u32 *)(&sessionid->data[0]); in dump_sessionid()
1580 * Bump the seqid on cstate->replay_owner, and clear replay_owner if it
1585 struct nfs4_stateowner *so = cstate->replay_owner; in nfsd4_bump_seqid()
1596 if (so->so_is_open_owner) in nfsd4_bump_seqid()
1598 so->so_seqid++; in nfsd4_bump_seqid()
1605 struct nfs4_client *clp = ses->se_client; in gen_sessionid()
1608 sid = (struct nfsd4_sessionid *)ses->se_sessionid.data; in gen_sessionid()
1609 sid->clientid = clp->cl_clientid; in gen_sessionid()
1610 sid->sequence = current_sessionid++; in gen_sessionid()
1611 sid->reserved = 0; in gen_sessionid()
1617 * the end of the initial SEQUENCE operation--the rest we regenerate
1623 * verifier), 12 for the compound header (with zero-length tag), and 44
1633 for (i = 0; i < ses->se_fchannel.maxreqs; i++) { in free_session_slots()
1634 free_svc_cred(&ses->se_slots[i]->sl_cred); in free_session_slots()
1635 kfree(ses->se_slots[i]); in free_session_slots()
1647 if (ca->maxresp_cached < NFSD_MIN_HDR_SEQ_SZ) in slot_bytes()
1650 size = ca->maxresp_cached - NFSD_MIN_HDR_SEQ_SZ; in slot_bytes()
1656 * re-negotiate active sessions and reduce their slot usage to make
1662 u32 num = ca->maxreqs; in nfsd4_get_drc_mem()
1668 total_avail = nfsd_drc_max_mem - nfsd_drc_mem_used; in nfsd4_get_drc_mem()
1684 * over-allocation--it is better than failure. in nfsd4_get_drc_mem()
1686 scale_factor = max_t(unsigned int, 8, nn->nfsd_serv->sv_nrthreads); in nfsd4_get_drc_mem()
1703 nfsd_drc_mem_used -= slotsize * ca->maxreqs; in nfsd4_put_drc_mem()
1710 int numslots = fattrs->maxreqs; in alloc_session()
1724 new->se_slots[i] = kzalloc(slotsize, GFP_KERNEL); in alloc_session()
1725 if (!new->se_slots[i]) in alloc_session()
1729 memcpy(&new->se_fchannel, fattrs, sizeof(struct nfsd4_channel_attrs)); in alloc_session()
1730 memcpy(&new->se_bchannel, battrs, sizeof(struct nfsd4_channel_attrs)); in alloc_session()
1734 while (i--) in alloc_session()
1735 kfree(new->se_slots[i]); in alloc_session()
1742 svc_xprt_put(c->cn_xprt); in free_conn()
1749 struct nfs4_client *clp = c->cn_session->se_client; in nfsd4_conn_lost()
1751 spin_lock(&clp->cl_lock); in nfsd4_conn_lost()
1752 if (!list_empty(&c->cn_persession)) { in nfsd4_conn_lost()
1753 list_del(&c->cn_persession); in nfsd4_conn_lost()
1757 spin_unlock(&clp->cl_lock); in nfsd4_conn_lost()
1767 svc_xprt_get(rqstp->rq_xprt); in alloc_conn()
1768 conn->cn_xprt = rqstp->rq_xprt; in alloc_conn()
1769 conn->cn_flags = flags; in alloc_conn()
1770 INIT_LIST_HEAD(&conn->cn_xpt_user.list); in alloc_conn()
1776 conn->cn_session = ses; in __nfsd4_hash_conn()
1777 list_add(&conn->cn_persession, &ses->se_conns); in __nfsd4_hash_conn()
1782 struct nfs4_client *clp = ses->se_client; in nfsd4_hash_conn()
1784 spin_lock(&clp->cl_lock); in nfsd4_hash_conn()
1786 spin_unlock(&clp->cl_lock); in nfsd4_hash_conn()
1791 conn->cn_xpt_user.callback = nfsd4_conn_lost; in nfsd4_register_conn()
1792 return register_xpt_user(conn->cn_xprt, &conn->cn_xpt_user); in nfsd4_register_conn()
1803 nfsd4_conn_lost(&conn->cn_xpt_user); in nfsd4_init_conn()
1805 nfsd4_probe_callback_sync(ses->se_client); in nfsd4_init_conn()
1812 if (cses->flags & SESSION4_BACK_CHAN) in alloc_conn_from_crses()
1820 struct nfs4_client *clp = s->se_client; in nfsd4_del_conns()
1823 spin_lock(&clp->cl_lock); in nfsd4_del_conns()
1824 while (!list_empty(&s->se_conns)) { in nfsd4_del_conns()
1825 c = list_first_entry(&s->se_conns, struct nfsd4_conn, cn_persession); in nfsd4_del_conns()
1826 list_del_init(&c->cn_persession); in nfsd4_del_conns()
1827 spin_unlock(&clp->cl_lock); in nfsd4_del_conns()
1829 unregister_xpt_user(c->cn_xprt, &c->cn_xpt_user); in nfsd4_del_conns()
1832 spin_lock(&clp->cl_lock); in nfsd4_del_conns()
1834 spin_unlock(&clp->cl_lock); in nfsd4_del_conns()
1846 nfsd4_put_drc_mem(&ses->se_fchannel); in free_session()
1855 new->se_client = clp; in init_session()
1858 INIT_LIST_HEAD(&new->se_conns); in init_session()
1860 new->se_cb_seq_nr = 1; in init_session()
1861 new->se_flags = cses->flags; in init_session()
1862 new->se_cb_prog = cses->callback_prog; in init_session()
1863 new->se_cb_sec = cses->cb_sec; in init_session()
1864 atomic_set(&new->se_ref, 0); in init_session()
1865 idx = hash_sessionid(&new->se_sessionid); in init_session()
1866 list_add(&new->se_hash, &nn->sessionid_hashtbl[idx]); in init_session()
1867 spin_lock(&clp->cl_lock); in init_session()
1868 list_add(&new->se_perclnt, &clp->cl_sessions); in init_session()
1869 spin_unlock(&clp->cl_lock); in init_session()
1880 rpc_copy_addr((struct sockaddr *)&clp->cl_cb_conn.cb_addr, sa); in init_session()
1881 clp->cl_cb_conn.cb_addrlen = svc_addr_len(sa); in init_session()
1893 lockdep_assert_held(&nn->client_lock); in __find_in_sessionid_hashtbl()
1898 list_for_each_entry(elem, &nn->sessionid_hashtbl[idx], se_hash) { in __find_in_sessionid_hashtbl()
1899 if (!memcmp(elem->se_sessionid.data, sessionid->data, in __find_in_sessionid_hashtbl()
1931 struct nfs4_client *clp = ses->se_client; in unhash_session()
1932 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in unhash_session()
1934 lockdep_assert_held(&nn->client_lock); in unhash_session()
1936 list_del(&ses->se_hash); in unhash_session()
1937 spin_lock(&ses->se_client->cl_lock); in unhash_session()
1938 list_del(&ses->se_perclnt); in unhash_session()
1939 spin_unlock(&ses->se_client->cl_lock); in unhash_session()
1951 if (clid->cl_boot == (u32)nn->boot_time) in STALE_CLIENTID()
1970 xdr_netobj_dup(&clp->cl_name, &name, GFP_KERNEL); in alloc_client()
1971 if (clp->cl_name.data == NULL) in alloc_client()
1973 clp->cl_ownerstr_hashtbl = kmalloc_array(OWNER_HASH_SIZE, in alloc_client()
1976 if (!clp->cl_ownerstr_hashtbl) in alloc_client()
1979 INIT_LIST_HEAD(&clp->cl_ownerstr_hashtbl[i]); in alloc_client()
1980 INIT_LIST_HEAD(&clp->cl_sessions); in alloc_client()
1981 idr_init(&clp->cl_stateids); in alloc_client()
1982 atomic_set(&clp->cl_rpc_users, 0); in alloc_client()
1983 clp->cl_cb_state = NFSD4_CB_UNKNOWN; in alloc_client()
1984 INIT_LIST_HEAD(&clp->cl_idhash); in alloc_client()
1985 INIT_LIST_HEAD(&clp->cl_openowners); in alloc_client()
1986 INIT_LIST_HEAD(&clp->cl_delegations); in alloc_client()
1987 INIT_LIST_HEAD(&clp->cl_lru); in alloc_client()
1988 INIT_LIST_HEAD(&clp->cl_revoked); in alloc_client()
1990 INIT_LIST_HEAD(&clp->cl_lo_states); in alloc_client()
1992 INIT_LIST_HEAD(&clp->async_copies); in alloc_client()
1993 spin_lock_init(&clp->async_lock); in alloc_client()
1994 spin_lock_init(&clp->cl_lock); in alloc_client()
1995 rpc_init_wait_queue(&clp->cl_cb_waitq, "Backchannel slot table"); in alloc_client()
1998 kfree(clp->cl_name.data); in alloc_client()
2009 free_svc_cred(&clp->cl_cred); in __free_client()
2010 kfree(clp->cl_ownerstr_hashtbl); in __free_client()
2011 kfree(clp->cl_name.data); in __free_client()
2012 kfree(clp->cl_nii_domain.data); in __free_client()
2013 kfree(clp->cl_nii_name.data); in __free_client()
2014 idr_destroy(&clp->cl_stateids); in __free_client()
2020 kref_put(&clp->cl_nfsdfs.cl_ref, __free_client); in drop_client()
2026 while (!list_empty(&clp->cl_sessions)) { in free_client()
2028 ses = list_entry(clp->cl_sessions.next, struct nfsd4_session, in free_client()
2030 list_del(&ses->se_perclnt); in free_client()
2031 WARN_ON_ONCE(atomic_read(&ses->se_ref)); in free_client()
2034 rpc_destroy_wait_queue(&clp->cl_cb_waitq); in free_client()
2035 if (clp->cl_nfsd_dentry) { in free_client()
2036 nfsd_client_rmdir(clp->cl_nfsd_dentry); in free_client()
2037 clp->cl_nfsd_dentry = NULL; in free_client()
2047 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in unhash_client_locked()
2050 lockdep_assert_held(&nn->client_lock); in unhash_client_locked()
2053 clp->cl_time = 0; in unhash_client_locked()
2055 if (!list_empty(&clp->cl_idhash)) { in unhash_client_locked()
2056 list_del_init(&clp->cl_idhash); in unhash_client_locked()
2057 if (test_bit(NFSD4_CLIENT_CONFIRMED, &clp->cl_flags)) in unhash_client_locked()
2058 rb_erase(&clp->cl_namenode, &nn->conf_name_tree); in unhash_client_locked()
2060 rb_erase(&clp->cl_namenode, &nn->unconf_name_tree); in unhash_client_locked()
2062 list_del_init(&clp->cl_lru); in unhash_client_locked()
2063 spin_lock(&clp->cl_lock); in unhash_client_locked()
2064 list_for_each_entry(ses, &clp->cl_sessions, se_perclnt) in unhash_client_locked()
2065 list_del_init(&ses->se_hash); in unhash_client_locked()
2066 spin_unlock(&clp->cl_lock); in unhash_client_locked()
2072 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in unhash_client()
2074 spin_lock(&nn->client_lock); in unhash_client()
2076 spin_unlock(&nn->client_lock); in unhash_client()
2081 if (atomic_read(&clp->cl_rpc_users)) in mark_client_expired_locked()
2097 while (!list_empty(&clp->cl_delegations)) { in __destroy_client()
2098 dp = list_entry(clp->cl_delegations.next, struct nfs4_delegation, dl_perclnt); in __destroy_client()
2100 list_add(&dp->dl_recall_lru, &reaplist); in __destroy_client()
2105 list_del_init(&dp->dl_recall_lru); in __destroy_client()
2108 while (!list_empty(&clp->cl_revoked)) { in __destroy_client()
2109 dp = list_entry(clp->cl_revoked.next, struct nfs4_delegation, dl_recall_lru); in __destroy_client()
2110 list_del_init(&dp->dl_recall_lru); in __destroy_client()
2111 nfs4_put_stid(&dp->dl_stid); in __destroy_client()
2113 while (!list_empty(&clp->cl_openowners)) { in __destroy_client()
2114 oo = list_entry(clp->cl_openowners.next, struct nfs4_openowner, oo_perclient); in __destroy_client()
2115 nfs4_get_stateowner(&oo->oo_owner); in __destroy_client()
2121 list_for_each_entry_safe(so, tmp, &clp->cl_ownerstr_hashtbl[i], in __destroy_client()
2124 WARN_ON_ONCE(so->so_is_open_owner); in __destroy_client()
2131 if (clp->cl_cb_conn.cb_xprt) in __destroy_client()
2132 svc_xprt_put(clp->cl_cb_conn.cb_xprt); in __destroy_client()
2146 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in inc_reclaim_complete()
2148 if (!nn->track_reclaim_completes) in inc_reclaim_complete()
2150 if (!nfsd4_find_reclaim_client(clp->cl_name, nn)) in inc_reclaim_complete()
2152 if (atomic_inc_return(&nn->nr_reclaim_complete) == in inc_reclaim_complete()
2153 nn->reclaim_str_hashtbl_size) { in inc_reclaim_complete()
2155 clp->net->ns.inum); in inc_reclaim_complete()
2169 memcpy(target->cl_verifier.data, source->data, in copy_verf()
2170 sizeof(target->cl_verifier.data)); in copy_verf()
2175 target->cl_clientid.cl_boot = source->cl_clientid.cl_boot; in copy_clid()
2176 target->cl_clientid.cl_id = source->cl_clientid.cl_id; in copy_clid()
2181 target->cr_principal = kstrdup(source->cr_principal, GFP_KERNEL); in copy_cred()
2182 target->cr_raw_principal = kstrdup(source->cr_raw_principal, in copy_cred()
2184 target->cr_targ_princ = kstrdup(source->cr_targ_princ, GFP_KERNEL); in copy_cred()
2185 if ((source->cr_principal && !target->cr_principal) || in copy_cred()
2186 (source->cr_raw_principal && !target->cr_raw_principal) || in copy_cred()
2187 (source->cr_targ_princ && !target->cr_targ_princ)) in copy_cred()
2188 return -ENOMEM; in copy_cred()
2190 target->cr_flavor = source->cr_flavor; in copy_cred()
2191 target->cr_uid = source->cr_uid; in copy_cred()
2192 target->cr_gid = source->cr_gid; in copy_cred()
2193 target->cr_group_info = source->cr_group_info; in copy_cred()
2194 get_group_info(target->cr_group_info); in copy_cred()
2195 target->cr_gss_mech = source->cr_gss_mech; in copy_cred()
2196 if (source->cr_gss_mech) in copy_cred()
2197 gss_mech_get(source->cr_gss_mech); in copy_cred()
2204 if (o1->len < o2->len) in compare_blob()
2205 return -1; in compare_blob()
2206 if (o1->len > o2->len) in compare_blob()
2208 return memcmp(o1->data, o2->data, o1->len); in compare_blob()
2214 return 0 == memcmp(v1->data, v2->data, sizeof(v1->data)); in same_verf()
2220 return (cl1->cl_boot == cl2->cl_boot) && (cl1->cl_id == cl2->cl_id); in same_clid()
2227 if (g1->ngroups != g2->ngroups) in groups_equal()
2229 for (i=0; i<g1->ngroups; i++) in groups_equal()
2230 if (!gid_eq(g1->gid[i], g2->gid[i])) in groups_equal()
2239 * approximation. We also don't want to allow non-gss use of a client
2247 return (cr->cr_flavor > RPC_AUTH_MAXFLAVOR); in is_gss_cred()
2255 || (!uid_eq(cr1->cr_uid, cr2->cr_uid)) in same_creds()
2256 || (!gid_eq(cr1->cr_gid, cr2->cr_gid)) in same_creds()
2257 || !groups_equal(cr1->cr_group_info, cr2->cr_group_info)) in same_creds()
2260 if (cr1->cr_principal == cr2->cr_principal) in same_creds()
2262 if (!cr1->cr_principal || !cr2->cr_principal) in same_creds()
2264 return 0 == strcmp(cr1->cr_principal, cr2->cr_principal); in same_creds()
2269 struct svc_cred *cr = &rqstp->rq_cred; in svc_rqst_integrity_protected()
2272 if (!cr->cr_gss_mech) in svc_rqst_integrity_protected()
2274 service = gss_pseudoflavor_to_service(cr->cr_gss_mech, cr->cr_flavor); in svc_rqst_integrity_protected()
2281 struct svc_cred *cr = &rqstp->rq_cred; in nfsd4_mach_creds_match()
2283 if (!cl->cl_mach_cred) in nfsd4_mach_creds_match()
2285 if (cl->cl_cred.cr_gss_mech != cr->cr_gss_mech) in nfsd4_mach_creds_match()
2289 if (cl->cl_cred.cr_raw_principal) in nfsd4_mach_creds_match()
2290 return 0 == strcmp(cl->cl_cred.cr_raw_principal, in nfsd4_mach_creds_match()
2291 cr->cr_raw_principal); in nfsd4_mach_creds_match()
2292 if (!cr->cr_principal) in nfsd4_mach_creds_match()
2294 return 0 == strcmp(cl->cl_cred.cr_principal, cr->cr_principal); in nfsd4_mach_creds_match()
2302 * This is opaque to client, so no need to byte-swap. Use in gen_confirm()
2306 verf[1] = (__force __be32)nn->clverifier_counter++; in gen_confirm()
2307 memcpy(clp->cl_confirm.data, verf, sizeof(clp->cl_confirm.data)); in gen_confirm()
2312 clp->cl_clientid.cl_boot = (u32)nn->boot_time; in gen_clid()
2313 clp->cl_clientid.cl_id = nn->clientid_counter++; in gen_clid()
2322 ret = idr_find(&cl->cl_stateids, t->si_opaque.so_id); in find_stateid_locked()
2323 if (!ret || !ret->sc_type) in find_stateid_locked()
2333 spin_lock(&cl->cl_lock); in find_stateid_by_type()
2336 if (typemask & s->sc_type) in find_stateid_by_type()
2337 refcount_inc(&s->sc_count); in find_stateid_by_type()
2341 spin_unlock(&cl->cl_lock); in find_stateid_by_type()
2363 struct inode *inode = m->private; in client_info_show()
2369 return -ENXIO; in client_info_show()
2370 memcpy(&clid, &clp->cl_clientid, sizeof(clid)); in client_info_show()
2372 seq_printf(m, "address: \"%pISpc\"\n", (struct sockaddr *)&clp->cl_addr); in client_info_show()
2374 seq_quote_mem(m, clp->cl_name.data, clp->cl_name.len); in client_info_show()
2375 seq_printf(m, "\nminor version: %d\n", clp->cl_minorversion); in client_info_show()
2376 if (clp->cl_nii_domain.data) { in client_info_show()
2378 seq_quote_mem(m, clp->cl_nii_domain.data, in client_info_show()
2379 clp->cl_nii_domain.len); in client_info_show()
2381 seq_quote_mem(m, clp->cl_nii_name.data, clp->cl_nii_name.len); in client_info_show()
2383 clp->cl_nii_time.tv_sec, clp->cl_nii_time.tv_nsec); in client_info_show()
2403 __acquires(&clp->cl_lock) in states_start()
2405 struct nfs4_client *clp = s->private; in states_start()
2409 spin_lock(&clp->cl_lock); in states_start()
2410 ret = idr_get_next_ul(&clp->cl_stateids, &id); in states_start()
2417 struct nfs4_client *clp = s->private; in states_next()
2423 ret = idr_get_next_ul(&clp->cl_stateids, &id); in states_next()
2429 __releases(&clp->cl_lock) in states_stop()
2431 struct nfs4_client *clp = s->private; in states_stop()
2433 spin_unlock(&clp->cl_lock); in states_stop()
2438 seq_printf(s, "filename: \"%pD2\"", f->nf_file); in nfs4_show_fname()
2443 struct inode *inode = f->nf_inode; in nfs4_show_superblock()
2446 MAJOR(inode->i_sb->s_dev), in nfs4_show_superblock()
2447 MINOR(inode->i_sb->s_dev), in nfs4_show_superblock()
2448 inode->i_ino); in nfs4_show_superblock()
2454 seq_quote_mem(s, oo->so_owner.data, oo->so_owner.len); in nfs4_show_owner()
2459 seq_printf(s, "0x%.8x", stid->si_generation); in nfs4_show_stateid()
2460 seq_printf(s, "%12phN", &stid->si_opaque); in nfs4_show_stateid()
2471 if (st->sc_type != NFS4_OPEN_STID && st->sc_type != NFS4_LOCK_STID) in nfs4_show_open()
2474 oo = ols->st_stateowner; in nfs4_show_open()
2475 nf = st->sc_file; in nfs4_show_open()
2477 spin_lock(&nf->fi_lock); in nfs4_show_open()
2482 seq_printf(s, "- "); in nfs4_show_open()
2483 nfs4_show_stateid(s, &st->sc_stateid); in nfs4_show_open()
2486 access = bmap_to_share_mode(ols->st_access_bmap); in nfs4_show_open()
2487 deny = bmap_to_share_mode(ols->st_deny_bmap); in nfs4_show_open()
2490 access & NFS4_SHARE_ACCESS_READ ? "r" : "-", in nfs4_show_open()
2491 access & NFS4_SHARE_ACCESS_WRITE ? "w" : "-"); in nfs4_show_open()
2493 deny & NFS4_SHARE_ACCESS_READ ? "r" : "-", in nfs4_show_open()
2494 deny & NFS4_SHARE_ACCESS_WRITE ? "w" : "-"); in nfs4_show_open()
2503 spin_unlock(&nf->fi_lock); in nfs4_show_open()
2515 oo = ols->st_stateowner; in nfs4_show_lock()
2516 nf = st->sc_file; in nfs4_show_lock()
2517 spin_lock(&nf->fi_lock); in nfs4_show_lock()
2522 seq_printf(s, "- "); in nfs4_show_lock()
2523 nfs4_show_stateid(s, &st->sc_stateid); in nfs4_show_lock()
2541 spin_unlock(&nf->fi_lock); in nfs4_show_lock()
2552 nf = st->sc_file; in nfs4_show_deleg()
2553 spin_lock(&nf->fi_lock); in nfs4_show_deleg()
2558 seq_printf(s, "- "); in nfs4_show_deleg()
2559 nfs4_show_stateid(s, &st->sc_stateid); in nfs4_show_deleg()
2564 ds->dl_type == NFS4_OPEN_DELEGATE_READ ? "r" : "w"); in nfs4_show_deleg()
2573 spin_unlock(&nf->fi_lock); in nfs4_show_deleg()
2583 file = ls->ls_file; in nfs4_show_layout()
2585 seq_printf(s, "- "); in nfs4_show_layout()
2586 nfs4_show_stateid(s, &st->sc_stateid); in nfs4_show_layout()
2603 switch (st->sc_type) { in states_show()
2633 return -ENXIO; in client_states_open()
2638 s = file->private_data; in client_states_open()
2639 s->private = clp; in client_states_open()
2645 struct seq_file *m = file->private_data; in client_opens_release()
2646 struct nfs4_client *clp = m->private; in client_opens_release()
2668 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in force_expire_client()
2671 spin_lock(&nn->client_lock); in force_expire_client()
2672 clp->cl_time = 0; in force_expire_client()
2673 spin_unlock(&nn->client_lock); in force_expire_client()
2675 wait_event(expiry_wq, atomic_read(&clp->cl_rpc_users) == 0); in force_expire_client()
2676 spin_lock(&nn->client_lock); in force_expire_client()
2677 already_expired = list_empty(&clp->cl_lru); in force_expire_client()
2680 spin_unlock(&nn->client_lock); in force_expire_client()
2685 wait_event(expiry_wq, clp->cl_nfsd_dentry == NULL); in force_expire_client()
2698 return -EINVAL; in client_ctl_write()
2701 return -ENXIO; in client_ctl_write()
2732 ret = copy_cred(&clp->cl_cred, &rqstp->rq_cred); in create_client()
2738 kref_init(&clp->cl_nfsdfs.cl_ref); in create_client()
2739 nfsd4_init_cb(&clp->cl_cb_null, clp, NULL, NFSPROC4_CLNT_CB_NULL); in create_client()
2740 clp->cl_time = ktime_get_boottime_seconds(); in create_client()
2741 clear_bit(0, &clp->cl_cb_slot_busy); in create_client()
2743 memcpy(&clp->cl_addr, sa, sizeof(struct sockaddr_storage)); in create_client()
2744 clp->cl_cb_session = NULL; in create_client()
2745 clp->net = net; in create_client()
2746 clp->cl_nfsd_dentry = nfsd_client_mkdir(nn, &clp->cl_nfsdfs, in create_client()
2747 clp->cl_clientid.cl_id - nn->clientid_base, in create_client()
2749 if (!clp->cl_nfsd_dentry) { in create_client()
2759 struct rb_node **new = &(root->rb_node), *parent = NULL; in add_clp_to_name_tree()
2766 if (compare_blob(&clp->cl_name, &new_clp->cl_name) > 0) in add_clp_to_name_tree()
2767 new = &((*new)->rb_left); in add_clp_to_name_tree()
2769 new = &((*new)->rb_right); in add_clp_to_name_tree()
2772 rb_link_node(&new_clp->cl_namenode, parent, new); in add_clp_to_name_tree()
2773 rb_insert_color(&new_clp->cl_namenode, root); in add_clp_to_name_tree()
2780 struct rb_node *node = root->rb_node; in find_clp_in_name_tree()
2785 cmp = compare_blob(&clp->cl_name, name); in find_clp_in_name_tree()
2787 node = node->rb_left; in find_clp_in_name_tree()
2789 node = node->rb_right; in find_clp_in_name_tree()
2800 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in add_to_unconfirmed()
2802 lockdep_assert_held(&nn->client_lock); in add_to_unconfirmed()
2804 clear_bit(NFSD4_CLIENT_CONFIRMED, &clp->cl_flags); in add_to_unconfirmed()
2805 add_clp_to_name_tree(clp, &nn->unconf_name_tree); in add_to_unconfirmed()
2806 idhashval = clientid_hashval(clp->cl_clientid.cl_id); in add_to_unconfirmed()
2807 list_add(&clp->cl_idhash, &nn->unconf_id_hashtbl[idhashval]); in add_to_unconfirmed()
2814 unsigned int idhashval = clientid_hashval(clp->cl_clientid.cl_id); in move_to_confirmed()
2815 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in move_to_confirmed()
2817 lockdep_assert_held(&nn->client_lock); in move_to_confirmed()
2820 list_move(&clp->cl_idhash, &nn->conf_id_hashtbl[idhashval]); in move_to_confirmed()
2821 rb_erase(&clp->cl_namenode, &nn->unconf_name_tree); in move_to_confirmed()
2822 add_clp_to_name_tree(clp, &nn->conf_name_tree); in move_to_confirmed()
2823 set_bit(NFSD4_CLIENT_CONFIRMED, &clp->cl_flags); in move_to_confirmed()
2831 unsigned int idhashval = clientid_hashval(clid->cl_id); in find_client_in_id_table()
2834 if (same_clid(&clp->cl_clientid, clid)) { in find_client_in_id_table()
2835 if ((bool)clp->cl_minorversion != sessions) in find_client_in_id_table()
2847 struct list_head *tbl = nn->conf_id_hashtbl; in find_confirmed_client()
2849 lockdep_assert_held(&nn->client_lock); in find_confirmed_client()
2856 struct list_head *tbl = nn->unconf_id_hashtbl; in find_unconfirmed_client()
2858 lockdep_assert_held(&nn->client_lock); in find_unconfirmed_client()
2864 return clp->cl_exchange_flags != 0; in clp_used_exchangeid()
2870 lockdep_assert_held(&nn->client_lock); in find_confirmed_client_by_name()
2871 return find_clp_in_name_tree(name, &nn->conf_name_tree); in find_confirmed_client_by_name()
2877 lockdep_assert_held(&nn->client_lock); in find_unconfirmed_client_by_name()
2878 return find_clp_in_name_tree(name, &nn->unconf_name_tree); in find_unconfirmed_client_by_name()
2884 struct nfs4_cb_conn *conn = &clp->cl_cb_conn; in gen_callback()
2890 if (se->se_callback_netid_len == 3 && in gen_callback()
2891 !memcmp(se->se_callback_netid_val, "tcp", 3)) in gen_callback()
2893 else if (se->se_callback_netid_len == 4 && in gen_callback()
2894 !memcmp(se->se_callback_netid_val, "tcp6", 4)) in gen_callback()
2899 conn->cb_addrlen = rpc_uaddr2sockaddr(clp->net, se->se_callback_addr_val, in gen_callback()
2900 se->se_callback_addr_len, in gen_callback()
2901 (struct sockaddr *)&conn->cb_addr, in gen_callback()
2902 sizeof(conn->cb_addr)); in gen_callback()
2904 if (!conn->cb_addrlen || conn->cb_addr.ss_family != expected_family) in gen_callback()
2907 if (conn->cb_addr.ss_family == AF_INET6) in gen_callback()
2908 ((struct sockaddr_in6 *)&conn->cb_addr)->sin6_scope_id = scopeid; in gen_callback()
2910 conn->cb_prog = se->se_callback_prog; in gen_callback()
2911 conn->cb_ident = se->se_callback_ident; in gen_callback()
2912 memcpy(&conn->cb_saddr, &rqstp->rq_daddr, rqstp->rq_daddrlen); in gen_callback()
2916 conn->cb_addr.ss_family = AF_UNSPEC; in gen_callback()
2917 conn->cb_addrlen = 0; in gen_callback()
2928 struct xdr_buf *buf = resp->xdr.buf; in nfsd4_store_cache_entry()
2929 struct nfsd4_slot *slot = resp->cstate.slot; in nfsd4_store_cache_entry()
2932 dprintk("--> %s slot %p\n", __func__, slot); in nfsd4_store_cache_entry()
2934 slot->sl_flags |= NFSD4_SLOT_INITIALIZED; in nfsd4_store_cache_entry()
2935 slot->sl_opcnt = resp->opcnt; in nfsd4_store_cache_entry()
2936 slot->sl_status = resp->cstate.status; in nfsd4_store_cache_entry()
2937 free_svc_cred(&slot->sl_cred); in nfsd4_store_cache_entry()
2938 copy_cred(&slot->sl_cred, &resp->rqstp->rq_cred); in nfsd4_store_cache_entry()
2941 slot->sl_flags &= ~NFSD4_SLOT_CACHED; in nfsd4_store_cache_entry()
2944 slot->sl_flags |= NFSD4_SLOT_CACHED; in nfsd4_store_cache_entry()
2946 base = resp->cstate.data_offset; in nfsd4_store_cache_entry()
2947 slot->sl_datalen = buf->len - base; in nfsd4_store_cache_entry()
2948 if (read_bytes_from_xdr_buf(buf, base, slot->sl_data, slot->sl_datalen)) in nfsd4_store_cache_entry()
2957 * operation which sets resp->p and increments resp->opcnt for
2966 struct nfsd4_slot *slot = resp->cstate.slot; in nfsd4_enc_sequence_replay()
2969 op = &args->ops[resp->opcnt - 1]; in nfsd4_enc_sequence_replay()
2972 if (slot->sl_flags & NFSD4_SLOT_CACHED) in nfsd4_enc_sequence_replay()
2973 return op->status; in nfsd4_enc_sequence_replay()
2974 if (args->opcnt == 1) { in nfsd4_enc_sequence_replay()
2976 * The original operation wasn't a solo sequence--we in nfsd4_enc_sequence_replay()
2977 * always cache those--so this retry must not match the in nfsd4_enc_sequence_replay()
2980 op->status = nfserr_seq_false_retry; in nfsd4_enc_sequence_replay()
2982 op = &args->ops[resp->opcnt++]; in nfsd4_enc_sequence_replay()
2983 op->status = nfserr_retry_uncached_rep; in nfsd4_enc_sequence_replay()
2986 return op->status; in nfsd4_enc_sequence_replay()
2997 struct nfsd4_slot *slot = resp->cstate.slot; in nfsd4_replay_cache_entry()
2998 struct xdr_stream *xdr = &resp->xdr; in nfsd4_replay_cache_entry()
3002 dprintk("--> %s slot %p\n", __func__, slot); in nfsd4_replay_cache_entry()
3004 status = nfsd4_enc_sequence_replay(resp->rqstp->rq_argp, resp); in nfsd4_replay_cache_entry()
3008 p = xdr_reserve_space(xdr, slot->sl_datalen); in nfsd4_replay_cache_entry()
3013 xdr_encode_opaque_fixed(p, slot->sl_data, slot->sl_datalen); in nfsd4_replay_cache_entry()
3016 resp->opcnt = slot->sl_opcnt; in nfsd4_replay_cache_entry()
3017 return slot->sl_status; in nfsd4_replay_cache_entry()
3027 new->cl_exchange_flags |= EXCHGID4_FLAG_USE_PNFS_MDS; in nfsd4_set_ex_flags()
3029 new->cl_exchange_flags |= EXCHGID4_FLAG_USE_NON_PNFS; in nfsd4_set_ex_flags()
3033 new->cl_exchange_flags |= EXCHGID4_FLAG_SUPP_MOVED_REFER; in nfsd4_set_ex_flags()
3036 clid->flags = new->cl_exchange_flags; in nfsd4_set_ex_flags()
3043 list_for_each_entry(oo, &clp->cl_openowners, oo_perclient) { in client_has_openowners()
3044 if (!list_empty(&oo->oo_owner.so_stateids)) in client_has_openowners()
3054 || !list_empty(&clp->cl_lo_states) in client_has_state()
3056 || !list_empty(&clp->cl_delegations) in client_has_state()
3057 || !list_empty(&clp->cl_sessions) in client_has_state()
3058 || !list_empty(&clp->async_copies); in client_has_state()
3064 if (!exid->nii_domain.data) in copy_impl_id()
3066 xdr_netobj_dup(&clp->cl_nii_domain, &exid->nii_domain, GFP_KERNEL); in copy_impl_id()
3067 if (!clp->cl_nii_domain.data) in copy_impl_id()
3069 xdr_netobj_dup(&clp->cl_nii_name, &exid->nii_name, GFP_KERNEL); in copy_impl_id()
3070 if (!clp->cl_nii_name.data) in copy_impl_id()
3072 clp->cl_nii_time = exid->nii_time; in copy_impl_id()
3080 struct nfsd4_exchange_id *exid = &u->exchange_id; in nfsd4_exchange_id()
3085 nfs4_verifier verf = exid->verifier; in nfsd4_exchange_id()
3087 bool update = exid->flags & EXCHGID4_FLAG_UPD_CONFIRMED_REC_A; in nfsd4_exchange_id()
3093 __func__, rqstp, exid, exid->clname.len, exid->clname.data, in nfsd4_exchange_id()
3094 addr_str, exid->flags, exid->spa_how); in nfsd4_exchange_id()
3096 if (exid->flags & ~EXCHGID4_FLAG_MASK_A) in nfsd4_exchange_id()
3099 new = create_client(exid->clname, rqstp, &verf); in nfsd4_exchange_id()
3106 switch (exid->spa_how) { in nfsd4_exchange_id()
3108 exid->spo_must_enforce[0] = 0; in nfsd4_exchange_id()
3109 exid->spo_must_enforce[1] = ( in nfsd4_exchange_id()
3110 1 << (OP_BIND_CONN_TO_SESSION - 32) | in nfsd4_exchange_id()
3111 1 << (OP_EXCHANGE_ID - 32) | in nfsd4_exchange_id()
3112 1 << (OP_CREATE_SESSION - 32) | in nfsd4_exchange_id()
3113 1 << (OP_DESTROY_SESSION - 32) | in nfsd4_exchange_id()
3114 1 << (OP_DESTROY_CLIENTID - 32)); in nfsd4_exchange_id()
3116 exid->spo_must_allow[0] &= (1 << (OP_CLOSE) | in nfsd4_exchange_id()
3121 exid->spo_must_allow[1] &= ( in nfsd4_exchange_id()
3122 1 << (OP_TEST_STATEID - 32) | in nfsd4_exchange_id()
3123 1 << (OP_FREE_STATEID - 32)); in nfsd4_exchange_id()
3133 if (!new->cl_cred.cr_principal && in nfsd4_exchange_id()
3134 !new->cl_cred.cr_raw_principal) { in nfsd4_exchange_id()
3138 new->cl_mach_cred = true; in nfsd4_exchange_id()
3150 spin_lock(&nn->client_lock); in nfsd4_exchange_id()
3151 conf = find_confirmed_client_by_name(&exid->clname, nn); in nfsd4_exchange_id()
3153 bool creds_match = same_creds(&conf->cl_cred, &rqstp->rq_cred); in nfsd4_exchange_id()
3154 bool verfs_match = same_verf(&verf, &conf->cl_verifier); in nfsd4_exchange_id()
3174 exid->flags |= EXCHGID4_FLAG_CONFIRMED_R; in nfsd4_exchange_id()
3185 conf->cl_exchange_flags |= EXCHGID4_FLAG_CONFIRMED_R; in nfsd4_exchange_id()
3198 unconf = find_unconfirmed_client_by_name(&exid->clname, nn); in nfsd4_exchange_id()
3209 new->cl_minorversion = cstate->minorversion; in nfsd4_exchange_id()
3210 new->cl_spo_must_allow.u.words[0] = exid->spo_must_allow[0]; in nfsd4_exchange_id()
3211 new->cl_spo_must_allow.u.words[1] = exid->spo_must_allow[1]; in nfsd4_exchange_id()
3216 exid->clientid.cl_boot = conf->cl_clientid.cl_boot; in nfsd4_exchange_id()
3217 exid->clientid.cl_id = conf->cl_clientid.cl_id; in nfsd4_exchange_id()
3219 exid->seqid = conf->cl_cs_slot.sl_seqid + 1; in nfsd4_exchange_id()
3223 conf->cl_cs_slot.sl_seqid, conf->cl_exchange_flags); in nfsd4_exchange_id()
3227 spin_unlock(&nn->client_lock); in nfsd4_exchange_id()
3249 /* Note unsigned 32-bit arithmetic handles wraparound: */ in check_slot_seqid()
3260 * Do this for solo or embedded create session operations.
3266 slot->sl_status = nfserr; in nfsd4_cache_create_session()
3267 memcpy(&slot->sl_cr_ses, cr_ses, sizeof(*cr_ses)); in nfsd4_cache_create_session()
3274 memcpy(cr_ses, &slot->sl_cr_ses, sizeof(*cr_ses)); in nfsd4_replay_create_session()
3275 return slot->sl_status; in nfsd4_replay_create_session()
3297 u32 maxrpc = nn->nfsd_serv->sv_max_mesg; in check_forechannel_attrs()
3299 if (ca->maxreq_sz < NFSD_MIN_REQ_HDR_SEQ_SZ) in check_forechannel_attrs()
3301 if (ca->maxresp_sz < NFSD_MIN_RESP_HDR_SEQ_SZ) in check_forechannel_attrs()
3303 ca->headerpadsz = 0; in check_forechannel_attrs()
3304 ca->maxreq_sz = min_t(u32, ca->maxreq_sz, maxrpc); in check_forechannel_attrs()
3305 ca->maxresp_sz = min_t(u32, ca->maxresp_sz, maxrpc); in check_forechannel_attrs()
3306 ca->maxops = min_t(u32, ca->maxops, NFSD_MAX_OPS_PER_COMPOUND); in check_forechannel_attrs()
3307 ca->maxresp_cached = min_t(u32, ca->maxresp_cached, in check_forechannel_attrs()
3309 ca->maxreqs = min_t(u32, ca->maxreqs, NFSD_MAX_SLOTS_PER_SESSION); in check_forechannel_attrs()
3320 ca->maxreqs = nfsd4_get_drc_mem(ca, nn); in check_forechannel_attrs()
3326 * Server's NFSv4.1 backchannel support is AUTH_SYS-only for now.
3343 ca->headerpadsz = 0; in check_backchannel_attrs()
3345 if (ca->maxreq_sz < NFSD_CB_MAX_REQ_SZ) in check_backchannel_attrs()
3347 if (ca->maxresp_sz < NFSD_CB_MAX_RESP_SZ) in check_backchannel_attrs()
3349 ca->maxresp_cached = 0; in check_backchannel_attrs()
3350 if (ca->maxops < 2) in check_backchannel_attrs()
3358 switch (cbs->flavor) { in nfsd4_check_cb_sec()
3378 struct nfsd4_create_session *cr_ses = &u->create_session; in nfsd4_create_session()
3388 if (cr_ses->flags & ~SESSION4_FLAG_MASK_A) in nfsd4_create_session()
3390 status = nfsd4_check_cb_sec(&cr_ses->cb_sec); in nfsd4_create_session()
3393 status = check_forechannel_attrs(&cr_ses->fore_channel, nn); in nfsd4_create_session()
3396 status = check_backchannel_attrs(&cr_ses->back_channel); in nfsd4_create_session()
3400 new = alloc_session(&cr_ses->fore_channel, &cr_ses->back_channel); in nfsd4_create_session()
3407 spin_lock(&nn->client_lock); in nfsd4_create_session()
3408 unconf = find_unconfirmed_client(&cr_ses->clientid, true, nn); in nfsd4_create_session()
3409 conf = find_confirmed_client(&cr_ses->clientid, true, nn); in nfsd4_create_session()
3416 cs_slot = &conf->cl_cs_slot; in nfsd4_create_session()
3417 status = check_slot_seqid(cr_ses->seqid, cs_slot->sl_seqid, 0); in nfsd4_create_session()
3424 if (!same_creds(&unconf->cl_cred, &rqstp->rq_cred) || in nfsd4_create_session()
3425 !rpc_cmp_addr(sa, (struct sockaddr *) &unconf->cl_addr)) { in nfsd4_create_session()
3432 cs_slot = &unconf->cl_cs_slot; in nfsd4_create_session()
3433 status = check_slot_seqid(cr_ses->seqid, cs_slot->sl_seqid, 0); in nfsd4_create_session()
3439 old = find_confirmed_client_by_name(&unconf->cl_name, nn); in nfsd4_create_session()
3455 cr_ses->flags &= ~SESSION4_PERSIST; in nfsd4_create_session()
3457 cr_ses->flags &= ~SESSION4_RDMA; in nfsd4_create_session()
3462 memcpy(cr_ses->sessionid.data, new->se_sessionid.data, in nfsd4_create_session()
3464 cs_slot->sl_seqid++; in nfsd4_create_session()
3465 cr_ses->seqid = cs_slot->sl_seqid; in nfsd4_create_session()
3467 /* cache solo and embedded create sessions under the client_lock */ in nfsd4_create_session()
3469 spin_unlock(&nn->client_lock); in nfsd4_create_session()
3477 spin_unlock(&nn->client_lock); in nfsd4_create_session()
3484 nfsd4_put_drc_mem(&cr_ses->fore_channel); in nfsd4_create_session()
3506 struct nfsd4_backchannel_ctl *bc = &u->backchannel_ctl; in nfsd4_backchannel_ctl()
3507 struct nfsd4_session *session = cstate->session; in nfsd4_backchannel_ctl()
3511 status = nfsd4_check_cb_sec(&bc->bc_cb_sec); in nfsd4_backchannel_ctl()
3514 spin_lock(&nn->client_lock); in nfsd4_backchannel_ctl()
3515 session->se_cb_prog = bc->bc_cb_program; in nfsd4_backchannel_ctl()
3516 session->se_cb_sec = bc->bc_cb_sec; in nfsd4_backchannel_ctl()
3517 spin_unlock(&nn->client_lock); in nfsd4_backchannel_ctl()
3519 nfsd4_probe_callback(session->se_client); in nfsd4_backchannel_ctl()
3528 list_for_each_entry(c, &s->se_conns, cn_persession) { in __nfsd4_find_conn()
3529 if (c->cn_xprt == xpt) { in __nfsd4_find_conn()
3539 struct nfs4_client *clp = session->se_client; in nfsd4_match_existing_connection()
3540 struct svc_xprt *xpt = rqst->rq_xprt; in nfsd4_match_existing_connection()
3545 spin_lock(&clp->cl_lock); in nfsd4_match_existing_connection()
3549 else if (req == c->cn_flags) in nfsd4_match_existing_connection()
3552 c->cn_flags != NFS4_CDFC4_BACK) in nfsd4_match_existing_connection()
3555 c->cn_flags != NFS4_CDFC4_FORE) in nfsd4_match_existing_connection()
3559 spin_unlock(&clp->cl_lock); in nfsd4_match_existing_connection()
3569 struct nfsd4_bind_conn_to_session *bcts = &u->bind_conn_to_session; in nfsd4_bind_conn_to_session()
3578 spin_lock(&nn->client_lock); in nfsd4_bind_conn_to_session()
3579 session = find_in_sessionid_hashtbl(&bcts->sessionid, net, &status); in nfsd4_bind_conn_to_session()
3580 spin_unlock(&nn->client_lock); in nfsd4_bind_conn_to_session()
3584 if (!nfsd4_mach_creds_match(session->se_client, rqstp)) in nfsd4_bind_conn_to_session()
3587 bcts->dir, &conn); in nfsd4_bind_conn_to_session()
3589 if (bcts->dir == NFS4_CDFC4_FORE_OR_BOTH || in nfsd4_bind_conn_to_session()
3590 bcts->dir == NFS4_CDFC4_BACK) in nfsd4_bind_conn_to_session()
3591 conn->cn_flags |= NFS4_CDFC4_BACK; in nfsd4_bind_conn_to_session()
3592 nfsd4_probe_callback(session->se_client); in nfsd4_bind_conn_to_session()
3597 status = nfsd4_map_bcts_dir(&bcts->dir); in nfsd4_bind_conn_to_session()
3600 conn = alloc_conn(rqstp, bcts->dir); in nfsd4_bind_conn_to_session()
3614 if (!cstate->session) in nfsd4_compound_in_session()
3616 return !memcmp(sid, &cstate->session->se_sessionid, sizeof(*sid)); in nfsd4_compound_in_session()
3623 struct nfs4_sessionid *sessionid = &u->destroy_session.sessionid; in nfsd4_destroy_session()
3637 spin_lock(&nn->client_lock); in nfsd4_destroy_session()
3642 if (!nfsd4_mach_creds_match(ses->se_client, r)) in nfsd4_destroy_session()
3648 spin_unlock(&nn->client_lock); in nfsd4_destroy_session()
3650 nfsd4_probe_callback_sync(ses->se_client); in nfsd4_destroy_session()
3652 spin_lock(&nn->client_lock); in nfsd4_destroy_session()
3657 spin_unlock(&nn->client_lock); in nfsd4_destroy_session()
3664 struct nfs4_client *clp = ses->se_client; in nfsd4_sequence_check_conn()
3669 spin_lock(&clp->cl_lock); in nfsd4_sequence_check_conn()
3670 c = __nfsd4_find_conn(new->cn_xprt, ses); in nfsd4_sequence_check_conn()
3674 if (clp->cl_mach_cred) in nfsd4_sequence_check_conn()
3677 spin_unlock(&clp->cl_lock); in nfsd4_sequence_check_conn()
3681 nfsd4_conn_lost(&new->cn_xpt_user); in nfsd4_sequence_check_conn()
3684 spin_unlock(&clp->cl_lock); in nfsd4_sequence_check_conn()
3691 struct nfsd4_compoundargs *args = rqstp->rq_argp; in nfsd4_session_too_many_ops()
3693 return args->opcnt > session->se_fchannel.maxops; in nfsd4_session_too_many_ops()
3699 struct xdr_buf *xb = &rqstp->rq_arg; in nfsd4_request_too_big()
3701 return xb->len > session->se_fchannel.maxreq_sz; in nfsd4_request_too_big()
3707 struct nfsd4_compoundargs *argp = rqstp->rq_argp; in replay_matches_cache()
3709 if ((bool)(slot->sl_flags & NFSD4_SLOT_CACHETHIS) != in replay_matches_cache()
3710 (bool)seq->cachethis) in replay_matches_cache()
3716 if (slot->sl_opcnt < argp->opcnt && !slot->sl_status) in replay_matches_cache()
3723 if (slot->sl_opcnt > argp->opcnt) in replay_matches_cache()
3726 if (!same_creds(&rqstp->rq_cred, &slot->sl_cred)) in replay_matches_cache()
3741 struct nfsd4_sequence *seq = &u->sequence; in nfsd4_sequence()
3742 struct nfsd4_compoundres *resp = rqstp->rq_resp; in nfsd4_sequence()
3743 struct xdr_stream *xdr = &resp->xdr; in nfsd4_sequence()
3753 if (resp->opcnt != 1) in nfsd4_sequence()
3764 spin_lock(&nn->client_lock); in nfsd4_sequence()
3765 session = find_in_sessionid_hashtbl(&seq->sessionid, net, &status); in nfsd4_sequence()
3768 clp = session->se_client; in nfsd4_sequence()
3779 if (seq->slotid >= session->se_fchannel.maxreqs) in nfsd4_sequence()
3782 slot = session->se_slots[seq->slotid]; in nfsd4_sequence()
3783 dprintk("%s: slotid %d\n", __func__, seq->slotid); in nfsd4_sequence()
3788 seq->maxslots = session->se_fchannel.maxreqs; in nfsd4_sequence()
3790 status = check_slot_seqid(seq->seqid, slot->sl_seqid, in nfsd4_sequence()
3791 slot->sl_flags & NFSD4_SLOT_INUSE); in nfsd4_sequence()
3794 if (!(slot->sl_flags & NFSD4_SLOT_INITIALIZED)) in nfsd4_sequence()
3799 cstate->slot = slot; in nfsd4_sequence()
3800 cstate->session = session; in nfsd4_sequence()
3801 cstate->clp = clp; in nfsd4_sequence()
3802 /* Return the cached reply status and set cstate->status in nfsd4_sequence()
3805 cstate->status = nfserr_replay_cache; in nfsd4_sequence()
3816 buflen = (seq->cachethis) ? in nfsd4_sequence()
3817 session->se_fchannel.maxresp_cached : in nfsd4_sequence()
3818 session->se_fchannel.maxresp_sz; in nfsd4_sequence()
3819 status = (seq->cachethis) ? nfserr_rep_too_big_to_cache : in nfsd4_sequence()
3821 if (xdr_restrict_buflen(xdr, buflen - rqstp->rq_auth_slack)) in nfsd4_sequence()
3827 slot->sl_seqid = seq->seqid; in nfsd4_sequence()
3828 slot->sl_flags |= NFSD4_SLOT_INUSE; in nfsd4_sequence()
3829 if (seq->cachethis) in nfsd4_sequence()
3830 slot->sl_flags |= NFSD4_SLOT_CACHETHIS; in nfsd4_sequence()
3832 slot->sl_flags &= ~NFSD4_SLOT_CACHETHIS; in nfsd4_sequence()
3834 cstate->slot = slot; in nfsd4_sequence()
3835 cstate->session = session; in nfsd4_sequence()
3836 cstate->clp = clp; in nfsd4_sequence()
3839 switch (clp->cl_cb_state) { in nfsd4_sequence()
3841 seq->status_flags = SEQ4_STATUS_CB_PATH_DOWN; in nfsd4_sequence()
3844 seq->status_flags = SEQ4_STATUS_BACKCHANNEL_FAULT; in nfsd4_sequence()
3847 seq->status_flags = 0; in nfsd4_sequence()
3849 if (!list_empty(&clp->cl_revoked)) in nfsd4_sequence()
3850 seq->status_flags |= SEQ4_STATUS_RECALLABLE_STATE_REVOKED; in nfsd4_sequence()
3854 spin_unlock(&nn->client_lock); in nfsd4_sequence()
3864 struct nfsd4_compound_state *cs = &resp->cstate; in nfsd4_sequence_done()
3867 if (cs->status != nfserr_replay_cache) { in nfsd4_sequence_done()
3869 cs->slot->sl_flags &= ~NFSD4_SLOT_INUSE; in nfsd4_sequence_done()
3872 nfsd4_put_session(cs->session); in nfsd4_sequence_done()
3873 } else if (cs->clp) in nfsd4_sequence_done()
3874 put_client_renew(cs->clp); in nfsd4_sequence_done()
3882 struct nfsd4_destroy_clientid *dc = &u->destroy_clientid; in nfsd4_destroy_clientid()
3888 spin_lock(&nn->client_lock); in nfsd4_destroy_clientid()
3889 unconf = find_unconfirmed_client(&dc->clientid, true, nn); in nfsd4_destroy_clientid()
3890 conf = find_confirmed_client(&dc->clientid, true, nn); in nfsd4_destroy_clientid()
3915 spin_unlock(&nn->client_lock); in nfsd4_destroy_clientid()
3925 struct nfsd4_reclaim_complete *rc = &u->reclaim_complete; in nfsd4_reclaim_complete()
3928 if (rc->rca_one_fs) { in nfsd4_reclaim_complete()
3929 if (!cstate->current_fh.fh_dentry) in nfsd4_reclaim_complete()
3940 &cstate->session->se_client->cl_flags)) in nfsd4_reclaim_complete()
3944 if (is_client_expired(cstate->session->se_client)) in nfsd4_reclaim_complete()
3955 nfsd4_client_record_create(cstate->session->se_client); in nfsd4_reclaim_complete()
3956 inc_reclaim_complete(cstate->session->se_client); in nfsd4_reclaim_complete()
3965 struct nfsd4_setclientid *setclid = &u->setclientid; in nfsd4_setclientid()
3966 struct xdr_netobj clname = setclid->se_name; in nfsd4_setclientid()
3967 nfs4_verifier clverifier = setclid->se_verf; in nfsd4_setclientid()
3977 spin_lock(&nn->client_lock); in nfsd4_setclientid()
3984 if (!same_creds(&conf->cl_cred, &rqstp->rq_cred)) { in nfsd4_setclientid()
3993 if (conf && same_verf(&conf->cl_verifier, &clverifier)) { in nfsd4_setclientid()
3997 new->cl_minorversion = 0; in nfsd4_setclientid()
4000 setclid->se_clientid.cl_boot = new->cl_clientid.cl_boot; in nfsd4_setclientid()
4001 setclid->se_clientid.cl_id = new->cl_clientid.cl_id; in nfsd4_setclientid()
4002 memcpy(setclid->se_confirm.data, new->cl_confirm.data, sizeof(setclid->se_confirm.data)); in nfsd4_setclientid()
4006 spin_unlock(&nn->client_lock); in nfsd4_setclientid()
4021 &u->setclientid_confirm; in nfsd4_setclientid_confirm()
4024 nfs4_verifier confirm = setclientid_confirm->sc_confirm; in nfsd4_setclientid_confirm()
4025 clientid_t * clid = &setclientid_confirm->sc_clientid; in nfsd4_setclientid_confirm()
4032 spin_lock(&nn->client_lock); in nfsd4_setclientid_confirm()
4043 if (unconf && !same_creds(&unconf->cl_cred, &rqstp->rq_cred)) in nfsd4_setclientid_confirm()
4045 if (conf && !same_creds(&conf->cl_cred, &rqstp->rq_cred)) in nfsd4_setclientid_confirm()
4048 if (!unconf || !same_verf(&confirm, &unconf->cl_confirm)) { in nfsd4_setclientid_confirm()
4049 if (conf && same_verf(&confirm, &conf->cl_confirm)) { in nfsd4_setclientid_confirm()
4060 nfsd4_change_callback(conf, &unconf->cl_cb_conn); in nfsd4_setclientid_confirm()
4062 old = find_confirmed_client_by_name(&unconf->cl_name, nn); in nfsd4_setclientid_confirm()
4066 && !same_creds(&unconf->cl_cred, in nfsd4_setclientid_confirm()
4067 &old->cl_cred)) { in nfsd4_setclientid_confirm()
4081 spin_unlock(&nn->client_lock); in nfsd4_setclientid_confirm()
4083 spin_lock(&nn->client_lock); in nfsd4_setclientid_confirm()
4086 spin_unlock(&nn->client_lock); in nfsd4_setclientid_confirm()
4103 refcount_set(&fp->fi_ref, 1); in nfsd4_init_file()
4104 spin_lock_init(&fp->fi_lock); in nfsd4_init_file()
4105 INIT_LIST_HEAD(&fp->fi_stateids); in nfsd4_init_file()
4106 INIT_LIST_HEAD(&fp->fi_delegations); in nfsd4_init_file()
4107 INIT_LIST_HEAD(&fp->fi_clnt_odstate); in nfsd4_init_file()
4108 fh_copy_shallow(&fp->fi_fhandle, fh); in nfsd4_init_file()
4109 fp->fi_deleg_file = NULL; in nfsd4_init_file()
4110 fp->fi_had_conflict = false; in nfsd4_init_file()
4111 fp->fi_share_deny = 0; in nfsd4_init_file()
4112 memset(fp->fi_fds, 0, sizeof(fp->fi_fds)); in nfsd4_init_file()
4113 memset(fp->fi_access, 0, sizeof(fp->fi_access)); in nfsd4_init_file()
4115 INIT_LIST_HEAD(&fp->fi_lo_states); in nfsd4_init_file()
4116 atomic_set(&fp->fi_lo_recalls, 0); in nfsd4_init_file()
4118 hlist_add_head_rcu(&fp->fi_hash, &file_hashtbl[hashval]); in nfsd4_init_file()
4179 return -ENOMEM; in nfsd4_init_slabs()
4184 rp->rp_status = nfserr_serverfault; in init_nfs4_replay()
4185 rp->rp_buflen = 0; in init_nfs4_replay()
4186 rp->rp_buf = rp->rp_ibuf; in init_nfs4_replay()
4187 mutex_init(&rp->rp_mutex); in init_nfs4_replay()
4194 mutex_lock(&so->so_replay.rp_mutex); in nfsd4_cstate_assign_replay()
4195 cstate->replay_owner = nfs4_get_stateowner(so); in nfsd4_cstate_assign_replay()
4201 struct nfs4_stateowner *so = cstate->replay_owner; in nfsd4_cstate_clear_replay()
4204 cstate->replay_owner = NULL; in nfsd4_cstate_clear_replay()
4205 mutex_unlock(&so->so_replay.rp_mutex); in nfsd4_cstate_clear_replay()
4218 xdr_netobj_dup(&sop->so_owner, owner, GFP_KERNEL); in alloc_stateowner()
4219 if (!sop->so_owner.data) { in alloc_stateowner()
4224 INIT_LIST_HEAD(&sop->so_stateids); in alloc_stateowner()
4225 sop->so_client = clp; in alloc_stateowner()
4226 init_nfs4_replay(&sop->so_replay); in alloc_stateowner()
4227 atomic_set(&sop->so_count, 1); in alloc_stateowner()
4233 lockdep_assert_held(&clp->cl_lock); in hash_openowner()
4235 list_add(&oo->oo_owner.so_strhash, in hash_openowner()
4236 &clp->cl_ownerstr_hashtbl[strhashval]); in hash_openowner()
4237 list_add(&oo->oo_perclient, &clp->cl_openowners); in hash_openowner()
4261 struct nfs4_openowner *oo = open->op_openowner; in nfsd4_find_existing_open()
4263 lockdep_assert_held(&fp->fi_lock); in nfsd4_find_existing_open()
4265 list_for_each_entry(local, &fp->fi_stateids, st_perfile) { in nfsd4_find_existing_open()
4267 if (local->st_stateowner->so_is_open_owner == 0) in nfsd4_find_existing_open()
4269 if (local->st_stateowner != &oo->oo_owner) in nfsd4_find_existing_open()
4271 if (local->st_stid.sc_type == NFS4_OPEN_STID) { in nfsd4_find_existing_open()
4273 refcount_inc(&ret->st_stid.sc_count); in nfsd4_find_existing_open()
4285 switch (s->sc_type) { in nfsd4_verify_open_stid()
4305 mutex_lock_nested(&stp->st_mutex, LOCK_STATEID_MUTEX); in nfsd4_lock_ol_stateid()
4306 ret = nfsd4_verify_open_stid(&stp->st_stid); in nfsd4_lock_ol_stateid()
4308 mutex_unlock(&stp->st_mutex); in nfsd4_lock_ol_stateid()
4317 spin_lock(&fp->fi_lock); in nfsd4_find_and_lock_existing_open()
4319 spin_unlock(&fp->fi_lock); in nfsd4_find_and_lock_existing_open()
4322 nfs4_put_stid(&stp->st_stid); in nfsd4_find_and_lock_existing_open()
4331 struct nfs4_client *clp = cstate->clp; in alloc_init_open_stateowner()
4334 oo = alloc_stateowner(openowner_slab, &open->op_owner, clp); in alloc_init_open_stateowner()
4337 oo->oo_owner.so_ops = &openowner_ops; in alloc_init_open_stateowner()
4338 oo->oo_owner.so_is_open_owner = 1; in alloc_init_open_stateowner()
4339 oo->oo_owner.so_seqid = open->op_seqid; in alloc_init_open_stateowner()
4340 oo->oo_flags = 0; in alloc_init_open_stateowner()
4342 oo->oo_flags |= NFS4_OO_CONFIRMED; in alloc_init_open_stateowner()
4343 oo->oo_time = 0; in alloc_init_open_stateowner()
4344 oo->oo_last_closed_stid = NULL; in alloc_init_open_stateowner()
4345 INIT_LIST_HEAD(&oo->oo_close_lru); in alloc_init_open_stateowner()
4346 spin_lock(&clp->cl_lock); in alloc_init_open_stateowner()
4352 nfs4_free_stateowner(&oo->oo_owner); in alloc_init_open_stateowner()
4354 spin_unlock(&clp->cl_lock); in alloc_init_open_stateowner()
4362 struct nfs4_openowner *oo = open->op_openowner; in init_open_stateid()
4366 stp = open->op_stp; in init_open_stateid()
4368 mutex_init(&stp->st_mutex); in init_open_stateid()
4369 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX); in init_open_stateid()
4372 spin_lock(&oo->oo_owner.so_client->cl_lock); in init_open_stateid()
4373 spin_lock(&fp->fi_lock); in init_open_stateid()
4379 open->op_stp = NULL; in init_open_stateid()
4380 refcount_inc(&stp->st_stid.sc_count); in init_open_stateid()
4381 stp->st_stid.sc_type = NFS4_OPEN_STID; in init_open_stateid()
4382 INIT_LIST_HEAD(&stp->st_locks); in init_open_stateid()
4383 stp->st_stateowner = nfs4_get_stateowner(&oo->oo_owner); in init_open_stateid()
4385 stp->st_stid.sc_file = fp; in init_open_stateid()
4386 stp->st_access_bmap = 0; in init_open_stateid()
4387 stp->st_deny_bmap = 0; in init_open_stateid()
4388 stp->st_openstp = NULL; in init_open_stateid()
4389 list_add(&stp->st_perstateowner, &oo->oo_owner.so_stateids); in init_open_stateid()
4390 list_add(&stp->st_perfile, &fp->fi_stateids); in init_open_stateid()
4393 spin_unlock(&fp->fi_lock); in init_open_stateid()
4394 spin_unlock(&oo->oo_owner.so_client->cl_lock); in init_open_stateid()
4398 nfs4_put_stid(&retstp->st_stid); in init_open_stateid()
4402 mutex_unlock(&stp->st_mutex); in init_open_stateid()
4417 struct nfs4_openowner *oo = openowner(s->st_stateowner); in move_to_close_lru()
4418 struct nfsd_net *nn = net_generic(s->st_stid.sc_client->net, in move_to_close_lru()
4432 wait_event(close_wq, refcount_read(&s->st_stid.sc_count) == 2); in move_to_close_lru()
4435 if (s->st_stid.sc_file) { in move_to_close_lru()
4436 put_nfs4_file(s->st_stid.sc_file); in move_to_close_lru()
4437 s->st_stid.sc_file = NULL; in move_to_close_lru()
4440 spin_lock(&nn->client_lock); in move_to_close_lru()
4441 last = oo->oo_last_closed_stid; in move_to_close_lru()
4442 oo->oo_last_closed_stid = s; in move_to_close_lru()
4443 list_move_tail(&oo->oo_close_lru, &nn->close_lru); in move_to_close_lru()
4444 oo->oo_time = ktime_get_boottime_seconds(); in move_to_close_lru()
4445 spin_unlock(&nn->client_lock); in move_to_close_lru()
4447 nfs4_put_stid(&last->st_stid); in move_to_close_lru()
4458 if (fh_match(&fp->fi_fhandle, fh)) { in find_file_locked()
4459 if (refcount_inc_not_zero(&fp->fi_ref)) in find_file_locked()
4511 fp = find_file(&current_fh->fh_handle); in nfs4_share_conflict()
4515 spin_lock(&fp->fi_lock); in nfs4_share_conflict()
4516 if (fp->fi_share_deny & deny_type) in nfs4_share_conflict()
4518 spin_unlock(&fp->fi_lock); in nfs4_share_conflict()
4526 struct nfsd_net *nn = net_generic(dp->dl_stid.sc_client->net, in nfsd4_cb_recall_prepare()
4529 block_delegations(&dp->dl_stid.sc_file->fi_fhandle); in nfsd4_cb_recall_prepare()
4533 * already holding inode->i_lock. in nfsd4_cb_recall_prepare()
4539 if (delegation_hashed(dp) && dp->dl_time == 0) { in nfsd4_cb_recall_prepare()
4540 dp->dl_time = ktime_get_boottime_seconds(); in nfsd4_cb_recall_prepare()
4541 list_add_tail(&dp->dl_recall_lru, &nn->del_recall_lru); in nfsd4_cb_recall_prepare()
4551 if (dp->dl_stid.sc_type == NFS4_CLOSED_DELEG_STID || in nfsd4_cb_recall_done()
4552 dp->dl_stid.sc_type == NFS4_REVOKED_DELEG_STID) in nfsd4_cb_recall_done()
4555 switch (task->tk_status) { in nfsd4_cb_recall_done()
4558 case -NFS4ERR_DELAY: in nfsd4_cb_recall_done()
4561 case -EBADHANDLE: in nfsd4_cb_recall_done()
4562 case -NFS4ERR_BAD_STATEID: in nfsd4_cb_recall_done()
4567 if (dp->dl_retries--) { in nfsd4_cb_recall_done()
4581 nfs4_put_stid(&dp->dl_stid); in nfsd4_cb_recall_release()
4599 refcount_inc(&dp->dl_stid.sc_count); in nfsd_break_one_deleg()
4600 nfsd4_run_cb(&dp->dl_recall); in nfsd_break_one_deleg()
4608 struct nfs4_delegation *dp = (struct nfs4_delegation *)fl->fl_owner; in nfsd_break_deleg_cb()
4609 struct nfs4_file *fp = dp->dl_stid.sc_file; in nfsd_break_deleg_cb()
4611 trace_nfsd_deleg_break(&dp->dl_stid.sc_stateid); in nfsd_break_deleg_cb()
4618 fl->fl_break_time = 0; in nfsd_break_deleg_cb()
4620 spin_lock(&fp->fi_lock); in nfsd_break_deleg_cb()
4621 fp->fi_had_conflict = true; in nfsd_break_deleg_cb()
4623 spin_unlock(&fp->fi_lock); in nfsd_break_deleg_cb()
4628 * nfsd_breaker_owns_lease - Check if lease conflict was resolved
4637 struct nfs4_delegation *dl = fl->fl_owner; in nfsd_breaker_owns_lease()
4645 if (rqst->rq_prog != NFS_PROGRAM || rqst->rq_vers < 4) in nfsd_breaker_owns_lease()
4647 clp = *(rqst->rq_lease_breaker); in nfsd_breaker_owns_lease()
4648 return dl->dl_stid.sc_client == clp; in nfsd_breaker_owns_lease()
4658 return -EAGAIN; in nfsd_change_deleg_cb()
4671 if (seqid == so->so_seqid - 1) in nfsd4_check_seqid()
4673 if (seqid == so->so_seqid) in nfsd4_check_seqid()
4685 if (cstate->clp) { in lookup_clientid()
4686 found = cstate->clp; in lookup_clientid()
4687 if (!same_clid(&found->cl_clientid, clid)) in lookup_clientid()
4700 WARN_ON_ONCE(cstate->session); in lookup_clientid()
4701 spin_lock(&nn->client_lock); in lookup_clientid()
4704 spin_unlock(&nn->client_lock); in lookup_clientid()
4707 atomic_inc(&found->cl_rpc_users); in lookup_clientid()
4708 spin_unlock(&nn->client_lock); in lookup_clientid()
4711 cstate->clp = found; in lookup_clientid()
4719 clientid_t *clientid = &open->op_clientid; in nfsd4_process_open1()
4725 if (STALE_CLIENTID(&open->op_clientid, nn)) in nfsd4_process_open1()
4731 open->op_file = nfsd4_alloc_file(); in nfsd4_process_open1()
4732 if (open->op_file == NULL) in nfsd4_process_open1()
4738 clp = cstate->clp; in nfsd4_process_open1()
4740 strhashval = ownerstr_hashval(&open->op_owner); in nfsd4_process_open1()
4742 open->op_openowner = oo; in nfsd4_process_open1()
4746 if (!(oo->oo_flags & NFS4_OO_CONFIRMED)) { in nfsd4_process_open1()
4749 open->op_openowner = NULL; in nfsd4_process_open1()
4752 status = nfsd4_check_seqid(cstate, &oo->oo_owner, open->op_seqid); in nfsd4_process_open1()
4760 open->op_openowner = oo; in nfsd4_process_open1()
4762 open->op_stp = nfs4_alloc_open_stateid(clp); in nfsd4_process_open1()
4763 if (!open->op_stp) in nfsd4_process_open1()
4767 (cstate->current_fh.fh_export->ex_flags & NFSEXP_PNFS)) { in nfsd4_process_open1()
4768 open->op_odstate = alloc_clnt_odstate(clp); in nfsd4_process_open1()
4769 if (!open->op_odstate) in nfsd4_process_open1()
4779 if ((flags & WR_STATE) && (dp->dl_type == NFS4_OPEN_DELEGATE_READ)) in nfs4_check_delegmode()
4803 return open->op_claim_type == NFS4_OPEN_CLAIM_DELEGATE_CUR || in nfsd4_is_deleg_cur()
4804 open->op_claim_type == NFS4_OPEN_CLAIM_DELEG_CUR_FH; in nfsd4_is_deleg_cur()
4815 deleg = find_deleg_stateid(cl, &open->op_delegate_stateid); in nfs4_check_deleg()
4818 if (deleg->dl_stid.sc_type == NFS4_REVOKED_DELEG_STID) { in nfs4_check_deleg()
4819 nfs4_put_stid(&deleg->dl_stid); in nfs4_check_deleg()
4820 if (cl->cl_minorversion) in nfs4_check_deleg()
4824 flags = share_access_to_flags(open->op_share_access); in nfs4_check_deleg()
4827 nfs4_put_stid(&deleg->dl_stid); in nfs4_check_deleg()
4836 open->op_openowner->oo_flags |= NFS4_OO_CONFIRMED; in nfs4_check_deleg()
4859 if (!open->op_truncate) in nfsd4_truncate()
4861 if (!(open->op_share_access & NFS4_SHARE_ACCESS_WRITE)) in nfsd4_truncate()
4872 int oflag = nfs4_access_to_omode(open->op_share_access); in nfs4_get_vfs_file()
4873 int access = nfs4_access_to_access(open->op_share_access); in nfs4_get_vfs_file()
4876 spin_lock(&fp->fi_lock); in nfs4_get_vfs_file()
4882 status = nfs4_file_check_deny(fp, open->op_share_deny); in nfs4_get_vfs_file()
4884 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
4889 status = nfs4_file_get_access(fp, open->op_share_access); in nfs4_get_vfs_file()
4891 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
4896 old_access_bmap = stp->st_access_bmap; in nfs4_get_vfs_file()
4897 set_access(open->op_share_access, stp); in nfs4_get_vfs_file()
4900 old_deny_bmap = stp->st_deny_bmap; in nfs4_get_vfs_file()
4901 set_deny(open->op_share_deny, stp); in nfs4_get_vfs_file()
4902 fp->fi_share_deny |= (open->op_share_deny & NFS4_SHARE_DENY_BOTH); in nfs4_get_vfs_file()
4904 if (!fp->fi_fds[oflag]) { in nfs4_get_vfs_file()
4905 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
4909 spin_lock(&fp->fi_lock); in nfs4_get_vfs_file()
4910 if (!fp->fi_fds[oflag]) { in nfs4_get_vfs_file()
4911 fp->fi_fds[oflag] = nf; in nfs4_get_vfs_file()
4915 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
4919 status = nfserrno(nfsd_open_break_lease(cur_fh->fh_dentry->d_inode, in nfs4_get_vfs_file()
4930 stp->st_access_bmap = old_access_bmap; in nfs4_get_vfs_file()
4931 nfs4_file_put_access(fp, open->op_share_access); in nfs4_get_vfs_file()
4940 unsigned char old_deny_bmap = stp->st_deny_bmap; in nfs4_upgrade_open()
4942 if (!test_access(open->op_share_access, stp)) in nfs4_upgrade_open()
4946 spin_lock(&fp->fi_lock); in nfs4_upgrade_open()
4947 status = nfs4_file_check_deny(fp, open->op_share_deny); in nfs4_upgrade_open()
4949 set_deny(open->op_share_deny, stp); in nfs4_upgrade_open()
4950 fp->fi_share_deny |= in nfs4_upgrade_open()
4951 (open->op_share_deny & NFS4_SHARE_DENY_BOTH); in nfs4_upgrade_open()
4953 spin_unlock(&fp->fi_lock); in nfs4_upgrade_open()
4967 if (clp->cl_cb_state == NFSD4_CB_UP) in nfsd4_cb_channel_good()
4974 return clp->cl_minorversion && clp->cl_cb_state == NFSD4_CB_UNKNOWN; in nfsd4_cb_channel_good()
4985 fl->fl_lmops = &nfsd_lease_mng_ops; in nfs4_alloc_init_lease()
4986 fl->fl_flags = FL_DELEG; in nfs4_alloc_init_lease()
4987 fl->fl_type = flag == NFS4_OPEN_DELEGATE_READ? F_RDLCK: F_WRLCK; in nfs4_alloc_init_lease()
4988 fl->fl_end = OFFSET_MAX; in nfs4_alloc_init_lease()
4989 fl->fl_owner = (fl_owner_t)dp; in nfs4_alloc_init_lease()
4990 fl->fl_pid = current->tgid; in nfs4_alloc_init_lease()
4991 fl->fl_file = dp->dl_stid.sc_file->fi_deleg_file->nf_file; in nfs4_alloc_init_lease()
5009 if (fp->fi_had_conflict) in nfs4_set_delegation()
5010 return ERR_PTR(-EAGAIN); in nfs4_set_delegation()
5016 return ERR_PTR(-EBADF); in nfs4_set_delegation()
5019 spin_lock(&fp->fi_lock); in nfs4_set_delegation()
5021 status = -EAGAIN; in nfs4_set_delegation()
5022 else if (!fp->fi_deleg_file) { in nfs4_set_delegation()
5023 fp->fi_deleg_file = nf; in nfs4_set_delegation()
5026 fp->fi_delegees = 1; in nfs4_set_delegation()
5029 fp->fi_delegees++; in nfs4_set_delegation()
5030 spin_unlock(&fp->fi_lock); in nfs4_set_delegation()
5037 status = -ENOMEM; in nfs4_set_delegation()
5046 status = vfs_setlease(fp->fi_deleg_file->nf_file, fl->fl_type, &fl, NULL); in nfs4_set_delegation()
5053 spin_lock(&fp->fi_lock); in nfs4_set_delegation()
5054 if (fp->fi_had_conflict) in nfs4_set_delegation()
5055 status = -EAGAIN; in nfs4_set_delegation()
5058 spin_unlock(&fp->fi_lock); in nfs4_set_delegation()
5066 vfs_setlease(fp->fi_deleg_file->nf_file, F_UNLCK, NULL, (void **)&dp); in nfs4_set_delegation()
5068 put_clnt_odstate(dp->dl_clnt_odstate); in nfs4_set_delegation()
5069 nfs4_put_stid(&dp->dl_stid); in nfs4_set_delegation()
5077 open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE_EXT; in nfsd4_open_deleg_none_ext()
5078 if (status == -EAGAIN) in nfsd4_open_deleg_none_ext()
5079 open->op_why_no_deleg = WND4_CONTENTION; in nfsd4_open_deleg_none_ext()
5081 open->op_why_no_deleg = WND4_RESOURCE; in nfsd4_open_deleg_none_ext()
5082 switch (open->op_deleg_want) { in nfsd4_open_deleg_none_ext()
5088 open->op_why_no_deleg = WND4_CANCELLED; in nfsd4_open_deleg_none_ext()
5107 struct nfs4_openowner *oo = openowner(stp->st_stateowner); in nfs4_open_delegation()
5108 struct nfs4_client *clp = stp->st_stid.sc_client; in nfs4_open_delegation()
5112 cb_up = nfsd4_cb_channel_good(oo->oo_owner.so_client); in nfs4_open_delegation()
5113 open->op_recall = 0; in nfs4_open_delegation()
5114 switch (open->op_claim_type) { in nfs4_open_delegation()
5117 open->op_recall = 1; in nfs4_open_delegation()
5118 if (open->op_delegate_type != NFS4_OPEN_DELEGATE_READ) in nfs4_open_delegation()
5128 if (locks_in_grace(clp->net)) in nfs4_open_delegation()
5130 if (!cb_up || !(oo->oo_flags & NFS4_OO_CONFIRMED)) in nfs4_open_delegation()
5139 if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) in nfs4_open_delegation()
5141 if (open->op_create == NFS4_OPEN_CREATE) in nfs4_open_delegation()
5147 dp = nfs4_set_delegation(clp, fh, stp->st_stid.sc_file, stp->st_clnt_odstate); in nfs4_open_delegation()
5151 memcpy(&open->op_delegate_stateid, &dp->dl_stid.sc_stateid, sizeof(dp->dl_stid.sc_stateid)); in nfs4_open_delegation()
5153 trace_nfsd_deleg_read(&dp->dl_stid.sc_stateid); in nfs4_open_delegation()
5154 open->op_delegate_type = NFS4_OPEN_DELEGATE_READ; in nfs4_open_delegation()
5155 nfs4_put_stid(&dp->dl_stid); in nfs4_open_delegation()
5158 open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE; in nfs4_open_delegation()
5159 if (open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS && in nfs4_open_delegation()
5160 open->op_delegate_type != NFS4_OPEN_DELEGATE_NONE) { in nfs4_open_delegation()
5162 open->op_recall = 1; in nfs4_open_delegation()
5166 if (open->op_deleg_want) in nfs4_open_delegation()
5174 if (open->op_deleg_want == NFS4_SHARE_WANT_READ_DELEG && in nfsd4_deleg_xgrade_none_ext()
5175 dp->dl_type == NFS4_OPEN_DELEGATE_WRITE) { in nfsd4_deleg_xgrade_none_ext()
5176 open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE_EXT; in nfsd4_deleg_xgrade_none_ext()
5177 open->op_why_no_deleg = WND4_NOT_SUPP_DOWNGRADE; in nfsd4_deleg_xgrade_none_ext()
5178 } else if (open->op_deleg_want == NFS4_SHARE_WANT_WRITE_DELEG && in nfsd4_deleg_xgrade_none_ext()
5179 dp->dl_type == NFS4_OPEN_DELEGATE_WRITE) { in nfsd4_deleg_xgrade_none_ext()
5180 open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE_EXT; in nfsd4_deleg_xgrade_none_ext()
5181 open->op_why_no_deleg = WND4_NOT_SUPP_UPGRADE; in nfsd4_deleg_xgrade_none_ext()
5192 struct nfsd4_compoundres *resp = rqstp->rq_resp; in nfsd4_process_open2()
5193 struct nfs4_client *cl = open->op_openowner->oo_owner.so_client; in nfsd4_process_open2()
5205 fp = find_or_add_file(open->op_file, &current_fh->fh_handle); in nfsd4_process_open2()
5206 if (fp != open->op_file) { in nfsd4_process_open2()
5212 open->op_file = NULL; in nfsd4_process_open2()
5220 if (!open->op_stp) in nfsd4_process_open2()
5234 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
5240 stp->st_stid.sc_type = NFS4_CLOSED_STID; in nfsd4_process_open2()
5242 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
5246 stp->st_clnt_odstate = find_or_hash_clnt_odstate(fp, in nfsd4_process_open2()
5247 open->op_odstate); in nfsd4_process_open2()
5248 if (stp->st_clnt_odstate == open->op_odstate) in nfsd4_process_open2()
5249 open->op_odstate = NULL; in nfsd4_process_open2()
5252 nfs4_inc_and_copy_stateid(&open->op_stateid, &stp->st_stid); in nfsd4_process_open2()
5253 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
5255 if (nfsd4_has_session(&resp->cstate)) { in nfsd4_process_open2()
5256 if (open->op_deleg_want & NFS4_SHARE_WANT_NO_DELEG) { in nfsd4_process_open2()
5257 open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE_EXT; in nfsd4_process_open2()
5258 open->op_why_no_deleg = WND4_NOT_WANTED; in nfsd4_process_open2()
5270 trace_nfsd_open(&stp->st_stid.sc_stateid); in nfsd4_process_open2()
5273 if (open->op_delegate_type == NFS4_OPEN_DELEGATE_NONE && dp && in nfsd4_process_open2()
5274 open->op_deleg_want) in nfsd4_process_open2()
5279 if (status == 0 && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS) in nfsd4_process_open2()
5280 open->op_openowner->oo_flags |= NFS4_OO_CONFIRMED; in nfsd4_process_open2()
5284 open->op_rflags = NFS4_OPEN_RESULT_LOCKTYPE_POSIX; in nfsd4_process_open2()
5285 if (nfsd4_has_session(&resp->cstate)) in nfsd4_process_open2()
5286 open->op_rflags |= NFS4_OPEN_RESULT_MAY_NOTIFY_LOCK; in nfsd4_process_open2()
5287 else if (!(open->op_openowner->oo_flags & NFS4_OO_CONFIRMED)) in nfsd4_process_open2()
5288 open->op_rflags |= NFS4_OPEN_RESULT_CONFIRM; in nfsd4_process_open2()
5291 nfs4_put_stid(&dp->dl_stid); in nfsd4_process_open2()
5293 nfs4_put_stid(&stp->st_stid); in nfsd4_process_open2()
5301 if (open->op_openowner) { in nfsd4_cleanup_open_state()
5302 struct nfs4_stateowner *so = &open->op_openowner->oo_owner; in nfsd4_cleanup_open_state()
5307 if (open->op_file) in nfsd4_cleanup_open_state()
5308 kmem_cache_free(file_slab, open->op_file); in nfsd4_cleanup_open_state()
5309 if (open->op_stp) in nfsd4_cleanup_open_state()
5310 nfs4_put_stid(&open->op_stp->st_stid); in nfsd4_cleanup_open_state()
5311 if (open->op_odstate) in nfsd4_cleanup_open_state()
5312 kmem_cache_free(odstate_slab, open->op_odstate); in nfsd4_cleanup_open_state()
5319 clientid_t *clid = &u->renew; in nfsd4_renew()
5328 clp = cstate->clp; in nfsd4_renew()
5330 if (!list_empty(&clp->cl_delegations) in nfsd4_renew()
5331 && clp->cl_cb_state != NFSD4_CB_UP) in nfsd4_renew()
5342 if (nn->grace_ended) in nfsd4_end_grace()
5346 nn->grace_ended = true; in nfsd4_end_grace()
5363 locks_end_grace(&nn->nfsd4_manager); in nfsd4_end_grace()
5377 time64_t double_grace_period_end = nn->boot_time + in clients_still_reclaiming()
5378 2 * nn->nfsd4_lease; in clients_still_reclaiming()
5380 if (nn->track_reclaim_completes && in clients_still_reclaiming()
5381 atomic_read(&nn->nr_reclaim_complete) == in clients_still_reclaiming()
5382 nn->reclaim_str_hashtbl_size) in clients_still_reclaiming()
5384 if (!nn->somebody_reclaimed) in clients_still_reclaiming()
5386 nn->somebody_reclaimed = false; in clients_still_reclaiming()
5405 time64_t cutoff = ktime_get_boottime_seconds() - nn->nfsd4_lease; in nfs4_laundromat()
5406 time64_t t, new_timeo = nn->nfsd4_lease; in nfs4_laundromat()
5418 spin_lock(&nn->s2s_cp_lock); in nfs4_laundromat()
5419 idr_for_each_entry(&nn->s2s_cp_stateids, cps_t, i) { in nfs4_laundromat()
5421 if (cps->cp_stateid.sc_type == NFS4_COPYNOTIFY_STID && in nfs4_laundromat()
5422 cps->cpntf_time < cutoff) in nfs4_laundromat()
5425 spin_unlock(&nn->s2s_cp_lock); in nfs4_laundromat()
5427 spin_lock(&nn->client_lock); in nfs4_laundromat()
5428 list_for_each_safe(pos, next, &nn->client_lru) { in nfs4_laundromat()
5430 if (clp->cl_time > cutoff) { in nfs4_laundromat()
5431 t = clp->cl_time - cutoff; in nfs4_laundromat()
5436 trace_nfsd_clid_expired(&clp->cl_clientid); in nfs4_laundromat()
5439 list_add(&clp->cl_lru, &reaplist); in nfs4_laundromat()
5441 spin_unlock(&nn->client_lock); in nfs4_laundromat()
5444 trace_nfsd_clid_purged(&clp->cl_clientid); in nfs4_laundromat()
5445 list_del_init(&clp->cl_lru); in nfs4_laundromat()
5449 list_for_each_safe(pos, next, &nn->del_recall_lru) { in nfs4_laundromat()
5451 if (dp->dl_time > cutoff) { in nfs4_laundromat()
5452 t = dp->dl_time - cutoff; in nfs4_laundromat()
5457 list_add(&dp->dl_recall_lru, &reaplist); in nfs4_laundromat()
5463 list_del_init(&dp->dl_recall_lru); in nfs4_laundromat()
5467 spin_lock(&nn->client_lock); in nfs4_laundromat()
5468 while (!list_empty(&nn->close_lru)) { in nfs4_laundromat()
5469 oo = list_first_entry(&nn->close_lru, struct nfs4_openowner, in nfs4_laundromat()
5471 if (oo->oo_time > cutoff) { in nfs4_laundromat()
5472 t = oo->oo_time - cutoff; in nfs4_laundromat()
5476 list_del_init(&oo->oo_close_lru); in nfs4_laundromat()
5477 stp = oo->oo_last_closed_stid; in nfs4_laundromat()
5478 oo->oo_last_closed_stid = NULL; in nfs4_laundromat()
5479 spin_unlock(&nn->client_lock); in nfs4_laundromat()
5480 nfs4_put_stid(&stp->st_stid); in nfs4_laundromat()
5481 spin_lock(&nn->client_lock); in nfs4_laundromat()
5483 spin_unlock(&nn->client_lock); in nfs4_laundromat()
5488 * So, we clean out any un-revisited request after a lease period in nfs4_laundromat()
5497 spin_lock(&nn->blocked_locks_lock); in nfs4_laundromat()
5498 while (!list_empty(&nn->blocked_locks_lru)) { in nfs4_laundromat()
5499 nbl = list_first_entry(&nn->blocked_locks_lru, in nfs4_laundromat()
5501 if (nbl->nbl_time > cutoff) { in nfs4_laundromat()
5502 t = nbl->nbl_time - cutoff; in nfs4_laundromat()
5506 list_move(&nbl->nbl_lru, &reaplist); in nfs4_laundromat()
5507 list_del_init(&nbl->nbl_list); in nfs4_laundromat()
5509 spin_unlock(&nn->blocked_locks_lock); in nfs4_laundromat()
5514 list_del_init(&nbl->nbl_lru); in nfs4_laundromat()
5534 queue_delayed_work(laundry_wq, &nn->laundromat_work, t*HZ); in laundromat_main()
5539 if (!fh_match(&fhp->fh_handle, &stp->sc_file->fi_fhandle)) in nfs4_check_fh()
5565 if (stp->st_openstp) in nfs4_check_openmode()
5566 stp = stp->st_openstp; in nfs4_check_openmode()
5609 if (has_session && in->si_generation == 0) in check_stateid_generation()
5612 if (in->si_generation == ref->si_generation) in check_stateid_generation()
5620 * non-buggy client. For example, if the client sends a lock in check_stateid_generation()
5635 spin_lock(&s->sc_lock); in nfsd4_stid_check_stateid_generation()
5638 ret = check_stateid_generation(in, &s->sc_stateid, has_session); in nfsd4_stid_check_stateid_generation()
5639 spin_unlock(&s->sc_lock); in nfsd4_stid_check_stateid_generation()
5645 if (ols->st_stateowner->so_is_open_owner && in nfsd4_check_openowner_confirmed()
5646 !(openowner(ols->st_stateowner)->oo_flags & NFS4_OO_CONFIRMED)) in nfsd4_check_openowner_confirmed()
5659 spin_lock(&cl->cl_lock); in nfsd4_validate_stateid()
5666 switch (s->sc_type) { in nfsd4_validate_stateid()
5678 printk("unknown stateid type %x\n", s->sc_type); in nfsd4_validate_stateid()
5685 spin_unlock(&cl->cl_lock); in nfsd4_validate_stateid()
5709 status = lookup_clientid(&stateid->si_opaque.so_clid, cstate, nn, in nfsd4_lookup_stateid()
5712 if (cstate->session) in nfsd4_lookup_stateid()
5718 *s = find_stateid_by_type(cstate->clp, stateid, typemask); in nfsd4_lookup_stateid()
5721 if (((*s)->sc_type == NFS4_REVOKED_DELEG_STID) && !return_revoked) { in nfsd4_lookup_stateid()
5723 if (cstate->minorversion) in nfsd4_lookup_stateid()
5736 switch (s->sc_type) { in nfs4_find_file()
5738 if (WARN_ON_ONCE(!s->sc_file->fi_deleg_file)) in nfs4_find_file()
5740 return nfsd_file_get(s->sc_file->fi_deleg_file); in nfs4_find_file()
5744 return find_readable_file(s->sc_file); in nfs4_find_file()
5746 return find_writeable_file(s->sc_file); in nfs4_find_file()
5773 status = nfsd_permission(rqstp, fhp->fh_export, fhp->fh_dentry, in nfs4_check_file()
5791 WARN_ON_ONCE(cps->cp_stateid.sc_type != NFS4_COPYNOTIFY_STID); in _free_cpntf_state_locked()
5792 if (!refcount_dec_and_test(&cps->cp_stateid.sc_count)) in _free_cpntf_state_locked()
5794 list_del(&cps->cp_list); in _free_cpntf_state_locked()
5795 idr_remove(&nn->s2s_cp_stateids, in _free_cpntf_state_locked()
5796 cps->cp_stateid.stid.si_opaque.so_id); in _free_cpntf_state_locked()
5811 if (st->si_opaque.so_clid.cl_id != nn->s2s_cp_cl_id) in manage_cpntf_state()
5813 spin_lock(&nn->s2s_cp_lock); in manage_cpntf_state()
5814 cps_t = idr_find(&nn->s2s_cp_stateids, st->si_opaque.so_id); in manage_cpntf_state()
5818 if (state->cp_stateid.sc_type != NFS4_COPYNOTIFY_STID) { in manage_cpntf_state()
5823 refcount_inc(&state->cp_stateid.sc_count); in manage_cpntf_state()
5828 spin_unlock(&nn->s2s_cp_lock); in manage_cpntf_state()
5847 cps->cpntf_time = ktime_get_boottime_seconds(); in find_cpntf_state()
5849 status = lookup_clientid(&cps->cp_p_clid, &cstate, nn, true); in find_cpntf_state()
5852 status = nfsd4_lookup_stateid(&cstate, &cps->cp_p_stateid, in find_cpntf_state()
5863 spin_lock(&nn->s2s_cp_lock); in nfs4_put_cpntf_state()
5865 spin_unlock(&nn->s2s_cp_lock); in nfs4_put_cpntf_state()
5877 struct inode *ino = d_inode(fhp->fh_dentry); in nfs4_preprocess_stateid_op()
5906 switch (s->sc_type) { in nfs4_preprocess_stateid_op()
5942 struct nfsd4_test_stateid *test_stateid = &u->test_stateid; in nfsd4_test_stateid()
5944 struct nfs4_client *cl = cstate->session->se_client; in nfsd4_test_stateid()
5946 list_for_each_entry(stateid, &test_stateid->ts_stateid_list, ts_id_list) in nfsd4_test_stateid()
5947 stateid->ts_id_status = in nfsd4_test_stateid()
5948 nfsd4_validate_stateid(cl, &stateid->ts_id_stateid); in nfsd4_test_stateid()
5963 ret = check_stateid_generation(stateid, &s->sc_stateid, 1); in nfsd4_free_lock_stateid()
5968 if (check_for_locks(stp->st_stid.sc_file, in nfsd4_free_lock_stateid()
5969 lockowner(stp->st_stateowner))) in nfsd4_free_lock_stateid()
5976 mutex_unlock(&stp->st_mutex); in nfsd4_free_lock_stateid()
5986 struct nfsd4_free_stateid *free_stateid = &u->free_stateid; in nfsd4_free_stateid()
5987 stateid_t *stateid = &free_stateid->fr_stateid; in nfsd4_free_stateid()
5990 struct nfs4_client *cl = cstate->session->se_client; in nfsd4_free_stateid()
5993 spin_lock(&cl->cl_lock); in nfsd4_free_stateid()
5997 spin_lock(&s->sc_lock); in nfsd4_free_stateid()
5998 switch (s->sc_type) { in nfsd4_free_stateid()
6003 ret = check_stateid_generation(stateid, &s->sc_stateid, 1); in nfsd4_free_stateid()
6009 spin_unlock(&s->sc_lock); in nfsd4_free_stateid()
6010 refcount_inc(&s->sc_count); in nfsd4_free_stateid()
6011 spin_unlock(&cl->cl_lock); in nfsd4_free_stateid()
6015 spin_unlock(&s->sc_lock); in nfsd4_free_stateid()
6017 list_del_init(&dp->dl_recall_lru); in nfsd4_free_stateid()
6018 spin_unlock(&cl->cl_lock); in nfsd4_free_stateid()
6024 spin_unlock(&s->sc_lock); in nfsd4_free_stateid()
6026 spin_unlock(&cl->cl_lock); in nfsd4_free_stateid()
6040 struct svc_fh *current_fh = &cstate->current_fh; in nfs4_seqid_op_checks()
6041 struct nfs4_stateowner *sop = stp->st_stateowner; in nfs4_seqid_op_checks()
6050 status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate)); in nfs4_seqid_op_checks()
6052 status = nfs4_check_fh(current_fh, &stp->st_stid); in nfs4_seqid_op_checks()
6054 mutex_unlock(&stp->st_mutex); in nfs4_seqid_op_checks()
6078 nfsd4_cstate_assign_replay(cstate, stp->st_stateowner); in nfs4_preprocess_seqid_op()
6084 nfs4_put_stid(&stp->st_stid); in nfs4_preprocess_seqid_op()
6099 oo = openowner(stp->st_stateowner); in nfs4_preprocess_confirmed_seqid_op()
6100 if (!(oo->oo_flags & NFS4_OO_CONFIRMED)) { in nfs4_preprocess_confirmed_seqid_op()
6101 mutex_unlock(&stp->st_mutex); in nfs4_preprocess_confirmed_seqid_op()
6102 nfs4_put_stid(&stp->st_stid); in nfs4_preprocess_confirmed_seqid_op()
6113 struct nfsd4_open_confirm *oc = &u->open_confirm; in nfsd4_open_confirm()
6120 cstate->current_fh.fh_dentry); in nfsd4_open_confirm()
6122 status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0); in nfsd4_open_confirm()
6127 oc->oc_seqid, &oc->oc_req_stateid, in nfsd4_open_confirm()
6131 oo = openowner(stp->st_stateowner); in nfsd4_open_confirm()
6133 if (oo->oo_flags & NFS4_OO_CONFIRMED) { in nfsd4_open_confirm()
6134 mutex_unlock(&stp->st_mutex); in nfsd4_open_confirm()
6137 oo->oo_flags |= NFS4_OO_CONFIRMED; in nfsd4_open_confirm()
6138 nfs4_inc_and_copy_stateid(&oc->oc_resp_stateid, &stp->st_stid); in nfsd4_open_confirm()
6139 mutex_unlock(&stp->st_mutex); in nfsd4_open_confirm()
6140 trace_nfsd_open_confirm(oc->oc_seqid, &stp->st_stid.sc_stateid); in nfsd4_open_confirm()
6141 nfsd4_client_record_create(oo->oo_owner.so_client); in nfsd4_open_confirm()
6144 nfs4_put_stid(&stp->st_stid); in nfsd4_open_confirm()
6154 nfs4_file_put_access(stp->st_stid.sc_file, access); in nfs4_stateid_downgrade_bit()
6180 struct nfsd4_open_downgrade *od = &u->open_downgrade; in nfsd4_open_downgrade()
6186 cstate->current_fh.fh_dentry); in nfsd4_open_downgrade()
6189 if (od->od_deleg_want) in nfsd4_open_downgrade()
6191 od->od_deleg_want); in nfsd4_open_downgrade()
6193 status = nfs4_preprocess_confirmed_seqid_op(cstate, od->od_seqid, in nfsd4_open_downgrade()
6194 &od->od_stateid, &stp, nn); in nfsd4_open_downgrade()
6198 if (!test_access(od->od_share_access, stp)) { in nfsd4_open_downgrade()
6200 stp->st_access_bmap, od->od_share_access); in nfsd4_open_downgrade()
6203 if (!test_deny(od->od_share_deny, stp)) { in nfsd4_open_downgrade()
6205 stp->st_deny_bmap, od->od_share_deny); in nfsd4_open_downgrade()
6208 nfs4_stateid_downgrade(stp, od->od_share_access); in nfsd4_open_downgrade()
6209 reset_union_bmap_deny(od->od_share_deny, stp); in nfsd4_open_downgrade()
6210 nfs4_inc_and_copy_stateid(&od->od_stateid, &stp->st_stid); in nfsd4_open_downgrade()
6213 mutex_unlock(&stp->st_mutex); in nfsd4_open_downgrade()
6214 nfs4_put_stid(&stp->st_stid); in nfsd4_open_downgrade()
6222 struct nfs4_client *clp = s->st_stid.sc_client; in nfsd4_close_open_stateid()
6227 spin_lock(&clp->cl_lock); in nfsd4_close_open_stateid()
6230 if (clp->cl_minorversion) { in nfsd4_close_open_stateid()
6233 spin_unlock(&clp->cl_lock); in nfsd4_close_open_stateid()
6235 nfs4_free_cpntf_statelist(clp->net, &stp->st_stid); in nfsd4_close_open_stateid()
6238 spin_unlock(&clp->cl_lock); in nfsd4_close_open_stateid()
6241 move_to_close_lru(s, clp->net); in nfsd4_close_open_stateid()
6252 struct nfsd4_close *close = &u->close; in nfsd4_close()
6259 cstate->current_fh.fh_dentry); in nfsd4_close()
6261 status = nfs4_preprocess_seqid_op(cstate, close->cl_seqid, in nfsd4_close()
6262 &close->cl_stateid, in nfsd4_close()
6269 stp->st_stid.sc_type = NFS4_CLOSED_STID; in nfsd4_close()
6277 nfs4_inc_and_copy_stateid(&close->cl_stateid, &stp->st_stid); in nfsd4_close()
6280 mutex_unlock(&stp->st_mutex); in nfsd4_close()
6289 memcpy(&close->cl_stateid, &close_stateid, sizeof(close->cl_stateid)); in nfsd4_close()
6292 nfs4_put_stid(&stp->st_stid); in nfsd4_close()
6301 struct nfsd4_delegreturn *dr = &u->delegreturn; in nfsd4_delegreturn()
6303 stateid_t *stateid = &dr->dr_stateid; in nfsd4_delegreturn()
6308 if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0))) in nfsd4_delegreturn()
6315 status = nfsd4_stid_check_stateid_generation(stateid, &dp->dl_stid, nfsd4_has_session(cstate)); in nfsd4_delegreturn()
6321 nfs4_put_stid(&dp->dl_stid); in nfsd4_delegreturn()
6343 return end > start ? end - 1: NFS4_MAX_UINT64; in last_byte_offset()
6347 * TODO: Linux file offsets are _signed_ 64-bit quantities, which means that
6348 * we can't properly handle lock requests that go beyond the (2^63 - 1)-th
6349 * byte, because of sign extension problems. Since NFSv4 calls for 64-bit
6350 * locking, this prevents us from being completely protocol-compliant. The
6357 if (lock->fl_start < 0) in nfs4_transform_lock_offset()
6358 lock->fl_start = OFFSET_MAX; in nfs4_transform_lock_offset()
6359 if (lock->fl_end < 0) in nfs4_transform_lock_offset()
6360 lock->fl_end = OFFSET_MAX; in nfs4_transform_lock_offset()
6368 nfs4_get_stateowner(&lo->lo_owner); in nfsd4_fl_get_owner()
6378 nfs4_put_stateowner(&lo->lo_owner); in nfsd4_fl_put_owner()
6384 struct nfs4_lockowner *lo = (struct nfs4_lockowner *)fl->fl_owner; in nfsd4_lm_notify()
6385 struct net *net = lo->lo_owner.so_client->net; in nfsd4_lm_notify()
6392 spin_lock(&nn->blocked_locks_lock); in nfsd4_lm_notify()
6393 if (!list_empty(&nbl->nbl_list)) { in nfsd4_lm_notify()
6394 list_del_init(&nbl->nbl_list); in nfsd4_lm_notify()
6395 list_del_init(&nbl->nbl_lru); in nfsd4_lm_notify()
6398 spin_unlock(&nn->blocked_locks_lock); in nfsd4_lm_notify()
6401 nfsd4_run_cb(&nbl->nbl_cb); in nfsd4_lm_notify()
6415 if (fl->fl_lmops == &nfsd_posix_mng_ops) { in nfs4_set_lock_denied()
6416 lo = (struct nfs4_lockowner *) fl->fl_owner; in nfs4_set_lock_denied()
6417 xdr_netobj_dup(&deny->ld_owner, &lo->lo_owner.so_owner, in nfs4_set_lock_denied()
6419 if (!deny->ld_owner.data) in nfs4_set_lock_denied()
6422 deny->ld_clientid = lo->lo_owner.so_client->cl_clientid; in nfs4_set_lock_denied()
6425 deny->ld_owner.len = 0; in nfs4_set_lock_denied()
6426 deny->ld_owner.data = NULL; in nfs4_set_lock_denied()
6427 deny->ld_clientid.cl_boot = 0; in nfs4_set_lock_denied()
6428 deny->ld_clientid.cl_id = 0; in nfs4_set_lock_denied()
6430 deny->ld_start = fl->fl_start; in nfs4_set_lock_denied()
6431 deny->ld_length = NFS4_MAX_UINT64; in nfs4_set_lock_denied()
6432 if (fl->fl_end != NFS4_MAX_UINT64) in nfs4_set_lock_denied()
6433 deny->ld_length = fl->fl_end - fl->fl_start + 1; in nfs4_set_lock_denied()
6434 deny->ld_type = NFS4_READ_LT; in nfs4_set_lock_denied()
6435 if (fl->fl_type != F_RDLCK) in nfs4_set_lock_denied()
6436 deny->ld_type = NFS4_WRITE_LT; in nfs4_set_lock_denied()
6445 lockdep_assert_held(&clp->cl_lock); in find_lockowner_str_locked()
6447 list_for_each_entry(so, &clp->cl_ownerstr_hashtbl[strhashval], in find_lockowner_str_locked()
6449 if (so->so_is_open_owner) in find_lockowner_str_locked()
6462 spin_lock(&clp->cl_lock); in find_lockowner_str()
6464 spin_unlock(&clp->cl_lock); in find_lockowner_str()
6487 * Called in nfsd4_lock - therefore, OPEN and OPEN_CONFIRM (if needed) has
6499 lo = alloc_stateowner(lockowner_slab, &lock->lk_new_owner, clp); in alloc_init_lock_stateowner()
6502 INIT_LIST_HEAD(&lo->lo_blocked); in alloc_init_lock_stateowner()
6503 INIT_LIST_HEAD(&lo->lo_owner.so_stateids); in alloc_init_lock_stateowner()
6504 lo->lo_owner.so_is_open_owner = 0; in alloc_init_lock_stateowner()
6505 lo->lo_owner.so_seqid = lock->lk_new_lock_seqid; in alloc_init_lock_stateowner()
6506 lo->lo_owner.so_ops = &lockowner_ops; in alloc_init_lock_stateowner()
6507 spin_lock(&clp->cl_lock); in alloc_init_lock_stateowner()
6508 ret = find_lockowner_str_locked(clp, &lock->lk_new_owner); in alloc_init_lock_stateowner()
6510 list_add(&lo->lo_owner.so_strhash, in alloc_init_lock_stateowner()
6511 &clp->cl_ownerstr_hashtbl[strhashval]); in alloc_init_lock_stateowner()
6514 nfs4_free_stateowner(&lo->lo_owner); in alloc_init_lock_stateowner()
6516 spin_unlock(&clp->cl_lock); in alloc_init_lock_stateowner()
6526 lockdep_assert_held(&ost->st_stid.sc_client->cl_lock); in find_lock_stateid()
6528 /* If ost is not hashed, ost->st_locks will not be valid */ in find_lock_stateid()
6530 list_for_each_entry(lst, &ost->st_locks, st_locks) { in find_lock_stateid()
6531 if (lst->st_stateowner == &lo->lo_owner) { in find_lock_stateid()
6532 refcount_inc(&lst->st_stid.sc_count); in find_lock_stateid()
6544 struct nfs4_client *clp = lo->lo_owner.so_client; in init_lock_stateid()
6547 mutex_init(&stp->st_mutex); in init_lock_stateid()
6548 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX); in init_lock_stateid()
6550 spin_lock(&clp->cl_lock); in init_lock_stateid()
6556 refcount_inc(&stp->st_stid.sc_count); in init_lock_stateid()
6557 stp->st_stid.sc_type = NFS4_LOCK_STID; in init_lock_stateid()
6558 stp->st_stateowner = nfs4_get_stateowner(&lo->lo_owner); in init_lock_stateid()
6560 stp->st_stid.sc_file = fp; in init_lock_stateid()
6561 stp->st_access_bmap = 0; in init_lock_stateid()
6562 stp->st_deny_bmap = open_stp->st_deny_bmap; in init_lock_stateid()
6563 stp->st_openstp = open_stp; in init_lock_stateid()
6564 spin_lock(&fp->fi_lock); in init_lock_stateid()
6565 list_add(&stp->st_locks, &open_stp->st_locks); in init_lock_stateid()
6566 list_add(&stp->st_perstateowner, &lo->lo_owner.so_stateids); in init_lock_stateid()
6567 list_add(&stp->st_perfile, &fp->fi_stateids); in init_lock_stateid()
6568 spin_unlock(&fp->fi_lock); in init_lock_stateid()
6569 spin_unlock(&clp->cl_lock); in init_lock_stateid()
6572 spin_unlock(&clp->cl_lock); in init_lock_stateid()
6574 nfs4_put_stid(&retstp->st_stid); in init_lock_stateid()
6578 mutex_unlock(&stp->st_mutex); in init_lock_stateid()
6581 spin_unlock(&clp->cl_lock); in init_lock_stateid()
6582 mutex_unlock(&stp->st_mutex); in init_lock_stateid()
6593 struct nfs4_openowner *oo = openowner(ost->st_stateowner); in find_or_create_lock_stateid()
6594 struct nfs4_client *clp = oo->oo_owner.so_client; in find_or_create_lock_stateid()
6597 spin_lock(&clp->cl_lock); in find_or_create_lock_stateid()
6599 spin_unlock(&clp->cl_lock); in find_or_create_lock_stateid()
6603 nfs4_put_stid(&lst->st_stid); in find_or_create_lock_stateid()
6627 struct nfs4_file *fp = lock_stp->st_stid.sc_file; in get_lock_access()
6629 lockdep_assert_held(&fp->fi_lock); in get_lock_access()
6644 struct nfs4_file *fi = ost->st_stid.sc_file; in lookup_or_create_lock_state()
6645 struct nfs4_openowner *oo = openowner(ost->st_stateowner); in lookup_or_create_lock_state()
6646 struct nfs4_client *cl = oo->oo_owner.so_client; in lookup_or_create_lock_state()
6647 struct inode *inode = d_inode(cstate->current_fh.fh_dentry); in lookup_or_create_lock_state()
6652 lo = find_lockowner_str(cl, &lock->lk_new_owner); in lookup_or_create_lock_state()
6654 strhashval = ownerstr_hashval(&lock->lk_new_owner); in lookup_or_create_lock_state()
6661 if (!cstate->minorversion && in lookup_or_create_lock_state()
6662 lock->lk_new_lock_seqid != lo->lo_owner.so_seqid) in lookup_or_create_lock_state()
6675 nfs4_put_stateowner(&lo->lo_owner); in lookup_or_create_lock_state()
6686 struct nfsd4_lock *lock = &u->lock; in nfsd4_lock()
6706 (long long) lock->lk_offset, in nfsd4_lock()
6707 (long long) lock->lk_length); in nfsd4_lock()
6709 if (check_lock_length(lock->lk_offset, lock->lk_length)) in nfsd4_lock()
6712 if ((status = fh_verify(rqstp, &cstate->current_fh, in nfsd4_lock()
6718 if (lock->lk_is_new) { in nfsd4_lock()
6721 memcpy(&lock->lk_new_clientid, in nfsd4_lock()
6722 &cstate->session->se_client->cl_clientid, in nfsd4_lock()
6726 if (STALE_CLIENTID(&lock->lk_new_clientid, nn)) in nfsd4_lock()
6731 lock->lk_new_open_seqid, in nfsd4_lock()
6732 &lock->lk_new_open_stateid, in nfsd4_lock()
6736 mutex_unlock(&open_stp->st_mutex); in nfsd4_lock()
6737 open_sop = openowner(open_stp->st_stateowner); in nfsd4_lock()
6739 if (!same_clid(&open_sop->oo_owner.so_client->cl_clientid, in nfsd4_lock()
6740 &lock->lk_new_clientid)) in nfsd4_lock()
6746 lock->lk_old_lock_seqid, in nfsd4_lock()
6747 &lock->lk_old_lock_stateid, in nfsd4_lock()
6752 lock_sop = lockowner(lock_stp->st_stateowner); in nfsd4_lock()
6754 lkflg = setlkflg(lock->lk_type); in nfsd4_lock()
6760 if (locks_in_grace(net) && !lock->lk_reclaim) in nfsd4_lock()
6763 if (!locks_in_grace(net) && lock->lk_reclaim) in nfsd4_lock()
6766 fp = lock_stp->st_stid.sc_file; in nfsd4_lock()
6767 switch (lock->lk_type) { in nfsd4_lock()
6773 spin_lock(&fp->fi_lock); in nfsd4_lock()
6777 spin_unlock(&fp->fi_lock); in nfsd4_lock()
6785 spin_lock(&fp->fi_lock); in nfsd4_lock()
6789 spin_unlock(&fp->fi_lock); in nfsd4_lock()
6802 nbl = find_or_allocate_block(lock_sop, &fp->fi_fhandle, nn); in nfsd4_lock()
6809 file_lock = &nbl->nbl_lock; in nfsd4_lock()
6810 file_lock->fl_type = fl_type; in nfsd4_lock()
6811 file_lock->fl_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(&lock_sop->lo_owner)); in nfsd4_lock()
6812 file_lock->fl_pid = current->tgid; in nfsd4_lock()
6813 file_lock->fl_file = nf->nf_file; in nfsd4_lock()
6814 file_lock->fl_flags = fl_flags; in nfsd4_lock()
6815 file_lock->fl_lmops = &nfsd_posix_mng_ops; in nfsd4_lock()
6816 file_lock->fl_start = lock->lk_offset; in nfsd4_lock()
6817 file_lock->fl_end = last_byte_offset(lock->lk_offset, lock->lk_length); in nfsd4_lock()
6828 nbl->nbl_time = ktime_get_boottime_seconds(); in nfsd4_lock()
6829 spin_lock(&nn->blocked_locks_lock); in nfsd4_lock()
6830 list_add_tail(&nbl->nbl_list, &lock_sop->lo_blocked); in nfsd4_lock()
6831 list_add_tail(&nbl->nbl_lru, &nn->blocked_locks_lru); in nfsd4_lock()
6832 spin_unlock(&nn->blocked_locks_lock); in nfsd4_lock()
6835 err = vfs_lock_file(nf->nf_file, F_SETLK, file_lock, conflock); in nfsd4_lock()
6838 nfs4_inc_and_copy_stateid(&lock->lk_resp_stateid, &lock_stp->st_stid); in nfsd4_lock()
6840 if (lock->lk_reclaim) in nfsd4_lock()
6841 nn->somebody_reclaimed = true; in nfsd4_lock()
6846 case -EAGAIN: /* conflock holds conflicting lock */ in nfsd4_lock()
6849 nfs4_set_lock_denied(conflock, &lock->lk_denied); in nfsd4_lock()
6851 case -EDEADLK: in nfsd4_lock()
6863 spin_lock(&nn->blocked_locks_lock); in nfsd4_lock()
6864 list_del_init(&nbl->nbl_list); in nfsd4_lock()
6865 list_del_init(&nbl->nbl_lru); in nfsd4_lock()
6866 spin_unlock(&nn->blocked_locks_lock); in nfsd4_lock()
6874 if (cstate->replay_owner && in nfsd4_lock()
6875 cstate->replay_owner != &lock_sop->lo_owner && in nfsd4_lock()
6877 lock_sop->lo_owner.so_seqid++; in nfsd4_lock()
6880 * If this is a new, never-before-used stateid, and we are in nfsd4_lock()
6886 mutex_unlock(&lock_stp->st_mutex); in nfsd4_lock()
6888 nfs4_put_stid(&lock_stp->st_stid); in nfsd4_lock()
6891 nfs4_put_stid(&open_stp->st_stid); in nfsd4_lock()
6912 err = nfserrno(nfsd_open_break_lease(fhp->fh_dentry->d_inode, in nfsd_test_lock()
6916 lock->fl_file = nf->nf_file; in nfsd_test_lock()
6917 err = nfserrno(vfs_test_lock(nf->nf_file, lock)); in nfsd_test_lock()
6918 lock->fl_file = NULL; in nfsd_test_lock()
6932 struct nfsd4_lockt *lockt = &u->lockt; in nfsd4_lockt()
6941 if (check_lock_length(lockt->lt_offset, lockt->lt_length)) in nfsd4_lockt()
6945 status = lookup_clientid(&lockt->lt_clientid, cstate, nn, in nfsd4_lockt()
6951 if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0))) in nfsd4_lockt()
6961 switch (lockt->lt_type) { in nfsd4_lockt()
6964 file_lock->fl_type = F_RDLCK; in nfsd4_lockt()
6968 file_lock->fl_type = F_WRLCK; in nfsd4_lockt()
6976 lo = find_lockowner_str(cstate->clp, &lockt->lt_owner); in nfsd4_lockt()
6978 file_lock->fl_owner = (fl_owner_t)lo; in nfsd4_lockt()
6979 file_lock->fl_pid = current->tgid; in nfsd4_lockt()
6980 file_lock->fl_flags = FL_POSIX; in nfsd4_lockt()
6982 file_lock->fl_start = lockt->lt_offset; in nfsd4_lockt()
6983 file_lock->fl_end = last_byte_offset(lockt->lt_offset, lockt->lt_length); in nfsd4_lockt()
6987 status = nfsd_test_lock(rqstp, &cstate->current_fh, file_lock); in nfsd4_lockt()
6991 if (file_lock->fl_type != F_UNLCK) { in nfsd4_lockt()
6993 nfs4_set_lock_denied(file_lock, &lockt->lt_denied); in nfsd4_lockt()
6997 nfs4_put_stateowner(&lo->lo_owner); in nfsd4_lockt()
7007 struct nfsd4_locku *locku = &u->locku; in nfsd4_locku()
7016 (long long) locku->lu_offset, in nfsd4_locku()
7017 (long long) locku->lu_length); in nfsd4_locku()
7019 if (check_lock_length(locku->lu_offset, locku->lu_length)) in nfsd4_locku()
7022 status = nfs4_preprocess_seqid_op(cstate, locku->lu_seqid, in nfsd4_locku()
7023 &locku->lu_stateid, NFS4_LOCK_STID, in nfsd4_locku()
7027 nf = find_any_file(stp->st_stid.sc_file); in nfsd4_locku()
7039 file_lock->fl_type = F_UNLCK; in nfsd4_locku()
7040 file_lock->fl_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(stp->st_stateowner)); in nfsd4_locku()
7041 file_lock->fl_pid = current->tgid; in nfsd4_locku()
7042 file_lock->fl_file = nf->nf_file; in nfsd4_locku()
7043 file_lock->fl_flags = FL_POSIX; in nfsd4_locku()
7044 file_lock->fl_lmops = &nfsd_posix_mng_ops; in nfsd4_locku()
7045 file_lock->fl_start = locku->lu_offset; in nfsd4_locku()
7047 file_lock->fl_end = last_byte_offset(locku->lu_offset, in nfsd4_locku()
7048 locku->lu_length); in nfsd4_locku()
7051 err = vfs_lock_file(nf->nf_file, F_SETLK, file_lock, NULL); in nfsd4_locku()
7056 nfs4_inc_and_copy_stateid(&locku->lu_stateid, &stp->st_stid); in nfsd4_locku()
7060 mutex_unlock(&stp->st_mutex); in nfsd4_locku()
7061 nfs4_put_stid(&stp->st_stid); in nfsd4_locku()
7093 inode = locks_inode(nf->nf_file); in check_for_locks()
7094 flctx = inode->i_flctx; in check_for_locks()
7096 if (flctx && !list_empty_careful(&flctx->flc_posix)) { in check_for_locks()
7097 spin_lock(&flctx->flc_lock); in check_for_locks()
7098 list_for_each_entry(fl, &flctx->flc_posix, fl_list) { in check_for_locks()
7099 if (fl->fl_owner == (fl_owner_t)lowner) { in check_for_locks()
7104 spin_unlock(&flctx->flc_lock); in check_for_locks()
7115 struct nfsd4_release_lockowner *rlockowner = &u->release_lockowner; in nfsd4_release_lockowner()
7116 clientid_t *clid = &rlockowner->rl_clientid; in nfsd4_release_lockowner()
7120 struct xdr_netobj *owner = &rlockowner->rl_owner; in nfsd4_release_lockowner()
7128 clid->cl_boot, clid->cl_id); in nfsd4_release_lockowner()
7134 clp = cstate->clp; in nfsd4_release_lockowner()
7136 spin_lock(&clp->cl_lock); in nfsd4_release_lockowner()
7137 list_for_each_entry(sop, &clp->cl_ownerstr_hashtbl[hashval], in nfsd4_release_lockowner()
7140 if (sop->so_is_open_owner || !same_owner_str(sop, owner)) in nfsd4_release_lockowner()
7143 if (atomic_read(&sop->so_count) != 1) { in nfsd4_release_lockowner()
7144 spin_unlock(&clp->cl_lock); in nfsd4_release_lockowner()
7153 spin_unlock(&clp->cl_lock); in nfsd4_release_lockowner()
7158 while (!list_empty(&lo->lo_owner.so_stateids)) { in nfsd4_release_lockowner()
7159 stp = list_first_entry(&lo->lo_owner.so_stateids, in nfsd4_release_lockowner()
7165 spin_unlock(&clp->cl_lock); in nfsd4_release_lockowner()
7168 nfs4_put_stateowner(&lo->lo_owner); in nfsd4_release_lockowner()
7185 return (crp && crp->cr_clp); in nfs4_has_reclaimed_state()
7204 INIT_LIST_HEAD(&crp->cr_strhash); in nfs4_client_to_reclaim()
7205 list_add(&crp->cr_strhash, &nn->reclaim_str_hashtbl[strhashval]); in nfs4_client_to_reclaim()
7206 crp->cr_name.data = name.data; in nfs4_client_to_reclaim()
7207 crp->cr_name.len = name.len; in nfs4_client_to_reclaim()
7208 crp->cr_princhash.data = princhash.data; in nfs4_client_to_reclaim()
7209 crp->cr_princhash.len = princhash.len; in nfs4_client_to_reclaim()
7210 crp->cr_clp = NULL; in nfs4_client_to_reclaim()
7211 nn->reclaim_str_hashtbl_size++; in nfs4_client_to_reclaim()
7219 list_del(&crp->cr_strhash); in nfs4_remove_reclaim_record()
7220 kfree(crp->cr_name.data); in nfs4_remove_reclaim_record()
7221 kfree(crp->cr_princhash.data); in nfs4_remove_reclaim_record()
7223 nn->reclaim_str_hashtbl_size--; in nfs4_remove_reclaim_record()
7233 while (!list_empty(&nn->reclaim_str_hashtbl[i])) { in nfs4_release_reclaim()
7234 crp = list_entry(nn->reclaim_str_hashtbl[i].next, in nfs4_release_reclaim()
7239 WARN_ON_ONCE(nn->reclaim_str_hashtbl_size); in nfs4_release_reclaim()
7251 list_for_each_entry(crp, &nn->reclaim_str_hashtbl[strhashval], cr_strhash) { in nfsd4_find_reclaim_client()
7252 if (compare_blob(&crp->cr_name, &name) == 0) { in nfsd4_find_reclaim_client()
7274 if (test_bit(NFSD4_CLIENT_RECLAIM_COMPLETE, &cstate->clp->cl_flags)) in nfs4_check_open_reclaim()
7277 if (nfsd4_client_record_check(cstate->clp)) in nfs4_check_open_reclaim()
7301 max_delegations = nr_free_buffer_pages() >> (20 - 2 - PAGE_SHIFT); in set_max_delegations()
7309 nn->conf_id_hashtbl = kmalloc_array(CLIENT_HASH_SIZE, in nfs4_state_create_net()
7312 if (!nn->conf_id_hashtbl) in nfs4_state_create_net()
7314 nn->unconf_id_hashtbl = kmalloc_array(CLIENT_HASH_SIZE, in nfs4_state_create_net()
7317 if (!nn->unconf_id_hashtbl) in nfs4_state_create_net()
7319 nn->sessionid_hashtbl = kmalloc_array(SESSION_HASH_SIZE, in nfs4_state_create_net()
7322 if (!nn->sessionid_hashtbl) in nfs4_state_create_net()
7326 INIT_LIST_HEAD(&nn->conf_id_hashtbl[i]); in nfs4_state_create_net()
7327 INIT_LIST_HEAD(&nn->unconf_id_hashtbl[i]); in nfs4_state_create_net()
7330 INIT_LIST_HEAD(&nn->sessionid_hashtbl[i]); in nfs4_state_create_net()
7331 nn->conf_name_tree = RB_ROOT; in nfs4_state_create_net()
7332 nn->unconf_name_tree = RB_ROOT; in nfs4_state_create_net()
7333 nn->boot_time = ktime_get_real_seconds(); in nfs4_state_create_net()
7334 nn->grace_ended = false; in nfs4_state_create_net()
7335 nn->nfsd4_manager.block_opens = true; in nfs4_state_create_net()
7336 INIT_LIST_HEAD(&nn->nfsd4_manager.list); in nfs4_state_create_net()
7337 INIT_LIST_HEAD(&nn->client_lru); in nfs4_state_create_net()
7338 INIT_LIST_HEAD(&nn->close_lru); in nfs4_state_create_net()
7339 INIT_LIST_HEAD(&nn->del_recall_lru); in nfs4_state_create_net()
7340 spin_lock_init(&nn->client_lock); in nfs4_state_create_net()
7341 spin_lock_init(&nn->s2s_cp_lock); in nfs4_state_create_net()
7342 idr_init(&nn->s2s_cp_stateids); in nfs4_state_create_net()
7344 spin_lock_init(&nn->blocked_locks_lock); in nfs4_state_create_net()
7345 INIT_LIST_HEAD(&nn->blocked_locks_lru); in nfs4_state_create_net()
7347 INIT_DELAYED_WORK(&nn->laundromat_work, laundromat_main); in nfs4_state_create_net()
7353 kfree(nn->unconf_id_hashtbl); in nfs4_state_create_net()
7355 kfree(nn->conf_id_hashtbl); in nfs4_state_create_net()
7357 return -ENOMEM; in nfs4_state_create_net()
7368 while (!list_empty(&nn->conf_id_hashtbl[i])) { in nfs4_state_destroy_net()
7369 clp = list_entry(nn->conf_id_hashtbl[i].next, struct nfs4_client, cl_idhash); in nfs4_state_destroy_net()
7374 WARN_ON(!list_empty(&nn->blocked_locks_lru)); in nfs4_state_destroy_net()
7377 while (!list_empty(&nn->unconf_id_hashtbl[i])) { in nfs4_state_destroy_net()
7378 clp = list_entry(nn->unconf_id_hashtbl[i].next, struct nfs4_client, cl_idhash); in nfs4_state_destroy_net()
7383 kfree(nn->sessionid_hashtbl); in nfs4_state_destroy_net()
7384 kfree(nn->unconf_id_hashtbl); in nfs4_state_destroy_net()
7385 kfree(nn->conf_id_hashtbl); in nfs4_state_destroy_net()
7398 locks_start_grace(net, &nn->nfsd4_manager); in nfs4_state_start_net()
7400 if (nn->track_reclaim_completes && nn->reclaim_str_hashtbl_size == 0) in nfs4_state_start_net()
7402 printk(KERN_INFO "NFSD: starting %lld-second grace period (net %x)\n", in nfs4_state_start_net()
7403 nn->nfsd4_grace, net->ns.inum); in nfs4_state_start_net()
7405 queue_delayed_work(laundry_wq, &nn->laundromat_work, nn->nfsd4_grace * HZ); in nfs4_state_start_net()
7410 net->ns.inum); in nfs4_state_start_net()
7411 queue_delayed_work(laundry_wq, &nn->laundromat_work, nn->nfsd4_lease * HZ); in nfs4_state_start_net()
7425 ret = -ENOMEM; in nfs4_state_start()
7448 cancel_delayed_work_sync(&nn->laundromat_work); in nfs4_state_shutdown_net()
7449 locks_end_grace(&nn->nfsd4_manager); in nfs4_state_shutdown_net()
7453 list_for_each_safe(pos, next, &nn->del_recall_lru) { in nfs4_state_shutdown_net()
7456 list_add(&dp->dl_recall_lru, &reaplist); in nfs4_state_shutdown_net()
7461 list_del_init(&dp->dl_recall_lru); in nfs4_state_shutdown_net()
7481 memcpy(stateid, &cstate->current_stateid, sizeof(stateid_t)); in get_stateid()
7487 if (cstate->minorversion) { in put_stateid()
7488 memcpy(&cstate->current_stateid, stateid, sizeof(stateid_t)); in put_stateid()
7506 put_stateid(cstate, &u->open_downgrade.od_stateid); in nfsd4_set_opendowngradestateid()
7513 put_stateid(cstate, &u->open.op_stateid); in nfsd4_set_openstateid()
7520 put_stateid(cstate, &u->close.cl_stateid); in nfsd4_set_closestateid()
7527 put_stateid(cstate, &u->lock.lk_resp_stateid); in nfsd4_set_lockstateid()
7538 get_stateid(cstate, &u->open_downgrade.od_stateid); in nfsd4_get_opendowngradestateid()
7545 get_stateid(cstate, &u->delegreturn.dr_stateid); in nfsd4_get_delegreturnstateid()
7552 get_stateid(cstate, &u->free_stateid.fr_stateid); in nfsd4_get_freestateid()
7559 get_stateid(cstate, &u->setattr.sa_stateid); in nfsd4_get_setattrstateid()
7566 get_stateid(cstate, &u->close.cl_stateid); in nfsd4_get_closestateid()
7573 get_stateid(cstate, &u->locku.lu_stateid); in nfsd4_get_lockustateid()
7580 get_stateid(cstate, &u->read.rd_stateid); in nfsd4_get_readstateid()
7587 get_stateid(cstate, &u->write.wr_stateid); in nfsd4_get_writestateid()