Lines Matching refs:stp
1203 set_access(u32 access, struct nfs4_ol_stateid *stp)
1208 stp->st_access_bmap |= mask;
1213 clear_access(u32 access, struct nfs4_ol_stateid *stp)
1218 stp->st_access_bmap &= ~mask;
1223 test_access(u32 access, struct nfs4_ol_stateid *stp)
1227 return (bool)(stp->st_access_bmap & mask);
1232 set_deny(u32 deny, struct nfs4_ol_stateid *stp)
1237 stp->st_deny_bmap |= mask;
1242 clear_deny(u32 deny, struct nfs4_ol_stateid *stp)
1247 stp->st_deny_bmap &= ~mask;
1252 test_deny(u32 deny, struct nfs4_ol_stateid *stp)
1256 return (bool)(stp->st_deny_bmap & mask);
1280 struct nfs4_ol_stateid *stp;
1284 list_for_each_entry(stp, &fp->fi_stateids, st_perfile)
1285 fp->fi_share_deny |= bmap_to_share_mode(stp->st_deny_bmap);
1290 reset_union_bmap_deny(u32 deny, struct nfs4_ol_stateid *stp)
1298 clear_deny(i, stp);
1304 recalculate_deny_mode(stp->st_stid.sc_file);
1309 release_all_access(struct nfs4_ol_stateid *stp)
1312 struct nfs4_file *fp = stp->st_stid.sc_file;
1314 if (fp && stp->st_deny_bmap != 0)
1318 if (test_access(i, stp))
1319 nfs4_file_put_access(stp->st_stid.sc_file, i);
1320 clear_access(i, stp);
1344 nfs4_ol_stateid_unhashed(const struct nfs4_ol_stateid *stp)
1346 return list_empty(&stp->st_perfile);
1349 static bool unhash_ol_stateid(struct nfs4_ol_stateid *stp)
1351 struct nfs4_file *fp = stp->st_stid.sc_file;
1353 lockdep_assert_held(&stp->st_stateowner->so_client->cl_lock);
1355 if (list_empty(&stp->st_perfile))
1359 list_del_init(&stp->st_perfile);
1361 list_del(&stp->st_perstateowner);
1367 struct nfs4_ol_stateid *stp = openlockstateid(stid);
1369 put_clnt_odstate(stp->st_clnt_odstate);
1370 release_all_access(stp);
1371 if (stp->st_stateowner)
1372 nfs4_put_stateowner(stp->st_stateowner);
1379 struct nfs4_ol_stateid *stp = openlockstateid(stid);
1380 struct nfs4_lockowner *lo = lockowner(stp->st_stateowner);
1383 nf = find_any_file(stp->st_stid.sc_file);
1397 static void put_ol_stateid_locked(struct nfs4_ol_stateid *stp,
1400 struct nfs4_stid *s = &stp->st_stid;
1405 WARN_ON_ONCE(!list_empty(&stp->st_locks));
1413 list_add(&stp->st_locks, reaplist);
1416 static bool unhash_lock_stateid(struct nfs4_ol_stateid *stp)
1418 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock);
1420 if (!unhash_ol_stateid(stp))
1422 list_del_init(&stp->st_locks);
1423 nfs4_unhash_stid(&stp->st_stid);
1427 static void release_lock_stateid(struct nfs4_ol_stateid *stp)
1429 struct nfs4_client *clp = stp->st_stid.sc_client;
1433 unhashed = unhash_lock_stateid(stp);
1436 nfs4_put_stid(&stp->st_stid);
1455 struct nfs4_ol_stateid *stp;
1461 stp = list_first_entry(reaplist, struct nfs4_ol_stateid,
1463 list_del(&stp->st_locks);
1464 fp = stp->st_stid.sc_file;
1465 stp->st_stid.sc_free(&stp->st_stid);
1474 struct nfs4_ol_stateid *stp;
1479 stp = list_entry(open_stp->st_locks.next,
1481 WARN_ON(!unhash_lock_stateid(stp));
1482 put_ol_stateid_locked(stp, reaplist);
1486 static bool unhash_open_stateid(struct nfs4_ol_stateid *stp,
1489 lockdep_assert_held(&stp->st_stid.sc_client->cl_lock);
1491 if (!unhash_ol_stateid(stp))
1493 release_open_stateid_locks(stp, reaplist);
1497 static void release_open_stateid(struct nfs4_ol_stateid *stp)
1501 spin_lock(&stp->st_stid.sc_client->cl_lock);
1502 if (unhash_open_stateid(stp, &reaplist))
1503 put_ol_stateid_locked(stp, &reaplist);
1504 spin_unlock(&stp->st_stid.sc_client->cl_lock);
1537 struct nfs4_ol_stateid *stp;
1546 stp = list_first_entry(&oo->oo_owner.so_stateids,
1548 if (unhash_open_stateid(stp, &reaplist))
1549 put_ol_stateid_locked(stp, &reaplist);
4301 nfsd4_lock_ol_stateid(struct nfs4_ol_stateid *stp)
4305 mutex_lock_nested(&stp->st_mutex, LOCK_STATEID_MUTEX);
4306 ret = nfsd4_verify_open_stid(&stp->st_stid);
4308 mutex_unlock(&stp->st_mutex);
4315 struct nfs4_ol_stateid *stp;
4318 stp = nfsd4_find_existing_open(fp, open);
4320 if (!stp || nfsd4_lock_ol_stateid(stp) == nfs_ok)
4322 nfs4_put_stid(&stp->st_stid);
4324 return stp;
4364 struct nfs4_ol_stateid *stp;
4366 stp = open->op_stp;
4368 mutex_init(&stp->st_mutex);
4369 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX);
4380 refcount_inc(&stp->st_stid.sc_count);
4381 stp->st_stid.sc_type = NFS4_OPEN_STID;
4382 INIT_LIST_HEAD(&stp->st_locks);
4383 stp->st_stateowner = nfs4_get_stateowner(&oo->oo_owner);
4385 stp->st_stid.sc_file = fp;
4386 stp->st_access_bmap = 0;
4387 stp->st_deny_bmap = 0;
4388 stp->st_openstp = NULL;
4389 list_add(&stp->st_perstateowner, &oo->oo_owner.so_stateids);
4390 list_add(&stp->st_perfile, &fp->fi_stateids);
4402 mutex_unlock(&stp->st_mutex);
4403 stp = retstp;
4405 return stp;
4867 struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp,
4896 old_access_bmap = stp->st_access_bmap;
4897 set_access(open->op_share_access, stp);
4900 old_deny_bmap = stp->st_deny_bmap;
4901 set_deny(open->op_share_deny, stp);
4930 stp->st_access_bmap = old_access_bmap;
4932 reset_union_bmap_deny(bmap_to_share_mode(old_deny_bmap), stp);
4937 nfs4_upgrade_open(struct svc_rqst *rqstp, struct nfs4_file *fp, struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, struct nfsd4_open *open)
4940 unsigned char old_deny_bmap = stp->st_deny_bmap;
4942 if (!test_access(open->op_share_access, stp))
4943 return nfs4_get_vfs_file(rqstp, fp, cur_fh, stp, open);
4949 set_deny(open->op_share_deny, stp);
4960 reset_union_bmap_deny(old_deny_bmap, stp);
5104 struct nfs4_ol_stateid *stp)
5107 struct nfs4_openowner *oo = openowner(stp->st_stateowner);
5108 struct nfs4_client *clp = stp->st_stid.sc_client;
5147 dp = nfs4_set_delegation(clp, fh, stp->st_stid.sc_file, stp->st_clnt_odstate);
5195 struct nfs4_ol_stateid *stp = NULL;
5210 stp = nfsd4_find_and_lock_existing_open(fp, open);
5218 if (!stp) {
5219 stp = init_open_stateid(fp, open);
5228 * stp is already locked.
5232 status = nfs4_upgrade_open(rqstp, fp, current_fh, stp, open);
5234 mutex_unlock(&stp->st_mutex);
5238 status = nfs4_get_vfs_file(rqstp, fp, current_fh, stp, open);
5240 stp->st_stid.sc_type = NFS4_CLOSED_STID;
5241 release_open_stateid(stp);
5242 mutex_unlock(&stp->st_mutex);
5246 stp->st_clnt_odstate = find_or_hash_clnt_odstate(fp,
5248 if (stp->st_clnt_odstate == open->op_odstate)
5252 nfs4_inc_and_copy_stateid(&open->op_stateid, &stp->st_stid);
5253 mutex_unlock(&stp->st_mutex);
5267 nfs4_open_delegation(current_fh, open, stp);
5270 trace_nfsd_open(&stp->st_stid.sc_stateid);
5292 if (stp)
5293 nfs4_put_stid(&stp->st_stid);
5402 struct nfs4_ol_stateid *stp;
5477 stp = oo->oo_last_closed_stid;
5480 nfs4_put_stid(&stp->st_stid);
5537 static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stid *stp)
5539 if (!fh_match(&fhp->fh_handle, &stp->sc_file->fi_fhandle))
5545 access_permit_read(struct nfs4_ol_stateid *stp)
5547 return test_access(NFS4_SHARE_ACCESS_READ, stp) ||
5548 test_access(NFS4_SHARE_ACCESS_BOTH, stp) ||
5549 test_access(NFS4_SHARE_ACCESS_WRITE, stp);
5553 access_permit_write(struct nfs4_ol_stateid *stp)
5555 return test_access(NFS4_SHARE_ACCESS_WRITE, stp) ||
5556 test_access(NFS4_SHARE_ACCESS_BOTH, stp);
5560 __be32 nfs4_check_openmode(struct nfs4_ol_stateid *stp, int flags)
5565 if (stp->st_openstp)
5566 stp = stp->st_openstp;
5567 if ((flags & WR_STATE) && !access_permit_write(stp))
5569 if ((flags & RD_STATE) && !access_permit_read(stp))
5956 struct nfs4_ol_stateid *stp = openlockstateid(s);
5959 ret = nfsd4_lock_ol_stateid(stp);
5968 if (check_for_locks(stp->st_stid.sc_file,
5969 lockowner(stp->st_stateowner)))
5972 release_lock_stateid(stp);
5976 mutex_unlock(&stp->st_mutex);
6038 static __be32 nfs4_seqid_op_checks(struct nfsd4_compound_state *cstate, stateid_t *stateid, u32 seqid, struct nfs4_ol_stateid *stp)
6041 struct nfs4_stateowner *sop = stp->st_stateowner;
6047 status = nfsd4_lock_ol_stateid(stp);
6050 status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate));
6052 status = nfs4_check_fh(current_fh, &stp->st_stid);
6054 mutex_unlock(&stp->st_mutex);
6069 struct nfs4_ol_stateid *stp = NULL;
6077 stp = openlockstateid(s);
6078 nfsd4_cstate_assign_replay(cstate, stp->st_stateowner);
6080 status = nfs4_seqid_op_checks(cstate, stateid, seqid, stp);
6082 *stpp = stp;
6084 nfs4_put_stid(&stp->st_stid);
6093 struct nfs4_ol_stateid *stp;
6096 NFS4_OPEN_STID, &stp, nn);
6099 oo = openowner(stp->st_stateowner);
6101 mutex_unlock(&stp->st_mutex);
6102 nfs4_put_stid(&stp->st_stid);
6105 *stpp = stp;
6116 struct nfs4_ol_stateid *stp;
6128 NFS4_OPEN_STID, &stp, nn);
6131 oo = openowner(stp->st_stateowner);
6134 mutex_unlock(&stp->st_mutex);
6138 nfs4_inc_and_copy_stateid(&oc->oc_resp_stateid, &stp->st_stid);
6139 mutex_unlock(&stp->st_mutex);
6140 trace_nfsd_open_confirm(oc->oc_seqid, &stp->st_stid.sc_stateid);
6144 nfs4_put_stid(&stp->st_stid);
6150 static inline void nfs4_stateid_downgrade_bit(struct nfs4_ol_stateid *stp, u32 access)
6152 if (!test_access(access, stp))
6154 nfs4_file_put_access(stp->st_stid.sc_file, access);
6155 clear_access(access, stp);
6158 static inline void nfs4_stateid_downgrade(struct nfs4_ol_stateid *stp, u32 to_access)
6162 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_WRITE);
6163 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH);
6166 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_READ);
6167 nfs4_stateid_downgrade_bit(stp, NFS4_SHARE_ACCESS_BOTH);
6182 struct nfs4_ol_stateid *stp;
6194 &od->od_stateid, &stp, nn);
6198 if (!test_access(od->od_share_access, stp)) {
6200 stp->st_access_bmap, od->od_share_access);
6203 if (!test_deny(od->od_share_deny, stp)) {
6205 stp->st_deny_bmap, od->od_share_deny);
6208 nfs4_stateid_downgrade(stp, od->od_share_access);
6209 reset_union_bmap_deny(od->od_share_deny, stp);
6210 nfs4_inc_and_copy_stateid(&od->od_stateid, &stp->st_stid);
6213 mutex_unlock(&stp->st_mutex);
6214 nfs4_put_stid(&stp->st_stid);
6225 struct nfs4_ol_stateid *stp;
6234 list_for_each_entry(stp, &reaplist, st_locks)
6235 nfs4_free_cpntf_statelist(clp->net, &stp->st_stid);
6254 struct nfs4_ol_stateid *stp;
6264 &stp, nn);
6269 stp->st_stid.sc_type = NFS4_CLOSED_STID;
6277 nfs4_inc_and_copy_stateid(&close->cl_stateid, &stp->st_stid);
6279 nfsd4_close_open_stateid(stp);
6280 mutex_unlock(&stp->st_mutex);
6292 nfs4_put_stid(&stp->st_stid);
6540 init_lock_stateid(struct nfs4_ol_stateid *stp, struct nfs4_lockowner *lo,
6547 mutex_init(&stp->st_mutex);
6548 mutex_lock_nested(&stp->st_mutex, OPEN_STATEID_MUTEX);
6556 refcount_inc(&stp->st_stid.sc_count);
6557 stp->st_stid.sc_type = NFS4_LOCK_STID;
6558 stp->st_stateowner = nfs4_get_stateowner(&lo->lo_owner);
6560 stp->st_stid.sc_file = fp;
6561 stp->st_access_bmap = 0;
6562 stp->st_deny_bmap = open_stp->st_deny_bmap;
6563 stp->st_openstp = open_stp;
6565 list_add(&stp->st_locks, &open_stp->st_locks);
6566 list_add(&stp->st_perstateowner, &lo->lo_owner.so_stateids);
6567 list_add(&stp->st_perfile, &fp->fi_stateids);
6570 return stp;
6578 mutex_unlock(&stp->st_mutex);
6582 mutex_unlock(&stp->st_mutex);
7008 struct nfs4_ol_stateid *stp;
7024 &stp, nn);
7027 nf = find_any_file(stp->st_stid.sc_file);
7040 file_lock->fl_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(stp->st_stateowner));
7056 nfs4_inc_and_copy_stateid(&locku->lu_stateid, &stp->st_stid);
7060 mutex_unlock(&stp->st_mutex);
7061 nfs4_put_stid(&stp->st_stid);
7119 struct nfs4_ol_stateid *stp;
7159 stp = list_first_entry(&lo->lo_owner.so_stateids,
7162 WARN_ON(!unhash_lock_stateid(stp));
7163 put_ol_stateid_locked(stp, &reaplist);