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()
282 ino_t ino = parent_ino(file->f_path.dentry); in ceph_readdir()
353 req->r_dentry = dget(file->f_path.dentry); in ceph_readdir()
473 sizeof(struct dentry*)); in ceph_readdir()
553 struct dentry *dentry, int err) in ceph_handle_snapdir() argument
555 struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); in ceph_handle_snapdir()
556 struct inode *parent = d_inode(dentry->d_parent); /* we hold i_mutex */ in ceph_handle_snapdir()
561 strcmp(dentry->d_name.name, in ceph_handle_snapdir()
565 dentry, dentry, inode); in ceph_handle_snapdir()
566 BUG_ON(!d_unhashed(dentry)); in ceph_handle_snapdir()
567 d_add(dentry, inode); in ceph_handle_snapdir()
584 struct dentry *ceph_finish_lookup(struct ceph_mds_request *req, in ceph_finish_lookup()
585 struct dentry *dentry, int err) in ceph_finish_lookup() argument
592 dentry, d_inode(dentry)); in ceph_finish_lookup()
593 if (d_really_is_positive(dentry)) { in ceph_finish_lookup()
594 d_drop(dentry); in ceph_finish_lookup()
597 d_add(dentry, NULL); in ceph_finish_lookup()
602 dentry = ERR_PTR(err); in ceph_finish_lookup()
603 else if (dentry != req->r_dentry) in ceph_finish_lookup()
604 dentry = dget(req->r_dentry); /* we got spliced */ in ceph_finish_lookup()
606 dentry = NULL; in ceph_finish_lookup()
607 return dentry; in ceph_finish_lookup()
610 static int is_root_ceph_dentry(struct inode *inode, struct dentry *dentry) in is_root_ceph_dentry() argument
613 strncmp(dentry->d_name.name, ".ceph", 5) == 0; in is_root_ceph_dentry()
620 static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, in ceph_lookup() argument
630 dir, dentry, dentry); in ceph_lookup()
632 if (dentry->d_name.len > NAME_MAX) in ceph_lookup()
635 err = ceph_init_dentry(dentry); in ceph_lookup()
640 if (d_really_is_negative(dentry)) { in ceph_lookup()
642 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_lookup()
646 if (strncmp(dentry->d_name.name, in ceph_lookup()
648 dentry->d_name.len) && in ceph_lookup()
649 !is_root_ceph_dentry(dir, dentry) && in ceph_lookup()
655 d_add(dentry, NULL); in ceph_lookup()
667 req->r_dentry = dget(dentry); in ceph_lookup()
673 err = ceph_handle_snapdir(req, dentry, err); in ceph_lookup()
674 dentry = ceph_finish_lookup(req, dentry, err); in ceph_lookup()
676 dout("lookup result=%p\n", dentry); in ceph_lookup()
677 return dentry; in ceph_lookup()
684 int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry) in ceph_handle_notrace_create() argument
686 struct dentry *result = ceph_lookup(dir, dentry, 0); in ceph_handle_notrace_create()
707 static int ceph_mknod(struct inode *dir, struct dentry *dentry, in ceph_mknod() argument
724 dir, dentry, mode, rdev); in ceph_mknod()
730 req->r_dentry = dget(dentry); in ceph_mknod()
743 err = ceph_handle_notrace_create(dir, dentry); in ceph_mknod()
747 ceph_init_inode_acls(d_inode(dentry), &acls); in ceph_mknod()
749 d_drop(dentry); in ceph_mknod()
754 static int ceph_create(struct inode *dir, struct dentry *dentry, umode_t mode, in ceph_create() argument
757 return ceph_mknod(dir, dentry, mode, 0); in ceph_create()
760 static int ceph_symlink(struct inode *dir, struct dentry *dentry, in ceph_symlink() argument
771 dout("symlink in dir %p dentry %p to '%s'\n", dir, dentry, dest); in ceph_symlink()
784 req->r_dentry = dget(dentry); in ceph_symlink()
790 err = ceph_handle_notrace_create(dir, dentry); in ceph_symlink()
794 d_drop(dentry); in ceph_symlink()
798 static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) in ceph_mkdir() argument
811 dentry, dentry); in ceph_mkdir()
813 dout("mkdir dir %p dn %p mode 0%ho\n", dir, dentry, mode); in ceph_mkdir()
830 req->r_dentry = dget(dentry); in ceph_mkdir()
844 err = ceph_handle_notrace_create(dir, dentry); in ceph_mkdir()
848 ceph_init_inode_acls(d_inode(dentry), &acls); in ceph_mkdir()
850 d_drop(dentry); in ceph_mkdir()
855 static int ceph_link(struct dentry *old_dentry, struct inode *dir, in ceph_link()
856 struct dentry *dentry) in ceph_link() argument
867 old_dentry, dentry); in ceph_link()
870 d_drop(dentry); in ceph_link()
873 req->r_dentry = dget(dentry); in ceph_link()
883 d_drop(dentry); in ceph_link()
886 d_instantiate(dentry, d_inode(old_dentry)); in ceph_link()
915 static int ceph_unlink(struct inode *dir, struct dentry *dentry) in ceph_unlink() argument
919 struct inode *inode = d_inode(dentry); in ceph_unlink()
926 dout("rmsnap dir %p '%pd' dn %p\n", dir, dentry, dentry); in ceph_unlink()
930 dir, dentry, inode); in ceph_unlink()
931 op = d_is_dir(dentry) ? in ceph_unlink()
940 req->r_dentry = dget(dentry); in ceph_unlink()
948 d_delete(dentry); in ceph_unlink()
954 static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry, in ceph_rename()
955 struct inode *new_dir, struct dentry *new_dentry) in ceph_rename()
1015 void ceph_invalidate_dentry_lease(struct dentry *dentry) in ceph_invalidate_dentry_lease() argument
1017 spin_lock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1018 dentry->d_time = jiffies; in ceph_invalidate_dentry_lease()
1019 ceph_dentry(dentry)->lease_shared_gen = 0; in ceph_invalidate_dentry_lease()
1020 spin_unlock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1027 static int dentry_lease_is_valid(struct dentry *dentry) in dentry_lease_is_valid() argument
1038 spin_lock(&dentry->d_lock); in dentry_lease_is_valid()
1039 di = ceph_dentry(dentry); in dentry_lease_is_valid()
1048 time_before(jiffies, dentry->d_time) && in dentry_lease_is_valid()
1054 dir = d_inode(dentry->d_parent); in dentry_lease_is_valid()
1062 spin_unlock(&dentry->d_lock); in dentry_lease_is_valid()
1065 ceph_mdsc_lease_send_msg(session, dir, dentry, in dentry_lease_is_valid()
1069 dout("dentry_lease_is_valid - dentry %p = %d\n", dentry, valid); in dentry_lease_is_valid()
1076 static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry) in dir_lease_is_valid() argument
1079 struct ceph_dentry_info *di = ceph_dentry(dentry); in dir_lease_is_valid()
1087 dir, (unsigned)ci->i_shared_gen, dentry, in dir_lease_is_valid()
1095 static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags) in ceph_d_revalidate() argument
1103 dout("d_revalidate %p '%pd' inode %p offset %lld\n", dentry, in ceph_d_revalidate()
1104 dentry, d_inode(dentry), ceph_dentry(dentry)->offset); in ceph_d_revalidate()
1106 dir = ceph_get_dentry_parent_inode(dentry); in ceph_d_revalidate()
1110 dout("d_revalidate %p '%pd' inode %p is SNAPPED\n", dentry, in ceph_d_revalidate()
1111 dentry, d_inode(dentry)); in ceph_d_revalidate()
1113 } else if (d_really_is_positive(dentry) && in ceph_d_revalidate()
1114 ceph_snap(d_inode(dentry)) == CEPH_SNAPDIR) { in ceph_d_revalidate()
1116 } else if (dentry_lease_is_valid(dentry) || in ceph_d_revalidate()
1117 dir_lease_is_valid(dir, dentry)) { in ceph_d_revalidate()
1118 if (d_really_is_positive(dentry)) in ceph_d_revalidate()
1119 valid = ceph_is_any_caps(d_inode(dentry)); in ceph_d_revalidate()
1124 dout("d_revalidate %p %s\n", dentry, valid ? "valid" : "invalid"); in ceph_d_revalidate()
1126 ceph_dentry_lru_touch(dentry); in ceph_d_revalidate()
1137 static void ceph_d_release(struct dentry *dentry) in ceph_d_release() argument
1139 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_d_release()
1141 dout("d_release %p\n", dentry); in ceph_d_release()
1142 ceph_dentry_lru_del(dentry); in ceph_d_release()
1146 dentry->d_fsdata = NULL; in ceph_d_release()
1149 static int ceph_snapdir_d_revalidate(struct dentry *dentry, in ceph_snapdir_d_revalidate() argument
1165 static void ceph_d_prune(struct dentry *dentry) in ceph_d_prune() argument
1167 dout("ceph_d_prune %p\n", dentry); in ceph_d_prune()
1170 if (IS_ROOT(dentry)) in ceph_d_prune()
1174 if (d_unhashed(dentry)) in ceph_d_prune()
1181 ceph_dir_clear_complete(d_inode(dentry->d_parent)); in ceph_d_prune()
1240 void ceph_dentry_lru_add(struct dentry *dn) in ceph_dentry_lru_add()
1253 void ceph_dentry_lru_touch(struct dentry *dn) in ceph_dentry_lru_touch()
1266 void ceph_dentry_lru_del(struct dentry *dn) in ceph_dentry_lru_del()
1283 unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) in ceph_dentry_hash()