Lines Matching refs:dentry

33 static int __dir_lease_try_check(const struct dentry *dentry);
38 static int ceph_d_init(struct dentry *dentry) in ceph_d_init() argument
41 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dentry->d_sb); in ceph_d_init()
47 di->dentry = dentry; in ceph_d_init()
50 dentry->d_fsdata = di; in ceph_d_init()
127 static struct dentry *
128 __dcache_find_get_entry(struct dentry *parent, u64 idx, in __dcache_find_get_entry()
132 struct dentry *dentry; in __dcache_find_get_entry() local
133 unsigned idx_mask = (PAGE_SIZE / sizeof(struct dentry *)) - 1; in __dcache_find_get_entry()
134 loff_t ptr_pos = idx * sizeof(struct dentry *); in __dcache_find_get_entry()
160 dentry = cache_ctl->dentries[cache_ctl->index]; in __dcache_find_get_entry()
162 dentry = NULL; in __dcache_find_get_entry()
164 if (dentry && !lockref_get_not_dead(&dentry->d_lockref)) in __dcache_find_get_entry()
165 dentry = NULL; in __dcache_find_get_entry()
167 return dentry ? : ERR_PTR(-EAGAIN); in __dcache_find_get_entry()
185 struct dentry *parent = file->f_path.dentry; in __dcache_readdir()
187 struct dentry *dentry, *last = NULL; in __dcache_readdir() local
197 u64 count = div_u64(i_size_read(dir), sizeof(struct dentry *)); in __dcache_readdir()
200 dentry = __dcache_find_get_entry(parent, idx + step, in __dcache_readdir()
202 if (!dentry) { in __dcache_readdir()
207 if (IS_ERR(dentry)) { in __dcache_readdir()
208 err = PTR_ERR(dentry); in __dcache_readdir()
211 di = ceph_dentry(dentry); in __dcache_readdir()
212 spin_lock(&dentry->d_lock); in __dcache_readdir()
219 spin_unlock(&dentry->d_lock); in __dcache_readdir()
220 dput(dentry); in __dcache_readdir()
229 dentry = __dcache_find_get_entry(parent, idx++, &cache_ctl); in __dcache_readdir()
230 if (!dentry) { in __dcache_readdir()
235 if (IS_ERR(dentry)) { in __dcache_readdir()
236 err = PTR_ERR(dentry); in __dcache_readdir()
240 spin_lock(&dentry->d_lock); in __dcache_readdir()
241 di = ceph_dentry(dentry); in __dcache_readdir()
242 if (d_unhashed(dentry) || in __dcache_readdir()
243 d_really_is_negative(dentry) || in __dcache_readdir()
245 spin_unlock(&dentry->d_lock); in __dcache_readdir()
246 dput(dentry); in __dcache_readdir()
254 spin_unlock(&dentry->d_lock); in __dcache_readdir()
258 dentry, dentry, d_inode(dentry)); in __dcache_readdir()
260 if (!dir_emit(ctx, dentry->d_name.name, in __dcache_readdir()
261 dentry->d_name.len, ceph_present_inode(d_inode(dentry)), in __dcache_readdir()
262 d_inode(dentry)->i_mode >> 12)) { in __dcache_readdir()
263 dput(dentry); in __dcache_readdir()
271 last = dentry; in __dcache_readdir()
273 dput(dentry); in __dcache_readdir()
331 struct dentry *dentry = file->f_path.dentry; in ceph_readdir() local
333 spin_lock(&dentry->d_lock); in ceph_readdir()
334 ino = ceph_present_inode(dentry->d_parent->d_inode); in ceph_readdir()
335 spin_unlock(&dentry->d_lock); in ceph_readdir()
425 req->r_dentry = dget(file->f_path.dentry); in ceph_readdir()
572 sizeof(struct dentry*)); in ceph_readdir()
669 struct dentry *dentry, int err) in ceph_handle_snapdir() argument
671 struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); in ceph_handle_snapdir()
672 struct inode *parent = d_inode(dentry->d_parent); /* we hold i_mutex */ in ceph_handle_snapdir()
677 strcmp(dentry->d_name.name, in ceph_handle_snapdir()
681 dentry, dentry, inode); in ceph_handle_snapdir()
682 BUG_ON(!d_unhashed(dentry)); in ceph_handle_snapdir()
683 d_add(dentry, inode); in ceph_handle_snapdir()
700 struct dentry *ceph_finish_lookup(struct ceph_mds_request *req, in ceph_finish_lookup()
701 struct dentry *dentry, int err) in ceph_finish_lookup() argument
708 dentry, d_inode(dentry)); in ceph_finish_lookup()
709 if (d_really_is_positive(dentry)) { in ceph_finish_lookup()
710 d_drop(dentry); in ceph_finish_lookup()
713 d_add(dentry, NULL); in ceph_finish_lookup()
718 dentry = ERR_PTR(err); in ceph_finish_lookup()
719 else if (dentry != req->r_dentry) in ceph_finish_lookup()
720 dentry = dget(req->r_dentry); /* we got spliced */ in ceph_finish_lookup()
722 dentry = NULL; in ceph_finish_lookup()
723 return dentry; in ceph_finish_lookup()
726 static bool is_root_ceph_dentry(struct inode *inode, struct dentry *dentry) in is_root_ceph_dentry() argument
729 strncmp(dentry->d_name.name, ".ceph", 5) == 0; in is_root_ceph_dentry()
736 static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, in ceph_lookup() argument
747 dir, dentry, dentry); in ceph_lookup()
749 if (dentry->d_name.len > NAME_MAX) in ceph_lookup()
753 if (d_really_is_negative(dentry)) { in ceph_lookup()
755 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_lookup()
759 if (strncmp(dentry->d_name.name, in ceph_lookup()
761 dentry->d_name.len) && in ceph_lookup()
762 !is_root_ceph_dentry(dir, dentry) && in ceph_lookup()
769 d_add(dentry, NULL); in ceph_lookup()
781 req->r_dentry = dget(dentry); in ceph_lookup()
792 err = ceph_handle_snapdir(req, dentry, err); in ceph_lookup()
793 dentry = ceph_finish_lookup(req, dentry, err); in ceph_lookup()
795 dout("lookup result=%p\n", dentry); in ceph_lookup()
796 return dentry; in ceph_lookup()
803 int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry) in ceph_handle_notrace_create() argument
805 struct dentry *result = ceph_lookup(dir, dentry, 0); in ceph_handle_notrace_create()
826 static int ceph_mknod(struct inode *dir, struct dentry *dentry, in ceph_mknod() argument
845 err = ceph_security_init_secctx(dentry, mode, &as_ctx); in ceph_mknod()
850 dir, dentry, mode, rdev); in ceph_mknod()
856 req->r_dentry = dget(dentry); in ceph_mknod()
870 err = ceph_handle_notrace_create(dir, dentry); in ceph_mknod()
874 ceph_init_inode_acls(d_inode(dentry), &as_ctx); in ceph_mknod()
876 d_drop(dentry); in ceph_mknod()
881 static int ceph_create(struct inode *dir, struct dentry *dentry, umode_t mode, in ceph_create() argument
884 return ceph_mknod(dir, dentry, mode, 0); in ceph_create()
887 static int ceph_symlink(struct inode *dir, struct dentry *dentry, in ceph_symlink() argument
903 err = ceph_security_init_secctx(dentry, S_IFLNK | 0777, &as_ctx); in ceph_symlink()
907 dout("symlink in dir %p dentry %p to '%s'\n", dir, dentry, dest); in ceph_symlink()
921 req->r_dentry = dget(dentry); in ceph_symlink()
931 err = ceph_handle_notrace_create(dir, dentry); in ceph_symlink()
935 d_drop(dentry); in ceph_symlink()
940 static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) in ceph_mkdir() argument
952 dentry, dentry); in ceph_mkdir()
954 dout("mkdir dir %p dn %p mode 0%ho\n", dir, dentry, mode); in ceph_mkdir()
970 err = ceph_security_init_secctx(dentry, mode, &as_ctx); in ceph_mkdir()
980 req->r_dentry = dget(dentry); in ceph_mkdir()
995 err = ceph_handle_notrace_create(dir, dentry); in ceph_mkdir()
999 ceph_init_inode_acls(d_inode(dentry), &as_ctx); in ceph_mkdir()
1001 d_drop(dentry); in ceph_mkdir()
1006 static int ceph_link(struct dentry *old_dentry, struct inode *dir, in ceph_link()
1007 struct dentry *dentry) in ceph_link() argument
1017 old_dentry, dentry); in ceph_link()
1020 d_drop(dentry); in ceph_link()
1023 req->r_dentry = dget(dentry); in ceph_link()
1034 d_drop(dentry); in ceph_link()
1037 d_instantiate(dentry, d_inode(old_dentry)); in ceph_link()
1079 static int get_caps_for_async_unlink(struct inode *dir, struct dentry *dentry) in get_caps_for_async_unlink() argument
1096 spin_lock(&dentry->d_lock); in get_caps_for_async_unlink()
1097 di = ceph_dentry(dentry); in get_caps_for_async_unlink()
1105 spin_unlock(&dentry->d_lock); in get_caps_for_async_unlink()
1118 static int ceph_unlink(struct inode *dir, struct dentry *dentry) in ceph_unlink() argument
1122 struct inode *inode = d_inode(dentry); in ceph_unlink()
1130 dout("rmsnap dir %p '%pd' dn %p\n", dir, dentry, dentry); in ceph_unlink()
1134 dir, dentry, inode); in ceph_unlink()
1135 op = d_is_dir(dentry) ? in ceph_unlink()
1145 req->r_dentry = dget(dentry); in ceph_unlink()
1153 (req->r_dir_caps = get_caps_for_async_unlink(dir, dentry))) { in ceph_unlink()
1155 dentry->d_name.len, dentry->d_name.name, in ceph_unlink()
1159 req->r_old_inode = d_inode(dentry); in ceph_unlink()
1168 d_delete(dentry); in ceph_unlink()
1178 d_delete(dentry); in ceph_unlink()
1186 static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry, in ceph_rename()
1187 struct inode *new_dir, struct dentry *new_dentry, in ceph_rename()
1256 struct dentry *dn = di->dentry; in __ceph_dentry_lease_touch()
1290 struct dentry *dn = di->dentry; in __ceph_dentry_dir_lease_touch()
1328 mdsc = ceph_sb_to_client(di->dentry->d_sb)->mdsc; in __dentry_lease_unlist()
1351 int (*check)(struct dentry*, void*)) in __dentry_leases_walk() argument
1354 struct dentry *dentry, *last = NULL; in __dentry_leases_walk() local
1367 dentry = di->dentry; in __dentry_leases_walk()
1368 if (last == dentry) in __dentry_leases_walk()
1371 if (!spin_trylock(&dentry->d_lock)) in __dentry_leases_walk()
1374 if (__lockref_is_dead(&dentry->d_lockref)) { in __dentry_leases_walk()
1379 ret = check(dentry, lwc); in __dentry_leases_walk()
1384 last = dentry; in __dentry_leases_walk()
1389 if (dentry->d_lockref.count > 0) { in __dentry_leases_walk()
1398 dget_dlock(dentry); in __dentry_leases_walk()
1402 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1411 dentry = di->dentry; in __dentry_leases_walk()
1412 spin_lock(&dentry->d_lock); in __dentry_leases_walk()
1429 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1431 dput(dentry); in __dentry_leases_walk()
1436 static int __dentry_lease_check(struct dentry *dentry, void *arg) in __dentry_lease_check() argument
1438 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dentry_lease_check()
1443 ret = __dir_lease_try_check(dentry); in __dentry_lease_check()
1451 static int __dir_lease_check(struct dentry *dentry, void *arg) in __dir_lease_check() argument
1454 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dir_lease_check()
1456 int ret = __dir_lease_try_check(dentry); in __dir_lease_check()
1467 if (dentry->d_lockref.count > 0 || in __dir_lease_check()
1512 void ceph_invalidate_dentry_lease(struct dentry *dentry) in ceph_invalidate_dentry_lease() argument
1514 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_invalidate_dentry_lease()
1515 spin_lock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1520 spin_unlock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1553 static int dentry_lease_is_valid(struct dentry *dentry, unsigned int flags) in dentry_lease_is_valid() argument
1560 spin_lock(&dentry->d_lock); in dentry_lease_is_valid()
1561 di = ceph_dentry(dentry); in dentry_lease_is_valid()
1582 spin_unlock(&dentry->d_lock); in dentry_lease_is_valid()
1585 ceph_mdsc_lease_send_msg(session, dentry, in dentry_lease_is_valid()
1589 dout("dentry_lease_is_valid - dentry %p = %d\n", dentry, valid); in dentry_lease_is_valid()
1596 static int __dir_lease_try_check(const struct dentry *dentry) in __dir_lease_try_check() argument
1598 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dir_lease_try_check()
1605 if (IS_ROOT(dentry)) in __dir_lease_try_check()
1608 dir = d_inode(dentry->d_parent); in __dir_lease_try_check()
1628 static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry, in dir_lease_is_valid() argument
1644 spin_lock(&dentry->d_lock); in dir_lease_is_valid()
1645 di = ceph_dentry(dentry); in dir_lease_is_valid()
1646 if (dir == d_inode(dentry->d_parent) && in dir_lease_is_valid()
1651 spin_unlock(&dentry->d_lock); in dir_lease_is_valid()
1654 dir, (unsigned)atomic_read(&ci->i_shared_gen), dentry, valid); in dir_lease_is_valid()
1661 static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags) in ceph_d_revalidate() argument
1664 struct dentry *parent; in ceph_d_revalidate()
1669 parent = READ_ONCE(dentry->d_parent); in ceph_d_revalidate()
1673 inode = d_inode_rcu(dentry); in ceph_d_revalidate()
1675 parent = dget_parent(dentry); in ceph_d_revalidate()
1677 inode = d_inode(dentry); in ceph_d_revalidate()
1680 dout("d_revalidate %p '%pd' inode %p offset 0x%llx\n", dentry, in ceph_d_revalidate()
1681 dentry, inode, ceph_dentry(dentry)->offset); in ceph_d_revalidate()
1687 dout("d_revalidate %p '%pd' inode %p is SNAPPED\n", dentry, in ceph_d_revalidate()
1688 dentry, inode); in ceph_d_revalidate()
1693 valid = dentry_lease_is_valid(dentry, flags); in ceph_d_revalidate()
1696 if (valid || dir_lease_is_valid(dir, dentry, mdsc)) { in ceph_d_revalidate()
1718 req->r_dentry = dget(dentry); in ceph_d_revalidate()
1730 if (d_really_is_positive(dentry) && in ceph_d_revalidate()
1731 d_inode(dentry) == req->r_target_inode) in ceph_d_revalidate()
1735 if (d_really_is_negative(dentry)) in ceph_d_revalidate()
1743 dentry, err); in ceph_d_revalidate()
1749 dout("d_revalidate %p %s\n", dentry, valid ? "valid" : "invalid"); in ceph_d_revalidate()
1763 static int ceph_d_delete(const struct dentry *dentry) in ceph_d_delete() argument
1768 if (d_really_is_negative(dentry)) in ceph_d_delete()
1770 if (ceph_snap(d_inode(dentry)) != CEPH_NOSNAP) in ceph_d_delete()
1773 di = ceph_dentry(dentry); in ceph_d_delete()
1777 if (__dir_lease_try_check(dentry)) in ceph_d_delete()
1786 static void ceph_d_release(struct dentry *dentry) in ceph_d_release() argument
1788 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_d_release()
1789 struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); in ceph_d_release()
1791 dout("d_release %p\n", dentry); in ceph_d_release()
1795 spin_lock(&dentry->d_lock); in ceph_d_release()
1797 dentry->d_fsdata = NULL; in ceph_d_release()
1798 spin_unlock(&dentry->d_lock); in ceph_d_release()
1811 static void ceph_d_prune(struct dentry *dentry) in ceph_d_prune() argument
1816 dout("ceph_d_prune %pd %p\n", dentry, dentry); in ceph_d_prune()
1819 if (IS_ROOT(dentry)) in ceph_d_prune()
1823 dir_ci = ceph_inode(d_inode(dentry->d_parent)); in ceph_d_prune()
1828 if (d_really_is_negative(dentry)) in ceph_d_prune()
1832 if (!d_unhashed(dentry)) { in ceph_d_prune()
1840 di = ceph_dentry(dentry); in ceph_d_prune()
1903 unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) in ceph_dentry_hash()