Lines Matching refs:fp

74 static bool check_for_locks(struct nfs4_file *fp, struct nfs4_lockowner *lowner);
272 struct nfs4_file *fp = container_of(rcu, struct nfs4_file, fi_rcu); in nfsd4_free_file_rcu() local
274 kmem_cache_free(file_slab, fp); in nfsd4_free_file_rcu()
401 __nfs4_file_get_access(struct nfs4_file *fp, u32 access) in __nfs4_file_get_access() argument
403 lockdep_assert_held(&fp->fi_lock); in __nfs4_file_get_access()
406 atomic_inc(&fp->fi_access[O_WRONLY]); in __nfs4_file_get_access()
408 atomic_inc(&fp->fi_access[O_RDONLY]); in __nfs4_file_get_access()
412 nfs4_file_get_access(struct nfs4_file *fp, u32 access) in nfs4_file_get_access() argument
414 lockdep_assert_held(&fp->fi_lock); in nfs4_file_get_access()
421 if ((access & fp->fi_share_deny) != 0) in nfs4_file_get_access()
424 __nfs4_file_get_access(fp, access); in nfs4_file_get_access()
428 static __be32 nfs4_file_check_deny(struct nfs4_file *fp, u32 deny) in nfs4_file_check_deny() argument
437 atomic_read(&fp->fi_access[O_RDONLY])) in nfs4_file_check_deny()
441 atomic_read(&fp->fi_access[O_WRONLY])) in nfs4_file_check_deny()
447 static void __nfs4_file_put_access(struct nfs4_file *fp, int oflag) in __nfs4_file_put_access() argument
449 might_lock(&fp->fi_lock); in __nfs4_file_put_access()
451 if (atomic_dec_and_lock(&fp->fi_access[oflag], &fp->fi_lock)) { in __nfs4_file_put_access()
455 swap(f1, fp->fi_fds[oflag]); in __nfs4_file_put_access()
456 if (atomic_read(&fp->fi_access[1 - oflag]) == 0) in __nfs4_file_put_access()
457 swap(f2, fp->fi_fds[O_RDWR]); in __nfs4_file_put_access()
458 spin_unlock(&fp->fi_lock); in __nfs4_file_put_access()
466 static void nfs4_file_put_access(struct nfs4_file *fp, u32 access) in nfs4_file_put_access() argument
471 __nfs4_file_put_access(fp, O_WRONLY); in nfs4_file_put_access()
473 __nfs4_file_put_access(fp, O_RDONLY); in nfs4_file_put_access()
499 struct nfs4_file *fp = co->co_file; in hash_clnt_odstate_locked() local
501 lockdep_assert_held(&fp->fi_lock); in hash_clnt_odstate_locked()
502 list_add(&co->co_perfile, &fp->fi_clnt_odstate); in hash_clnt_odstate_locked()
515 struct nfs4_file *fp; in put_clnt_odstate() local
520 fp = co->co_file; in put_clnt_odstate()
521 if (atomic_dec_and_lock(&co->co_odcount, &fp->fi_lock)) { in put_clnt_odstate()
523 spin_unlock(&fp->fi_lock); in put_clnt_odstate()
525 nfsd4_return_all_file_layouts(co->co_client, fp); in put_clnt_odstate()
531 find_or_hash_clnt_odstate(struct nfs4_file *fp, struct nfs4_clnt_odstate *new) in find_or_hash_clnt_odstate() argument
541 spin_lock(&fp->fi_lock); in find_or_hash_clnt_odstate()
542 list_for_each_entry(co, &fp->fi_clnt_odstate, co_perfile) { in find_or_hash_clnt_odstate()
549 co->co_file = fp; in find_or_hash_clnt_odstate()
552 spin_unlock(&fp->fi_lock); in find_or_hash_clnt_odstate()
732 struct nfs4_file *fp = s->sc_file; in nfs4_put_stid() local
744 if (fp) in nfs4_put_stid()
745 put_nfs4_file(fp); in nfs4_put_stid()
748 static void nfs4_put_deleg_lease(struct nfs4_file *fp) in nfs4_put_deleg_lease() argument
752 spin_lock(&fp->fi_lock); in nfs4_put_deleg_lease()
753 if (fp->fi_deleg_file && --fp->fi_delegees == 0) in nfs4_put_deleg_lease()
754 swap(filp, fp->fi_deleg_file); in nfs4_put_deleg_lease()
755 spin_unlock(&fp->fi_lock); in nfs4_put_deleg_lease()
758 vfs_setlease(filp, F_UNLCK, NULL, (void **)&fp); in nfs4_put_deleg_lease()
782 nfs4_get_existing_delegation(struct nfs4_client *clp, struct nfs4_file *fp) in nfs4_get_existing_delegation() argument
788 lockdep_assert_held(&fp->fi_lock); in nfs4_get_existing_delegation()
790 list_for_each_entry(searchdp, &fp->fi_delegations, dl_perfile) { in nfs4_get_existing_delegation()
813 hash_delegation_locked(struct nfs4_delegation *dp, struct nfs4_file *fp) in hash_delegation_locked() argument
819 lockdep_assert_held(&fp->fi_lock); in hash_delegation_locked()
821 status = nfs4_get_existing_delegation(clp, fp); in hash_delegation_locked()
824 ++fp->fi_delegees; in hash_delegation_locked()
827 list_add(&dp->dl_perfile, &fp->fi_delegations); in hash_delegation_locked()
835 struct nfs4_file *fp = dp->dl_stid.sc_file; in unhash_delegation_locked() local
845 spin_lock(&fp->fi_lock); in unhash_delegation_locked()
849 spin_unlock(&fp->fi_lock); in unhash_delegation_locked()
1007 recalculate_deny_mode(struct nfs4_file *fp) in recalculate_deny_mode() argument
1011 spin_lock(&fp->fi_lock); in recalculate_deny_mode()
1012 fp->fi_share_deny = 0; in recalculate_deny_mode()
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()
1015 spin_unlock(&fp->fi_lock); in recalculate_deny_mode()
1041 struct nfs4_file *fp = stp->st_stid.sc_file; in release_all_access() local
1043 if (fp && stp->st_deny_bmap != 0) in release_all_access()
1044 recalculate_deny_mode(fp); in release_all_access()
1069 struct nfs4_file *fp = stp->st_stid.sc_file; in unhash_ol_stateid() local
1076 spin_lock(&fp->fi_lock); in unhash_ol_stateid()
1078 spin_unlock(&fp->fi_lock); in unhash_ol_stateid()
1170 struct nfs4_file *fp; in free_ol_stateid_reaplist() local
1178 fp = stp->st_stid.sc_file; in free_ol_stateid_reaplist()
1180 if (fp) in free_ol_stateid_reaplist()
1181 put_nfs4_file(fp); in free_ol_stateid_reaplist()
3211 struct nfs4_file *fp) in nfsd4_init_file() argument
3215 atomic_set(&fp->fi_ref, 1); in nfsd4_init_file()
3216 spin_lock_init(&fp->fi_lock); in nfsd4_init_file()
3217 INIT_LIST_HEAD(&fp->fi_stateids); in nfsd4_init_file()
3218 INIT_LIST_HEAD(&fp->fi_delegations); in nfsd4_init_file()
3219 INIT_LIST_HEAD(&fp->fi_clnt_odstate); in nfsd4_init_file()
3220 fh_copy_shallow(&fp->fi_fhandle, fh); in nfsd4_init_file()
3221 fp->fi_deleg_file = NULL; in nfsd4_init_file()
3222 fp->fi_had_conflict = false; in nfsd4_init_file()
3223 fp->fi_share_deny = 0; in nfsd4_init_file()
3224 memset(fp->fi_fds, 0, sizeof(fp->fi_fds)); in nfsd4_init_file()
3225 memset(fp->fi_access, 0, sizeof(fp->fi_access)); in nfsd4_init_file()
3227 INIT_LIST_HEAD(&fp->fi_lo_states); in nfsd4_init_file()
3228 atomic_set(&fp->fi_lo_recalls, 0); in nfsd4_init_file()
3230 hlist_add_head_rcu(&fp->fi_hash, &file_hashtbl[hashval]); in nfsd4_init_file()
3394 static void init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_file *fp, struct nfsd4_open … in init_open_stateid() argument
3401 get_nfs4_file(fp); in init_open_stateid()
3402 stp->st_stid.sc_file = fp; in init_open_stateid()
3409 spin_lock(&fp->fi_lock); in init_open_stateid()
3410 list_add(&stp->st_perfile, &fp->fi_stateids); in init_open_stateid()
3411 spin_unlock(&fp->fi_lock); in init_open_stateid()
3461 struct nfs4_file *fp; in find_file_locked() local
3463 hlist_for_each_entry_rcu(fp, &file_hashtbl[hashval], fi_hash) { in find_file_locked()
3464 if (fh_match(&fp->fi_fhandle, fh)) { in find_file_locked()
3465 if (atomic_inc_not_zero(&fp->fi_ref)) in find_file_locked()
3466 return fp; in find_file_locked()
3475 struct nfs4_file *fp; in find_file() local
3479 fp = find_file_locked(fh, hashval); in find_file()
3481 return fp; in find_file()
3487 struct nfs4_file *fp; in find_or_add_file() local
3491 fp = find_file_locked(fh, hashval); in find_or_add_file()
3493 if (fp) in find_or_add_file()
3494 return fp; in find_or_add_file()
3497 fp = find_file_locked(fh, hashval); in find_or_add_file()
3498 if (likely(fp == NULL)) { in find_or_add_file()
3500 fp = new; in find_or_add_file()
3504 return fp; in find_or_add_file()
3514 struct nfs4_file *fp; in nfs4_share_conflict() local
3517 fp = find_file(&current_fh->fh_handle); in nfs4_share_conflict()
3518 if (!fp) in nfs4_share_conflict()
3521 spin_lock(&fp->fi_lock); in nfs4_share_conflict()
3522 if (fp->fi_share_deny & deny_type) in nfs4_share_conflict()
3524 spin_unlock(&fp->fi_lock); in nfs4_share_conflict()
3525 put_nfs4_file(fp); in nfs4_share_conflict()
3607 struct nfs4_file *fp = (struct nfs4_file *)fl->fl_owner; in nfsd_break_deleg_cb() local
3610 if (!fp) { in nfsd_break_deleg_cb()
3614 if (fp->fi_had_conflict) { in nfsd_break_deleg_cb()
3615 WARN(1, "duplicate break on %p\n", fp); in nfsd_break_deleg_cb()
3625 spin_lock(&fp->fi_lock); in nfsd_break_deleg_cb()
3626 fp->fi_had_conflict = true; in nfsd_break_deleg_cb()
3631 if (list_empty(&fp->fi_delegations)) in nfsd_break_deleg_cb()
3634 list_for_each_entry(dp, &fp->fi_delegations, dl_perfile) in nfsd_break_deleg_cb()
3636 spin_unlock(&fp->fi_lock); in nfsd_break_deleg_cb()
3821 nfsd4_find_existing_open(struct nfs4_file *fp, struct nfsd4_open *open) in nfsd4_find_existing_open() argument
3826 spin_lock(&fp->fi_lock); in nfsd4_find_existing_open()
3827 list_for_each_entry(local, &fp->fi_stateids, st_perfile) { in nfsd4_find_existing_open()
3837 spin_unlock(&fp->fi_lock); in nfsd4_find_existing_open()
3867 static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp, in nfs4_get_vfs_file() argument
3877 spin_lock(&fp->fi_lock); in nfs4_get_vfs_file()
3883 status = nfs4_file_check_deny(fp, open->op_share_deny); in nfs4_get_vfs_file()
3885 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
3890 status = nfs4_file_get_access(fp, open->op_share_access); in nfs4_get_vfs_file()
3892 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
3903 fp->fi_share_deny |= (open->op_share_deny & NFS4_SHARE_DENY_BOTH); in nfs4_get_vfs_file()
3905 if (!fp->fi_fds[oflag]) { in nfs4_get_vfs_file()
3906 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
3910 spin_lock(&fp->fi_lock); in nfs4_get_vfs_file()
3911 if (!fp->fi_fds[oflag]) { in nfs4_get_vfs_file()
3912 fp->fi_fds[oflag] = filp; in nfs4_get_vfs_file()
3916 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
3927 nfs4_file_put_access(fp, open->op_share_access); in nfs4_get_vfs_file()
3933 nfs4_upgrade_open(struct svc_rqst *rqstp, struct nfs4_file *fp, struct svc_fh *cur_fh, struct nfs4_… in nfs4_upgrade_open() argument
3939 return nfs4_get_vfs_file(rqstp, fp, cur_fh, stp, open); in nfs4_upgrade_open()
3942 spin_lock(&fp->fi_lock); in nfs4_upgrade_open()
3943 status = nfs4_file_check_deny(fp, open->op_share_deny); in nfs4_upgrade_open()
3947 fp->fi_share_deny |= in nfs4_upgrade_open()
3950 spin_unlock(&fp->fi_lock); in nfs4_upgrade_open()
3980 static struct file_lock *nfs4_alloc_init_lease(struct nfs4_file *fp, int flag) in nfs4_alloc_init_lease() argument
3991 fl->fl_owner = (fl_owner_t)fp; in nfs4_alloc_init_lease()
4010 struct nfs4_file *fp = dp->dl_stid.sc_file; in nfs4_setlease() local
4015 fl = nfs4_alloc_init_lease(fp, NFS4_OPEN_DELEGATE_READ); in nfs4_setlease()
4018 filp = find_readable_file(fp); in nfs4_setlease()
4032 spin_lock(&fp->fi_lock); in nfs4_setlease()
4035 if (fp->fi_had_conflict) in nfs4_setlease()
4038 if (fp->fi_deleg_file) { in nfs4_setlease()
4039 status = hash_delegation_locked(dp, fp); in nfs4_setlease()
4042 fp->fi_deleg_file = filp; in nfs4_setlease()
4043 fp->fi_delegees = 0; in nfs4_setlease()
4044 status = hash_delegation_locked(dp, fp); in nfs4_setlease()
4045 spin_unlock(&fp->fi_lock); in nfs4_setlease()
4054 spin_unlock(&fp->fi_lock); in nfs4_setlease()
4063 struct nfs4_file *fp, struct nfs4_clnt_odstate *odstate) in nfs4_set_delegation() argument
4068 if (fp->fi_had_conflict) in nfs4_set_delegation()
4072 spin_lock(&fp->fi_lock); in nfs4_set_delegation()
4073 status = nfs4_get_existing_delegation(clp, fp); in nfs4_set_delegation()
4074 spin_unlock(&fp->fi_lock); in nfs4_set_delegation()
4084 get_nfs4_file(fp); in nfs4_set_delegation()
4086 spin_lock(&fp->fi_lock); in nfs4_set_delegation()
4087 dp->dl_stid.sc_file = fp; in nfs4_set_delegation()
4088 if (!fp->fi_deleg_file) { in nfs4_set_delegation()
4089 spin_unlock(&fp->fi_lock); in nfs4_set_delegation()
4094 if (fp->fi_had_conflict) { in nfs4_set_delegation()
4098 status = hash_delegation_locked(dp, fp); in nfs4_set_delegation()
4100 spin_unlock(&fp->fi_lock); in nfs4_set_delegation()
4230 struct nfs4_file *fp = NULL; in nfsd4_process_open2() local
4240 fp = find_or_add_file(open->op_file, &current_fh->fh_handle); in nfsd4_process_open2()
4241 if (fp != open->op_file) { in nfsd4_process_open2()
4245 stp = nfsd4_find_existing_open(fp, open); in nfsd4_process_open2()
4260 status = nfs4_upgrade_open(rqstp, fp, current_fh, stp, open); in nfsd4_process_open2()
4268 init_open_stateid(stp, fp, open); in nfsd4_process_open2()
4270 status = nfs4_get_vfs_file(rqstp, fp, current_fh, stp, open); in nfsd4_process_open2()
4277 stp->st_clnt_odstate = find_or_hash_clnt_odstate(fp, in nfsd4_process_open2()
4310 if (fp) in nfsd4_process_open2()
4311 put_nfs4_file(fp); in nfsd4_process_open2()
5300 struct nfs4_file *fp, struct inode *inode, in init_lock_stateid() argument
5310 get_nfs4_file(fp); in init_lock_stateid()
5311 stp->st_stid.sc_file = fp; in init_lock_stateid()
5319 spin_lock(&fp->fi_lock); in init_lock_stateid()
5320 list_add(&stp->st_perfile, &fp->fi_stateids); in init_lock_stateid()
5321 spin_unlock(&fp->fi_lock); in init_lock_stateid()
5325 find_lock_stateid(struct nfs4_lockowner *lo, struct nfs4_file *fp) in find_lock_stateid() argument
5333 if (lst->st_stid.sc_file == fp) { in find_lock_stateid()
5383 struct nfs4_file *fp = lock_stp->st_stid.sc_file; in get_lock_access() local
5385 lockdep_assert_held(&fp->fi_lock); in get_lock_access()
5389 __nfs4_file_get_access(fp, access); in get_lock_access()
5443 struct nfs4_file *fp; in nfsd4_lock() local
5524 fp = lock_stp->st_stid.sc_file; in nfsd4_lock()
5528 spin_lock(&fp->fi_lock); in nfsd4_lock()
5529 filp = find_readable_file_locked(fp); in nfsd4_lock()
5532 spin_unlock(&fp->fi_lock); in nfsd4_lock()
5537 spin_lock(&fp->fi_lock); in nfsd4_lock()
5538 filp = find_writeable_file_locked(fp); in nfsd4_lock()
5541 spin_unlock(&fp->fi_lock); in nfsd4_lock()
5791 check_for_locks(struct nfs4_file *fp, struct nfs4_lockowner *lowner) in check_for_locks() argument
5795 struct file *filp = find_any_file(fp); in check_for_locks()