Lines Matching refs:stp

598 	struct nfs4_ol_stateid *stp;  in nfs4_alloc_open_stateid()  local
604 stp = openlockstateid(stid); in nfs4_alloc_open_stateid()
605 stp->st_stid.sc_free = nfs4_free_ol_stateid; in nfs4_alloc_open_stateid()
606 return stp; in nfs4_alloc_open_stateid()
945 set_access(u32 access, struct nfs4_ol_stateid *stp) in set_access() argument
950 stp->st_access_bmap |= mask; in set_access()
955 clear_access(u32 access, struct nfs4_ol_stateid *stp) in clear_access() argument
960 stp->st_access_bmap &= ~mask; in clear_access()
965 test_access(u32 access, struct nfs4_ol_stateid *stp) in test_access() argument
969 return (bool)(stp->st_access_bmap & mask); in test_access()
974 set_deny(u32 deny, struct nfs4_ol_stateid *stp) in set_deny() argument
979 stp->st_deny_bmap |= mask; in set_deny()
984 clear_deny(u32 deny, struct nfs4_ol_stateid *stp) in clear_deny() argument
989 stp->st_deny_bmap &= ~mask; in clear_deny()
994 test_deny(u32 deny, struct nfs4_ol_stateid *stp) in test_deny() argument
998 return (bool)(stp->st_deny_bmap & mask); in test_deny()
1022 struct nfs4_ol_stateid *stp; in recalculate_deny_mode() local
1026 list_for_each_entry(stp, &fp->fi_stateids, st_perfile) in recalculate_deny_mode()
1027 fp->fi_share_deny |= bmap_to_share_mode(stp->st_deny_bmap); in recalculate_deny_mode()
1032 reset_union_bmap_deny(u32 deny, struct nfs4_ol_stateid *stp) in reset_union_bmap_deny() argument
1040 clear_deny(i, stp); in reset_union_bmap_deny()
1046 recalculate_deny_mode(stp->st_stid.sc_file); in reset_union_bmap_deny()
1051 release_all_access(struct nfs4_ol_stateid *stp) in release_all_access() argument
1054 struct nfs4_file *fp = stp->st_stid.sc_file; in release_all_access()
1056 if (fp && stp->st_deny_bmap != 0) in release_all_access()
1060 if (test_access(i, stp)) in release_all_access()
1061 nfs4_file_put_access(stp->st_stid.sc_file, i); in release_all_access()
1062 clear_access(i, stp); in release_all_access()
1085 static bool unhash_ol_stateid(struct nfs4_ol_stateid *stp) in unhash_ol_stateid() argument
1087 struct nfs4_file *fp = stp->st_stid.sc_file; in unhash_ol_stateid()
1089 lockdep_assert_held(&stp->st_stateowner->so_client->cl_lock); in unhash_ol_stateid()
1091 if (list_empty(&stp->st_perfile)) in unhash_ol_stateid()
1095 list_del_init(&stp->st_perfile); in unhash_ol_stateid()
1097 list_del(&stp->st_perstateowner); in unhash_ol_stateid()
1103 struct nfs4_ol_stateid *stp = openlockstateid(stid); in nfs4_free_ol_stateid() local
1105 put_clnt_odstate(stp->st_clnt_odstate); in nfs4_free_ol_stateid()
1106 release_all_access(stp); in nfs4_free_ol_stateid()
1107 if (stp->st_stateowner) in nfs4_free_ol_stateid()
1108 nfs4_put_stateowner(stp->st_stateowner); in nfs4_free_ol_stateid()
1114 struct nfs4_ol_stateid *stp = openlockstateid(stid); in nfs4_free_lock_stateid() local
1115 struct nfs4_lockowner *lo = lockowner(stp->st_stateowner); in nfs4_free_lock_stateid()
1118 file = find_any_file(stp->st_stid.sc_file); in nfs4_free_lock_stateid()
1129 static void put_ol_stateid_locked(struct nfs4_ol_stateid *stp, in put_ol_stateid_locked() argument
1132 struct nfs4_stid *s = &stp->st_stid; in put_ol_stateid_locked()
1137 WARN_ON_ONCE(!list_empty(&stp->st_locks)); in put_ol_stateid_locked()
1145 list_add(&stp->st_locks, reaplist); in put_ol_stateid_locked()
1148 static bool unhash_lock_stateid(struct nfs4_ol_stateid *stp) in unhash_lock_stateid() argument
1150 struct nfs4_openowner *oo = openowner(stp->st_openstp->st_stateowner); in unhash_lock_stateid()
1154 list_del_init(&stp->st_locks); in unhash_lock_stateid()
1155 nfs4_unhash_stid(&stp->st_stid); in unhash_lock_stateid()
1156 return unhash_ol_stateid(stp); in unhash_lock_stateid()
1159 static void release_lock_stateid(struct nfs4_ol_stateid *stp) in release_lock_stateid() argument
1161 struct nfs4_openowner *oo = openowner(stp->st_openstp->st_stateowner); in release_lock_stateid()
1165 unhashed = unhash_lock_stateid(stp); in release_lock_stateid()
1168 nfs4_put_stid(&stp->st_stid); in release_lock_stateid()
1187 struct nfs4_ol_stateid *stp; in free_ol_stateid_reaplist() local
1193 stp = list_first_entry(reaplist, struct nfs4_ol_stateid, in free_ol_stateid_reaplist()
1195 list_del(&stp->st_locks); in free_ol_stateid_reaplist()
1196 fp = stp->st_stid.sc_file; in free_ol_stateid_reaplist()
1197 stp->st_stid.sc_free(&stp->st_stid); in free_ol_stateid_reaplist()
1206 struct nfs4_ol_stateid *stp; in release_lockowner() local
1214 stp = list_first_entry(&lo->lo_owner.so_stateids, in release_lockowner()
1216 WARN_ON(!unhash_lock_stateid(stp)); in release_lockowner()
1217 put_ol_stateid_locked(stp, &reaplist); in release_lockowner()
1227 struct nfs4_ol_stateid *stp; in release_open_stateid_locks() local
1232 stp = list_entry(open_stp->st_locks.next, in release_open_stateid_locks()
1234 WARN_ON(!unhash_lock_stateid(stp)); in release_open_stateid_locks()
1235 put_ol_stateid_locked(stp, reaplist); in release_open_stateid_locks()
1239 static bool unhash_open_stateid(struct nfs4_ol_stateid *stp, in unhash_open_stateid() argument
1244 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock); in unhash_open_stateid()
1246 unhashed = unhash_ol_stateid(stp); in unhash_open_stateid()
1247 release_open_stateid_locks(stp, reaplist); in unhash_open_stateid()
1251 static void release_open_stateid(struct nfs4_ol_stateid *stp) in release_open_stateid() argument
1255 spin_lock(&stp->st_stid.sc_client->cl_lock); in release_open_stateid()
1256 if (unhash_open_stateid(stp, &reaplist)) in release_open_stateid()
1257 put_ol_stateid_locked(stp, &reaplist); in release_open_stateid()
1258 spin_unlock(&stp->st_stid.sc_client->cl_lock); in release_open_stateid()
1291 struct nfs4_ol_stateid *stp; in release_openowner() local
1300 stp = list_first_entry(&oo->oo_owner.so_stateids, in release_openowner()
1302 if (unhash_open_stateid(stp, &reaplist)) in release_openowner()
1303 put_ol_stateid_locked(stp, &reaplist); in release_openowner()
3448 init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_file *fp, in init_open_stateid() argument
3461 atomic_inc(&stp->st_stid.sc_count); in init_open_stateid()
3462 stp->st_stid.sc_type = NFS4_OPEN_STID; in init_open_stateid()
3463 INIT_LIST_HEAD(&stp->st_locks); in init_open_stateid()
3464 stp->st_stateowner = nfs4_get_stateowner(&oo->oo_owner); in init_open_stateid()
3466 stp->st_stid.sc_file = fp; in init_open_stateid()
3467 stp->st_access_bmap = 0; in init_open_stateid()
3468 stp->st_deny_bmap = 0; in init_open_stateid()
3469 stp->st_openstp = NULL; in init_open_stateid()
3470 init_rwsem(&stp->st_rwsem); in init_open_stateid()
3471 list_add(&stp->st_perstateowner, &oo->oo_owner.so_stateids); in init_open_stateid()
3472 list_add(&stp->st_perfile, &fp->fi_stateids); in init_open_stateid()
3915 struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, in nfs4_get_vfs_file() argument
3944 old_access_bmap = stp->st_access_bmap; in nfs4_get_vfs_file()
3945 set_access(open->op_share_access, stp); in nfs4_get_vfs_file()
3948 old_deny_bmap = stp->st_deny_bmap; in nfs4_get_vfs_file()
3949 set_deny(open->op_share_deny, stp); in nfs4_get_vfs_file()
3973 stp->st_access_bmap = old_access_bmap; in nfs4_get_vfs_file()
3975 reset_union_bmap_deny(bmap_to_share_mode(old_deny_bmap), stp); in nfs4_get_vfs_file()
3980 …qstp, struct nfs4_file *fp, struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, struct nfsd4_open … in nfs4_upgrade_open() argument
3983 unsigned char old_deny_bmap = stp->st_deny_bmap; in nfs4_upgrade_open()
3985 if (!test_access(open->op_share_access, stp)) in nfs4_upgrade_open()
3986 return nfs4_get_vfs_file(rqstp, fp, cur_fh, stp, open); in nfs4_upgrade_open()
3992 set_deny(open->op_share_deny, stp); in nfs4_upgrade_open()
4003 reset_union_bmap_deny(old_deny_bmap, stp); in nfs4_upgrade_open()
4180 struct nfs4_ol_stateid *stp) in nfs4_open_delegation() argument
4183 struct nfs4_openowner *oo = openowner(stp->st_stateowner); in nfs4_open_delegation()
4184 struct nfs4_client *clp = stp->st_stid.sc_client; in nfs4_open_delegation()
4223 dp = nfs4_set_delegation(clp, fh, stp->st_stid.sc_file, stp->st_clnt_odstate); in nfs4_open_delegation()
4272 struct nfs4_ol_stateid *stp = NULL; in nfsd4_process_open2() local
4288 stp = nfsd4_find_existing_open(fp, open); in nfsd4_process_open2()
4301 if (stp) { in nfsd4_process_open2()
4303 down_read(&stp->st_rwsem); in nfsd4_process_open2()
4304 status = nfs4_upgrade_open(rqstp, fp, current_fh, stp, open); in nfsd4_process_open2()
4306 up_read(&stp->st_rwsem); in nfsd4_process_open2()
4310 stp = open->op_stp; in nfsd4_process_open2()
4312 swapstp = init_open_stateid(stp, fp, open); in nfsd4_process_open2()
4314 nfs4_put_stid(&stp->st_stid); in nfsd4_process_open2()
4315 stp = swapstp; in nfsd4_process_open2()
4316 down_read(&stp->st_rwsem); in nfsd4_process_open2()
4318 stp, open); in nfsd4_process_open2()
4320 up_read(&stp->st_rwsem); in nfsd4_process_open2()
4325 down_read(&stp->st_rwsem); in nfsd4_process_open2()
4326 status = nfs4_get_vfs_file(rqstp, fp, current_fh, stp, open); in nfsd4_process_open2()
4328 up_read(&stp->st_rwsem); in nfsd4_process_open2()
4329 release_open_stateid(stp); in nfsd4_process_open2()
4333 stp->st_clnt_odstate = find_or_hash_clnt_odstate(fp, in nfsd4_process_open2()
4335 if (stp->st_clnt_odstate == open->op_odstate) in nfsd4_process_open2()
4339 nfs4_inc_and_copy_stateid(&open->op_stateid, &stp->st_stid); in nfsd4_process_open2()
4340 up_read(&stp->st_rwsem); in nfsd4_process_open2()
4354 nfs4_open_delegation(current_fh, open, stp); in nfsd4_process_open2()
4359 STATEID_VAL(&stp->st_stid.sc_stateid)); in nfsd4_process_open2()
4379 if (stp) in nfsd4_process_open2()
4380 nfs4_put_stid(&stp->st_stid); in nfsd4_process_open2()
4464 struct nfs4_ol_stateid *stp; in nfs4_laundromat() local
4525 stp = oo->oo_last_closed_stid; in nfs4_laundromat()
4528 nfs4_put_stid(&stp->st_stid); in nfs4_laundromat()
4554 static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stid *stp) in nfs4_check_fh() argument
4556 if (!fh_match(&fhp->fh_handle, &stp->sc_file->fi_fhandle)) in nfs4_check_fh()
4562 access_permit_read(struct nfs4_ol_stateid *stp) in access_permit_read() argument
4564 return test_access(NFS4_SHARE_ACCESS_READ, stp) || in access_permit_read()
4565 test_access(NFS4_SHARE_ACCESS_BOTH, stp) || in access_permit_read()
4566 test_access(NFS4_SHARE_ACCESS_WRITE, stp); in access_permit_read()
4570 access_permit_write(struct nfs4_ol_stateid *stp) in access_permit_write() argument
4572 return test_access(NFS4_SHARE_ACCESS_WRITE, stp) || in access_permit_write()
4573 test_access(NFS4_SHARE_ACCESS_BOTH, stp); in access_permit_write()
4577 __be32 nfs4_check_openmode(struct nfs4_ol_stateid *stp, int flags) in nfs4_check_openmode() argument
4582 if (stp->st_openstp) in nfs4_check_openmode()
4583 stp = stp->st_openstp; in nfs4_check_openmode()
4584 if ((flags & WR_STATE) && !access_permit_write(stp)) in nfs4_check_openmode()
4586 if ((flags & RD_STATE) && !access_permit_read(stp)) in nfs4_check_openmode()
4882 struct nfs4_ol_stateid *stp; in nfsd4_free_stateid() local
4904 stp = openlockstateid(s); in nfsd4_free_stateid()
4906 if (check_for_locks(stp->st_stid.sc_file, in nfsd4_free_stateid()
4907 lockowner(stp->st_stateowner))) in nfsd4_free_stateid()
4909 WARN_ON(!unhash_lock_stateid(stp)); in nfsd4_free_stateid()
4936 …ks(struct nfsd4_compound_state *cstate, stateid_t *stateid, u32 seqid, struct nfs4_ol_stateid *stp) in nfs4_seqid_op_checks() argument
4939 struct nfs4_stateowner *sop = stp->st_stateowner; in nfs4_seqid_op_checks()
4945 if (stp->st_stid.sc_type == NFS4_CLOSED_STID in nfs4_seqid_op_checks()
4946 || stp->st_stid.sc_type == NFS4_REVOKED_DELEG_STID) in nfs4_seqid_op_checks()
4953 down_write(&stp->st_rwsem); in nfs4_seqid_op_checks()
4954 status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate)); in nfs4_seqid_op_checks()
4956 status = nfs4_check_fh(current_fh, &stp->st_stid); in nfs4_seqid_op_checks()
4958 up_write(&stp->st_rwsem); in nfs4_seqid_op_checks()
4973 struct nfs4_ol_stateid *stp = NULL; in nfs4_preprocess_seqid_op() local
4982 stp = openlockstateid(s); in nfs4_preprocess_seqid_op()
4983 nfsd4_cstate_assign_replay(cstate, stp->st_stateowner); in nfs4_preprocess_seqid_op()
4985 status = nfs4_seqid_op_checks(cstate, stateid, seqid, stp); in nfs4_preprocess_seqid_op()
4987 *stpp = stp; in nfs4_preprocess_seqid_op()
4989 nfs4_put_stid(&stp->st_stid); in nfs4_preprocess_seqid_op()
4998 struct nfs4_ol_stateid *stp; in nfs4_preprocess_confirmed_seqid_op() local
5001 NFS4_OPEN_STID, &stp, nn); in nfs4_preprocess_confirmed_seqid_op()
5004 oo = openowner(stp->st_stateowner); in nfs4_preprocess_confirmed_seqid_op()
5006 up_write(&stp->st_rwsem); in nfs4_preprocess_confirmed_seqid_op()
5007 nfs4_put_stid(&stp->st_stid); in nfs4_preprocess_confirmed_seqid_op()
5010 *stpp = stp; in nfs4_preprocess_confirmed_seqid_op()
5020 struct nfs4_ol_stateid *stp; in nfsd4_open_confirm() local
5032 NFS4_OPEN_STID, &stp, nn); in nfsd4_open_confirm()
5035 oo = openowner(stp->st_stateowner); in nfsd4_open_confirm()
5038 up_write(&stp->st_rwsem); in nfsd4_open_confirm()
5042 nfs4_inc_and_copy_stateid(&oc->oc_resp_stateid, &stp->st_stid); in nfsd4_open_confirm()
5043 up_write(&stp->st_rwsem); in nfsd4_open_confirm()
5045 __func__, oc->oc_seqid, STATEID_VAL(&stp->st_stid.sc_stateid)); in nfsd4_open_confirm()
5050 nfs4_put_stid(&stp->st_stid); in nfsd4_open_confirm()
5056 static inline void nfs4_stateid_downgrade_bit(struct nfs4_ol_stateid *stp, u32 access) in nfs4_stateid_downgrade_bit() argument
5058 if (!test_access(access, stp)) in nfs4_stateid_downgrade_bit()
5060 nfs4_file_put_access(stp->st_stid.sc_file, access); in nfs4_stateid_downgrade_bit()
5061 clear_access(access, stp); in nfs4_stateid_downgrade_bit()
5064 static inline void nfs4_stateid_downgrade(struct nfs4_ol_stateid *stp, u32 to_access) in nfs4_stateid_downgrade() argument
5068 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_WRITE); in nfs4_stateid_downgrade()
5069 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH); in nfs4_stateid_downgrade()
5072 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_READ); in nfs4_stateid_downgrade()
5073 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH); in nfs4_stateid_downgrade()
5088 struct nfs4_ol_stateid *stp; in nfsd4_open_downgrade() local
5100 &od->od_stateid, &stp, nn); in nfsd4_open_downgrade()
5104 if (!test_access(od->od_share_access, stp)) { in nfsd4_open_downgrade()
5106 stp->st_access_bmap, od->od_share_access); in nfsd4_open_downgrade()
5109 if (!test_deny(od->od_share_deny, stp)) { in nfsd4_open_downgrade()
5111 stp->st_deny_bmap, od->od_share_deny); in nfsd4_open_downgrade()
5114 nfs4_stateid_downgrade(stp, od->od_share_access); in nfsd4_open_downgrade()
5115 reset_union_bmap_deny(od->od_share_deny, stp); in nfsd4_open_downgrade()
5116 nfs4_inc_and_copy_stateid(&od->od_stateid, &stp->st_stid); in nfsd4_open_downgrade()
5119 up_write(&stp->st_rwsem); in nfsd4_open_downgrade()
5120 nfs4_put_stid(&stp->st_stid); in nfsd4_open_downgrade()
5157 struct nfs4_ol_stateid *stp; in nfsd4_close() local
5167 &stp, nn); in nfsd4_close()
5171 nfs4_inc_and_copy_stateid(&close->cl_stateid, &stp->st_stid); in nfsd4_close()
5172 up_write(&stp->st_rwsem); in nfsd4_close()
5174 nfsd4_close_open_stateid(stp); in nfsd4_close()
5177 nfs4_put_stid(&stp->st_stid); in nfsd4_close()
5381 init_lock_stateid(struct nfs4_ol_stateid *stp, struct nfs4_lockowner *lo, in init_lock_stateid() argument
5389 atomic_inc(&stp->st_stid.sc_count); in init_lock_stateid()
5390 stp->st_stid.sc_type = NFS4_LOCK_STID; in init_lock_stateid()
5391 stp->st_stateowner = nfs4_get_stateowner(&lo->lo_owner); in init_lock_stateid()
5393 stp->st_stid.sc_file = fp; in init_lock_stateid()
5394 stp->st_stid.sc_free = nfs4_free_lock_stateid; in init_lock_stateid()
5395 stp->st_access_bmap = 0; in init_lock_stateid()
5396 stp->st_deny_bmap = open_stp->st_deny_bmap; in init_lock_stateid()
5397 stp->st_openstp = open_stp; in init_lock_stateid()
5398 init_rwsem(&stp->st_rwsem); in init_lock_stateid()
5399 list_add(&stp->st_locks, &open_stp->st_locks); in init_lock_stateid()
5400 list_add(&stp->st_perstateowner, &lo->lo_owner.so_stateids); in init_lock_stateid()
5402 list_add(&stp->st_perfile, &fp->fi_stateids); in init_lock_stateid()
5798 struct nfs4_ol_stateid *stp; in nfsd4_locku() local
5814 &stp, nn); in nfsd4_locku()
5817 filp = find_any_file(stp->st_stid.sc_file); in nfsd4_locku()
5830 file_lock->fl_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(stp->st_stateowner)); in nfsd4_locku()
5846 nfs4_inc_and_copy_stateid(&locku->lu_stateid, &stp->st_stid); in nfsd4_locku()
5850 up_write(&stp->st_rwsem); in nfsd4_locku()
5851 nfs4_put_stid(&stp->st_stid); in nfsd4_locku()
5908 struct nfs4_ol_stateid *stp; in nfsd4_release_lockowner() local
5933 list_for_each_entry(stp, &sop->so_stateids, st_perstateowner) { in nfsd4_release_lockowner()
5934 if (check_for_locks(stp->st_stid.sc_file, lo)) { in nfsd4_release_lockowner()
6185 struct nfs4_ol_stateid *stp, *st_next; in nfsd_foreach_client_lock() local
6191 list_for_each_entry_safe(stp, st_next, in nfsd_foreach_client_lock()
6194 &stp->st_locks, st_locks) { in nfsd_foreach_client_lock()
6258 struct nfs4_ol_stateid *stp, *next; in nfsd_reap_locks() local
6260 list_for_each_entry_safe(stp, next, reaplist, st_locks) { in nfsd_reap_locks()
6261 list_del_init(&stp->st_locks); in nfsd_reap_locks()
6262 clp = stp->st_stid.sc_client; in nfsd_reap_locks()
6263 nfs4_put_stid(&stp->st_stid); in nfsd_reap_locks()