Lines Matching refs:stp

442 set_access(u32 access, struct nfs4_ol_stateid *stp)  in set_access()  argument
447 stp->st_access_bmap |= mask; in set_access()
452 clear_access(u32 access, struct nfs4_ol_stateid *stp) in clear_access() argument
457 stp->st_access_bmap &= ~mask; in clear_access()
462 test_access(u32 access, struct nfs4_ol_stateid *stp) in test_access() argument
466 return (bool)(stp->st_access_bmap & mask); in test_access()
471 set_deny(u32 deny, struct nfs4_ol_stateid *stp) in set_deny() argument
476 stp->st_deny_bmap |= mask; in set_deny()
481 clear_deny(u32 deny, struct nfs4_ol_stateid *stp) in clear_deny() argument
486 stp->st_deny_bmap &= ~mask; in clear_deny()
491 test_deny(u32 deny, struct nfs4_ol_stateid *stp) in test_deny() argument
495 return (bool)(stp->st_deny_bmap & mask); in test_deny()
513 access_permit_read(struct nfs4_ol_stateid *stp) in access_permit_read() argument
515 return test_access(NFS4_SHARE_ACCESS_READ, stp) || in access_permit_read()
516 test_access(NFS4_SHARE_ACCESS_BOTH, stp) || in access_permit_read()
517 test_access(NFS4_SHARE_ACCESS_WRITE, stp); in access_permit_read()
521 access_permit_write(struct nfs4_ol_stateid *stp) in access_permit_write() argument
523 return test_access(NFS4_SHARE_ACCESS_WRITE, stp) || in access_permit_write()
524 test_access(NFS4_SHARE_ACCESS_BOTH, stp); in access_permit_write()
736 struct nfs4_ol_stateid *stp, u32 access, bool share_access) in nfs4_resolve_deny_conflicts_locked() argument
749 if (st == stp && new_stp) in nfs4_resolve_deny_conflicts_locked()
762 clp = stp->st_stid.sc_client; in nfs4_resolve_deny_conflicts_locked()
1387 struct nfs4_ol_stateid *stp; in recalculate_deny_mode() local
1391 list_for_each_entry(stp, &fp->fi_stateids, st_perfile) in recalculate_deny_mode()
1392 fp->fi_share_deny |= bmap_to_share_mode(stp->st_deny_bmap); in recalculate_deny_mode()
1397 reset_union_bmap_deny(u32 deny, struct nfs4_ol_stateid *stp) in reset_union_bmap_deny() argument
1405 clear_deny(i, stp); in reset_union_bmap_deny()
1411 recalculate_deny_mode(stp->st_stid.sc_file); in reset_union_bmap_deny()
1416 release_all_access(struct nfs4_ol_stateid *stp) in release_all_access() argument
1419 struct nfs4_file *fp = stp->st_stid.sc_file; in release_all_access()
1421 if (fp && stp->st_deny_bmap != 0) in release_all_access()
1425 if (test_access(i, stp)) in release_all_access()
1426 nfs4_file_put_access(stp->st_stid.sc_file, i); in release_all_access()
1427 clear_access(i, stp); in release_all_access()
1451 nfs4_ol_stateid_unhashed(const struct nfs4_ol_stateid *stp) in nfs4_ol_stateid_unhashed() argument
1453 return list_empty(&stp->st_perfile); in nfs4_ol_stateid_unhashed()
1456 static bool unhash_ol_stateid(struct nfs4_ol_stateid *stp) in unhash_ol_stateid() argument
1458 struct nfs4_file *fp = stp->st_stid.sc_file; in unhash_ol_stateid()
1460 lockdep_assert_held(&stp->st_stateowner->so_client->cl_lock); in unhash_ol_stateid()
1462 if (list_empty(&stp->st_perfile)) in unhash_ol_stateid()
1466 list_del_init(&stp->st_perfile); in unhash_ol_stateid()
1468 list_del(&stp->st_perstateowner); in unhash_ol_stateid()
1474 struct nfs4_ol_stateid *stp = openlockstateid(stid); in nfs4_free_ol_stateid() local
1476 put_clnt_odstate(stp->st_clnt_odstate); in nfs4_free_ol_stateid()
1477 release_all_access(stp); in nfs4_free_ol_stateid()
1478 if (stp->st_stateowner) in nfs4_free_ol_stateid()
1479 nfs4_put_stateowner(stp->st_stateowner); in nfs4_free_ol_stateid()
1486 struct nfs4_ol_stateid *stp = openlockstateid(stid); in nfs4_free_lock_stateid() local
1487 struct nfs4_lockowner *lo = lockowner(stp->st_stateowner); in nfs4_free_lock_stateid()
1490 nf = find_any_file(stp->st_stid.sc_file); in nfs4_free_lock_stateid()
1504 static void put_ol_stateid_locked(struct nfs4_ol_stateid *stp, in put_ol_stateid_locked() argument
1507 struct nfs4_stid *s = &stp->st_stid; in put_ol_stateid_locked()
1512 WARN_ON_ONCE(!list_empty(&stp->st_locks)); in put_ol_stateid_locked()
1520 list_add(&stp->st_locks, reaplist); in put_ol_stateid_locked()
1523 static bool unhash_lock_stateid(struct nfs4_ol_stateid *stp) in unhash_lock_stateid() argument
1525 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock); in unhash_lock_stateid()
1527 if (!unhash_ol_stateid(stp)) in unhash_lock_stateid()
1529 list_del_init(&stp->st_locks); in unhash_lock_stateid()
1530 nfs4_unhash_stid(&stp->st_stid); in unhash_lock_stateid()
1534 static void release_lock_stateid(struct nfs4_ol_stateid *stp) in release_lock_stateid() argument
1536 struct nfs4_client *clp = stp->st_stid.sc_client; in release_lock_stateid()
1540 unhashed = unhash_lock_stateid(stp); in release_lock_stateid()
1543 nfs4_put_stid(&stp->st_stid); in release_lock_stateid()
1562 struct nfs4_ol_stateid *stp; in free_ol_stateid_reaplist() local
1568 stp = list_first_entry(reaplist, struct nfs4_ol_stateid, in free_ol_stateid_reaplist()
1570 list_del(&stp->st_locks); in free_ol_stateid_reaplist()
1571 fp = stp->st_stid.sc_file; in free_ol_stateid_reaplist()
1572 stp->st_stid.sc_free(&stp->st_stid); in free_ol_stateid_reaplist()
1581 struct nfs4_ol_stateid *stp; in release_open_stateid_locks() local
1586 stp = list_entry(open_stp->st_locks.next, in release_open_stateid_locks()
1588 WARN_ON(!unhash_lock_stateid(stp)); in release_open_stateid_locks()
1589 put_ol_stateid_locked(stp, reaplist); in release_open_stateid_locks()
1593 static bool unhash_open_stateid(struct nfs4_ol_stateid *stp, in unhash_open_stateid() argument
1596 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock); in unhash_open_stateid()
1598 if (!unhash_ol_stateid(stp)) in unhash_open_stateid()
1600 release_open_stateid_locks(stp, reaplist); in unhash_open_stateid()
1604 static void release_open_stateid(struct nfs4_ol_stateid *stp) in release_open_stateid() argument
1608 spin_lock(&stp->st_stid.sc_client->cl_lock); in release_open_stateid()
1609 if (unhash_open_stateid(stp, &reaplist)) in release_open_stateid()
1610 put_ol_stateid_locked(stp, &reaplist); in release_open_stateid()
1611 spin_unlock(&stp->st_stid.sc_client->cl_lock); in release_open_stateid()
1644 struct nfs4_ol_stateid *stp; in release_openowner() local
1653 stp = list_first_entry(&oo->oo_owner.so_stateids, in release_openowner()
1655 if (unhash_open_stateid(stp, &reaplist)) in release_openowner()
1656 put_ol_stateid_locked(stp, &reaplist); in release_openowner()
4551 nfsd4_lock_ol_stateid(struct nfs4_ol_stateid *stp) in nfsd4_lock_ol_stateid() argument
4555 mutex_lock_nested(&stp->st_mutex, LOCK_STATEID_MUTEX); in nfsd4_lock_ol_stateid()
4556 ret = nfsd4_verify_open_stid(&stp->st_stid); in nfsd4_lock_ol_stateid()
4558 mutex_unlock(&stp->st_mutex); in nfsd4_lock_ol_stateid()
4565 struct nfs4_ol_stateid *stp; in nfsd4_find_and_lock_existing_open() local
4568 stp = nfsd4_find_existing_open(fp, open); in nfsd4_find_and_lock_existing_open()
4570 if (!stp || nfsd4_lock_ol_stateid(stp) == nfs_ok) in nfsd4_find_and_lock_existing_open()
4572 nfs4_put_stid(&stp->st_stid); in nfsd4_find_and_lock_existing_open()
4574 return stp; in nfsd4_find_and_lock_existing_open()
4614 struct nfs4_ol_stateid *stp; in init_open_stateid() local
4616 stp = open->op_stp; in init_open_stateid()
4618 mutex_init(&stp->st_mutex); in init_open_stateid()
4619 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX); in init_open_stateid()
4630 refcount_inc(&stp->st_stid.sc_count); in init_open_stateid()
4631 stp->st_stid.sc_type = NFS4_OPEN_STID; in init_open_stateid()
4632 INIT_LIST_HEAD(&stp->st_locks); in init_open_stateid()
4633 stp->st_stateowner = nfs4_get_stateowner(&oo->oo_owner); in init_open_stateid()
4635 stp->st_stid.sc_file = fp; in init_open_stateid()
4636 stp->st_access_bmap = 0; in init_open_stateid()
4637 stp->st_deny_bmap = 0; in init_open_stateid()
4638 stp->st_openstp = NULL; in init_open_stateid()
4639 list_add(&stp->st_perstateowner, &oo->oo_owner.so_stateids); in init_open_stateid()
4640 list_add(&stp->st_perfile, &fp->fi_stateids); in init_open_stateid()
4652 mutex_unlock(&stp->st_mutex); in init_open_stateid()
4653 stp = retstp; in init_open_stateid()
4655 return stp; in init_open_stateid()
5185 struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, in nfs4_get_vfs_file() argument
5207 stp, open->op_share_deny, false)) in nfs4_get_vfs_file()
5221 stp, open->op_share_access, true)) in nfs4_get_vfs_file()
5228 old_access_bmap = stp->st_access_bmap; in nfs4_get_vfs_file()
5229 set_access(open->op_share_access, stp); in nfs4_get_vfs_file()
5232 old_deny_bmap = stp->st_deny_bmap; in nfs4_get_vfs_file()
5233 set_deny(open->op_share_deny, stp); in nfs4_get_vfs_file()
5265 stp->st_access_bmap = old_access_bmap; in nfs4_get_vfs_file()
5267 reset_union_bmap_deny(bmap_to_share_mode(old_deny_bmap), stp); in nfs4_get_vfs_file()
5273 struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, in nfs4_upgrade_open() argument
5277 unsigned char old_deny_bmap = stp->st_deny_bmap; in nfs4_upgrade_open()
5279 if (!test_access(open->op_share_access, stp)) in nfs4_upgrade_open()
5280 return nfs4_get_vfs_file(rqstp, fp, cur_fh, stp, open, false); in nfs4_upgrade_open()
5287 set_deny(open->op_share_deny, stp); in nfs4_upgrade_open()
5293 stp, open->op_share_deny, false)) in nfs4_upgrade_open()
5304 reset_union_bmap_deny(old_deny_bmap, stp); in nfs4_upgrade_open()
5444 nfs4_set_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp, in nfs4_set_delegation() argument
5448 struct nfs4_client *clp = stp->st_stid.sc_client; in nfs4_set_delegation()
5449 struct nfs4_file *fp = stp->st_stid.sc_file; in nfs4_set_delegation()
5450 struct nfs4_clnt_odstate *odstate = stp->st_clnt_odstate; in nfs4_set_delegation()
5577 nfs4_open_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp, in nfs4_open_delegation() argument
5581 struct nfs4_openowner *oo = openowner(stp->st_stateowner); in nfs4_open_delegation()
5582 struct nfs4_client *clp = stp->st_stid.sc_client; in nfs4_open_delegation()
5613 dp = nfs4_set_delegation(open, stp, parent); in nfs4_open_delegation()
5673 struct nfs4_ol_stateid *stp = NULL; in nfsd4_process_open2() local
5690 stp = nfsd4_find_and_lock_existing_open(fp, open); in nfsd4_process_open2()
5698 if (!stp) { in nfsd4_process_open2()
5699 stp = init_open_stateid(fp, open); in nfsd4_process_open2()
5712 status = nfs4_upgrade_open(rqstp, fp, current_fh, stp, open); in nfsd4_process_open2()
5714 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
5718 status = nfs4_get_vfs_file(rqstp, fp, current_fh, stp, open, true); in nfsd4_process_open2()
5720 stp->st_stid.sc_type = NFS4_CLOSED_STID; in nfsd4_process_open2()
5721 release_open_stateid(stp); in nfsd4_process_open2()
5722 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
5726 stp->st_clnt_odstate = find_or_hash_clnt_odstate(fp, in nfsd4_process_open2()
5728 if (stp->st_clnt_odstate == open->op_odstate) in nfsd4_process_open2()
5732 nfs4_inc_and_copy_stateid(&open->op_stateid, &stp->st_stid); in nfsd4_process_open2()
5733 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
5747 nfs4_open_delegation(open, stp, &resp->cstate.current_fh); in nfsd4_process_open2()
5750 trace_nfsd_open(&stp->st_stid.sc_stateid); in nfsd4_process_open2()
5772 if (stp) in nfsd4_process_open2()
5773 nfs4_put_stid(&stp->st_stid); in nfsd4_process_open2()
5957 struct nfs4_ol_stateid *stp; in nfs4_lockowner_has_blockers() local
5960 list_for_each_entry(stp, &lo->lo_owner.so_stateids, st_perstateowner) { in nfs4_lockowner_has_blockers()
5961 nf = stp->st_stid.sc_file; in nfs4_lockowner_has_blockers()
6079 struct nfs4_ol_stateid *stp; in nfs4_laundromat() local
6130 stp = oo->oo_last_closed_stid; in nfs4_laundromat()
6133 nfs4_put_stid(&stp->st_stid); in nfs4_laundromat()
6247 static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stid *stp) in nfs4_check_fh() argument
6249 if (!fh_match(&fhp->fh_handle, &stp->sc_file->fi_fhandle)) in nfs4_check_fh()
6255 __be32 nfs4_check_openmode(struct nfs4_ol_stateid *stp, int flags) in nfs4_check_openmode() argument
6260 if (stp->st_openstp) in nfs4_check_openmode()
6261 stp = stp->st_openstp; in nfs4_check_openmode()
6262 if ((flags & WR_STATE) && !access_permit_write(stp)) in nfs4_check_openmode()
6264 if ((flags & RD_STATE) && !access_permit_read(stp)) in nfs4_check_openmode()
6664 struct nfs4_ol_stateid *stp = openlockstateid(s); in nfsd4_free_lock_stateid() local
6667 ret = nfsd4_lock_ol_stateid(stp); in nfsd4_free_lock_stateid()
6676 if (check_for_locks(stp->st_stid.sc_file, in nfsd4_free_lock_stateid()
6677 lockowner(stp->st_stateowner))) in nfsd4_free_lock_stateid()
6680 release_lock_stateid(stp); in nfsd4_free_lock_stateid()
6684 mutex_unlock(&stp->st_mutex); in nfsd4_free_lock_stateid()
6746 …ks(struct nfsd4_compound_state *cstate, stateid_t *stateid, u32 seqid, struct nfs4_ol_stateid *stp) in nfs4_seqid_op_checks() argument
6749 struct nfs4_stateowner *sop = stp->st_stateowner; in nfs4_seqid_op_checks()
6755 status = nfsd4_lock_ol_stateid(stp); in nfs4_seqid_op_checks()
6758 status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate)); in nfs4_seqid_op_checks()
6760 status = nfs4_check_fh(current_fh, &stp->st_stid); in nfs4_seqid_op_checks()
6762 mutex_unlock(&stp->st_mutex); in nfs4_seqid_op_checks()
6787 struct nfs4_ol_stateid *stp = NULL; in nfs4_preprocess_seqid_op() local
6795 stp = openlockstateid(s); in nfs4_preprocess_seqid_op()
6796 nfsd4_cstate_assign_replay(cstate, stp->st_stateowner); in nfs4_preprocess_seqid_op()
6798 status = nfs4_seqid_op_checks(cstate, stateid, seqid, stp); in nfs4_preprocess_seqid_op()
6800 *stpp = stp; in nfs4_preprocess_seqid_op()
6802 nfs4_put_stid(&stp->st_stid); in nfs4_preprocess_seqid_op()
6811 struct nfs4_ol_stateid *stp; in nfs4_preprocess_confirmed_seqid_op() local
6814 NFS4_OPEN_STID, &stp, nn); in nfs4_preprocess_confirmed_seqid_op()
6817 oo = openowner(stp->st_stateowner); in nfs4_preprocess_confirmed_seqid_op()
6819 mutex_unlock(&stp->st_mutex); in nfs4_preprocess_confirmed_seqid_op()
6820 nfs4_put_stid(&stp->st_stid); in nfs4_preprocess_confirmed_seqid_op()
6823 *stpp = stp; in nfs4_preprocess_confirmed_seqid_op()
6834 struct nfs4_ol_stateid *stp; in nfsd4_open_confirm() local
6846 NFS4_OPEN_STID, &stp, nn); in nfsd4_open_confirm()
6849 oo = openowner(stp->st_stateowner); in nfsd4_open_confirm()
6852 mutex_unlock(&stp->st_mutex); in nfsd4_open_confirm()
6856 nfs4_inc_and_copy_stateid(&oc->oc_resp_stateid, &stp->st_stid); in nfsd4_open_confirm()
6857 mutex_unlock(&stp->st_mutex); in nfsd4_open_confirm()
6858 trace_nfsd_open_confirm(oc->oc_seqid, &stp->st_stid.sc_stateid); in nfsd4_open_confirm()
6862 nfs4_put_stid(&stp->st_stid); in nfsd4_open_confirm()
6868 static inline void nfs4_stateid_downgrade_bit(struct nfs4_ol_stateid *stp, u32 access) in nfs4_stateid_downgrade_bit() argument
6870 if (!test_access(access, stp)) in nfs4_stateid_downgrade_bit()
6872 nfs4_file_put_access(stp->st_stid.sc_file, access); in nfs4_stateid_downgrade_bit()
6873 clear_access(access, stp); in nfs4_stateid_downgrade_bit()
6876 static inline void nfs4_stateid_downgrade(struct nfs4_ol_stateid *stp, u32 to_access) in nfs4_stateid_downgrade() argument
6880 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_WRITE); in nfs4_stateid_downgrade()
6881 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH); in nfs4_stateid_downgrade()
6884 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_READ); in nfs4_stateid_downgrade()
6885 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH); in nfs4_stateid_downgrade()
6900 struct nfs4_ol_stateid *stp; in nfsd4_open_downgrade() local
6912 &od->od_stateid, &stp, nn); in nfsd4_open_downgrade()
6916 if (!test_access(od->od_share_access, stp)) { in nfsd4_open_downgrade()
6918 stp->st_access_bmap, od->od_share_access); in nfsd4_open_downgrade()
6921 if (!test_deny(od->od_share_deny, stp)) { in nfsd4_open_downgrade()
6923 stp->st_deny_bmap, od->od_share_deny); in nfsd4_open_downgrade()
6926 nfs4_stateid_downgrade(stp, od->od_share_access); in nfsd4_open_downgrade()
6927 reset_union_bmap_deny(od->od_share_deny, stp); in nfsd4_open_downgrade()
6928 nfs4_inc_and_copy_stateid(&od->od_stateid, &stp->st_stid); in nfsd4_open_downgrade()
6931 mutex_unlock(&stp->st_mutex); in nfsd4_open_downgrade()
6932 nfs4_put_stid(&stp->st_stid); in nfsd4_open_downgrade()
6943 struct nfs4_ol_stateid *stp; in nfsd4_close_open_stateid() local
6952 list_for_each_entry(stp, &reaplist, st_locks) in nfsd4_close_open_stateid()
6953 nfs4_free_cpntf_statelist(clp->net, &stp->st_stid); in nfsd4_close_open_stateid()
6972 struct nfs4_ol_stateid *stp; in nfsd4_close() local
6982 &stp, nn); in nfsd4_close()
6987 stp->st_stid.sc_type = NFS4_CLOSED_STID; in nfsd4_close()
6995 nfs4_inc_and_copy_stateid(&close->cl_stateid, &stp->st_stid); in nfsd4_close()
6997 nfsd4_close_open_stateid(stp); in nfsd4_close()
6998 mutex_unlock(&stp->st_mutex); in nfsd4_close()
7010 nfs4_put_stid(&stp->st_stid); in nfsd4_close()
7279 init_lock_stateid(struct nfs4_ol_stateid *stp, struct nfs4_lockowner *lo, in init_lock_stateid() argument
7286 mutex_init(&stp->st_mutex); in init_lock_stateid()
7287 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX); in init_lock_stateid()
7295 refcount_inc(&stp->st_stid.sc_count); in init_lock_stateid()
7296 stp->st_stid.sc_type = NFS4_LOCK_STID; in init_lock_stateid()
7297 stp->st_stateowner = nfs4_get_stateowner(&lo->lo_owner); in init_lock_stateid()
7299 stp->st_stid.sc_file = fp; in init_lock_stateid()
7300 stp->st_access_bmap = 0; in init_lock_stateid()
7301 stp->st_deny_bmap = open_stp->st_deny_bmap; in init_lock_stateid()
7302 stp->st_openstp = open_stp; in init_lock_stateid()
7304 list_add(&stp->st_locks, &open_stp->st_locks); in init_lock_stateid()
7305 list_add(&stp->st_perstateowner, &lo->lo_owner.so_stateids); in init_lock_stateid()
7306 list_add(&stp->st_perfile, &fp->fi_stateids); in init_lock_stateid()
7309 return stp; in init_lock_stateid()
7317 mutex_unlock(&stp->st_mutex); in init_lock_stateid()
7321 mutex_unlock(&stp->st_mutex); in init_lock_stateid()
7763 struct nfs4_ol_stateid *stp; in nfsd4_locku() local
7779 &stp, nn); in nfsd4_locku()
7782 nf = find_any_file(stp->st_stid.sc_file); in nfsd4_locku()
7795 file_lock->fl_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(stp->st_stateowner)); in nfsd4_locku()
7811 nfs4_inc_and_copy_stateid(&locku->lu_stateid, &stp->st_stid); in nfsd4_locku()
7815 mutex_unlock(&stp->st_mutex); in nfsd4_locku()
7816 nfs4_put_stid(&stp->st_stid); in nfsd4_locku()
7890 struct nfs4_ol_stateid *stp; in nfsd4_release_lockowner() local
7917 stp = list_first_entry(&lo->lo_owner.so_stateids, in nfsd4_release_lockowner()
7920 WARN_ON(!unhash_lock_stateid(stp)); in nfsd4_release_lockowner()
7921 put_ol_stateid_locked(stp, &reaplist); in nfsd4_release_lockowner()