Lines Matching defs:stp

442 set_access(u32 access, struct nfs4_ol_stateid *stp)
447 stp->st_access_bmap |= mask;
452 clear_access(u32 access, struct nfs4_ol_stateid *stp)
457 stp->st_access_bmap &= ~mask;
462 test_access(u32 access, struct nfs4_ol_stateid *stp)
466 return (bool)(stp->st_access_bmap & mask);
471 set_deny(u32 deny, struct nfs4_ol_stateid *stp)
476 stp->st_deny_bmap |= mask;
481 clear_deny(u32 deny, struct nfs4_ol_stateid *stp)
486 stp->st_deny_bmap &= ~mask;
491 test_deny(u32 deny, struct nfs4_ol_stateid *stp)
495 return (bool)(stp->st_deny_bmap & mask);
513 access_permit_read(struct nfs4_ol_stateid *stp)
515 return test_access(NFS4_SHARE_ACCESS_READ, stp) ||
516 test_access(NFS4_SHARE_ACCESS_BOTH, stp) ||
517 test_access(NFS4_SHARE_ACCESS_WRITE, stp);
521 access_permit_write(struct nfs4_ol_stateid *stp)
523 return test_access(NFS4_SHARE_ACCESS_WRITE, stp) ||
524 test_access(NFS4_SHARE_ACCESS_BOTH, stp);
739 * stp: skip checking this entry.
748 struct nfs4_ol_stateid *stp, u32 access, bool share_access)
761 if (st == stp && new_stp)
774 clp = stp->st_stid.sc_client;
1399 struct nfs4_ol_stateid *stp;
1403 list_for_each_entry(stp, &fp->fi_stateids, st_perfile)
1404 fp->fi_share_deny |= bmap_to_share_mode(stp->st_deny_bmap);
1409 reset_union_bmap_deny(u32 deny, struct nfs4_ol_stateid *stp)
1417 clear_deny(i, stp);
1423 recalculate_deny_mode(stp->st_stid.sc_file);
1428 release_all_access(struct nfs4_ol_stateid *stp)
1431 struct nfs4_file *fp = stp->st_stid.sc_file;
1433 if (fp && stp->st_deny_bmap != 0)
1437 if (test_access(i, stp))
1438 nfs4_file_put_access(stp->st_stid.sc_file, i);
1439 clear_access(i, stp);
1463 nfs4_ol_stateid_unhashed(const struct nfs4_ol_stateid *stp)
1465 return list_empty(&stp->st_perfile);
1468 static bool unhash_ol_stateid(struct nfs4_ol_stateid *stp)
1470 struct nfs4_file *fp = stp->st_stid.sc_file;
1472 lockdep_assert_held(&stp->st_stateowner->so_client->cl_lock);
1474 if (list_empty(&stp->st_perfile))
1478 list_del_init(&stp->st_perfile);
1480 list_del(&stp->st_perstateowner);
1486 struct nfs4_ol_stateid *stp = openlockstateid(stid);
1488 put_clnt_odstate(stp->st_clnt_odstate);
1489 release_all_access(stp);
1490 if (stp->st_stateowner)
1491 nfs4_put_stateowner(stp->st_stateowner);
1498 struct nfs4_ol_stateid *stp = openlockstateid(stid);
1499 struct nfs4_lockowner *lo = lockowner(stp->st_stateowner);
1502 nf = find_any_file(stp->st_stid.sc_file);
1516 static void put_ol_stateid_locked(struct nfs4_ol_stateid *stp,
1519 struct nfs4_stid *s = &stp->st_stid;
1524 WARN_ON_ONCE(!list_empty(&stp->st_locks));
1532 list_add(&stp->st_locks, reaplist);
1535 static bool unhash_lock_stateid(struct nfs4_ol_stateid *stp)
1537 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock);
1539 if (!unhash_ol_stateid(stp))
1541 list_del_init(&stp->st_locks);
1542 nfs4_unhash_stid(&stp->st_stid);
1546 static void release_lock_stateid(struct nfs4_ol_stateid *stp)
1548 struct nfs4_client *clp = stp->st_stid.sc_client;
1552 unhashed = unhash_lock_stateid(stp);
1555 nfs4_put_stid(&stp->st_stid);
1574 struct nfs4_ol_stateid *stp;
1580 stp = list_first_entry(reaplist, struct nfs4_ol_stateid,
1582 list_del(&stp->st_locks);
1583 fp = stp->st_stid.sc_file;
1584 stp->st_stid.sc_free(&stp->st_stid);
1593 struct nfs4_ol_stateid *stp;
1598 stp = list_entry(open_stp->st_locks.next,
1600 WARN_ON(!unhash_lock_stateid(stp));
1601 put_ol_stateid_locked(stp, reaplist);
1605 static bool unhash_open_stateid(struct nfs4_ol_stateid *stp,
1608 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock);
1610 if (!unhash_ol_stateid(stp))
1612 release_open_stateid_locks(stp, reaplist);
1616 static void release_open_stateid(struct nfs4_ol_stateid *stp)
1620 spin_lock(&stp->st_stid.sc_client->cl_lock);
1621 if (unhash_open_stateid(stp, &reaplist))
1622 put_ol_stateid_locked(stp, &reaplist);
1623 spin_unlock(&stp->st_stid.sc_client->cl_lock);
1656 struct nfs4_ol_stateid *stp;
1665 stp = list_first_entry(&oo->oo_owner.so_stateids,
1667 if (unhash_open_stateid(stp, &reaplist))
1668 put_ol_stateid_locked(stp, &reaplist);
4563 nfsd4_lock_ol_stateid(struct nfs4_ol_stateid *stp)
4567 mutex_lock_nested(&stp->st_mutex, LOCK_STATEID_MUTEX);
4568 ret = nfsd4_verify_open_stid(&stp->st_stid);
4570 mutex_unlock(&stp->st_mutex);
4577 struct nfs4_ol_stateid *stp;
4580 stp = nfsd4_find_existing_open(fp, open);
4582 if (!stp || nfsd4_lock_ol_stateid(stp) == nfs_ok)
4584 nfs4_put_stid(&stp->st_stid);
4586 return stp;
4626 struct nfs4_ol_stateid *stp;
4628 stp = open->op_stp;
4630 mutex_init(&stp->st_mutex);
4631 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX);
4642 refcount_inc(&stp->st_stid.sc_count);
4643 stp->st_stid.sc_type = NFS4_OPEN_STID;
4644 INIT_LIST_HEAD(&stp->st_locks);
4645 stp->st_stateowner = nfs4_get_stateowner(&oo->oo_owner);
4647 stp->st_stid.sc_file = fp;
4648 stp->st_access_bmap = 0;
4649 stp->st_deny_bmap = 0;
4650 stp->st_openstp = NULL;
4651 list_add(&stp->st_perstateowner, &oo->oo_owner.so_stateids);
4652 list_add(&stp->st_perfile, &fp->fi_stateids);
4664 mutex_unlock(&stp->st_mutex);
4665 stp = retstp;
4667 return stp;
5195 struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp,
5217 stp, open->op_share_deny, false))
5231 stp, open->op_share_access, true))
5238 old_access_bmap = stp->st_access_bmap;
5239 set_access(open->op_share_access, stp);
5242 old_deny_bmap = stp->st_deny_bmap;
5243 set_deny(open->op_share_deny, stp);
5275 stp->st_access_bmap = old_access_bmap;
5277 reset_union_bmap_deny(bmap_to_share_mode(old_deny_bmap), stp);
5283 struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp,
5287 unsigned char old_deny_bmap = stp->st_deny_bmap;
5289 if (!test_access(open->op_share_access, stp))
5290 return nfs4_get_vfs_file(rqstp, fp, cur_fh, stp, open, false);
5297 set_deny(open->op_share_deny, stp);
5303 stp, open->op_share_deny, false))
5314 reset_union_bmap_deny(old_deny_bmap, stp);
5454 nfs4_set_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp,
5458 struct nfs4_client *clp = stp->st_stid.sc_client;
5459 struct nfs4_file *fp = stp->st_stid.sc_file;
5460 struct nfs4_clnt_odstate *odstate = stp->st_clnt_odstate;
5627 nfs4_open_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp,
5631 struct nfs4_openowner *oo = openowner(stp->st_stateowner);
5632 struct nfs4_client *clp = stp->st_stid.sc_client;
5664 dp = nfs4_set_delegation(open, stp, parent);
5729 struct nfs4_ol_stateid *stp = NULL;
5746 stp = nfsd4_find_and_lock_existing_open(fp, open);
5754 if (!stp) {
5755 stp = init_open_stateid(fp, open);
5764 * stp is already locked.
5768 status = nfs4_upgrade_open(rqstp, fp, current_fh, stp, open);
5770 mutex_unlock(&stp->st_mutex);
5774 status = nfs4_get_vfs_file(rqstp, fp, current_fh, stp, open, true);
5776 stp->st_stid.sc_type = NFS4_CLOSED_STID;
5777 release_open_stateid(stp);
5778 mutex_unlock(&stp->st_mutex);
5782 stp->st_clnt_odstate = find_or_hash_clnt_odstate(fp,
5784 if (stp->st_clnt_odstate == open->op_odstate)
5788 nfs4_inc_and_copy_stateid(&open->op_stateid, &stp->st_stid);
5789 mutex_unlock(&stp->st_mutex);
5803 nfs4_open_delegation(open, stp, &resp->cstate.current_fh);
5806 trace_nfsd_open(&stp->st_stid.sc_stateid);
5828 if (stp)
5829 nfs4_put_stid(&stp->st_stid);
6013 struct nfs4_ol_stateid *stp;
6016 list_for_each_entry(stp, &lo->lo_owner.so_stateids, st_perstateowner) {
6017 nf = stp->st_stid.sc_file;
6135 struct nfs4_ol_stateid *stp;
6186 stp = oo->oo_last_closed_stid;
6189 nfs4_put_stid(&stp->st_stid);
6303 static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stid *stp)
6305 if (!fh_match(&fhp->fh_handle, &stp->sc_file->fi_fhandle))
6311 __be32 nfs4_check_openmode(struct nfs4_ol_stateid *stp, int flags)
6316 if (stp->st_openstp)
6317 stp = stp->st_openstp;
6318 if ((flags & WR_STATE) && !access_permit_write(stp))
6320 if ((flags & RD_STATE) && !access_permit_read(stp))
6718 struct nfs4_ol_stateid *stp = openlockstateid(s);
6721 ret = nfsd4_lock_ol_stateid(stp);
6730 if (check_for_locks(stp->st_stid.sc_file,
6731 lockowner(stp->st_stateowner)))
6734 release_lock_stateid(stp);
6738 mutex_unlock(&stp->st_mutex);
6800 static __be32 nfs4_seqid_op_checks(struct nfsd4_compound_state *cstate, stateid_t *stateid, u32 seqid, struct nfs4_ol_stateid *stp)
6803 struct nfs4_stateowner *sop = stp->st_stateowner;
6809 status = nfsd4_lock_ol_stateid(stp);
6812 status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate));
6814 status = nfs4_check_fh(current_fh, &stp->st_stid);
6816 mutex_unlock(&stp->st_mutex);
6841 struct nfs4_ol_stateid *stp = NULL;
6849 stp = openlockstateid(s);
6850 nfsd4_cstate_assign_replay(cstate, stp->st_stateowner);
6852 status = nfs4_seqid_op_checks(cstate, stateid, seqid, stp);
6854 *stpp = stp;
6856 nfs4_put_stid(&stp->st_stid);
6865 struct nfs4_ol_stateid *stp;
6868 NFS4_OPEN_STID, &stp, nn);
6871 oo = openowner(stp->st_stateowner);
6873 mutex_unlock(&stp->st_mutex);
6874 nfs4_put_stid(&stp->st_stid);
6877 *stpp = stp;
6888 struct nfs4_ol_stateid *stp;
6900 NFS4_OPEN_STID, &stp, nn);
6903 oo = openowner(stp->st_stateowner);
6906 mutex_unlock(&stp->st_mutex);
6910 nfs4_inc_and_copy_stateid(&oc->oc_resp_stateid, &stp->st_stid);
6911 mutex_unlock(&stp->st_mutex);
6912 trace_nfsd_open_confirm(oc->oc_seqid, &stp->st_stid.sc_stateid);
6916 nfs4_put_stid(&stp->st_stid);
6922 static inline void nfs4_stateid_downgrade_bit(struct nfs4_ol_stateid *stp, u32 access)
6924 if (!test_access(access, stp))
6926 nfs4_file_put_access(stp->st_stid.sc_file, access);
6927 clear_access(access, stp);
6930 static inline void nfs4_stateid_downgrade(struct nfs4_ol_stateid *stp, u32 to_access)
6934 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_WRITE);
6935 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH);
6938 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_READ);
6939 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH);
6954 struct nfs4_ol_stateid *stp;
6966 &od->od_stateid, &stp, nn);
6970 if (!test_access(od->od_share_access, stp)) {
6972 stp->st_access_bmap, od->od_share_access);
6975 if (!test_deny(od->od_share_deny, stp)) {
6977 stp->st_deny_bmap, od->od_share_deny);
6980 nfs4_stateid_downgrade(stp, od->od_share_access);
6981 reset_union_bmap_deny(od->od_share_deny, stp);
6982 nfs4_inc_and_copy_stateid(&od->od_stateid, &stp->st_stid);
6985 mutex_unlock(&stp->st_mutex);
6986 nfs4_put_stid(&stp->st_stid);
6997 struct nfs4_ol_stateid *stp;
7006 list_for_each_entry(stp, &reaplist, st_locks)
7007 nfs4_free_cpntf_statelist(clp->net, &stp->st_stid);
7026 struct nfs4_ol_stateid *stp;
7036 &stp, nn);
7041 stp->st_stid.sc_type = NFS4_CLOSED_STID;
7049 nfs4_inc_and_copy_stateid(&close->cl_stateid, &stp->st_stid);
7051 nfsd4_close_open_stateid(stp);
7052 mutex_unlock(&stp->st_mutex);
7064 nfs4_put_stid(&stp->st_stid);
7333 init_lock_stateid(struct nfs4_ol_stateid *stp, struct nfs4_lockowner *lo,
7340 mutex_init(&stp->st_mutex);
7341 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX);
7349 refcount_inc(&stp->st_stid.sc_count);
7350 stp->st_stid.sc_type = NFS4_LOCK_STID;
7351 stp->st_stateowner = nfs4_get_stateowner(&lo->lo_owner);
7353 stp->st_stid.sc_file = fp;
7354 stp->st_access_bmap = 0;
7355 stp->st_deny_bmap = open_stp->st_deny_bmap;
7356 stp->st_openstp = open_stp;
7358 list_add(&stp->st_locks, &open_stp->st_locks);
7359 list_add(&stp->st_perstateowner, &lo->lo_owner.so_stateids);
7360 list_add(&stp->st_perfile, &fp->fi_stateids);
7363 return stp;
7371 mutex_unlock(&stp->st_mutex);
7375 mutex_unlock(&stp->st_mutex);
7817 struct nfs4_ol_stateid *stp;
7833 &stp, nn);
7836 nf = find_any_file(stp->st_stid.sc_file);
7849 file_lock->fl_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(stp->st_stateowner));
7865 nfs4_inc_and_copy_stateid(&locku->lu_stateid, &stp->st_stid);
7869 mutex_unlock(&stp->st_mutex);
7870 nfs4_put_stid(&stp->st_stid);
7945 struct nfs4_ol_stateid *stp;
7966 list_for_each_entry(stp, &lo->lo_owner.so_stateids, st_perstateowner) {
7967 if (check_for_locks(stp->st_stid.sc_file, lo)) {
7975 stp = list_first_entry(&lo->lo_owner.so_stateids,
7978 WARN_ON(!unhash_lock_stateid(stp));
7979 put_ol_stateid_locked(stp, &reaplist);