Lines Matching refs:dentry

34 static int __dir_lease_try_check(const struct dentry *dentry);
39 static int ceph_d_init(struct dentry *dentry) in ceph_d_init() argument
42 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dentry->d_sb); in ceph_d_init()
48 di->dentry = dentry; in ceph_d_init()
51 dentry->d_fsdata = di; in ceph_d_init()
130 static struct dentry *
131 __dcache_find_get_entry(struct dentry *parent, u64 idx, in __dcache_find_get_entry()
136 struct dentry *dentry; in __dcache_find_get_entry() local
137 unsigned idx_mask = (PAGE_SIZE / sizeof(struct dentry *)) - 1; in __dcache_find_get_entry()
138 loff_t ptr_pos = idx * sizeof(struct dentry *); in __dcache_find_get_entry()
164 dentry = cache_ctl->dentries[cache_ctl->index]; in __dcache_find_get_entry()
166 dentry = NULL; in __dcache_find_get_entry()
168 if (dentry && !lockref_get_not_dead(&dentry->d_lockref)) in __dcache_find_get_entry()
169 dentry = NULL; in __dcache_find_get_entry()
171 return dentry ? : ERR_PTR(-EAGAIN); in __dcache_find_get_entry()
189 struct dentry *parent = file->f_path.dentry; in __dcache_readdir()
193 struct dentry *dentry, *last = NULL; in __dcache_readdir() local
204 u64 count = div_u64(i_size_read(dir), sizeof(struct dentry *)); in __dcache_readdir()
207 dentry = __dcache_find_get_entry(parent, idx + step, in __dcache_readdir()
209 if (!dentry) { in __dcache_readdir()
214 if (IS_ERR(dentry)) { in __dcache_readdir()
215 err = PTR_ERR(dentry); in __dcache_readdir()
218 di = ceph_dentry(dentry); in __dcache_readdir()
219 spin_lock(&dentry->d_lock); in __dcache_readdir()
226 spin_unlock(&dentry->d_lock); in __dcache_readdir()
227 dput(dentry); in __dcache_readdir()
237 dentry = __dcache_find_get_entry(parent, idx++, &cache_ctl); in __dcache_readdir()
238 if (!dentry) { in __dcache_readdir()
243 if (IS_ERR(dentry)) { in __dcache_readdir()
244 err = PTR_ERR(dentry); in __dcache_readdir()
248 spin_lock(&dentry->d_lock); in __dcache_readdir()
249 di = ceph_dentry(dentry); in __dcache_readdir()
250 if (d_unhashed(dentry) || in __dcache_readdir()
251 d_really_is_negative(dentry) || in __dcache_readdir()
253 ((dentry->d_flags & DCACHE_NOKEY_NAME) && in __dcache_readdir()
255 spin_unlock(&dentry->d_lock); in __dcache_readdir()
256 dput(dentry); in __dcache_readdir()
264 spin_unlock(&dentry->d_lock); in __dcache_readdir()
268 dentry, dentry, d_inode(dentry)); in __dcache_readdir()
270 if (!dir_emit(ctx, dentry->d_name.name, in __dcache_readdir()
271 dentry->d_name.len, ceph_present_inode(d_inode(dentry)), in __dcache_readdir()
272 d_inode(dentry)->i_mode >> 12)) { in __dcache_readdir()
273 dput(dentry); in __dcache_readdir()
281 last = dentry; in __dcache_readdir()
283 dput(dentry); in __dcache_readdir()
345 struct dentry *dentry = file->f_path.dentry; in ceph_readdir() local
347 spin_lock(&dentry->d_lock); in ceph_readdir()
348 ino = ceph_present_inode(dentry->d_parent->d_inode); in ceph_readdir()
349 spin_unlock(&dentry->d_lock); in ceph_readdir()
455 req->r_dentry = dget(file->f_path.dentry); in ceph_readdir()
622 sizeof(struct dentry*)); in ceph_readdir()
722 struct dentry *ceph_handle_snapdir(struct ceph_mds_request *req, in ceph_handle_snapdir()
723 struct dentry *dentry) in ceph_handle_snapdir() argument
725 struct ceph_fs_client *fsc = ceph_sb_to_fs_client(dentry->d_sb); in ceph_handle_snapdir()
726 struct inode *parent = d_inode(dentry->d_parent); /* we hold i_rwsem */ in ceph_handle_snapdir()
731 strcmp(dentry->d_name.name, fsc->mount_options->snapdir_name) == 0) { in ceph_handle_snapdir()
732 struct dentry *res; in ceph_handle_snapdir()
735 res = d_splice_alias(inode, dentry); in ceph_handle_snapdir()
738 dentry, dentry, inode, ceph_vinop(inode), res); in ceph_handle_snapdir()
740 dentry = res; in ceph_handle_snapdir()
742 return dentry; in ceph_handle_snapdir()
756 struct dentry *ceph_finish_lookup(struct ceph_mds_request *req, in ceph_finish_lookup()
757 struct dentry *dentry, int err) in ceph_finish_lookup() argument
767 dentry, ceph_vinop(d_inode(dentry))); in ceph_finish_lookup()
768 if (d_really_is_positive(dentry)) { in ceph_finish_lookup()
769 d_drop(dentry); in ceph_finish_lookup()
772 d_add(dentry, NULL); in ceph_finish_lookup()
777 dentry = ERR_PTR(err); in ceph_finish_lookup()
778 else if (dentry != req->r_dentry) in ceph_finish_lookup()
779 dentry = dget(req->r_dentry); /* we got spliced */ in ceph_finish_lookup()
781 dentry = NULL; in ceph_finish_lookup()
782 return dentry; in ceph_finish_lookup()
785 static bool is_root_ceph_dentry(struct inode *inode, struct dentry *dentry) in is_root_ceph_dentry() argument
788 strncmp(dentry->d_name.name, ".ceph", 5) == 0; in is_root_ceph_dentry()
795 static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, in ceph_lookup() argument
807 dentry, dentry); in ceph_lookup()
809 if (dentry->d_name.len > NAME_MAX) in ceph_lookup()
815 err = fscrypt_prepare_lookup_partial(dir, dentry); in ceph_lookup()
825 if (d_really_is_negative(dentry)) { in ceph_lookup()
827 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_lookup()
832 if (strncmp(dentry->d_name.name, in ceph_lookup()
834 dentry->d_name.len) && in ceph_lookup()
835 !is_root_ceph_dentry(dir, dentry) && in ceph_lookup()
843 d_add(dentry, NULL); in ceph_lookup()
855 req->r_dentry = dget(dentry); in ceph_lookup()
868 struct dentry *res; in ceph_lookup()
870 res = ceph_handle_snapdir(req, dentry); in ceph_lookup()
874 dentry = res; in ceph_lookup()
878 dentry = ceph_finish_lookup(req, dentry, err); in ceph_lookup()
880 doutc(cl, "result=%p\n", dentry); in ceph_lookup()
881 return dentry; in ceph_lookup()
888 int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry) in ceph_handle_notrace_create() argument
890 struct dentry *result = ceph_lookup(dir, dentry, 0); in ceph_handle_notrace_create()
912 struct dentry *dentry, umode_t mode, dev_t rdev) in ceph_mknod() argument
923 err = ceph_wait_on_conflict_unlink(dentry); in ceph_mknod()
933 dir, ceph_vinop(dir), dentry, dentry, mode, rdev); in ceph_mknod()
940 req->r_new_inode = ceph_new_inode(dir, dentry, &mode, &as_ctx); in ceph_mknod()
950 req->r_dentry = dget(dentry); in ceph_mknod()
966 err = ceph_handle_notrace_create(dir, dentry); in ceph_mknod()
971 ceph_init_inode_acls(d_inode(dentry), &as_ctx); in ceph_mknod()
973 d_drop(dentry); in ceph_mknod()
979 struct dentry *dentry, umode_t mode, bool excl) in ceph_create() argument
981 return ceph_mknod(idmap, dir, dentry, mode, 0); in ceph_create()
1022 struct dentry *dentry, const char *dest) in ceph_symlink() argument
1034 err = ceph_wait_on_conflict_unlink(dentry); in ceph_symlink()
1043 doutc(cl, "%p %llx.%llx/'%pd' to '%s'\n", dir, ceph_vinop(dir), dentry, in ceph_symlink()
1051 req->r_new_inode = ceph_new_inode(dir, dentry, &mode, &as_ctx); in ceph_symlink()
1075 req->r_dentry = dget(dentry); in ceph_symlink()
1085 err = ceph_handle_notrace_create(dir, dentry); in ceph_symlink()
1090 d_drop(dentry); in ceph_symlink()
1096 struct dentry *dentry, umode_t mode) in ceph_mkdir() argument
1105 err = ceph_wait_on_conflict_unlink(dentry); in ceph_mkdir()
1113 ceph_vinop(dir), dentry, dentry); in ceph_mkdir()
1116 ceph_vinop(dir), dentry, dentry, mode); in ceph_mkdir()
1142 req->r_new_inode = ceph_new_inode(dir, dentry, &mode, &as_ctx); in ceph_mkdir()
1149 req->r_dentry = dget(dentry); in ceph_mkdir()
1167 err = ceph_handle_notrace_create(dir, dentry); in ceph_mkdir()
1172 ceph_init_inode_acls(d_inode(dentry), &as_ctx); in ceph_mkdir()
1174 d_drop(dentry); in ceph_mkdir()
1179 static int ceph_link(struct dentry *old_dentry, struct inode *dir, in ceph_link()
1180 struct dentry *dentry) in ceph_link() argument
1187 if (dentry->d_flags & DCACHE_DISCONNECTED) in ceph_link()
1190 err = ceph_wait_on_conflict_unlink(dentry); in ceph_link()
1197 err = fscrypt_prepare_link(old_dentry, dir, dentry); in ceph_link()
1202 old_dentry, dentry); in ceph_link()
1205 d_drop(dentry); in ceph_link()
1208 req->r_dentry = dget(dentry); in ceph_link()
1226 d_drop(dentry); in ceph_link()
1229 d_instantiate(dentry, d_inode(old_dentry)); in ceph_link()
1238 struct dentry *dentry = req->r_dentry; in ceph_async_unlink_cb() local
1239 struct ceph_fs_client *fsc = ceph_sb_to_fs_client(dentry->d_sb); in ceph_async_unlink_cb()
1241 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_async_unlink_cb()
1248 dentry, dentry); in ceph_async_unlink_cb()
1254 spin_lock(&dentry->d_lock); in ceph_async_unlink_cb()
1257 spin_unlock(&dentry->d_lock); in ceph_async_unlink_cb()
1268 char *path = ceph_mdsc_build_path(mdsc, dentry, &pathlen, in ceph_async_unlink_cb()
1276 if (!d_unhashed(dentry)) in ceph_async_unlink_cb()
1277 d_drop(dentry); in ceph_async_unlink_cb()
1291 static int get_caps_for_async_unlink(struct inode *dir, struct dentry *dentry) in get_caps_for_async_unlink() argument
1308 spin_lock(&dentry->d_lock); in get_caps_for_async_unlink()
1309 di = ceph_dentry(dentry); in get_caps_for_async_unlink()
1317 spin_unlock(&dentry->d_lock); in get_caps_for_async_unlink()
1330 static int ceph_unlink(struct inode *dir, struct dentry *dentry) in ceph_unlink() argument
1335 struct inode *inode = d_inode(dentry); in ceph_unlink()
1338 struct dentry *dn; in ceph_unlink()
1348 dentry); in ceph_unlink()
1352 ceph_vinop(dir), dentry, ceph_vinop(inode)); in ceph_unlink()
1353 op = d_is_dir(dentry) ? in ceph_unlink()
1387 req->r_dentry = dget(dentry); in ceph_unlink()
1396 (req->r_dir_caps = get_caps_for_async_unlink(dir, dentry))) { in ceph_unlink()
1397 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_unlink()
1400 ceph_vinop(dir), dentry, in ceph_unlink()
1404 req->r_old_inode = d_inode(dentry); in ceph_unlink()
1407 spin_lock(&dentry->d_lock); in ceph_unlink()
1409 spin_unlock(&dentry->d_lock); in ceph_unlink()
1413 dentry->d_name.hash); in ceph_unlink()
1423 d_delete(dentry); in ceph_unlink()
1429 spin_lock(&dentry->d_lock); in ceph_unlink()
1431 spin_unlock(&dentry->d_lock); in ceph_unlink()
1443 d_delete(dentry); in ceph_unlink()
1452 struct dentry *old_dentry, struct inode *new_dir, in ceph_rename()
1453 struct dentry *new_dentry, unsigned int flags) in ceph_rename()
1532 struct dentry *dn = di->dentry; in __ceph_dentry_lease_touch()
1566 struct dentry *dn = di->dentry; in __ceph_dentry_dir_lease_touch()
1603 mdsc = ceph_sb_to_fs_client(di->dentry->d_sb)->mdsc; in __dentry_lease_unlist()
1623 static int __dir_lease_check(const struct dentry *, struct ceph_lease_walk_control *);
1624 static int __dentry_lease_check(const struct dentry *);
1631 struct dentry *dentry, *last = NULL; in __dentry_leases_walk() local
1644 dentry = di->dentry; in __dentry_leases_walk()
1645 if (last == dentry) in __dentry_leases_walk()
1648 if (!spin_trylock(&dentry->d_lock)) in __dentry_leases_walk()
1651 if (__lockref_is_dead(&dentry->d_lockref)) { in __dentry_leases_walk()
1657 ret = __dir_lease_check(dentry, lwc); in __dentry_leases_walk()
1659 ret = __dentry_lease_check(dentry); in __dentry_leases_walk()
1664 last = dentry; in __dentry_leases_walk()
1669 if (dentry->d_lockref.count > 0) { in __dentry_leases_walk()
1678 dget_dlock(dentry); in __dentry_leases_walk()
1682 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1691 dentry = di->dentry; in __dentry_leases_walk()
1692 spin_lock(&dentry->d_lock); in __dentry_leases_walk()
1709 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1711 dput(dentry); in __dentry_leases_walk()
1716 static int __dentry_lease_check(const struct dentry *dentry) in __dentry_lease_check() argument
1718 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dentry_lease_check()
1723 ret = __dir_lease_try_check(dentry); in __dentry_lease_check()
1731 static int __dir_lease_check(const struct dentry *dentry, in __dir_lease_check() argument
1734 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dir_lease_check()
1736 int ret = __dir_lease_try_check(dentry); in __dir_lease_check()
1747 if (dentry->d_lockref.count > 0 || in __dir_lease_check()
1792 void ceph_invalidate_dentry_lease(struct dentry *dentry) in ceph_invalidate_dentry_lease() argument
1794 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_invalidate_dentry_lease()
1795 spin_lock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1800 spin_unlock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1831 static int dentry_lease_is_valid(struct dentry *dentry, unsigned int flags) in dentry_lease_is_valid() argument
1835 struct ceph_mds_client *mdsc = ceph_sb_to_fs_client(dentry->d_sb)->mdsc; in dentry_lease_is_valid()
1840 spin_lock(&dentry->d_lock); in dentry_lease_is_valid()
1841 di = ceph_dentry(dentry); in dentry_lease_is_valid()
1862 spin_unlock(&dentry->d_lock); in dentry_lease_is_valid()
1865 ceph_mdsc_lease_send_msg(session, dentry, in dentry_lease_is_valid()
1869 doutc(cl, "dentry %p = %d\n", dentry, valid); in dentry_lease_is_valid()
1876 static int __dir_lease_try_check(const struct dentry *dentry) in __dir_lease_try_check() argument
1878 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dir_lease_try_check()
1885 if (IS_ROOT(dentry)) in __dir_lease_try_check()
1888 dir = d_inode(dentry->d_parent); in __dir_lease_try_check()
1908 static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry, in dir_lease_is_valid() argument
1925 spin_lock(&dentry->d_lock); in dir_lease_is_valid()
1926 di = ceph_dentry(dentry); in dir_lease_is_valid()
1927 if (dir == d_inode(dentry->d_parent) && in dir_lease_is_valid()
1932 spin_unlock(&dentry->d_lock); in dir_lease_is_valid()
1936 dentry, dentry, valid); in dir_lease_is_valid()
1943 static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags) in ceph_d_revalidate() argument
1945 struct ceph_mds_client *mdsc = ceph_sb_to_fs_client(dentry->d_sb)->mdsc; in ceph_d_revalidate()
1948 struct dentry *parent; in ceph_d_revalidate()
1951 valid = fscrypt_d_revalidate(dentry, flags); in ceph_d_revalidate()
1956 parent = READ_ONCE(dentry->d_parent); in ceph_d_revalidate()
1960 inode = d_inode_rcu(dentry); in ceph_d_revalidate()
1962 parent = dget_parent(dentry); in ceph_d_revalidate()
1964 inode = d_inode(dentry); in ceph_d_revalidate()
1968 dentry, dentry, inode, ceph_dentry(dentry)->offset, in ceph_d_revalidate()
1969 !!(dentry->d_flags & DCACHE_NOKEY_NAME)); in ceph_d_revalidate()
1975 doutc(cl, "%p '%pd' inode %p is SNAPPED\n", dentry, in ceph_d_revalidate()
1976 dentry, inode); in ceph_d_revalidate()
1981 valid = dentry_lease_is_valid(dentry, flags); in ceph_d_revalidate()
1984 if (valid || dir_lease_is_valid(dir, dentry, mdsc)) { in ceph_d_revalidate()
2006 req->r_dentry = dget(dentry); in ceph_d_revalidate()
2019 if (d_really_is_positive(dentry) && in ceph_d_revalidate()
2020 d_inode(dentry) == req->r_target_inode) in ceph_d_revalidate()
2024 if (d_really_is_negative(dentry)) in ceph_d_revalidate()
2031 doutc(cl, "%p '%pd', lookup result=%d\n", dentry, in ceph_d_revalidate()
2032 dentry, err); in ceph_d_revalidate()
2038 doutc(cl, "%p '%pd' %s\n", dentry, dentry, valid ? "valid" : "invalid"); in ceph_d_revalidate()
2052 static int ceph_d_delete(const struct dentry *dentry) in ceph_d_delete() argument
2057 if (d_really_is_negative(dentry)) in ceph_d_delete()
2059 if (ceph_snap(d_inode(dentry)) != CEPH_NOSNAP) in ceph_d_delete()
2062 di = ceph_dentry(dentry); in ceph_d_delete()
2066 if (__dir_lease_try_check(dentry)) in ceph_d_delete()
2075 static void ceph_d_release(struct dentry *dentry) in ceph_d_release() argument
2077 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_d_release()
2078 struct ceph_fs_client *fsc = ceph_sb_to_fs_client(dentry->d_sb); in ceph_d_release()
2080 doutc(fsc->client, "dentry %p '%pd'\n", dentry, dentry); in ceph_d_release()
2084 spin_lock(&dentry->d_lock); in ceph_d_release()
2086 dentry->d_fsdata = NULL; in ceph_d_release()
2087 spin_unlock(&dentry->d_lock); in ceph_d_release()
2099 static void ceph_d_prune(struct dentry *dentry) in ceph_d_prune() argument
2101 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dentry->d_sb); in ceph_d_prune()
2106 doutc(cl, "dentry %p '%pd'\n", dentry, dentry); in ceph_d_prune()
2109 if (IS_ROOT(dentry)) in ceph_d_prune()
2113 dir_ci = ceph_inode(d_inode(dentry->d_parent)); in ceph_d_prune()
2118 if (d_really_is_negative(dentry)) in ceph_d_prune()
2122 if (!d_unhashed(dentry)) { in ceph_d_prune()
2130 di = ceph_dentry(dentry); in ceph_d_prune()
2193 unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) in ceph_dentry_hash()