Lines Matching +full:nc +full:- +full:si
107 * A waitqueue for all in-progress 4.0 CLOSE operations that are waiting for
141 rc = -ENOMEM; in nfsd4_create_laundry_wq()
152 return ses->se_dead; in is_session_dead()
157 if (atomic_read(&ses->se_ref) > ref_held_by_me) in mark_session_dead_locked()
159 ses->se_dead = true; in mark_session_dead_locked()
165 return clp->cl_time == 0; in is_client_expired()
171 if (clp->cl_state != NFSD4_ACTIVE) in nfsd4_dec_courtesy_client_count()
172 atomic_add_unless(&nn->nfsd_courtesy_clients, -1, 0); in nfsd4_dec_courtesy_client_count()
177 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in get_client_locked()
179 lockdep_assert_held(&nn->client_lock); in get_client_locked()
183 atomic_inc(&clp->cl_rpc_users); in get_client_locked()
185 clp->cl_state = NFSD4_ACTIVE; in get_client_locked()
193 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in renew_client_locked()
199 clp->cl_clientid.cl_boot, in renew_client_locked()
200 clp->cl_clientid.cl_id); in renew_client_locked()
204 list_move_tail(&clp->cl_lru, &nn->client_lru); in renew_client_locked()
205 clp->cl_time = ktime_get_boottime_seconds(); in renew_client_locked()
207 clp->cl_state = NFSD4_ACTIVE; in renew_client_locked()
212 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in put_client_renew_locked()
214 lockdep_assert_held(&nn->client_lock); in put_client_renew_locked()
216 if (!atomic_dec_and_test(&clp->cl_rpc_users)) in put_client_renew_locked()
226 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in put_client_renew()
228 if (!atomic_dec_and_lock(&clp->cl_rpc_users, &nn->client_lock)) in put_client_renew()
234 spin_unlock(&nn->client_lock); in put_client_renew()
243 status = get_client_locked(ses->se_client); in nfsd4_get_session_locked()
246 atomic_inc(&ses->se_ref); in nfsd4_get_session_locked()
252 struct nfs4_client *clp = ses->se_client; in nfsd4_put_session_locked()
253 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in nfsd4_put_session_locked()
255 lockdep_assert_held(&nn->client_lock); in nfsd4_put_session_locked()
257 if (atomic_dec_and_test(&ses->se_ref) && is_session_dead(ses)) in nfsd4_put_session_locked()
264 struct nfs4_client *clp = ses->se_client; in nfsd4_put_session()
265 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in nfsd4_put_session()
267 spin_lock(&nn->client_lock); in nfsd4_put_session()
269 spin_unlock(&nn->client_lock); in nfsd4_put_session()
278 spin_lock(&nn->blocked_locks_lock); in find_blocked_lock()
279 list_for_each_entry(cur, &lo->lo_blocked, nbl_list) { in find_blocked_lock()
280 if (fh_match(fh, &cur->nbl_fh)) { in find_blocked_lock()
281 list_del_init(&cur->nbl_list); in find_blocked_lock()
282 WARN_ON(list_empty(&cur->nbl_lru)); in find_blocked_lock()
283 list_del_init(&cur->nbl_lru); in find_blocked_lock()
288 spin_unlock(&nn->blocked_locks_lock); in find_blocked_lock()
290 locks_delete_block(&found->nbl_lock); in find_blocked_lock()
304 INIT_LIST_HEAD(&nbl->nbl_list); in find_or_allocate_block()
305 INIT_LIST_HEAD(&nbl->nbl_lru); in find_or_allocate_block()
306 fh_copy_shallow(&nbl->nbl_fh, fh); in find_or_allocate_block()
307 locks_init_lock(&nbl->nbl_lock); in find_or_allocate_block()
308 kref_init(&nbl->nbl_kref); in find_or_allocate_block()
309 nfsd4_init_cb(&nbl->nbl_cb, lo->lo_owner.so_client, in find_or_allocate_block()
323 locks_release_private(&nbl->nbl_lock); in free_nbl()
330 locks_delete_block(&nbl->nbl_lock); in free_blocked_lock()
331 kref_put(&nbl->nbl_kref, free_nbl); in free_blocked_lock()
337 struct nfs4_client *clp = lo->lo_owner.so_client; in remove_blocked_locks()
338 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in remove_blocked_locks()
343 spin_lock(&nn->blocked_locks_lock); in remove_blocked_locks()
344 while (!list_empty(&lo->lo_blocked)) { in remove_blocked_locks()
345 nbl = list_first_entry(&lo->lo_blocked, in remove_blocked_locks()
348 list_del_init(&nbl->nbl_list); in remove_blocked_locks()
349 WARN_ON(list_empty(&nbl->nbl_lru)); in remove_blocked_locks()
350 list_move(&nbl->nbl_lru, &reaplist); in remove_blocked_locks()
352 spin_unlock(&nn->blocked_locks_lock); in remove_blocked_locks()
358 list_del_init(&nbl->nbl_lru); in remove_blocked_locks()
368 locks_delete_block(&nbl->nbl_lock); in nfsd4_cb_notify_lock_prepare()
381 switch (task->tk_status) { in nfsd4_cb_notify_lock_done()
382 case -NFS4ERR_DELAY: in nfsd4_cb_notify_lock_done()
412 * https://datatracker.ietf.org/doc/html/rfc7530#section-16.19.4 that
450 stp->st_access_bmap |= mask; in set_access()
460 stp->st_access_bmap &= ~mask; in clear_access()
469 return (bool)(stp->st_access_bmap & mask); in test_access()
479 stp->st_deny_bmap |= mask; in set_deny()
489 stp->st_deny_bmap &= ~mask; in clear_deny()
498 return (bool)(stp->st_deny_bmap & mask); in test_deny()
533 atomic_inc(&sop->so_count); in nfs4_get_stateowner()
540 return (sop->so_owner.len == owner->len) && in same_owner_str()
541 0 == memcmp(sop->so_owner.data, owner->data, owner->len); in same_owner_str()
550 lockdep_assert_held(&clp->cl_lock); in find_openstateowner_str()
552 list_for_each_entry(so, &clp->cl_ownerstr_hashtbl[hashval], in find_openstateowner_str()
554 if (!so->so_is_open_owner) in find_openstateowner_str()
556 if (same_owner_str(so, &open->op_owner)) in find_openstateowner_str()
568 while (nbytes--) { in opaque_hashval()
578 if (refcount_dec_and_test(&fi->fi_ref)) { in put_nfs4_file()
580 WARN_ON_ONCE(!list_empty(&fi->fi_clnt_odstate)); in put_nfs4_file()
581 WARN_ON_ONCE(!list_empty(&fi->fi_delegations)); in put_nfs4_file()
591 lockdep_assert_held(&f->fi_lock); in find_writeable_file_locked()
593 ret = nfsd_file_get(f->fi_fds[O_WRONLY]); in find_writeable_file_locked()
595 ret = nfsd_file_get(f->fi_fds[O_RDWR]); in find_writeable_file_locked()
604 spin_lock(&f->fi_lock); in find_writeable_file()
606 spin_unlock(&f->fi_lock); in find_writeable_file()
616 lockdep_assert_held(&f->fi_lock); in find_readable_file_locked()
618 ret = nfsd_file_get(f->fi_fds[O_RDONLY]); in find_readable_file_locked()
620 ret = nfsd_file_get(f->fi_fds[O_RDWR]); in find_readable_file_locked()
629 spin_lock(&f->fi_lock); in find_readable_file()
631 spin_unlock(&f->fi_lock); in find_readable_file()
641 spin_lock(&f->fi_lock); in find_rw_file()
642 ret = nfsd_file_get(f->fi_fds[O_RDWR]); in find_rw_file()
643 spin_unlock(&f->fi_lock); in find_rw_file()
655 spin_lock(&f->fi_lock); in find_any_file()
656 ret = nfsd_file_get(f->fi_fds[O_RDWR]); in find_any_file()
658 ret = nfsd_file_get(f->fi_fds[O_WRONLY]); in find_any_file()
660 ret = nfsd_file_get(f->fi_fds[O_RDONLY]); in find_any_file()
662 spin_unlock(&f->fi_lock); in find_any_file()
668 lockdep_assert_held(&f->fi_lock); in find_any_file_locked()
670 if (f->fi_fds[O_RDWR]) in find_any_file_locked()
671 return f->fi_fds[O_RDWR]; in find_any_file_locked()
672 if (f->fi_fds[O_WRONLY]) in find_any_file_locked()
673 return f->fi_fds[O_WRONLY]; in find_any_file_locked()
674 if (f->fi_fds[O_RDONLY]) in find_any_file_locked()
675 return f->fi_fds[O_RDONLY]; in find_any_file_locked()
689 #define OWNER_HASH_MASK (OWNER_HASH_SIZE - 1)
695 ret = opaque_hashval(ownername->data, ownername->len); in ownerstr_hashval()
727 * false - access/deny mode conflict with normal client.
728 * true - no conflict or conflict with courtesy client(s) is resolved.
740 lockdep_assert_held(&fp->fi_lock); in nfs4_resolve_deny_conflicts_locked()
741 list_for_each_entry(st, &fp->fi_stateids, st_perfile) { in nfs4_resolve_deny_conflicts_locked()
743 if (st->st_openstp) in nfs4_resolve_deny_conflicts_locked()
748 bmap = share_access ? st->st_deny_bmap : st->st_access_bmap; in nfs4_resolve_deny_conflicts_locked()
751 clp = st->st_stid.sc_client; in nfs4_resolve_deny_conflicts_locked()
758 clp = stp->st_stid.sc_client; in nfs4_resolve_deny_conflicts_locked()
759 nn = net_generic(clp->net, nfsd_net_id); in nfs4_resolve_deny_conflicts_locked()
760 mod_delayed_work(laundry_wq, &nn->laundromat_work, 0); in nfs4_resolve_deny_conflicts_locked()
768 lockdep_assert_held(&fp->fi_lock); in __nfs4_file_get_access()
771 atomic_inc(&fp->fi_access[O_WRONLY]); in __nfs4_file_get_access()
773 atomic_inc(&fp->fi_access[O_RDONLY]); in __nfs4_file_get_access()
779 lockdep_assert_held(&fp->fi_lock); in nfs4_file_get_access()
786 if ((access & fp->fi_share_deny) != 0) in nfs4_file_get_access()
802 atomic_read(&fp->fi_access[O_RDONLY])) in nfs4_file_check_deny()
806 atomic_read(&fp->fi_access[O_WRONLY])) in nfs4_file_check_deny()
814 might_lock(&fp->fi_lock); in __nfs4_file_put_access()
816 if (atomic_dec_and_lock(&fp->fi_access[oflag], &fp->fi_lock)) { in __nfs4_file_put_access()
820 swap(f1, fp->fi_fds[oflag]); in __nfs4_file_put_access()
821 if (atomic_read(&fp->fi_access[1 - oflag]) == 0) in __nfs4_file_put_access()
822 swap(f2, fp->fi_fds[O_RDWR]); in __nfs4_file_put_access()
823 spin_unlock(&fp->fi_lock); in __nfs4_file_put_access()
845 * Note that we only allocate it for pNFS-enabled exports, otherwise
855 co->co_client = clp; in alloc_clnt_odstate()
856 refcount_set(&co->co_odcount, 1); in alloc_clnt_odstate()
864 struct nfs4_file *fp = co->co_file; in hash_clnt_odstate_locked()
866 lockdep_assert_held(&fp->fi_lock); in hash_clnt_odstate_locked()
867 list_add(&co->co_perfile, &fp->fi_clnt_odstate); in hash_clnt_odstate_locked()
874 refcount_inc(&co->co_odcount); in get_clnt_odstate()
885 fp = co->co_file; in put_clnt_odstate()
886 if (refcount_dec_and_lock(&co->co_odcount, &fp->fi_lock)) { in put_clnt_odstate()
887 list_del(&co->co_perfile); in put_clnt_odstate()
888 spin_unlock(&fp->fi_lock); in put_clnt_odstate()
890 nfsd4_return_all_file_layouts(co->co_client, fp); in put_clnt_odstate()
904 cl = new->co_client; in find_or_hash_clnt_odstate()
906 spin_lock(&fp->fi_lock); in find_or_hash_clnt_odstate()
907 list_for_each_entry(co, &fp->fi_clnt_odstate, co_perfile) { in find_or_hash_clnt_odstate()
908 if (co->co_client == cl) { in find_or_hash_clnt_odstate()
914 co->co_file = fp; in find_or_hash_clnt_odstate()
917 spin_unlock(&fp->fi_lock); in find_or_hash_clnt_odstate()
932 spin_lock(&cl->cl_lock); in nfs4_alloc_stid()
934 new_id = idr_alloc_cyclic(&cl->cl_stateids, stid, 1, 0, GFP_NOWAIT); in nfs4_alloc_stid()
935 spin_unlock(&cl->cl_lock); in nfs4_alloc_stid()
940 stid->sc_free = sc_free; in nfs4_alloc_stid()
941 stid->sc_client = cl; in nfs4_alloc_stid()
942 stid->sc_stateid.si_opaque.so_id = new_id; in nfs4_alloc_stid()
943 stid->sc_stateid.si_opaque.so_clid = cl->cl_clientid; in nfs4_alloc_stid()
945 refcount_set(&stid->sc_count, 1); in nfs4_alloc_stid()
946 spin_lock_init(&stid->sc_lock); in nfs4_alloc_stid()
947 INIT_LIST_HEAD(&stid->sc_cp_list); in nfs4_alloc_stid()
972 stid->cs_stid.si_opaque.so_clid.cl_boot = (u32)nn->boot_time; in nfs4_init_cp_state()
973 stid->cs_stid.si_opaque.so_clid.cl_id = nn->s2s_cp_cl_id; in nfs4_init_cp_state()
976 spin_lock(&nn->s2s_cp_lock); in nfs4_init_cp_state()
977 new_id = idr_alloc_cyclic(&nn->s2s_cp_stateids, stid, 0, 0, GFP_NOWAIT); in nfs4_init_cp_state()
978 stid->cs_stid.si_opaque.so_id = new_id; in nfs4_init_cp_state()
979 stid->cs_stid.si_generation = 1; in nfs4_init_cp_state()
980 spin_unlock(&nn->s2s_cp_lock); in nfs4_init_cp_state()
984 stid->cs_type = cs_type; in nfs4_init_cp_state()
990 return nfs4_init_cp_state(nn, ©->cp_stateid, NFS4_COPY_STID); in nfs4_init_copy_state()
1001 cps->cpntf_time = ktime_get_boottime_seconds(); in nfs4_alloc_init_cpntf_state()
1002 refcount_set(&cps->cp_stateid.cs_count, 1); in nfs4_alloc_init_cpntf_state()
1003 if (!nfs4_init_cp_state(nn, &cps->cp_stateid, NFS4_COPYNOTIFY_STID)) in nfs4_alloc_init_cpntf_state()
1005 spin_lock(&nn->s2s_cp_lock); in nfs4_alloc_init_cpntf_state()
1006 list_add(&cps->cp_list, &p_stid->sc_cp_list); in nfs4_alloc_init_cpntf_state()
1007 spin_unlock(&nn->s2s_cp_lock); in nfs4_alloc_init_cpntf_state()
1018 if (copy->cp_stateid.cs_type != NFS4_COPY_STID) in nfs4_free_copy_state()
1020 nn = net_generic(copy->cp_clp->net, nfsd_net_id); in nfs4_free_copy_state()
1021 spin_lock(&nn->s2s_cp_lock); in nfs4_free_copy_state()
1022 idr_remove(&nn->s2s_cp_stateids, in nfs4_free_copy_state()
1023 copy->cp_stateid.cs_stid.si_opaque.so_id); in nfs4_free_copy_state()
1024 spin_unlock(&nn->s2s_cp_lock); in nfs4_free_copy_state()
1033 spin_lock(&nn->s2s_cp_lock); in nfs4_free_cpntf_statelist()
1034 while (!list_empty(&stid->sc_cp_list)) { in nfs4_free_cpntf_statelist()
1035 cps = list_first_entry(&stid->sc_cp_list, in nfs4_free_cpntf_statelist()
1039 spin_unlock(&nn->s2s_cp_lock); in nfs4_free_cpntf_statelist()
1057 WARN_ON_ONCE(!list_empty(&stid->sc_cp_list)); in nfs4_free_deleg()
1058 WARN_ON_ONCE(!list_empty(&dp->dl_perfile)); in nfs4_free_deleg()
1059 WARN_ON_ONCE(!list_empty(&dp->dl_perclnt)); in nfs4_free_deleg()
1060 WARN_ON_ONCE(!list_empty(&dp->dl_recall_lru)); in nfs4_free_deleg()
1078 * low 3 bytes as hash-table indices.
1097 if (bd->entries == 0) in delegation_blocked()
1099 if (ktime_get_seconds() - bd->swap_time > 30) { in delegation_blocked()
1101 if (ktime_get_seconds() - bd->swap_time > 30) { in delegation_blocked()
1102 bd->entries -= bd->old_entries; in delegation_blocked()
1103 bd->old_entries = bd->entries; in delegation_blocked()
1104 bd->new = 1-bd->new; in delegation_blocked()
1105 memset(bd->set[bd->new], 0, in delegation_blocked()
1106 sizeof(bd->set[0])); in delegation_blocked()
1107 bd->swap_time = ktime_get_seconds(); in delegation_blocked()
1111 hash = jhash(&fh->fh_raw, fh->fh_size, 0); in delegation_blocked()
1112 if (test_bit(hash&255, bd->set[0]) && in delegation_blocked()
1113 test_bit((hash>>8)&255, bd->set[0]) && in delegation_blocked()
1114 test_bit((hash>>16)&255, bd->set[0])) in delegation_blocked()
1117 if (test_bit(hash&255, bd->set[1]) && in delegation_blocked()
1118 test_bit((hash>>8)&255, bd->set[1]) && in delegation_blocked()
1119 test_bit((hash>>16)&255, bd->set[1])) in delegation_blocked()
1130 hash = jhash(&fh->fh_raw, fh->fh_size, 0); in block_delegations()
1133 __set_bit(hash&255, bd->set[bd->new]); in block_delegations()
1134 __set_bit((hash>>8)&255, bd->set[bd->new]); in block_delegations()
1135 __set_bit((hash>>16)&255, bd->set[bd->new]); in block_delegations()
1136 if (bd->entries == 0) in block_delegations()
1137 bd->swap_time = ktime_get_seconds(); in block_delegations()
1138 bd->entries += 1; in block_delegations()
1154 if (delegation_blocked(&fp->fi_fhandle)) in alloc_init_deleg()
1166 dp->dl_stid.sc_stateid.si_generation = 1; in alloc_init_deleg()
1167 INIT_LIST_HEAD(&dp->dl_perfile); in alloc_init_deleg()
1168 INIT_LIST_HEAD(&dp->dl_perclnt); in alloc_init_deleg()
1169 INIT_LIST_HEAD(&dp->dl_recall_lru); in alloc_init_deleg()
1170 dp->dl_clnt_odstate = odstate; in alloc_init_deleg()
1172 dp->dl_type = dl_type; in alloc_init_deleg()
1173 dp->dl_retries = 1; in alloc_init_deleg()
1174 dp->dl_recalled = false; in alloc_init_deleg()
1175 nfsd4_init_cb(&dp->dl_recall, dp->dl_stid.sc_client, in alloc_init_deleg()
1177 nfsd4_init_cb(&dp->dl_cb_fattr.ncf_getattr, dp->dl_stid.sc_client, in alloc_init_deleg()
1179 dp->dl_cb_fattr.ncf_file_modified = false; in alloc_init_deleg()
1181 dp->dl_stid.sc_file = fp; in alloc_init_deleg()
1191 struct nfs4_file *fp = s->sc_file; in nfs4_put_stid()
1192 struct nfs4_client *clp = s->sc_client; in nfs4_put_stid()
1194 might_lock(&clp->cl_lock); in nfs4_put_stid()
1196 if (!refcount_dec_and_lock(&s->sc_count, &clp->cl_lock)) { in nfs4_put_stid()
1200 idr_remove(&clp->cl_stateids, s->sc_stateid.si_opaque.so_id); in nfs4_put_stid()
1201 if (s->sc_status & SC_STATUS_ADMIN_REVOKED) in nfs4_put_stid()
1202 atomic_dec(&s->sc_client->cl_admin_revoked); in nfs4_put_stid()
1203 nfs4_free_cpntf_statelist(clp->net, s); in nfs4_put_stid()
1204 spin_unlock(&clp->cl_lock); in nfs4_put_stid()
1205 s->sc_free(s); in nfs4_put_stid()
1213 stateid_t *src = &stid->sc_stateid; in nfs4_inc_and_copy_stateid()
1215 spin_lock(&stid->sc_lock); in nfs4_inc_and_copy_stateid()
1216 if (unlikely(++src->si_generation == 0)) in nfs4_inc_and_copy_stateid()
1217 src->si_generation = 1; in nfs4_inc_and_copy_stateid()
1219 spin_unlock(&stid->sc_lock); in nfs4_inc_and_copy_stateid()
1226 spin_lock(&fp->fi_lock); in put_deleg_file()
1227 if (--fp->fi_delegees == 0) in put_deleg_file()
1228 swap(nf, fp->fi_deleg_file); in put_deleg_file()
1229 spin_unlock(&fp->fi_lock); in put_deleg_file()
1237 struct nfs4_file *fp = dp->dl_stid.sc_file; in nfs4_unlock_deleg_lease()
1238 struct nfsd_file *nf = fp->fi_deleg_file; in nfs4_unlock_deleg_lease()
1240 WARN_ON_ONCE(!fp->fi_delegees); in nfs4_unlock_deleg_lease()
1242 kernel_setlease(nf->nf_file, F_UNLCK, NULL, (void **)&dp); in nfs4_unlock_deleg_lease()
1248 put_clnt_odstate(dp->dl_clnt_odstate); in destroy_unhashed_deleg()
1250 nfs4_put_stid(&dp->dl_stid); in destroy_unhashed_deleg()
1254 * nfs4_delegation_exists - Discover if this delegation already exists
1269 lockdep_assert_held(&fp->fi_lock); in nfs4_delegation_exists()
1271 list_for_each_entry(searchdp, &fp->fi_delegations, dl_perfile) { in nfs4_delegation_exists()
1272 searchclp = searchdp->dl_stid.sc_client; in nfs4_delegation_exists()
1281 * hash_delegation_locked - Add a delegation to the appropriate lists
1288 * On error: -EAGAIN if one was previously granted to this
1296 struct nfs4_client *clp = dp->dl_stid.sc_client; in hash_delegation_locked()
1299 lockdep_assert_held(&fp->fi_lock); in hash_delegation_locked()
1300 lockdep_assert_held(&clp->cl_lock); in hash_delegation_locked()
1303 return -EAGAIN; in hash_delegation_locked()
1304 refcount_inc(&dp->dl_stid.sc_count); in hash_delegation_locked()
1305 dp->dl_stid.sc_type = SC_TYPE_DELEG; in hash_delegation_locked()
1306 list_add(&dp->dl_perfile, &fp->fi_delegations); in hash_delegation_locked()
1307 list_add(&dp->dl_perclnt, &clp->cl_delegations); in hash_delegation_locked()
1313 return !(list_empty(&dp->dl_perfile)); in delegation_hashed()
1319 struct nfs4_file *fp = dp->dl_stid.sc_file; in unhash_delegation_locked()
1327 dp->dl_stid.sc_client->cl_minorversion == 0) in unhash_delegation_locked()
1329 dp->dl_stid.sc_status |= statusmask; in unhash_delegation_locked()
1331 atomic_inc(&dp->dl_stid.sc_client->cl_admin_revoked); in unhash_delegation_locked()
1334 ++dp->dl_time; in unhash_delegation_locked()
1335 spin_lock(&fp->fi_lock); in unhash_delegation_locked()
1336 list_del_init(&dp->dl_perclnt); in unhash_delegation_locked()
1337 list_del_init(&dp->dl_recall_lru); in unhash_delegation_locked()
1338 list_del_init(&dp->dl_perfile); in unhash_delegation_locked()
1339 spin_unlock(&fp->fi_lock); in unhash_delegation_locked()
1355 * revoke_delegation - perform nfs4 delegation structure cleanup
1374 * in the revocation process is protected by the clp->cl_lock.
1378 struct nfs4_client *clp = dp->dl_stid.sc_client; in revoke_delegation()
1380 WARN_ON(!list_empty(&dp->dl_recall_lru)); in revoke_delegation()
1381 WARN_ON_ONCE(!(dp->dl_stid.sc_status & in revoke_delegation()
1384 trace_nfsd_stid_revoke(&dp->dl_stid); in revoke_delegation()
1386 spin_lock(&clp->cl_lock); in revoke_delegation()
1387 if (dp->dl_stid.sc_status & SC_STATUS_FREED) { in revoke_delegation()
1388 list_del_init(&dp->dl_recall_lru); in revoke_delegation()
1391 list_add(&dp->dl_recall_lru, &clp->cl_revoked); in revoke_delegation()
1392 dp->dl_stid.sc_status |= SC_STATUS_FREEABLE; in revoke_delegation()
1394 spin_unlock(&clp->cl_lock); in revoke_delegation()
1422 spin_lock(&fp->fi_lock); in recalculate_deny_mode()
1423 old_deny = fp->fi_share_deny; in recalculate_deny_mode()
1424 fp->fi_share_deny = 0; in recalculate_deny_mode()
1425 list_for_each_entry(stp, &fp->fi_stateids, st_perfile) { in recalculate_deny_mode()
1426 fp->fi_share_deny |= bmap_to_share_mode(stp->st_deny_bmap); in recalculate_deny_mode()
1427 if (fp->fi_share_deny == old_deny) in recalculate_deny_mode()
1430 spin_unlock(&fp->fi_lock); in recalculate_deny_mode()
1446 /* Recalculate per-file deny mode if there was a change */ in reset_union_bmap_deny()
1448 recalculate_deny_mode(stp->st_stid.sc_file); in reset_union_bmap_deny()
1456 struct nfs4_file *fp = stp->st_stid.sc_file; in release_all_access()
1458 if (fp && stp->st_deny_bmap != 0) in release_all_access()
1463 nfs4_file_put_access(stp->st_stid.sc_file, i); in release_all_access()
1470 kfree(sop->so_owner.data); in nfs4_free_stateowner()
1471 sop->so_ops->so_free(sop); in nfs4_free_stateowner()
1476 struct nfs4_client *clp = sop->so_client; in nfs4_put_stateowner()
1478 might_lock(&clp->cl_lock); in nfs4_put_stateowner()
1480 if (!atomic_dec_and_lock(&sop->so_count, &clp->cl_lock)) in nfs4_put_stateowner()
1482 sop->so_ops->so_unhash(sop); in nfs4_put_stateowner()
1483 spin_unlock(&clp->cl_lock); in nfs4_put_stateowner()
1490 return list_empty(&stp->st_perfile); in nfs4_ol_stateid_unhashed()
1495 struct nfs4_file *fp = stp->st_stid.sc_file; in unhash_ol_stateid()
1497 lockdep_assert_held(&stp->st_stateowner->so_client->cl_lock); in unhash_ol_stateid()
1499 if (list_empty(&stp->st_perfile)) in unhash_ol_stateid()
1502 spin_lock(&fp->fi_lock); in unhash_ol_stateid()
1503 list_del_init(&stp->st_perfile); in unhash_ol_stateid()
1504 spin_unlock(&fp->fi_lock); in unhash_ol_stateid()
1505 list_del(&stp->st_perstateowner); in unhash_ol_stateid()
1513 put_clnt_odstate(stp->st_clnt_odstate); in nfs4_free_ol_stateid()
1515 if (stp->st_stateowner) in nfs4_free_ol_stateid()
1516 nfs4_put_stateowner(stp->st_stateowner); in nfs4_free_ol_stateid()
1517 WARN_ON(!list_empty(&stid->sc_cp_list)); in nfs4_free_ol_stateid()
1524 struct nfs4_lockowner *lo = lockowner(stp->st_stateowner); in nfs4_free_lock_stateid()
1527 nf = find_any_file(stp->st_stid.sc_file); in nfs4_free_lock_stateid()
1529 get_file(nf->nf_file); in nfs4_free_lock_stateid()
1530 filp_close(nf->nf_file, (fl_owner_t)lo); in nfs4_free_lock_stateid()
1544 struct nfs4_stid *s = &stp->st_stid; in put_ol_stateid_locked()
1545 struct nfs4_client *clp = s->sc_client; in put_ol_stateid_locked()
1547 lockdep_assert_held(&clp->cl_lock); in put_ol_stateid_locked()
1549 WARN_ON_ONCE(!list_empty(&stp->st_locks)); in put_ol_stateid_locked()
1551 if (!refcount_dec_and_test(&s->sc_count)) { in put_ol_stateid_locked()
1556 idr_remove(&clp->cl_stateids, s->sc_stateid.si_opaque.so_id); in put_ol_stateid_locked()
1557 if (s->sc_status & SC_STATUS_ADMIN_REVOKED) in put_ol_stateid_locked()
1558 atomic_dec(&s->sc_client->cl_admin_revoked); in put_ol_stateid_locked()
1559 list_add(&stp->st_locks, reaplist); in put_ol_stateid_locked()
1564 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock); in unhash_lock_stateid()
1568 list_del_init(&stp->st_locks); in unhash_lock_stateid()
1569 stp->st_stid.sc_status |= SC_STATUS_CLOSED; in unhash_lock_stateid()
1575 struct nfs4_client *clp = stp->st_stid.sc_client; in release_lock_stateid()
1578 spin_lock(&clp->cl_lock); in release_lock_stateid()
1580 spin_unlock(&clp->cl_lock); in release_lock_stateid()
1582 nfs4_put_stid(&stp->st_stid); in release_lock_stateid()
1587 struct nfs4_client *clp = lo->lo_owner.so_client; in unhash_lockowner_locked()
1589 lockdep_assert_held(&clp->cl_lock); in unhash_lockowner_locked()
1591 list_del_init(&lo->lo_owner.so_strhash); in unhash_lockowner_locked()
1609 list_del(&stp->st_locks); in free_ol_stateid_reaplist()
1610 fp = stp->st_stid.sc_file; in free_ol_stateid_reaplist()
1611 stp->st_stid.sc_free(&stp->st_stid); in free_ol_stateid_reaplist()
1622 lockdep_assert_held(&open_stp->st_stid.sc_client->cl_lock); in release_open_stateid_locks()
1624 while (!list_empty(&open_stp->st_locks)) { in release_open_stateid_locks()
1625 stp = list_entry(open_stp->st_locks.next, in release_open_stateid_locks()
1635 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock); in unhash_open_stateid()
1647 spin_lock(&stp->st_stid.sc_client->cl_lock); in release_open_stateid()
1648 stp->st_stid.sc_status |= SC_STATUS_CLOSED; in release_open_stateid()
1651 spin_unlock(&stp->st_stid.sc_client->cl_lock); in release_open_stateid()
1657 lockdep_assert_held(&oo->oo_owner.so_client->cl_lock); in nfs4_openowner_unhashed()
1659 return list_empty(&oo->oo_owner.so_strhash) && in nfs4_openowner_unhashed()
1660 list_empty(&oo->oo_perclient); in nfs4_openowner_unhashed()
1665 struct nfs4_client *clp = oo->oo_owner.so_client; in unhash_openowner_locked()
1667 lockdep_assert_held(&clp->cl_lock); in unhash_openowner_locked()
1669 list_del_init(&oo->oo_owner.so_strhash); in unhash_openowner_locked()
1670 list_del_init(&oo->oo_perclient); in unhash_openowner_locked()
1675 struct nfsd_net *nn = net_generic(oo->oo_owner.so_client->net, in release_last_closed_stateid()
1679 spin_lock(&nn->client_lock); in release_last_closed_stateid()
1680 s = oo->oo_last_closed_stid; in release_last_closed_stateid()
1682 list_del_init(&oo->oo_close_lru); in release_last_closed_stateid()
1683 oo->oo_last_closed_stid = NULL; in release_last_closed_stateid()
1685 spin_unlock(&nn->client_lock); in release_last_closed_stateid()
1687 nfs4_put_stid(&s->st_stid); in release_last_closed_stateid()
1693 struct nfs4_client *clp = oo->oo_owner.so_client; in release_openowner()
1696 spin_lock(&clp->cl_lock); in release_openowner()
1698 while (!list_empty(&oo->oo_owner.so_stateids)) { in release_openowner()
1699 stp = list_first_entry(&oo->oo_owner.so_stateids, in release_openowner()
1704 spin_unlock(&clp->cl_lock); in release_openowner()
1707 nfs4_put_stateowner(&oo->oo_owner); in release_openowner()
1717 spin_lock(&clp->cl_lock); in find_one_sb_stid()
1718 idr_for_each_entry_ul(&clp->cl_stateids, stid, tmp, id) in find_one_sb_stid()
1719 if ((stid->sc_type & sc_types) && in find_one_sb_stid()
1720 stid->sc_status == 0 && in find_one_sb_stid()
1721 stid->sc_file->fi_inode->i_sb == sb) { in find_one_sb_stid()
1722 refcount_inc(&stid->sc_count); in find_one_sb_stid()
1725 spin_unlock(&clp->cl_lock); in find_one_sb_stid()
1730 * nfsd4_revoke_states - revoke all nfsv4 states associated with given filesystem
1741 * states have been "admin-revoked".
1751 spin_lock(&nn->client_lock); in nfsd4_revoke_states()
1753 struct list_head *head = &nn->conf_id_hashtbl[idhashval]; in nfsd4_revoke_states()
1764 spin_unlock(&nn->client_lock); in nfsd4_revoke_states()
1765 switch (stid->sc_type) { in nfsd4_revoke_states()
1768 mutex_lock_nested(&stp->st_mutex, in nfsd4_revoke_states()
1771 spin_lock(&clp->cl_lock); in nfsd4_revoke_states()
1772 if (stid->sc_status == 0) { in nfsd4_revoke_states()
1773 stid->sc_status |= in nfsd4_revoke_states()
1775 atomic_inc(&clp->cl_admin_revoked); in nfsd4_revoke_states()
1776 spin_unlock(&clp->cl_lock); in nfsd4_revoke_states()
1779 spin_unlock(&clp->cl_lock); in nfsd4_revoke_states()
1780 mutex_unlock(&stp->st_mutex); in nfsd4_revoke_states()
1784 mutex_lock_nested(&stp->st_mutex, in nfsd4_revoke_states()
1786 spin_lock(&clp->cl_lock); in nfsd4_revoke_states()
1787 if (stid->sc_status == 0) { in nfsd4_revoke_states()
1789 lockowner(stp->st_stateowner); in nfsd4_revoke_states()
1792 stid->sc_status |= in nfsd4_revoke_states()
1794 atomic_inc(&clp->cl_admin_revoked); in nfsd4_revoke_states()
1795 spin_unlock(&clp->cl_lock); in nfsd4_revoke_states()
1796 nf = find_any_file(stp->st_stid.sc_file); in nfsd4_revoke_states()
1798 get_file(nf->nf_file); in nfsd4_revoke_states()
1799 filp_close(nf->nf_file, in nfsd4_revoke_states()
1805 spin_unlock(&clp->cl_lock); in nfsd4_revoke_states()
1806 mutex_unlock(&stp->st_mutex); in nfsd4_revoke_states()
1809 refcount_inc(&stid->sc_count); in nfsd4_revoke_states()
1825 spin_lock(&nn->client_lock); in nfsd4_revoke_states()
1826 if (clp->cl_minorversion == 0) in nfsd4_revoke_states()
1832 nn->nfs40_last_revoke = in nfsd4_revoke_states()
1838 spin_unlock(&nn->client_lock); in nfsd4_revoke_states()
1846 return sid->sequence % SESSION_HASH_SIZE; in hash_sessionid()
1853 u32 *ptr = (u32 *)(&sessionid->data[0]); in dump_sessionid()
1864 * Bump the seqid on cstate->replay_owner, and clear replay_owner if it
1869 struct nfs4_stateowner *so = cstate->replay_owner; in nfsd4_bump_seqid()
1880 if (so->so_is_open_owner) in nfsd4_bump_seqid()
1882 so->so_seqid++; in nfsd4_bump_seqid()
1889 struct nfs4_client *clp = ses->se_client; in gen_sessionid()
1892 sid = (struct nfsd4_sessionid *)ses->se_sessionid.data; in gen_sessionid()
1893 sid->clientid = clp->cl_clientid; in gen_sessionid()
1894 sid->sequence = current_sessionid++; in gen_sessionid()
1895 sid->reserved = 0; in gen_sessionid()
1901 * the end of the initial SEQUENCE operation--the rest we regenerate
1907 * verifier), 12 for the compound header (with zero-length tag), and 44
1917 for (i = 0; i < ses->se_fchannel.maxreqs; i++) { in free_session_slots()
1918 free_svc_cred(&ses->se_slots[i]->sl_cred); in free_session_slots()
1919 kfree(ses->se_slots[i]); in free_session_slots()
1931 if (ca->maxresp_cached < NFSD_MIN_HDR_SEQ_SZ) in slot_bytes()
1934 size = ca->maxresp_cached - NFSD_MIN_HDR_SEQ_SZ; in slot_bytes()
1940 * re-negotiate active sessions and reduce their slot usage to make
1946 u32 num = ca->maxreqs; in nfsd4_get_drc_mem()
1952 total_avail = nfsd_drc_max_mem - nfsd_drc_mem_used; in nfsd4_get_drc_mem()
1968 * over-allocation--it is better than failure. in nfsd4_get_drc_mem()
1970 scale_factor = max_t(unsigned int, 8, nn->nfsd_serv->sv_nrthreads); in nfsd4_get_drc_mem()
1987 nfsd_drc_mem_used -= slotsize * ca->maxreqs; in nfsd4_put_drc_mem()
1994 int numslots = fattrs->maxreqs; in alloc_session()
2007 new->se_slots[i] = kzalloc(slotsize, GFP_KERNEL); in alloc_session()
2008 if (!new->se_slots[i]) in alloc_session()
2012 memcpy(&new->se_fchannel, fattrs, sizeof(struct nfsd4_channel_attrs)); in alloc_session()
2013 new->se_cb_slot_avail = ~0U; in alloc_session()
2014 new->se_cb_highest_slot = min(battrs->maxreqs - 1, in alloc_session()
2015 NFSD_BC_SLOT_TABLE_SIZE - 1); in alloc_session()
2016 spin_lock_init(&new->se_lock); in alloc_session()
2019 while (i--) in alloc_session()
2020 kfree(new->se_slots[i]); in alloc_session()
2027 svc_xprt_put(c->cn_xprt); in free_conn()
2034 struct nfs4_client *clp = c->cn_session->se_client; in nfsd4_conn_lost()
2038 spin_lock(&clp->cl_lock); in nfsd4_conn_lost()
2039 if (!list_empty(&c->cn_persession)) { in nfsd4_conn_lost()
2040 list_del(&c->cn_persession); in nfsd4_conn_lost()
2044 spin_unlock(&clp->cl_lock); in nfsd4_conn_lost()
2054 svc_xprt_get(rqstp->rq_xprt); in alloc_conn()
2055 conn->cn_xprt = rqstp->rq_xprt; in alloc_conn()
2056 conn->cn_flags = flags; in alloc_conn()
2057 INIT_LIST_HEAD(&conn->cn_xpt_user.list); in alloc_conn()
2063 conn->cn_session = ses; in __nfsd4_hash_conn()
2064 list_add(&conn->cn_persession, &ses->se_conns); in __nfsd4_hash_conn()
2069 struct nfs4_client *clp = ses->se_client; in nfsd4_hash_conn()
2071 spin_lock(&clp->cl_lock); in nfsd4_hash_conn()
2073 spin_unlock(&clp->cl_lock); in nfsd4_hash_conn()
2078 conn->cn_xpt_user.callback = nfsd4_conn_lost; in nfsd4_register_conn()
2079 return register_xpt_user(conn->cn_xprt, &conn->cn_xpt_user); in nfsd4_register_conn()
2090 nfsd4_conn_lost(&conn->cn_xpt_user); in nfsd4_init_conn()
2092 nfsd4_probe_callback_sync(ses->se_client); in nfsd4_init_conn()
2099 if (cses->flags & SESSION4_BACK_CHAN) in alloc_conn_from_crses()
2107 struct nfs4_client *clp = s->se_client; in nfsd4_del_conns()
2110 spin_lock(&clp->cl_lock); in nfsd4_del_conns()
2111 while (!list_empty(&s->se_conns)) { in nfsd4_del_conns()
2112 c = list_first_entry(&s->se_conns, struct nfsd4_conn, cn_persession); in nfsd4_del_conns()
2113 list_del_init(&c->cn_persession); in nfsd4_del_conns()
2114 spin_unlock(&clp->cl_lock); in nfsd4_del_conns()
2116 unregister_xpt_user(c->cn_xprt, &c->cn_xpt_user); in nfsd4_del_conns()
2119 spin_lock(&clp->cl_lock); in nfsd4_del_conns()
2121 spin_unlock(&clp->cl_lock); in nfsd4_del_conns()
2133 nfsd4_put_drc_mem(&ses->se_fchannel); in free_session()
2142 new->se_client = clp; in init_session()
2145 INIT_LIST_HEAD(&new->se_conns); in init_session()
2147 atomic_set(&new->se_ref, 0); in init_session()
2148 new->se_dead = false; in init_session()
2149 new->se_cb_prog = cses->callback_prog; in init_session()
2150 new->se_cb_sec = cses->cb_sec; in init_session()
2153 new->se_cb_seq_nr[idx] = 1; in init_session()
2155 idx = hash_sessionid(&new->se_sessionid); in init_session()
2156 list_add(&new->se_hash, &nn->sessionid_hashtbl[idx]); in init_session()
2157 spin_lock(&clp->cl_lock); in init_session()
2158 list_add(&new->se_perclnt, &clp->cl_sessions); in init_session()
2159 spin_unlock(&clp->cl_lock); in init_session()
2170 rpc_copy_addr((struct sockaddr *)&clp->cl_cb_conn.cb_addr, sa); in init_session()
2171 clp->cl_cb_conn.cb_addrlen = svc_addr_len(sa); in init_session()
2183 lockdep_assert_held(&nn->client_lock); in __find_in_sessionid_hashtbl()
2188 list_for_each_entry(elem, &nn->sessionid_hashtbl[idx], se_hash) { in __find_in_sessionid_hashtbl()
2189 if (!memcmp(elem->se_sessionid.data, sessionid->data, in __find_in_sessionid_hashtbl()
2221 struct nfs4_client *clp = ses->se_client; in unhash_session()
2222 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in unhash_session()
2224 lockdep_assert_held(&nn->client_lock); in unhash_session()
2226 list_del(&ses->se_hash); in unhash_session()
2227 spin_lock(&ses->se_client->cl_lock); in unhash_session()
2228 list_del(&ses->se_perclnt); in unhash_session()
2229 spin_unlock(&ses->se_client->cl_lock); in unhash_session()
2241 if (clid->cl_boot == (u32)nn->boot_time) in STALE_CLIENTID()
2253 if (atomic_read(&nn->nfs4_client_count) >= nn->nfs4_max_clients && in alloc_client()
2254 atomic_read(&nn->nfsd_courtesy_clients) > 0) in alloc_client()
2255 mod_delayed_work(laundry_wq, &nn->laundromat_work, 0); in alloc_client()
2260 xdr_netobj_dup(&clp->cl_name, &name, GFP_KERNEL); in alloc_client()
2261 if (clp->cl_name.data == NULL) in alloc_client()
2263 clp->cl_ownerstr_hashtbl = kmalloc_array(OWNER_HASH_SIZE, in alloc_client()
2266 if (!clp->cl_ownerstr_hashtbl) in alloc_client()
2268 clp->cl_callback_wq = alloc_ordered_workqueue("nfsd4_callbacks", 0); in alloc_client()
2269 if (!clp->cl_callback_wq) in alloc_client()
2273 INIT_LIST_HEAD(&clp->cl_ownerstr_hashtbl[i]); in alloc_client()
2274 INIT_LIST_HEAD(&clp->cl_sessions); in alloc_client()
2275 idr_init(&clp->cl_stateids); in alloc_client()
2276 atomic_set(&clp->cl_rpc_users, 0); in alloc_client()
2277 clp->cl_cb_state = NFSD4_CB_UNKNOWN; in alloc_client()
2278 clp->cl_state = NFSD4_ACTIVE; in alloc_client()
2279 atomic_inc(&nn->nfs4_client_count); in alloc_client()
2280 atomic_set(&clp->cl_delegs_in_recall, 0); in alloc_client()
2281 INIT_LIST_HEAD(&clp->cl_idhash); in alloc_client()
2282 INIT_LIST_HEAD(&clp->cl_openowners); in alloc_client()
2283 INIT_LIST_HEAD(&clp->cl_delegations); in alloc_client()
2284 INIT_LIST_HEAD(&clp->cl_lru); in alloc_client()
2285 INIT_LIST_HEAD(&clp->cl_revoked); in alloc_client()
2287 INIT_LIST_HEAD(&clp->cl_lo_states); in alloc_client()
2289 INIT_LIST_HEAD(&clp->async_copies); in alloc_client()
2290 spin_lock_init(&clp->async_lock); in alloc_client()
2291 spin_lock_init(&clp->cl_lock); in alloc_client()
2292 rpc_init_wait_queue(&clp->cl_cb_waitq, "Backchannel slot table"); in alloc_client()
2295 kfree(clp->cl_ownerstr_hashtbl); in alloc_client()
2297 kfree(clp->cl_name.data); in alloc_client()
2308 free_svc_cred(&clp->cl_cred); in __free_client()
2309 destroy_workqueue(clp->cl_callback_wq); in __free_client()
2310 kfree(clp->cl_ownerstr_hashtbl); in __free_client()
2311 kfree(clp->cl_name.data); in __free_client()
2312 kfree(clp->cl_nii_domain.data); in __free_client()
2313 kfree(clp->cl_nii_name.data); in __free_client()
2314 idr_destroy(&clp->cl_stateids); in __free_client()
2315 kfree(clp->cl_ra); in __free_client()
2321 kref_put(&clp->cl_nfsdfs.cl_ref, __free_client); in drop_client()
2327 while (!list_empty(&clp->cl_sessions)) { in free_client()
2329 ses = list_entry(clp->cl_sessions.next, struct nfsd4_session, in free_client()
2331 list_del(&ses->se_perclnt); in free_client()
2332 WARN_ON_ONCE(atomic_read(&ses->se_ref)); in free_client()
2335 rpc_destroy_wait_queue(&clp->cl_cb_waitq); in free_client()
2336 if (clp->cl_nfsd_dentry) { in free_client()
2337 nfsd_client_rmdir(clp->cl_nfsd_dentry); in free_client()
2338 clp->cl_nfsd_dentry = NULL; in free_client()
2348 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in unhash_client_locked()
2351 lockdep_assert_held(&nn->client_lock); in unhash_client_locked()
2354 clp->cl_time = 0; in unhash_client_locked()
2356 if (!list_empty(&clp->cl_idhash)) { in unhash_client_locked()
2357 list_del_init(&clp->cl_idhash); in unhash_client_locked()
2358 if (test_bit(NFSD4_CLIENT_CONFIRMED, &clp->cl_flags)) in unhash_client_locked()
2359 rb_erase(&clp->cl_namenode, &nn->conf_name_tree); in unhash_client_locked()
2361 rb_erase(&clp->cl_namenode, &nn->unconf_name_tree); in unhash_client_locked()
2363 list_del_init(&clp->cl_lru); in unhash_client_locked()
2364 spin_lock(&clp->cl_lock); in unhash_client_locked()
2365 list_for_each_entry(ses, &clp->cl_sessions, se_perclnt) in unhash_client_locked()
2366 list_del_init(&ses->se_hash); in unhash_client_locked()
2367 spin_unlock(&clp->cl_lock); in unhash_client_locked()
2373 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in unhash_client()
2375 spin_lock(&nn->client_lock); in unhash_client()
2377 spin_unlock(&nn->client_lock); in unhash_client()
2382 int users = atomic_read(&clp->cl_rpc_users); in mark_client_expired_locked()
2395 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in __destroy_client()
2402 while (!list_empty(&clp->cl_delegations)) { in __destroy_client()
2403 dp = list_entry(clp->cl_delegations.next, struct nfs4_delegation, dl_perclnt); in __destroy_client()
2405 list_add(&dp->dl_recall_lru, &reaplist); in __destroy_client()
2410 list_del_init(&dp->dl_recall_lru); in __destroy_client()
2413 while (!list_empty(&clp->cl_revoked)) { in __destroy_client()
2414 dp = list_entry(clp->cl_revoked.next, struct nfs4_delegation, dl_recall_lru); in __destroy_client()
2415 list_del_init(&dp->dl_recall_lru); in __destroy_client()
2416 nfs4_put_stid(&dp->dl_stid); in __destroy_client()
2418 while (!list_empty(&clp->cl_openowners)) { in __destroy_client()
2419 oo = list_entry(clp->cl_openowners.next, struct nfs4_openowner, oo_perclient); in __destroy_client()
2420 nfs4_get_stateowner(&oo->oo_owner); in __destroy_client()
2426 list_for_each_entry_safe(so, tmp, &clp->cl_ownerstr_hashtbl[i], in __destroy_client()
2429 WARN_ON_ONCE(so->so_is_open_owner); in __destroy_client()
2436 if (clp->cl_cb_conn.cb_xprt) in __destroy_client()
2437 svc_xprt_put(clp->cl_cb_conn.cb_xprt); in __destroy_client()
2438 atomic_add_unless(&nn->nfs4_client_count, -1, 0); in __destroy_client()
2453 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in inc_reclaim_complete()
2455 if (!nn->track_reclaim_completes) in inc_reclaim_complete()
2457 if (!nfsd4_find_reclaim_client(clp->cl_name, nn)) in inc_reclaim_complete()
2459 if (atomic_inc_return(&nn->nr_reclaim_complete) == in inc_reclaim_complete()
2460 nn->reclaim_str_hashtbl_size) { in inc_reclaim_complete()
2462 clp->net->ns.inum); in inc_reclaim_complete()
2476 memcpy(target->cl_verifier.data, source->data, in copy_verf()
2477 sizeof(target->cl_verifier.data)); in copy_verf()
2482 target->cl_clientid.cl_boot = source->cl_clientid.cl_boot; in copy_clid()
2483 target->cl_clientid.cl_id = source->cl_clientid.cl_id; in copy_clid()
2488 target->cr_principal = kstrdup(source->cr_principal, GFP_KERNEL); in copy_cred()
2489 target->cr_raw_principal = kstrdup(source->cr_raw_principal, in copy_cred()
2491 target->cr_targ_princ = kstrdup(source->cr_targ_princ, GFP_KERNEL); in copy_cred()
2492 if ((source->cr_principal && !target->cr_principal) || in copy_cred()
2493 (source->cr_raw_principal && !target->cr_raw_principal) || in copy_cred()
2494 (source->cr_targ_princ && !target->cr_targ_princ)) in copy_cred()
2495 return -ENOMEM; in copy_cred()
2497 target->cr_flavor = source->cr_flavor; in copy_cred()
2498 target->cr_uid = source->cr_uid; in copy_cred()
2499 target->cr_gid = source->cr_gid; in copy_cred()
2500 target->cr_group_info = source->cr_group_info; in copy_cred()
2501 get_group_info(target->cr_group_info); in copy_cred()
2502 target->cr_gss_mech = source->cr_gss_mech; in copy_cred()
2503 if (source->cr_gss_mech) in copy_cred()
2504 gss_mech_get(source->cr_gss_mech); in copy_cred()
2511 if (o1->len < o2->len) in compare_blob()
2512 return -1; in compare_blob()
2513 if (o1->len > o2->len) in compare_blob()
2515 return memcmp(o1->data, o2->data, o1->len); in compare_blob()
2521 return 0 == memcmp(v1->data, v2->data, sizeof(v1->data)); in same_verf()
2527 return (cl1->cl_boot == cl2->cl_boot) && (cl1->cl_id == cl2->cl_id); in same_clid()
2534 if (g1->ngroups != g2->ngroups) in groups_equal()
2536 for (i=0; i<g1->ngroups; i++) in groups_equal()
2537 if (!gid_eq(g1->gid[i], g2->gid[i])) in groups_equal()
2546 * approximation. We also don't want to allow non-gss use of a client
2554 return (cr->cr_flavor > RPC_AUTH_MAXFLAVOR); in is_gss_cred()
2562 || (!uid_eq(cr1->cr_uid, cr2->cr_uid)) in same_creds()
2563 || (!gid_eq(cr1->cr_gid, cr2->cr_gid)) in same_creds()
2564 || !groups_equal(cr1->cr_group_info, cr2->cr_group_info)) in same_creds()
2567 if (cr1->cr_principal == cr2->cr_principal) in same_creds()
2569 if (!cr1->cr_principal || !cr2->cr_principal) in same_creds()
2571 return 0 == strcmp(cr1->cr_principal, cr2->cr_principal); in same_creds()
2576 struct svc_cred *cr = &rqstp->rq_cred; in svc_rqst_integrity_protected()
2579 if (!cr->cr_gss_mech) in svc_rqst_integrity_protected()
2581 service = gss_pseudoflavor_to_service(cr->cr_gss_mech, cr->cr_flavor); in svc_rqst_integrity_protected()
2588 struct svc_cred *cr = &rqstp->rq_cred; in nfsd4_mach_creds_match()
2590 if (!cl->cl_mach_cred) in nfsd4_mach_creds_match()
2592 if (cl->cl_cred.cr_gss_mech != cr->cr_gss_mech) in nfsd4_mach_creds_match()
2596 if (cl->cl_cred.cr_raw_principal) in nfsd4_mach_creds_match()
2597 return 0 == strcmp(cl->cl_cred.cr_raw_principal, in nfsd4_mach_creds_match()
2598 cr->cr_raw_principal); in nfsd4_mach_creds_match()
2599 if (!cr->cr_principal) in nfsd4_mach_creds_match()
2601 return 0 == strcmp(cl->cl_cred.cr_principal, cr->cr_principal); in nfsd4_mach_creds_match()
2609 * This is opaque to client, so no need to byte-swap. Use in gen_confirm()
2613 verf[1] = (__force __be32)nn->clverifier_counter++; in gen_confirm()
2614 memcpy(clp->cl_confirm.data, verf, sizeof(clp->cl_confirm.data)); in gen_confirm()
2619 clp->cl_clientid.cl_boot = (u32)nn->boot_time; in gen_clid()
2620 clp->cl_clientid.cl_id = nn->clientid_counter++; in gen_clid()
2629 ret = idr_find(&cl->cl_stateids, t->si_opaque.so_id); in find_stateid_locked()
2630 if (!ret || !ret->sc_type) in find_stateid_locked()
2641 spin_lock(&cl->cl_lock); in find_stateid_by_type()
2644 if ((s->sc_status & ~ok_states) == 0 && in find_stateid_by_type()
2645 (typemask & s->sc_type)) in find_stateid_by_type()
2646 refcount_inc(&s->sc_count); in find_stateid_by_type()
2650 spin_unlock(&cl->cl_lock); in find_stateid_by_type()
2656 struct nfsdfs_client *nc; in get_nfsdfs_clp() local
2657 nc = get_nfsdfs_client(inode); in get_nfsdfs_clp()
2658 if (!nc) in get_nfsdfs_clp()
2660 return container_of(nc, struct nfs4_client, cl_nfsdfs); in get_nfsdfs_clp()
2687 struct inode *inode = file_inode(m->file); in client_info_show()
2693 return -ENXIO; in client_info_show()
2694 memcpy(&clid, &clp->cl_clientid, sizeof(clid)); in client_info_show()
2696 seq_printf(m, "address: \"%pISpc\"\n", (struct sockaddr *)&clp->cl_addr); in client_info_show()
2698 if (clp->cl_state == NFSD4_COURTESY) in client_info_show()
2700 else if (clp->cl_state == NFSD4_EXPIRABLE) in client_info_show()
2702 else if (test_bit(NFSD4_CLIENT_CONFIRMED, &clp->cl_flags)) in client_info_show()
2707 ktime_get_boottime_seconds() - clp->cl_time); in client_info_show()
2709 seq_quote_mem(m, clp->cl_name.data, clp->cl_name.len); in client_info_show()
2710 seq_printf(m, "\nminor version: %d\n", clp->cl_minorversion); in client_info_show()
2711 if (clp->cl_nii_domain.data) { in client_info_show()
2713 seq_quote_mem(m, clp->cl_nii_domain.data, in client_info_show()
2714 clp->cl_nii_domain.len); in client_info_show()
2716 seq_quote_mem(m, clp->cl_nii_name.data, clp->cl_nii_name.len); in client_info_show()
2718 clp->cl_nii_time.tv_sec, clp->cl_nii_time.tv_nsec); in client_info_show()
2720 seq_printf(m, "callback state: %s\n", cb_state2str(clp->cl_cb_state)); in client_info_show()
2721 seq_printf(m, "callback address: \"%pISpc\"\n", &clp->cl_cb_conn.cb_addr); in client_info_show()
2722 seq_printf(m, "admin-revoked states: %d\n", in client_info_show()
2723 atomic_read(&clp->cl_admin_revoked)); in client_info_show()
2732 __acquires(&clp->cl_lock) in states_start()
2734 struct nfs4_client *clp = s->private; in states_start()
2738 spin_lock(&clp->cl_lock); in states_start()
2739 ret = idr_get_next_ul(&clp->cl_stateids, &id); in states_start()
2746 struct nfs4_client *clp = s->private; in states_next()
2752 ret = idr_get_next_ul(&clp->cl_stateids, &id); in states_next()
2758 __releases(&clp->cl_lock) in states_stop()
2760 struct nfs4_client *clp = s->private; in states_stop()
2762 spin_unlock(&clp->cl_lock); in states_stop()
2767 seq_printf(s, "filename: \"%pD2\"", f->nf_file); in nfs4_show_fname()
2772 struct inode *inode = file_inode(f->nf_file); in nfs4_show_superblock()
2775 MAJOR(inode->i_sb->s_dev), in nfs4_show_superblock()
2776 MINOR(inode->i_sb->s_dev), in nfs4_show_superblock()
2777 inode->i_ino); in nfs4_show_superblock()
2783 seq_quote_mem(s, oo->so_owner.data, oo->so_owner.len); in nfs4_show_owner()
2788 seq_printf(s, "0x%.8x", stid->si_generation); in nfs4_show_stateid()
2789 seq_printf(s, "%12phN", &stid->si_opaque); in nfs4_show_stateid()
2801 oo = ols->st_stateowner; in nfs4_show_open()
2802 nf = st->sc_file; in nfs4_show_open()
2804 seq_puts(s, "- "); in nfs4_show_open()
2805 nfs4_show_stateid(s, &st->sc_stateid); in nfs4_show_open()
2808 access = bmap_to_share_mode(ols->st_access_bmap); in nfs4_show_open()
2809 deny = bmap_to_share_mode(ols->st_deny_bmap); in nfs4_show_open()
2812 access & NFS4_SHARE_ACCESS_READ ? "r" : "-", in nfs4_show_open()
2813 access & NFS4_SHARE_ACCESS_WRITE ? "w" : "-"); in nfs4_show_open()
2815 deny & NFS4_SHARE_ACCESS_READ ? "r" : "-", in nfs4_show_open()
2816 deny & NFS4_SHARE_ACCESS_WRITE ? "w" : "-"); in nfs4_show_open()
2819 spin_lock(&nf->fi_lock); in nfs4_show_open()
2827 spin_unlock(&nf->fi_lock); in nfs4_show_open()
2831 if (st->sc_status & SC_STATUS_ADMIN_REVOKED) in nfs4_show_open()
2832 seq_puts(s, ", admin-revoked"); in nfs4_show_open()
2845 oo = ols->st_stateowner; in nfs4_show_lock()
2846 nf = st->sc_file; in nfs4_show_lock()
2848 seq_puts(s, "- "); in nfs4_show_lock()
2849 nfs4_show_stateid(s, &st->sc_stateid); in nfs4_show_lock()
2852 spin_lock(&nf->fi_lock); in nfs4_show_lock()
2869 if (st->sc_status & SC_STATUS_ADMIN_REVOKED) in nfs4_show_lock()
2870 seq_puts(s, ", admin-revoked"); in nfs4_show_lock()
2872 spin_unlock(&nf->fi_lock); in nfs4_show_lock()
2883 nf = st->sc_file; in nfs4_show_deleg()
2885 seq_puts(s, "- "); in nfs4_show_deleg()
2886 nfs4_show_stateid(s, &st->sc_stateid); in nfs4_show_deleg()
2890 ds->dl_type == NFS4_OPEN_DELEGATE_READ ? "r" : "w"); in nfs4_show_deleg()
2894 spin_lock(&nf->fi_lock); in nfs4_show_deleg()
2895 file = nf->fi_deleg_file; in nfs4_show_deleg()
2902 spin_unlock(&nf->fi_lock); in nfs4_show_deleg()
2903 if (st->sc_status & SC_STATUS_ADMIN_REVOKED) in nfs4_show_deleg()
2904 seq_puts(s, ", admin-revoked"); in nfs4_show_deleg()
2916 seq_puts(s, "- "); in nfs4_show_layout()
2917 nfs4_show_stateid(s, &st->sc_stateid); in nfs4_show_layout()
2922 spin_lock(&ls->ls_stid.sc_file->fi_lock); in nfs4_show_layout()
2923 file = ls->ls_file; in nfs4_show_layout()
2930 spin_unlock(&ls->ls_stid.sc_file->fi_lock); in nfs4_show_layout()
2931 if (st->sc_status & SC_STATUS_ADMIN_REVOKED) in nfs4_show_layout()
2932 seq_puts(s, ", admin-revoked"); in nfs4_show_layout()
2942 switch (st->sc_type) { in states_show()
2972 return -ENXIO; in client_states_open()
2977 s = file->private_data; in client_states_open()
2978 s->private = clp; in client_states_open()
2984 struct seq_file *m = file->private_data; in client_opens_release()
2985 struct nfs4_client *clp = m->private; in client_opens_release()
3007 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in force_expire_client()
3010 trace_nfsd_clid_admin_expired(&clp->cl_clientid); in force_expire_client()
3012 spin_lock(&nn->client_lock); in force_expire_client()
3013 clp->cl_time = 0; in force_expire_client()
3014 spin_unlock(&nn->client_lock); in force_expire_client()
3016 wait_event(expiry_wq, atomic_read(&clp->cl_rpc_users) == 0); in force_expire_client()
3017 spin_lock(&nn->client_lock); in force_expire_client()
3018 already_expired = list_empty(&clp->cl_lru); in force_expire_client()
3021 spin_unlock(&nn->client_lock); in force_expire_client()
3026 wait_event(expiry_wq, clp->cl_nfsd_dentry == NULL); in force_expire_client()
3039 return -EINVAL; in client_ctl_write()
3042 return -ENXIO; in client_ctl_write()
3065 switch (task->tk_status) { in nfsd4_cb_recall_any_done()
3066 case -NFS4ERR_DELAY: in nfsd4_cb_recall_any_done()
3077 struct nfs4_client *clp = cb->cb_clp; in nfsd4_cb_recall_any_release()
3079 clear_bit(NFSD4_CLIENT_CB_RECALL_ANY, &clp->cl_flags); in nfsd4_cb_recall_any_release()
3091 trace_nfsd_cb_getattr_done(&dp->dl_stid.sc_stateid, task); in nfsd4_cb_getattr_done()
3092 ncf->ncf_cb_status = task->tk_status; in nfsd4_cb_getattr_done()
3093 switch (task->tk_status) { in nfsd4_cb_getattr_done()
3094 case -NFS4ERR_DELAY: in nfsd4_cb_getattr_done()
3110 clear_and_wake_up_bit(CB_GETATTR_BUSY, &ncf->ncf_cb_flags); in nfsd4_cb_getattr_release()
3111 nfs4_put_stid(&dp->dl_stid); in nfsd4_cb_getattr_release()
3131 if (test_and_set_bit(CB_GETATTR_BUSY, &ncf->ncf_cb_flags)) in nfs4_cb_getattr()
3134 ncf->ncf_cb_status = NFS4ERR_IO; in nfs4_cb_getattr()
3136 refcount_inc(&dp->dl_stid.sc_count); in nfs4_cb_getattr()
3137 nfsd4_run_cb(&ncf->ncf_getattr); in nfs4_cb_getattr()
3154 ret = copy_cred(&clp->cl_cred, &rqstp->rq_cred); in create_client()
3160 kref_init(&clp->cl_nfsdfs.cl_ref); in create_client()
3161 nfsd4_init_cb(&clp->cl_cb_null, clp, NULL, NFSPROC4_CLNT_CB_NULL); in create_client()
3162 clp->cl_time = ktime_get_boottime_seconds(); in create_client()
3164 memcpy(&clp->cl_addr, sa, sizeof(struct sockaddr_storage)); in create_client()
3165 clp->cl_cb_session = NULL; in create_client()
3166 clp->net = net; in create_client()
3167 clp->cl_nfsd_dentry = nfsd_client_mkdir( in create_client()
3168 nn, &clp->cl_nfsdfs, in create_client()
3169 clp->cl_clientid.cl_id - nn->clientid_base, in create_client()
3171 clp->cl_nfsd_info_dentry = dentries[0]; in create_client()
3172 if (!clp->cl_nfsd_dentry) { in create_client()
3176 clp->cl_ra = kzalloc(sizeof(*clp->cl_ra), GFP_KERNEL); in create_client()
3177 if (!clp->cl_ra) { in create_client()
3181 clp->cl_ra_time = 0; in create_client()
3182 nfsd4_init_cb(&clp->cl_ra->ra_cb, clp, &nfsd4_cb_recall_any_ops, in create_client()
3190 struct rb_node **new = &(root->rb_node), *parent = NULL; in add_clp_to_name_tree()
3197 if (compare_blob(&clp->cl_name, &new_clp->cl_name) > 0) in add_clp_to_name_tree()
3198 new = &((*new)->rb_left); in add_clp_to_name_tree()
3200 new = &((*new)->rb_right); in add_clp_to_name_tree()
3203 rb_link_node(&new_clp->cl_namenode, parent, new); in add_clp_to_name_tree()
3204 rb_insert_color(&new_clp->cl_namenode, root); in add_clp_to_name_tree()
3211 struct rb_node *node = root->rb_node; in find_clp_in_name_tree()
3216 cmp = compare_blob(&clp->cl_name, name); in find_clp_in_name_tree()
3218 node = node->rb_left; in find_clp_in_name_tree()
3220 node = node->rb_right; in find_clp_in_name_tree()
3231 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in add_to_unconfirmed()
3233 lockdep_assert_held(&nn->client_lock); in add_to_unconfirmed()
3235 clear_bit(NFSD4_CLIENT_CONFIRMED, &clp->cl_flags); in add_to_unconfirmed()
3236 add_clp_to_name_tree(clp, &nn->unconf_name_tree); in add_to_unconfirmed()
3237 idhashval = clientid_hashval(clp->cl_clientid.cl_id); in add_to_unconfirmed()
3238 list_add(&clp->cl_idhash, &nn->unconf_id_hashtbl[idhashval]); in add_to_unconfirmed()
3245 unsigned int idhashval = clientid_hashval(clp->cl_clientid.cl_id); in move_to_confirmed()
3246 struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); in move_to_confirmed()
3248 lockdep_assert_held(&nn->client_lock); in move_to_confirmed()
3250 list_move(&clp->cl_idhash, &nn->conf_id_hashtbl[idhashval]); in move_to_confirmed()
3251 rb_erase(&clp->cl_namenode, &nn->unconf_name_tree); in move_to_confirmed()
3252 add_clp_to_name_tree(clp, &nn->conf_name_tree); in move_to_confirmed()
3253 set_bit(NFSD4_CLIENT_CONFIRMED, &clp->cl_flags); in move_to_confirmed()
3254 trace_nfsd_clid_confirmed(&clp->cl_clientid); in move_to_confirmed()
3262 unsigned int idhashval = clientid_hashval(clid->cl_id); in find_client_in_id_table()
3265 if (same_clid(&clp->cl_clientid, clid)) { in find_client_in_id_table()
3266 if ((bool)clp->cl_minorversion != sessions) in find_client_in_id_table()
3278 struct list_head *tbl = nn->conf_id_hashtbl; in find_confirmed_client()
3280 lockdep_assert_held(&nn->client_lock); in find_confirmed_client()
3287 struct list_head *tbl = nn->unconf_id_hashtbl; in find_unconfirmed_client()
3289 lockdep_assert_held(&nn->client_lock); in find_unconfirmed_client()
3295 return clp->cl_exchange_flags != 0; in clp_used_exchangeid()
3301 lockdep_assert_held(&nn->client_lock); in find_confirmed_client_by_name()
3302 return find_clp_in_name_tree(name, &nn->conf_name_tree); in find_confirmed_client_by_name()
3308 lockdep_assert_held(&nn->client_lock); in find_unconfirmed_client_by_name()
3309 return find_clp_in_name_tree(name, &nn->unconf_name_tree); in find_unconfirmed_client_by_name()
3315 struct nfs4_cb_conn *conn = &clp->cl_cb_conn; in gen_callback()
3321 if (se->se_callback_netid_len == 3 && in gen_callback()
3322 !memcmp(se->se_callback_netid_val, "tcp", 3)) in gen_callback()
3324 else if (se->se_callback_netid_len == 4 && in gen_callback()
3325 !memcmp(se->se_callback_netid_val, "tcp6", 4)) in gen_callback()
3330 conn->cb_addrlen = rpc_uaddr2sockaddr(clp->net, se->se_callback_addr_val, in gen_callback()
3331 se->se_callback_addr_len, in gen_callback()
3332 (struct sockaddr *)&conn->cb_addr, in gen_callback()
3333 sizeof(conn->cb_addr)); in gen_callback()
3335 if (!conn->cb_addrlen || conn->cb_addr.ss_family != expected_family) in gen_callback()
3338 if (conn->cb_addr.ss_family == AF_INET6) in gen_callback()
3339 ((struct sockaddr_in6 *)&conn->cb_addr)->sin6_scope_id = scopeid; in gen_callback()
3341 conn->cb_prog = se->se_callback_prog; in gen_callback()
3342 conn->cb_ident = se->se_callback_ident; in gen_callback()
3343 memcpy(&conn->cb_saddr, &rqstp->rq_daddr, rqstp->rq_daddrlen); in gen_callback()
3347 conn->cb_addr.ss_family = AF_UNSPEC; in gen_callback()
3348 conn->cb_addrlen = 0; in gen_callback()
3359 struct xdr_buf *buf = resp->xdr->buf; in nfsd4_store_cache_entry()
3360 struct nfsd4_slot *slot = resp->cstate.slot; in nfsd4_store_cache_entry()
3363 dprintk("--> %s slot %p\n", __func__, slot); in nfsd4_store_cache_entry()
3365 slot->sl_flags |= NFSD4_SLOT_INITIALIZED; in nfsd4_store_cache_entry()
3366 slot->sl_opcnt = resp->opcnt; in nfsd4_store_cache_entry()
3367 slot->sl_status = resp->cstate.status; in nfsd4_store_cache_entry()
3368 free_svc_cred(&slot->sl_cred); in nfsd4_store_cache_entry()
3369 copy_cred(&slot->sl_cred, &resp->rqstp->rq_cred); in nfsd4_store_cache_entry()
3372 slot->sl_flags &= ~NFSD4_SLOT_CACHED; in nfsd4_store_cache_entry()
3375 slot->sl_flags |= NFSD4_SLOT_CACHED; in nfsd4_store_cache_entry()
3377 base = resp->cstate.data_offset; in nfsd4_store_cache_entry()
3378 slot->sl_datalen = buf->len - base; in nfsd4_store_cache_entry()
3379 if (read_bytes_from_xdr_buf(buf, base, slot->sl_data, slot->sl_datalen)) in nfsd4_store_cache_entry()
3388 * operation which sets resp->p and increments resp->opcnt for
3397 struct nfsd4_slot *slot = resp->cstate.slot; in nfsd4_enc_sequence_replay()
3400 op = &args->ops[resp->opcnt - 1]; in nfsd4_enc_sequence_replay()
3403 if (slot->sl_flags & NFSD4_SLOT_CACHED) in nfsd4_enc_sequence_replay()
3404 return op->status; in nfsd4_enc_sequence_replay()
3405 if (args->opcnt == 1) { in nfsd4_enc_sequence_replay()
3407 * The original operation wasn't a solo sequence--we in nfsd4_enc_sequence_replay()
3408 * always cache those--so this retry must not match the in nfsd4_enc_sequence_replay()
3411 op->status = nfserr_seq_false_retry; in nfsd4_enc_sequence_replay()
3413 op = &args->ops[resp->opcnt++]; in nfsd4_enc_sequence_replay()
3414 op->status = nfserr_retry_uncached_rep; in nfsd4_enc_sequence_replay()
3417 return op->status; in nfsd4_enc_sequence_replay()
3428 struct nfsd4_slot *slot = resp->cstate.slot; in nfsd4_replay_cache_entry()
3429 struct xdr_stream *xdr = resp->xdr; in nfsd4_replay_cache_entry()
3433 dprintk("--> %s slot %p\n", __func__, slot); in nfsd4_replay_cache_entry()
3435 status = nfsd4_enc_sequence_replay(resp->rqstp->rq_argp, resp); in nfsd4_replay_cache_entry()
3439 p = xdr_reserve_space(xdr, slot->sl_datalen); in nfsd4_replay_cache_entry()
3444 xdr_encode_opaque_fixed(p, slot->sl_data, slot->sl_datalen); in nfsd4_replay_cache_entry()
3447 resp->opcnt = slot->sl_opcnt; in nfsd4_replay_cache_entry()
3448 return slot->sl_status; in nfsd4_replay_cache_entry()
3458 new->cl_exchange_flags |= EXCHGID4_FLAG_USE_PNFS_MDS; in nfsd4_set_ex_flags()
3460 new->cl_exchange_flags |= EXCHGID4_FLAG_USE_NON_PNFS; in nfsd4_set_ex_flags()
3464 new->cl_exchange_flags |= EXCHGID4_FLAG_SUPP_MOVED_REFER; in nfsd4_set_ex_flags()
3467 clid->flags = new->cl_exchange_flags; in nfsd4_set_ex_flags()
3474 list_for_each_entry(oo, &clp->cl_openowners, oo_perclient) { in client_has_openowners()
3475 if (!list_empty(&oo->oo_owner.so_stateids)) in client_has_openowners()
3485 || !list_empty(&clp->cl_lo_states) in client_has_state()
3487 || !list_empty(&clp->cl_delegations) in client_has_state()
3488 || !list_empty(&clp->cl_sessions) in client_has_state()
3495 if (!exid->nii_domain.data) in copy_impl_id()
3497 xdr_netobj_dup(&clp->cl_nii_domain, &exid->nii_domain, GFP_KERNEL); in copy_impl_id()
3498 if (!clp->cl_nii_domain.data) in copy_impl_id()
3500 xdr_netobj_dup(&clp->cl_nii_name, &exid->nii_name, GFP_KERNEL); in copy_impl_id()
3501 if (!clp->cl_nii_name.data) in copy_impl_id()
3503 clp->cl_nii_time = exid->nii_time; in copy_impl_id()
3511 struct nfsd4_exchange_id *exid = &u->exchange_id; in nfsd4_exchange_id()
3516 nfs4_verifier verf = exid->verifier; in nfsd4_exchange_id()
3518 bool update = exid->flags & EXCHGID4_FLAG_UPD_CONFIRMED_REC_A; in nfsd4_exchange_id()
3524 __func__, rqstp, exid, exid->clname.len, exid->clname.data, in nfsd4_exchange_id()
3525 addr_str, exid->flags, exid->spa_how); in nfsd4_exchange_id()
3527 exid->server_impl_name = kasprintf(GFP_KERNEL, "%s %s %s %s", in nfsd4_exchange_id()
3528 utsname()->sysname, utsname()->release, in nfsd4_exchange_id()
3529 utsname()->version, utsname()->machine); in nfsd4_exchange_id()
3530 if (!exid->server_impl_name) in nfsd4_exchange_id()
3533 if (exid->flags & ~EXCHGID4_FLAG_MASK_A) in nfsd4_exchange_id()
3536 new = create_client(exid->clname, rqstp, &verf); in nfsd4_exchange_id()
3543 switch (exid->spa_how) { in nfsd4_exchange_id()
3545 exid->spo_must_enforce[0] = 0; in nfsd4_exchange_id()
3546 exid->spo_must_enforce[1] = ( in nfsd4_exchange_id()
3547 1 << (OP_BIND_CONN_TO_SESSION - 32) | in nfsd4_exchange_id()
3548 1 << (OP_EXCHANGE_ID - 32) | in nfsd4_exchange_id()
3549 1 << (OP_CREATE_SESSION - 32) | in nfsd4_exchange_id()
3550 1 << (OP_DESTROY_SESSION - 32) | in nfsd4_exchange_id()
3551 1 << (OP_DESTROY_CLIENTID - 32)); in nfsd4_exchange_id()
3553 exid->spo_must_allow[0] &= (1 << (OP_CLOSE) | in nfsd4_exchange_id()
3558 exid->spo_must_allow[1] &= ( in nfsd4_exchange_id()
3559 1 << (OP_TEST_STATEID - 32) | in nfsd4_exchange_id()
3560 1 << (OP_FREE_STATEID - 32)); in nfsd4_exchange_id()
3570 if (!new->cl_cred.cr_principal && in nfsd4_exchange_id()
3571 !new->cl_cred.cr_raw_principal) { in nfsd4_exchange_id()
3575 new->cl_mach_cred = true; in nfsd4_exchange_id()
3588 spin_lock(&nn->client_lock); in nfsd4_exchange_id()
3589 conf = find_confirmed_client_by_name(&exid->clname, nn); in nfsd4_exchange_id()
3591 bool creds_match = same_creds(&conf->cl_cred, &rqstp->rq_cred); in nfsd4_exchange_id()
3592 bool verfs_match = same_verf(&verf, &conf->cl_verifier); in nfsd4_exchange_id()
3612 exid->flags |= EXCHGID4_FLAG_CONFIRMED_R; in nfsd4_exchange_id()
3625 conf->cl_exchange_flags |= EXCHGID4_FLAG_CONFIRMED_R; in nfsd4_exchange_id()
3640 unconf = find_unconfirmed_client_by_name(&exid->clname, nn); in nfsd4_exchange_id()
3652 trace_nfsd_clid_replaced(&conf->cl_clientid); in nfsd4_exchange_id()
3654 new->cl_minorversion = cstate->minorversion; in nfsd4_exchange_id()
3655 new->cl_spo_must_allow.u.words[0] = exid->spo_must_allow[0]; in nfsd4_exchange_id()
3656 new->cl_spo_must_allow.u.words[1] = exid->spo_must_allow[1]; in nfsd4_exchange_id()
3659 new->cl_cs_slot.sl_status = nfserr_seq_misordered; in nfsd4_exchange_id()
3664 exid->clientid.cl_boot = conf->cl_clientid.cl_boot; in nfsd4_exchange_id()
3665 exid->clientid.cl_id = conf->cl_clientid.cl_id; in nfsd4_exchange_id()
3667 exid->seqid = conf->cl_cs_slot.sl_seqid + 1; in nfsd4_exchange_id()
3670 exid->nii_domain.len = sizeof("kernel.org") - 1; in nfsd4_exchange_id()
3671 exid->nii_domain.data = "kernel.org"; in nfsd4_exchange_id()
3678 exid->nii_name.len = strlen(exid->server_impl_name); in nfsd4_exchange_id()
3679 if (exid->nii_name.len > NFS4_OPAQUE_LIMIT) in nfsd4_exchange_id()
3680 exid->nii_name.len = NFS4_OPAQUE_LIMIT; in nfsd4_exchange_id()
3681 exid->nii_name.data = exid->server_impl_name; in nfsd4_exchange_id()
3683 /* just send zeros - the date is in nii_name */ in nfsd4_exchange_id()
3684 exid->nii_time.tv_sec = 0; in nfsd4_exchange_id()
3685 exid->nii_time.tv_nsec = 0; in nfsd4_exchange_id()
3688 conf->cl_cs_slot.sl_seqid, conf->cl_exchange_flags); in nfsd4_exchange_id()
3692 spin_unlock(&nn->client_lock); in nfsd4_exchange_id()
3697 trace_nfsd_clid_expire_unconf(&unconf->cl_clientid); in nfsd4_exchange_id()
3706 struct nfsd4_exchange_id *exid = &u->exchange_id; in nfsd4_exchange_id_release()
3708 kfree(exid->server_impl_name); in nfsd4_exchange_id_release()
3720 /* Note unsigned 32-bit arithmetic handles wraparound: */ in check_slot_seqid()
3737 slot->sl_status = nfserr; in nfsd4_cache_create_session()
3738 memcpy(&slot->sl_cr_ses, cr_ses, sizeof(*cr_ses)); in nfsd4_cache_create_session()
3745 memcpy(cr_ses, &slot->sl_cr_ses, sizeof(*cr_ses)); in nfsd4_replay_create_session()
3746 return slot->sl_status; in nfsd4_replay_create_session()
3768 u32 maxrpc = nn->nfsd_serv->sv_max_mesg; in check_forechannel_attrs()
3770 if (ca->maxreq_sz < NFSD_MIN_REQ_HDR_SEQ_SZ) in check_forechannel_attrs()
3772 if (ca->maxresp_sz < NFSD_MIN_RESP_HDR_SEQ_SZ) in check_forechannel_attrs()
3774 ca->headerpadsz = 0; in check_forechannel_attrs()
3775 ca->maxreq_sz = min_t(u32, ca->maxreq_sz, maxrpc); in check_forechannel_attrs()
3776 ca->maxresp_sz = min_t(u32, ca->maxresp_sz, maxrpc); in check_forechannel_attrs()
3777 ca->maxops = min_t(u32, ca->maxops, NFSD_MAX_OPS_PER_COMPOUND); in check_forechannel_attrs()
3778 ca->maxresp_cached = min_t(u32, ca->maxresp_cached, in check_forechannel_attrs()
3780 ca->maxreqs = min_t(u32, ca->maxreqs, NFSD_MAX_SLOTS_PER_SESSION); in check_forechannel_attrs()
3791 ca->maxreqs = nfsd4_get_drc_mem(ca, nn); in check_forechannel_attrs()
3797 * Server's NFSv4.1 backchannel support is AUTH_SYS-only for now.
3814 ca->headerpadsz = 0; in check_backchannel_attrs()
3816 if (ca->maxreq_sz < NFSD_CB_MAX_REQ_SZ) in check_backchannel_attrs()
3818 if (ca->maxresp_sz < NFSD_CB_MAX_RESP_SZ) in check_backchannel_attrs()
3820 ca->maxresp_cached = 0; in check_backchannel_attrs()
3821 if (ca->maxops < 2) in check_backchannel_attrs()
3829 switch (cbs->flavor) { in nfsd4_check_cb_sec()
3849 struct nfsd4_create_session *cr_ses = &u->create_session; in nfsd4_create_session()
3859 if (cr_ses->flags & ~SESSION4_FLAG_MASK_A) in nfsd4_create_session()
3861 status = nfsd4_check_cb_sec(&cr_ses->cb_sec); in nfsd4_create_session()
3864 status = check_forechannel_attrs(&cr_ses->fore_channel, nn); in nfsd4_create_session()
3867 status = check_backchannel_attrs(&cr_ses->back_channel); in nfsd4_create_session()
3871 new = alloc_session(&cr_ses->fore_channel, &cr_ses->back_channel); in nfsd4_create_session()
3878 spin_lock(&nn->client_lock); in nfsd4_create_session()
3880 /* RFC 8881 Section 18.36.4 Phase 1: Client record look-up. */ in nfsd4_create_session()
3881 unconf = find_unconfirmed_client(&cr_ses->clientid, true, nn); in nfsd4_create_session()
3882 conf = find_confirmed_client(&cr_ses->clientid, true, nn); in nfsd4_create_session()
3890 cs_slot = &conf->cl_cs_slot; in nfsd4_create_session()
3893 cs_slot = &unconf->cl_cs_slot; in nfsd4_create_session()
3896 status = check_slot_seqid(cr_ses->seqid, cs_slot->sl_seqid, 0); in nfsd4_create_session()
3899 cs_slot->sl_seqid++; in nfsd4_create_session()
3900 cr_ses->seqid = cs_slot->sl_seqid; in nfsd4_create_session()
3919 if (!same_creds(&unconf->cl_cred, &rqstp->rq_cred) || in nfsd4_create_session()
3920 !rpc_cmp_addr(sa, (struct sockaddr *) &unconf->cl_addr)) { in nfsd4_create_session()
3927 old = find_confirmed_client_by_name(&unconf->cl_name, nn); in nfsd4_create_session()
3932 trace_nfsd_clid_replaced(&old->cl_clientid); in nfsd4_create_session()
3941 cr_ses->flags &= ~SESSION4_PERSIST; in nfsd4_create_session()
3943 cr_ses->flags &= ~SESSION4_RDMA; in nfsd4_create_session()
3945 cr_ses->back_channel.maxreqs = new->se_cb_highest_slot + 1; in nfsd4_create_session()
3950 memcpy(cr_ses->sessionid.data, new->se_sessionid.data, in nfsd4_create_session()
3955 spin_unlock(&nn->client_lock); in nfsd4_create_session()
3957 fsnotify_dentry(conf->cl_nfsd_info_dentry, FS_MODIFY); in nfsd4_create_session()
3971 cs_slot->sl_seqid--; in nfsd4_create_session()
3972 cr_ses->seqid = cs_slot->sl_seqid; in nfsd4_create_session()
3978 spin_unlock(&nn->client_lock); in nfsd4_create_session()
3983 nfsd4_put_drc_mem(&cr_ses->fore_channel); in nfsd4_create_session()
4005 struct nfsd4_backchannel_ctl *bc = &u->backchannel_ctl; in nfsd4_backchannel_ctl()
4006 struct nfsd4_session *session = cstate->session; in nfsd4_backchannel_ctl()
4010 status = nfsd4_check_cb_sec(&bc->bc_cb_sec); in nfsd4_backchannel_ctl()
4013 spin_lock(&nn->client_lock); in nfsd4_backchannel_ctl()
4014 session->se_cb_prog = bc->bc_cb_program; in nfsd4_backchannel_ctl()
4015 session->se_cb_sec = bc->bc_cb_sec; in nfsd4_backchannel_ctl()
4016 spin_unlock(&nn->client_lock); in nfsd4_backchannel_ctl()
4018 nfsd4_probe_callback(session->se_client); in nfsd4_backchannel_ctl()
4027 list_for_each_entry(c, &s->se_conns, cn_persession) { in __nfsd4_find_conn()
4028 if (c->cn_xprt == xpt) { in __nfsd4_find_conn()
4038 struct nfs4_client *clp = session->se_client; in nfsd4_match_existing_connection()
4039 struct svc_xprt *xpt = rqst->rq_xprt; in nfsd4_match_existing_connection()
4044 spin_lock(&clp->cl_lock); in nfsd4_match_existing_connection()
4048 else if (req == c->cn_flags) in nfsd4_match_existing_connection()
4051 c->cn_flags != NFS4_CDFC4_BACK) in nfsd4_match_existing_connection()
4054 c->cn_flags != NFS4_CDFC4_FORE) in nfsd4_match_existing_connection()
4058 spin_unlock(&clp->cl_lock); in nfsd4_match_existing_connection()
4068 struct nfsd4_bind_conn_to_session *bcts = &u->bind_conn_to_session; in nfsd4_bind_conn_to_session()
4077 spin_lock(&nn->client_lock); in nfsd4_bind_conn_to_session()
4078 session = find_in_sessionid_hashtbl(&bcts->sessionid, net, &status); in nfsd4_bind_conn_to_session()
4079 spin_unlock(&nn->client_lock); in nfsd4_bind_conn_to_session()
4083 if (!nfsd4_mach_creds_match(session->se_client, rqstp)) in nfsd4_bind_conn_to_session()
4086 bcts->dir, &conn); in nfsd4_bind_conn_to_session()
4088 if (bcts->dir == NFS4_CDFC4_FORE_OR_BOTH || in nfsd4_bind_conn_to_session()
4089 bcts->dir == NFS4_CDFC4_BACK) in nfsd4_bind_conn_to_session()
4090 conn->cn_flags |= NFS4_CDFC4_BACK; in nfsd4_bind_conn_to_session()
4091 nfsd4_probe_callback(session->se_client); in nfsd4_bind_conn_to_session()
4096 status = nfsd4_map_bcts_dir(&bcts->dir); in nfsd4_bind_conn_to_session()
4099 conn = alloc_conn(rqstp, bcts->dir); in nfsd4_bind_conn_to_session()
4113 if (!cstate->session) in nfsd4_compound_in_session()
4115 return !memcmp(sid, &cstate->session->se_sessionid, sizeof(*sid)); in nfsd4_compound_in_session()
4122 struct nfs4_sessionid *sessionid = &u->destroy_session.sessionid; in nfsd4_destroy_session()
4136 spin_lock(&nn->client_lock); in nfsd4_destroy_session()
4141 if (!nfsd4_mach_creds_match(ses->se_client, r)) in nfsd4_destroy_session()
4147 spin_unlock(&nn->client_lock); in nfsd4_destroy_session()
4149 nfsd4_probe_callback_sync(ses->se_client); in nfsd4_destroy_session()
4151 spin_lock(&nn->client_lock); in nfsd4_destroy_session()
4156 spin_unlock(&nn->client_lock); in nfsd4_destroy_session()
4163 struct nfs4_client *clp = ses->se_client; in nfsd4_sequence_check_conn()
4168 spin_lock(&clp->cl_lock); in nfsd4_sequence_check_conn()
4169 c = __nfsd4_find_conn(new->cn_xprt, ses); in nfsd4_sequence_check_conn()
4173 if (clp->cl_mach_cred) in nfsd4_sequence_check_conn()
4176 spin_unlock(&clp->cl_lock); in nfsd4_sequence_check_conn()
4180 nfsd4_conn_lost(&new->cn_xpt_user); in nfsd4_sequence_check_conn()
4183 spin_unlock(&clp->cl_lock); in nfsd4_sequence_check_conn()
4190 struct nfsd4_compoundargs *args = rqstp->rq_argp; in nfsd4_session_too_many_ops()
4192 return args->opcnt > session->se_fchannel.maxops; in nfsd4_session_too_many_ops()
4198 struct xdr_buf *xb = &rqstp->rq_arg; in nfsd4_request_too_big()
4200 return xb->len > session->se_fchannel.maxreq_sz; in nfsd4_request_too_big()
4206 struct nfsd4_compoundargs *argp = rqstp->rq_argp; in replay_matches_cache()
4208 if ((bool)(slot->sl_flags & NFSD4_SLOT_CACHETHIS) != in replay_matches_cache()
4209 (bool)seq->cachethis) in replay_matches_cache()
4215 if (slot->sl_opcnt < argp->opcnt && !slot->sl_status) in replay_matches_cache()
4222 if (slot->sl_opcnt > argp->opcnt) in replay_matches_cache()
4225 if (!same_creds(&rqstp->rq_cred, &slot->sl_cred)) in replay_matches_cache()
4240 struct nfsd4_sequence *seq = &u->sequence; in nfsd4_sequence()
4241 struct nfsd4_compoundres *resp = rqstp->rq_resp; in nfsd4_sequence()
4242 struct xdr_stream *xdr = resp->xdr; in nfsd4_sequence()
4252 if (resp->opcnt != 1) in nfsd4_sequence()
4263 spin_lock(&nn->client_lock); in nfsd4_sequence()
4264 session = find_in_sessionid_hashtbl(&seq->sessionid, net, &status); in nfsd4_sequence()
4267 clp = session->se_client; in nfsd4_sequence()
4278 if (seq->slotid >= session->se_fchannel.maxreqs) in nfsd4_sequence()
4281 slot = session->se_slots[seq->slotid]; in nfsd4_sequence()
4282 dprintk("%s: slotid %d\n", __func__, seq->slotid); in nfsd4_sequence()
4287 seq->maxslots = session->se_fchannel.maxreqs; in nfsd4_sequence()
4290 status = check_slot_seqid(seq->seqid, slot->sl_seqid, in nfsd4_sequence()
4291 slot->sl_flags & NFSD4_SLOT_INUSE); in nfsd4_sequence()
4294 if (!(slot->sl_flags & NFSD4_SLOT_INITIALIZED)) in nfsd4_sequence()
4299 cstate->slot = slot; in nfsd4_sequence()
4300 cstate->session = session; in nfsd4_sequence()
4301 cstate->clp = clp; in nfsd4_sequence()
4302 /* Return the cached reply status and set cstate->status in nfsd4_sequence()
4305 cstate->status = nfserr_replay_cache; in nfsd4_sequence()
4316 buflen = (seq->cachethis) ? in nfsd4_sequence()
4317 session->se_fchannel.maxresp_cached : in nfsd4_sequence()
4318 session->se_fchannel.maxresp_sz; in nfsd4_sequence()
4319 status = (seq->cachethis) ? nfserr_rep_too_big_to_cache : in nfsd4_sequence()
4321 if (xdr_restrict_buflen(xdr, buflen - rqstp->rq_auth_slack)) in nfsd4_sequence()
4327 slot->sl_seqid = seq->seqid; in nfsd4_sequence()
4328 slot->sl_flags |= NFSD4_SLOT_INUSE; in nfsd4_sequence()
4329 if (seq->cachethis) in nfsd4_sequence()
4330 slot->sl_flags |= NFSD4_SLOT_CACHETHIS; in nfsd4_sequence()
4332 slot->sl_flags &= ~NFSD4_SLOT_CACHETHIS; in nfsd4_sequence()
4334 cstate->slot = slot; in nfsd4_sequence()
4335 cstate->session = session; in nfsd4_sequence()
4336 cstate->clp = clp; in nfsd4_sequence()
4339 switch (clp->cl_cb_state) { in nfsd4_sequence()
4341 seq->status_flags = SEQ4_STATUS_CB_PATH_DOWN; in nfsd4_sequence()
4344 seq->status_flags = SEQ4_STATUS_BACKCHANNEL_FAULT; in nfsd4_sequence()
4347 seq->status_flags = 0; in nfsd4_sequence()
4349 if (!list_empty(&clp->cl_revoked)) in nfsd4_sequence()
4350 seq->status_flags |= SEQ4_STATUS_RECALLABLE_STATE_REVOKED; in nfsd4_sequence()
4351 if (atomic_read(&clp->cl_admin_revoked)) in nfsd4_sequence()
4352 seq->status_flags |= SEQ4_STATUS_ADMIN_STATE_REVOKED; in nfsd4_sequence()
4357 spin_unlock(&nn->client_lock); in nfsd4_sequence()
4367 struct nfsd4_compound_state *cs = &resp->cstate; in nfsd4_sequence_done()
4370 if (cs->status != nfserr_replay_cache) { in nfsd4_sequence_done()
4372 cs->slot->sl_flags &= ~NFSD4_SLOT_INUSE; in nfsd4_sequence_done()
4375 nfsd4_put_session(cs->session); in nfsd4_sequence_done()
4376 } else if (cs->clp) in nfsd4_sequence_done()
4377 put_client_renew(cs->clp); in nfsd4_sequence_done()
4385 struct nfsd4_destroy_clientid *dc = &u->destroy_clientid; in nfsd4_destroy_clientid()
4391 spin_lock(&nn->client_lock); in nfsd4_destroy_clientid()
4392 unconf = find_unconfirmed_client(&dc->clientid, true, nn); in nfsd4_destroy_clientid()
4393 conf = find_confirmed_client(&dc->clientid, true, nn); in nfsd4_destroy_clientid()
4416 trace_nfsd_clid_destroyed(&clp->cl_clientid); in nfsd4_destroy_clientid()
4419 spin_unlock(&nn->client_lock); in nfsd4_destroy_clientid()
4429 struct nfsd4_reclaim_complete *rc = &u->reclaim_complete; in nfsd4_reclaim_complete()
4430 struct nfs4_client *clp = cstate->clp; in nfsd4_reclaim_complete()
4433 if (rc->rca_one_fs) { in nfsd4_reclaim_complete()
4434 if (!cstate->current_fh.fh_dentry) in nfsd4_reclaim_complete()
4444 if (test_and_set_bit(NFSD4_CLIENT_RECLAIM_COMPLETE, &clp->cl_flags)) in nfsd4_reclaim_complete()
4459 trace_nfsd_clid_reclaim_complete(&clp->cl_clientid); in nfsd4_reclaim_complete()
4470 struct nfsd4_setclientid *setclid = &u->setclientid; in nfsd4_setclientid()
4471 struct xdr_netobj clname = setclid->se_name; in nfsd4_setclientid()
4472 nfs4_verifier clverifier = setclid->se_verf; in nfsd4_setclientid()
4481 spin_lock(&nn->client_lock); in nfsd4_setclientid()
4487 if (!same_creds(&conf->cl_cred, &rqstp->rq_cred)) { in nfsd4_setclientid()
4496 if (same_verf(&conf->cl_verifier, &clverifier)) { in nfsd4_setclientid()
4504 new->cl_minorversion = 0; in nfsd4_setclientid()
4507 setclid->se_clientid.cl_boot = new->cl_clientid.cl_boot; in nfsd4_setclientid()
4508 setclid->se_clientid.cl_id = new->cl_clientid.cl_id; in nfsd4_setclientid()
4509 memcpy(setclid->se_confirm.data, new->cl_confirm.data, sizeof(setclid->se_confirm.data)); in nfsd4_setclientid()
4513 spin_unlock(&nn->client_lock); in nfsd4_setclientid()
4517 trace_nfsd_clid_expire_unconf(&unconf->cl_clientid); in nfsd4_setclientid()
4529 &u->setclientid_confirm; in nfsd4_setclientid_confirm()
4532 nfs4_verifier confirm = setclientid_confirm->sc_confirm; in nfsd4_setclientid_confirm()
4533 clientid_t * clid = &setclientid_confirm->sc_clientid; in nfsd4_setclientid_confirm()
4540 spin_lock(&nn->client_lock); in nfsd4_setclientid_confirm()
4551 if (unconf && !same_creds(&unconf->cl_cred, &rqstp->rq_cred)) { in nfsd4_setclientid_confirm()
4555 if (conf && !same_creds(&conf->cl_cred, &rqstp->rq_cred)) { in nfsd4_setclientid_confirm()
4559 if (!unconf || !same_verf(&confirm, &unconf->cl_confirm)) { in nfsd4_setclientid_confirm()
4560 if (conf && same_verf(&confirm, &conf->cl_confirm)) { in nfsd4_setclientid_confirm()
4570 nfsd4_change_callback(conf, &unconf->cl_cb_conn); in nfsd4_setclientid_confirm()
4572 old = find_confirmed_client_by_name(&unconf->cl_name, nn); in nfsd4_setclientid_confirm()
4576 && !same_creds(&unconf->cl_cred, in nfsd4_setclientid_confirm()
4577 &old->cl_cred)) { in nfsd4_setclientid_confirm()
4586 trace_nfsd_clid_replaced(&old->cl_clientid); in nfsd4_setclientid_confirm()
4592 spin_unlock(&nn->client_lock); in nfsd4_setclientid_confirm()
4594 fsnotify_dentry(conf->cl_nfsd_info_dentry, FS_MODIFY); in nfsd4_setclientid_confirm()
4596 spin_lock(&nn->client_lock); in nfsd4_setclientid_confirm()
4599 spin_unlock(&nn->client_lock); in nfsd4_setclientid_confirm()
4614 refcount_set(&fp->fi_ref, 1); in nfsd4_file_init()
4615 spin_lock_init(&fp->fi_lock); in nfsd4_file_init()
4616 INIT_LIST_HEAD(&fp->fi_stateids); in nfsd4_file_init()
4617 INIT_LIST_HEAD(&fp->fi_delegations); in nfsd4_file_init()
4618 INIT_LIST_HEAD(&fp->fi_clnt_odstate); in nfsd4_file_init()
4619 fh_copy_shallow(&fp->fi_fhandle, &fh->fh_handle); in nfsd4_file_init()
4620 fp->fi_deleg_file = NULL; in nfsd4_file_init()
4621 fp->fi_had_conflict = false; in nfsd4_file_init()
4622 fp->fi_share_deny = 0; in nfsd4_file_init()
4623 memset(fp->fi_fds, 0, sizeof(fp->fi_fds)); in nfsd4_file_init()
4624 memset(fp->fi_access, 0, sizeof(fp->fi_access)); in nfsd4_file_init()
4625 fp->fi_aliased = false; in nfsd4_file_init()
4626 fp->fi_inode = d_inode(fh->fh_dentry); in nfsd4_file_init()
4628 INIT_LIST_HEAD(&fp->fi_lo_states); in nfsd4_file_init()
4629 atomic_set(&fp->fi_lo_recalls, 0); in nfsd4_file_init()
4684 return -ENOMEM; in nfsd4_init_slabs()
4691 struct nfsd_net *nn = shrink->private_data; in nfsd4_state_shrinker_count()
4693 count = atomic_read(&nn->nfsd_courtesy_clients); in nfsd4_state_shrinker_count()
4697 queue_work(laundry_wq, &nn->nfsd_shrinker_work); in nfsd4_state_shrinker_count()
4710 struct sysinfo si; in nfsd4_init_leases_net() local
4713 nn->nfsd4_lease = 90; /* default lease time */ in nfsd4_init_leases_net()
4714 nn->nfsd4_grace = 90; in nfsd4_init_leases_net()
4715 nn->somebody_reclaimed = false; in nfsd4_init_leases_net()
4716 nn->track_reclaim_completes = false; in nfsd4_init_leases_net()
4717 nn->clverifier_counter = get_random_u32(); in nfsd4_init_leases_net()
4718 nn->clientid_base = get_random_u32(); in nfsd4_init_leases_net()
4719 nn->clientid_counter = nn->clientid_base + 1; in nfsd4_init_leases_net()
4720 nn->s2s_cp_cl_id = nn->clientid_counter++; in nfsd4_init_leases_net()
4722 atomic_set(&nn->nfs4_client_count, 0); in nfsd4_init_leases_net()
4723 si_meminfo(&si); in nfsd4_init_leases_net()
4724 max_clients = (u64)si.totalram * si.mem_unit / (1024 * 1024 * 1024); in nfsd4_init_leases_net()
4726 nn->nfs4_max_clients = max_t(int, max_clients, NFS4_CLIENTS_PER_GB); in nfsd4_init_leases_net()
4728 atomic_set(&nn->nfsd_courtesy_clients, 0); in nfsd4_init_leases_net()
4739 rp->rp_status = nfserr_serverfault; in init_nfs4_replay()
4740 rp->rp_buflen = 0; in init_nfs4_replay()
4741 rp->rp_buf = rp->rp_ibuf; in init_nfs4_replay()
4742 atomic_set(&rp->rp_locked, RP_UNLOCKED); in init_nfs4_replay()
4749 wait_var_event(&so->so_replay.rp_locked, in nfsd4_cstate_assign_replay()
4750 atomic_cmpxchg(&so->so_replay.rp_locked, in nfsd4_cstate_assign_replay()
4752 if (atomic_read(&so->so_replay.rp_locked) == RP_UNHASHED) in nfsd4_cstate_assign_replay()
4753 return -EAGAIN; in nfsd4_cstate_assign_replay()
4754 cstate->replay_owner = nfs4_get_stateowner(so); in nfsd4_cstate_assign_replay()
4761 struct nfs4_stateowner *so = cstate->replay_owner; in nfsd4_cstate_clear_replay()
4764 cstate->replay_owner = NULL; in nfsd4_cstate_clear_replay()
4765 atomic_set(&so->so_replay.rp_locked, RP_UNLOCKED); in nfsd4_cstate_clear_replay()
4767 wake_up_var(&so->so_replay.rp_locked); in nfsd4_cstate_clear_replay()
4780 xdr_netobj_dup(&sop->so_owner, owner, GFP_KERNEL); in alloc_stateowner()
4781 if (!sop->so_owner.data) { in alloc_stateowner()
4786 INIT_LIST_HEAD(&sop->so_stateids); in alloc_stateowner()
4787 sop->so_client = clp; in alloc_stateowner()
4788 init_nfs4_replay(&sop->so_replay); in alloc_stateowner()
4789 atomic_set(&sop->so_count, 1); in alloc_stateowner()
4795 lockdep_assert_held(&clp->cl_lock); in hash_openowner()
4797 list_add(&oo->oo_owner.so_strhash, in hash_openowner()
4798 &clp->cl_ownerstr_hashtbl[strhashval]); in hash_openowner()
4799 list_add(&oo->oo_perclient, &clp->cl_openowners); in hash_openowner()
4823 struct nfs4_openowner *oo = open->op_openowner; in nfsd4_find_existing_open()
4825 lockdep_assert_held(&fp->fi_lock); in nfsd4_find_existing_open()
4827 list_for_each_entry(local, &fp->fi_stateids, st_perfile) { in nfsd4_find_existing_open()
4829 if (local->st_stateowner->so_is_open_owner == 0) in nfsd4_find_existing_open()
4831 if (local->st_stateowner != &oo->oo_owner) in nfsd4_find_existing_open()
4833 if (local->st_stid.sc_type == SC_TYPE_OPEN && in nfsd4_find_existing_open()
4834 !local->st_stid.sc_status) { in nfsd4_find_existing_open()
4836 refcount_inc(&ret->st_stid.sc_count); in nfsd4_find_existing_open()
4844 __releases(&s->sc_client->cl_lock) in nfsd4_drop_revoked_stid()
4846 struct nfs4_client *cl = s->sc_client; in nfsd4_drop_revoked_stid()
4852 switch (s->sc_type) { in nfsd4_drop_revoked_stid()
4857 spin_unlock(&cl->cl_lock); in nfsd4_drop_revoked_stid()
4863 spin_unlock(&cl->cl_lock); in nfsd4_drop_revoked_stid()
4869 list_del_init(&dp->dl_recall_lru); in nfsd4_drop_revoked_stid()
4870 spin_unlock(&cl->cl_lock); in nfsd4_drop_revoked_stid()
4874 spin_unlock(&cl->cl_lock); in nfsd4_drop_revoked_stid()
4882 * that it can forget an admin-revoked stateid. in nfsd40_drop_revoked_stid()
4889 if (cl->cl_minorversion == 0) { in nfsd40_drop_revoked_stid()
4892 spin_lock(&cl->cl_lock); in nfsd40_drop_revoked_stid()
4897 spin_unlock(&cl->cl_lock); in nfsd40_drop_revoked_stid()
4906 if (s->sc_status & SC_STATUS_ADMIN_REVOKED) in nfsd4_verify_open_stid()
4908 else if (s->sc_status & SC_STATUS_REVOKED) in nfsd4_verify_open_stid()
4910 else if (s->sc_status & SC_STATUS_CLOSED) in nfsd4_verify_open_stid()
4921 mutex_lock_nested(&stp->st_mutex, LOCK_STATEID_MUTEX); in nfsd4_lock_ol_stateid()
4922 ret = nfsd4_verify_open_stid(&stp->st_stid); in nfsd4_lock_ol_stateid()
4924 nfsd40_drop_revoked_stid(stp->st_stid.sc_client, in nfsd4_lock_ol_stateid()
4925 &stp->st_stid.sc_stateid); in nfsd4_lock_ol_stateid()
4928 mutex_unlock(&stp->st_mutex); in nfsd4_lock_ol_stateid()
4937 spin_lock(&fp->fi_lock); in nfsd4_find_and_lock_existing_open()
4939 spin_unlock(&fp->fi_lock); in nfsd4_find_and_lock_existing_open()
4942 nfs4_put_stid(&stp->st_stid); in nfsd4_find_and_lock_existing_open()
4951 struct nfs4_client *clp = cstate->clp; in find_or_alloc_open_stateowner()
4955 spin_lock(&clp->cl_lock); in find_or_alloc_open_stateowner()
4959 spin_unlock(&clp->cl_lock); in find_or_alloc_open_stateowner()
4962 spin_unlock(&clp->cl_lock); in find_or_alloc_open_stateowner()
4964 if (oo && !(oo->oo_flags & NFS4_OO_CONFIRMED)) { in find_or_alloc_open_stateowner()
4971 nfs4_free_stateowner(&new->oo_owner); in find_or_alloc_open_stateowner()
4975 new = alloc_stateowner(openowner_slab, &open->op_owner, clp); in find_or_alloc_open_stateowner()
4978 new->oo_owner.so_ops = &openowner_ops; in find_or_alloc_open_stateowner()
4979 new->oo_owner.so_is_open_owner = 1; in find_or_alloc_open_stateowner()
4980 new->oo_owner.so_seqid = open->op_seqid; in find_or_alloc_open_stateowner()
4981 new->oo_flags = 0; in find_or_alloc_open_stateowner()
4983 new->oo_flags |= NFS4_OO_CONFIRMED; in find_or_alloc_open_stateowner()
4984 new->oo_time = 0; in find_or_alloc_open_stateowner()
4985 new->oo_last_closed_stid = NULL; in find_or_alloc_open_stateowner()
4986 INIT_LIST_HEAD(&new->oo_close_lru); in find_or_alloc_open_stateowner()
4994 struct nfs4_openowner *oo = open->op_openowner; in init_open_stateid()
4998 stp = open->op_stp; in init_open_stateid()
5000 mutex_init(&stp->st_mutex); in init_open_stateid()
5001 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX); in init_open_stateid()
5004 spin_lock(&oo->oo_owner.so_client->cl_lock); in init_open_stateid()
5005 spin_lock(&fp->fi_lock); in init_open_stateid()
5008 mutex_unlock(&stp->st_mutex); in init_open_stateid()
5017 open->op_stp = NULL; in init_open_stateid()
5018 refcount_inc(&stp->st_stid.sc_count); in init_open_stateid()
5019 stp->st_stid.sc_type = SC_TYPE_OPEN; in init_open_stateid()
5020 INIT_LIST_HEAD(&stp->st_locks); in init_open_stateid()
5021 stp->st_stateowner = nfs4_get_stateowner(&oo->oo_owner); in init_open_stateid()
5023 stp->st_stid.sc_file = fp; in init_open_stateid()
5024 stp->st_access_bmap = 0; in init_open_stateid()
5025 stp->st_deny_bmap = 0; in init_open_stateid()
5026 stp->st_openstp = NULL; in init_open_stateid()
5027 list_add(&stp->st_perstateowner, &oo->oo_owner.so_stateids); in init_open_stateid()
5028 list_add(&stp->st_perfile, &fp->fi_stateids); in init_open_stateid()
5031 spin_unlock(&fp->fi_lock); in init_open_stateid()
5032 spin_unlock(&oo->oo_owner.so_client->cl_lock); in init_open_stateid()
5036 nfs4_put_stid(&retstp->st_stid); in init_open_stateid()
5040 mutex_unlock(&stp->st_mutex); in init_open_stateid()
5055 struct nfs4_openowner *oo = openowner(s->st_stateowner); in move_to_close_lru()
5056 struct nfsd_net *nn = net_generic(s->st_stid.sc_client->net, in move_to_close_lru()
5072 atomic_set(&oo->oo_owner.so_replay.rp_locked, RP_UNHASHED); in move_to_close_lru()
5074 wake_up_var(&oo->oo_owner.so_replay.rp_locked); in move_to_close_lru()
5075 wait_event(close_wq, refcount_read(&s->st_stid.sc_count) == 2); in move_to_close_lru()
5078 if (s->st_stid.sc_file) { in move_to_close_lru()
5079 put_nfs4_file(s->st_stid.sc_file); in move_to_close_lru()
5080 s->st_stid.sc_file = NULL; in move_to_close_lru()
5083 spin_lock(&nn->client_lock); in move_to_close_lru()
5084 last = oo->oo_last_closed_stid; in move_to_close_lru()
5085 oo->oo_last_closed_stid = s; in move_to_close_lru()
5086 list_move_tail(&oo->oo_close_lru, &nn->close_lru); in move_to_close_lru()
5087 oo->oo_time = ktime_get_boottime_seconds(); in move_to_close_lru()
5088 spin_unlock(&nn->client_lock); in move_to_close_lru()
5090 nfs4_put_stid(&last->st_stid); in move_to_close_lru()
5096 struct inode *inode = d_inode(fhp->fh_dentry); in nfsd4_file_hash_lookup()
5104 if (fh_match(&fi->fi_fhandle, &fhp->fh_handle)) { in nfsd4_file_hash_lookup()
5105 if (refcount_inc_not_zero(&fi->fi_ref)) { in nfsd4_file_hash_lookup()
5120 * inode->i_lock prevents racing insertions from adding an entry
5126 struct inode *inode = d_inode(fhp->fh_dentry); in nfsd4_file_hash_insert()
5134 spin_lock(&inode->i_lock); in nfsd4_file_hash_insert()
5139 if (fh_match(&fi->fi_fhandle, &fhp->fh_handle)) { in nfsd4_file_hash_insert()
5140 if (refcount_inc_not_zero(&fi->fi_ref)) in nfsd4_file_hash_insert()
5143 fi->fi_aliased = alias_found = true; in nfsd4_file_hash_insert()
5149 err = rhltable_insert(&nfs4_file_rhltable, &new->fi_rlist, in nfsd4_file_hash_insert()
5154 new->fi_aliased = alias_found; in nfsd4_file_hash_insert()
5158 spin_unlock(&inode->i_lock); in nfsd4_file_hash_insert()
5165 rhltable_remove(&nfs4_file_rhltable, &fi->fi_rlist, in nfsd4_file_hash_remove()
5184 spin_lock(&fp->fi_lock); in nfs4_share_conflict()
5185 if (fp->fi_share_deny & deny_type) in nfs4_share_conflict()
5187 spin_unlock(&fp->fi_lock); in nfs4_share_conflict()
5196 return ctx && !list_empty_careful(&ctx->flc_lease); in nfsd4_deleg_present()
5200 * nfsd_wait_for_delegreturn - wait for delegations to be returned
5202 * @inode: in-core inode of the file being waited for
5224 struct nfsd_net *nn = net_generic(dp->dl_stid.sc_client->net, in nfsd4_cb_recall_prepare()
5227 block_delegations(&dp->dl_stid.sc_file->fi_fhandle); in nfsd4_cb_recall_prepare()
5231 * already holding inode->i_lock. in nfsd4_cb_recall_prepare()
5237 if (delegation_hashed(dp) && dp->dl_time == 0) { in nfsd4_cb_recall_prepare()
5238 dp->dl_time = ktime_get_boottime_seconds(); in nfsd4_cb_recall_prepare()
5239 list_add_tail(&dp->dl_recall_lru, &nn->del_recall_lru); in nfsd4_cb_recall_prepare()
5249 trace_nfsd_cb_recall_done(&dp->dl_stid.sc_stateid, task); in nfsd4_cb_recall_done()
5251 if (dp->dl_stid.sc_status) in nfsd4_cb_recall_done()
5255 switch (task->tk_status) { in nfsd4_cb_recall_done()
5258 case -NFS4ERR_DELAY: in nfsd4_cb_recall_done()
5261 case -EBADHANDLE: in nfsd4_cb_recall_done()
5262 case -NFS4ERR_BAD_STATEID: in nfsd4_cb_recall_done()
5267 if (dp->dl_retries--) { in nfsd4_cb_recall_done()
5281 nfs4_put_stid(&dp->dl_stid); in nfsd4_cb_recall_release()
5300 refcount_inc(&dp->dl_stid.sc_count); in nfsd_break_one_deleg()
5301 WARN_ON_ONCE(!nfsd4_run_cb(&dp->dl_recall)); in nfsd_break_one_deleg()
5308 struct nfs4_delegation *dp = (struct nfs4_delegation *) fl->c.flc_owner; in nfsd_break_deleg_cb()
5309 struct nfs4_file *fp = dp->dl_stid.sc_file; in nfsd_break_deleg_cb()
5310 struct nfs4_client *clp = dp->dl_stid.sc_client; in nfsd_break_deleg_cb()
5313 trace_nfsd_cb_recall(&dp->dl_stid); in nfsd_break_deleg_cb()
5315 dp->dl_recalled = true; in nfsd_break_deleg_cb()
5316 atomic_inc(&clp->cl_delegs_in_recall); in nfsd_break_deleg_cb()
5318 nn = net_generic(clp->net, nfsd_net_id); in nfsd_break_deleg_cb()
5319 mod_delayed_work(laundry_wq, &nn->laundromat_work, 0); in nfsd_break_deleg_cb()
5327 fl->fl_break_time = 0; in nfsd_break_deleg_cb()
5329 fp->fi_had_conflict = true; in nfsd_break_deleg_cb()
5335 * nfsd_breaker_owns_lease - Check if lease conflict was resolved
5344 struct nfs4_delegation *dl = fl->c.flc_owner; in nfsd_breaker_owns_lease()
5351 clp = *(rqst->rq_lease_breaker); in nfsd_breaker_owns_lease()
5352 return dl->dl_stid.sc_client == clp; in nfsd_breaker_owns_lease()
5359 struct nfs4_delegation *dp = (struct nfs4_delegation *) onlist->c.flc_owner; in nfsd_change_deleg_cb()
5360 struct nfs4_client *clp = dp->dl_stid.sc_client; in nfsd_change_deleg_cb()
5363 if (dp->dl_recalled) in nfsd_change_deleg_cb()
5364 atomic_dec(&clp->cl_delegs_in_recall); in nfsd_change_deleg_cb()
5367 return -EAGAIN; in nfsd_change_deleg_cb()
5380 if (seqid == so->so_seqid - 1) in nfsd4_check_seqid()
5382 if (seqid == so->so_seqid) in nfsd4_check_seqid()
5392 spin_lock(&nn->client_lock); in lookup_clientid()
5395 atomic_inc(&found->cl_rpc_users); in lookup_clientid()
5396 spin_unlock(&nn->client_lock); in lookup_clientid()
5404 if (cstate->clp) { in set_client()
5405 if (!same_clid(&cstate->clp->cl_clientid, clid)) in set_client()
5413 * set cstate->clp), so session = false: in set_client()
5415 cstate->clp = lookup_clientid(clid, false, nn); in set_client()
5416 if (!cstate->clp) in set_client()
5425 clientid_t *clientid = &open->op_clientid; in nfsd4_process_open1()
5435 open->op_file = nfsd4_alloc_file(); in nfsd4_process_open1()
5436 if (open->op_file == NULL) in nfsd4_process_open1()
5442 clp = cstate->clp; in nfsd4_process_open1()
5444 strhashval = ownerstr_hashval(&open->op_owner); in nfsd4_process_open1()
5447 open->op_openowner = oo; in nfsd4_process_open1()
5450 if (nfsd4_cstate_assign_replay(cstate, &oo->oo_owner) == -EAGAIN) { in nfsd4_process_open1()
5451 nfs4_put_stateowner(&oo->oo_owner); in nfsd4_process_open1()
5454 status = nfsd4_check_seqid(cstate, &oo->oo_owner, open->op_seqid); in nfsd4_process_open1()
5458 open->op_stp = nfs4_alloc_open_stateid(clp); in nfsd4_process_open1()
5459 if (!open->op_stp) in nfsd4_process_open1()
5463 (cstate->current_fh.fh_export->ex_flags & NFSEXP_PNFS)) { in nfsd4_process_open1()
5464 open->op_odstate = alloc_clnt_odstate(clp); in nfsd4_process_open1()
5465 if (!open->op_odstate) in nfsd4_process_open1()
5475 if ((flags & WR_STATE) && (dp->dl_type == NFS4_OPEN_DELEGATE_READ)) in nfs4_check_delegmode()
5499 return open->op_claim_type == NFS4_OPEN_CLAIM_DELEGATE_CUR || in nfsd4_is_deleg_cur()
5500 open->op_claim_type == NFS4_OPEN_CLAIM_DELEG_CUR_FH; in nfsd4_is_deleg_cur()
5511 deleg = find_deleg_stateid(cl, &open->op_delegate_stateid); in nfs4_check_deleg()
5514 if (deleg->dl_stid.sc_status & SC_STATUS_ADMIN_REVOKED) { in nfs4_check_deleg()
5515 nfs4_put_stid(&deleg->dl_stid); in nfs4_check_deleg()
5519 if (deleg->dl_stid.sc_status & SC_STATUS_REVOKED) { in nfs4_check_deleg()
5520 nfs4_put_stid(&deleg->dl_stid); in nfs4_check_deleg()
5521 nfsd40_drop_revoked_stid(cl, &open->op_delegate_stateid); in nfs4_check_deleg()
5525 flags = share_access_to_flags(open->op_share_access); in nfs4_check_deleg()
5528 nfs4_put_stid(&deleg->dl_stid); in nfs4_check_deleg()
5537 open->op_openowner->oo_flags |= NFS4_OO_CONFIRMED; in nfs4_check_deleg()
5563 if (!open->op_truncate) in nfsd4_truncate()
5565 if (!(open->op_share_access & NFS4_SHARE_ACCESS_WRITE)) in nfsd4_truncate()
5576 int oflag = nfs4_access_to_omode(open->op_share_access); in nfs4_get_vfs_file()
5577 int access = nfs4_access_to_access(open->op_share_access); in nfs4_get_vfs_file()
5580 spin_lock(&fp->fi_lock); in nfs4_get_vfs_file()
5586 status = nfs4_file_check_deny(fp, open->op_share_deny); in nfs4_get_vfs_file()
5589 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
5593 stp, open->op_share_deny, false)) in nfs4_get_vfs_file()
5595 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
5600 status = nfs4_file_get_access(fp, open->op_share_access); in nfs4_get_vfs_file()
5603 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
5607 stp, open->op_share_access, true)) in nfs4_get_vfs_file()
5609 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
5614 old_access_bmap = stp->st_access_bmap; in nfs4_get_vfs_file()
5615 set_access(open->op_share_access, stp); in nfs4_get_vfs_file()
5618 old_deny_bmap = stp->st_deny_bmap; in nfs4_get_vfs_file()
5619 set_deny(open->op_share_deny, stp); in nfs4_get_vfs_file()
5620 fp->fi_share_deny |= (open->op_share_deny & NFS4_SHARE_DENY_BOTH); in nfs4_get_vfs_file()
5622 if (!fp->fi_fds[oflag]) { in nfs4_get_vfs_file()
5623 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
5626 open->op_filp, &nf); in nfs4_get_vfs_file()
5630 spin_lock(&fp->fi_lock); in nfs4_get_vfs_file()
5631 if (!fp->fi_fds[oflag]) { in nfs4_get_vfs_file()
5632 fp->fi_fds[oflag] = nf; in nfs4_get_vfs_file()
5636 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
5640 status = nfserrno(nfsd_open_break_lease(cur_fh->fh_dentry->d_inode, in nfs4_get_vfs_file()
5651 stp->st_access_bmap = old_access_bmap; in nfs4_get_vfs_file()
5652 nfs4_file_put_access(fp, open->op_share_access); in nfs4_get_vfs_file()
5663 unsigned char old_deny_bmap = stp->st_deny_bmap; in nfs4_upgrade_open()
5665 if (!test_access(open->op_share_access, stp)) in nfs4_upgrade_open()
5669 spin_lock(&fp->fi_lock); in nfs4_upgrade_open()
5670 status = nfs4_file_check_deny(fp, open->op_share_deny); in nfs4_upgrade_open()
5673 set_deny(open->op_share_deny, stp); in nfs4_upgrade_open()
5674 fp->fi_share_deny |= in nfs4_upgrade_open()
5675 (open->op_share_deny & NFS4_SHARE_DENY_BOTH); in nfs4_upgrade_open()
5679 stp, open->op_share_deny, false)) in nfs4_upgrade_open()
5683 spin_unlock(&fp->fi_lock); in nfs4_upgrade_open()
5697 if (clp->cl_cb_state == NFSD4_CB_UP) in nfsd4_cb_channel_good()
5704 return clp->cl_minorversion && clp->cl_cb_state == NFSD4_CB_UNKNOWN; in nfsd4_cb_channel_good()
5715 fl->fl_lmops = &nfsd_lease_mng_ops; in nfs4_alloc_init_lease()
5716 fl->c.flc_flags = FL_DELEG; in nfs4_alloc_init_lease()
5717 fl->c.flc_type = flag == NFS4_OPEN_DELEGATE_READ? F_RDLCK: F_WRLCK; in nfs4_alloc_init_lease()
5718 fl->c.flc_owner = (fl_owner_t)dp; in nfs4_alloc_init_lease()
5719 fl->c.flc_pid = current->tgid; in nfs4_alloc_init_lease()
5720 fl->c.flc_file = dp->dl_stid.sc_file->fi_deleg_file->nf_file; in nfs4_alloc_init_lease()
5728 struct file *f = fp->fi_deleg_file->nf_file; in nfsd4_check_conflicting_opens()
5732 writes = atomic_read(&ino->i_writecount); in nfsd4_check_conflicting_opens()
5742 if (fp->fi_aliased) in nfsd4_check_conflicting_opens()
5743 return -EAGAIN; in nfsd4_check_conflicting_opens()
5751 if (fp->fi_fds[O_WRONLY]) in nfsd4_check_conflicting_opens()
5752 writes--; in nfsd4_check_conflicting_opens()
5753 if (fp->fi_fds[O_RDWR]) in nfsd4_check_conflicting_opens()
5754 writes--; in nfsd4_check_conflicting_opens()
5756 return -EAGAIN; /* There may be non-NFSv4 writers */ in nfsd4_check_conflicting_opens()
5758 * It's possible there are non-NFSv4 write opens in progress, in nfsd4_check_conflicting_opens()
5764 spin_lock(&fp->fi_lock); in nfsd4_check_conflicting_opens()
5765 list_for_each_entry(st, &fp->fi_stateids, st_perfile) { in nfsd4_check_conflicting_opens()
5766 if (st->st_openstp == NULL /* it's an open */ && in nfsd4_check_conflicting_opens()
5768 st->st_stid.sc_client != clp) { in nfsd4_check_conflicting_opens()
5769 spin_unlock(&fp->fi_lock); in nfsd4_check_conflicting_opens()
5770 return -EAGAIN; in nfsd4_check_conflicting_opens()
5773 spin_unlock(&fp->fi_lock); in nfsd4_check_conflicting_opens()
5796 err = nfsd_lookup_dentry(open->op_rqstp, parent, in nfsd4_verify_deleg_dentry()
5797 open->op_fname, open->op_fnamelen, in nfsd4_verify_deleg_dentry()
5801 return -EAGAIN; in nfsd4_verify_deleg_dentry()
5805 if (child != file_dentry(fp->fi_deleg_file->nf_file)) in nfsd4_verify_deleg_dentry()
5806 return -EAGAIN; in nfsd4_verify_deleg_dentry()
5820 struct inode *inode = file_inode(nf->nf_file); in nfsd4_verify_setuid_write()
5822 if ((open->op_share_access & NFS4_SHARE_ACCESS_WRITE) && in nfsd4_verify_setuid_write()
5823 (inode->i_mode & (S_ISUID|S_ISGID))) in nfsd4_verify_setuid_write()
5824 return -EAGAIN; in nfsd4_verify_setuid_write()
5833 struct nfs4_client *clp = stp->st_stid.sc_client; in nfs4_set_delegation()
5834 struct nfs4_file *fp = stp->st_stid.sc_file; in nfs4_set_delegation()
5835 struct nfs4_clnt_odstate *odstate = stp->st_clnt_odstate; in nfs4_set_delegation()
5846 if (fp->fi_had_conflict) in nfs4_set_delegation()
5847 return ERR_PTR(-EAGAIN); in nfs4_set_delegation()
5861 if ((open->op_share_access & NFS4_SHARE_ACCESS_BOTH) == NFS4_SHARE_ACCESS_BOTH) { in nfs4_set_delegation()
5870 if (!nf && (open->op_share_access & NFS4_SHARE_ACCESS_READ)) { in nfs4_set_delegation()
5876 return ERR_PTR(-EAGAIN); in nfs4_set_delegation()
5879 spin_lock(&fp->fi_lock); in nfs4_set_delegation()
5881 status = -EAGAIN; in nfs4_set_delegation()
5883 status = -EAGAIN; in nfs4_set_delegation()
5884 else if (!fp->fi_deleg_file) { in nfs4_set_delegation()
5885 fp->fi_deleg_file = nf; in nfs4_set_delegation()
5888 fp->fi_delegees = 1; in nfs4_set_delegation()
5891 fp->fi_delegees++; in nfs4_set_delegation()
5892 spin_unlock(&fp->fi_lock); in nfs4_set_delegation()
5899 status = -ENOMEM; in nfs4_set_delegation()
5908 status = kernel_setlease(fp->fi_deleg_file->nf_file, in nfs4_set_delegation()
5909 fl->c.flc_type, &fl, NULL); in nfs4_set_delegation()
5929 status = nfsd4_verify_setuid_write(open, fp->fi_deleg_file); in nfs4_set_delegation()
5933 status = -EAGAIN; in nfs4_set_delegation()
5934 if (fp->fi_had_conflict) in nfs4_set_delegation()
5938 spin_lock(&clp->cl_lock); in nfs4_set_delegation()
5939 spin_lock(&fp->fi_lock); in nfs4_set_delegation()
5941 spin_unlock(&fp->fi_lock); in nfs4_set_delegation()
5942 spin_unlock(&clp->cl_lock); in nfs4_set_delegation()
5950 kernel_setlease(fp->fi_deleg_file->nf_file, F_UNLCK, NULL, (void **)&dp); in nfs4_set_delegation()
5952 put_clnt_odstate(dp->dl_clnt_odstate); in nfs4_set_delegation()
5953 nfs4_put_stid(&dp->dl_stid); in nfs4_set_delegation()
5961 open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE_EXT; in nfsd4_open_deleg_none_ext()
5962 if (status == -EAGAIN) in nfsd4_open_deleg_none_ext()
5963 open->op_why_no_deleg = WND4_CONTENTION; in nfsd4_open_deleg_none_ext()
5965 open->op_why_no_deleg = WND4_RESOURCE; in nfsd4_open_deleg_none_ext()
5966 switch (open->op_deleg_want) { in nfsd4_open_deleg_none_ext()
5972 open->op_why_no_deleg = WND4_CANCELLED; in nfsd4_open_deleg_none_ext()
5984 struct nfsd_file *nf = find_rw_file(dp->dl_stid.sc_file); in nfs4_delegation_stat()
5991 path.mnt = currentfh->fh_export->ex_path.mnt; in nfs4_delegation_stat()
5992 path.dentry = file_dentry(nf->nf_file); in nfs4_delegation_stat()
6031 struct nfs4_openowner *oo = openowner(stp->st_stateowner); in nfs4_open_delegation()
6032 struct nfs4_client *clp = stp->st_stid.sc_client; in nfs4_open_delegation()
6038 cb_up = nfsd4_cb_channel_good(oo->oo_owner.so_client); in nfs4_open_delegation()
6039 open->op_recall = false; in nfs4_open_delegation()
6040 switch (open->op_claim_type) { in nfs4_open_delegation()
6043 open->op_recall = true; in nfs4_open_delegation()
6054 if (locks_in_grace(clp->net)) in nfs4_open_delegation()
6056 if (!cb_up || !(oo->oo_flags & NFS4_OO_CONFIRMED)) in nfs4_open_delegation()
6058 if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE && in nfs4_open_delegation()
6059 !clp->cl_minorversion) in nfs4_open_delegation()
6069 memcpy(&open->op_delegate_stateid, &dp->dl_stid.sc_stateid, sizeof(dp->dl_stid.sc_stateid)); in nfs4_open_delegation()
6071 if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) { in nfs4_open_delegation()
6073 nfs4_put_stid(&dp->dl_stid); in nfs4_open_delegation()
6077 open->op_delegate_type = NFS4_OPEN_DELEGATE_WRITE; in nfs4_open_delegation()
6078 dp->dl_cb_fattr.ncf_cur_fsize = stat.size; in nfs4_open_delegation()
6079 dp->dl_cb_fattr.ncf_initial_cinfo = nfsd4_change_attribute(&stat); in nfs4_open_delegation()
6080 trace_nfsd_deleg_write(&dp->dl_stid.sc_stateid); in nfs4_open_delegation()
6082 open->op_delegate_type = NFS4_OPEN_DELEGATE_READ; in nfs4_open_delegation()
6083 trace_nfsd_deleg_read(&dp->dl_stid.sc_stateid); in nfs4_open_delegation()
6085 nfs4_put_stid(&dp->dl_stid); in nfs4_open_delegation()
6088 open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE; in nfs4_open_delegation()
6089 if (open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS && in nfs4_open_delegation()
6090 open->op_delegate_type != NFS4_OPEN_DELEGATE_NONE) { in nfs4_open_delegation()
6092 open->op_recall = true; in nfs4_open_delegation()
6096 if (open->op_deleg_want) in nfs4_open_delegation()
6104 if (open->op_deleg_want == NFS4_SHARE_WANT_READ_DELEG && in nfsd4_deleg_xgrade_none_ext()
6105 dp->dl_type == NFS4_OPEN_DELEGATE_WRITE) { in nfsd4_deleg_xgrade_none_ext()
6106 open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE_EXT; in nfsd4_deleg_xgrade_none_ext()
6107 open->op_why_no_deleg = WND4_NOT_SUPP_DOWNGRADE; in nfsd4_deleg_xgrade_none_ext()
6108 } else if (open->op_deleg_want == NFS4_SHARE_WANT_WRITE_DELEG && in nfsd4_deleg_xgrade_none_ext()
6109 dp->dl_type == NFS4_OPEN_DELEGATE_WRITE) { in nfsd4_deleg_xgrade_none_ext()
6110 open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE_EXT; in nfsd4_deleg_xgrade_none_ext()
6111 open->op_why_no_deleg = WND4_NOT_SUPP_UPGRADE; in nfsd4_deleg_xgrade_none_ext()
6120 * nfsd4_process_open2 - finish open processing
6125 * If successful, (1) truncate the file if open->op_truncate was
6126 * set, (2) set open->op_stateid, (3) set open->op_delegation.
6134 struct nfsd4_compoundres *resp = rqstp->rq_resp; in nfsd4_process_open2()
6135 struct nfs4_client *cl = open->op_openowner->oo_owner.so_client; in nfsd4_process_open2()
6147 fp = nfsd4_file_hash_insert(open->op_file, current_fh); in nfsd4_process_open2()
6150 if (fp != open->op_file) { in nfsd4_process_open2()
6156 open->op_file = NULL; in nfsd4_process_open2()
6169 if (!open->op_stp) in nfsd4_process_open2()
6183 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
6190 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
6194 stp->st_clnt_odstate = find_or_hash_clnt_odstate(fp, in nfsd4_process_open2()
6195 open->op_odstate); in nfsd4_process_open2()
6196 if (stp->st_clnt_odstate == open->op_odstate) in nfsd4_process_open2()
6197 open->op_odstate = NULL; in nfsd4_process_open2()
6200 nfs4_inc_and_copy_stateid(&open->op_stateid, &stp->st_stid); in nfsd4_process_open2()
6201 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
6203 if (nfsd4_has_session(&resp->cstate)) { in nfsd4_process_open2()
6204 if (open->op_deleg_want & NFS4_SHARE_WANT_NO_DELEG) { in nfsd4_process_open2()
6205 open->op_delegate_type = NFS4_OPEN_DELEGATE_NONE_EXT; in nfsd4_process_open2()
6206 open->op_why_no_deleg = WND4_NOT_WANTED; in nfsd4_process_open2()
6215 nfs4_open_delegation(open, stp, &resp->cstate.current_fh); in nfsd4_process_open2()
6218 trace_nfsd_open(&stp->st_stid.sc_stateid); in nfsd4_process_open2()
6221 if (open->op_delegate_type == NFS4_OPEN_DELEGATE_NONE && dp && in nfsd4_process_open2()
6222 open->op_deleg_want) in nfsd4_process_open2()
6227 if (status == 0 && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS) in nfsd4_process_open2()
6228 open->op_openowner->oo_flags |= NFS4_OO_CONFIRMED; in nfsd4_process_open2()
6232 open->op_rflags = NFS4_OPEN_RESULT_LOCKTYPE_POSIX; in nfsd4_process_open2()
6233 if (nfsd4_has_session(&resp->cstate)) in nfsd4_process_open2()
6234 open->op_rflags |= NFS4_OPEN_RESULT_MAY_NOTIFY_LOCK; in nfsd4_process_open2()
6235 else if (!(open->op_openowner->oo_flags & NFS4_OO_CONFIRMED)) in nfsd4_process_open2()
6236 open->op_rflags |= NFS4_OPEN_RESULT_CONFIRM; in nfsd4_process_open2()
6239 nfs4_put_stid(&dp->dl_stid); in nfsd4_process_open2()
6241 nfs4_put_stid(&stp->st_stid); in nfsd4_process_open2()
6249 if (open->op_openowner) in nfsd4_cleanup_open_state()
6250 nfs4_put_stateowner(&open->op_openowner->oo_owner); in nfsd4_cleanup_open_state()
6251 if (open->op_file) in nfsd4_cleanup_open_state()
6252 kmem_cache_free(file_slab, open->op_file); in nfsd4_cleanup_open_state()
6253 if (open->op_stp) in nfsd4_cleanup_open_state()
6254 nfs4_put_stid(&open->op_stp->st_stid); in nfsd4_cleanup_open_state()
6255 if (open->op_odstate) in nfsd4_cleanup_open_state()
6256 kmem_cache_free(odstate_slab, open->op_odstate); in nfsd4_cleanup_open_state()
6263 clientid_t *clid = &u->renew; in nfsd4_renew()
6272 clp = cstate->clp; in nfsd4_renew()
6273 if (!list_empty(&clp->cl_delegations) in nfsd4_renew()
6274 && clp->cl_cb_state != NFSD4_CB_UP) in nfsd4_renew()
6283 if (nn->grace_ended) in nfsd4_end_grace()
6287 nn->grace_ended = true; in nfsd4_end_grace()
6304 locks_end_grace(&nn->nfsd4_manager); in nfsd4_end_grace()
6318 time64_t double_grace_period_end = nn->boot_time + in clients_still_reclaiming()
6319 2 * nn->nfsd4_lease; in clients_still_reclaiming()
6321 if (nn->track_reclaim_completes && in clients_still_reclaiming()
6322 atomic_read(&nn->nr_reclaim_complete) == in clients_still_reclaiming()
6323 nn->reclaim_str_hashtbl_size) in clients_still_reclaiming()
6325 if (!nn->somebody_reclaimed) in clients_still_reclaiming()
6327 nn->somebody_reclaimed = false; in clients_still_reclaiming()
6346 if (last_refresh < lt->cutoff) in state_expired()
6348 time_remaining = last_refresh - lt->cutoff; in state_expired()
6349 lt->new_timeo = min(lt->new_timeo, time_remaining); in state_expired()
6356 spin_lock_init(&nn->nfsd_ssc_lock); in nfsd4_ssc_init_umount_work()
6357 INIT_LIST_HEAD(&nn->nfsd_ssc_mount_list); in nfsd4_ssc_init_umount_work()
6358 init_waitqueue_head(&nn->nfsd_ssc_waitq); in nfsd4_ssc_init_umount_work()
6370 spin_lock(&nn->nfsd_ssc_lock); in nfsd4_ssc_shutdown_umount()
6371 list_for_each_entry_safe(ni, tmp, &nn->nfsd_ssc_mount_list, nsui_list) { in nfsd4_ssc_shutdown_umount()
6372 list_del(&ni->nsui_list); in nfsd4_ssc_shutdown_umount()
6373 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_ssc_shutdown_umount()
6374 mntput(ni->nsui_vfsmount); in nfsd4_ssc_shutdown_umount()
6376 spin_lock(&nn->nfsd_ssc_lock); in nfsd4_ssc_shutdown_umount()
6378 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_ssc_shutdown_umount()
6387 spin_lock(&nn->nfsd_ssc_lock); in nfsd4_ssc_expire_umount()
6388 list_for_each_entry_safe(ni, tmp, &nn->nfsd_ssc_mount_list, nsui_list) { in nfsd4_ssc_expire_umount()
6389 if (time_after(jiffies, ni->nsui_expire)) { in nfsd4_ssc_expire_umount()
6390 if (refcount_read(&ni->nsui_refcnt) > 1) in nfsd4_ssc_expire_umount()
6394 ni->nsui_busy = true; in nfsd4_ssc_expire_umount()
6395 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_ssc_expire_umount()
6396 mntput(ni->nsui_vfsmount); in nfsd4_ssc_expire_umount()
6397 spin_lock(&nn->nfsd_ssc_lock); in nfsd4_ssc_expire_umount()
6400 list_del(&ni->nsui_list); in nfsd4_ssc_expire_umount()
6410 wake_up_all(&nn->nfsd_ssc_waitq); in nfsd4_ssc_expire_umount()
6411 spin_unlock(&nn->nfsd_ssc_lock); in nfsd4_ssc_expire_umount()
6423 list_for_each_entry(stp, &lo->lo_owner.so_stateids, st_perstateowner) { in nfs4_lockowner_has_blockers()
6424 nf = stp->st_stid.sc_file; in nfs4_lockowner_has_blockers()
6425 ctx = locks_inode_context(nf->fi_inode); in nfs4_lockowner_has_blockers()
6441 if (atomic_read(&clp->cl_delegs_in_recall)) in nfs4_anylock_blockers()
6443 spin_lock(&clp->cl_lock); in nfs4_anylock_blockers()
6445 list_for_each_entry(so, &clp->cl_ownerstr_hashtbl[i], in nfs4_anylock_blockers()
6447 if (so->so_is_open_owner) in nfs4_anylock_blockers()
6451 spin_unlock(&clp->cl_lock); in nfs4_anylock_blockers()
6456 spin_unlock(&clp->cl_lock); in nfs4_anylock_blockers()
6468 maxreap = (atomic_read(&nn->nfs4_client_count) >= nn->nfs4_max_clients) ? in nfs4_get_client_reaplist()
6471 spin_lock(&nn->client_lock); in nfs4_get_client_reaplist()
6472 list_for_each_safe(pos, next, &nn->client_lru) { in nfs4_get_client_reaplist()
6474 if (clp->cl_state == NFSD4_EXPIRABLE) in nfs4_get_client_reaplist()
6476 if (!state_expired(lt, clp->cl_time)) in nfs4_get_client_reaplist()
6478 if (!atomic_read(&clp->cl_rpc_users)) { in nfs4_get_client_reaplist()
6479 if (clp->cl_state == NFSD4_ACTIVE) in nfs4_get_client_reaplist()
6480 atomic_inc(&nn->nfsd_courtesy_clients); in nfs4_get_client_reaplist()
6481 clp->cl_state = NFSD4_COURTESY; in nfs4_get_client_reaplist()
6490 list_add(&clp->cl_lru, reaplist); in nfs4_get_client_reaplist()
6494 spin_unlock(&nn->client_lock); in nfs4_get_client_reaplist()
6508 spin_lock(&nn->client_lock); in nfs4_get_courtesy_client_reaplist()
6509 list_for_each_safe(pos, next, &nn->client_lru) { in nfs4_get_courtesy_client_reaplist()
6511 if (clp->cl_state == NFSD4_ACTIVE) in nfs4_get_courtesy_client_reaplist()
6516 list_add(&clp->cl_lru, reaplist); in nfs4_get_courtesy_client_reaplist()
6520 spin_unlock(&nn->client_lock); in nfs4_get_courtesy_client_reaplist()
6531 trace_nfsd_clid_purged(&clp->cl_clientid); in nfs4_process_client_reaplist()
6532 list_del_init(&clp->cl_lru); in nfs4_process_client_reaplist()
6542 spin_lock(&nn->client_lock); in nfs40_clean_admin_revoked()
6543 if (nn->nfs40_last_revoke == 0 || in nfs40_clean_admin_revoked()
6544 nn->nfs40_last_revoke > lt->cutoff) { in nfs40_clean_admin_revoked()
6545 spin_unlock(&nn->client_lock); in nfs40_clean_admin_revoked()
6548 nn->nfs40_last_revoke = 0; in nfs40_clean_admin_revoked()
6551 list_for_each_entry(clp, &nn->client_lru, cl_lru) { in nfs40_clean_admin_revoked()
6555 if (atomic_read(&clp->cl_admin_revoked) == 0) in nfs40_clean_admin_revoked()
6558 spin_lock(&clp->cl_lock); in nfs40_clean_admin_revoked()
6559 idr_for_each_entry_ul(&clp->cl_stateids, stid, tmp, id) in nfs40_clean_admin_revoked()
6560 if (stid->sc_status & SC_STATUS_ADMIN_REVOKED) { in nfs40_clean_admin_revoked()
6561 refcount_inc(&stid->sc_count); in nfs40_clean_admin_revoked()
6562 spin_unlock(&nn->client_lock); in nfs40_clean_admin_revoked()
6563 /* this function drops ->cl_lock */ in nfs40_clean_admin_revoked()
6566 spin_lock(&nn->client_lock); in nfs40_clean_admin_revoked()
6569 spin_unlock(&clp->cl_lock); in nfs40_clean_admin_revoked()
6571 spin_unlock(&nn->client_lock); in nfs40_clean_admin_revoked()
6583 .cutoff = ktime_get_boottime_seconds() - nn->nfsd4_lease, in nfs4_laundromat()
6584 .new_timeo = nn->nfsd4_lease in nfs4_laundromat()
6596 spin_lock(&nn->s2s_cp_lock); in nfs4_laundromat()
6597 idr_for_each_entry(&nn->s2s_cp_stateids, cps_t, i) { in nfs4_laundromat()
6599 if (cps->cp_stateid.cs_type == NFS4_COPYNOTIFY_STID && in nfs4_laundromat()
6600 state_expired(<, cps->cpntf_time)) in nfs4_laundromat()
6603 spin_unlock(&nn->s2s_cp_lock); in nfs4_laundromat()
6611 list_for_each_safe(pos, next, &nn->del_recall_lru) { in nfs4_laundromat()
6613 if (!state_expired(<, dp->dl_time)) in nfs4_laundromat()
6615 refcount_inc(&dp->dl_stid.sc_count); in nfs4_laundromat()
6617 list_add(&dp->dl_recall_lru, &reaplist); in nfs4_laundromat()
6623 list_del_init(&dp->dl_recall_lru); in nfs4_laundromat()
6627 spin_lock(&nn->client_lock); in nfs4_laundromat()
6628 while (!list_empty(&nn->close_lru)) { in nfs4_laundromat()
6629 oo = list_first_entry(&nn->close_lru, struct nfs4_openowner, in nfs4_laundromat()
6631 if (!state_expired(<, oo->oo_time)) in nfs4_laundromat()
6633 list_del_init(&oo->oo_close_lru); in nfs4_laundromat()
6634 stp = oo->oo_last_closed_stid; in nfs4_laundromat()
6635 oo->oo_last_closed_stid = NULL; in nfs4_laundromat()
6636 spin_unlock(&nn->client_lock); in nfs4_laundromat()
6637 nfs4_put_stid(&stp->st_stid); in nfs4_laundromat()
6638 spin_lock(&nn->client_lock); in nfs4_laundromat()
6640 spin_unlock(&nn->client_lock); in nfs4_laundromat()
6645 * So, we clean out any un-revisited request after a lease period in nfs4_laundromat()
6654 spin_lock(&nn->blocked_locks_lock); in nfs4_laundromat()
6655 while (!list_empty(&nn->blocked_locks_lru)) { in nfs4_laundromat()
6656 nbl = list_first_entry(&nn->blocked_locks_lru, in nfs4_laundromat()
6658 if (!state_expired(<, nbl->nbl_time)) in nfs4_laundromat()
6660 list_move(&nbl->nbl_lru, &reaplist); in nfs4_laundromat()
6661 list_del_init(&nbl->nbl_list); in nfs4_laundromat()
6663 spin_unlock(&nn->blocked_locks_lock); in nfs4_laundromat()
6668 list_del_init(&nbl->nbl_lru); in nfs4_laundromat()
6672 /* service the server-to-server copy delayed unmount list */ in nfs4_laundromat()
6692 queue_delayed_work(laundry_wq, &nn->laundromat_work, t*HZ); in laundromat_main()
6711 spin_lock(&nn->client_lock); in deleg_reaper()
6712 list_for_each_safe(pos, next, &nn->client_lru) { in deleg_reaper()
6714 if (clp->cl_state != NFSD4_ACTIVE || in deleg_reaper()
6715 list_empty(&clp->cl_delegations) || in deleg_reaper()
6716 atomic_read(&clp->cl_delegs_in_recall) || in deleg_reaper()
6717 test_bit(NFSD4_CLIENT_CB_RECALL_ANY, &clp->cl_flags) || in deleg_reaper()
6718 (ktime_get_boottime_seconds() - in deleg_reaper()
6719 clp->cl_ra_time < 5)) { in deleg_reaper()
6722 list_add(&clp->cl_ra_cblist, &cblist); in deleg_reaper()
6725 kref_get(&clp->cl_nfsdfs.cl_ref); in deleg_reaper()
6726 set_bit(NFSD4_CLIENT_CB_RECALL_ANY, &clp->cl_flags); in deleg_reaper()
6727 clp->cl_ra_time = ktime_get_boottime_seconds(); in deleg_reaper()
6729 spin_unlock(&nn->client_lock); in deleg_reaper()
6734 list_del_init(&clp->cl_ra_cblist); in deleg_reaper()
6735 clp->cl_ra->ra_keep = 0; in deleg_reaper()
6736 clp->cl_ra->ra_bmval[0] = BIT(RCA4_TYPE_MASK_RDATA_DLG) | in deleg_reaper()
6738 trace_nfsd_cb_recall_any(clp->cl_ra); in deleg_reaper()
6739 nfsd4_run_cb(&clp->cl_ra->ra_cb); in deleg_reaper()
6755 if (!fh_match(&fhp->fh_handle, &stp->sc_file->fi_fhandle)) in nfs4_check_fh()
6766 if (stp->st_openstp) in nfs4_check_openmode()
6767 stp = stp->st_openstp; in nfs4_check_openmode()
6800 if (has_session && in->si_generation == 0) in check_stateid_generation()
6803 if (in->si_generation == ref->si_generation) in check_stateid_generation()
6811 * non-buggy client. For example, if the client sends a lock in check_stateid_generation()
6826 spin_lock(&s->sc_lock); in nfsd4_stid_check_stateid_generation()
6829 ret = check_stateid_generation(in, &s->sc_stateid, has_session); in nfsd4_stid_check_stateid_generation()
6830 spin_unlock(&s->sc_lock); in nfsd4_stid_check_stateid_generation()
6832 nfsd40_drop_revoked_stid(s->sc_client, in nfsd4_stid_check_stateid_generation()
6833 &s->sc_stateid); in nfsd4_stid_check_stateid_generation()
6839 if (ols->st_stateowner->so_is_open_owner && in nfsd4_check_openowner_confirmed()
6840 !(openowner(ols->st_stateowner)->oo_flags & NFS4_OO_CONFIRMED)) in nfsd4_check_openowner_confirmed()
6853 spin_lock(&cl->cl_lock); in nfsd4_validate_stateid()
6864 switch (s->sc_type) { in nfsd4_validate_stateid()
6873 printk("unknown stateid type %x\n", s->sc_type); in nfsd4_validate_stateid()
6877 spin_unlock(&cl->cl_lock); in nfsd4_validate_stateid()
6910 status = set_client(&stateid->si_opaque.so_clid, cstate, nn); in nfsd4_lookup_stateid()
6912 if (cstate->session) in nfsd4_lookup_stateid()
6918 stid = find_stateid_by_type(cstate->clp, stateid, typemask, statusmask); in nfsd4_lookup_stateid()
6921 if ((stid->sc_status & SC_STATUS_REVOKED) && !return_revoked) { in nfsd4_lookup_stateid()
6925 if (stid->sc_status & SC_STATUS_ADMIN_REVOKED) { in nfsd4_lookup_stateid()
6926 nfsd40_drop_revoked_stid(cstate->clp, stateid); in nfsd4_lookup_stateid()
6939 if (!s || s->sc_status) in nfs4_find_file()
6942 switch (s->sc_type) { in nfs4_find_file()
6944 spin_lock(&s->sc_file->fi_lock); in nfs4_find_file()
6945 ret = nfsd_file_get(s->sc_file->fi_deleg_file); in nfs4_find_file()
6946 spin_unlock(&s->sc_file->fi_lock); in nfs4_find_file()
6951 ret = find_readable_file(s->sc_file); in nfs4_find_file()
6953 ret = find_writeable_file(s->sc_file); in nfs4_find_file()
6980 status = nfsd_permission(&rqstp->rq_cred, in nfs4_check_file()
6981 fhp->fh_export, fhp->fh_dentry, in nfs4_check_file()
6999 WARN_ON_ONCE(cps->cp_stateid.cs_type != NFS4_COPYNOTIFY_STID); in _free_cpntf_state_locked()
7000 if (!refcount_dec_and_test(&cps->cp_stateid.cs_count)) in _free_cpntf_state_locked()
7002 list_del(&cps->cp_list); in _free_cpntf_state_locked()
7003 idr_remove(&nn->s2s_cp_stateids, in _free_cpntf_state_locked()
7004 cps->cp_stateid.cs_stid.si_opaque.so_id); in _free_cpntf_state_locked()
7019 if (st->si_opaque.so_clid.cl_id != nn->s2s_cp_cl_id) in manage_cpntf_state()
7021 spin_lock(&nn->s2s_cp_lock); in manage_cpntf_state()
7022 cps_t = idr_find(&nn->s2s_cp_stateids, st->si_opaque.so_id); in manage_cpntf_state()
7026 if (state->cp_stateid.cs_type != NFS4_COPYNOTIFY_STID) { in manage_cpntf_state()
7031 refcount_inc(&state->cp_stateid.cs_count); in manage_cpntf_state()
7036 spin_unlock(&nn->s2s_cp_lock); in manage_cpntf_state()
7055 cps->cpntf_time = ktime_get_boottime_seconds(); in find_cpntf_state()
7058 found = lookup_clientid(&cps->cp_p_clid, true, nn); in find_cpntf_state()
7062 *stid = find_stateid_by_type(found, &cps->cp_p_stateid, in find_cpntf_state()
7078 spin_lock(&nn->s2s_cp_lock); in nfs4_put_cpntf_state()
7080 spin_unlock(&nn->s2s_cp_lock); in nfs4_put_cpntf_state()
7084 * nfs4_preprocess_stateid_op - find and prep stateid for an operation
7128 switch (s->sc_type) { in nfs4_preprocess_stateid_op()
7161 struct nfsd4_test_stateid *test_stateid = &u->test_stateid; in nfsd4_test_stateid()
7163 struct nfs4_client *cl = cstate->clp; in nfsd4_test_stateid()
7165 list_for_each_entry(stateid, &test_stateid->ts_stateid_list, ts_id_list) in nfsd4_test_stateid()
7166 stateid->ts_id_status = in nfsd4_test_stateid()
7167 nfsd4_validate_stateid(cl, &stateid->ts_id_stateid); in nfsd4_test_stateid()
7182 ret = check_stateid_generation(stateid, &s->sc_stateid, 1); in nfsd4_free_lock_stateid()
7187 if (check_for_locks(stp->st_stid.sc_file, in nfsd4_free_lock_stateid()
7188 lockowner(stp->st_stateowner))) in nfsd4_free_lock_stateid()
7195 mutex_unlock(&stp->st_mutex); in nfsd4_free_lock_stateid()
7205 struct nfsd4_free_stateid *free_stateid = &u->free_stateid; in nfsd4_free_stateid()
7206 stateid_t *stateid = &free_stateid->fr_stateid; in nfsd4_free_stateid()
7209 struct nfs4_client *cl = cstate->clp; in nfsd4_free_stateid()
7212 spin_lock(&cl->cl_lock); in nfsd4_free_stateid()
7214 if (!s || s->sc_status & SC_STATUS_CLOSED) in nfsd4_free_stateid()
7216 if (s->sc_status & SC_STATUS_ADMIN_REVOKED) { in nfsd4_free_stateid()
7221 spin_lock(&s->sc_lock); in nfsd4_free_stateid()
7222 switch (s->sc_type) { in nfsd4_free_stateid()
7224 if (s->sc_status & SC_STATUS_REVOKED) { in nfsd4_free_stateid()
7225 s->sc_status |= SC_STATUS_CLOSED; in nfsd4_free_stateid()
7226 spin_unlock(&s->sc_lock); in nfsd4_free_stateid()
7228 if (s->sc_status & SC_STATUS_FREEABLE) in nfsd4_free_stateid()
7229 list_del_init(&dp->dl_recall_lru); in nfsd4_free_stateid()
7230 s->sc_status |= SC_STATUS_FREED; in nfsd4_free_stateid()
7231 spin_unlock(&cl->cl_lock); in nfsd4_free_stateid()
7239 ret = check_stateid_generation(stateid, &s->sc_stateid, 1); in nfsd4_free_stateid()
7245 spin_unlock(&s->sc_lock); in nfsd4_free_stateid()
7246 refcount_inc(&s->sc_count); in nfsd4_free_stateid()
7247 spin_unlock(&cl->cl_lock); in nfsd4_free_stateid()
7251 spin_unlock(&s->sc_lock); in nfsd4_free_stateid()
7253 spin_unlock(&cl->cl_lock); in nfsd4_free_stateid()
7267 struct svc_fh *current_fh = &cstate->current_fh; in nfs4_seqid_op_checks()
7268 struct nfs4_stateowner *sop = stp->st_stateowner; in nfs4_seqid_op_checks()
7277 status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate)); in nfs4_seqid_op_checks()
7279 status = nfs4_check_fh(current_fh, &stp->st_stid); in nfs4_seqid_op_checks()
7281 mutex_unlock(&stp->st_mutex); in nfs4_seqid_op_checks()
7286 * nfs4_preprocess_seqid_op - find and prep an ol_stateid for a seqid-morphing op
7319 if (nfsd4_cstate_assign_replay(cstate, stp->st_stateowner) == -EAGAIN) { in nfs4_preprocess_seqid_op()
7320 nfs4_put_stateowner(stp->st_stateowner); in nfs4_preprocess_seqid_op()
7328 nfs4_put_stid(&stp->st_stid); in nfs4_preprocess_seqid_op()
7343 oo = openowner(stp->st_stateowner); in nfs4_preprocess_confirmed_seqid_op()
7344 if (!(oo->oo_flags & NFS4_OO_CONFIRMED)) { in nfs4_preprocess_confirmed_seqid_op()
7345 mutex_unlock(&stp->st_mutex); in nfs4_preprocess_confirmed_seqid_op()
7346 nfs4_put_stid(&stp->st_stid); in nfs4_preprocess_confirmed_seqid_op()
7357 struct nfsd4_open_confirm *oc = &u->open_confirm; in nfsd4_open_confirm()
7364 cstate->current_fh.fh_dentry); in nfsd4_open_confirm()
7366 status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0); in nfsd4_open_confirm()
7371 oc->oc_seqid, &oc->oc_req_stateid, in nfsd4_open_confirm()
7375 oo = openowner(stp->st_stateowner); in nfsd4_open_confirm()
7377 if (oo->oo_flags & NFS4_OO_CONFIRMED) { in nfsd4_open_confirm()
7378 mutex_unlock(&stp->st_mutex); in nfsd4_open_confirm()
7381 oo->oo_flags |= NFS4_OO_CONFIRMED; in nfsd4_open_confirm()
7382 nfs4_inc_and_copy_stateid(&oc->oc_resp_stateid, &stp->st_stid); in nfsd4_open_confirm()
7383 mutex_unlock(&stp->st_mutex); in nfsd4_open_confirm()
7384 trace_nfsd_open_confirm(oc->oc_seqid, &stp->st_stid.sc_stateid); in nfsd4_open_confirm()
7385 nfsd4_client_record_create(oo->oo_owner.so_client); in nfsd4_open_confirm()
7388 nfs4_put_stid(&stp->st_stid); in nfsd4_open_confirm()
7398 nfs4_file_put_access(stp->st_stid.sc_file, access); in nfs4_stateid_downgrade_bit()
7424 struct nfsd4_open_downgrade *od = &u->open_downgrade; in nfsd4_open_downgrade()
7430 cstate->current_fh.fh_dentry); in nfsd4_open_downgrade()
7433 if (od->od_deleg_want) in nfsd4_open_downgrade()
7435 od->od_deleg_want); in nfsd4_open_downgrade()
7437 status = nfs4_preprocess_confirmed_seqid_op(cstate, od->od_seqid, in nfsd4_open_downgrade()
7438 &od->od_stateid, &stp, nn); in nfsd4_open_downgrade()
7442 if (!test_access(od->od_share_access, stp)) { in nfsd4_open_downgrade()
7444 stp->st_access_bmap, od->od_share_access); in nfsd4_open_downgrade()
7447 if (!test_deny(od->od_share_deny, stp)) { in nfsd4_open_downgrade()
7449 stp->st_deny_bmap, od->od_share_deny); in nfsd4_open_downgrade()
7452 nfs4_stateid_downgrade(stp, od->od_share_access); in nfsd4_open_downgrade()
7453 reset_union_bmap_deny(od->od_share_deny, stp); in nfsd4_open_downgrade()
7454 nfs4_inc_and_copy_stateid(&od->od_stateid, &stp->st_stid); in nfsd4_open_downgrade()
7457 mutex_unlock(&stp->st_mutex); in nfsd4_open_downgrade()
7458 nfs4_put_stid(&stp->st_stid); in nfsd4_open_downgrade()
7466 struct nfs4_client *clp = s->st_stid.sc_client; in nfsd4_close_open_stateid()
7471 spin_lock(&clp->cl_lock); in nfsd4_close_open_stateid()
7474 if (clp->cl_minorversion) { in nfsd4_close_open_stateid()
7477 spin_unlock(&clp->cl_lock); in nfsd4_close_open_stateid()
7479 nfs4_free_cpntf_statelist(clp->net, &stp->st_stid); in nfsd4_close_open_stateid()
7483 spin_unlock(&clp->cl_lock); in nfsd4_close_open_stateid()
7496 struct nfsd4_close *close = &u->close; in nfsd4_close()
7504 cstate->current_fh.fh_dentry); in nfsd4_close()
7506 status = nfs4_preprocess_seqid_op(cstate, close->cl_seqid, in nfsd4_close()
7507 &close->cl_stateid, in nfsd4_close()
7514 spin_lock(&stp->st_stid.sc_client->cl_lock); in nfsd4_close()
7515 stp->st_stid.sc_status |= SC_STATUS_CLOSED; in nfsd4_close()
7516 spin_unlock(&stp->st_stid.sc_client->cl_lock); in nfsd4_close()
7524 nfs4_inc_and_copy_stateid(&close->cl_stateid, &stp->st_stid); in nfsd4_close()
7527 mutex_unlock(&stp->st_mutex); in nfsd4_close()
7538 memcpy(&close->cl_stateid, &close_stateid, sizeof(close->cl_stateid)); in nfsd4_close()
7541 nfs4_put_stid(&stp->st_stid); in nfsd4_close()
7550 struct nfsd4_delegreturn *dr = &u->delegreturn; in nfsd4_delegreturn()
7552 stateid_t *stateid = &dr->dr_stateid; in nfsd4_delegreturn()
7557 if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0))) in nfsd4_delegreturn()
7566 status = nfsd4_stid_check_stateid_generation(stateid, &dp->dl_stid, nfsd4_has_session(cstate)); in nfsd4_delegreturn()
7573 wake_up_var(d_inode(cstate->current_fh.fh_dentry)); in nfsd4_delegreturn()
7575 nfs4_put_stid(&dp->dl_stid); in nfsd4_delegreturn()
7588 return end > start ? end - 1: NFS4_MAX_UINT64; in last_byte_offset()
7592 * TODO: Linux file offsets are _signed_ 64-bit quantities, which means that
7593 * we can't properly handle lock requests that go beyond the (2^63 - 1)-th
7594 * byte, because of sign extension problems. Since NFSv4 calls for 64-bit
7595 * locking, this prevents us from being completely protocol-compliant. The
7602 if (lock->fl_start < 0) in nfs4_transform_lock_offset()
7603 lock->fl_start = OFFSET_MAX; in nfs4_transform_lock_offset()
7604 if (lock->fl_end < 0) in nfs4_transform_lock_offset()
7605 lock->fl_end = OFFSET_MAX; in nfs4_transform_lock_offset()
7613 nfs4_get_stateowner(&lo->lo_owner); in nfsd4_lm_get_owner()
7623 nfs4_put_stateowner(&lo->lo_owner); in nfsd4_lm_put_owner()
7630 struct nfs4_lockowner *lo = (struct nfs4_lockowner *) cfl->c.flc_owner; in nfsd4_lm_lock_expirable()
7631 struct nfs4_client *clp = lo->lo_owner.so_client; in nfsd4_lm_lock_expirable()
7635 nn = net_generic(clp->net, nfsd_net_id); in nfsd4_lm_lock_expirable()
7636 mod_delayed_work(laundry_wq, &nn->laundromat_work, 0); in nfsd4_lm_lock_expirable()
7652 struct nfs4_lockowner *lo = (struct nfs4_lockowner *) fl->c.flc_owner; in nfsd4_lm_notify()
7653 struct net *net = lo->lo_owner.so_client->net; in nfsd4_lm_notify()
7660 spin_lock(&nn->blocked_locks_lock); in nfsd4_lm_notify()
7661 if (!list_empty(&nbl->nbl_list)) { in nfsd4_lm_notify()
7662 list_del_init(&nbl->nbl_list); in nfsd4_lm_notify()
7663 list_del_init(&nbl->nbl_lru); in nfsd4_lm_notify()
7666 spin_unlock(&nn->blocked_locks_lock); in nfsd4_lm_notify()
7670 nfsd4_run_cb(&nbl->nbl_cb); in nfsd4_lm_notify()
7688 if (fl->fl_lmops == &nfsd_posix_mng_ops) { in nfs4_set_lock_denied()
7689 lo = (struct nfs4_lockowner *) fl->c.flc_owner; in nfs4_set_lock_denied()
7690 xdr_netobj_dup(&deny->ld_owner, &lo->lo_owner.so_owner, in nfs4_set_lock_denied()
7692 if (!deny->ld_owner.data) in nfs4_set_lock_denied()
7695 deny->ld_clientid = lo->lo_owner.so_client->cl_clientid; in nfs4_set_lock_denied()
7698 deny->ld_owner.len = 0; in nfs4_set_lock_denied()
7699 deny->ld_owner.data = NULL; in nfs4_set_lock_denied()
7700 deny->ld_clientid.cl_boot = 0; in nfs4_set_lock_denied()
7701 deny->ld_clientid.cl_id = 0; in nfs4_set_lock_denied()
7703 deny->ld_start = fl->fl_start; in nfs4_set_lock_denied()
7704 deny->ld_length = NFS4_MAX_UINT64; in nfs4_set_lock_denied()
7705 if (fl->fl_end != NFS4_MAX_UINT64) in nfs4_set_lock_denied()
7706 deny->ld_length = fl->fl_end - fl->fl_start + 1; in nfs4_set_lock_denied()
7707 deny->ld_type = NFS4_READ_LT; in nfs4_set_lock_denied()
7708 if (fl->c.flc_type != F_RDLCK) in nfs4_set_lock_denied()
7709 deny->ld_type = NFS4_WRITE_LT; in nfs4_set_lock_denied()
7718 lockdep_assert_held(&clp->cl_lock); in find_lockowner_str_locked()
7720 list_for_each_entry(so, &clp->cl_ownerstr_hashtbl[strhashval], in find_lockowner_str_locked()
7722 if (so->so_is_open_owner) in find_lockowner_str_locked()
7735 spin_lock(&clp->cl_lock); in find_lockowner_str()
7737 spin_unlock(&clp->cl_lock); in find_lockowner_str()
7760 * Called in nfsd4_lock - therefore, OPEN and OPEN_CONFIRM (if needed) has
7772 lo = alloc_stateowner(lockowner_slab, &lock->lk_new_owner, clp); in alloc_init_lock_stateowner()
7775 INIT_LIST_HEAD(&lo->lo_blocked); in alloc_init_lock_stateowner()
7776 INIT_LIST_HEAD(&lo->lo_owner.so_stateids); in alloc_init_lock_stateowner()
7777 lo->lo_owner.so_is_open_owner = 0; in alloc_init_lock_stateowner()
7778 lo->lo_owner.so_seqid = lock->lk_new_lock_seqid; in alloc_init_lock_stateowner()
7779 lo->lo_owner.so_ops = &lockowner_ops; in alloc_init_lock_stateowner()
7780 spin_lock(&clp->cl_lock); in alloc_init_lock_stateowner()
7781 ret = find_lockowner_str_locked(clp, &lock->lk_new_owner); in alloc_init_lock_stateowner()
7783 list_add(&lo->lo_owner.so_strhash, in alloc_init_lock_stateowner()
7784 &clp->cl_ownerstr_hashtbl[strhashval]); in alloc_init_lock_stateowner()
7787 nfs4_free_stateowner(&lo->lo_owner); in alloc_init_lock_stateowner()
7789 spin_unlock(&clp->cl_lock); in alloc_init_lock_stateowner()
7799 lockdep_assert_held(&ost->st_stid.sc_client->cl_lock); in find_lock_stateid()
7801 /* If ost is not hashed, ost->st_locks will not be valid */ in find_lock_stateid()
7803 list_for_each_entry(lst, &ost->st_locks, st_locks) { in find_lock_stateid()
7804 if (lst->st_stateowner == &lo->lo_owner) { in find_lock_stateid()
7805 refcount_inc(&lst->st_stid.sc_count); in find_lock_stateid()
7817 struct nfs4_client *clp = lo->lo_owner.so_client; in init_lock_stateid()
7820 mutex_init(&stp->st_mutex); in init_lock_stateid()
7821 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX); in init_lock_stateid()
7823 spin_lock(&clp->cl_lock); in init_lock_stateid()
7829 refcount_inc(&stp->st_stid.sc_count); in init_lock_stateid()
7830 stp->st_stid.sc_type = SC_TYPE_LOCK; in init_lock_stateid()
7831 stp->st_stateowner = nfs4_get_stateowner(&lo->lo_owner); in init_lock_stateid()
7833 stp->st_stid.sc_file = fp; in init_lock_stateid()
7834 stp->st_access_bmap = 0; in init_lock_stateid()
7835 stp->st_deny_bmap = open_stp->st_deny_bmap; in init_lock_stateid()
7836 stp->st_openstp = open_stp; in init_lock_stateid()
7837 spin_lock(&fp->fi_lock); in init_lock_stateid()
7838 list_add(&stp->st_locks, &open_stp->st_locks); in init_lock_stateid()
7839 list_add(&stp->st_perstateowner, &lo->lo_owner.so_stateids); in init_lock_stateid()
7840 list_add(&stp->st_perfile, &fp->fi_stateids); in init_lock_stateid()
7841 spin_unlock(&fp->fi_lock); in init_lock_stateid()
7842 spin_unlock(&clp->cl_lock); in init_lock_stateid()
7845 spin_unlock(&clp->cl_lock); in init_lock_stateid()
7847 nfs4_put_stid(&retstp->st_stid); in init_lock_stateid()
7851 mutex_unlock(&stp->st_mutex); in init_lock_stateid()
7854 spin_unlock(&clp->cl_lock); in init_lock_stateid()
7855 mutex_unlock(&stp->st_mutex); in init_lock_stateid()
7866 struct nfs4_openowner *oo = openowner(ost->st_stateowner); in find_or_create_lock_stateid()
7867 struct nfs4_client *clp = oo->oo_owner.so_client; in find_or_create_lock_stateid()
7870 spin_lock(&clp->cl_lock); in find_or_create_lock_stateid()
7872 spin_unlock(&clp->cl_lock); in find_or_create_lock_stateid()
7876 nfs4_put_stid(&lst->st_stid); in find_or_create_lock_stateid()
7900 struct nfs4_file *fp = lock_stp->st_stid.sc_file; in get_lock_access()
7902 lockdep_assert_held(&fp->fi_lock); in get_lock_access()
7917 struct nfs4_file *fi = ost->st_stid.sc_file; in lookup_or_create_lock_state()
7918 struct nfs4_openowner *oo = openowner(ost->st_stateowner); in lookup_or_create_lock_state()
7919 struct nfs4_client *cl = oo->oo_owner.so_client; in lookup_or_create_lock_state()
7920 struct inode *inode = d_inode(cstate->current_fh.fh_dentry); in lookup_or_create_lock_state()
7925 lo = find_lockowner_str(cl, &lock->lk_new_owner); in lookup_or_create_lock_state()
7927 strhashval = ownerstr_hashval(&lock->lk_new_owner); in lookup_or_create_lock_state()
7934 if (!cstate->minorversion && in lookup_or_create_lock_state()
7935 lock->lk_new_lock_seqid != lo->lo_owner.so_seqid) in lookup_or_create_lock_state()
7948 nfs4_put_stateowner(&lo->lo_owner); in lookup_or_create_lock_state()
7959 struct nfsd4_lock *lock = &u->lock; in nfsd4_lock()
7980 (long long) lock->lk_offset, in nfsd4_lock()
7981 (long long) lock->lk_length); in nfsd4_lock()
7983 if (check_lock_length(lock->lk_offset, lock->lk_length)) in nfsd4_lock()
7986 status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0); in nfsd4_lock()
7989 sb = cstate->current_fh.fh_dentry->d_sb; in nfsd4_lock()
7991 if (lock->lk_is_new) { in nfsd4_lock()
7994 memcpy(&lock->lk_new_clientid, in nfsd4_lock()
7995 &cstate->clp->cl_clientid, in nfsd4_lock()
8000 lock->lk_new_open_seqid, in nfsd4_lock()
8001 &lock->lk_new_open_stateid, in nfsd4_lock()
8005 mutex_unlock(&open_stp->st_mutex); in nfsd4_lock()
8006 open_sop = openowner(open_stp->st_stateowner); in nfsd4_lock()
8008 if (!same_clid(&open_sop->oo_owner.so_client->cl_clientid, in nfsd4_lock()
8009 &lock->lk_new_clientid)) in nfsd4_lock()
8015 lock->lk_old_lock_seqid, in nfsd4_lock()
8016 &lock->lk_old_lock_stateid, in nfsd4_lock()
8022 lock_sop = lockowner(lock_stp->st_stateowner); in nfsd4_lock()
8024 lkflg = setlkflg(lock->lk_type); in nfsd4_lock()
8030 if (locks_in_grace(net) && !lock->lk_reclaim) in nfsd4_lock()
8033 if (!locks_in_grace(net) && lock->lk_reclaim) in nfsd4_lock()
8036 if (lock->lk_reclaim) in nfsd4_lock()
8039 fp = lock_stp->st_stid.sc_file; in nfsd4_lock()
8040 switch (lock->lk_type) { in nfsd4_lock()
8044 spin_lock(&fp->fi_lock); in nfsd4_lock()
8048 spin_unlock(&fp->fi_lock); in nfsd4_lock()
8054 spin_lock(&fp->fi_lock); in nfsd4_lock()
8058 spin_unlock(&fp->fi_lock); in nfsd4_lock()
8071 if (lock->lk_type & (NFS4_READW_LT | NFS4_WRITEW_LT) && in nfsd4_lock()
8073 locks_can_async_lock(nf->nf_file->f_op)) in nfsd4_lock()
8076 nbl = find_or_allocate_block(lock_sop, &fp->fi_fhandle, nn); in nfsd4_lock()
8083 file_lock = &nbl->nbl_lock; in nfsd4_lock()
8084 file_lock->c.flc_type = type; in nfsd4_lock()
8085 file_lock->c.flc_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(&lock_sop->lo_owner)); in nfsd4_lock()
8086 file_lock->c.flc_pid = current->tgid; in nfsd4_lock()
8087 file_lock->c.flc_file = nf->nf_file; in nfsd4_lock()
8088 file_lock->c.flc_flags = flags; in nfsd4_lock()
8089 file_lock->fl_lmops = &nfsd_posix_mng_ops; in nfsd4_lock()
8090 file_lock->fl_start = lock->lk_offset; in nfsd4_lock()
8091 file_lock->fl_end = last_byte_offset(lock->lk_offset, lock->lk_length); in nfsd4_lock()
8102 nbl->nbl_time = ktime_get_boottime_seconds(); in nfsd4_lock()
8103 spin_lock(&nn->blocked_locks_lock); in nfsd4_lock()
8104 list_add_tail(&nbl->nbl_list, &lock_sop->lo_blocked); in nfsd4_lock()
8105 list_add_tail(&nbl->nbl_lru, &nn->blocked_locks_lru); in nfsd4_lock()
8106 kref_get(&nbl->nbl_kref); in nfsd4_lock()
8107 spin_unlock(&nn->blocked_locks_lock); in nfsd4_lock()
8110 err = vfs_lock_file(nf->nf_file, F_SETLK, file_lock, conflock); in nfsd4_lock()
8113 nfs4_inc_and_copy_stateid(&lock->lk_resp_stateid, &lock_stp->st_stid); in nfsd4_lock()
8115 if (lock->lk_reclaim) in nfsd4_lock()
8116 nn->somebody_reclaimed = true; in nfsd4_lock()
8119 kref_put(&nbl->nbl_kref, free_nbl); in nfsd4_lock()
8122 case -EAGAIN: /* conflock holds conflicting lock */ in nfsd4_lock()
8125 nfs4_set_lock_denied(conflock, &lock->lk_denied); in nfsd4_lock()
8127 case -EDEADLK: in nfsd4_lock()
8139 spin_lock(&nn->blocked_locks_lock); in nfsd4_lock()
8140 if (!list_empty(&nbl->nbl_list) && in nfsd4_lock()
8141 !list_empty(&nbl->nbl_lru)) { in nfsd4_lock()
8142 list_del_init(&nbl->nbl_list); in nfsd4_lock()
8143 list_del_init(&nbl->nbl_lru); in nfsd4_lock()
8144 kref_put(&nbl->nbl_kref, free_nbl); in nfsd4_lock()
8147 spin_unlock(&nn->blocked_locks_lock); in nfsd4_lock()
8155 if (cstate->replay_owner && in nfsd4_lock()
8156 cstate->replay_owner != &lock_sop->lo_owner && in nfsd4_lock()
8158 lock_sop->lo_owner.so_seqid++; in nfsd4_lock()
8161 * If this is a new, never-before-used stateid, and we are in nfsd4_lock()
8167 mutex_unlock(&lock_stp->st_mutex); in nfsd4_lock()
8169 nfs4_put_stid(&lock_stp->st_stid); in nfsd4_lock()
8172 nfs4_put_stid(&open_stp->st_stid); in nfsd4_lock()
8181 struct nfsd4_lock *lock = &u->lock; in nfsd4_lock_release()
8182 struct nfsd4_lock_denied *deny = &lock->lk_denied; in nfsd4_lock_release()
8184 kfree(deny->ld_owner.data); in nfsd4_lock_release()
8201 inode = fhp->fh_dentry->d_inode; in nfsd_test_lock()
8206 lock->c.flc_file = nf->nf_file; in nfsd_test_lock()
8207 err = nfserrno(vfs_test_lock(nf->nf_file, lock)); in nfsd_test_lock()
8208 lock->c.flc_file = NULL; in nfsd_test_lock()
8222 struct nfsd4_lockt *lockt = &u->lockt; in nfsd4_lockt()
8231 if (check_lock_length(lockt->lt_offset, lockt->lt_length)) in nfsd4_lockt()
8235 status = set_client(&lockt->lt_clientid, cstate, nn); in nfsd4_lockt()
8240 if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0))) in nfsd4_lockt()
8250 switch (lockt->lt_type) { in nfsd4_lockt()
8253 file_lock->c.flc_type = F_RDLCK; in nfsd4_lockt()
8257 file_lock->c.flc_type = F_WRLCK; in nfsd4_lockt()
8265 lo = find_lockowner_str(cstate->clp, &lockt->lt_owner); in nfsd4_lockt()
8267 file_lock->c.flc_owner = (fl_owner_t)lo; in nfsd4_lockt()
8268 file_lock->c.flc_pid = current->tgid; in nfsd4_lockt()
8269 file_lock->c.flc_flags = FL_POSIX; in nfsd4_lockt()
8271 file_lock->fl_start = lockt->lt_offset; in nfsd4_lockt()
8272 file_lock->fl_end = last_byte_offset(lockt->lt_offset, lockt->lt_length); in nfsd4_lockt()
8276 status = nfsd_test_lock(rqstp, &cstate->current_fh, file_lock); in nfsd4_lockt()
8280 if (file_lock->c.flc_type != F_UNLCK) { in nfsd4_lockt()
8282 nfs4_set_lock_denied(file_lock, &lockt->lt_denied); in nfsd4_lockt()
8286 nfs4_put_stateowner(&lo->lo_owner); in nfsd4_lockt()
8294 struct nfsd4_lockt *lockt = &u->lockt; in nfsd4_lockt_release()
8295 struct nfsd4_lock_denied *deny = &lockt->lt_denied; in nfsd4_lockt_release()
8297 kfree(deny->ld_owner.data); in nfsd4_lockt_release()
8304 struct nfsd4_locku *locku = &u->locku; in nfsd4_locku()
8313 (long long) locku->lu_offset, in nfsd4_locku()
8314 (long long) locku->lu_length); in nfsd4_locku()
8316 if (check_lock_length(locku->lu_offset, locku->lu_length)) in nfsd4_locku()
8319 status = nfs4_preprocess_seqid_op(cstate, locku->lu_seqid, in nfsd4_locku()
8320 &locku->lu_stateid, SC_TYPE_LOCK, 0, in nfsd4_locku()
8324 nf = find_any_file(stp->st_stid.sc_file); in nfsd4_locku()
8336 file_lock->c.flc_type = F_UNLCK; in nfsd4_locku()
8337 file_lock->c.flc_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(stp->st_stateowner)); in nfsd4_locku()
8338 file_lock->c.flc_pid = current->tgid; in nfsd4_locku()
8339 file_lock->c.flc_file = nf->nf_file; in nfsd4_locku()
8340 file_lock->c.flc_flags = FL_POSIX; in nfsd4_locku()
8341 file_lock->fl_lmops = &nfsd_posix_mng_ops; in nfsd4_locku()
8342 file_lock->fl_start = locku->lu_offset; in nfsd4_locku()
8344 file_lock->fl_end = last_byte_offset(locku->lu_offset, in nfsd4_locku()
8345 locku->lu_length); in nfsd4_locku()
8348 err = vfs_lock_file(nf->nf_file, F_SETLK, file_lock, NULL); in nfsd4_locku()
8353 nfs4_inc_and_copy_stateid(&locku->lu_stateid, &stp->st_stid); in nfsd4_locku()
8357 mutex_unlock(&stp->st_mutex); in nfsd4_locku()
8358 nfs4_put_stid(&stp->st_stid); in nfsd4_locku()
8384 spin_lock(&fp->fi_lock); in check_for_locks()
8392 inode = file_inode(nf->nf_file); in check_for_locks()
8395 if (flctx && !list_empty_careful(&flctx->flc_posix)) { in check_for_locks()
8396 spin_lock(&flctx->flc_lock); in check_for_locks()
8397 for_each_file_lock(fl, &flctx->flc_posix) { in check_for_locks()
8398 if (fl->c.flc_owner == (fl_owner_t)lowner) { in check_for_locks()
8403 spin_unlock(&flctx->flc_lock); in check_for_locks()
8406 spin_unlock(&fp->fi_lock); in check_for_locks()
8411 * nfsd4_release_lockowner - process NFSv4.0 RELEASE_LOCKOWNER operations
8430 struct nfsd4_release_lockowner *rlockowner = &u->release_lockowner; in nfsd4_release_lockowner()
8432 clientid_t *clid = &rlockowner->rl_clientid; in nfsd4_release_lockowner()
8440 clid->cl_boot, clid->cl_id); in nfsd4_release_lockowner()
8445 clp = cstate->clp; in nfsd4_release_lockowner()
8447 spin_lock(&clp->cl_lock); in nfsd4_release_lockowner()
8448 lo = find_lockowner_str_locked(clp, &rlockowner->rl_owner); in nfsd4_release_lockowner()
8450 spin_unlock(&clp->cl_lock); in nfsd4_release_lockowner()
8454 list_for_each_entry(stp, &lo->lo_owner.so_stateids, st_perstateowner) { in nfsd4_release_lockowner()
8455 if (check_for_locks(stp->st_stid.sc_file, lo)) { in nfsd4_release_lockowner()
8456 spin_unlock(&clp->cl_lock); in nfsd4_release_lockowner()
8457 nfs4_put_stateowner(&lo->lo_owner); in nfsd4_release_lockowner()
8462 while (!list_empty(&lo->lo_owner.so_stateids)) { in nfsd4_release_lockowner()
8463 stp = list_first_entry(&lo->lo_owner.so_stateids, in nfsd4_release_lockowner()
8469 spin_unlock(&clp->cl_lock); in nfsd4_release_lockowner()
8473 nfs4_put_stateowner(&lo->lo_owner); in nfsd4_release_lockowner()
8489 return (crp && crp->cr_clp); in nfs4_has_reclaimed_state()
8508 INIT_LIST_HEAD(&crp->cr_strhash); in nfs4_client_to_reclaim()
8509 list_add(&crp->cr_strhash, &nn->reclaim_str_hashtbl[strhashval]); in nfs4_client_to_reclaim()
8510 crp->cr_name.data = name.data; in nfs4_client_to_reclaim()
8511 crp->cr_name.len = name.len; in nfs4_client_to_reclaim()
8512 crp->cr_princhash.data = princhash.data; in nfs4_client_to_reclaim()
8513 crp->cr_princhash.len = princhash.len; in nfs4_client_to_reclaim()
8514 crp->cr_clp = NULL; in nfs4_client_to_reclaim()
8515 nn->reclaim_str_hashtbl_size++; in nfs4_client_to_reclaim()
8523 list_del(&crp->cr_strhash); in nfs4_remove_reclaim_record()
8524 kfree(crp->cr_name.data); in nfs4_remove_reclaim_record()
8525 kfree(crp->cr_princhash.data); in nfs4_remove_reclaim_record()
8527 nn->reclaim_str_hashtbl_size--; in nfs4_remove_reclaim_record()
8537 while (!list_empty(&nn->reclaim_str_hashtbl[i])) { in nfs4_release_reclaim()
8538 crp = list_entry(nn->reclaim_str_hashtbl[i].next, in nfs4_release_reclaim()
8543 WARN_ON_ONCE(nn->reclaim_str_hashtbl_size); in nfs4_release_reclaim()
8555 list_for_each_entry(crp, &nn->reclaim_str_hashtbl[strhashval], cr_strhash) { in nfsd4_find_reclaim_client()
8556 if (compare_blob(&crp->cr_name, &name) == 0) { in nfsd4_find_reclaim_client()
8566 if (test_bit(NFSD4_CLIENT_RECLAIM_COMPLETE, &clp->cl_flags)) in nfs4_check_open_reclaim()
8593 max_delegations = nr_free_buffer_pages() >> (20 - 2 - PAGE_SHIFT); in set_max_delegations()
8601 nn->conf_id_hashtbl = kmalloc_array(CLIENT_HASH_SIZE, in nfs4_state_create_net()
8604 if (!nn->conf_id_hashtbl) in nfs4_state_create_net()
8606 nn->unconf_id_hashtbl = kmalloc_array(CLIENT_HASH_SIZE, in nfs4_state_create_net()
8609 if (!nn->unconf_id_hashtbl) in nfs4_state_create_net()
8611 nn->sessionid_hashtbl = kmalloc_array(SESSION_HASH_SIZE, in nfs4_state_create_net()
8614 if (!nn->sessionid_hashtbl) in nfs4_state_create_net()
8618 INIT_LIST_HEAD(&nn->conf_id_hashtbl[i]); in nfs4_state_create_net()
8619 INIT_LIST_HEAD(&nn->unconf_id_hashtbl[i]); in nfs4_state_create_net()
8622 INIT_LIST_HEAD(&nn->sessionid_hashtbl[i]); in nfs4_state_create_net()
8623 nn->conf_name_tree = RB_ROOT; in nfs4_state_create_net()
8624 nn->unconf_name_tree = RB_ROOT; in nfs4_state_create_net()
8625 nn->boot_time = ktime_get_real_seconds(); in nfs4_state_create_net()
8626 nn->grace_ended = false; in nfs4_state_create_net()
8627 nn->nfsd4_manager.block_opens = true; in nfs4_state_create_net()
8628 INIT_LIST_HEAD(&nn->nfsd4_manager.list); in nfs4_state_create_net()
8629 INIT_LIST_HEAD(&nn->client_lru); in nfs4_state_create_net()
8630 INIT_LIST_HEAD(&nn->close_lru); in nfs4_state_create_net()
8631 INIT_LIST_HEAD(&nn->del_recall_lru); in nfs4_state_create_net()
8632 spin_lock_init(&nn->client_lock); in nfs4_state_create_net()
8633 spin_lock_init(&nn->s2s_cp_lock); in nfs4_state_create_net()
8634 idr_init(&nn->s2s_cp_stateids); in nfs4_state_create_net()
8635 atomic_set(&nn->pending_async_copies, 0); in nfs4_state_create_net()
8637 spin_lock_init(&nn->blocked_locks_lock); in nfs4_state_create_net()
8638 INIT_LIST_HEAD(&nn->blocked_locks_lru); in nfs4_state_create_net()
8640 INIT_DELAYED_WORK(&nn->laundromat_work, laundromat_main); in nfs4_state_create_net()
8641 INIT_WORK(&nn->nfsd_shrinker_work, nfsd4_state_shrinker_worker); in nfs4_state_create_net()
8644 nn->nfsd_client_shrinker = shrinker_alloc(0, "nfsd-client"); in nfs4_state_create_net()
8645 if (!nn->nfsd_client_shrinker) in nfs4_state_create_net()
8648 nn->nfsd_client_shrinker->scan_objects = nfsd4_state_shrinker_scan; in nfs4_state_create_net()
8649 nn->nfsd_client_shrinker->count_objects = nfsd4_state_shrinker_count; in nfs4_state_create_net()
8650 nn->nfsd_client_shrinker->private_data = nn; in nfs4_state_create_net()
8652 shrinker_register(nn->nfsd_client_shrinker); in nfs4_state_create_net()
8658 kfree(nn->sessionid_hashtbl); in nfs4_state_create_net()
8660 kfree(nn->unconf_id_hashtbl); in nfs4_state_create_net()
8662 kfree(nn->conf_id_hashtbl); in nfs4_state_create_net()
8664 return -ENOMEM; in nfs4_state_create_net()
8675 while (!list_empty(&nn->conf_id_hashtbl[i])) { in nfs4_state_destroy_net()
8676 clp = list_entry(nn->conf_id_hashtbl[i].next, struct nfs4_client, cl_idhash); in nfs4_state_destroy_net()
8681 WARN_ON(!list_empty(&nn->blocked_locks_lru)); in nfs4_state_destroy_net()
8684 while (!list_empty(&nn->unconf_id_hashtbl[i])) { in nfs4_state_destroy_net()
8685 clp = list_entry(nn->unconf_id_hashtbl[i].next, struct nfs4_client, cl_idhash); in nfs4_state_destroy_net()
8690 kfree(nn->sessionid_hashtbl); in nfs4_state_destroy_net()
8691 kfree(nn->unconf_id_hashtbl); in nfs4_state_destroy_net()
8692 kfree(nn->conf_id_hashtbl); in nfs4_state_destroy_net()
8705 locks_start_grace(net, &nn->nfsd4_manager); in nfs4_state_start_net()
8707 if (nn->track_reclaim_completes && nn->reclaim_str_hashtbl_size == 0) in nfs4_state_start_net()
8709 printk(KERN_INFO "NFSD: starting %lld-second grace period (net %x)\n", in nfs4_state_start_net()
8710 nn->nfsd4_grace, net->ns.inum); in nfs4_state_start_net()
8712 queue_delayed_work(laundry_wq, &nn->laundromat_work, nn->nfsd4_grace * HZ); in nfs4_state_start_net()
8717 net->ns.inum); in nfs4_state_start_net()
8718 queue_delayed_work(laundry_wq, &nn->laundromat_work, nn->nfsd4_lease * HZ); in nfs4_state_start_net()
8745 shrinker_free(nn->nfsd_client_shrinker); in nfs4_state_shutdown_net()
8746 cancel_work_sync(&nn->nfsd_shrinker_work); in nfs4_state_shutdown_net()
8747 cancel_delayed_work_sync(&nn->laundromat_work); in nfs4_state_shutdown_net()
8748 locks_end_grace(&nn->nfsd4_manager); in nfs4_state_shutdown_net()
8752 list_for_each_safe(pos, next, &nn->del_recall_lru) { in nfs4_state_shutdown_net()
8755 list_add(&dp->dl_recall_lru, &reaplist); in nfs4_state_shutdown_net()
8760 list_del_init(&dp->dl_recall_lru); in nfs4_state_shutdown_net()
8782 memcpy(stateid, &cstate->current_stateid, sizeof(stateid_t)); in get_stateid()
8788 if (cstate->minorversion) { in put_stateid()
8789 memcpy(&cstate->current_stateid, stateid, sizeof(stateid_t)); in put_stateid()
8807 put_stateid(cstate, &u->open_downgrade.od_stateid); in nfsd4_set_opendowngradestateid()
8814 put_stateid(cstate, &u->open.op_stateid); in nfsd4_set_openstateid()
8821 put_stateid(cstate, &u->close.cl_stateid); in nfsd4_set_closestateid()
8828 put_stateid(cstate, &u->lock.lk_resp_stateid); in nfsd4_set_lockstateid()
8839 get_stateid(cstate, &u->open_downgrade.od_stateid); in nfsd4_get_opendowngradestateid()
8846 get_stateid(cstate, &u->delegreturn.dr_stateid); in nfsd4_get_delegreturnstateid()
8853 get_stateid(cstate, &u->free_stateid.fr_stateid); in nfsd4_get_freestateid()
8860 get_stateid(cstate, &u->setattr.sa_stateid); in nfsd4_get_setattrstateid()
8867 get_stateid(cstate, &u->close.cl_stateid); in nfsd4_get_closestateid()
8874 get_stateid(cstate, &u->locku.lu_stateid); in nfsd4_get_lockustateid()
8881 get_stateid(cstate, &u->read.rd_stateid); in nfsd4_get_readstateid()
8888 get_stateid(cstate, &u->write.wr_stateid); in nfsd4_get_writestateid()
8892 * nfsd4_deleg_getattr_conflict - Recall if GETATTR causes conflict
8905 * code is returned. If @pdp is set to a non-NULL value, then the
8927 spin_lock(&ctx->flc_lock); in nfsd4_deleg_getattr_conflict()
8928 for_each_file_lock(fl, &ctx->flc_lease) { in nfsd4_deleg_getattr_conflict()
8929 if (fl->c.flc_flags == FL_LAYOUT) in nfsd4_deleg_getattr_conflict()
8931 if (fl->c.flc_type == F_WRLCK) { in nfsd4_deleg_getattr_conflict()
8932 if (fl->fl_lmops == &nfsd_lease_mng_ops) in nfsd4_deleg_getattr_conflict()
8933 dp = fl->c.flc_owner; in nfsd4_deleg_getattr_conflict()
8940 dp->dl_recall.cb_clp == *(rqstp->rq_lease_breaker)) { in nfsd4_deleg_getattr_conflict()
8941 spin_unlock(&ctx->flc_lock); in nfsd4_deleg_getattr_conflict()
8953 refcount_inc(&dp->dl_stid.sc_count); in nfsd4_deleg_getattr_conflict()
8954 ncf = &dp->dl_cb_fattr; in nfsd4_deleg_getattr_conflict()
8955 nfs4_cb_getattr(&dp->dl_cb_fattr); in nfsd4_deleg_getattr_conflict()
8956 spin_unlock(&ctx->flc_lock); in nfsd4_deleg_getattr_conflict()
8958 wait_on_bit_timeout(&ncf->ncf_cb_flags, CB_GETATTR_BUSY, in nfsd4_deleg_getattr_conflict()
8960 if (ncf->ncf_cb_status) { in nfsd4_deleg_getattr_conflict()
8967 if (!ncf->ncf_file_modified && in nfsd4_deleg_getattr_conflict()
8968 (ncf->ncf_initial_cinfo != ncf->ncf_cb_change || in nfsd4_deleg_getattr_conflict()
8969 ncf->ncf_cur_fsize != ncf->ncf_cb_fsize)) in nfsd4_deleg_getattr_conflict()
8970 ncf->ncf_file_modified = true; in nfsd4_deleg_getattr_conflict()
8971 if (ncf->ncf_file_modified) { in nfsd4_deleg_getattr_conflict()
8988 ncf->ncf_cur_fsize = ncf->ncf_cb_fsize; in nfsd4_deleg_getattr_conflict()
8994 nfs4_put_stid(&dp->dl_stid); in nfsd4_deleg_getattr_conflict()