Lines Matching refs:stp
1192 set_access(u32 access, struct nfs4_ol_stateid *stp) in set_access() argument
1197 stp->st_access_bmap |= mask; in set_access()
1202 clear_access(u32 access, struct nfs4_ol_stateid *stp) in clear_access() argument
1207 stp->st_access_bmap &= ~mask; in clear_access()
1212 test_access(u32 access, struct nfs4_ol_stateid *stp) in test_access() argument
1216 return (bool)(stp->st_access_bmap & mask); in test_access()
1221 set_deny(u32 deny, struct nfs4_ol_stateid *stp) in set_deny() argument
1226 stp->st_deny_bmap |= mask; in set_deny()
1231 clear_deny(u32 deny, struct nfs4_ol_stateid *stp) in clear_deny() argument
1236 stp->st_deny_bmap &= ~mask; in clear_deny()
1241 test_deny(u32 deny, struct nfs4_ol_stateid *stp) in test_deny() argument
1245 return (bool)(stp->st_deny_bmap & mask); in test_deny()
1269 struct nfs4_ol_stateid *stp; in recalculate_deny_mode() local
1273 list_for_each_entry(stp, &fp->fi_stateids, st_perfile) in recalculate_deny_mode()
1274 fp->fi_share_deny |= bmap_to_share_mode(stp->st_deny_bmap); in recalculate_deny_mode()
1279 reset_union_bmap_deny(u32 deny, struct nfs4_ol_stateid *stp) in reset_union_bmap_deny() argument
1287 clear_deny(i, stp); in reset_union_bmap_deny()
1293 recalculate_deny_mode(stp->st_stid.sc_file); in reset_union_bmap_deny()
1298 release_all_access(struct nfs4_ol_stateid *stp) in release_all_access() argument
1301 struct nfs4_file *fp = stp->st_stid.sc_file; in release_all_access()
1303 if (fp && stp->st_deny_bmap != 0) in release_all_access()
1307 if (test_access(i, stp)) in release_all_access()
1308 nfs4_file_put_access(stp->st_stid.sc_file, i); in release_all_access()
1309 clear_access(i, stp); in release_all_access()
1333 nfs4_ol_stateid_unhashed(const struct nfs4_ol_stateid *stp) in nfs4_ol_stateid_unhashed() argument
1335 return list_empty(&stp->st_perfile); in nfs4_ol_stateid_unhashed()
1338 static bool unhash_ol_stateid(struct nfs4_ol_stateid *stp) in unhash_ol_stateid() argument
1340 struct nfs4_file *fp = stp->st_stid.sc_file; in unhash_ol_stateid()
1342 lockdep_assert_held(&stp->st_stateowner->so_client->cl_lock); in unhash_ol_stateid()
1344 if (list_empty(&stp->st_perfile)) in unhash_ol_stateid()
1348 list_del_init(&stp->st_perfile); in unhash_ol_stateid()
1350 list_del(&stp->st_perstateowner); in unhash_ol_stateid()
1356 struct nfs4_ol_stateid *stp = openlockstateid(stid); in nfs4_free_ol_stateid() local
1358 put_clnt_odstate(stp->st_clnt_odstate); in nfs4_free_ol_stateid()
1359 release_all_access(stp); in nfs4_free_ol_stateid()
1360 if (stp->st_stateowner) in nfs4_free_ol_stateid()
1361 nfs4_put_stateowner(stp->st_stateowner); in nfs4_free_ol_stateid()
1368 struct nfs4_ol_stateid *stp = openlockstateid(stid); in nfs4_free_lock_stateid() local
1369 struct nfs4_lockowner *lo = lockowner(stp->st_stateowner); in nfs4_free_lock_stateid()
1372 nf = find_any_file(stp->st_stid.sc_file); in nfs4_free_lock_stateid()
1386 static void put_ol_stateid_locked(struct nfs4_ol_stateid *stp, in put_ol_stateid_locked() argument
1389 struct nfs4_stid *s = &stp->st_stid; in put_ol_stateid_locked()
1394 WARN_ON_ONCE(!list_empty(&stp->st_locks)); in put_ol_stateid_locked()
1402 list_add(&stp->st_locks, reaplist); in put_ol_stateid_locked()
1405 static bool unhash_lock_stateid(struct nfs4_ol_stateid *stp) in unhash_lock_stateid() argument
1407 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock); in unhash_lock_stateid()
1409 if (!unhash_ol_stateid(stp)) in unhash_lock_stateid()
1411 list_del_init(&stp->st_locks); in unhash_lock_stateid()
1412 nfs4_unhash_stid(&stp->st_stid); in unhash_lock_stateid()
1416 static void release_lock_stateid(struct nfs4_ol_stateid *stp) in release_lock_stateid() argument
1418 struct nfs4_client *clp = stp->st_stid.sc_client; in release_lock_stateid()
1422 unhashed = unhash_lock_stateid(stp); in release_lock_stateid()
1425 nfs4_put_stid(&stp->st_stid); in release_lock_stateid()
1444 struct nfs4_ol_stateid *stp; in free_ol_stateid_reaplist() local
1450 stp = list_first_entry(reaplist, struct nfs4_ol_stateid, in free_ol_stateid_reaplist()
1452 list_del(&stp->st_locks); in free_ol_stateid_reaplist()
1453 fp = stp->st_stid.sc_file; in free_ol_stateid_reaplist()
1454 stp->st_stid.sc_free(&stp->st_stid); in free_ol_stateid_reaplist()
1463 struct nfs4_ol_stateid *stp; in release_open_stateid_locks() local
1468 stp = list_entry(open_stp->st_locks.next, in release_open_stateid_locks()
1470 WARN_ON(!unhash_lock_stateid(stp)); in release_open_stateid_locks()
1471 put_ol_stateid_locked(stp, reaplist); in release_open_stateid_locks()
1475 static bool unhash_open_stateid(struct nfs4_ol_stateid *stp, in unhash_open_stateid() argument
1478 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock); in unhash_open_stateid()
1480 if (!unhash_ol_stateid(stp)) in unhash_open_stateid()
1482 release_open_stateid_locks(stp, reaplist); in unhash_open_stateid()
1486 static void release_open_stateid(struct nfs4_ol_stateid *stp) in release_open_stateid() argument
1490 spin_lock(&stp->st_stid.sc_client->cl_lock); in release_open_stateid()
1491 if (unhash_open_stateid(stp, &reaplist)) in release_open_stateid()
1492 put_ol_stateid_locked(stp, &reaplist); in release_open_stateid()
1493 spin_unlock(&stp->st_stid.sc_client->cl_lock); in release_open_stateid()
1526 struct nfs4_ol_stateid *stp; in release_openowner() local
1535 stp = list_first_entry(&oo->oo_owner.so_stateids, in release_openowner()
1537 if (unhash_open_stateid(stp, &reaplist)) in release_openowner()
1538 put_ol_stateid_locked(stp, &reaplist); in release_openowner()
4286 nfsd4_lock_ol_stateid(struct nfs4_ol_stateid *stp) in nfsd4_lock_ol_stateid() argument
4290 mutex_lock_nested(&stp->st_mutex, LOCK_STATEID_MUTEX); in nfsd4_lock_ol_stateid()
4291 ret = nfsd4_verify_open_stid(&stp->st_stid); in nfsd4_lock_ol_stateid()
4293 mutex_unlock(&stp->st_mutex); in nfsd4_lock_ol_stateid()
4300 struct nfs4_ol_stateid *stp; in nfsd4_find_and_lock_existing_open() local
4303 stp = nfsd4_find_existing_open(fp, open); in nfsd4_find_and_lock_existing_open()
4305 if (!stp || nfsd4_lock_ol_stateid(stp) == nfs_ok) in nfsd4_find_and_lock_existing_open()
4307 nfs4_put_stid(&stp->st_stid); in nfsd4_find_and_lock_existing_open()
4309 return stp; in nfsd4_find_and_lock_existing_open()
4349 struct nfs4_ol_stateid *stp; in init_open_stateid() local
4351 stp = open->op_stp; in init_open_stateid()
4353 mutex_init(&stp->st_mutex); in init_open_stateid()
4354 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX); in init_open_stateid()
4365 refcount_inc(&stp->st_stid.sc_count); in init_open_stateid()
4366 stp->st_stid.sc_type = NFS4_OPEN_STID; in init_open_stateid()
4367 INIT_LIST_HEAD(&stp->st_locks); in init_open_stateid()
4368 stp->st_stateowner = nfs4_get_stateowner(&oo->oo_owner); in init_open_stateid()
4370 stp->st_stid.sc_file = fp; in init_open_stateid()
4371 stp->st_access_bmap = 0; in init_open_stateid()
4372 stp->st_deny_bmap = 0; in init_open_stateid()
4373 stp->st_openstp = NULL; in init_open_stateid()
4374 list_add(&stp->st_perstateowner, &oo->oo_owner.so_stateids); in init_open_stateid()
4375 list_add(&stp->st_perfile, &fp->fi_stateids); in init_open_stateid()
4387 mutex_unlock(&stp->st_mutex); in init_open_stateid()
4388 stp = retstp; in init_open_stateid()
4390 return stp; in init_open_stateid()
4852 struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, in nfs4_get_vfs_file() argument
4881 old_access_bmap = stp->st_access_bmap; in nfs4_get_vfs_file()
4882 set_access(open->op_share_access, stp); in nfs4_get_vfs_file()
4885 old_deny_bmap = stp->st_deny_bmap; in nfs4_get_vfs_file()
4886 set_deny(open->op_share_deny, stp); in nfs4_get_vfs_file()
4915 stp->st_access_bmap = old_access_bmap; in nfs4_get_vfs_file()
4917 reset_union_bmap_deny(bmap_to_share_mode(old_deny_bmap), stp); in nfs4_get_vfs_file()
4922 …qstp, struct nfs4_file *fp, struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, struct nfsd4_open … in nfs4_upgrade_open() argument
4925 unsigned char old_deny_bmap = stp->st_deny_bmap; in nfs4_upgrade_open()
4927 if (!test_access(open->op_share_access, stp)) in nfs4_upgrade_open()
4928 return nfs4_get_vfs_file(rqstp, fp, cur_fh, stp, open); in nfs4_upgrade_open()
4934 set_deny(open->op_share_deny, stp); in nfs4_upgrade_open()
4945 reset_union_bmap_deny(old_deny_bmap, stp); in nfs4_upgrade_open()
5089 struct nfs4_ol_stateid *stp) in nfs4_open_delegation() argument
5092 struct nfs4_openowner *oo = openowner(stp->st_stateowner); in nfs4_open_delegation()
5093 struct nfs4_client *clp = stp->st_stid.sc_client; in nfs4_open_delegation()
5132 dp = nfs4_set_delegation(clp, fh, stp->st_stid.sc_file, stp->st_clnt_odstate); in nfs4_open_delegation()
5180 struct nfs4_ol_stateid *stp = NULL; in nfsd4_process_open2() local
5195 stp = nfsd4_find_and_lock_existing_open(fp, open); in nfsd4_process_open2()
5203 if (!stp) { in nfsd4_process_open2()
5204 stp = init_open_stateid(fp, open); in nfsd4_process_open2()
5217 status = nfs4_upgrade_open(rqstp, fp, current_fh, stp, open); in nfsd4_process_open2()
5219 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
5223 status = nfs4_get_vfs_file(rqstp, fp, current_fh, stp, open); in nfsd4_process_open2()
5225 stp->st_stid.sc_type = NFS4_CLOSED_STID; in nfsd4_process_open2()
5226 release_open_stateid(stp); in nfsd4_process_open2()
5227 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
5231 stp->st_clnt_odstate = find_or_hash_clnt_odstate(fp, in nfsd4_process_open2()
5233 if (stp->st_clnt_odstate == open->op_odstate) in nfsd4_process_open2()
5237 nfs4_inc_and_copy_stateid(&open->op_stateid, &stp->st_stid); in nfsd4_process_open2()
5238 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
5252 nfs4_open_delegation(current_fh, open, stp); in nfsd4_process_open2()
5255 trace_nfsd_open(&stp->st_stid.sc_stateid); in nfsd4_process_open2()
5277 if (stp) in nfsd4_process_open2()
5278 nfs4_put_stid(&stp->st_stid); in nfsd4_process_open2()
5387 struct nfs4_ol_stateid *stp; in nfs4_laundromat() local
5462 stp = oo->oo_last_closed_stid; in nfs4_laundromat()
5465 nfs4_put_stid(&stp->st_stid); in nfs4_laundromat()
5522 static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stid *stp) in nfs4_check_fh() argument
5524 if (!fh_match(&fhp->fh_handle, &stp->sc_file->fi_fhandle)) in nfs4_check_fh()
5530 access_permit_read(struct nfs4_ol_stateid *stp) in access_permit_read() argument
5532 return test_access(NFS4_SHARE_ACCESS_READ, stp) || in access_permit_read()
5533 test_access(NFS4_SHARE_ACCESS_BOTH, stp) || in access_permit_read()
5534 test_access(NFS4_SHARE_ACCESS_WRITE, stp); in access_permit_read()
5538 access_permit_write(struct nfs4_ol_stateid *stp) in access_permit_write() argument
5540 return test_access(NFS4_SHARE_ACCESS_WRITE, stp) || in access_permit_write()
5541 test_access(NFS4_SHARE_ACCESS_BOTH, stp); in access_permit_write()
5545 __be32 nfs4_check_openmode(struct nfs4_ol_stateid *stp, int flags) in nfs4_check_openmode() argument
5550 if (stp->st_openstp) in nfs4_check_openmode()
5551 stp = stp->st_openstp; in nfs4_check_openmode()
5552 if ((flags & WR_STATE) && !access_permit_write(stp)) in nfs4_check_openmode()
5554 if ((flags & RD_STATE) && !access_permit_read(stp)) in nfs4_check_openmode()
5943 struct nfs4_ol_stateid *stp = openlockstateid(s); in nfsd4_free_lock_stateid() local
5946 ret = nfsd4_lock_ol_stateid(stp); in nfsd4_free_lock_stateid()
5955 if (check_for_locks(stp->st_stid.sc_file, in nfsd4_free_lock_stateid()
5956 lockowner(stp->st_stateowner))) in nfsd4_free_lock_stateid()
5959 release_lock_stateid(stp); in nfsd4_free_lock_stateid()
5963 mutex_unlock(&stp->st_mutex); in nfsd4_free_lock_stateid()
6025 …ks(struct nfsd4_compound_state *cstate, stateid_t *stateid, u32 seqid, struct nfs4_ol_stateid *stp) in nfs4_seqid_op_checks() argument
6028 struct nfs4_stateowner *sop = stp->st_stateowner; in nfs4_seqid_op_checks()
6034 status = nfsd4_lock_ol_stateid(stp); in nfs4_seqid_op_checks()
6037 status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate)); in nfs4_seqid_op_checks()
6039 status = nfs4_check_fh(current_fh, &stp->st_stid); in nfs4_seqid_op_checks()
6041 mutex_unlock(&stp->st_mutex); in nfs4_seqid_op_checks()
6056 struct nfs4_ol_stateid *stp = NULL; in nfs4_preprocess_seqid_op() local
6064 stp = openlockstateid(s); in nfs4_preprocess_seqid_op()
6065 nfsd4_cstate_assign_replay(cstate, stp->st_stateowner); in nfs4_preprocess_seqid_op()
6067 status = nfs4_seqid_op_checks(cstate, stateid, seqid, stp); in nfs4_preprocess_seqid_op()
6069 *stpp = stp; in nfs4_preprocess_seqid_op()
6071 nfs4_put_stid(&stp->st_stid); in nfs4_preprocess_seqid_op()
6080 struct nfs4_ol_stateid *stp; in nfs4_preprocess_confirmed_seqid_op() local
6083 NFS4_OPEN_STID, &stp, nn); in nfs4_preprocess_confirmed_seqid_op()
6086 oo = openowner(stp->st_stateowner); in nfs4_preprocess_confirmed_seqid_op()
6088 mutex_unlock(&stp->st_mutex); in nfs4_preprocess_confirmed_seqid_op()
6089 nfs4_put_stid(&stp->st_stid); in nfs4_preprocess_confirmed_seqid_op()
6092 *stpp = stp; in nfs4_preprocess_confirmed_seqid_op()
6103 struct nfs4_ol_stateid *stp; in nfsd4_open_confirm() local
6115 NFS4_OPEN_STID, &stp, nn); in nfsd4_open_confirm()
6118 oo = openowner(stp->st_stateowner); in nfsd4_open_confirm()
6121 mutex_unlock(&stp->st_mutex); in nfsd4_open_confirm()
6125 nfs4_inc_and_copy_stateid(&oc->oc_resp_stateid, &stp->st_stid); in nfsd4_open_confirm()
6126 mutex_unlock(&stp->st_mutex); in nfsd4_open_confirm()
6127 trace_nfsd_open_confirm(oc->oc_seqid, &stp->st_stid.sc_stateid); in nfsd4_open_confirm()
6131 nfs4_put_stid(&stp->st_stid); in nfsd4_open_confirm()
6137 static inline void nfs4_stateid_downgrade_bit(struct nfs4_ol_stateid *stp, u32 access) in nfs4_stateid_downgrade_bit() argument
6139 if (!test_access(access, stp)) in nfs4_stateid_downgrade_bit()
6141 nfs4_file_put_access(stp->st_stid.sc_file, access); in nfs4_stateid_downgrade_bit()
6142 clear_access(access, stp); in nfs4_stateid_downgrade_bit()
6145 static inline void nfs4_stateid_downgrade(struct nfs4_ol_stateid *stp, u32 to_access) in nfs4_stateid_downgrade() argument
6149 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_WRITE); in nfs4_stateid_downgrade()
6150 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH); in nfs4_stateid_downgrade()
6153 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_READ); in nfs4_stateid_downgrade()
6154 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH); in nfs4_stateid_downgrade()
6169 struct nfs4_ol_stateid *stp; in nfsd4_open_downgrade() local
6181 &od->od_stateid, &stp, nn); in nfsd4_open_downgrade()
6185 if (!test_access(od->od_share_access, stp)) { in nfsd4_open_downgrade()
6187 stp->st_access_bmap, od->od_share_access); in nfsd4_open_downgrade()
6190 if (!test_deny(od->od_share_deny, stp)) { in nfsd4_open_downgrade()
6192 stp->st_deny_bmap, od->od_share_deny); in nfsd4_open_downgrade()
6195 nfs4_stateid_downgrade(stp, od->od_share_access); in nfsd4_open_downgrade()
6196 reset_union_bmap_deny(od->od_share_deny, stp); in nfsd4_open_downgrade()
6197 nfs4_inc_and_copy_stateid(&od->od_stateid, &stp->st_stid); in nfsd4_open_downgrade()
6200 mutex_unlock(&stp->st_mutex); in nfsd4_open_downgrade()
6201 nfs4_put_stid(&stp->st_stid); in nfsd4_open_downgrade()
6212 struct nfs4_ol_stateid *stp; in nfsd4_close_open_stateid() local
6221 list_for_each_entry(stp, &reaplist, st_locks) in nfsd4_close_open_stateid()
6222 nfs4_free_cpntf_statelist(clp->net, &stp->st_stid); in nfsd4_close_open_stateid()
6241 struct nfs4_ol_stateid *stp; in nfsd4_close() local
6251 &stp, nn); in nfsd4_close()
6256 stp->st_stid.sc_type = NFS4_CLOSED_STID; in nfsd4_close()
6264 nfs4_inc_and_copy_stateid(&close->cl_stateid, &stp->st_stid); in nfsd4_close()
6266 nfsd4_close_open_stateid(stp); in nfsd4_close()
6267 mutex_unlock(&stp->st_mutex); in nfsd4_close()
6279 nfs4_put_stid(&stp->st_stid); in nfsd4_close()
6527 init_lock_stateid(struct nfs4_ol_stateid *stp, struct nfs4_lockowner *lo, in init_lock_stateid() argument
6534 mutex_init(&stp->st_mutex); in init_lock_stateid()
6535 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX); in init_lock_stateid()
6543 refcount_inc(&stp->st_stid.sc_count); in init_lock_stateid()
6544 stp->st_stid.sc_type = NFS4_LOCK_STID; in init_lock_stateid()
6545 stp->st_stateowner = nfs4_get_stateowner(&lo->lo_owner); in init_lock_stateid()
6547 stp->st_stid.sc_file = fp; in init_lock_stateid()
6548 stp->st_access_bmap = 0; in init_lock_stateid()
6549 stp->st_deny_bmap = open_stp->st_deny_bmap; in init_lock_stateid()
6550 stp->st_openstp = open_stp; in init_lock_stateid()
6552 list_add(&stp->st_locks, &open_stp->st_locks); in init_lock_stateid()
6553 list_add(&stp->st_perstateowner, &lo->lo_owner.so_stateids); in init_lock_stateid()
6554 list_add(&stp->st_perfile, &fp->fi_stateids); in init_lock_stateid()
6557 return stp; in init_lock_stateid()
6565 mutex_unlock(&stp->st_mutex); in init_lock_stateid()
6569 mutex_unlock(&stp->st_mutex); in init_lock_stateid()
6995 struct nfs4_ol_stateid *stp; in nfsd4_locku() local
7011 &stp, nn); in nfsd4_locku()
7014 nf = find_any_file(stp->st_stid.sc_file); in nfsd4_locku()
7027 file_lock->fl_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(stp->st_stateowner)); in nfsd4_locku()
7043 nfs4_inc_and_copy_stateid(&locku->lu_stateid, &stp->st_stid); in nfsd4_locku()
7047 mutex_unlock(&stp->st_mutex); in nfsd4_locku()
7048 nfs4_put_stid(&stp->st_stid); in nfsd4_locku()
7106 struct nfs4_ol_stateid *stp; in nfsd4_release_lockowner() local
7146 stp = list_first_entry(&lo->lo_owner.so_stateids, in nfsd4_release_lockowner()
7149 WARN_ON(!unhash_lock_stateid(stp)); in nfsd4_release_lockowner()
7150 put_ol_stateid_locked(stp, &reaplist); in nfsd4_release_lockowner()