Lines Matching refs:dentry
34 int ceph_init_dentry(struct dentry *dentry) in ceph_init_dentry() argument
38 if (dentry->d_fsdata) in ceph_init_dentry()
45 spin_lock(&dentry->d_lock); in ceph_init_dentry()
46 if (dentry->d_fsdata) { in ceph_init_dentry()
52 if (ceph_snap(d_inode(dentry->d_parent)) == CEPH_NOSNAP) in ceph_init_dentry()
53 d_set_d_op(dentry, &ceph_dentry_ops); in ceph_init_dentry()
54 else if (ceph_snap(d_inode(dentry->d_parent)) == CEPH_SNAPDIR) in ceph_init_dentry()
55 d_set_d_op(dentry, &ceph_snapdir_dentry_ops); in ceph_init_dentry()
57 d_set_d_op(dentry, &ceph_snap_dentry_ops); in ceph_init_dentry()
59 di->dentry = dentry; in ceph_init_dentry()
61 dentry->d_time = jiffies; in ceph_init_dentry()
64 dentry->d_fsdata = di; in ceph_init_dentry()
65 ceph_dentry_lru_add(dentry); in ceph_init_dentry()
67 spin_unlock(&dentry->d_lock); in ceph_init_dentry()
71 struct inode *ceph_get_dentry_parent_inode(struct dentry *dentry) in ceph_get_dentry_parent_inode() argument
75 if (!dentry) in ceph_get_dentry_parent_inode()
78 spin_lock(&dentry->d_lock); in ceph_get_dentry_parent_inode()
79 if (!IS_ROOT(dentry)) { in ceph_get_dentry_parent_inode()
80 inode = d_inode(dentry->d_parent); in ceph_get_dentry_parent_inode()
83 spin_unlock(&dentry->d_lock); in ceph_get_dentry_parent_inode()
145 struct dentry *parent = file->f_path.dentry; in __dcache_readdir()
147 struct dentry *dentry, *last = NULL; in __dcache_readdir() local
149 unsigned nsize = PAGE_CACHE_SIZE / sizeof(struct dentry *); in __dcache_readdir()
160 ptr_pos = cache_ctl.index * sizeof(struct dentry *); in __dcache_readdir()
194 dentry = cache_ctl.dentries[cache_ctl.index % nsize]; in __dcache_readdir()
196 dentry = NULL; in __dcache_readdir()
198 if (dentry && !lockref_get_not_dead(&dentry->d_lockref)) in __dcache_readdir()
199 dentry = NULL; in __dcache_readdir()
201 if (!dentry) in __dcache_readdir()
205 di = ceph_dentry(dentry); in __dcache_readdir()
206 spin_lock(&dentry->d_lock); in __dcache_readdir()
208 d_really_is_positive(dentry) && in __dcache_readdir()
209 ceph_snap(d_inode(dentry)) != CEPH_SNAPDIR && in __dcache_readdir()
210 ceph_ino(d_inode(dentry)) != CEPH_INO_CEPH && in __dcache_readdir()
214 spin_unlock(&dentry->d_lock); in __dcache_readdir()
218 dentry, dentry, d_inode(dentry)); in __dcache_readdir()
220 if (!dir_emit(ctx, dentry->d_name.name, in __dcache_readdir()
221 dentry->d_name.len, in __dcache_readdir()
222 ceph_translate_ino(dentry->d_sb, in __dcache_readdir()
223 d_inode(dentry)->i_ino), in __dcache_readdir()
224 d_inode(dentry)->i_mode >> 12)) { in __dcache_readdir()
225 dput(dentry); in __dcache_readdir()
233 last = dentry; in __dcache_readdir()
235 dput(dentry); in __dcache_readdir()
239 ptr_pos += sizeof(struct dentry *); in __dcache_readdir()
287 ino_t ino = parent_ino(file->f_path.dentry); in ceph_readdir()
358 req->r_dentry = dget(file->f_path.dentry); in ceph_readdir()
478 sizeof(struct dentry*)); in ceph_readdir()
558 struct dentry *dentry, int err) in ceph_handle_snapdir() argument
560 struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); in ceph_handle_snapdir()
561 struct inode *parent = d_inode(dentry->d_parent); /* we hold i_mutex */ in ceph_handle_snapdir()
566 strcmp(dentry->d_name.name, in ceph_handle_snapdir()
570 dentry, dentry, inode); in ceph_handle_snapdir()
571 BUG_ON(!d_unhashed(dentry)); in ceph_handle_snapdir()
572 d_add(dentry, inode); in ceph_handle_snapdir()
589 struct dentry *ceph_finish_lookup(struct ceph_mds_request *req, in ceph_finish_lookup()
590 struct dentry *dentry, int err) in ceph_finish_lookup() argument
597 dentry, d_inode(dentry)); in ceph_finish_lookup()
598 if (d_really_is_positive(dentry)) { in ceph_finish_lookup()
599 d_drop(dentry); in ceph_finish_lookup()
602 d_add(dentry, NULL); in ceph_finish_lookup()
607 dentry = ERR_PTR(err); in ceph_finish_lookup()
608 else if (dentry != req->r_dentry) in ceph_finish_lookup()
609 dentry = dget(req->r_dentry); /* we got spliced */ in ceph_finish_lookup()
611 dentry = NULL; in ceph_finish_lookup()
612 return dentry; in ceph_finish_lookup()
615 static int is_root_ceph_dentry(struct inode *inode, struct dentry *dentry) in is_root_ceph_dentry() argument
618 strncmp(dentry->d_name.name, ".ceph", 5) == 0; in is_root_ceph_dentry()
625 static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, in ceph_lookup() argument
635 dir, dentry, dentry); in ceph_lookup()
637 if (dentry->d_name.len > NAME_MAX) in ceph_lookup()
640 err = ceph_init_dentry(dentry); in ceph_lookup()
645 if (d_really_is_negative(dentry)) { in ceph_lookup()
647 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_lookup()
651 if (strncmp(dentry->d_name.name, in ceph_lookup()
653 dentry->d_name.len) && in ceph_lookup()
654 !is_root_ceph_dentry(dir, dentry) && in ceph_lookup()
660 d_add(dentry, NULL); in ceph_lookup()
672 req->r_dentry = dget(dentry); in ceph_lookup()
678 err = ceph_handle_snapdir(req, dentry, err); in ceph_lookup()
679 dentry = ceph_finish_lookup(req, dentry, err); in ceph_lookup()
681 dout("lookup result=%p\n", dentry); in ceph_lookup()
682 return dentry; in ceph_lookup()
689 int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry) in ceph_handle_notrace_create() argument
691 struct dentry *result = ceph_lookup(dir, dentry, 0); in ceph_handle_notrace_create()
712 static int ceph_mknod(struct inode *dir, struct dentry *dentry, in ceph_mknod() argument
729 dir, dentry, mode, rdev); in ceph_mknod()
735 req->r_dentry = dget(dentry); in ceph_mknod()
748 err = ceph_handle_notrace_create(dir, dentry); in ceph_mknod()
752 ceph_init_inode_acls(d_inode(dentry), &acls); in ceph_mknod()
754 d_drop(dentry); in ceph_mknod()
759 static int ceph_create(struct inode *dir, struct dentry *dentry, umode_t mode, in ceph_create() argument
762 return ceph_mknod(dir, dentry, mode, 0); in ceph_create()
765 static int ceph_symlink(struct inode *dir, struct dentry *dentry, in ceph_symlink() argument
776 dout("symlink in dir %p dentry %p to '%s'\n", dir, dentry, dest); in ceph_symlink()
789 req->r_dentry = dget(dentry); in ceph_symlink()
795 err = ceph_handle_notrace_create(dir, dentry); in ceph_symlink()
799 d_drop(dentry); in ceph_symlink()
803 static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) in ceph_mkdir() argument
816 dentry, dentry); in ceph_mkdir()
818 dout("mkdir dir %p dn %p mode 0%ho\n", dir, dentry, mode); in ceph_mkdir()
835 req->r_dentry = dget(dentry); in ceph_mkdir()
849 err = ceph_handle_notrace_create(dir, dentry); in ceph_mkdir()
853 ceph_init_inode_acls(d_inode(dentry), &acls); in ceph_mkdir()
855 d_drop(dentry); in ceph_mkdir()
860 static int ceph_link(struct dentry *old_dentry, struct inode *dir, in ceph_link()
861 struct dentry *dentry) in ceph_link() argument
872 old_dentry, dentry); in ceph_link()
875 d_drop(dentry); in ceph_link()
878 req->r_dentry = dget(dentry); in ceph_link()
888 d_drop(dentry); in ceph_link()
891 d_instantiate(dentry, d_inode(old_dentry)); in ceph_link()
920 static int ceph_unlink(struct inode *dir, struct dentry *dentry) in ceph_unlink() argument
924 struct inode *inode = d_inode(dentry); in ceph_unlink()
931 dout("rmsnap dir %p '%pd' dn %p\n", dir, dentry, dentry); in ceph_unlink()
935 dir, dentry, inode); in ceph_unlink()
936 op = d_is_dir(dentry) ? in ceph_unlink()
945 req->r_dentry = dget(dentry); in ceph_unlink()
953 d_delete(dentry); in ceph_unlink()
959 static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry, in ceph_rename()
960 struct inode *new_dir, struct dentry *new_dentry) in ceph_rename()
1020 void ceph_invalidate_dentry_lease(struct dentry *dentry) in ceph_invalidate_dentry_lease() argument
1022 spin_lock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1023 dentry->d_time = jiffies; in ceph_invalidate_dentry_lease()
1024 ceph_dentry(dentry)->lease_shared_gen = 0; in ceph_invalidate_dentry_lease()
1025 spin_unlock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1032 static int dentry_lease_is_valid(struct dentry *dentry) in dentry_lease_is_valid() argument
1043 spin_lock(&dentry->d_lock); in dentry_lease_is_valid()
1044 di = ceph_dentry(dentry); in dentry_lease_is_valid()
1053 time_before(jiffies, dentry->d_time) && in dentry_lease_is_valid()
1059 dir = d_inode(dentry->d_parent); in dentry_lease_is_valid()
1067 spin_unlock(&dentry->d_lock); in dentry_lease_is_valid()
1070 ceph_mdsc_lease_send_msg(session, dir, dentry, in dentry_lease_is_valid()
1074 dout("dentry_lease_is_valid - dentry %p = %d\n", dentry, valid); in dentry_lease_is_valid()
1081 static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry) in dir_lease_is_valid() argument
1084 struct ceph_dentry_info *di = ceph_dentry(dentry); in dir_lease_is_valid()
1092 dir, (unsigned)ci->i_shared_gen, dentry, in dir_lease_is_valid()
1100 static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags) in ceph_d_revalidate() argument
1108 dout("d_revalidate %p '%pd' inode %p offset %lld\n", dentry, in ceph_d_revalidate()
1109 dentry, d_inode(dentry), ceph_dentry(dentry)->offset); in ceph_d_revalidate()
1111 dir = ceph_get_dentry_parent_inode(dentry); in ceph_d_revalidate()
1115 dout("d_revalidate %p '%pd' inode %p is SNAPPED\n", dentry, in ceph_d_revalidate()
1116 dentry, d_inode(dentry)); in ceph_d_revalidate()
1118 } else if (d_really_is_positive(dentry) && in ceph_d_revalidate()
1119 ceph_snap(d_inode(dentry)) == CEPH_SNAPDIR) { in ceph_d_revalidate()
1121 } else if (dentry_lease_is_valid(dentry) || in ceph_d_revalidate()
1122 dir_lease_is_valid(dir, dentry)) { in ceph_d_revalidate()
1123 if (d_really_is_positive(dentry)) in ceph_d_revalidate()
1124 valid = ceph_is_any_caps(d_inode(dentry)); in ceph_d_revalidate()
1129 dout("d_revalidate %p %s\n", dentry, valid ? "valid" : "invalid"); in ceph_d_revalidate()
1131 ceph_dentry_lru_touch(dentry); in ceph_d_revalidate()
1142 static void ceph_d_release(struct dentry *dentry) in ceph_d_release() argument
1144 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_d_release()
1146 dout("d_release %p\n", dentry); in ceph_d_release()
1147 ceph_dentry_lru_del(dentry); in ceph_d_release()
1151 dentry->d_fsdata = NULL; in ceph_d_release()
1154 static int ceph_snapdir_d_revalidate(struct dentry *dentry, in ceph_snapdir_d_revalidate() argument
1170 static void ceph_d_prune(struct dentry *dentry) in ceph_d_prune() argument
1172 dout("ceph_d_prune %p\n", dentry); in ceph_d_prune()
1175 if (IS_ROOT(dentry)) in ceph_d_prune()
1179 if (d_unhashed(dentry)) in ceph_d_prune()
1186 ceph_dir_clear_complete(d_inode(dentry->d_parent)); in ceph_d_prune()
1245 void ceph_dentry_lru_add(struct dentry *dn) in ceph_dentry_lru_add()
1258 void ceph_dentry_lru_touch(struct dentry *dn) in ceph_dentry_lru_touch()
1271 void ceph_dentry_lru_del(struct dentry *dn) in ceph_dentry_lru_del()
1288 unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) in ceph_dentry_hash()