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()
733 struct nfs4_file *fp = s->sc_file; in nfs4_put_stid() local
745 if (fp) in nfs4_put_stid()
746 put_nfs4_file(fp); in nfs4_put_stid()
761 static void nfs4_put_deleg_lease(struct nfs4_file *fp) in nfs4_put_deleg_lease() argument
765 spin_lock(&fp->fi_lock); in nfs4_put_deleg_lease()
766 if (fp->fi_deleg_file && --fp->fi_delegees == 0) in nfs4_put_deleg_lease()
767 swap(filp, fp->fi_deleg_file); in nfs4_put_deleg_lease()
768 spin_unlock(&fp->fi_lock); in nfs4_put_deleg_lease()
771 vfs_setlease(filp, F_UNLCK, NULL, (void **)&fp); in nfs4_put_deleg_lease()
795 nfs4_get_existing_delegation(struct nfs4_client *clp, struct nfs4_file *fp) in nfs4_get_existing_delegation() argument
801 lockdep_assert_held(&fp->fi_lock); in nfs4_get_existing_delegation()
803 list_for_each_entry(searchdp, &fp->fi_delegations, dl_perfile) { in nfs4_get_existing_delegation()
826 hash_delegation_locked(struct nfs4_delegation *dp, struct nfs4_file *fp) in hash_delegation_locked() argument
832 lockdep_assert_held(&fp->fi_lock); in hash_delegation_locked()
834 status = nfs4_get_existing_delegation(clp, fp); in hash_delegation_locked()
837 ++fp->fi_delegees; in hash_delegation_locked()
840 list_add(&dp->dl_perfile, &fp->fi_delegations); in hash_delegation_locked()
848 struct nfs4_file *fp = dp->dl_stid.sc_file; in unhash_delegation_locked() local
858 spin_lock(&fp->fi_lock); in unhash_delegation_locked()
862 spin_unlock(&fp->fi_lock); in unhash_delegation_locked()
1020 recalculate_deny_mode(struct nfs4_file *fp) in recalculate_deny_mode() argument
1024 spin_lock(&fp->fi_lock); in recalculate_deny_mode()
1025 fp->fi_share_deny = 0; in recalculate_deny_mode()
1026 list_for_each_entry(stp, &fp->fi_stateids, st_perfile) in recalculate_deny_mode()
1027 fp->fi_share_deny |= bmap_to_share_mode(stp->st_deny_bmap); in recalculate_deny_mode()
1028 spin_unlock(&fp->fi_lock); in recalculate_deny_mode()
1054 struct nfs4_file *fp = stp->st_stid.sc_file; in release_all_access() local
1056 if (fp && stp->st_deny_bmap != 0) in release_all_access()
1057 recalculate_deny_mode(fp); in release_all_access()
1087 struct nfs4_file *fp = stp->st_stid.sc_file; in unhash_ol_stateid() local
1094 spin_lock(&fp->fi_lock); in unhash_ol_stateid()
1096 spin_unlock(&fp->fi_lock); in unhash_ol_stateid()
1188 struct nfs4_file *fp; in free_ol_stateid_reaplist() local
1196 fp = stp->st_stid.sc_file; in free_ol_stateid_reaplist()
1198 if (fp) in free_ol_stateid_reaplist()
1199 put_nfs4_file(fp); in free_ol_stateid_reaplist()
3242 struct nfs4_file *fp) in nfsd4_init_file() argument
3246 atomic_set(&fp->fi_ref, 1); in nfsd4_init_file()
3247 spin_lock_init(&fp->fi_lock); in nfsd4_init_file()
3248 INIT_LIST_HEAD(&fp->fi_stateids); in nfsd4_init_file()
3249 INIT_LIST_HEAD(&fp->fi_delegations); in nfsd4_init_file()
3250 INIT_LIST_HEAD(&fp->fi_clnt_odstate); in nfsd4_init_file()
3251 fh_copy_shallow(&fp->fi_fhandle, fh); in nfsd4_init_file()
3252 fp->fi_deleg_file = NULL; in nfsd4_init_file()
3253 fp->fi_had_conflict = false; in nfsd4_init_file()
3254 fp->fi_share_deny = 0; in nfsd4_init_file()
3255 memset(fp->fi_fds, 0, sizeof(fp->fi_fds)); in nfsd4_init_file()
3256 memset(fp->fi_access, 0, sizeof(fp->fi_access)); in nfsd4_init_file()
3258 INIT_LIST_HEAD(&fp->fi_lo_states); in nfsd4_init_file()
3259 atomic_set(&fp->fi_lo_recalls, 0); in nfsd4_init_file()
3261 hlist_add_head_rcu(&fp->fi_hash, &file_hashtbl[hashval]); in nfsd4_init_file()
3396 nfsd4_find_existing_open(struct nfs4_file *fp, struct nfsd4_open *open) in nfsd4_find_existing_open() argument
3401 lockdep_assert_held(&fp->fi_lock); in nfsd4_find_existing_open()
3403 list_for_each_entry(local, &fp->fi_stateids, st_perfile) { in nfsd4_find_existing_open()
3448 init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_file *fp, in init_open_stateid() argument
3456 spin_lock(&fp->fi_lock); in init_open_stateid()
3458 retstp = nfsd4_find_existing_open(fp, open); in init_open_stateid()
3465 get_nfs4_file(fp); in init_open_stateid()
3466 stp->st_stid.sc_file = fp; in init_open_stateid()
3472 list_add(&stp->st_perfile, &fp->fi_stateids); in init_open_stateid()
3475 spin_unlock(&fp->fi_lock); in init_open_stateid()
3526 struct nfs4_file *fp; in find_file_locked() local
3528 hlist_for_each_entry_rcu(fp, &file_hashtbl[hashval], fi_hash) { in find_file_locked()
3529 if (fh_match(&fp->fi_fhandle, fh)) { in find_file_locked()
3530 if (atomic_inc_not_zero(&fp->fi_ref)) in find_file_locked()
3531 return fp; in find_file_locked()
3540 struct nfs4_file *fp; in find_file() local
3544 fp = find_file_locked(fh, hashval); in find_file()
3546 return fp; in find_file()
3552 struct nfs4_file *fp; in find_or_add_file() local
3556 fp = find_file_locked(fh, hashval); in find_or_add_file()
3558 if (fp) in find_or_add_file()
3559 return fp; in find_or_add_file()
3562 fp = find_file_locked(fh, hashval); in find_or_add_file()
3563 if (likely(fp == NULL)) { in find_or_add_file()
3565 fp = new; in find_or_add_file()
3569 return fp; in find_or_add_file()
3579 struct nfs4_file *fp; in nfs4_share_conflict() local
3582 fp = find_file(¤t_fh->fh_handle); in nfs4_share_conflict()
3583 if (!fp) in nfs4_share_conflict()
3586 spin_lock(&fp->fi_lock); in nfs4_share_conflict()
3587 if (fp->fi_share_deny & deny_type) in nfs4_share_conflict()
3589 spin_unlock(&fp->fi_lock); in nfs4_share_conflict()
3590 put_nfs4_file(fp); in nfs4_share_conflict()
3675 struct nfs4_file *fp = (struct nfs4_file *)fl->fl_owner; in nfsd_break_deleg_cb() local
3678 if (!fp) { in nfsd_break_deleg_cb()
3682 if (fp->fi_had_conflict) { in nfsd_break_deleg_cb()
3683 WARN(1, "duplicate break on %p\n", fp); in nfsd_break_deleg_cb()
3693 spin_lock(&fp->fi_lock); in nfsd_break_deleg_cb()
3694 fp->fi_had_conflict = true; in nfsd_break_deleg_cb()
3699 if (list_empty(&fp->fi_delegations)) in nfsd_break_deleg_cb()
3702 list_for_each_entry(dp, &fp->fi_delegations, dl_perfile) in nfsd_break_deleg_cb()
3704 spin_unlock(&fp->fi_lock); in nfsd_break_deleg_cb()
3914 static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp, in nfs4_get_vfs_file() argument
3924 spin_lock(&fp->fi_lock); in nfs4_get_vfs_file()
3930 status = nfs4_file_check_deny(fp, open->op_share_deny); in nfs4_get_vfs_file()
3932 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
3937 status = nfs4_file_get_access(fp, open->op_share_access); in nfs4_get_vfs_file()
3939 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
3950 fp->fi_share_deny |= (open->op_share_deny & NFS4_SHARE_DENY_BOTH); in nfs4_get_vfs_file()
3952 if (!fp->fi_fds[oflag]) { in nfs4_get_vfs_file()
3953 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
3957 spin_lock(&fp->fi_lock); in nfs4_get_vfs_file()
3958 if (!fp->fi_fds[oflag]) { in nfs4_get_vfs_file()
3959 fp->fi_fds[oflag] = filp; in nfs4_get_vfs_file()
3963 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
3974 nfs4_file_put_access(fp, open->op_share_access); in nfs4_get_vfs_file()
3980 nfs4_upgrade_open(struct svc_rqst *rqstp, struct nfs4_file *fp, struct svc_fh *cur_fh, struct nfs4_… in nfs4_upgrade_open() argument
3986 return nfs4_get_vfs_file(rqstp, fp, cur_fh, stp, open); in nfs4_upgrade_open()
3989 spin_lock(&fp->fi_lock); in nfs4_upgrade_open()
3990 status = nfs4_file_check_deny(fp, open->op_share_deny); in nfs4_upgrade_open()
3993 fp->fi_share_deny |= in nfs4_upgrade_open()
3996 spin_unlock(&fp->fi_lock); in nfs4_upgrade_open()
4020 static struct file_lock *nfs4_alloc_init_lease(struct nfs4_file *fp, int flag) in nfs4_alloc_init_lease() argument
4031 fl->fl_owner = (fl_owner_t)fp; in nfs4_alloc_init_lease()
4050 struct nfs4_file *fp = dp->dl_stid.sc_file; in nfs4_setlease() local
4055 fl = nfs4_alloc_init_lease(fp, NFS4_OPEN_DELEGATE_READ); in nfs4_setlease()
4058 filp = find_readable_file(fp); in nfs4_setlease()
4072 spin_lock(&fp->fi_lock); in nfs4_setlease()
4075 if (fp->fi_had_conflict) in nfs4_setlease()
4078 if (fp->fi_deleg_file) { in nfs4_setlease()
4079 status = hash_delegation_locked(dp, fp); in nfs4_setlease()
4082 fp->fi_deleg_file = filp; in nfs4_setlease()
4083 fp->fi_delegees = 0; in nfs4_setlease()
4084 status = hash_delegation_locked(dp, fp); in nfs4_setlease()
4085 spin_unlock(&fp->fi_lock); in nfs4_setlease()
4094 spin_unlock(&fp->fi_lock); in nfs4_setlease()
4103 struct nfs4_file *fp, struct nfs4_clnt_odstate *odstate) in nfs4_set_delegation() argument
4108 if (fp->fi_had_conflict) in nfs4_set_delegation()
4112 spin_lock(&fp->fi_lock); in nfs4_set_delegation()
4113 status = nfs4_get_existing_delegation(clp, fp); in nfs4_set_delegation()
4114 spin_unlock(&fp->fi_lock); in nfs4_set_delegation()
4124 get_nfs4_file(fp); in nfs4_set_delegation()
4126 spin_lock(&fp->fi_lock); in nfs4_set_delegation()
4127 dp->dl_stid.sc_file = fp; in nfs4_set_delegation()
4128 if (!fp->fi_deleg_file) { in nfs4_set_delegation()
4129 spin_unlock(&fp->fi_lock); in nfs4_set_delegation()
4134 if (fp->fi_had_conflict) { in nfs4_set_delegation()
4138 status = hash_delegation_locked(dp, fp); in nfs4_set_delegation()
4140 spin_unlock(&fp->fi_lock); in nfs4_set_delegation()
4271 struct nfs4_file *fp = NULL; in nfsd4_process_open2() local
4282 fp = find_or_add_file(open->op_file, ¤t_fh->fh_handle); in nfsd4_process_open2()
4283 if (fp != open->op_file) { in nfsd4_process_open2()
4287 spin_lock(&fp->fi_lock); in nfsd4_process_open2()
4288 stp = nfsd4_find_existing_open(fp, open); in nfsd4_process_open2()
4289 spin_unlock(&fp->fi_lock); in nfsd4_process_open2()
4304 status = nfs4_upgrade_open(rqstp, fp, current_fh, stp, open); in nfsd4_process_open2()
4312 swapstp = init_open_stateid(stp, fp, open); in nfsd4_process_open2()
4317 status = nfs4_upgrade_open(rqstp, fp, current_fh, in nfsd4_process_open2()
4326 status = nfs4_get_vfs_file(rqstp, fp, current_fh, stp, open); in nfsd4_process_open2()
4333 stp->st_clnt_odstate = find_or_hash_clnt_odstate(fp, in nfsd4_process_open2()
4366 if (fp) in nfsd4_process_open2()
4367 put_nfs4_file(fp); in nfsd4_process_open2()
5382 struct nfs4_file *fp, struct inode *inode, in init_lock_stateid() argument
5392 get_nfs4_file(fp); in init_lock_stateid()
5393 stp->st_stid.sc_file = fp; in init_lock_stateid()
5401 spin_lock(&fp->fi_lock); in init_lock_stateid()
5402 list_add(&stp->st_perfile, &fp->fi_stateids); in init_lock_stateid()
5403 spin_unlock(&fp->fi_lock); in init_lock_stateid()
5407 find_lock_stateid(struct nfs4_lockowner *lo, struct nfs4_file *fp) in find_lock_stateid() argument
5415 if (lst->st_stid.sc_file == fp) { in find_lock_stateid()
5465 struct nfs4_file *fp = lock_stp->st_stid.sc_file; in get_lock_access() local
5467 lockdep_assert_held(&fp->fi_lock); in get_lock_access()
5471 __nfs4_file_get_access(fp, access); in get_lock_access()
5525 struct nfs4_file *fp; in nfsd4_lock() local
5606 fp = lock_stp->st_stid.sc_file; in nfsd4_lock()
5610 spin_lock(&fp->fi_lock); in nfsd4_lock()
5611 filp = find_readable_file_locked(fp); in nfsd4_lock()
5614 spin_unlock(&fp->fi_lock); in nfsd4_lock()
5619 spin_lock(&fp->fi_lock); in nfsd4_lock()
5620 filp = find_writeable_file_locked(fp); in nfsd4_lock()
5623 spin_unlock(&fp->fi_lock); in nfsd4_lock()
5869 check_for_locks(struct nfs4_file *fp, struct nfs4_lockowner *lowner) in check_for_locks() argument
5873 struct file *filp = find_any_file(fp); in check_for_locks()