Lines Matching refs:stp
597 struct nfs4_ol_stateid *stp; in nfs4_alloc_open_stateid() local
603 stp = openlockstateid(stid); in nfs4_alloc_open_stateid()
604 stp->st_stid.sc_free = nfs4_free_ol_stateid; in nfs4_alloc_open_stateid()
605 return stp; in nfs4_alloc_open_stateid()
932 set_access(u32 access, struct nfs4_ol_stateid *stp) in set_access() argument
937 stp->st_access_bmap |= mask; in set_access()
942 clear_access(u32 access, struct nfs4_ol_stateid *stp) in clear_access() argument
947 stp->st_access_bmap &= ~mask; in clear_access()
952 test_access(u32 access, struct nfs4_ol_stateid *stp) in test_access() argument
956 return (bool)(stp->st_access_bmap & mask); in test_access()
961 set_deny(u32 deny, struct nfs4_ol_stateid *stp) in set_deny() argument
966 stp->st_deny_bmap |= mask; in set_deny()
971 clear_deny(u32 deny, struct nfs4_ol_stateid *stp) in clear_deny() argument
976 stp->st_deny_bmap &= ~mask; in clear_deny()
981 test_deny(u32 deny, struct nfs4_ol_stateid *stp) in test_deny() argument
985 return (bool)(stp->st_deny_bmap & mask); in test_deny()
1009 struct nfs4_ol_stateid *stp; in recalculate_deny_mode() local
1013 list_for_each_entry(stp, &fp->fi_stateids, st_perfile) in recalculate_deny_mode()
1014 fp->fi_share_deny |= bmap_to_share_mode(stp->st_deny_bmap); in recalculate_deny_mode()
1019 reset_union_bmap_deny(u32 deny, struct nfs4_ol_stateid *stp) in reset_union_bmap_deny() argument
1027 clear_deny(i, stp); in reset_union_bmap_deny()
1033 recalculate_deny_mode(stp->st_stid.sc_file); in reset_union_bmap_deny()
1038 release_all_access(struct nfs4_ol_stateid *stp) in release_all_access() argument
1041 struct nfs4_file *fp = stp->st_stid.sc_file; in release_all_access()
1043 if (fp && stp->st_deny_bmap != 0) in release_all_access()
1047 if (test_access(i, stp)) in release_all_access()
1048 nfs4_file_put_access(stp->st_stid.sc_file, i); in release_all_access()
1049 clear_access(i, stp); in release_all_access()
1067 static bool unhash_ol_stateid(struct nfs4_ol_stateid *stp) in unhash_ol_stateid() argument
1069 struct nfs4_file *fp = stp->st_stid.sc_file; in unhash_ol_stateid()
1071 lockdep_assert_held(&stp->st_stateowner->so_client->cl_lock); in unhash_ol_stateid()
1073 if (list_empty(&stp->st_perfile)) in unhash_ol_stateid()
1077 list_del_init(&stp->st_perfile); in unhash_ol_stateid()
1079 list_del(&stp->st_perstateowner); in unhash_ol_stateid()
1085 struct nfs4_ol_stateid *stp = openlockstateid(stid); in nfs4_free_ol_stateid() local
1087 put_clnt_odstate(stp->st_clnt_odstate); in nfs4_free_ol_stateid()
1088 release_all_access(stp); in nfs4_free_ol_stateid()
1089 if (stp->st_stateowner) in nfs4_free_ol_stateid()
1090 nfs4_put_stateowner(stp->st_stateowner); in nfs4_free_ol_stateid()
1096 struct nfs4_ol_stateid *stp = openlockstateid(stid); in nfs4_free_lock_stateid() local
1097 struct nfs4_lockowner *lo = lockowner(stp->st_stateowner); in nfs4_free_lock_stateid()
1100 file = find_any_file(stp->st_stid.sc_file); in nfs4_free_lock_stateid()
1111 static void put_ol_stateid_locked(struct nfs4_ol_stateid *stp, in put_ol_stateid_locked() argument
1114 struct nfs4_stid *s = &stp->st_stid; in put_ol_stateid_locked()
1119 WARN_ON_ONCE(!list_empty(&stp->st_locks)); in put_ol_stateid_locked()
1127 list_add(&stp->st_locks, reaplist); in put_ol_stateid_locked()
1130 static bool unhash_lock_stateid(struct nfs4_ol_stateid *stp) in unhash_lock_stateid() argument
1132 struct nfs4_openowner *oo = openowner(stp->st_openstp->st_stateowner); in unhash_lock_stateid()
1136 list_del_init(&stp->st_locks); in unhash_lock_stateid()
1137 nfs4_unhash_stid(&stp->st_stid); in unhash_lock_stateid()
1138 return unhash_ol_stateid(stp); in unhash_lock_stateid()
1141 static void release_lock_stateid(struct nfs4_ol_stateid *stp) in release_lock_stateid() argument
1143 struct nfs4_openowner *oo = openowner(stp->st_openstp->st_stateowner); in release_lock_stateid()
1147 unhashed = unhash_lock_stateid(stp); in release_lock_stateid()
1150 nfs4_put_stid(&stp->st_stid); in release_lock_stateid()
1169 struct nfs4_ol_stateid *stp; in free_ol_stateid_reaplist() local
1175 stp = list_first_entry(reaplist, struct nfs4_ol_stateid, in free_ol_stateid_reaplist()
1177 list_del(&stp->st_locks); in free_ol_stateid_reaplist()
1178 fp = stp->st_stid.sc_file; in free_ol_stateid_reaplist()
1179 stp->st_stid.sc_free(&stp->st_stid); in free_ol_stateid_reaplist()
1188 struct nfs4_ol_stateid *stp; in release_lockowner() local
1196 stp = list_first_entry(&lo->lo_owner.so_stateids, in release_lockowner()
1198 WARN_ON(!unhash_lock_stateid(stp)); in release_lockowner()
1199 put_ol_stateid_locked(stp, &reaplist); in release_lockowner()
1209 struct nfs4_ol_stateid *stp; in release_open_stateid_locks() local
1214 stp = list_entry(open_stp->st_locks.next, in release_open_stateid_locks()
1216 WARN_ON(!unhash_lock_stateid(stp)); in release_open_stateid_locks()
1217 put_ol_stateid_locked(stp, reaplist); in release_open_stateid_locks()
1221 static bool unhash_open_stateid(struct nfs4_ol_stateid *stp, in unhash_open_stateid() argument
1226 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock); in unhash_open_stateid()
1228 unhashed = unhash_ol_stateid(stp); in unhash_open_stateid()
1229 release_open_stateid_locks(stp, reaplist); in unhash_open_stateid()
1233 static void release_open_stateid(struct nfs4_ol_stateid *stp) in release_open_stateid() argument
1237 spin_lock(&stp->st_stid.sc_client->cl_lock); in release_open_stateid()
1238 if (unhash_open_stateid(stp, &reaplist)) in release_open_stateid()
1239 put_ol_stateid_locked(stp, &reaplist); in release_open_stateid()
1240 spin_unlock(&stp->st_stid.sc_client->cl_lock); in release_open_stateid()
1273 struct nfs4_ol_stateid *stp; in release_openowner() local
1282 stp = list_first_entry(&oo->oo_owner.so_stateids, in release_openowner()
1284 if (unhash_open_stateid(stp, &reaplist)) in release_openowner()
1285 put_ol_stateid_locked(stp, &reaplist); in release_openowner()
3394 static void init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_file *fp, struct nfsd4_open … in init_open_stateid() argument
3397 atomic_inc(&stp->st_stid.sc_count); in init_open_stateid()
3398 stp->st_stid.sc_type = NFS4_OPEN_STID; in init_open_stateid()
3399 INIT_LIST_HEAD(&stp->st_locks); in init_open_stateid()
3400 stp->st_stateowner = nfs4_get_stateowner(&oo->oo_owner); in init_open_stateid()
3402 stp->st_stid.sc_file = fp; in init_open_stateid()
3403 stp->st_access_bmap = 0; in init_open_stateid()
3404 stp->st_deny_bmap = 0; in init_open_stateid()
3405 stp->st_openstp = NULL; in init_open_stateid()
3406 init_rwsem(&stp->st_rwsem); in init_open_stateid()
3408 list_add(&stp->st_perstateowner, &oo->oo_owner.so_stateids); in init_open_stateid()
3410 list_add(&stp->st_perfile, &fp->fi_stateids); in init_open_stateid()
3868 struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, in nfs4_get_vfs_file() argument
3897 old_access_bmap = stp->st_access_bmap; in nfs4_get_vfs_file()
3898 set_access(open->op_share_access, stp); in nfs4_get_vfs_file()
3901 old_deny_bmap = stp->st_deny_bmap; in nfs4_get_vfs_file()
3902 set_deny(open->op_share_deny, stp); in nfs4_get_vfs_file()
3926 stp->st_access_bmap = old_access_bmap; in nfs4_get_vfs_file()
3928 reset_union_bmap_deny(bmap_to_share_mode(old_deny_bmap), stp); in nfs4_get_vfs_file()
3933 …qstp, struct nfs4_file *fp, struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, struct nfsd4_open … in nfs4_upgrade_open() argument
3938 if (!test_access(open->op_share_access, stp)) in nfs4_upgrade_open()
3939 return nfs4_get_vfs_file(rqstp, fp, cur_fh, stp, open); in nfs4_upgrade_open()
3945 old_deny_bmap = stp->st_deny_bmap; in nfs4_upgrade_open()
3946 set_deny(open->op_share_deny, stp); in nfs4_upgrade_open()
3957 reset_union_bmap_deny(old_deny_bmap, stp); in nfs4_upgrade_open()
4140 struct nfs4_ol_stateid *stp) in nfs4_open_delegation() argument
4143 struct nfs4_openowner *oo = openowner(stp->st_stateowner); in nfs4_open_delegation()
4144 struct nfs4_client *clp = stp->st_stid.sc_client; in nfs4_open_delegation()
4182 dp = nfs4_set_delegation(clp, fh, stp->st_stid.sc_file, stp->st_clnt_odstate); in nfs4_open_delegation()
4231 struct nfs4_ol_stateid *stp = NULL; in nfsd4_process_open2() local
4245 stp = nfsd4_find_existing_open(fp, open); in nfsd4_process_open2()
4257 if (stp) { in nfsd4_process_open2()
4259 down_read(&stp->st_rwsem); in nfsd4_process_open2()
4260 status = nfs4_upgrade_open(rqstp, fp, current_fh, stp, open); in nfsd4_process_open2()
4262 up_read(&stp->st_rwsem); in nfsd4_process_open2()
4266 stp = open->op_stp; in nfsd4_process_open2()
4268 init_open_stateid(stp, fp, open); in nfsd4_process_open2()
4269 down_read(&stp->st_rwsem); in nfsd4_process_open2()
4270 status = nfs4_get_vfs_file(rqstp, fp, current_fh, stp, open); in nfsd4_process_open2()
4272 up_read(&stp->st_rwsem); in nfsd4_process_open2()
4273 release_open_stateid(stp); in nfsd4_process_open2()
4277 stp->st_clnt_odstate = find_or_hash_clnt_odstate(fp, in nfsd4_process_open2()
4279 if (stp->st_clnt_odstate == open->op_odstate) in nfsd4_process_open2()
4282 update_stateid(&stp->st_stid.sc_stateid); in nfsd4_process_open2()
4283 memcpy(&open->op_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t)); in nfsd4_process_open2()
4284 up_read(&stp->st_rwsem); in nfsd4_process_open2()
4298 nfs4_open_delegation(current_fh, open, stp); in nfsd4_process_open2()
4303 STATEID_VAL(&stp->st_stid.sc_stateid)); in nfsd4_process_open2()
4323 if (stp) in nfsd4_process_open2()
4324 nfs4_put_stid(&stp->st_stid); in nfsd4_process_open2()
4408 struct nfs4_ol_stateid *stp; in nfs4_laundromat() local
4471 stp = oo->oo_last_closed_stid; in nfs4_laundromat()
4474 nfs4_put_stid(&stp->st_stid); in nfs4_laundromat()
4500 static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stid *stp) in nfs4_check_fh() argument
4502 if (!fh_match(&fhp->fh_handle, &stp->sc_file->fi_fhandle)) in nfs4_check_fh()
4508 access_permit_read(struct nfs4_ol_stateid *stp) in access_permit_read() argument
4510 return test_access(NFS4_SHARE_ACCESS_READ, stp) || in access_permit_read()
4511 test_access(NFS4_SHARE_ACCESS_BOTH, stp) || in access_permit_read()
4512 test_access(NFS4_SHARE_ACCESS_WRITE, stp); in access_permit_read()
4516 access_permit_write(struct nfs4_ol_stateid *stp) in access_permit_write() argument
4518 return test_access(NFS4_SHARE_ACCESS_WRITE, stp) || in access_permit_write()
4519 test_access(NFS4_SHARE_ACCESS_BOTH, stp); in access_permit_write()
4523 __be32 nfs4_check_openmode(struct nfs4_ol_stateid *stp, int flags) in nfs4_check_openmode() argument
4528 if (stp->st_openstp) in nfs4_check_openmode()
4529 stp = stp->st_openstp; in nfs4_check_openmode()
4530 if ((flags & WR_STATE) && !access_permit_write(stp)) in nfs4_check_openmode()
4532 if ((flags & RD_STATE) && !access_permit_read(stp)) in nfs4_check_openmode()
4790 struct nfs4_ol_stateid *stp; in nfsd4_free_stateid() local
4812 stp = openlockstateid(s); in nfsd4_free_stateid()
4814 if (check_for_locks(stp->st_stid.sc_file, in nfsd4_free_stateid()
4815 lockowner(stp->st_stateowner))) in nfsd4_free_stateid()
4817 WARN_ON(!unhash_lock_stateid(stp)); in nfsd4_free_stateid()
4844 …ks(struct nfsd4_compound_state *cstate, stateid_t *stateid, u32 seqid, struct nfs4_ol_stateid *stp) in nfs4_seqid_op_checks() argument
4847 struct nfs4_stateowner *sop = stp->st_stateowner; in nfs4_seqid_op_checks()
4853 if (stp->st_stid.sc_type == NFS4_CLOSED_STID in nfs4_seqid_op_checks()
4854 || stp->st_stid.sc_type == NFS4_REVOKED_DELEG_STID) in nfs4_seqid_op_checks()
4861 down_write(&stp->st_rwsem); in nfs4_seqid_op_checks()
4862 status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate)); in nfs4_seqid_op_checks()
4864 status = nfs4_check_fh(current_fh, &stp->st_stid); in nfs4_seqid_op_checks()
4866 up_write(&stp->st_rwsem); in nfs4_seqid_op_checks()
4881 struct nfs4_ol_stateid *stp = NULL; in nfs4_preprocess_seqid_op() local
4890 stp = openlockstateid(s); in nfs4_preprocess_seqid_op()
4891 nfsd4_cstate_assign_replay(cstate, stp->st_stateowner); in nfs4_preprocess_seqid_op()
4893 status = nfs4_seqid_op_checks(cstate, stateid, seqid, stp); in nfs4_preprocess_seqid_op()
4895 *stpp = stp; in nfs4_preprocess_seqid_op()
4897 nfs4_put_stid(&stp->st_stid); in nfs4_preprocess_seqid_op()
4906 struct nfs4_ol_stateid *stp; in nfs4_preprocess_confirmed_seqid_op() local
4909 NFS4_OPEN_STID, &stp, nn); in nfs4_preprocess_confirmed_seqid_op()
4912 oo = openowner(stp->st_stateowner); in nfs4_preprocess_confirmed_seqid_op()
4914 up_write(&stp->st_rwsem); in nfs4_preprocess_confirmed_seqid_op()
4915 nfs4_put_stid(&stp->st_stid); in nfs4_preprocess_confirmed_seqid_op()
4918 *stpp = stp; in nfs4_preprocess_confirmed_seqid_op()
4928 struct nfs4_ol_stateid *stp; in nfsd4_open_confirm() local
4940 NFS4_OPEN_STID, &stp, nn); in nfsd4_open_confirm()
4943 oo = openowner(stp->st_stateowner); in nfsd4_open_confirm()
4946 up_write(&stp->st_rwsem); in nfsd4_open_confirm()
4950 update_stateid(&stp->st_stid.sc_stateid); in nfsd4_open_confirm()
4951 memcpy(&oc->oc_resp_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t)); in nfsd4_open_confirm()
4952 up_write(&stp->st_rwsem); in nfsd4_open_confirm()
4954 __func__, oc->oc_seqid, STATEID_VAL(&stp->st_stid.sc_stateid)); in nfsd4_open_confirm()
4959 nfs4_put_stid(&stp->st_stid); in nfsd4_open_confirm()
4965 static inline void nfs4_stateid_downgrade_bit(struct nfs4_ol_stateid *stp, u32 access) in nfs4_stateid_downgrade_bit() argument
4967 if (!test_access(access, stp)) in nfs4_stateid_downgrade_bit()
4969 nfs4_file_put_access(stp->st_stid.sc_file, access); in nfs4_stateid_downgrade_bit()
4970 clear_access(access, stp); in nfs4_stateid_downgrade_bit()
4973 static inline void nfs4_stateid_downgrade(struct nfs4_ol_stateid *stp, u32 to_access) in nfs4_stateid_downgrade() argument
4977 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_WRITE); in nfs4_stateid_downgrade()
4978 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH); in nfs4_stateid_downgrade()
4981 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_READ); in nfs4_stateid_downgrade()
4982 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH); in nfs4_stateid_downgrade()
4997 struct nfs4_ol_stateid *stp; in nfsd4_open_downgrade() local
5009 &od->od_stateid, &stp, nn); in nfsd4_open_downgrade()
5013 if (!test_access(od->od_share_access, stp)) { in nfsd4_open_downgrade()
5015 stp->st_access_bmap, od->od_share_access); in nfsd4_open_downgrade()
5018 if (!test_deny(od->od_share_deny, stp)) { in nfsd4_open_downgrade()
5020 stp->st_deny_bmap, od->od_share_deny); in nfsd4_open_downgrade()
5023 nfs4_stateid_downgrade(stp, od->od_share_access); in nfsd4_open_downgrade()
5025 reset_union_bmap_deny(od->od_share_deny, stp); in nfsd4_open_downgrade()
5027 update_stateid(&stp->st_stid.sc_stateid); in nfsd4_open_downgrade()
5028 memcpy(&od->od_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t)); in nfsd4_open_downgrade()
5031 up_write(&stp->st_rwsem); in nfsd4_open_downgrade()
5032 nfs4_put_stid(&stp->st_stid); in nfsd4_open_downgrade()
5069 struct nfs4_ol_stateid *stp; in nfsd4_close() local
5079 &stp, nn); in nfsd4_close()
5083 update_stateid(&stp->st_stid.sc_stateid); in nfsd4_close()
5084 memcpy(&close->cl_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t)); in nfsd4_close()
5085 up_write(&stp->st_rwsem); in nfsd4_close()
5087 nfsd4_close_open_stateid(stp); in nfsd4_close()
5090 nfs4_put_stid(&stp->st_stid); in nfsd4_close()
5299 init_lock_stateid(struct nfs4_ol_stateid *stp, struct nfs4_lockowner *lo, in init_lock_stateid() argument
5307 atomic_inc(&stp->st_stid.sc_count); in init_lock_stateid()
5308 stp->st_stid.sc_type = NFS4_LOCK_STID; in init_lock_stateid()
5309 stp->st_stateowner = nfs4_get_stateowner(&lo->lo_owner); in init_lock_stateid()
5311 stp->st_stid.sc_file = fp; in init_lock_stateid()
5312 stp->st_stid.sc_free = nfs4_free_lock_stateid; in init_lock_stateid()
5313 stp->st_access_bmap = 0; in init_lock_stateid()
5314 stp->st_deny_bmap = open_stp->st_deny_bmap; in init_lock_stateid()
5315 stp->st_openstp = open_stp; in init_lock_stateid()
5316 init_rwsem(&stp->st_rwsem); in init_lock_stateid()
5317 list_add(&stp->st_locks, &open_stp->st_locks); in init_lock_stateid()
5318 list_add(&stp->st_perstateowner, &lo->lo_owner.so_stateids); in init_lock_stateid()
5320 list_add(&stp->st_perfile, &fp->fi_stateids); in init_lock_stateid()
5719 struct nfs4_ol_stateid *stp; in nfsd4_locku() local
5735 &stp, nn); in nfsd4_locku()
5738 filp = find_any_file(stp->st_stid.sc_file); in nfsd4_locku()
5751 file_lock->fl_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(stp->st_stateowner)); in nfsd4_locku()
5767 update_stateid(&stp->st_stid.sc_stateid); in nfsd4_locku()
5768 memcpy(&locku->lu_stateid, &stp->st_stid.sc_stateid, sizeof(stateid_t)); in nfsd4_locku()
5772 up_write(&stp->st_rwsem); in nfsd4_locku()
5773 nfs4_put_stid(&stp->st_stid); in nfsd4_locku()
5830 struct nfs4_ol_stateid *stp; in nfsd4_release_lockowner() local
5855 list_for_each_entry(stp, &sop->so_stateids, st_perstateowner) { in nfsd4_release_lockowner()
5856 if (check_for_locks(stp->st_stid.sc_file, lo)) { in nfsd4_release_lockowner()
6107 struct nfs4_ol_stateid *stp, *st_next; in nfsd_foreach_client_lock() local
6113 list_for_each_entry_safe(stp, st_next, in nfsd_foreach_client_lock()
6116 &stp->st_locks, st_locks) { in nfsd_foreach_client_lock()
6180 struct nfs4_ol_stateid *stp, *next; in nfsd_reap_locks() local
6182 list_for_each_entry_safe(stp, next, reaplist, st_locks) { in nfsd_reap_locks()
6183 list_del_init(&stp->st_locks); in nfsd_reap_locks()
6184 clp = stp->st_stid.sc_client; in nfsd_reap_locks()
6185 nfs4_put_stid(&stp->st_stid); in nfsd_reap_locks()