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()
165 dentry = cache_ctl->dentries[cache_ctl->index]; in __dcache_find_get_entry()
167 dentry = NULL; in __dcache_find_get_entry()
169 if (dentry && !lockref_get_not_dead(&dentry->d_lockref)) in __dcache_find_get_entry()
170 dentry = NULL; in __dcache_find_get_entry()
172 return dentry ? : ERR_PTR(-EAGAIN); in __dcache_find_get_entry()
190 struct dentry *parent = file->f_path.dentry; in __dcache_readdir()
194 struct dentry *dentry, *last = NULL; in __dcache_readdir() local
205 u64 count = div_u64(i_size_read(dir), sizeof(struct dentry *)); in __dcache_readdir()
208 dentry = __dcache_find_get_entry(parent, idx + step, in __dcache_readdir()
210 if (!dentry) { in __dcache_readdir()
215 if (IS_ERR(dentry)) { in __dcache_readdir()
216 err = PTR_ERR(dentry); in __dcache_readdir()
219 di = ceph_dentry(dentry); in __dcache_readdir()
220 spin_lock(&dentry->d_lock); in __dcache_readdir()
227 spin_unlock(&dentry->d_lock); in __dcache_readdir()
228 dput(dentry); in __dcache_readdir()
238 dentry = __dcache_find_get_entry(parent, idx++, &cache_ctl); in __dcache_readdir()
239 if (!dentry) { in __dcache_readdir()
244 if (IS_ERR(dentry)) { in __dcache_readdir()
245 err = PTR_ERR(dentry); in __dcache_readdir()
249 spin_lock(&dentry->d_lock); in __dcache_readdir()
250 di = ceph_dentry(dentry); in __dcache_readdir()
251 if (d_unhashed(dentry) || in __dcache_readdir()
252 d_really_is_negative(dentry) || in __dcache_readdir()
254 ((dentry->d_flags & DCACHE_NOKEY_NAME) && in __dcache_readdir()
256 spin_unlock(&dentry->d_lock); in __dcache_readdir()
257 dput(dentry); in __dcache_readdir()
265 spin_unlock(&dentry->d_lock); in __dcache_readdir()
269 dentry, dentry, d_inode(dentry)); in __dcache_readdir()
271 if (!dir_emit(ctx, dentry->d_name.name, in __dcache_readdir()
272 dentry->d_name.len, ceph_present_inode(d_inode(dentry)), in __dcache_readdir()
273 d_inode(dentry)->i_mode >> 12)) { in __dcache_readdir()
274 dput(dentry); in __dcache_readdir()
282 last = dentry; in __dcache_readdir()
284 dput(dentry); in __dcache_readdir()
346 struct dentry *dentry = file->f_path.dentry; in ceph_readdir() local
348 spin_lock(&dentry->d_lock); in ceph_readdir()
349 ino = ceph_present_inode(dentry->d_parent->d_inode); in ceph_readdir()
350 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()
1095 static struct dentry *ceph_mkdir(struct mnt_idmap *idmap, struct inode *dir, in ceph_mkdir()
1096 struct dentry *dentry, umode_t mode) in ceph_mkdir() argument
1102 struct dentry *ret; in ceph_mkdir()
1106 err = ceph_wait_on_conflict_unlink(dentry); in ceph_mkdir()
1114 ceph_vinop(dir), dentry, dentry); in ceph_mkdir()
1117 ceph_vinop(dir), dentry, dentry, mode); in ceph_mkdir()
1143 req->r_new_inode = ceph_new_inode(dir, dentry, &mode, &as_ctx); in ceph_mkdir()
1150 req->r_dentry = dget(dentry); in ceph_mkdir()
1168 err = ceph_handle_notrace_create(dir, dentry); in ceph_mkdir()
1171 if (!IS_ERR(ret) && req->r_dentry != dentry) in ceph_mkdir()
1178 dentry = ret; in ceph_mkdir()
1179 ceph_init_inode_acls(d_inode(dentry), &as_ctx); in ceph_mkdir()
1181 d_drop(dentry); in ceph_mkdir()
1187 static int ceph_link(struct dentry *old_dentry, struct inode *dir, in ceph_link()
1188 struct dentry *dentry) in ceph_link() argument
1195 if (dentry->d_flags & DCACHE_DISCONNECTED) in ceph_link()
1198 err = ceph_wait_on_conflict_unlink(dentry); in ceph_link()
1205 err = fscrypt_prepare_link(old_dentry, dir, dentry); in ceph_link()
1210 old_dentry, dentry); in ceph_link()
1213 d_drop(dentry); in ceph_link()
1216 req->r_dentry = dget(dentry); in ceph_link()
1234 d_drop(dentry); in ceph_link()
1237 d_instantiate(dentry, d_inode(old_dentry)); in ceph_link()
1246 struct dentry *dentry = req->r_dentry; in ceph_async_unlink_cb() local
1247 struct ceph_fs_client *fsc = ceph_sb_to_fs_client(dentry->d_sb); in ceph_async_unlink_cb()
1249 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_async_unlink_cb()
1256 dentry, dentry); in ceph_async_unlink_cb()
1262 spin_lock(&dentry->d_lock); in ceph_async_unlink_cb()
1265 spin_unlock(&dentry->d_lock); in ceph_async_unlink_cb()
1276 char *path = ceph_mdsc_build_path(mdsc, dentry, &pathlen, in ceph_async_unlink_cb()
1284 if (!d_unhashed(dentry)) in ceph_async_unlink_cb()
1285 d_drop(dentry); in ceph_async_unlink_cb()
1299 static int get_caps_for_async_unlink(struct inode *dir, struct dentry *dentry) in get_caps_for_async_unlink() argument
1316 spin_lock(&dentry->d_lock); in get_caps_for_async_unlink()
1317 di = ceph_dentry(dentry); in get_caps_for_async_unlink()
1325 spin_unlock(&dentry->d_lock); in get_caps_for_async_unlink()
1338 static int ceph_unlink(struct inode *dir, struct dentry *dentry) in ceph_unlink() argument
1343 struct inode *inode = d_inode(dentry); in ceph_unlink()
1346 struct dentry *dn; in ceph_unlink()
1356 dentry); in ceph_unlink()
1360 ceph_vinop(dir), dentry, ceph_vinop(inode)); in ceph_unlink()
1361 op = d_is_dir(dentry) ? in ceph_unlink()
1395 req->r_dentry = dget(dentry); in ceph_unlink()
1404 (req->r_dir_caps = get_caps_for_async_unlink(dir, dentry))) { in ceph_unlink()
1405 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_unlink()
1408 ceph_vinop(dir), dentry, in ceph_unlink()
1412 req->r_old_inode = d_inode(dentry); in ceph_unlink()
1415 spin_lock(&dentry->d_lock); in ceph_unlink()
1417 spin_unlock(&dentry->d_lock); in ceph_unlink()
1421 dentry->d_name.hash); in ceph_unlink()
1431 d_delete(dentry); in ceph_unlink()
1437 spin_lock(&dentry->d_lock); in ceph_unlink()
1439 spin_unlock(&dentry->d_lock); in ceph_unlink()
1451 d_delete(dentry); in ceph_unlink()
1460 struct dentry *old_dentry, struct inode *new_dir, in ceph_rename()
1461 struct dentry *new_dentry, unsigned int flags) in ceph_rename()
1540 struct dentry *dn = di->dentry; in __ceph_dentry_lease_touch()
1574 struct dentry *dn = di->dentry; in __ceph_dentry_dir_lease_touch()
1611 mdsc = ceph_sb_to_fs_client(di->dentry->d_sb)->mdsc; in __dentry_lease_unlist()
1631 static int __dir_lease_check(const struct dentry *, struct ceph_lease_walk_control *);
1632 static int __dentry_lease_check(const struct dentry *);
1639 struct dentry *dentry, *last = NULL; in __dentry_leases_walk() local
1652 dentry = di->dentry; in __dentry_leases_walk()
1653 if (last == dentry) in __dentry_leases_walk()
1656 if (!spin_trylock(&dentry->d_lock)) in __dentry_leases_walk()
1659 if (__lockref_is_dead(&dentry->d_lockref)) { in __dentry_leases_walk()
1665 ret = __dir_lease_check(dentry, lwc); in __dentry_leases_walk()
1667 ret = __dentry_lease_check(dentry); in __dentry_leases_walk()
1672 last = dentry; in __dentry_leases_walk()
1677 if (dentry->d_lockref.count > 0) { in __dentry_leases_walk()
1686 dget_dlock(dentry); in __dentry_leases_walk()
1690 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1699 dentry = di->dentry; in __dentry_leases_walk()
1700 spin_lock(&dentry->d_lock); in __dentry_leases_walk()
1717 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1719 dput(dentry); in __dentry_leases_walk()
1724 static int __dentry_lease_check(const struct dentry *dentry) in __dentry_lease_check() argument
1726 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dentry_lease_check()
1731 ret = __dir_lease_try_check(dentry); in __dentry_lease_check()
1739 static int __dir_lease_check(const struct dentry *dentry, in __dir_lease_check() argument
1742 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dir_lease_check()
1744 int ret = __dir_lease_try_check(dentry); in __dir_lease_check()
1755 if (dentry->d_lockref.count > 0 || in __dir_lease_check()
1800 void ceph_invalidate_dentry_lease(struct dentry *dentry) in ceph_invalidate_dentry_lease() argument
1802 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_invalidate_dentry_lease()
1803 spin_lock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1808 spin_unlock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1839 static int dentry_lease_is_valid(struct dentry *dentry, unsigned int flags) in dentry_lease_is_valid() argument
1843 struct ceph_mds_client *mdsc = ceph_sb_to_fs_client(dentry->d_sb)->mdsc; in dentry_lease_is_valid()
1848 spin_lock(&dentry->d_lock); in dentry_lease_is_valid()
1849 di = ceph_dentry(dentry); in dentry_lease_is_valid()
1870 spin_unlock(&dentry->d_lock); in dentry_lease_is_valid()
1873 ceph_mdsc_lease_send_msg(session, dentry, in dentry_lease_is_valid()
1877 doutc(cl, "dentry %p = %d\n", dentry, valid); in dentry_lease_is_valid()
1884 static int __dir_lease_try_check(const struct dentry *dentry) in __dir_lease_try_check() argument
1886 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dir_lease_try_check()
1893 if (IS_ROOT(dentry)) in __dir_lease_try_check()
1896 dir = d_inode(dentry->d_parent); in __dir_lease_try_check()
1916 static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry, in dir_lease_is_valid() argument
1933 spin_lock(&dentry->d_lock); in dir_lease_is_valid()
1934 di = ceph_dentry(dentry); in dir_lease_is_valid()
1935 if (dir == d_inode(dentry->d_parent) && in dir_lease_is_valid()
1940 spin_unlock(&dentry->d_lock); in dir_lease_is_valid()
1944 dentry, dentry, valid); in dir_lease_is_valid()
1952 struct dentry *dentry, unsigned int flags) in ceph_d_revalidate() argument
1954 struct ceph_mds_client *mdsc = ceph_sb_to_fs_client(dentry->d_sb)->mdsc; in ceph_d_revalidate()
1959 valid = fscrypt_d_revalidate(dir, name, dentry, flags); in ceph_d_revalidate()
1963 inode = d_inode_rcu(dentry); in ceph_d_revalidate()
1966 dentry, dentry, inode, ceph_dentry(dentry)->offset, in ceph_d_revalidate()
1967 !!(dentry->d_flags & DCACHE_NOKEY_NAME)); in ceph_d_revalidate()
1973 doutc(cl, "%p '%pd' inode %p is SNAPPED\n", dentry, in ceph_d_revalidate()
1974 dentry, inode); in ceph_d_revalidate()
1979 valid = dentry_lease_is_valid(dentry, flags); in ceph_d_revalidate()
1982 if (valid || dir_lease_is_valid(dir, dentry, mdsc)) { in ceph_d_revalidate()
2004 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()
2049 static int ceph_d_delete(const struct dentry *dentry) in ceph_d_delete() argument
2054 if (d_really_is_negative(dentry)) in ceph_d_delete()
2056 if (ceph_snap(d_inode(dentry)) != CEPH_NOSNAP) in ceph_d_delete()
2059 di = ceph_dentry(dentry); in ceph_d_delete()
2063 if (__dir_lease_try_check(dentry)) in ceph_d_delete()
2072 static void ceph_d_release(struct dentry *dentry) in ceph_d_release() argument
2074 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_d_release()
2075 struct ceph_fs_client *fsc = ceph_sb_to_fs_client(dentry->d_sb); in ceph_d_release()
2077 doutc(fsc->client, "dentry %p '%pd'\n", dentry, dentry); in ceph_d_release()
2081 spin_lock(&dentry->d_lock); in ceph_d_release()
2083 dentry->d_fsdata = NULL; in ceph_d_release()
2084 spin_unlock(&dentry->d_lock); in ceph_d_release()
2096 static void ceph_d_prune(struct dentry *dentry) in ceph_d_prune() argument
2098 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dentry->d_sb); in ceph_d_prune()
2103 doutc(cl, "dentry %p '%pd'\n", dentry, dentry); in ceph_d_prune()
2106 if (IS_ROOT(dentry)) in ceph_d_prune()
2110 dir_ci = ceph_inode(d_inode(dentry->d_parent)); in ceph_d_prune()
2115 if (d_really_is_negative(dentry)) in ceph_d_prune()
2119 if (!d_unhashed(dentry)) { in ceph_d_prune()
2127 di = ceph_dentry(dentry); in ceph_d_prune()
2190 unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) in ceph_dentry_hash()