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()
128 static struct dentry *
129 __dcache_find_get_entry(struct dentry *parent, u64 idx, in __dcache_find_get_entry()
133 struct dentry *dentry; in __dcache_find_get_entry() local
134 unsigned idx_mask = (PAGE_SIZE / sizeof(struct dentry *)) - 1; in __dcache_find_get_entry()
135 loff_t ptr_pos = idx * sizeof(struct dentry *); in __dcache_find_get_entry()
161 dentry = cache_ctl->dentries[cache_ctl->index]; in __dcache_find_get_entry()
163 dentry = NULL; in __dcache_find_get_entry()
165 if (dentry && !lockref_get_not_dead(&dentry->d_lockref)) in __dcache_find_get_entry()
166 dentry = NULL; in __dcache_find_get_entry()
168 return dentry ? : ERR_PTR(-EAGAIN); in __dcache_find_get_entry()
186 struct dentry *parent = file->f_path.dentry; in __dcache_readdir()
188 struct dentry *dentry, *last = NULL; in __dcache_readdir() local
198 u64 count = div_u64(i_size_read(dir), sizeof(struct dentry *)); in __dcache_readdir()
201 dentry = __dcache_find_get_entry(parent, idx + step, in __dcache_readdir()
203 if (!dentry) { in __dcache_readdir()
208 if (IS_ERR(dentry)) { in __dcache_readdir()
209 err = PTR_ERR(dentry); in __dcache_readdir()
212 di = ceph_dentry(dentry); in __dcache_readdir()
213 spin_lock(&dentry->d_lock); in __dcache_readdir()
220 spin_unlock(&dentry->d_lock); in __dcache_readdir()
221 dput(dentry); in __dcache_readdir()
230 dentry = __dcache_find_get_entry(parent, idx++, &cache_ctl); in __dcache_readdir()
231 if (!dentry) { in __dcache_readdir()
236 if (IS_ERR(dentry)) { in __dcache_readdir()
237 err = PTR_ERR(dentry); in __dcache_readdir()
241 spin_lock(&dentry->d_lock); in __dcache_readdir()
242 di = ceph_dentry(dentry); in __dcache_readdir()
243 if (d_unhashed(dentry) || in __dcache_readdir()
244 d_really_is_negative(dentry) || in __dcache_readdir()
246 ((dentry->d_flags & DCACHE_NOKEY_NAME) && in __dcache_readdir()
248 spin_unlock(&dentry->d_lock); in __dcache_readdir()
249 dput(dentry); in __dcache_readdir()
257 spin_unlock(&dentry->d_lock); in __dcache_readdir()
261 dentry, dentry, d_inode(dentry)); in __dcache_readdir()
263 if (!dir_emit(ctx, dentry->d_name.name, in __dcache_readdir()
264 dentry->d_name.len, ceph_present_inode(d_inode(dentry)), in __dcache_readdir()
265 d_inode(dentry)->i_mode >> 12)) { in __dcache_readdir()
266 dput(dentry); in __dcache_readdir()
274 last = dentry; in __dcache_readdir()
276 dput(dentry); in __dcache_readdir()
334 struct dentry *dentry = file->f_path.dentry; in ceph_readdir() local
336 spin_lock(&dentry->d_lock); in ceph_readdir()
337 ino = ceph_present_inode(dentry->d_parent->d_inode); in ceph_readdir()
338 spin_unlock(&dentry->d_lock); in ceph_readdir()
443 req->r_dentry = dget(file->f_path.dentry); in ceph_readdir()
606 sizeof(struct dentry*)); in ceph_readdir()
703 struct dentry *ceph_handle_snapdir(struct ceph_mds_request *req, in ceph_handle_snapdir()
704 struct dentry *dentry) in ceph_handle_snapdir() argument
706 struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); in ceph_handle_snapdir()
707 struct inode *parent = d_inode(dentry->d_parent); /* we hold i_rwsem */ in ceph_handle_snapdir()
711 strcmp(dentry->d_name.name, fsc->mount_options->snapdir_name) == 0) { in ceph_handle_snapdir()
712 struct dentry *res; in ceph_handle_snapdir()
715 res = d_splice_alias(inode, dentry); in ceph_handle_snapdir()
717 dentry, dentry, inode, res); in ceph_handle_snapdir()
719 dentry = res; in ceph_handle_snapdir()
721 return dentry; in ceph_handle_snapdir()
735 struct dentry *ceph_finish_lookup(struct ceph_mds_request *req, in ceph_finish_lookup()
736 struct dentry *dentry, int err) in ceph_finish_lookup() argument
743 dentry, d_inode(dentry)); in ceph_finish_lookup()
744 if (d_really_is_positive(dentry)) { in ceph_finish_lookup()
745 d_drop(dentry); in ceph_finish_lookup()
748 d_add(dentry, NULL); in ceph_finish_lookup()
753 dentry = ERR_PTR(err); in ceph_finish_lookup()
754 else if (dentry != req->r_dentry) in ceph_finish_lookup()
755 dentry = dget(req->r_dentry); /* we got spliced */ in ceph_finish_lookup()
757 dentry = NULL; in ceph_finish_lookup()
758 return dentry; in ceph_finish_lookup()
761 static bool is_root_ceph_dentry(struct inode *inode, struct dentry *dentry) in is_root_ceph_dentry() argument
764 strncmp(dentry->d_name.name, ".ceph", 5) == 0; in is_root_ceph_dentry()
771 static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, in ceph_lookup() argument
782 dir, dentry, dentry); in ceph_lookup()
784 if (dentry->d_name.len > NAME_MAX) in ceph_lookup()
790 err = fscrypt_prepare_lookup_partial(dir, dentry); in ceph_lookup()
800 if (d_really_is_negative(dentry)) { in ceph_lookup()
802 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_lookup()
806 if (strncmp(dentry->d_name.name, in ceph_lookup()
808 dentry->d_name.len) && in ceph_lookup()
809 !is_root_ceph_dentry(dir, dentry) && in ceph_lookup()
816 d_add(dentry, NULL); in ceph_lookup()
828 req->r_dentry = dget(dentry); in ceph_lookup()
841 struct dentry *res; in ceph_lookup()
843 res = ceph_handle_snapdir(req, dentry); in ceph_lookup()
847 dentry = res; in ceph_lookup()
851 dentry = ceph_finish_lookup(req, dentry, err); in ceph_lookup()
853 dout("lookup result=%p\n", dentry); in ceph_lookup()
854 return dentry; in ceph_lookup()
861 int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry) in ceph_handle_notrace_create() argument
863 struct dentry *result = ceph_lookup(dir, dentry, 0); in ceph_handle_notrace_create()
885 struct dentry *dentry, umode_t mode, dev_t rdev) in ceph_mknod() argument
895 err = ceph_wait_on_conflict_unlink(dentry); in ceph_mknod()
905 dir, dentry, mode, rdev); in ceph_mknod()
912 req->r_new_inode = ceph_new_inode(dir, dentry, &mode, &as_ctx); in ceph_mknod()
922 req->r_dentry = dget(dentry); in ceph_mknod()
937 err = ceph_handle_notrace_create(dir, dentry); in ceph_mknod()
942 ceph_init_inode_acls(d_inode(dentry), &as_ctx); in ceph_mknod()
944 d_drop(dentry); in ceph_mknod()
950 struct dentry *dentry, umode_t mode, bool excl) in ceph_create() argument
952 return ceph_mknod(idmap, dir, dentry, mode, 0); in ceph_create()
993 struct dentry *dentry, const char *dest) in ceph_symlink() argument
1004 err = ceph_wait_on_conflict_unlink(dentry); in ceph_symlink()
1013 dout("symlink in dir %p dentry %p to '%s'\n", dir, dentry, dest); in ceph_symlink()
1020 req->r_new_inode = ceph_new_inode(dir, dentry, &mode, &as_ctx); in ceph_symlink()
1043 req->r_dentry = dget(dentry); in ceph_symlink()
1053 err = ceph_handle_notrace_create(dir, dentry); in ceph_symlink()
1058 d_drop(dentry); in ceph_symlink()
1064 struct dentry *dentry, umode_t mode) in ceph_mkdir() argument
1072 err = ceph_wait_on_conflict_unlink(dentry); in ceph_mkdir()
1080 dentry, dentry); in ceph_mkdir()
1082 dout("mkdir dir %p dn %p mode 0%ho\n", dir, dentry, mode); in ceph_mkdir()
1108 req->r_new_inode = ceph_new_inode(dir, dentry, &mode, &as_ctx); in ceph_mkdir()
1115 req->r_dentry = dget(dentry); in ceph_mkdir()
1131 err = ceph_handle_notrace_create(dir, dentry); in ceph_mkdir()
1136 ceph_init_inode_acls(d_inode(dentry), &as_ctx); in ceph_mkdir()
1138 d_drop(dentry); in ceph_mkdir()
1143 static int ceph_link(struct dentry *old_dentry, struct inode *dir, in ceph_link()
1144 struct dentry *dentry) in ceph_link() argument
1150 if (dentry->d_flags & DCACHE_DISCONNECTED) in ceph_link()
1153 err = ceph_wait_on_conflict_unlink(dentry); in ceph_link()
1160 err = fscrypt_prepare_link(old_dentry, dir, dentry); in ceph_link()
1165 dir, ceph_vinop(dir), old_dentry, old_dentry, dentry, dentry); in ceph_link()
1168 d_drop(dentry); in ceph_link()
1171 req->r_dentry = dget(dentry); in ceph_link()
1189 d_drop(dentry); in ceph_link()
1192 d_instantiate(dentry, d_inode(old_dentry)); in ceph_link()
1201 struct dentry *dentry = req->r_dentry; in ceph_async_unlink_cb() local
1202 struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); in ceph_async_unlink_cb()
1203 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_async_unlink_cb()
1209 __func__, dentry, dentry); in ceph_async_unlink_cb()
1215 spin_lock(&dentry->d_lock); in ceph_async_unlink_cb()
1218 spin_unlock(&dentry->d_lock); in ceph_async_unlink_cb()
1229 char *path = ceph_mdsc_build_path(dentry, &pathlen, in ceph_async_unlink_cb()
1237 if (!d_unhashed(dentry)) in ceph_async_unlink_cb()
1238 d_drop(dentry); in ceph_async_unlink_cb()
1252 static int get_caps_for_async_unlink(struct inode *dir, struct dentry *dentry) in get_caps_for_async_unlink() argument
1269 spin_lock(&dentry->d_lock); in get_caps_for_async_unlink()
1270 di = ceph_dentry(dentry); in get_caps_for_async_unlink()
1278 spin_unlock(&dentry->d_lock); in get_caps_for_async_unlink()
1291 static int ceph_unlink(struct inode *dir, struct dentry *dentry) in ceph_unlink() argument
1295 struct inode *inode = d_inode(dentry); in ceph_unlink()
1303 dout("rmsnap dir %p '%pd' dn %p\n", dir, dentry, dentry); in ceph_unlink()
1307 dir, dentry, inode); in ceph_unlink()
1308 op = d_is_dir(dentry) ? in ceph_unlink()
1318 req->r_dentry = dget(dentry); in ceph_unlink()
1327 (req->r_dir_caps = get_caps_for_async_unlink(dir, dentry))) { in ceph_unlink()
1328 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_unlink()
1331 dentry->d_name.len, dentry->d_name.name, in ceph_unlink()
1335 req->r_old_inode = d_inode(dentry); in ceph_unlink()
1338 spin_lock(&dentry->d_lock); in ceph_unlink()
1340 spin_unlock(&dentry->d_lock); in ceph_unlink()
1344 dentry->d_name.hash); in ceph_unlink()
1354 d_delete(dentry); in ceph_unlink()
1360 spin_lock(&dentry->d_lock); in ceph_unlink()
1362 spin_unlock(&dentry->d_lock); in ceph_unlink()
1374 d_delete(dentry); in ceph_unlink()
1383 struct dentry *old_dentry, struct inode *new_dir, in ceph_rename()
1384 struct dentry *new_dentry, unsigned int flags) in ceph_rename()
1461 struct dentry *dn = di->dentry; in __ceph_dentry_lease_touch()
1495 struct dentry *dn = di->dentry; in __ceph_dentry_dir_lease_touch()
1533 mdsc = ceph_sb_to_client(di->dentry->d_sb)->mdsc; in __dentry_lease_unlist()
1556 int (*check)(struct dentry*, void*)) in __dentry_leases_walk() argument
1559 struct dentry *dentry, *last = NULL; in __dentry_leases_walk() local
1572 dentry = di->dentry; in __dentry_leases_walk()
1573 if (last == dentry) in __dentry_leases_walk()
1576 if (!spin_trylock(&dentry->d_lock)) in __dentry_leases_walk()
1579 if (__lockref_is_dead(&dentry->d_lockref)) { in __dentry_leases_walk()
1584 ret = check(dentry, lwc); in __dentry_leases_walk()
1589 last = dentry; in __dentry_leases_walk()
1594 if (dentry->d_lockref.count > 0) { in __dentry_leases_walk()
1603 dget_dlock(dentry); in __dentry_leases_walk()
1607 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1616 dentry = di->dentry; in __dentry_leases_walk()
1617 spin_lock(&dentry->d_lock); in __dentry_leases_walk()
1634 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1636 dput(dentry); in __dentry_leases_walk()
1641 static int __dentry_lease_check(struct dentry *dentry, void *arg) in __dentry_lease_check() argument
1643 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dentry_lease_check()
1648 ret = __dir_lease_try_check(dentry); in __dentry_lease_check()
1656 static int __dir_lease_check(struct dentry *dentry, void *arg) in __dir_lease_check() argument
1659 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dir_lease_check()
1661 int ret = __dir_lease_try_check(dentry); in __dir_lease_check()
1672 if (dentry->d_lockref.count > 0 || in __dir_lease_check()
1717 void ceph_invalidate_dentry_lease(struct dentry *dentry) in ceph_invalidate_dentry_lease() argument
1719 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_invalidate_dentry_lease()
1720 spin_lock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1725 spin_unlock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1756 static int dentry_lease_is_valid(struct dentry *dentry, unsigned int flags) in dentry_lease_is_valid() argument
1763 spin_lock(&dentry->d_lock); in dentry_lease_is_valid()
1764 di = ceph_dentry(dentry); in dentry_lease_is_valid()
1785 spin_unlock(&dentry->d_lock); in dentry_lease_is_valid()
1788 ceph_mdsc_lease_send_msg(session, dentry, in dentry_lease_is_valid()
1792 dout("dentry_lease_is_valid - dentry %p = %d\n", dentry, valid); in dentry_lease_is_valid()
1799 static int __dir_lease_try_check(const struct dentry *dentry) in __dir_lease_try_check() argument
1801 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dir_lease_try_check()
1808 if (IS_ROOT(dentry)) in __dir_lease_try_check()
1811 dir = d_inode(dentry->d_parent); in __dir_lease_try_check()
1831 static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry, in dir_lease_is_valid() argument
1847 spin_lock(&dentry->d_lock); in dir_lease_is_valid()
1848 di = ceph_dentry(dentry); in dir_lease_is_valid()
1849 if (dir == d_inode(dentry->d_parent) && in dir_lease_is_valid()
1854 spin_unlock(&dentry->d_lock); in dir_lease_is_valid()
1857 dir, (unsigned)atomic_read(&ci->i_shared_gen), dentry, valid); in dir_lease_is_valid()
1864 static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags) in ceph_d_revalidate() argument
1867 struct dentry *parent; in ceph_d_revalidate()
1871 valid = fscrypt_d_revalidate(dentry, flags); in ceph_d_revalidate()
1876 parent = READ_ONCE(dentry->d_parent); in ceph_d_revalidate()
1880 inode = d_inode_rcu(dentry); in ceph_d_revalidate()
1882 parent = dget_parent(dentry); in ceph_d_revalidate()
1884 inode = d_inode(dentry); in ceph_d_revalidate()
1887 dout("d_revalidate %p '%pd' inode %p offset 0x%llx nokey %d\n", dentry, in ceph_d_revalidate()
1888 dentry, inode, ceph_dentry(dentry)->offset, in ceph_d_revalidate()
1889 !!(dentry->d_flags & DCACHE_NOKEY_NAME)); in ceph_d_revalidate()
1895 dout("d_revalidate %p '%pd' inode %p is SNAPPED\n", dentry, in ceph_d_revalidate()
1896 dentry, inode); in ceph_d_revalidate()
1901 valid = dentry_lease_is_valid(dentry, flags); in ceph_d_revalidate()
1904 if (valid || dir_lease_is_valid(dir, dentry, mdsc)) { in ceph_d_revalidate()
1926 req->r_dentry = dget(dentry); in ceph_d_revalidate()
1939 if (d_really_is_positive(dentry) && in ceph_d_revalidate()
1940 d_inode(dentry) == req->r_target_inode) in ceph_d_revalidate()
1944 if (d_really_is_negative(dentry)) in ceph_d_revalidate()
1952 dentry, err); in ceph_d_revalidate()
1958 dout("d_revalidate %p %s\n", dentry, valid ? "valid" : "invalid"); in ceph_d_revalidate()
1972 static int ceph_d_delete(const struct dentry *dentry) in ceph_d_delete() argument
1977 if (d_really_is_negative(dentry)) in ceph_d_delete()
1979 if (ceph_snap(d_inode(dentry)) != CEPH_NOSNAP) in ceph_d_delete()
1982 di = ceph_dentry(dentry); in ceph_d_delete()
1986 if (__dir_lease_try_check(dentry)) in ceph_d_delete()
1995 static void ceph_d_release(struct dentry *dentry) in ceph_d_release() argument
1997 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_d_release()
1998 struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); in ceph_d_release()
2000 dout("d_release %p\n", dentry); in ceph_d_release()
2004 spin_lock(&dentry->d_lock); in ceph_d_release()
2006 dentry->d_fsdata = NULL; in ceph_d_release()
2007 spin_unlock(&dentry->d_lock); in ceph_d_release()
2019 static void ceph_d_prune(struct dentry *dentry) in ceph_d_prune() argument
2024 dout("ceph_d_prune %pd %p\n", dentry, dentry); in ceph_d_prune()
2027 if (IS_ROOT(dentry)) in ceph_d_prune()
2031 dir_ci = ceph_inode(d_inode(dentry->d_parent)); in ceph_d_prune()
2036 if (d_really_is_negative(dentry)) in ceph_d_prune()
2040 if (!d_unhashed(dentry)) { in ceph_d_prune()
2048 di = ceph_dentry(dentry); in ceph_d_prune()
2111 unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) in ceph_dentry_hash()