Lines Matching full:stp
391 set_access(u32 access, struct nfs4_ol_stateid *stp) in set_access() argument
396 stp->st_access_bmap |= mask; in set_access()
401 clear_access(u32 access, struct nfs4_ol_stateid *stp) in clear_access() argument
406 stp->st_access_bmap &= ~mask; in clear_access()
411 test_access(u32 access, struct nfs4_ol_stateid *stp) in test_access() argument
415 return (bool)(stp->st_access_bmap & mask); in test_access()
420 set_deny(u32 deny, struct nfs4_ol_stateid *stp) in set_deny() argument
425 stp->st_deny_bmap |= mask; in set_deny()
430 clear_deny(u32 deny, struct nfs4_ol_stateid *stp) in clear_deny() argument
435 stp->st_deny_bmap &= ~mask; in clear_deny()
440 test_deny(u32 deny, struct nfs4_ol_stateid *stp) in test_deny() argument
444 return (bool)(stp->st_deny_bmap & mask); in test_deny()
462 access_permit_read(struct nfs4_ol_stateid *stp) in access_permit_read() argument
464 return test_access(NFS4_SHARE_ACCESS_READ, stp) || in access_permit_read()
465 test_access(NFS4_SHARE_ACCESS_BOTH, stp) || in access_permit_read()
466 test_access(NFS4_SHARE_ACCESS_WRITE, stp); in access_permit_read()
470 access_permit_write(struct nfs4_ol_stateid *stp) in access_permit_write() argument
472 return test_access(NFS4_SHARE_ACCESS_WRITE, stp) || in access_permit_write()
473 test_access(NFS4_SHARE_ACCESS_BOTH, stp); in access_permit_write()
1279 struct nfs4_ol_stateid *stp; in recalculate_deny_mode() local
1283 list_for_each_entry(stp, &fp->fi_stateids, st_perfile) in recalculate_deny_mode()
1284 fp->fi_share_deny |= bmap_to_share_mode(stp->st_deny_bmap); in recalculate_deny_mode()
1289 reset_union_bmap_deny(u32 deny, struct nfs4_ol_stateid *stp) in reset_union_bmap_deny() argument
1297 clear_deny(i, stp); in reset_union_bmap_deny()
1303 recalculate_deny_mode(stp->st_stid.sc_file); in reset_union_bmap_deny()
1308 release_all_access(struct nfs4_ol_stateid *stp) in release_all_access() argument
1311 struct nfs4_file *fp = stp->st_stid.sc_file; in release_all_access()
1313 if (fp && stp->st_deny_bmap != 0) in release_all_access()
1317 if (test_access(i, stp)) in release_all_access()
1318 nfs4_file_put_access(stp->st_stid.sc_file, i); in release_all_access()
1319 clear_access(i, stp); in release_all_access()
1343 nfs4_ol_stateid_unhashed(const struct nfs4_ol_stateid *stp) in nfs4_ol_stateid_unhashed() argument
1345 return list_empty(&stp->st_perfile); in nfs4_ol_stateid_unhashed()
1348 static bool unhash_ol_stateid(struct nfs4_ol_stateid *stp) in unhash_ol_stateid() argument
1350 struct nfs4_file *fp = stp->st_stid.sc_file; in unhash_ol_stateid()
1352 lockdep_assert_held(&stp->st_stateowner->so_client->cl_lock); in unhash_ol_stateid()
1354 if (list_empty(&stp->st_perfile)) in unhash_ol_stateid()
1358 list_del_init(&stp->st_perfile); in unhash_ol_stateid()
1360 list_del(&stp->st_perstateowner); in unhash_ol_stateid()
1366 struct nfs4_ol_stateid *stp = openlockstateid(stid); in nfs4_free_ol_stateid() local
1368 put_clnt_odstate(stp->st_clnt_odstate); in nfs4_free_ol_stateid()
1369 release_all_access(stp); in nfs4_free_ol_stateid()
1370 if (stp->st_stateowner) in nfs4_free_ol_stateid()
1371 nfs4_put_stateowner(stp->st_stateowner); in nfs4_free_ol_stateid()
1377 struct nfs4_ol_stateid *stp = openlockstateid(stid); in nfs4_free_lock_stateid() local
1378 struct nfs4_lockowner *lo = lockowner(stp->st_stateowner); in nfs4_free_lock_stateid()
1381 nf = find_any_file(stp->st_stid.sc_file); in nfs4_free_lock_stateid()
1395 static void put_ol_stateid_locked(struct nfs4_ol_stateid *stp, in put_ol_stateid_locked() argument
1398 struct nfs4_stid *s = &stp->st_stid; in put_ol_stateid_locked()
1403 WARN_ON_ONCE(!list_empty(&stp->st_locks)); in put_ol_stateid_locked()
1411 list_add(&stp->st_locks, reaplist); in put_ol_stateid_locked()
1414 static bool unhash_lock_stateid(struct nfs4_ol_stateid *stp) in unhash_lock_stateid() argument
1416 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock); in unhash_lock_stateid()
1418 if (!unhash_ol_stateid(stp)) in unhash_lock_stateid()
1420 list_del_init(&stp->st_locks); in unhash_lock_stateid()
1421 nfs4_unhash_stid(&stp->st_stid); in unhash_lock_stateid()
1425 static void release_lock_stateid(struct nfs4_ol_stateid *stp) in release_lock_stateid() argument
1427 struct nfs4_client *clp = stp->st_stid.sc_client; in release_lock_stateid()
1431 unhashed = unhash_lock_stateid(stp); in release_lock_stateid()
1434 nfs4_put_stid(&stp->st_stid); in release_lock_stateid()
1453 struct nfs4_ol_stateid *stp; in free_ol_stateid_reaplist() local
1459 stp = list_first_entry(reaplist, struct nfs4_ol_stateid, in free_ol_stateid_reaplist()
1461 list_del(&stp->st_locks); in free_ol_stateid_reaplist()
1462 fp = stp->st_stid.sc_file; in free_ol_stateid_reaplist()
1463 stp->st_stid.sc_free(&stp->st_stid); in free_ol_stateid_reaplist()
1472 struct nfs4_ol_stateid *stp; in release_open_stateid_locks() local
1477 stp = list_entry(open_stp->st_locks.next, in release_open_stateid_locks()
1479 WARN_ON(!unhash_lock_stateid(stp)); in release_open_stateid_locks()
1480 put_ol_stateid_locked(stp, reaplist); in release_open_stateid_locks()
1484 static bool unhash_open_stateid(struct nfs4_ol_stateid *stp, in unhash_open_stateid() argument
1487 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock); in unhash_open_stateid()
1489 if (!unhash_ol_stateid(stp)) in unhash_open_stateid()
1491 release_open_stateid_locks(stp, reaplist); in unhash_open_stateid()
1495 static void release_open_stateid(struct nfs4_ol_stateid *stp) in release_open_stateid() argument
1499 spin_lock(&stp->st_stid.sc_client->cl_lock); in release_open_stateid()
1500 if (unhash_open_stateid(stp, &reaplist)) in release_open_stateid()
1501 put_ol_stateid_locked(stp, &reaplist); in release_open_stateid()
1502 spin_unlock(&stp->st_stid.sc_client->cl_lock); in release_open_stateid()
1535 struct nfs4_ol_stateid *stp; in release_openowner() local
1544 stp = list_first_entry(&oo->oo_owner.so_stateids, in release_openowner()
1546 if (unhash_open_stateid(stp, &reaplist)) in release_openowner()
1547 put_ol_stateid_locked(stp, &reaplist); in release_openowner()
4347 nfsd4_lock_ol_stateid(struct nfs4_ol_stateid *stp) in nfsd4_lock_ol_stateid() argument
4351 mutex_lock_nested(&stp->st_mutex, LOCK_STATEID_MUTEX); in nfsd4_lock_ol_stateid()
4352 ret = nfsd4_verify_open_stid(&stp->st_stid); in nfsd4_lock_ol_stateid()
4354 mutex_unlock(&stp->st_mutex); in nfsd4_lock_ol_stateid()
4361 struct nfs4_ol_stateid *stp; in nfsd4_find_and_lock_existing_open() local
4364 stp = nfsd4_find_existing_open(fp, open); in nfsd4_find_and_lock_existing_open()
4366 if (!stp || nfsd4_lock_ol_stateid(stp) == nfs_ok) in nfsd4_find_and_lock_existing_open()
4368 nfs4_put_stid(&stp->st_stid); in nfsd4_find_and_lock_existing_open()
4370 return stp; in nfsd4_find_and_lock_existing_open()
4410 struct nfs4_ol_stateid *stp; in init_open_stateid() local
4412 stp = open->op_stp; in init_open_stateid()
4414 mutex_init(&stp->st_mutex); in init_open_stateid()
4415 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX); in init_open_stateid()
4426 refcount_inc(&stp->st_stid.sc_count); in init_open_stateid()
4427 stp->st_stid.sc_type = NFS4_OPEN_STID; in init_open_stateid()
4428 INIT_LIST_HEAD(&stp->st_locks); in init_open_stateid()
4429 stp->st_stateowner = nfs4_get_stateowner(&oo->oo_owner); in init_open_stateid()
4431 stp->st_stid.sc_file = fp; in init_open_stateid()
4432 stp->st_access_bmap = 0; in init_open_stateid()
4433 stp->st_deny_bmap = 0; in init_open_stateid()
4434 stp->st_openstp = NULL; in init_open_stateid()
4435 list_add(&stp->st_perstateowner, &oo->oo_owner.so_stateids); in init_open_stateid()
4436 list_add(&stp->st_perfile, &fp->fi_stateids); in init_open_stateid()
4448 mutex_unlock(&stp->st_mutex); in init_open_stateid()
4449 stp = retstp; in init_open_stateid()
4451 return stp; in init_open_stateid()
4916 struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, in nfs4_get_vfs_file() argument
4945 old_access_bmap = stp->st_access_bmap; in nfs4_get_vfs_file()
4946 set_access(open->op_share_access, stp); in nfs4_get_vfs_file()
4949 old_deny_bmap = stp->st_deny_bmap; in nfs4_get_vfs_file()
4950 set_deny(open->op_share_deny, stp); in nfs4_get_vfs_file()
4979 stp->st_access_bmap = old_access_bmap; in nfs4_get_vfs_file()
4981 reset_union_bmap_deny(bmap_to_share_mode(old_deny_bmap), stp); in nfs4_get_vfs_file()
4986 …qstp, struct nfs4_file *fp, struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, struct nfsd4_open … in nfs4_upgrade_open() argument
4989 unsigned char old_deny_bmap = stp->st_deny_bmap; in nfs4_upgrade_open()
4991 if (!test_access(open->op_share_access, stp)) in nfs4_upgrade_open()
4992 return nfs4_get_vfs_file(rqstp, fp, cur_fh, stp, open); in nfs4_upgrade_open()
4998 set_deny(open->op_share_deny, stp); in nfs4_upgrade_open()
5009 reset_union_bmap_deny(old_deny_bmap, stp); in nfs4_upgrade_open()
5218 struct nfs4_ol_stateid *stp) in nfs4_open_delegation() argument
5221 struct nfs4_openowner *oo = openowner(stp->st_stateowner); in nfs4_open_delegation()
5222 struct nfs4_client *clp = stp->st_stid.sc_client; in nfs4_open_delegation()
5250 dp = nfs4_set_delegation(clp, fh, stp->st_stid.sc_file, stp->st_clnt_odstate); in nfs4_open_delegation()
5298 struct nfs4_ol_stateid *stp = NULL; in nfsd4_process_open2() local
5313 stp = nfsd4_find_and_lock_existing_open(fp, open); in nfsd4_process_open2()
5321 if (!stp) { in nfsd4_process_open2()
5322 stp = init_open_stateid(fp, open); in nfsd4_process_open2()
5331 * stp is already locked. in nfsd4_process_open2()
5335 status = nfs4_upgrade_open(rqstp, fp, current_fh, stp, open); in nfsd4_process_open2()
5337 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
5341 status = nfs4_get_vfs_file(rqstp, fp, current_fh, stp, open); in nfsd4_process_open2()
5343 stp->st_stid.sc_type = NFS4_CLOSED_STID; in nfsd4_process_open2()
5344 release_open_stateid(stp); in nfsd4_process_open2()
5345 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
5349 stp->st_clnt_odstate = find_or_hash_clnt_odstate(fp, in nfsd4_process_open2()
5351 if (stp->st_clnt_odstate == open->op_odstate) in nfsd4_process_open2()
5355 nfs4_inc_and_copy_stateid(&open->op_stateid, &stp->st_stid); in nfsd4_process_open2()
5356 mutex_unlock(&stp->st_mutex); in nfsd4_process_open2()
5370 nfs4_open_delegation(current_fh, open, stp); in nfsd4_process_open2()
5373 trace_nfsd_open(&stp->st_stid.sc_stateid); in nfsd4_process_open2()
5395 if (stp) in nfsd4_process_open2()
5396 nfs4_put_stid(&stp->st_stid); in nfsd4_process_open2()
5581 struct nfs4_ol_stateid *stp; in nfs4_laundromat() local
5647 stp = oo->oo_last_closed_stid; in nfs4_laundromat()
5650 nfs4_put_stid(&stp->st_stid); in nfs4_laundromat()
5707 static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stid *stp) in nfs4_check_fh() argument
5709 if (!fh_match(&fhp->fh_handle, &stp->sc_file->fi_fhandle)) in nfs4_check_fh()
5715 __be32 nfs4_check_openmode(struct nfs4_ol_stateid *stp, int flags) in nfs4_check_openmode() argument
5720 if (stp->st_openstp) in nfs4_check_openmode()
5721 stp = stp->st_openstp; in nfs4_check_openmode()
5722 if ((flags & WR_STATE) && !access_permit_write(stp)) in nfs4_check_openmode()
5724 if ((flags & RD_STATE) && !access_permit_read(stp)) in nfs4_check_openmode()
6104 struct nfs4_ol_stateid *stp = openlockstateid(s); in nfsd4_free_lock_stateid() local
6107 ret = nfsd4_lock_ol_stateid(stp); in nfsd4_free_lock_stateid()
6116 if (check_for_locks(stp->st_stid.sc_file, in nfsd4_free_lock_stateid()
6117 lockowner(stp->st_stateowner))) in nfsd4_free_lock_stateid()
6120 release_lock_stateid(stp); in nfsd4_free_lock_stateid()
6124 mutex_unlock(&stp->st_mutex); in nfsd4_free_lock_stateid()
6186 …ks(struct nfsd4_compound_state *cstate, stateid_t *stateid, u32 seqid, struct nfs4_ol_stateid *stp) in nfs4_seqid_op_checks() argument
6189 struct nfs4_stateowner *sop = stp->st_stateowner; in nfs4_seqid_op_checks()
6195 status = nfsd4_lock_ol_stateid(stp); in nfs4_seqid_op_checks()
6198 status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate)); in nfs4_seqid_op_checks()
6200 status = nfs4_check_fh(current_fh, &stp->st_stid); in nfs4_seqid_op_checks()
6202 mutex_unlock(&stp->st_mutex); in nfs4_seqid_op_checks()
6217 struct nfs4_ol_stateid *stp = NULL; in nfs4_preprocess_seqid_op() local
6225 stp = openlockstateid(s); in nfs4_preprocess_seqid_op()
6226 nfsd4_cstate_assign_replay(cstate, stp->st_stateowner); in nfs4_preprocess_seqid_op()
6228 status = nfs4_seqid_op_checks(cstate, stateid, seqid, stp); in nfs4_preprocess_seqid_op()
6230 *stpp = stp; in nfs4_preprocess_seqid_op()
6232 nfs4_put_stid(&stp->st_stid); in nfs4_preprocess_seqid_op()
6241 struct nfs4_ol_stateid *stp; in nfs4_preprocess_confirmed_seqid_op() local
6244 NFS4_OPEN_STID, &stp, nn); in nfs4_preprocess_confirmed_seqid_op()
6247 oo = openowner(stp->st_stateowner); in nfs4_preprocess_confirmed_seqid_op()
6249 mutex_unlock(&stp->st_mutex); in nfs4_preprocess_confirmed_seqid_op()
6250 nfs4_put_stid(&stp->st_stid); in nfs4_preprocess_confirmed_seqid_op()
6253 *stpp = stp; in nfs4_preprocess_confirmed_seqid_op()
6264 struct nfs4_ol_stateid *stp; in nfsd4_open_confirm() local
6276 NFS4_OPEN_STID, &stp, nn); in nfsd4_open_confirm()
6279 oo = openowner(stp->st_stateowner); in nfsd4_open_confirm()
6282 mutex_unlock(&stp->st_mutex); in nfsd4_open_confirm()
6286 nfs4_inc_and_copy_stateid(&oc->oc_resp_stateid, &stp->st_stid); in nfsd4_open_confirm()
6287 mutex_unlock(&stp->st_mutex); in nfsd4_open_confirm()
6288 trace_nfsd_open_confirm(oc->oc_seqid, &stp->st_stid.sc_stateid); in nfsd4_open_confirm()
6292 nfs4_put_stid(&stp->st_stid); in nfsd4_open_confirm()
6298 static inline void nfs4_stateid_downgrade_bit(struct nfs4_ol_stateid *stp, u32 access) in nfs4_stateid_downgrade_bit() argument
6300 if (!test_access(access, stp)) in nfs4_stateid_downgrade_bit()
6302 nfs4_file_put_access(stp->st_stid.sc_file, access); in nfs4_stateid_downgrade_bit()
6303 clear_access(access, stp); in nfs4_stateid_downgrade_bit()
6306 static inline void nfs4_stateid_downgrade(struct nfs4_ol_stateid *stp, u32 to_access) in nfs4_stateid_downgrade() argument
6310 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_WRITE); in nfs4_stateid_downgrade()
6311 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH); in nfs4_stateid_downgrade()
6314 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_READ); in nfs4_stateid_downgrade()
6315 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH); in nfs4_stateid_downgrade()
6330 struct nfs4_ol_stateid *stp; in nfsd4_open_downgrade() local
6342 &od->od_stateid, &stp, nn); in nfsd4_open_downgrade()
6346 if (!test_access(od->od_share_access, stp)) { in nfsd4_open_downgrade()
6348 stp->st_access_bmap, od->od_share_access); in nfsd4_open_downgrade()
6351 if (!test_deny(od->od_share_deny, stp)) { in nfsd4_open_downgrade()
6353 stp->st_deny_bmap, od->od_share_deny); in nfsd4_open_downgrade()
6356 nfs4_stateid_downgrade(stp, od->od_share_access); in nfsd4_open_downgrade()
6357 reset_union_bmap_deny(od->od_share_deny, stp); in nfsd4_open_downgrade()
6358 nfs4_inc_and_copy_stateid(&od->od_stateid, &stp->st_stid); in nfsd4_open_downgrade()
6361 mutex_unlock(&stp->st_mutex); in nfsd4_open_downgrade()
6362 nfs4_put_stid(&stp->st_stid); in nfsd4_open_downgrade()
6399 struct nfs4_ol_stateid *stp; in nfsd4_close() local
6409 &stp, nn); in nfsd4_close()
6414 stp->st_stid.sc_type = NFS4_CLOSED_STID; in nfsd4_close()
6422 nfs4_inc_and_copy_stateid(&close->cl_stateid, &stp->st_stid); in nfsd4_close()
6424 nfsd4_close_open_stateid(stp); in nfsd4_close()
6425 mutex_unlock(&stp->st_mutex); in nfsd4_close()
6437 nfs4_put_stid(&stp->st_stid); in nfsd4_close()
6678 init_lock_stateid(struct nfs4_ol_stateid *stp, struct nfs4_lockowner *lo, in init_lock_stateid() argument
6685 mutex_init(&stp->st_mutex); in init_lock_stateid()
6686 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX); in init_lock_stateid()
6694 refcount_inc(&stp->st_stid.sc_count); in init_lock_stateid()
6695 stp->st_stid.sc_type = NFS4_LOCK_STID; in init_lock_stateid()
6696 stp->st_stateowner = nfs4_get_stateowner(&lo->lo_owner); in init_lock_stateid()
6698 stp->st_stid.sc_file = fp; in init_lock_stateid()
6699 stp->st_access_bmap = 0; in init_lock_stateid()
6700 stp->st_deny_bmap = open_stp->st_deny_bmap; in init_lock_stateid()
6701 stp->st_openstp = open_stp; in init_lock_stateid()
6703 list_add(&stp->st_locks, &open_stp->st_locks); in init_lock_stateid()
6704 list_add(&stp->st_perstateowner, &lo->lo_owner.so_stateids); in init_lock_stateid()
6705 list_add(&stp->st_perfile, &fp->fi_stateids); in init_lock_stateid()
6708 return stp; in init_lock_stateid()
6716 mutex_unlock(&stp->st_mutex); in init_lock_stateid()
6720 mutex_unlock(&stp->st_mutex); in init_lock_stateid()
7148 struct nfs4_ol_stateid *stp; in nfsd4_locku() local
7164 &stp, nn); in nfsd4_locku()
7167 nf = find_any_file(stp->st_stid.sc_file); in nfsd4_locku()
7180 file_lock->fl_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(stp->st_stateowner)); in nfsd4_locku()
7196 nfs4_inc_and_copy_stateid(&locku->lu_stateid, &stp->st_stid); in nfsd4_locku()
7200 mutex_unlock(&stp->st_mutex); in nfsd4_locku()
7201 nfs4_put_stid(&stp->st_stid); in nfsd4_locku()
7259 struct nfs4_ol_stateid *stp; in nfsd4_release_lockowner() local
7285 list_for_each_entry(stp, &sop->so_stateids, st_perstateowner) { in nfsd4_release_lockowner()
7286 if (check_for_locks(stp->st_stid.sc_file, lo)) { in nfsd4_release_lockowner()
7303 stp = list_first_entry(&lo->lo_owner.so_stateids, in nfsd4_release_lockowner()
7306 WARN_ON(!unhash_lock_stateid(stp)); in nfsd4_release_lockowner()
7307 put_ol_stateid_locked(stp, &reaplist); in nfsd4_release_lockowner()