Lines Matching refs:stp
1123 set_access(u32 access, struct nfs4_ol_stateid *stp) in set_access() argument
1128 stp->st_access_bmap |= mask; in set_access()
1133 clear_access(u32 access, struct nfs4_ol_stateid *stp) in clear_access() argument
1138 stp->st_access_bmap &= ~mask; in clear_access()
1143 test_access(u32 access, struct nfs4_ol_stateid *stp) in test_access() argument
1147 return (bool)(stp->st_access_bmap & mask); in test_access()
1152 set_deny(u32 deny, struct nfs4_ol_stateid *stp) in set_deny() argument
1157 stp->st_deny_bmap |= mask; in set_deny()
1162 clear_deny(u32 deny, struct nfs4_ol_stateid *stp) in clear_deny() argument
1167 stp->st_deny_bmap &= ~mask; in clear_deny()
1172 test_deny(u32 deny, struct nfs4_ol_stateid *stp) in test_deny() argument
1176 return (bool)(stp->st_deny_bmap & mask); in test_deny()
1200 struct nfs4_ol_stateid *stp; in recalculate_deny_mode() local
1204 list_for_each_entry(stp, &fp->fi_stateids, st_perfile) in recalculate_deny_mode()
1205 fp->fi_share_deny |= bmap_to_share_mode(stp->st_deny_bmap); in recalculate_deny_mode()
1210 reset_union_bmap_deny(u32 deny, struct nfs4_ol_stateid *stp) in reset_union_bmap_deny() argument
1218 clear_deny(i, stp); in reset_union_bmap_deny()
1224 recalculate_deny_mode(stp->st_stid.sc_file); in reset_union_bmap_deny()
1229 release_all_access(struct nfs4_ol_stateid *stp) in release_all_access() argument
1232 struct nfs4_file *fp = stp->st_stid.sc_file; in release_all_access()
1234 if (fp && stp->st_deny_bmap != 0) in release_all_access()
1238 if (test_access(i, stp)) in release_all_access()
1239 nfs4_file_put_access(stp->st_stid.sc_file, i); in release_all_access()
1240 clear_access(i, stp); in release_all_access()
1263 static bool unhash_ol_stateid(struct nfs4_ol_stateid *stp) in unhash_ol_stateid() argument
1265 struct nfs4_file *fp = stp->st_stid.sc_file; in unhash_ol_stateid()
1267 lockdep_assert_held(&stp->st_stateowner->so_client->cl_lock); in unhash_ol_stateid()
1269 if (list_empty(&stp->st_perfile)) in unhash_ol_stateid()
1273 list_del_init(&stp->st_perfile); in unhash_ol_stateid()
1275 list_del(&stp->st_perstateowner); in unhash_ol_stateid()
1281 struct nfs4_ol_stateid *stp = openlockstateid(stid); in nfs4_free_ol_stateid() local
1283 put_clnt_odstate(stp->st_clnt_odstate); in nfs4_free_ol_stateid()
1284 release_all_access(stp); in nfs4_free_ol_stateid()
1285 if (stp->st_stateowner) in nfs4_free_ol_stateid()
1286 nfs4_put_stateowner(stp->st_stateowner); in nfs4_free_ol_stateid()
1292 struct nfs4_ol_stateid *stp = openlockstateid(stid); in nfs4_free_lock_stateid() local
1293 struct nfs4_lockowner *lo = lockowner(stp->st_stateowner); in nfs4_free_lock_stateid()
1296 nf = find_any_file(stp->st_stid.sc_file); in nfs4_free_lock_stateid()
1310 static void put_ol_stateid_locked(struct nfs4_ol_stateid *stp, in put_ol_stateid_locked() argument
1313 struct nfs4_stid *s = &stp->st_stid; in put_ol_stateid_locked()
1318 WARN_ON_ONCE(!list_empty(&stp->st_locks)); in put_ol_stateid_locked()
1326 list_add(&stp->st_locks, reaplist); in put_ol_stateid_locked()
1329 static bool unhash_lock_stateid(struct nfs4_ol_stateid *stp) in unhash_lock_stateid() argument
1331 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock); in unhash_lock_stateid()
1333 list_del_init(&stp->st_locks); in unhash_lock_stateid()
1334 nfs4_unhash_stid(&stp->st_stid); in unhash_lock_stateid()
1335 return unhash_ol_stateid(stp); in unhash_lock_stateid()
1338 static void release_lock_stateid(struct nfs4_ol_stateid *stp) in release_lock_stateid() argument
1340 struct nfs4_client *clp = stp->st_stid.sc_client; in release_lock_stateid()
1344 unhashed = unhash_lock_stateid(stp); in release_lock_stateid()
1347 nfs4_put_stid(&stp->st_stid); in release_lock_stateid()
1366 struct nfs4_ol_stateid *stp; in free_ol_stateid_reaplist() local
1372 stp = list_first_entry(reaplist, struct nfs4_ol_stateid, in free_ol_stateid_reaplist()
1374 list_del(&stp->st_locks); in free_ol_stateid_reaplist()
1375 fp = stp->st_stid.sc_file; in free_ol_stateid_reaplist()
1376 stp->st_stid.sc_free(&stp->st_stid); in free_ol_stateid_reaplist()
1385 struct nfs4_ol_stateid *stp; in release_open_stateid_locks() local
1390 stp = list_entry(open_stp->st_locks.next, in release_open_stateid_locks()
1392 WARN_ON(!unhash_lock_stateid(stp)); in release_open_stateid_locks()
1393 put_ol_stateid_locked(stp, reaplist); in release_open_stateid_locks()
1397 static bool unhash_open_stateid(struct nfs4_ol_stateid *stp, in unhash_open_stateid() argument
1402 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock); in unhash_open_stateid()
1404 unhashed = unhash_ol_stateid(stp); in unhash_open_stateid()
1405 release_open_stateid_locks(stp, reaplist); in unhash_open_stateid()
1409 static void release_open_stateid(struct nfs4_ol_stateid *stp) in release_open_stateid() argument
1413 spin_lock(&stp->st_stid.sc_client->cl_lock); in release_open_stateid()
1414 if (unhash_open_stateid(stp, &reaplist)) in release_open_stateid()
1415 put_ol_stateid_locked(stp, &reaplist); in release_open_stateid()
1416 spin_unlock(&stp->st_stid.sc_client->cl_lock); in release_open_stateid()
1449 struct nfs4_ol_stateid *stp; in release_openowner() local
1458 stp = list_first_entry(&oo->oo_owner.so_stateids, in release_openowner()
1460 if (unhash_open_stateid(stp, &reaplist)) in release_openowner()
1461 put_ol_stateid_locked(stp, &reaplist); in release_openowner()
4143 nfsd4_lock_ol_stateid(struct nfs4_ol_stateid *stp) in nfsd4_lock_ol_stateid() argument
4147 mutex_lock_nested(&stp->st_mutex, LOCK_STATEID_MUTEX); in nfsd4_lock_ol_stateid()
4148 ret = nfsd4_verify_open_stid(&stp->st_stid); in nfsd4_lock_ol_stateid()
4150 mutex_unlock(&stp->st_mutex); in nfsd4_lock_ol_stateid()
4157 struct nfs4_ol_stateid *stp; in nfsd4_find_and_lock_existing_open() local
4160 stp = nfsd4_find_existing_open(fp, open); in nfsd4_find_and_lock_existing_open()
4162 if (!stp || nfsd4_lock_ol_stateid(stp) == nfs_ok) in nfsd4_find_and_lock_existing_open()
4164 nfs4_put_stid(&stp->st_stid); in nfsd4_find_and_lock_existing_open()
4166 return stp; in nfsd4_find_and_lock_existing_open()
4206 struct nfs4_ol_stateid *stp; in init_open_stateid() local
4208 stp = open->op_stp; in init_open_stateid()
4210 mutex_init(&stp->st_mutex); in init_open_stateid()
4211 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX); in init_open_stateid()
4222 refcount_inc(&stp->st_stid.sc_count); in init_open_stateid()
4223 stp->st_stid.sc_type = NFS4_OPEN_STID; in init_open_stateid()
4224 INIT_LIST_HEAD(&stp->st_locks); in init_open_stateid()
4225 stp->st_stateowner = nfs4_get_stateowner(&oo->oo_owner); in init_open_stateid()
4227 stp->st_stid.sc_file = fp; in init_open_stateid()
4228 stp->st_access_bmap = 0; in init_open_stateid()
4229 stp->st_deny_bmap = 0; in init_open_stateid()
4230 stp->st_openstp = NULL; in init_open_stateid()
4231 list_add(&stp->st_perstateowner, &oo->oo_owner.so_stateids); in init_open_stateid()
4232 list_add(&stp->st_perfile, &fp->fi_stateids); in init_open_stateid()
4244 mutex_unlock(&stp->st_mutex); in init_open_stateid()
4245 stp = retstp; in init_open_stateid()
4247 return stp; in init_open_stateid()
4679 struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, in nfs4_get_vfs_file() argument
4708 old_access_bmap = stp->st_access_bmap; in nfs4_get_vfs_file()
4709 set_access(open->op_share_access, stp); in nfs4_get_vfs_file()
4712 old_deny_bmap = stp->st_deny_bmap; in nfs4_get_vfs_file()
4713 set_deny(open->op_share_deny, stp); in nfs4_get_vfs_file()
4737 stp->st_access_bmap = old_access_bmap; in nfs4_get_vfs_file()
4739 reset_union_bmap_deny(bmap_to_share_mode(old_deny_bmap), stp); in nfs4_get_vfs_file()
4744 …qstp, struct nfs4_file *fp, struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, struct nfsd4_open … in nfs4_upgrade_open() argument
4747 unsigned char old_deny_bmap = stp->st_deny_bmap; in nfs4_upgrade_open()
4749 if (!test_access(open->op_share_access, stp)) in nfs4_upgrade_open()
4750 return nfs4_get_vfs_file(rqstp, fp, cur_fh, stp, open); in nfs4_upgrade_open()
4756 set_deny(open->op_share_deny, stp); in nfs4_upgrade_open()
4767 reset_union_bmap_deny(old_deny_bmap, stp); in nfs4_upgrade_open()
4911 struct nfs4_ol_stateid *stp) in nfs4_open_delegation() argument
4914 struct nfs4_openowner *oo = openowner(stp->st_stateowner); in nfs4_open_delegation()
4915 struct nfs4_client *clp = stp->st_stid.sc_client; in nfs4_open_delegation()
4954 dp = nfs4_set_delegation(clp, fh, stp->st_stid.sc_file, stp->st_clnt_odstate); in nfs4_open_delegation()
5003 struct nfs4_ol_stateid *stp = NULL; in nfsd4_process_open2() local
5018 stp = nfsd4_find_and_lock_existing_open(fp, open); in nfsd4_process_open2()
5026 if (!stp) { in nfsd4_process_open2()
5027 stp = init_open_stateid(fp, open); in nfsd4_process_open2()
5040 status = nfs4_upgrade_open(rqstp, fp, current_fh, stp, open); in nfsd4_process_open2()
5042 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
5046 status = nfs4_get_vfs_file(rqstp, fp, current_fh, stp, open); in nfsd4_process_open2()
5048 stp->st_stid.sc_type = NFS4_CLOSED_STID; in nfsd4_process_open2()
5049 release_open_stateid(stp); in nfsd4_process_open2()
5050 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
5054 stp->st_clnt_odstate = find_or_hash_clnt_odstate(fp, in nfsd4_process_open2()
5056 if (stp->st_clnt_odstate == open->op_odstate) in nfsd4_process_open2()
5060 nfs4_inc_and_copy_stateid(&open->op_stateid, &stp->st_stid); in nfsd4_process_open2()
5061 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
5075 nfs4_open_delegation(current_fh, open, stp); in nfsd4_process_open2()
5080 STATEID_VAL(&stp->st_stid.sc_stateid)); in nfsd4_process_open2()
5102 if (stp) in nfsd4_process_open2()
5103 nfs4_put_stid(&stp->st_stid); in nfsd4_process_open2()
5213 struct nfs4_ol_stateid *stp; in nfs4_laundromat() local
5281 stp = oo->oo_last_closed_stid; in nfs4_laundromat()
5284 nfs4_put_stid(&stp->st_stid); in nfs4_laundromat()
5343 static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stid *stp) in nfs4_check_fh() argument
5345 if (!fh_match(&fhp->fh_handle, &stp->sc_file->fi_fhandle)) in nfs4_check_fh()
5351 access_permit_read(struct nfs4_ol_stateid *stp) in access_permit_read() argument
5353 return test_access(NFS4_SHARE_ACCESS_READ, stp) || in access_permit_read()
5354 test_access(NFS4_SHARE_ACCESS_BOTH, stp) || in access_permit_read()
5355 test_access(NFS4_SHARE_ACCESS_WRITE, stp); in access_permit_read()
5359 access_permit_write(struct nfs4_ol_stateid *stp) in access_permit_write() argument
5361 return test_access(NFS4_SHARE_ACCESS_WRITE, stp) || in access_permit_write()
5362 test_access(NFS4_SHARE_ACCESS_BOTH, stp); in access_permit_write()
5366 __be32 nfs4_check_openmode(struct nfs4_ol_stateid *stp, int flags) in nfs4_check_openmode() argument
5371 if (stp->st_openstp) in nfs4_check_openmode()
5372 stp = stp->st_openstp; in nfs4_check_openmode()
5373 if ((flags & WR_STATE) && !access_permit_write(stp)) in nfs4_check_openmode()
5375 if ((flags & RD_STATE) && !access_permit_read(stp)) in nfs4_check_openmode()
5685 struct nfs4_ol_stateid *stp = openlockstateid(s); in nfsd4_free_lock_stateid() local
5688 ret = nfsd4_lock_ol_stateid(stp); in nfsd4_free_lock_stateid()
5697 if (check_for_locks(stp->st_stid.sc_file, in nfsd4_free_lock_stateid()
5698 lockowner(stp->st_stateowner))) in nfsd4_free_lock_stateid()
5701 release_lock_stateid(stp); in nfsd4_free_lock_stateid()
5705 mutex_unlock(&stp->st_mutex); in nfsd4_free_lock_stateid()
5767 …ks(struct nfsd4_compound_state *cstate, stateid_t *stateid, u32 seqid, struct nfs4_ol_stateid *stp) in nfs4_seqid_op_checks() argument
5770 struct nfs4_stateowner *sop = stp->st_stateowner; in nfs4_seqid_op_checks()
5776 status = nfsd4_lock_ol_stateid(stp); in nfs4_seqid_op_checks()
5779 status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate)); in nfs4_seqid_op_checks()
5781 status = nfs4_check_fh(current_fh, &stp->st_stid); in nfs4_seqid_op_checks()
5783 mutex_unlock(&stp->st_mutex); in nfs4_seqid_op_checks()
5798 struct nfs4_ol_stateid *stp = NULL; in nfs4_preprocess_seqid_op() local
5807 stp = openlockstateid(s); in nfs4_preprocess_seqid_op()
5808 nfsd4_cstate_assign_replay(cstate, stp->st_stateowner); in nfs4_preprocess_seqid_op()
5810 status = nfs4_seqid_op_checks(cstate, stateid, seqid, stp); in nfs4_preprocess_seqid_op()
5812 *stpp = stp; in nfs4_preprocess_seqid_op()
5814 nfs4_put_stid(&stp->st_stid); in nfs4_preprocess_seqid_op()
5823 struct nfs4_ol_stateid *stp; in nfs4_preprocess_confirmed_seqid_op() local
5826 NFS4_OPEN_STID, &stp, nn); in nfs4_preprocess_confirmed_seqid_op()
5829 oo = openowner(stp->st_stateowner); in nfs4_preprocess_confirmed_seqid_op()
5831 mutex_unlock(&stp->st_mutex); in nfs4_preprocess_confirmed_seqid_op()
5832 nfs4_put_stid(&stp->st_stid); in nfs4_preprocess_confirmed_seqid_op()
5835 *stpp = stp; in nfs4_preprocess_confirmed_seqid_op()
5846 struct nfs4_ol_stateid *stp; in nfsd4_open_confirm() local
5858 NFS4_OPEN_STID, &stp, nn); in nfsd4_open_confirm()
5861 oo = openowner(stp->st_stateowner); in nfsd4_open_confirm()
5864 mutex_unlock(&stp->st_mutex); in nfsd4_open_confirm()
5868 nfs4_inc_and_copy_stateid(&oc->oc_resp_stateid, &stp->st_stid); in nfsd4_open_confirm()
5869 mutex_unlock(&stp->st_mutex); in nfsd4_open_confirm()
5871 __func__, oc->oc_seqid, STATEID_VAL(&stp->st_stid.sc_stateid)); in nfsd4_open_confirm()
5876 nfs4_put_stid(&stp->st_stid); in nfsd4_open_confirm()
5882 static inline void nfs4_stateid_downgrade_bit(struct nfs4_ol_stateid *stp, u32 access) in nfs4_stateid_downgrade_bit() argument
5884 if (!test_access(access, stp)) in nfs4_stateid_downgrade_bit()
5886 nfs4_file_put_access(stp->st_stid.sc_file, access); in nfs4_stateid_downgrade_bit()
5887 clear_access(access, stp); in nfs4_stateid_downgrade_bit()
5890 static inline void nfs4_stateid_downgrade(struct nfs4_ol_stateid *stp, u32 to_access) in nfs4_stateid_downgrade() argument
5894 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_WRITE); in nfs4_stateid_downgrade()
5895 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH); in nfs4_stateid_downgrade()
5898 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_READ); in nfs4_stateid_downgrade()
5899 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH); in nfs4_stateid_downgrade()
5914 struct nfs4_ol_stateid *stp; in nfsd4_open_downgrade() local
5926 &od->od_stateid, &stp, nn); in nfsd4_open_downgrade()
5930 if (!test_access(od->od_share_access, stp)) { in nfsd4_open_downgrade()
5932 stp->st_access_bmap, od->od_share_access); in nfsd4_open_downgrade()
5935 if (!test_deny(od->od_share_deny, stp)) { in nfsd4_open_downgrade()
5937 stp->st_deny_bmap, od->od_share_deny); in nfsd4_open_downgrade()
5940 nfs4_stateid_downgrade(stp, od->od_share_access); in nfsd4_open_downgrade()
5941 reset_union_bmap_deny(od->od_share_deny, stp); in nfsd4_open_downgrade()
5942 nfs4_inc_and_copy_stateid(&od->od_stateid, &stp->st_stid); in nfsd4_open_downgrade()
5945 mutex_unlock(&stp->st_mutex); in nfsd4_open_downgrade()
5946 nfs4_put_stid(&stp->st_stid); in nfsd4_open_downgrade()
5983 struct nfs4_ol_stateid *stp; in nfsd4_close() local
5993 &stp, nn); in nfsd4_close()
5998 stp->st_stid.sc_type = NFS4_CLOSED_STID; in nfsd4_close()
6006 nfs4_inc_and_copy_stateid(&close->cl_stateid, &stp->st_stid); in nfsd4_close()
6008 nfsd4_close_open_stateid(stp); in nfsd4_close()
6009 mutex_unlock(&stp->st_mutex); in nfsd4_close()
6021 nfs4_put_stid(&stp->st_stid); in nfsd4_close()
6269 init_lock_stateid(struct nfs4_ol_stateid *stp, struct nfs4_lockowner *lo, in init_lock_stateid() argument
6276 mutex_init(&stp->st_mutex); in init_lock_stateid()
6277 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX); in init_lock_stateid()
6285 refcount_inc(&stp->st_stid.sc_count); in init_lock_stateid()
6286 stp->st_stid.sc_type = NFS4_LOCK_STID; in init_lock_stateid()
6287 stp->st_stateowner = nfs4_get_stateowner(&lo->lo_owner); in init_lock_stateid()
6289 stp->st_stid.sc_file = fp; in init_lock_stateid()
6290 stp->st_access_bmap = 0; in init_lock_stateid()
6291 stp->st_deny_bmap = open_stp->st_deny_bmap; in init_lock_stateid()
6292 stp->st_openstp = open_stp; in init_lock_stateid()
6293 list_add(&stp->st_locks, &open_stp->st_locks); in init_lock_stateid()
6294 list_add(&stp->st_perstateowner, &lo->lo_owner.so_stateids); in init_lock_stateid()
6295 list_add(&stp->st_perfile, &fp->fi_stateids); in init_lock_stateid()
6305 mutex_unlock(&stp->st_mutex); in init_lock_stateid()
6306 stp = retstp; in init_lock_stateid()
6308 return stp; in init_lock_stateid()
6722 struct nfs4_ol_stateid *stp; in nfsd4_locku() local
6738 &stp, nn); in nfsd4_locku()
6741 nf = find_any_file(stp->st_stid.sc_file); in nfsd4_locku()
6754 file_lock->fl_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(stp->st_stateowner)); in nfsd4_locku()
6770 nfs4_inc_and_copy_stateid(&locku->lu_stateid, &stp->st_stid); in nfsd4_locku()
6774 mutex_unlock(&stp->st_mutex); in nfsd4_locku()
6775 nfs4_put_stid(&stp->st_stid); in nfsd4_locku()
6833 struct nfs4_ol_stateid *stp; in nfsd4_release_lockowner() local
6859 list_for_each_entry(stp, &sop->so_stateids, st_perstateowner) { in nfsd4_release_lockowner()
6860 if (check_for_locks(stp->st_stid.sc_file, lo)) { in nfsd4_release_lockowner()
6877 stp = list_first_entry(&lo->lo_owner.so_stateids, in nfsd4_release_lockowner()
6880 WARN_ON(!unhash_lock_stateid(stp)); in nfsd4_release_lockowner()
6881 put_ol_stateid_locked(stp, &reaplist); in nfsd4_release_lockowner()
7135 struct nfs4_ol_stateid *stp, *st_next; in nfsd_foreach_client_lock() local
7141 list_for_each_entry_safe(stp, st_next, in nfsd_foreach_client_lock()
7144 &stp->st_locks, st_locks) { in nfsd_foreach_client_lock()
7208 struct nfs4_ol_stateid *stp, *next; in nfsd_reap_locks() local
7210 list_for_each_entry_safe(stp, next, reaplist, st_locks) { in nfsd_reap_locks()
7211 list_del_init(&stp->st_locks); in nfsd_reap_locks()
7212 clp = stp->st_stid.sc_client; in nfsd_reap_locks()
7213 nfs4_put_stid(&stp->st_stid); in nfsd_reap_locks()