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()
1023 struct dentry *dentry, const char *dest) in ceph_symlink() argument
1035 err = ceph_wait_on_conflict_unlink(dentry); in ceph_symlink()
1044 doutc(cl, "%p %llx.%llx/'%pd' to '%s'\n", dir, ceph_vinop(dir), dentry, in ceph_symlink()
1052 req->r_new_inode = ceph_new_inode(dir, dentry, &mode, &as_ctx); in ceph_symlink()
1076 req->r_dentry = dget(dentry); in ceph_symlink()
1086 err = ceph_handle_notrace_create(dir, dentry); in ceph_symlink()
1091 d_drop(dentry); in ceph_symlink()
1096 static struct dentry *ceph_mkdir(struct mnt_idmap *idmap, struct inode *dir, in ceph_mkdir()
1097 struct dentry *dentry, umode_t mode) in ceph_mkdir() argument
1103 struct dentry *ret; in ceph_mkdir()
1107 err = ceph_wait_on_conflict_unlink(dentry); in ceph_mkdir()
1115 ceph_vinop(dir), dentry, dentry); in ceph_mkdir()
1118 ceph_vinop(dir), dentry, dentry, mode); in ceph_mkdir()
1144 req->r_new_inode = ceph_new_inode(dir, dentry, &mode, &as_ctx); in ceph_mkdir()
1151 req->r_dentry = dget(dentry); in ceph_mkdir()
1169 err = ceph_handle_notrace_create(dir, dentry); in ceph_mkdir()
1172 if (!IS_ERR(ret) && req->r_dentry != dentry) in ceph_mkdir()
1179 dentry = ret; in ceph_mkdir()
1180 ceph_init_inode_acls(d_inode(dentry), &as_ctx); in ceph_mkdir()
1182 d_drop(dentry); in ceph_mkdir()
1188 static int ceph_link(struct dentry *old_dentry, struct inode *dir, in ceph_link()
1189 struct dentry *dentry) in ceph_link() argument
1196 if (dentry->d_flags & DCACHE_DISCONNECTED) in ceph_link()
1199 err = ceph_wait_on_conflict_unlink(dentry); in ceph_link()
1206 err = fscrypt_prepare_link(old_dentry, dir, dentry); in ceph_link()
1211 old_dentry, dentry); in ceph_link()
1214 d_drop(dentry); in ceph_link()
1217 req->r_dentry = dget(dentry); in ceph_link()
1235 d_drop(dentry); in ceph_link()
1238 d_instantiate(dentry, d_inode(old_dentry)); in ceph_link()
1247 struct dentry *dentry = req->r_dentry; in ceph_async_unlink_cb() local
1248 struct ceph_fs_client *fsc = ceph_sb_to_fs_client(dentry->d_sb); in ceph_async_unlink_cb()
1250 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_async_unlink_cb()
1257 dentry, dentry); in ceph_async_unlink_cb()
1263 spin_lock(&dentry->d_lock); in ceph_async_unlink_cb()
1265 spin_unlock(&dentry->d_lock); in ceph_async_unlink_cb()
1275 char *path = ceph_mdsc_build_path(mdsc, dentry, &path_info, 0); in ceph_async_unlink_cb()
1282 if (!d_unhashed(dentry)) in ceph_async_unlink_cb()
1283 d_drop(dentry); in ceph_async_unlink_cb()
1297 static int get_caps_for_async_unlink(struct inode *dir, struct dentry *dentry) in get_caps_for_async_unlink() argument
1314 spin_lock(&dentry->d_lock); in get_caps_for_async_unlink()
1315 di = ceph_dentry(dentry); in get_caps_for_async_unlink()
1323 spin_unlock(&dentry->d_lock); in get_caps_for_async_unlink()
1336 static int ceph_unlink(struct inode *dir, struct dentry *dentry) in ceph_unlink() argument
1341 struct inode *inode = d_inode(dentry); in ceph_unlink()
1344 struct dentry *dn; in ceph_unlink()
1352 dentry); in ceph_unlink()
1356 ceph_vinop(dir), dentry, ceph_vinop(inode)); in ceph_unlink()
1357 op = d_is_dir(dentry) ? in ceph_unlink()
1392 req->r_dentry = dget(dentry); in ceph_unlink()
1401 (req->r_dir_caps = get_caps_for_async_unlink(dir, dentry))) { in ceph_unlink()
1402 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_unlink()
1405 ceph_vinop(dir), dentry, in ceph_unlink()
1409 req->r_old_inode = d_inode(dentry); in ceph_unlink()
1412 spin_lock(&dentry->d_lock); in ceph_unlink()
1414 spin_unlock(&dentry->d_lock); in ceph_unlink()
1418 dentry->d_name.hash); in ceph_unlink()
1428 d_delete(dentry); in ceph_unlink()
1434 spin_lock(&dentry->d_lock); in ceph_unlink()
1436 spin_unlock(&dentry->d_lock); in ceph_unlink()
1448 d_delete(dentry); in ceph_unlink()
1457 struct dentry *old_dentry, struct inode *new_dir, in ceph_rename()
1458 struct dentry *new_dentry, unsigned int flags) in ceph_rename()
1537 struct dentry *dn = di->dentry; in __ceph_dentry_lease_touch()
1571 struct dentry *dn = di->dentry; in __ceph_dentry_dir_lease_touch()
1608 mdsc = ceph_sb_to_fs_client(di->dentry->d_sb)->mdsc; in __dentry_lease_unlist()
1628 static int __dir_lease_check(const struct dentry *, struct ceph_lease_walk_control *);
1629 static int __dentry_lease_check(const struct dentry *);
1636 struct dentry *dentry, *last = NULL; in __dentry_leases_walk() local
1649 dentry = di->dentry; in __dentry_leases_walk()
1650 if (last == dentry) in __dentry_leases_walk()
1653 if (!spin_trylock(&dentry->d_lock)) in __dentry_leases_walk()
1656 if (__lockref_is_dead(&dentry->d_lockref)) { in __dentry_leases_walk()
1662 ret = __dir_lease_check(dentry, lwc); in __dentry_leases_walk()
1664 ret = __dentry_lease_check(dentry); in __dentry_leases_walk()
1669 last = dentry; in __dentry_leases_walk()
1674 if (dentry->d_lockref.count > 0) { in __dentry_leases_walk()
1683 dget_dlock(dentry); in __dentry_leases_walk()
1687 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1696 dentry = di->dentry; in __dentry_leases_walk()
1697 spin_lock(&dentry->d_lock); in __dentry_leases_walk()
1714 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1716 dput(dentry); in __dentry_leases_walk()
1721 static int __dentry_lease_check(const struct dentry *dentry) in __dentry_lease_check() argument
1723 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dentry_lease_check()
1728 ret = __dir_lease_try_check(dentry); in __dentry_lease_check()
1736 static int __dir_lease_check(const struct dentry *dentry, in __dir_lease_check() argument
1739 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dir_lease_check()
1741 int ret = __dir_lease_try_check(dentry); in __dir_lease_check()
1752 if (dentry->d_lockref.count > 0 || in __dir_lease_check()
1797 void ceph_invalidate_dentry_lease(struct dentry *dentry) in ceph_invalidate_dentry_lease() argument
1799 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_invalidate_dentry_lease()
1800 spin_lock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1805 spin_unlock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1836 static int dentry_lease_is_valid(struct dentry *dentry, unsigned int flags) in dentry_lease_is_valid() argument
1840 struct ceph_mds_client *mdsc = ceph_sb_to_fs_client(dentry->d_sb)->mdsc; in dentry_lease_is_valid()
1845 spin_lock(&dentry->d_lock); in dentry_lease_is_valid()
1846 di = ceph_dentry(dentry); in dentry_lease_is_valid()
1867 spin_unlock(&dentry->d_lock); in dentry_lease_is_valid()
1870 ceph_mdsc_lease_send_msg(session, dentry, in dentry_lease_is_valid()
1874 doutc(cl, "dentry %p = %d\n", dentry, valid); in dentry_lease_is_valid()
1881 static int __dir_lease_try_check(const struct dentry *dentry) in __dir_lease_try_check() argument
1883 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dir_lease_try_check()
1890 if (IS_ROOT(dentry)) in __dir_lease_try_check()
1893 dir = d_inode(dentry->d_parent); in __dir_lease_try_check()
1913 static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry, in dir_lease_is_valid() argument
1930 spin_lock(&dentry->d_lock); in dir_lease_is_valid()
1931 di = ceph_dentry(dentry); in dir_lease_is_valid()
1932 if (dir == d_inode(dentry->d_parent) && in dir_lease_is_valid()
1937 spin_unlock(&dentry->d_lock); in dir_lease_is_valid()
1941 dentry, dentry, valid); in dir_lease_is_valid()
1949 struct dentry *dentry, unsigned int flags) in ceph_d_revalidate() argument
1951 struct ceph_mds_client *mdsc = ceph_sb_to_fs_client(dentry->d_sb)->mdsc; in ceph_d_revalidate()
1956 valid = fscrypt_d_revalidate(dir, name, dentry, flags); in ceph_d_revalidate()
1960 inode = d_inode_rcu(dentry); in ceph_d_revalidate()
1963 dentry, dentry, inode, ceph_dentry(dentry)->offset, in ceph_d_revalidate()
1964 !!(dentry->d_flags & DCACHE_NOKEY_NAME)); in ceph_d_revalidate()
1970 doutc(cl, "%p '%pd' inode %p is SNAPPED\n", dentry, in ceph_d_revalidate()
1971 dentry, inode); in ceph_d_revalidate()
1976 valid = dentry_lease_is_valid(dentry, flags); in ceph_d_revalidate()
1979 if (valid || dir_lease_is_valid(dir, dentry, mdsc)) { in ceph_d_revalidate()
2001 req->r_dentry = dget(dentry); in ceph_d_revalidate()
2016 if (d_really_is_positive(dentry) && in ceph_d_revalidate()
2017 d_inode(dentry) == req->r_target_inode) in ceph_d_revalidate()
2021 if (d_really_is_negative(dentry)) in ceph_d_revalidate()
2028 doutc(cl, "%p '%pd', lookup result=%d\n", dentry, in ceph_d_revalidate()
2029 dentry, err); in ceph_d_revalidate()
2035 doutc(cl, "%p '%pd' %s\n", dentry, dentry, valid ? "valid" : "invalid"); in ceph_d_revalidate()
2046 static int ceph_d_delete(const struct dentry *dentry) in ceph_d_delete() argument
2051 if (d_really_is_negative(dentry)) in ceph_d_delete()
2053 if (ceph_snap(d_inode(dentry)) != CEPH_NOSNAP) in ceph_d_delete()
2056 di = ceph_dentry(dentry); in ceph_d_delete()
2060 if (__dir_lease_try_check(dentry)) in ceph_d_delete()
2069 static void ceph_d_release(struct dentry *dentry) in ceph_d_release() argument
2071 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_d_release()
2072 struct ceph_fs_client *fsc = ceph_sb_to_fs_client(dentry->d_sb); in ceph_d_release()
2074 doutc(fsc->client, "dentry %p '%pd'\n", dentry, dentry); in ceph_d_release()
2078 spin_lock(&dentry->d_lock); in ceph_d_release()
2080 dentry->d_fsdata = NULL; in ceph_d_release()
2081 spin_unlock(&dentry->d_lock); in ceph_d_release()
2093 static void ceph_d_prune(struct dentry *dentry) in ceph_d_prune() argument
2095 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dentry->d_sb); in ceph_d_prune()
2100 doutc(cl, "dentry %p '%pd'\n", dentry, dentry); in ceph_d_prune()
2103 if (IS_ROOT(dentry)) in ceph_d_prune()
2107 dir_ci = ceph_inode(d_inode(dentry->d_parent)); in ceph_d_prune()
2112 if (d_really_is_negative(dentry)) in ceph_d_prune()
2116 if (!d_unhashed(dentry)) { in ceph_d_prune()
2124 di = ceph_dentry(dentry); in ceph_d_prune()
2186 unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) in ceph_dentry_hash()