Lines Matching defs:stp

445 set_access(u32 access, struct nfs4_ol_stateid *stp)
450 stp->st_access_bmap |= mask;
455 clear_access(u32 access, struct nfs4_ol_stateid *stp)
460 stp->st_access_bmap &= ~mask;
465 test_access(u32 access, struct nfs4_ol_stateid *stp)
469 return (bool)(stp->st_access_bmap & mask);
474 set_deny(u32 deny, struct nfs4_ol_stateid *stp)
479 stp->st_deny_bmap |= mask;
484 clear_deny(u32 deny, struct nfs4_ol_stateid *stp)
489 stp->st_deny_bmap &= ~mask;
494 test_deny(u32 deny, struct nfs4_ol_stateid *stp)
498 return (bool)(stp->st_deny_bmap & mask);
516 access_permit_read(struct nfs4_ol_stateid *stp)
518 return test_access(NFS4_SHARE_ACCESS_READ, stp) ||
519 test_access(NFS4_SHARE_ACCESS_BOTH, stp) ||
520 test_access(NFS4_SHARE_ACCESS_WRITE, stp);
524 access_permit_write(struct nfs4_ol_stateid *stp)
526 return test_access(NFS4_SHARE_ACCESS_WRITE, stp) ||
527 test_access(NFS4_SHARE_ACCESS_BOTH, stp);
711 * stp: skip checking this entry.
720 struct nfs4_ol_stateid *stp, u32 access, bool share_access)
733 if (st == stp && new_stp)
746 clp = stp->st_stid.sc_client;
1410 struct nfs4_ol_stateid *stp;
1416 list_for_each_entry(stp, &fp->fi_stateids, st_perfile) {
1417 fp->fi_share_deny |= bmap_to_share_mode(stp->st_deny_bmap);
1425 reset_union_bmap_deny(u32 deny, struct nfs4_ol_stateid *stp)
1433 clear_deny(i, stp);
1439 recalculate_deny_mode(stp->st_stid.sc_file);
1444 release_all_access(struct nfs4_ol_stateid *stp)
1447 struct nfs4_file *fp = stp->st_stid.sc_file;
1449 if (fp && stp->st_deny_bmap != 0)
1453 if (test_access(i, stp))
1454 nfs4_file_put_access(stp->st_stid.sc_file, i);
1455 clear_access(i, stp);
1479 nfs4_ol_stateid_unhashed(const struct nfs4_ol_stateid *stp)
1481 return list_empty(&stp->st_perfile);
1484 static bool unhash_ol_stateid(struct nfs4_ol_stateid *stp)
1486 struct nfs4_file *fp = stp->st_stid.sc_file;
1488 lockdep_assert_held(&stp->st_stateowner->so_client->cl_lock);
1490 if (list_empty(&stp->st_perfile))
1494 list_del_init(&stp->st_perfile);
1496 list_del(&stp->st_perstateowner);
1502 struct nfs4_ol_stateid *stp = openlockstateid(stid);
1504 put_clnt_odstate(stp->st_clnt_odstate);
1505 release_all_access(stp);
1506 if (stp->st_stateowner)
1507 nfs4_put_stateowner(stp->st_stateowner);
1514 struct nfs4_ol_stateid *stp = openlockstateid(stid);
1515 struct nfs4_lockowner *lo = lockowner(stp->st_stateowner);
1518 nf = find_any_file(stp->st_stid.sc_file);
1532 static void put_ol_stateid_locked(struct nfs4_ol_stateid *stp,
1535 struct nfs4_stid *s = &stp->st_stid;
1540 WARN_ON_ONCE(!list_empty(&stp->st_locks));
1550 list_add(&stp->st_locks, reaplist);
1553 static bool unhash_lock_stateid(struct nfs4_ol_stateid *stp)
1555 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock);
1557 if (!unhash_ol_stateid(stp))
1559 list_del_init(&stp->st_locks);
1560 stp->st_stid.sc_status |= SC_STATUS_CLOSED;
1564 static void release_lock_stateid(struct nfs4_ol_stateid *stp)
1566 struct nfs4_client *clp = stp->st_stid.sc_client;
1570 unhashed = unhash_lock_stateid(stp);
1573 nfs4_put_stid(&stp->st_stid);
1592 struct nfs4_ol_stateid *stp;
1598 stp = list_first_entry(reaplist, struct nfs4_ol_stateid,
1600 list_del(&stp->st_locks);
1601 fp = stp->st_stid.sc_file;
1602 stp->st_stid.sc_free(&stp->st_stid);
1611 struct nfs4_ol_stateid *stp;
1616 stp = list_entry(open_stp->st_locks.next,
1618 unhash_lock_stateid(stp);
1619 put_ol_stateid_locked(stp, reaplist);
1623 static bool unhash_open_stateid(struct nfs4_ol_stateid *stp,
1626 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock);
1628 if (!unhash_ol_stateid(stp))
1630 release_open_stateid_locks(stp, reaplist);
1634 static void release_open_stateid(struct nfs4_ol_stateid *stp)
1638 spin_lock(&stp->st_stid.sc_client->cl_lock);
1639 stp->st_stid.sc_status |= SC_STATUS_CLOSED;
1640 if (unhash_open_stateid(stp, &reaplist))
1641 put_ol_stateid_locked(stp, &reaplist);
1642 spin_unlock(&stp->st_stid.sc_client->cl_lock);
1683 struct nfs4_ol_stateid *stp;
1690 stp = list_first_entry(&oo->oo_owner.so_stateids,
1692 if (unhash_open_stateid(stp, &reaplist))
1693 put_ol_stateid_locked(stp, &reaplist);
1751 struct nfs4_ol_stateid *stp;
1758 stp = openlockstateid(stid);
1759 mutex_lock_nested(&stp->st_mutex,
1768 release_all_access(stp);
1771 mutex_unlock(&stp->st_mutex);
1774 stp = openlockstateid(stid);
1775 mutex_lock_nested(&stp->st_mutex,
1780 lockowner(stp->st_stateowner);
1787 nf = find_any_file(stp->st_stid.sc_file);
1794 release_all_access(stp);
1797 mutex_unlock(&stp->st_mutex);
4981 struct nfs4_ol_stateid *stp;
4987 stp = openlockstateid(s);
4988 if (unhash_open_stateid(stp, &reaplist))
4989 put_ol_stateid_locked(stp, &reaplist);
4994 stp = openlockstateid(s);
4995 unhashed = unhash_lock_stateid(stp);
5050 nfsd4_lock_ol_stateid(struct nfs4_ol_stateid *stp)
5054 mutex_lock_nested(&stp->st_mutex, LOCK_STATEID_MUTEX);
5055 ret = nfsd4_verify_open_stid(&stp->st_stid);
5057 nfsd40_drop_revoked_stid(stp->st_stid.sc_client,
5058 &stp->st_stid.sc_stateid);
5061 mutex_unlock(&stp->st_mutex);
5068 struct nfs4_ol_stateid *stp;
5071 stp = nfsd4_find_existing_open(fp, open);
5073 if (!stp || nfsd4_lock_ol_stateid(stp) == nfs_ok)
5075 nfs4_put_stid(&stp->st_stid);
5077 return stp;
5129 struct nfs4_ol_stateid *stp;
5131 stp = open->op_stp;
5133 mutex_init(&stp->st_mutex);
5134 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX);
5141 mutex_unlock(&stp->st_mutex);
5142 stp = NULL;
5151 refcount_inc(&stp->st_stid.sc_count);
5152 stp->st_stid.sc_type = SC_TYPE_OPEN;
5153 INIT_LIST_HEAD(&stp->st_locks);
5154 stp->st_stateowner = nfs4_get_stateowner(&oo->oo_owner);
5156 stp->st_stid.sc_file = fp;
5157 stp->st_access_bmap = 0;
5158 stp->st_deny_bmap = 0;
5159 stp->st_openstp = NULL;
5160 list_add(&stp->st_perstateowner, &oo->oo_owner.so_stateids);
5161 list_add(&stp->st_perfile, &fp->fi_stateids);
5173 mutex_unlock(&stp->st_mutex);
5174 stp = retstp;
5176 return stp;
5710 struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp,
5732 stp, open->op_share_deny, false))
5746 stp, open->op_share_access, true))
5753 old_access_bmap = stp->st_access_bmap;
5754 set_access(open->op_share_access, stp);
5757 old_deny_bmap = stp->st_deny_bmap;
5758 set_deny(open->op_share_deny, stp);
5790 stp->st_access_bmap = old_access_bmap;
5792 reset_union_bmap_deny(bmap_to_share_mode(old_deny_bmap), stp);
5798 struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp,
5802 unsigned char old_deny_bmap = stp->st_deny_bmap;
5804 if (!test_access(open->op_share_access, stp))
5805 return nfs4_get_vfs_file(rqstp, fp, cur_fh, stp, open, false);
5812 set_deny(open->op_share_deny, stp);
5818 stp, open->op_share_deny, false))
5829 reset_union_bmap_deny(old_deny_bmap, stp);
5979 nfs4_set_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp,
5983 struct nfs4_client *clp = stp->st_stid.sc_client;
5984 struct nfs4_file *fp = stp->st_stid.sc_file;
5985 struct nfs4_clnt_odstate *odstate = stp->st_clnt_odstate;
6175 struct svc_fh *fh, struct nfs4_ol_stateid *stp)
6184 fp = stp->st_stid.sc_file;
6187 fp = stp->st_stid.sc_file;
6221 struct nfs4_ol_stateid *stp, struct svc_fh *currentfh,
6224 struct nfs4_openowner *oo = openowner(stp->st_stateowner);
6226 struct nfs4_client *clp = stp->st_stid.sc_client;
6260 dp = nfs4_set_delegation(open, stp, parent);
6267 if (!nfsd4_add_rdaccess_to_wrdeleg(rqstp, open, fh, stp) ||
6346 struct nfs4_ol_stateid *stp = NULL;
6377 stp = nfsd4_find_and_lock_existing_open(fp, open);
6385 if (!stp) {
6386 stp = init_open_stateid(fp, open);
6387 if (!stp) {
6400 * stp is already locked.
6404 status = nfs4_upgrade_open(rqstp, fp, current_fh, stp, open);
6406 mutex_unlock(&stp->st_mutex);
6410 status = nfs4_get_vfs_file(rqstp, fp, current_fh, stp, open, true);
6412 release_open_stateid(stp);
6413 mutex_unlock(&stp->st_mutex);
6417 stp->st_clnt_odstate = find_or_hash_clnt_odstate(fp,
6419 if (stp->st_clnt_odstate == open->op_odstate)
6423 nfs4_inc_and_copy_stateid(&open->op_stateid, &stp->st_stid);
6424 mutex_unlock(&stp->st_mutex);
6438 nfs4_open_delegation(rqstp, open, stp,
6449 release_open_stateid(stp);
6453 trace_nfsd_open(&stp->st_stid.sc_stateid);
6475 if (stp)
6476 nfs4_put_stid(&stp->st_stid);
6655 struct nfs4_ol_stateid *stp;
6658 list_for_each_entry(stp, &lo->lo_owner.so_stateids, st_perstateowner) {
6659 nf = stp->st_stid.sc_file;
6814 struct nfs4_ol_stateid *stp;
6869 stp = oo->oo_last_closed_stid;
6872 nfs4_put_stid(&stp->st_stid);
6984 static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stid *stp)
6986 if (!fh_match(&fhp->fh_handle, &stp->sc_file->fi_fhandle))
6992 __be32 nfs4_check_openmode(struct nfs4_ol_stateid *stp, int flags)
6997 if (stp->st_openstp)
6998 stp = stp->st_openstp;
6999 if ((flags & WR_STATE) && !access_permit_write(stp))
7001 if ((flags & RD_STATE) && !access_permit_read(stp))
7402 struct nfs4_ol_stateid *stp = openlockstateid(s);
7405 ret = nfsd4_lock_ol_stateid(stp);
7414 if (check_for_locks(stp->st_stid.sc_file,
7415 lockowner(stp->st_stateowner)))
7418 release_lock_stateid(stp);
7422 mutex_unlock(&stp->st_mutex);
7492 static __be32 nfs4_seqid_op_checks(struct nfsd4_compound_state *cstate, stateid_t *stateid, u32 seqid, struct nfs4_ol_stateid *stp)
7495 struct nfs4_stateowner *sop = stp->st_stateowner;
7501 status = nfsd4_lock_ol_stateid(stp);
7504 status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate));
7506 status = nfs4_check_fh(current_fh, &stp->st_stid);
7508 mutex_unlock(&stp->st_mutex);
7535 struct nfs4_ol_stateid *stp = NULL;
7545 stp = openlockstateid(s);
7546 if (nfsd4_cstate_assign_replay(cstate, stp->st_stateowner) == -EAGAIN) {
7547 nfs4_put_stateowner(stp->st_stateowner);
7551 status = nfs4_seqid_op_checks(cstate, stateid, seqid, stp);
7553 *stpp = stp;
7555 nfs4_put_stid(&stp->st_stid);
7564 struct nfs4_ol_stateid *stp;
7567 SC_TYPE_OPEN, 0, &stp, nn);
7570 oo = openowner(stp->st_stateowner);
7572 mutex_unlock(&stp->st_mutex);
7573 nfs4_put_stid(&stp->st_stid);
7576 *stpp = stp;
7587 struct nfs4_ol_stateid *stp;
7599 SC_TYPE_OPEN, 0, &stp, nn);
7602 oo = openowner(stp->st_stateowner);
7605 mutex_unlock(&stp->st_mutex);
7609 nfs4_inc_and_copy_stateid(&oc->oc_resp_stateid, &stp->st_stid);
7610 mutex_unlock(&stp->st_mutex);
7611 trace_nfsd_open_confirm(oc->oc_seqid, &stp->st_stid.sc_stateid);
7615 nfs4_put_stid(&stp->st_stid);
7621 static inline void nfs4_stateid_downgrade_bit(struct nfs4_ol_stateid *stp, u32 access)
7623 if (!test_access(access, stp))
7625 nfs4_file_put_access(stp->st_stid.sc_file, access);
7626 clear_access(access, stp);
7629 static inline void nfs4_stateid_downgrade(struct nfs4_ol_stateid *stp, u32 to_access)
7633 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_WRITE);
7634 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH);
7637 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_READ);
7638 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH);
7653 struct nfs4_ol_stateid *stp;
7665 &od->od_stateid, &stp, nn);
7669 if (!test_access(od->od_share_access, stp)) {
7671 stp->st_access_bmap, od->od_share_access);
7674 if (!test_deny(od->od_share_deny, stp)) {
7676 stp->st_deny_bmap, od->od_share_deny);
7679 nfs4_stateid_downgrade(stp, od->od_share_access);
7680 reset_union_bmap_deny(od->od_share_deny, stp);
7681 nfs4_inc_and_copy_stateid(&od->od_stateid, &stp->st_stid);
7684 mutex_unlock(&stp->st_mutex);
7685 nfs4_put_stid(&stp->st_stid);
7696 struct nfs4_ol_stateid *stp;
7705 list_for_each_entry(stp, &reaplist, st_locks)
7706 nfs4_free_cpntf_statelist(clp->net, &stp->st_stid);
7725 struct nfs4_ol_stateid *stp;
7736 &stp, nn);
7741 spin_lock(&stp->st_stid.sc_client->cl_lock);
7742 stp->st_stid.sc_status |= SC_STATUS_CLOSED;
7743 spin_unlock(&stp->st_stid.sc_client->cl_lock);
7751 nfs4_inc_and_copy_stateid(&close->cl_stateid, &stp->st_stid);
7753 need_move_to_close_list = nfsd4_close_open_stateid(stp);
7754 mutex_unlock(&stp->st_mutex);
7756 move_to_close_lru(stp, net);
7768 nfs4_put_stid(&stp->st_stid);
8038 init_lock_stateid(struct nfs4_ol_stateid *stp, struct nfs4_lockowner *lo,
8045 mutex_init(&stp->st_mutex);
8046 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX);
8054 refcount_inc(&stp->st_stid.sc_count);
8055 stp->st_stid.sc_type = SC_TYPE_LOCK;
8056 stp->st_stateowner = nfs4_get_stateowner(&lo->lo_owner);
8058 stp->st_stid.sc_file = fp;
8059 stp->st_access_bmap = 0;
8060 stp->st_deny_bmap = open_stp->st_deny_bmap;
8061 stp->st_openstp = open_stp;
8063 list_add(&stp->st_locks, &open_stp->st_locks);
8064 list_add(&stp->st_perstateowner, &lo->lo_owner.so_stateids);
8065 list_add(&stp->st_perfile, &fp->fi_stateids);
8068 return stp;
8076 mutex_unlock(&stp->st_mutex);
8080 mutex_unlock(&stp->st_mutex);
8532 struct nfs4_ol_stateid *stp;
8548 &stp, nn);
8551 nf = find_any_file(stp->st_stid.sc_file);
8569 file_lock->c.flc_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(stp->st_stateowner));
8585 nfs4_inc_and_copy_stateid(&locku->lu_stateid, &stp->st_stid);
8589 mutex_unlock(&stp->st_mutex);
8590 nfs4_put_stid(&stp->st_stid);
8665 struct nfs4_ol_stateid *stp;
8686 list_for_each_entry(stp, &lo->lo_owner.so_stateids, st_perstateowner) {
8687 if (check_for_locks(stp->st_stid.sc_file, lo)) {
8695 stp = list_first_entry(&lo->lo_owner.so_stateids,
8698 unhash_lock_stateid(stp);
8699 put_ol_stateid_locked(stp, &reaplist);