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
46 di->dentry = dentry; in ceph_d_init()
49 dentry->d_fsdata = di; in ceph_d_init()
123 static struct dentry *
124 __dcache_find_get_entry(struct dentry *parent, u64 idx, in __dcache_find_get_entry()
128 struct dentry *dentry; in __dcache_find_get_entry() local
129 unsigned idx_mask = (PAGE_SIZE / sizeof(struct dentry *)) - 1; in __dcache_find_get_entry()
130 loff_t ptr_pos = idx * sizeof(struct dentry *); in __dcache_find_get_entry()
156 dentry = cache_ctl->dentries[cache_ctl->index]; in __dcache_find_get_entry()
158 dentry = NULL; in __dcache_find_get_entry()
160 if (dentry && !lockref_get_not_dead(&dentry->d_lockref)) in __dcache_find_get_entry()
161 dentry = NULL; in __dcache_find_get_entry()
163 return dentry ? : ERR_PTR(-EAGAIN); in __dcache_find_get_entry()
181 struct dentry *parent = file->f_path.dentry; in __dcache_readdir()
183 struct dentry *dentry, *last = NULL; in __dcache_readdir() local
193 u64 count = div_u64(i_size_read(dir), sizeof(struct dentry *)); in __dcache_readdir()
196 dentry = __dcache_find_get_entry(parent, idx + step, in __dcache_readdir()
198 if (!dentry) { in __dcache_readdir()
203 if (IS_ERR(dentry)) { in __dcache_readdir()
204 err = PTR_ERR(dentry); in __dcache_readdir()
207 di = ceph_dentry(dentry); in __dcache_readdir()
208 spin_lock(&dentry->d_lock); in __dcache_readdir()
215 spin_unlock(&dentry->d_lock); in __dcache_readdir()
216 dput(dentry); in __dcache_readdir()
225 dentry = __dcache_find_get_entry(parent, idx++, &cache_ctl); in __dcache_readdir()
226 if (!dentry) { in __dcache_readdir()
231 if (IS_ERR(dentry)) { in __dcache_readdir()
232 err = PTR_ERR(dentry); in __dcache_readdir()
236 spin_lock(&dentry->d_lock); in __dcache_readdir()
237 di = ceph_dentry(dentry); in __dcache_readdir()
238 if (d_unhashed(dentry) || in __dcache_readdir()
239 d_really_is_negative(dentry) || in __dcache_readdir()
241 spin_unlock(&dentry->d_lock); in __dcache_readdir()
242 dput(dentry); in __dcache_readdir()
250 spin_unlock(&dentry->d_lock); in __dcache_readdir()
254 dentry, dentry, d_inode(dentry)); in __dcache_readdir()
256 if (!dir_emit(ctx, dentry->d_name.name, in __dcache_readdir()
257 dentry->d_name.len, in __dcache_readdir()
258 ceph_translate_ino(dentry->d_sb, in __dcache_readdir()
259 d_inode(dentry)->i_ino), in __dcache_readdir()
260 d_inode(dentry)->i_mode >> 12)) { in __dcache_readdir()
261 dput(dentry); in __dcache_readdir()
269 last = dentry; in __dcache_readdir()
271 dput(dentry); in __dcache_readdir()
329 ino_t ino = parent_ino(file->f_path.dentry); in ceph_readdir()
416 req->r_dentry = dget(file->f_path.dentry); in ceph_readdir()
569 sizeof(struct dentry*)); in ceph_readdir()
666 struct dentry *dentry, int err) in ceph_handle_snapdir() argument
668 struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); in ceph_handle_snapdir()
669 struct inode *parent = d_inode(dentry->d_parent); /* we hold i_mutex */ in ceph_handle_snapdir()
674 strcmp(dentry->d_name.name, in ceph_handle_snapdir()
678 dentry, dentry, inode); in ceph_handle_snapdir()
679 BUG_ON(!d_unhashed(dentry)); in ceph_handle_snapdir()
680 d_add(dentry, inode); in ceph_handle_snapdir()
697 struct dentry *ceph_finish_lookup(struct ceph_mds_request *req, in ceph_finish_lookup()
698 struct dentry *dentry, int err) in ceph_finish_lookup() argument
705 dentry, d_inode(dentry)); in ceph_finish_lookup()
706 if (d_really_is_positive(dentry)) { in ceph_finish_lookup()
707 d_drop(dentry); in ceph_finish_lookup()
710 d_add(dentry, NULL); in ceph_finish_lookup()
715 dentry = ERR_PTR(err); in ceph_finish_lookup()
716 else if (dentry != req->r_dentry) in ceph_finish_lookup()
717 dentry = dget(req->r_dentry); /* we got spliced */ in ceph_finish_lookup()
719 dentry = NULL; in ceph_finish_lookup()
720 return dentry; in ceph_finish_lookup()
723 static bool is_root_ceph_dentry(struct inode *inode, struct dentry *dentry) in is_root_ceph_dentry() argument
726 strncmp(dentry->d_name.name, ".ceph", 5) == 0; in is_root_ceph_dentry()
733 static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, in ceph_lookup() argument
744 dir, dentry, dentry); in ceph_lookup()
746 if (dentry->d_name.len > NAME_MAX) in ceph_lookup()
750 if (d_really_is_negative(dentry)) { in ceph_lookup()
752 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_lookup()
756 if (strncmp(dentry->d_name.name, in ceph_lookup()
758 dentry->d_name.len) && in ceph_lookup()
759 !is_root_ceph_dentry(dir, dentry) && in ceph_lookup()
765 d_add(dentry, NULL); in ceph_lookup()
777 req->r_dentry = dget(dentry); in ceph_lookup()
788 err = ceph_handle_snapdir(req, dentry, err); in ceph_lookup()
789 dentry = ceph_finish_lookup(req, dentry, err); in ceph_lookup()
791 dout("lookup result=%p\n", dentry); in ceph_lookup()
792 return dentry; in ceph_lookup()
799 int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry) in ceph_handle_notrace_create() argument
801 struct dentry *result = ceph_lookup(dir, dentry, 0); in ceph_handle_notrace_create()
822 static int ceph_mknod(struct inode *dir, struct dentry *dentry, in ceph_mknod() argument
842 err = ceph_security_init_secctx(dentry, mode, &as_ctx); in ceph_mknod()
847 dir, dentry, mode, rdev); in ceph_mknod()
853 req->r_dentry = dget(dentry); in ceph_mknod()
867 err = ceph_handle_notrace_create(dir, dentry); in ceph_mknod()
871 ceph_init_inode_acls(d_inode(dentry), &as_ctx); in ceph_mknod()
873 d_drop(dentry); in ceph_mknod()
878 static int ceph_create(struct inode *dir, struct dentry *dentry, umode_t mode, in ceph_create() argument
881 return ceph_mknod(dir, dentry, mode, 0); in ceph_create()
884 static int ceph_symlink(struct inode *dir, struct dentry *dentry, in ceph_symlink() argument
901 err = ceph_security_init_secctx(dentry, S_IFLNK | 0777, &as_ctx); in ceph_symlink()
905 dout("symlink in dir %p dentry %p to '%s'\n", dir, dentry, dest); in ceph_symlink()
919 req->r_dentry = dget(dentry); in ceph_symlink()
925 err = ceph_handle_notrace_create(dir, dentry); in ceph_symlink()
929 d_drop(dentry); in ceph_symlink()
934 static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) in ceph_mkdir() argument
947 dentry, dentry); in ceph_mkdir()
949 dout("mkdir dir %p dn %p mode 0%ho\n", dir, dentry, mode); in ceph_mkdir()
965 err = ceph_security_init_secctx(dentry, mode, &as_ctx); in ceph_mkdir()
975 req->r_dentry = dget(dentry); in ceph_mkdir()
990 err = ceph_handle_notrace_create(dir, dentry); in ceph_mkdir()
994 ceph_init_inode_acls(d_inode(dentry), &as_ctx); in ceph_mkdir()
996 d_drop(dentry); in ceph_mkdir()
1001 static int ceph_link(struct dentry *old_dentry, struct inode *dir, in ceph_link()
1002 struct dentry *dentry) in ceph_link() argument
1013 old_dentry, dentry); in ceph_link()
1016 d_drop(dentry); in ceph_link()
1019 req->r_dentry = dget(dentry); in ceph_link()
1030 d_drop(dentry); in ceph_link()
1033 d_instantiate(dentry, d_inode(old_dentry)); in ceph_link()
1042 static int ceph_unlink(struct inode *dir, struct dentry *dentry) in ceph_unlink() argument
1046 struct inode *inode = d_inode(dentry); in ceph_unlink()
1053 dout("rmsnap dir %p '%pd' dn %p\n", dir, dentry, dentry); in ceph_unlink()
1057 dir, dentry, inode); in ceph_unlink()
1058 op = d_is_dir(dentry) ? in ceph_unlink()
1067 req->r_dentry = dget(dentry); in ceph_unlink()
1076 d_delete(dentry); in ceph_unlink()
1082 static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry, in ceph_rename()
1083 struct inode *new_dir, struct dentry *new_dentry, in ceph_rename()
1152 struct dentry *dn = di->dentry; in __ceph_dentry_lease_touch()
1186 struct dentry *dn = di->dentry; in __ceph_dentry_dir_lease_touch()
1224 mdsc = ceph_sb_to_client(di->dentry->d_sb)->mdsc; in __dentry_lease_unlist()
1247 int (*check)(struct dentry*, void*)) in __dentry_leases_walk() argument
1250 struct dentry *dentry, *last = NULL; in __dentry_leases_walk() local
1263 dentry = di->dentry; in __dentry_leases_walk()
1264 if (last == dentry) in __dentry_leases_walk()
1267 if (!spin_trylock(&dentry->d_lock)) in __dentry_leases_walk()
1270 if (__lockref_is_dead(&dentry->d_lockref)) { in __dentry_leases_walk()
1275 ret = check(dentry, lwc); in __dentry_leases_walk()
1280 last = dentry; in __dentry_leases_walk()
1285 if (dentry->d_lockref.count > 0) { in __dentry_leases_walk()
1294 dget_dlock(dentry); in __dentry_leases_walk()
1298 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1307 dentry = di->dentry; in __dentry_leases_walk()
1308 spin_lock(&dentry->d_lock); in __dentry_leases_walk()
1325 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1327 dput(dentry); in __dentry_leases_walk()
1332 static int __dentry_lease_check(struct dentry *dentry, void *arg) in __dentry_lease_check() argument
1334 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dentry_lease_check()
1339 ret = __dir_lease_try_check(dentry); in __dentry_lease_check()
1347 static int __dir_lease_check(struct dentry *dentry, void *arg) in __dir_lease_check() argument
1350 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dir_lease_check()
1352 int ret = __dir_lease_try_check(dentry); in __dir_lease_check()
1363 if (dentry->d_lockref.count > 0 || in __dir_lease_check()
1408 void ceph_invalidate_dentry_lease(struct dentry *dentry) in ceph_invalidate_dentry_lease() argument
1410 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_invalidate_dentry_lease()
1411 spin_lock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1415 spin_unlock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1448 static int dentry_lease_is_valid(struct dentry *dentry, unsigned int flags) in dentry_lease_is_valid() argument
1455 spin_lock(&dentry->d_lock); in dentry_lease_is_valid()
1456 di = ceph_dentry(dentry); in dentry_lease_is_valid()
1477 spin_unlock(&dentry->d_lock); in dentry_lease_is_valid()
1480 ceph_mdsc_lease_send_msg(session, dentry, in dentry_lease_is_valid()
1484 dout("dentry_lease_is_valid - dentry %p = %d\n", dentry, valid); in dentry_lease_is_valid()
1491 static int __dir_lease_try_check(const struct dentry *dentry) in __dir_lease_try_check() argument
1493 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dir_lease_try_check()
1500 if (IS_ROOT(dentry)) in __dir_lease_try_check()
1503 dir = d_inode(dentry->d_parent); in __dir_lease_try_check()
1523 static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry) in dir_lease_is_valid() argument
1535 spin_lock(&dentry->d_lock); in dir_lease_is_valid()
1536 di = ceph_dentry(dentry); in dir_lease_is_valid()
1537 if (dir == d_inode(dentry->d_parent) && in dir_lease_is_valid()
1542 spin_unlock(&dentry->d_lock); in dir_lease_is_valid()
1545 dir, (unsigned)atomic_read(&ci->i_shared_gen), dentry, valid); in dir_lease_is_valid()
1552 static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags) in ceph_d_revalidate() argument
1555 struct dentry *parent; in ceph_d_revalidate()
1559 parent = READ_ONCE(dentry->d_parent); in ceph_d_revalidate()
1563 inode = d_inode_rcu(dentry); in ceph_d_revalidate()
1565 parent = dget_parent(dentry); in ceph_d_revalidate()
1567 inode = d_inode(dentry); in ceph_d_revalidate()
1570 dout("d_revalidate %p '%pd' inode %p offset %lld\n", dentry, in ceph_d_revalidate()
1571 dentry, inode, ceph_dentry(dentry)->offset); in ceph_d_revalidate()
1575 dout("d_revalidate %p '%pd' inode %p is SNAPPED\n", dentry, in ceph_d_revalidate()
1576 dentry, inode); in ceph_d_revalidate()
1581 valid = dentry_lease_is_valid(dentry, flags); in ceph_d_revalidate()
1584 if (valid || dir_lease_is_valid(dir, dentry)) { in ceph_d_revalidate()
1606 req->r_dentry = dget(dentry); in ceph_d_revalidate()
1618 if (d_really_is_positive(dentry) && in ceph_d_revalidate()
1619 d_inode(dentry) == req->r_target_inode) in ceph_d_revalidate()
1623 if (d_really_is_negative(dentry)) in ceph_d_revalidate()
1631 dentry, err); in ceph_d_revalidate()
1635 dout("d_revalidate %p %s\n", dentry, valid ? "valid" : "invalid"); in ceph_d_revalidate()
1649 static int ceph_d_delete(const struct dentry *dentry) in ceph_d_delete() argument
1654 if (d_really_is_negative(dentry)) in ceph_d_delete()
1656 if (ceph_snap(d_inode(dentry)) != CEPH_NOSNAP) in ceph_d_delete()
1659 di = ceph_dentry(dentry); in ceph_d_delete()
1663 if (__dir_lease_try_check(dentry)) in ceph_d_delete()
1672 static void ceph_d_release(struct dentry *dentry) in ceph_d_release() argument
1674 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_d_release()
1676 dout("d_release %p\n", dentry); in ceph_d_release()
1678 spin_lock(&dentry->d_lock); in ceph_d_release()
1680 dentry->d_fsdata = NULL; in ceph_d_release()
1681 spin_unlock(&dentry->d_lock); in ceph_d_release()
1694 static void ceph_d_prune(struct dentry *dentry) in ceph_d_prune() argument
1699 dout("ceph_d_prune %pd %p\n", dentry, dentry); in ceph_d_prune()
1702 if (IS_ROOT(dentry)) in ceph_d_prune()
1706 dir_ci = ceph_inode(d_inode(dentry->d_parent)); in ceph_d_prune()
1711 if (d_really_is_negative(dentry)) in ceph_d_prune()
1715 if (!d_unhashed(dentry)) { in ceph_d_prune()
1723 di = ceph_dentry(dentry); in ceph_d_prune()
1786 unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) in ceph_dentry_hash()