Lines Matching refs:fp
78 static bool check_for_locks(struct nfs4_file *fp, struct nfs4_lockowner *lowner);
385 struct nfs4_file *fp = container_of(rcu, struct nfs4_file, fi_rcu); in nfsd4_free_file_rcu() local
387 kmem_cache_free(file_slab, fp); in nfsd4_free_file_rcu()
514 __nfs4_file_get_access(struct nfs4_file *fp, u32 access) in __nfs4_file_get_access() argument
516 lockdep_assert_held(&fp->fi_lock); in __nfs4_file_get_access()
519 atomic_inc(&fp->fi_access[O_WRONLY]); in __nfs4_file_get_access()
521 atomic_inc(&fp->fi_access[O_RDONLY]); in __nfs4_file_get_access()
525 nfs4_file_get_access(struct nfs4_file *fp, u32 access) in nfs4_file_get_access() argument
527 lockdep_assert_held(&fp->fi_lock); in nfs4_file_get_access()
534 if ((access & fp->fi_share_deny) != 0) in nfs4_file_get_access()
537 __nfs4_file_get_access(fp, access); in nfs4_file_get_access()
541 static __be32 nfs4_file_check_deny(struct nfs4_file *fp, u32 deny) in nfs4_file_check_deny() argument
550 atomic_read(&fp->fi_access[O_RDONLY])) in nfs4_file_check_deny()
554 atomic_read(&fp->fi_access[O_WRONLY])) in nfs4_file_check_deny()
560 static void __nfs4_file_put_access(struct nfs4_file *fp, int oflag) in __nfs4_file_put_access() argument
562 might_lock(&fp->fi_lock); in __nfs4_file_put_access()
564 if (atomic_dec_and_lock(&fp->fi_access[oflag], &fp->fi_lock)) { in __nfs4_file_put_access()
568 swap(f1, fp->fi_fds[oflag]); in __nfs4_file_put_access()
569 if (atomic_read(&fp->fi_access[1 - oflag]) == 0) in __nfs4_file_put_access()
570 swap(f2, fp->fi_fds[O_RDWR]); in __nfs4_file_put_access()
571 spin_unlock(&fp->fi_lock); in __nfs4_file_put_access()
579 static void nfs4_file_put_access(struct nfs4_file *fp, u32 access) in nfs4_file_put_access() argument
584 __nfs4_file_put_access(fp, O_WRONLY); in nfs4_file_put_access()
586 __nfs4_file_put_access(fp, O_RDONLY); in nfs4_file_put_access()
612 struct nfs4_file *fp = co->co_file; in hash_clnt_odstate_locked() local
614 lockdep_assert_held(&fp->fi_lock); in hash_clnt_odstate_locked()
615 list_add(&co->co_perfile, &fp->fi_clnt_odstate); in hash_clnt_odstate_locked()
628 struct nfs4_file *fp; in put_clnt_odstate() local
633 fp = co->co_file; in put_clnt_odstate()
634 if (atomic_dec_and_lock(&co->co_odcount, &fp->fi_lock)) { in put_clnt_odstate()
636 spin_unlock(&fp->fi_lock); in put_clnt_odstate()
638 nfsd4_return_all_file_layouts(co->co_client, fp); in put_clnt_odstate()
644 find_or_hash_clnt_odstate(struct nfs4_file *fp, struct nfs4_clnt_odstate *new) in find_or_hash_clnt_odstate() argument
654 spin_lock(&fp->fi_lock); in find_or_hash_clnt_odstate()
655 list_for_each_entry(co, &fp->fi_clnt_odstate, co_perfile) { in find_or_hash_clnt_odstate()
662 co->co_file = fp; in find_or_hash_clnt_odstate()
665 spin_unlock(&fp->fi_lock); in find_or_hash_clnt_odstate()
844 struct nfs4_file *fp = s->sc_file; in nfs4_put_stid() local
856 if (fp) in nfs4_put_stid()
857 put_nfs4_file(fp); in nfs4_put_stid()
872 static void nfs4_put_deleg_lease(struct nfs4_file *fp) in nfs4_put_deleg_lease() argument
876 spin_lock(&fp->fi_lock); in nfs4_put_deleg_lease()
877 if (fp->fi_deleg_file && --fp->fi_delegees == 0) in nfs4_put_deleg_lease()
878 swap(filp, fp->fi_deleg_file); in nfs4_put_deleg_lease()
879 spin_unlock(&fp->fi_lock); in nfs4_put_deleg_lease()
882 vfs_setlease(filp, F_UNLCK, NULL, (void **)&fp); in nfs4_put_deleg_lease()
906 nfs4_get_existing_delegation(struct nfs4_client *clp, struct nfs4_file *fp) in nfs4_get_existing_delegation() argument
912 lockdep_assert_held(&fp->fi_lock); in nfs4_get_existing_delegation()
914 list_for_each_entry(searchdp, &fp->fi_delegations, dl_perfile) { in nfs4_get_existing_delegation()
937 hash_delegation_locked(struct nfs4_delegation *dp, struct nfs4_file *fp) in hash_delegation_locked() argument
943 lockdep_assert_held(&fp->fi_lock); in hash_delegation_locked()
945 status = nfs4_get_existing_delegation(clp, fp); in hash_delegation_locked()
948 ++fp->fi_delegees; in hash_delegation_locked()
951 list_add(&dp->dl_perfile, &fp->fi_delegations); in hash_delegation_locked()
959 struct nfs4_file *fp = dp->dl_stid.sc_file; in unhash_delegation_locked() local
969 spin_lock(&fp->fi_lock); in unhash_delegation_locked()
973 spin_unlock(&fp->fi_lock); in unhash_delegation_locked()
1131 recalculate_deny_mode(struct nfs4_file *fp) in recalculate_deny_mode() argument
1135 spin_lock(&fp->fi_lock); in recalculate_deny_mode()
1136 fp->fi_share_deny = 0; in recalculate_deny_mode()
1137 list_for_each_entry(stp, &fp->fi_stateids, st_perfile) in recalculate_deny_mode()
1138 fp->fi_share_deny |= bmap_to_share_mode(stp->st_deny_bmap); in recalculate_deny_mode()
1139 spin_unlock(&fp->fi_lock); in recalculate_deny_mode()
1165 struct nfs4_file *fp = stp->st_stid.sc_file; in release_all_access() local
1167 if (fp && stp->st_deny_bmap != 0) in release_all_access()
1168 recalculate_deny_mode(fp); in release_all_access()
1198 struct nfs4_file *fp = stp->st_stid.sc_file; in unhash_ol_stateid() local
1205 spin_lock(&fp->fi_lock); in unhash_ol_stateid()
1207 spin_unlock(&fp->fi_lock); in unhash_ol_stateid()
1297 struct nfs4_file *fp; in free_ol_stateid_reaplist() local
1305 fp = stp->st_stid.sc_file; in free_ol_stateid_reaplist()
1307 if (fp) in free_ol_stateid_reaplist()
1308 put_nfs4_file(fp); in free_ol_stateid_reaplist()
3395 struct nfs4_file *fp) in nfsd4_init_file() argument
3399 atomic_set(&fp->fi_ref, 1); in nfsd4_init_file()
3400 spin_lock_init(&fp->fi_lock); in nfsd4_init_file()
3401 INIT_LIST_HEAD(&fp->fi_stateids); in nfsd4_init_file()
3402 INIT_LIST_HEAD(&fp->fi_delegations); in nfsd4_init_file()
3403 INIT_LIST_HEAD(&fp->fi_clnt_odstate); in nfsd4_init_file()
3404 fh_copy_shallow(&fp->fi_fhandle, fh); in nfsd4_init_file()
3405 fp->fi_deleg_file = NULL; in nfsd4_init_file()
3406 fp->fi_had_conflict = false; in nfsd4_init_file()
3407 fp->fi_share_deny = 0; in nfsd4_init_file()
3408 memset(fp->fi_fds, 0, sizeof(fp->fi_fds)); in nfsd4_init_file()
3409 memset(fp->fi_access, 0, sizeof(fp->fi_access)); in nfsd4_init_file()
3411 INIT_LIST_HEAD(&fp->fi_lo_states); in nfsd4_init_file()
3412 atomic_set(&fp->fi_lo_recalls, 0); in nfsd4_init_file()
3414 hlist_add_head_rcu(&fp->fi_hash, &file_hashtbl[hashval]); in nfsd4_init_file()
3549 nfsd4_find_existing_open(struct nfs4_file *fp, struct nfsd4_open *open) in nfsd4_find_existing_open() argument
3554 lockdep_assert_held(&fp->fi_lock); in nfsd4_find_existing_open()
3556 list_for_each_entry(local, &fp->fi_stateids, st_perfile) { in nfsd4_find_existing_open()
3603 nfsd4_find_and_lock_existing_open(struct nfs4_file *fp, struct nfsd4_open *open) in nfsd4_find_and_lock_existing_open() argument
3607 spin_lock(&fp->fi_lock); in nfsd4_find_and_lock_existing_open()
3608 stp = nfsd4_find_existing_open(fp, open); in nfsd4_find_and_lock_existing_open()
3609 spin_unlock(&fp->fi_lock); in nfsd4_find_and_lock_existing_open()
3649 init_open_stateid(struct nfs4_file *fp, struct nfsd4_open *open) in init_open_stateid() argument
3663 spin_lock(&fp->fi_lock); in init_open_stateid()
3665 retstp = nfsd4_find_existing_open(fp, open); in init_open_stateid()
3674 get_nfs4_file(fp); in init_open_stateid()
3675 stp->st_stid.sc_file = fp; in init_open_stateid()
3680 list_add(&stp->st_perfile, &fp->fi_stateids); in init_open_stateid()
3683 spin_unlock(&fp->fi_lock); in init_open_stateid()
3744 struct nfs4_file *fp; in find_file_locked() local
3746 hlist_for_each_entry_rcu(fp, &file_hashtbl[hashval], fi_hash) { in find_file_locked()
3747 if (fh_match(&fp->fi_fhandle, fh)) { in find_file_locked()
3748 if (atomic_inc_not_zero(&fp->fi_ref)) in find_file_locked()
3749 return fp; in find_file_locked()
3758 struct nfs4_file *fp; in find_file() local
3762 fp = find_file_locked(fh, hashval); in find_file()
3764 return fp; in find_file()
3770 struct nfs4_file *fp; in find_or_add_file() local
3774 fp = find_file_locked(fh, hashval); in find_or_add_file()
3776 if (fp) in find_or_add_file()
3777 return fp; in find_or_add_file()
3780 fp = find_file_locked(fh, hashval); in find_or_add_file()
3781 if (likely(fp == NULL)) { in find_or_add_file()
3783 fp = new; in find_or_add_file()
3787 return fp; in find_or_add_file()
3797 struct nfs4_file *fp; in nfs4_share_conflict() local
3800 fp = find_file(¤t_fh->fh_handle); in nfs4_share_conflict()
3801 if (!fp) in nfs4_share_conflict()
3804 spin_lock(&fp->fi_lock); in nfs4_share_conflict()
3805 if (fp->fi_share_deny & deny_type) in nfs4_share_conflict()
3807 spin_unlock(&fp->fi_lock); in nfs4_share_conflict()
3808 put_nfs4_file(fp); in nfs4_share_conflict()
3893 struct nfs4_file *fp = (struct nfs4_file *)fl->fl_owner; in nfsd_break_deleg_cb() local
3896 if (!fp) { in nfsd_break_deleg_cb()
3900 if (fp->fi_had_conflict) { in nfsd_break_deleg_cb()
3901 WARN(1, "duplicate break on %p\n", fp); in nfsd_break_deleg_cb()
3911 spin_lock(&fp->fi_lock); in nfsd_break_deleg_cb()
3912 fp->fi_had_conflict = true; in nfsd_break_deleg_cb()
3917 if (list_empty(&fp->fi_delegations)) in nfsd_break_deleg_cb()
3920 list_for_each_entry(dp, &fp->fi_delegations, dl_perfile) in nfsd_break_deleg_cb()
3922 spin_unlock(&fp->fi_lock); in nfsd_break_deleg_cb()
4139 static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp, in nfs4_get_vfs_file() argument
4149 spin_lock(&fp->fi_lock); in nfs4_get_vfs_file()
4155 status = nfs4_file_check_deny(fp, open->op_share_deny); in nfs4_get_vfs_file()
4157 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
4162 status = nfs4_file_get_access(fp, open->op_share_access); in nfs4_get_vfs_file()
4164 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
4175 fp->fi_share_deny |= (open->op_share_deny & NFS4_SHARE_DENY_BOTH); in nfs4_get_vfs_file()
4177 if (!fp->fi_fds[oflag]) { in nfs4_get_vfs_file()
4178 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
4182 spin_lock(&fp->fi_lock); in nfs4_get_vfs_file()
4183 if (!fp->fi_fds[oflag]) { in nfs4_get_vfs_file()
4184 fp->fi_fds[oflag] = filp; in nfs4_get_vfs_file()
4188 spin_unlock(&fp->fi_lock); in nfs4_get_vfs_file()
4199 nfs4_file_put_access(fp, open->op_share_access); in nfs4_get_vfs_file()
4205 nfs4_upgrade_open(struct svc_rqst *rqstp, struct nfs4_file *fp, struct svc_fh *cur_fh, struct nfs4_… in nfs4_upgrade_open() argument
4211 return nfs4_get_vfs_file(rqstp, fp, cur_fh, stp, open); in nfs4_upgrade_open()
4214 spin_lock(&fp->fi_lock); in nfs4_upgrade_open()
4215 status = nfs4_file_check_deny(fp, open->op_share_deny); in nfs4_upgrade_open()
4218 fp->fi_share_deny |= in nfs4_upgrade_open()
4221 spin_unlock(&fp->fi_lock); in nfs4_upgrade_open()
4245 static struct file_lock *nfs4_alloc_init_lease(struct nfs4_file *fp, int flag) in nfs4_alloc_init_lease() argument
4256 fl->fl_owner = (fl_owner_t)fp; in nfs4_alloc_init_lease()
4275 struct nfs4_file *fp = dp->dl_stid.sc_file; in nfs4_setlease() local
4280 fl = nfs4_alloc_init_lease(fp, NFS4_OPEN_DELEGATE_READ); in nfs4_setlease()
4283 filp = find_readable_file(fp); in nfs4_setlease()
4297 spin_lock(&fp->fi_lock); in nfs4_setlease()
4300 if (fp->fi_had_conflict) in nfs4_setlease()
4303 if (fp->fi_deleg_file) { in nfs4_setlease()
4304 status = hash_delegation_locked(dp, fp); in nfs4_setlease()
4307 fp->fi_deleg_file = filp; in nfs4_setlease()
4308 fp->fi_delegees = 0; in nfs4_setlease()
4309 status = hash_delegation_locked(dp, fp); in nfs4_setlease()
4310 spin_unlock(&fp->fi_lock); in nfs4_setlease()
4319 spin_unlock(&fp->fi_lock); in nfs4_setlease()
4328 struct nfs4_file *fp, struct nfs4_clnt_odstate *odstate) in nfs4_set_delegation() argument
4333 if (fp->fi_had_conflict) in nfs4_set_delegation()
4337 spin_lock(&fp->fi_lock); in nfs4_set_delegation()
4338 status = nfs4_get_existing_delegation(clp, fp); in nfs4_set_delegation()
4339 spin_unlock(&fp->fi_lock); in nfs4_set_delegation()
4349 get_nfs4_file(fp); in nfs4_set_delegation()
4351 spin_lock(&fp->fi_lock); in nfs4_set_delegation()
4352 dp->dl_stid.sc_file = fp; in nfs4_set_delegation()
4353 if (!fp->fi_deleg_file) { in nfs4_set_delegation()
4354 spin_unlock(&fp->fi_lock); in nfs4_set_delegation()
4359 if (fp->fi_had_conflict) { in nfs4_set_delegation()
4363 status = hash_delegation_locked(dp, fp); in nfs4_set_delegation()
4365 spin_unlock(&fp->fi_lock); in nfs4_set_delegation()
4496 struct nfs4_file *fp = NULL; in nfsd4_process_open2() local
4507 fp = find_or_add_file(open->op_file, ¤t_fh->fh_handle); in nfsd4_process_open2()
4508 if (fp != open->op_file) { in nfsd4_process_open2()
4512 stp = nfsd4_find_and_lock_existing_open(fp, open); in nfsd4_process_open2()
4521 stp = init_open_stateid(fp, open); in nfsd4_process_open2()
4534 status = nfs4_upgrade_open(rqstp, fp, current_fh, stp, open); in nfsd4_process_open2()
4540 status = nfs4_get_vfs_file(rqstp, fp, current_fh, stp, open); in nfsd4_process_open2()
4548 stp->st_clnt_odstate = find_or_hash_clnt_odstate(fp, in nfsd4_process_open2()
4581 if (fp) in nfsd4_process_open2()
4582 put_nfs4_file(fp); in nfsd4_process_open2()
5686 struct nfs4_file *fp, struct inode *inode, in init_lock_stateid() argument
5696 get_nfs4_file(fp); in init_lock_stateid()
5697 stp->st_stid.sc_file = fp; in init_lock_stateid()
5704 spin_lock(&fp->fi_lock); in init_lock_stateid()
5705 list_add(&stp->st_perfile, &fp->fi_stateids); in init_lock_stateid()
5706 spin_unlock(&fp->fi_lock); in init_lock_stateid()
5710 find_lock_stateid(struct nfs4_lockowner *lo, struct nfs4_file *fp) in find_lock_stateid() argument
5718 if (lst->st_stid.sc_file == fp) { in find_lock_stateid()
5768 struct nfs4_file *fp = lock_stp->st_stid.sc_file; in get_lock_access() local
5770 lockdep_assert_held(&fp->fi_lock); in get_lock_access()
5774 __nfs4_file_get_access(fp, access); in get_lock_access()
5845 struct nfs4_file *fp; in nfsd4_lock() local
5920 fp = lock_stp->st_stid.sc_file; in nfsd4_lock()
5927 spin_lock(&fp->fi_lock); in nfsd4_lock()
5928 filp = find_readable_file_locked(fp); in nfsd4_lock()
5931 spin_unlock(&fp->fi_lock); in nfsd4_lock()
5939 spin_lock(&fp->fi_lock); in nfsd4_lock()
5940 filp = find_writeable_file_locked(fp); in nfsd4_lock()
5943 spin_unlock(&fp->fi_lock); in nfsd4_lock()
5956 nbl = find_or_allocate_block(lock_sop, &fp->fi_fhandle, nn); in nfsd4_lock()
6218 check_for_locks(struct nfs4_file *fp, struct nfs4_lockowner *lowner) in check_for_locks() argument
6222 struct file *filp = find_any_file(fp); in check_for_locks()