Lines Matching full: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()
739 * stp: skip checking this entry.
748 struct nfs4_ol_stateid *stp, u32 access, bool share_access) in nfs4_resolve_deny_conflicts_locked() argument
761 if (st == stp && new_stp) in nfs4_resolve_deny_conflicts_locked()
774 clp = stp->st_stid.sc_client; in nfs4_resolve_deny_conflicts_locked()
1401 struct nfs4_ol_stateid *stp; in recalculate_deny_mode() local
1405 list_for_each_entry(stp, &fp->fi_stateids, st_perfile) in recalculate_deny_mode()
1406 fp->fi_share_deny |= bmap_to_share_mode(stp->st_deny_bmap); in recalculate_deny_mode()
1411 reset_union_bmap_deny(u32 deny, struct nfs4_ol_stateid *stp) in reset_union_bmap_deny() argument
1419 clear_deny(i, stp); in reset_union_bmap_deny()
1425 recalculate_deny_mode(stp->st_stid.sc_file); in reset_union_bmap_deny()
1430 release_all_access(struct nfs4_ol_stateid *stp) in release_all_access() argument
1433 struct nfs4_file *fp = stp->st_stid.sc_file; in release_all_access()
1435 if (fp && stp->st_deny_bmap != 0) in release_all_access()
1439 if (test_access(i, stp)) in release_all_access()
1440 nfs4_file_put_access(stp->st_stid.sc_file, i); in release_all_access()
1441 clear_access(i, stp); in release_all_access()
1465 nfs4_ol_stateid_unhashed(const struct nfs4_ol_stateid *stp) in nfs4_ol_stateid_unhashed() argument
1467 return list_empty(&stp->st_perfile); in nfs4_ol_stateid_unhashed()
1470 static bool unhash_ol_stateid(struct nfs4_ol_stateid *stp) in unhash_ol_stateid() argument
1472 struct nfs4_file *fp = stp->st_stid.sc_file; in unhash_ol_stateid()
1474 lockdep_assert_held(&stp->st_stateowner->so_client->cl_lock); in unhash_ol_stateid()
1476 if (list_empty(&stp->st_perfile)) in unhash_ol_stateid()
1480 list_del_init(&stp->st_perfile); in unhash_ol_stateid()
1482 list_del(&stp->st_perstateowner); in unhash_ol_stateid()
1488 struct nfs4_ol_stateid *stp = openlockstateid(stid); in nfs4_free_ol_stateid() local
1490 put_clnt_odstate(stp->st_clnt_odstate); in nfs4_free_ol_stateid()
1491 release_all_access(stp); in nfs4_free_ol_stateid()
1492 if (stp->st_stateowner) in nfs4_free_ol_stateid()
1493 nfs4_put_stateowner(stp->st_stateowner); in nfs4_free_ol_stateid()
1500 struct nfs4_ol_stateid *stp = openlockstateid(stid); in nfs4_free_lock_stateid() local
1501 struct nfs4_lockowner *lo = lockowner(stp->st_stateowner); in nfs4_free_lock_stateid()
1504 nf = find_any_file(stp->st_stid.sc_file); in nfs4_free_lock_stateid()
1518 static void put_ol_stateid_locked(struct nfs4_ol_stateid *stp, in put_ol_stateid_locked() argument
1521 struct nfs4_stid *s = &stp->st_stid; in put_ol_stateid_locked()
1526 WARN_ON_ONCE(!list_empty(&stp->st_locks)); in put_ol_stateid_locked()
1534 list_add(&stp->st_locks, reaplist); in put_ol_stateid_locked()
1537 static bool unhash_lock_stateid(struct nfs4_ol_stateid *stp) in unhash_lock_stateid() argument
1539 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock); in unhash_lock_stateid()
1541 if (!unhash_ol_stateid(stp)) in unhash_lock_stateid()
1543 list_del_init(&stp->st_locks); in unhash_lock_stateid()
1544 nfs4_unhash_stid(&stp->st_stid); in unhash_lock_stateid()
1548 static void release_lock_stateid(struct nfs4_ol_stateid *stp) in release_lock_stateid() argument
1550 struct nfs4_client *clp = stp->st_stid.sc_client; in release_lock_stateid()
1554 unhashed = unhash_lock_stateid(stp); in release_lock_stateid()
1557 nfs4_put_stid(&stp->st_stid); in release_lock_stateid()
1576 struct nfs4_ol_stateid *stp; in free_ol_stateid_reaplist() local
1582 stp = list_first_entry(reaplist, struct nfs4_ol_stateid, in free_ol_stateid_reaplist()
1584 list_del(&stp->st_locks); in free_ol_stateid_reaplist()
1585 fp = stp->st_stid.sc_file; in free_ol_stateid_reaplist()
1586 stp->st_stid.sc_free(&stp->st_stid); in free_ol_stateid_reaplist()
1595 struct nfs4_ol_stateid *stp; in release_open_stateid_locks() local
1600 stp = list_entry(open_stp->st_locks.next, in release_open_stateid_locks()
1602 WARN_ON(!unhash_lock_stateid(stp)); in release_open_stateid_locks()
1603 put_ol_stateid_locked(stp, reaplist); in release_open_stateid_locks()
1607 static bool unhash_open_stateid(struct nfs4_ol_stateid *stp, in unhash_open_stateid() argument
1610 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock); in unhash_open_stateid()
1612 if (!unhash_ol_stateid(stp)) in unhash_open_stateid()
1614 release_open_stateid_locks(stp, reaplist); in unhash_open_stateid()
1618 static void release_open_stateid(struct nfs4_ol_stateid *stp) in release_open_stateid() argument
1622 spin_lock(&stp->st_stid.sc_client->cl_lock); in release_open_stateid()
1623 if (unhash_open_stateid(stp, &reaplist)) in release_open_stateid()
1624 put_ol_stateid_locked(stp, &reaplist); in release_open_stateid()
1625 spin_unlock(&stp->st_stid.sc_client->cl_lock); in release_open_stateid()
1658 struct nfs4_ol_stateid *stp; in release_openowner() local
1667 stp = list_first_entry(&oo->oo_owner.so_stateids, in release_openowner()
1669 if (unhash_open_stateid(stp, &reaplist)) in release_openowner()
1670 put_ol_stateid_locked(stp, &reaplist); in release_openowner()
4564 nfsd4_lock_ol_stateid(struct nfs4_ol_stateid *stp) in nfsd4_lock_ol_stateid() argument
4568 mutex_lock_nested(&stp->st_mutex, LOCK_STATEID_MUTEX); in nfsd4_lock_ol_stateid()
4569 ret = nfsd4_verify_open_stid(&stp->st_stid); in nfsd4_lock_ol_stateid()
4571 mutex_unlock(&stp->st_mutex); in nfsd4_lock_ol_stateid()
4578 struct nfs4_ol_stateid *stp; in nfsd4_find_and_lock_existing_open() local
4581 stp = nfsd4_find_existing_open(fp, open); in nfsd4_find_and_lock_existing_open()
4583 if (!stp || nfsd4_lock_ol_stateid(stp) == nfs_ok) in nfsd4_find_and_lock_existing_open()
4585 nfs4_put_stid(&stp->st_stid); in nfsd4_find_and_lock_existing_open()
4587 return stp; in nfsd4_find_and_lock_existing_open()
4627 struct nfs4_ol_stateid *stp; in init_open_stateid() local
4629 stp = open->op_stp; in init_open_stateid()
4631 mutex_init(&stp->st_mutex); in init_open_stateid()
4632 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX); in init_open_stateid()
4643 refcount_inc(&stp->st_stid.sc_count); in init_open_stateid()
4644 stp->st_stid.sc_type = NFS4_OPEN_STID; in init_open_stateid()
4645 INIT_LIST_HEAD(&stp->st_locks); in init_open_stateid()
4646 stp->st_stateowner = nfs4_get_stateowner(&oo->oo_owner); in init_open_stateid()
4648 stp->st_stid.sc_file = fp; in init_open_stateid()
4649 stp->st_access_bmap = 0; in init_open_stateid()
4650 stp->st_deny_bmap = 0; in init_open_stateid()
4651 stp->st_openstp = NULL; in init_open_stateid()
4652 list_add(&stp->st_perstateowner, &oo->oo_owner.so_stateids); in init_open_stateid()
4653 list_add(&stp->st_perfile, &fp->fi_stateids); in init_open_stateid()
4665 mutex_unlock(&stp->st_mutex); in init_open_stateid()
4666 stp = retstp; in init_open_stateid()
4668 return stp; in init_open_stateid()
5196 struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, in nfs4_get_vfs_file() argument
5218 stp, open->op_share_deny, false)) in nfs4_get_vfs_file()
5232 stp, open->op_share_access, true)) in nfs4_get_vfs_file()
5239 old_access_bmap = stp->st_access_bmap; in nfs4_get_vfs_file()
5240 set_access(open->op_share_access, stp); in nfs4_get_vfs_file()
5243 old_deny_bmap = stp->st_deny_bmap; in nfs4_get_vfs_file()
5244 set_deny(open->op_share_deny, stp); in nfs4_get_vfs_file()
5276 stp->st_access_bmap = old_access_bmap; in nfs4_get_vfs_file()
5278 reset_union_bmap_deny(bmap_to_share_mode(old_deny_bmap), stp); in nfs4_get_vfs_file()
5284 struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, in nfs4_upgrade_open() argument
5288 unsigned char old_deny_bmap = stp->st_deny_bmap; in nfs4_upgrade_open()
5290 if (!test_access(open->op_share_access, stp)) in nfs4_upgrade_open()
5291 return nfs4_get_vfs_file(rqstp, fp, cur_fh, stp, open, false); in nfs4_upgrade_open()
5298 set_deny(open->op_share_deny, stp); in nfs4_upgrade_open()
5304 stp, open->op_share_deny, false)) in nfs4_upgrade_open()
5315 reset_union_bmap_deny(old_deny_bmap, stp); in nfs4_upgrade_open()
5455 nfs4_set_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp, in nfs4_set_delegation() argument
5459 struct nfs4_client *clp = stp->st_stid.sc_client; in nfs4_set_delegation()
5460 struct nfs4_file *fp = stp->st_stid.sc_file; in nfs4_set_delegation()
5461 struct nfs4_clnt_odstate *odstate = stp->st_clnt_odstate; in nfs4_set_delegation()
5628 nfs4_open_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp, in nfs4_open_delegation() argument
5632 struct nfs4_openowner *oo = openowner(stp->st_stateowner); in nfs4_open_delegation()
5633 struct nfs4_client *clp = stp->st_stid.sc_client; in nfs4_open_delegation()
5665 dp = nfs4_set_delegation(open, stp, parent); in nfs4_open_delegation()
5730 struct nfs4_ol_stateid *stp = NULL; in nfsd4_process_open2() local
5747 stp = nfsd4_find_and_lock_existing_open(fp, open); in nfsd4_process_open2()
5755 if (!stp) { in nfsd4_process_open2()
5756 stp = init_open_stateid(fp, open); in nfsd4_process_open2()
5765 * stp is already locked. in nfsd4_process_open2()
5769 status = nfs4_upgrade_open(rqstp, fp, current_fh, stp, open); in nfsd4_process_open2()
5771 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
5775 status = nfs4_get_vfs_file(rqstp, fp, current_fh, stp, open, true); in nfsd4_process_open2()
5777 stp->st_stid.sc_type = NFS4_CLOSED_STID; in nfsd4_process_open2()
5778 release_open_stateid(stp); in nfsd4_process_open2()
5779 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
5783 stp->st_clnt_odstate = find_or_hash_clnt_odstate(fp, in nfsd4_process_open2()
5785 if (stp->st_clnt_odstate == open->op_odstate) in nfsd4_process_open2()
5789 nfs4_inc_and_copy_stateid(&open->op_stateid, &stp->st_stid); in nfsd4_process_open2()
5790 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
5804 nfs4_open_delegation(open, stp, &resp->cstate.current_fh); in nfsd4_process_open2()
5807 trace_nfsd_open(&stp->st_stid.sc_stateid); in nfsd4_process_open2()
5829 if (stp) in nfsd4_process_open2()
5830 nfs4_put_stid(&stp->st_stid); in nfsd4_process_open2()
6014 struct nfs4_ol_stateid *stp; in nfs4_lockowner_has_blockers() local
6017 list_for_each_entry(stp, &lo->lo_owner.so_stateids, st_perstateowner) { in nfs4_lockowner_has_blockers()
6018 nf = stp->st_stid.sc_file; in nfs4_lockowner_has_blockers()
6136 struct nfs4_ol_stateid *stp; in nfs4_laundromat() local
6187 stp = oo->oo_last_closed_stid; in nfs4_laundromat()
6190 nfs4_put_stid(&stp->st_stid); in nfs4_laundromat()
6304 static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stid *stp) in nfs4_check_fh() argument
6306 if (!fh_match(&fhp->fh_handle, &stp->sc_file->fi_fhandle)) in nfs4_check_fh()
6312 __be32 nfs4_check_openmode(struct nfs4_ol_stateid *stp, int flags) in nfs4_check_openmode() argument
6317 if (stp->st_openstp) in nfs4_check_openmode()
6318 stp = stp->st_openstp; in nfs4_check_openmode()
6319 if ((flags & WR_STATE) && !access_permit_write(stp)) in nfs4_check_openmode()
6321 if ((flags & RD_STATE) && !access_permit_read(stp)) in nfs4_check_openmode()
6719 struct nfs4_ol_stateid *stp = openlockstateid(s); in nfsd4_free_lock_stateid() local
6722 ret = nfsd4_lock_ol_stateid(stp); in nfsd4_free_lock_stateid()
6731 if (check_for_locks(stp->st_stid.sc_file, in nfsd4_free_lock_stateid()
6732 lockowner(stp->st_stateowner))) in nfsd4_free_lock_stateid()
6735 release_lock_stateid(stp); in nfsd4_free_lock_stateid()
6739 mutex_unlock(&stp->st_mutex); in nfsd4_free_lock_stateid()
6801 …ks(struct nfsd4_compound_state *cstate, stateid_t *stateid, u32 seqid, struct nfs4_ol_stateid *stp) in nfs4_seqid_op_checks() argument
6804 struct nfs4_stateowner *sop = stp->st_stateowner; in nfs4_seqid_op_checks()
6810 status = nfsd4_lock_ol_stateid(stp); in nfs4_seqid_op_checks()
6813 status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate)); in nfs4_seqid_op_checks()
6815 status = nfs4_check_fh(current_fh, &stp->st_stid); in nfs4_seqid_op_checks()
6817 mutex_unlock(&stp->st_mutex); in nfs4_seqid_op_checks()
6842 struct nfs4_ol_stateid *stp = NULL; in nfs4_preprocess_seqid_op() local
6850 stp = openlockstateid(s); in nfs4_preprocess_seqid_op()
6851 nfsd4_cstate_assign_replay(cstate, stp->st_stateowner); in nfs4_preprocess_seqid_op()
6853 status = nfs4_seqid_op_checks(cstate, stateid, seqid, stp); in nfs4_preprocess_seqid_op()
6855 *stpp = stp; in nfs4_preprocess_seqid_op()
6857 nfs4_put_stid(&stp->st_stid); in nfs4_preprocess_seqid_op()
6866 struct nfs4_ol_stateid *stp; in nfs4_preprocess_confirmed_seqid_op() local
6869 NFS4_OPEN_STID, &stp, nn); in nfs4_preprocess_confirmed_seqid_op()
6872 oo = openowner(stp->st_stateowner); in nfs4_preprocess_confirmed_seqid_op()
6874 mutex_unlock(&stp->st_mutex); in nfs4_preprocess_confirmed_seqid_op()
6875 nfs4_put_stid(&stp->st_stid); in nfs4_preprocess_confirmed_seqid_op()
6878 *stpp = stp; in nfs4_preprocess_confirmed_seqid_op()
6889 struct nfs4_ol_stateid *stp; in nfsd4_open_confirm() local
6901 NFS4_OPEN_STID, &stp, nn); in nfsd4_open_confirm()
6904 oo = openowner(stp->st_stateowner); in nfsd4_open_confirm()
6907 mutex_unlock(&stp->st_mutex); in nfsd4_open_confirm()
6911 nfs4_inc_and_copy_stateid(&oc->oc_resp_stateid, &stp->st_stid); in nfsd4_open_confirm()
6912 mutex_unlock(&stp->st_mutex); in nfsd4_open_confirm()
6913 trace_nfsd_open_confirm(oc->oc_seqid, &stp->st_stid.sc_stateid); in nfsd4_open_confirm()
6917 nfs4_put_stid(&stp->st_stid); in nfsd4_open_confirm()
6923 static inline void nfs4_stateid_downgrade_bit(struct nfs4_ol_stateid *stp, u32 access) in nfs4_stateid_downgrade_bit() argument
6925 if (!test_access(access, stp)) in nfs4_stateid_downgrade_bit()
6927 nfs4_file_put_access(stp->st_stid.sc_file, access); in nfs4_stateid_downgrade_bit()
6928 clear_access(access, stp); in nfs4_stateid_downgrade_bit()
6931 static inline void nfs4_stateid_downgrade(struct nfs4_ol_stateid *stp, u32 to_access) in nfs4_stateid_downgrade() argument
6935 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_WRITE); in nfs4_stateid_downgrade()
6936 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH); in nfs4_stateid_downgrade()
6939 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_READ); in nfs4_stateid_downgrade()
6940 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH); in nfs4_stateid_downgrade()
6955 struct nfs4_ol_stateid *stp; in nfsd4_open_downgrade() local
6967 &od->od_stateid, &stp, nn); in nfsd4_open_downgrade()
6971 if (!test_access(od->od_share_access, stp)) { in nfsd4_open_downgrade()
6973 stp->st_access_bmap, od->od_share_access); in nfsd4_open_downgrade()
6976 if (!test_deny(od->od_share_deny, stp)) { in nfsd4_open_downgrade()
6978 stp->st_deny_bmap, od->od_share_deny); in nfsd4_open_downgrade()
6981 nfs4_stateid_downgrade(stp, od->od_share_access); in nfsd4_open_downgrade()
6982 reset_union_bmap_deny(od->od_share_deny, stp); in nfsd4_open_downgrade()
6983 nfs4_inc_and_copy_stateid(&od->od_stateid, &stp->st_stid); in nfsd4_open_downgrade()
6986 mutex_unlock(&stp->st_mutex); in nfsd4_open_downgrade()
6987 nfs4_put_stid(&stp->st_stid); in nfsd4_open_downgrade()
6998 struct nfs4_ol_stateid *stp; in nfsd4_close_open_stateid() local
7007 list_for_each_entry(stp, &reaplist, st_locks) in nfsd4_close_open_stateid()
7008 nfs4_free_cpntf_statelist(clp->net, &stp->st_stid); in nfsd4_close_open_stateid()
7027 struct nfs4_ol_stateid *stp; in nfsd4_close() local
7037 &stp, nn); in nfsd4_close()
7042 stp->st_stid.sc_type = NFS4_CLOSED_STID; in nfsd4_close()
7050 nfs4_inc_and_copy_stateid(&close->cl_stateid, &stp->st_stid); in nfsd4_close()
7052 nfsd4_close_open_stateid(stp); in nfsd4_close()
7053 mutex_unlock(&stp->st_mutex); in nfsd4_close()
7065 nfs4_put_stid(&stp->st_stid); in nfsd4_close()
7334 init_lock_stateid(struct nfs4_ol_stateid *stp, struct nfs4_lockowner *lo, in init_lock_stateid() argument
7341 mutex_init(&stp->st_mutex); in init_lock_stateid()
7342 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX); in init_lock_stateid()
7350 refcount_inc(&stp->st_stid.sc_count); in init_lock_stateid()
7351 stp->st_stid.sc_type = NFS4_LOCK_STID; in init_lock_stateid()
7352 stp->st_stateowner = nfs4_get_stateowner(&lo->lo_owner); in init_lock_stateid()
7354 stp->st_stid.sc_file = fp; in init_lock_stateid()
7355 stp->st_access_bmap = 0; in init_lock_stateid()
7356 stp->st_deny_bmap = open_stp->st_deny_bmap; in init_lock_stateid()
7357 stp->st_openstp = open_stp; in init_lock_stateid()
7359 list_add(&stp->st_locks, &open_stp->st_locks); in init_lock_stateid()
7360 list_add(&stp->st_perstateowner, &lo->lo_owner.so_stateids); in init_lock_stateid()
7361 list_add(&stp->st_perfile, &fp->fi_stateids); in init_lock_stateid()
7364 return stp; in init_lock_stateid()
7372 mutex_unlock(&stp->st_mutex); in init_lock_stateid()
7376 mutex_unlock(&stp->st_mutex); in init_lock_stateid()
7838 struct nfs4_ol_stateid *stp; in nfsd4_locku() local
7854 &stp, nn); in nfsd4_locku()
7857 nf = find_any_file(stp->st_stid.sc_file); in nfsd4_locku()
7870 file_lock->fl_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(stp->st_stateowner)); in nfsd4_locku()
7886 nfs4_inc_and_copy_stateid(&locku->lu_stateid, &stp->st_stid); in nfsd4_locku()
7890 mutex_unlock(&stp->st_mutex); in nfsd4_locku()
7891 nfs4_put_stid(&stp->st_stid); in nfsd4_locku()
7966 struct nfs4_ol_stateid *stp; in nfsd4_release_lockowner() local
7987 list_for_each_entry(stp, &lo->lo_owner.so_stateids, st_perstateowner) { in nfsd4_release_lockowner()
7988 if (check_for_locks(stp->st_stid.sc_file, lo)) { in nfsd4_release_lockowner()
7996 stp = list_first_entry(&lo->lo_owner.so_stateids, in nfsd4_release_lockowner()
7999 WARN_ON(!unhash_lock_stateid(stp)); in nfsd4_release_lockowner()
8000 put_ol_stateid_locked(stp, &reaplist); in nfsd4_release_lockowner()