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()
670 struct dentry *ceph_handle_snapdir(struct ceph_mds_request *req, in ceph_handle_snapdir()
671 struct dentry *dentry) in ceph_handle_snapdir() argument
673 struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); in ceph_handle_snapdir()
674 struct inode *parent = d_inode(dentry->d_parent); /* we hold i_mutex */ in ceph_handle_snapdir()
678 strcmp(dentry->d_name.name, fsc->mount_options->snapdir_name) == 0) { in ceph_handle_snapdir()
679 struct dentry *res; in ceph_handle_snapdir()
682 res = d_splice_alias(inode, dentry); in ceph_handle_snapdir()
684 dentry, dentry, inode, res); in ceph_handle_snapdir()
686 dentry = res; in ceph_handle_snapdir()
688 return dentry; in ceph_handle_snapdir()
702 struct dentry *ceph_finish_lookup(struct ceph_mds_request *req, in ceph_finish_lookup()
703 struct dentry *dentry, int err) in ceph_finish_lookup() argument
710 dentry, d_inode(dentry)); in ceph_finish_lookup()
711 if (d_really_is_positive(dentry)) { in ceph_finish_lookup()
712 d_drop(dentry); in ceph_finish_lookup()
715 d_add(dentry, NULL); in ceph_finish_lookup()
720 dentry = ERR_PTR(err); in ceph_finish_lookup()
721 else if (dentry != req->r_dentry) in ceph_finish_lookup()
722 dentry = dget(req->r_dentry); /* we got spliced */ in ceph_finish_lookup()
724 dentry = NULL; in ceph_finish_lookup()
725 return dentry; in ceph_finish_lookup()
728 static bool is_root_ceph_dentry(struct inode *inode, struct dentry *dentry) in is_root_ceph_dentry() argument
731 strncmp(dentry->d_name.name, ".ceph", 5) == 0; in is_root_ceph_dentry()
738 static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, in ceph_lookup() argument
749 dir, dentry, dentry); in ceph_lookup()
751 if (dentry->d_name.len > NAME_MAX) in ceph_lookup()
755 if (d_really_is_negative(dentry)) { in ceph_lookup()
757 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_lookup()
761 if (strncmp(dentry->d_name.name, in ceph_lookup()
763 dentry->d_name.len) && in ceph_lookup()
764 !is_root_ceph_dentry(dir, dentry) && in ceph_lookup()
771 d_add(dentry, NULL); in ceph_lookup()
783 req->r_dentry = dget(dentry); in ceph_lookup()
796 struct dentry *res; in ceph_lookup()
798 res = ceph_handle_snapdir(req, dentry); in ceph_lookup()
802 dentry = res; in ceph_lookup()
806 dentry = ceph_finish_lookup(req, dentry, err); in ceph_lookup()
808 dout("lookup result=%p\n", dentry); in ceph_lookup()
809 return dentry; in ceph_lookup()
816 int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry) in ceph_handle_notrace_create() argument
818 struct dentry *result = ceph_lookup(dir, dentry, 0); in ceph_handle_notrace_create()
840 struct dentry *dentry, umode_t mode, dev_t rdev) in ceph_mknod() argument
858 err = ceph_security_init_secctx(dentry, mode, &as_ctx); in ceph_mknod()
863 dir, dentry, mode, rdev); in ceph_mknod()
869 req->r_dentry = dget(dentry); in ceph_mknod()
884 err = ceph_handle_notrace_create(dir, dentry); in ceph_mknod()
888 ceph_init_inode_acls(d_inode(dentry), &as_ctx); in ceph_mknod()
890 d_drop(dentry); in ceph_mknod()
896 struct dentry *dentry, umode_t mode, bool excl) in ceph_create() argument
898 return ceph_mknod(mnt_userns, dir, dentry, mode, 0); in ceph_create()
902 struct dentry *dentry, const char *dest) in ceph_symlink() argument
917 err = ceph_security_init_secctx(dentry, S_IFLNK | 0777, &as_ctx); in ceph_symlink()
921 dout("symlink in dir %p dentry %p to '%s'\n", dir, dentry, dest); in ceph_symlink()
937 req->r_dentry = dget(dentry); in ceph_symlink()
947 err = ceph_handle_notrace_create(dir, dentry); in ceph_symlink()
951 d_drop(dentry); in ceph_symlink()
957 struct dentry *dentry, umode_t mode) in ceph_mkdir() argument
969 dentry, dentry); in ceph_mkdir()
971 dout("mkdir dir %p dn %p mode 0%ho\n", dir, dentry, mode); in ceph_mkdir()
987 err = ceph_security_init_secctx(dentry, mode, &as_ctx); in ceph_mkdir()
997 req->r_dentry = dget(dentry); in ceph_mkdir()
1013 err = ceph_handle_notrace_create(dir, dentry); in ceph_mkdir()
1017 ceph_init_inode_acls(d_inode(dentry), &as_ctx); in ceph_mkdir()
1019 d_drop(dentry); in ceph_mkdir()
1024 static int ceph_link(struct dentry *old_dentry, struct inode *dir, in ceph_link()
1025 struct dentry *dentry) in ceph_link() argument
1035 old_dentry, dentry); in ceph_link()
1038 d_drop(dentry); in ceph_link()
1041 req->r_dentry = dget(dentry); in ceph_link()
1053 d_drop(dentry); in ceph_link()
1056 d_instantiate(dentry, d_inode(old_dentry)); in ceph_link()
1098 static int get_caps_for_async_unlink(struct inode *dir, struct dentry *dentry) in get_caps_for_async_unlink() argument
1115 spin_lock(&dentry->d_lock); in get_caps_for_async_unlink()
1116 di = ceph_dentry(dentry); in get_caps_for_async_unlink()
1124 spin_unlock(&dentry->d_lock); in get_caps_for_async_unlink()
1137 static int ceph_unlink(struct inode *dir, struct dentry *dentry) in ceph_unlink() argument
1141 struct inode *inode = d_inode(dentry); in ceph_unlink()
1149 dout("rmsnap dir %p '%pd' dn %p\n", dir, dentry, dentry); in ceph_unlink()
1153 dir, dentry, inode); in ceph_unlink()
1154 op = d_is_dir(dentry) ? in ceph_unlink()
1164 req->r_dentry = dget(dentry); in ceph_unlink()
1173 (req->r_dir_caps = get_caps_for_async_unlink(dir, dentry))) { in ceph_unlink()
1175 dentry->d_name.len, dentry->d_name.name, in ceph_unlink()
1179 req->r_old_inode = d_inode(dentry); in ceph_unlink()
1188 d_delete(dentry); in ceph_unlink()
1198 d_delete(dentry); in ceph_unlink()
1207 struct dentry *old_dentry, struct inode *new_dir, in ceph_rename()
1208 struct dentry *new_dentry, unsigned int flags) in ceph_rename()
1276 struct dentry *dn = di->dentry; in __ceph_dentry_lease_touch()
1310 struct dentry *dn = di->dentry; in __ceph_dentry_dir_lease_touch()
1348 mdsc = ceph_sb_to_client(di->dentry->d_sb)->mdsc; in __dentry_lease_unlist()
1371 int (*check)(struct dentry*, void*)) in __dentry_leases_walk() argument
1374 struct dentry *dentry, *last = NULL; in __dentry_leases_walk() local
1387 dentry = di->dentry; in __dentry_leases_walk()
1388 if (last == dentry) in __dentry_leases_walk()
1391 if (!spin_trylock(&dentry->d_lock)) in __dentry_leases_walk()
1394 if (__lockref_is_dead(&dentry->d_lockref)) { in __dentry_leases_walk()
1399 ret = check(dentry, lwc); in __dentry_leases_walk()
1404 last = dentry; in __dentry_leases_walk()
1409 if (dentry->d_lockref.count > 0) { in __dentry_leases_walk()
1418 dget_dlock(dentry); in __dentry_leases_walk()
1422 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1431 dentry = di->dentry; in __dentry_leases_walk()
1432 spin_lock(&dentry->d_lock); in __dentry_leases_walk()
1449 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1451 dput(dentry); in __dentry_leases_walk()
1456 static int __dentry_lease_check(struct dentry *dentry, void *arg) in __dentry_lease_check() argument
1458 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dentry_lease_check()
1463 ret = __dir_lease_try_check(dentry); in __dentry_lease_check()
1471 static int __dir_lease_check(struct dentry *dentry, void *arg) in __dir_lease_check() argument
1474 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dir_lease_check()
1476 int ret = __dir_lease_try_check(dentry); in __dir_lease_check()
1487 if (dentry->d_lockref.count > 0 || in __dir_lease_check()
1532 void ceph_invalidate_dentry_lease(struct dentry *dentry) in ceph_invalidate_dentry_lease() argument
1534 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_invalidate_dentry_lease()
1535 spin_lock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1540 spin_unlock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1571 static int dentry_lease_is_valid(struct dentry *dentry, unsigned int flags) in dentry_lease_is_valid() argument
1578 spin_lock(&dentry->d_lock); in dentry_lease_is_valid()
1579 di = ceph_dentry(dentry); in dentry_lease_is_valid()
1600 spin_unlock(&dentry->d_lock); in dentry_lease_is_valid()
1603 ceph_mdsc_lease_send_msg(session, dentry, in dentry_lease_is_valid()
1607 dout("dentry_lease_is_valid - dentry %p = %d\n", dentry, valid); in dentry_lease_is_valid()
1614 static int __dir_lease_try_check(const struct dentry *dentry) in __dir_lease_try_check() argument
1616 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dir_lease_try_check()
1623 if (IS_ROOT(dentry)) in __dir_lease_try_check()
1626 dir = d_inode(dentry->d_parent); in __dir_lease_try_check()
1646 static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry, in dir_lease_is_valid() argument
1662 spin_lock(&dentry->d_lock); in dir_lease_is_valid()
1663 di = ceph_dentry(dentry); in dir_lease_is_valid()
1664 if (dir == d_inode(dentry->d_parent) && in dir_lease_is_valid()
1669 spin_unlock(&dentry->d_lock); in dir_lease_is_valid()
1672 dir, (unsigned)atomic_read(&ci->i_shared_gen), dentry, valid); in dir_lease_is_valid()
1679 static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags) in ceph_d_revalidate() argument
1682 struct dentry *parent; in ceph_d_revalidate()
1687 parent = READ_ONCE(dentry->d_parent); in ceph_d_revalidate()
1691 inode = d_inode_rcu(dentry); in ceph_d_revalidate()
1693 parent = dget_parent(dentry); in ceph_d_revalidate()
1695 inode = d_inode(dentry); in ceph_d_revalidate()
1698 dout("d_revalidate %p '%pd' inode %p offset 0x%llx\n", dentry, in ceph_d_revalidate()
1699 dentry, inode, ceph_dentry(dentry)->offset); in ceph_d_revalidate()
1705 dout("d_revalidate %p '%pd' inode %p is SNAPPED\n", dentry, in ceph_d_revalidate()
1706 dentry, inode); in ceph_d_revalidate()
1711 valid = dentry_lease_is_valid(dentry, flags); in ceph_d_revalidate()
1714 if (valid || dir_lease_is_valid(dir, dentry, mdsc)) { in ceph_d_revalidate()
1736 req->r_dentry = dget(dentry); in ceph_d_revalidate()
1749 if (d_really_is_positive(dentry) && in ceph_d_revalidate()
1750 d_inode(dentry) == req->r_target_inode) in ceph_d_revalidate()
1754 if (d_really_is_negative(dentry)) in ceph_d_revalidate()
1762 dentry, err); in ceph_d_revalidate()
1768 dout("d_revalidate %p %s\n", dentry, valid ? "valid" : "invalid"); in ceph_d_revalidate()
1782 static int ceph_d_delete(const struct dentry *dentry) in ceph_d_delete() argument
1787 if (d_really_is_negative(dentry)) in ceph_d_delete()
1789 if (ceph_snap(d_inode(dentry)) != CEPH_NOSNAP) in ceph_d_delete()
1792 di = ceph_dentry(dentry); in ceph_d_delete()
1796 if (__dir_lease_try_check(dentry)) in ceph_d_delete()
1805 static void ceph_d_release(struct dentry *dentry) in ceph_d_release() argument
1807 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_d_release()
1808 struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); in ceph_d_release()
1810 dout("d_release %p\n", dentry); in ceph_d_release()
1814 spin_lock(&dentry->d_lock); in ceph_d_release()
1816 dentry->d_fsdata = NULL; in ceph_d_release()
1817 spin_unlock(&dentry->d_lock); in ceph_d_release()
1829 static void ceph_d_prune(struct dentry *dentry) in ceph_d_prune() argument
1834 dout("ceph_d_prune %pd %p\n", dentry, dentry); in ceph_d_prune()
1837 if (IS_ROOT(dentry)) in ceph_d_prune()
1841 dir_ci = ceph_inode(d_inode(dentry->d_parent)); in ceph_d_prune()
1846 if (d_really_is_negative(dentry)) in ceph_d_prune()
1850 if (!d_unhashed(dentry)) { in ceph_d_prune()
1858 di = ceph_dentry(dentry); in ceph_d_prune()
1921 unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) in ceph_dentry_hash()