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()
124 struct dentry *parent = file->f_path.dentry; in __dcache_readdir()
127 struct dentry *dentry, *last; in __dcache_readdir() local
132 last = fi->dentry; in __dcache_readdir()
133 fi->dentry = NULL; in __dcache_readdir()
152 dentry = list_entry(p, struct dentry, d_child); in __dcache_readdir()
153 di = ceph_dentry(dentry); in __dcache_readdir()
156 d_unhashed(dentry) ? "!hashed" : "hashed", in __dcache_readdir()
162 spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); in __dcache_readdir()
164 !d_unhashed(dentry) && d_really_is_positive(dentry) && in __dcache_readdir()
165 ceph_snap(d_inode(dentry)) != CEPH_SNAPDIR && in __dcache_readdir()
166 ceph_ino(d_inode(dentry)) != CEPH_INO_CEPH && in __dcache_readdir()
169 dout(" skipping %p %pd at %llu (%llu)%s%s\n", dentry, in __dcache_readdir()
170 dentry, di->offset, in __dcache_readdir()
171 ctx->pos, d_unhashed(dentry) ? " unhashed" : "", in __dcache_readdir()
172 !d_inode(dentry) ? " null" : ""); in __dcache_readdir()
173 spin_unlock(&dentry->d_lock); in __dcache_readdir()
175 dentry = list_entry(p, struct dentry, d_child); in __dcache_readdir()
176 di = ceph_dentry(dentry); in __dcache_readdir()
179 dget_dlock(dentry); in __dcache_readdir()
180 spin_unlock(&dentry->d_lock); in __dcache_readdir()
186 dput(dentry); in __dcache_readdir()
192 dentry, dentry, d_inode(dentry)); in __dcache_readdir()
193 if (!dir_emit(ctx, dentry->d_name.name, in __dcache_readdir()
194 dentry->d_name.len, in __dcache_readdir()
195 ceph_translate_ino(dentry->d_sb, d_inode(dentry)->i_ino), in __dcache_readdir()
196 d_inode(dentry)->i_mode >> 12)) { in __dcache_readdir()
199 fi->dentry = last; in __dcache_readdir()
202 dput(dentry); in __dcache_readdir()
210 last = dentry; in __dcache_readdir()
271 ino_t ino = parent_ino(file->f_path.dentry); in ceph_readdir()
283 if ((ctx->pos == 2 || fi->dentry) && in ceph_readdir()
299 if (fi->dentry) { in ceph_readdir()
300 err = note_last_dentry(fi, fi->dentry->d_name.name, in ceph_readdir()
301 fi->dentry->d_name.len); in ceph_readdir()
304 dput(fi->dentry); in ceph_readdir()
305 fi->dentry = NULL; in ceph_readdir()
356 req->r_dentry = dget(file->f_path.dentry); in ceph_readdir()
483 if (fi->dentry) { in reset_readdir()
484 dput(fi->dentry); in reset_readdir()
485 fi->dentry = NULL; in reset_readdir()
543 struct dentry *dentry, int err) in ceph_handle_snapdir() argument
545 struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); in ceph_handle_snapdir()
546 struct inode *parent = d_inode(dentry->d_parent); /* we hold i_mutex */ in ceph_handle_snapdir()
551 strcmp(dentry->d_name.name, in ceph_handle_snapdir()
555 dentry, dentry, inode); in ceph_handle_snapdir()
556 BUG_ON(!d_unhashed(dentry)); in ceph_handle_snapdir()
557 d_add(dentry, inode); in ceph_handle_snapdir()
574 struct dentry *ceph_finish_lookup(struct ceph_mds_request *req, in ceph_finish_lookup()
575 struct dentry *dentry, int err) in ceph_finish_lookup() argument
582 dentry, d_inode(dentry)); in ceph_finish_lookup()
583 if (d_really_is_positive(dentry)) { in ceph_finish_lookup()
584 d_drop(dentry); in ceph_finish_lookup()
587 d_add(dentry, NULL); in ceph_finish_lookup()
592 dentry = ERR_PTR(err); in ceph_finish_lookup()
593 else if (dentry != req->r_dentry) in ceph_finish_lookup()
594 dentry = dget(req->r_dentry); /* we got spliced */ in ceph_finish_lookup()
596 dentry = NULL; in ceph_finish_lookup()
597 return dentry; in ceph_finish_lookup()
600 static int is_root_ceph_dentry(struct inode *inode, struct dentry *dentry) in is_root_ceph_dentry() argument
603 strncmp(dentry->d_name.name, ".ceph", 5) == 0; in is_root_ceph_dentry()
610 static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, in ceph_lookup() argument
620 dir, dentry, dentry); in ceph_lookup()
622 if (dentry->d_name.len > NAME_MAX) in ceph_lookup()
625 err = ceph_init_dentry(dentry); in ceph_lookup()
630 if (d_really_is_negative(dentry)) { in ceph_lookup()
632 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_lookup()
636 if (strncmp(dentry->d_name.name, in ceph_lookup()
638 dentry->d_name.len) && in ceph_lookup()
639 !is_root_ceph_dentry(dir, dentry) && in ceph_lookup()
645 d_add(dentry, NULL); in ceph_lookup()
657 req->r_dentry = dget(dentry); in ceph_lookup()
663 err = ceph_handle_snapdir(req, dentry, err); in ceph_lookup()
664 dentry = ceph_finish_lookup(req, dentry, err); in ceph_lookup()
666 dout("lookup result=%p\n", dentry); in ceph_lookup()
667 return dentry; in ceph_lookup()
674 int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry) in ceph_handle_notrace_create() argument
676 struct dentry *result = ceph_lookup(dir, dentry, 0); in ceph_handle_notrace_create()
697 static int ceph_mknod(struct inode *dir, struct dentry *dentry, in ceph_mknod() argument
714 dir, dentry, mode, rdev); in ceph_mknod()
720 req->r_dentry = dget(dentry); in ceph_mknod()
733 err = ceph_handle_notrace_create(dir, dentry); in ceph_mknod()
737 ceph_init_inode_acls(d_inode(dentry), &acls); in ceph_mknod()
739 d_drop(dentry); in ceph_mknod()
744 static int ceph_create(struct inode *dir, struct dentry *dentry, umode_t mode, in ceph_create() argument
747 return ceph_mknod(dir, dentry, mode, 0); in ceph_create()
750 static int ceph_symlink(struct inode *dir, struct dentry *dentry, in ceph_symlink() argument
761 dout("symlink in dir %p dentry %p to '%s'\n", dir, dentry, dest); in ceph_symlink()
774 req->r_dentry = dget(dentry); in ceph_symlink()
780 err = ceph_handle_notrace_create(dir, dentry); in ceph_symlink()
784 d_drop(dentry); in ceph_symlink()
788 static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) in ceph_mkdir() argument
801 dentry, dentry); in ceph_mkdir()
803 dout("mkdir dir %p dn %p mode 0%ho\n", dir, dentry, mode); in ceph_mkdir()
820 req->r_dentry = dget(dentry); in ceph_mkdir()
834 err = ceph_handle_notrace_create(dir, dentry); in ceph_mkdir()
838 ceph_init_inode_acls(d_inode(dentry), &acls); in ceph_mkdir()
840 d_drop(dentry); in ceph_mkdir()
845 static int ceph_link(struct dentry *old_dentry, struct inode *dir, in ceph_link()
846 struct dentry *dentry) in ceph_link() argument
857 old_dentry, dentry); in ceph_link()
860 d_drop(dentry); in ceph_link()
863 req->r_dentry = dget(dentry); in ceph_link()
873 d_drop(dentry); in ceph_link()
876 d_instantiate(dentry, d_inode(old_dentry)); in ceph_link()
905 static int ceph_unlink(struct inode *dir, struct dentry *dentry) in ceph_unlink() argument
909 struct inode *inode = d_inode(dentry); in ceph_unlink()
916 dout("rmsnap dir %p '%pd' dn %p\n", dir, dentry, dentry); in ceph_unlink()
920 dir, dentry, inode); in ceph_unlink()
921 op = d_is_dir(dentry) ? in ceph_unlink()
930 req->r_dentry = dget(dentry); in ceph_unlink()
938 d_delete(dentry); in ceph_unlink()
944 static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry, in ceph_rename()
945 struct inode *new_dir, struct dentry *new_dentry) in ceph_rename()
1006 void ceph_invalidate_dentry_lease(struct dentry *dentry) in ceph_invalidate_dentry_lease() argument
1008 spin_lock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1009 dentry->d_time = jiffies; in ceph_invalidate_dentry_lease()
1010 ceph_dentry(dentry)->lease_shared_gen = 0; in ceph_invalidate_dentry_lease()
1011 spin_unlock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1018 static int dentry_lease_is_valid(struct dentry *dentry) in dentry_lease_is_valid() argument
1029 spin_lock(&dentry->d_lock); in dentry_lease_is_valid()
1030 di = ceph_dentry(dentry); in dentry_lease_is_valid()
1039 time_before(jiffies, dentry->d_time) && in dentry_lease_is_valid()
1045 dir = d_inode(dentry->d_parent); in dentry_lease_is_valid()
1053 spin_unlock(&dentry->d_lock); in dentry_lease_is_valid()
1056 ceph_mdsc_lease_send_msg(session, dir, dentry, in dentry_lease_is_valid()
1060 dout("dentry_lease_is_valid - dentry %p = %d\n", dentry, valid); in dentry_lease_is_valid()
1067 static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry) in dir_lease_is_valid() argument
1070 struct ceph_dentry_info *di = ceph_dentry(dentry); in dir_lease_is_valid()
1078 dir, (unsigned)ci->i_shared_gen, dentry, in dir_lease_is_valid()
1086 static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags) in ceph_d_revalidate() argument
1094 dout("d_revalidate %p '%pd' inode %p offset %lld\n", dentry, in ceph_d_revalidate()
1095 dentry, d_inode(dentry), ceph_dentry(dentry)->offset); in ceph_d_revalidate()
1097 dir = ceph_get_dentry_parent_inode(dentry); in ceph_d_revalidate()
1101 dout("d_revalidate %p '%pd' inode %p is SNAPPED\n", dentry, in ceph_d_revalidate()
1102 dentry, d_inode(dentry)); in ceph_d_revalidate()
1104 } else if (d_really_is_positive(dentry) && in ceph_d_revalidate()
1105 ceph_snap(d_inode(dentry)) == CEPH_SNAPDIR) { in ceph_d_revalidate()
1107 } else if (dentry_lease_is_valid(dentry) || in ceph_d_revalidate()
1108 dir_lease_is_valid(dir, dentry)) { in ceph_d_revalidate()
1109 if (d_really_is_positive(dentry)) in ceph_d_revalidate()
1110 valid = ceph_is_any_caps(d_inode(dentry)); in ceph_d_revalidate()
1115 dout("d_revalidate %p %s\n", dentry, valid ? "valid" : "invalid"); in ceph_d_revalidate()
1117 ceph_dentry_lru_touch(dentry); in ceph_d_revalidate()
1128 static void ceph_d_release(struct dentry *dentry) in ceph_d_release() argument
1130 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_d_release()
1132 dout("d_release %p\n", dentry); in ceph_d_release()
1133 ceph_dentry_lru_del(dentry); in ceph_d_release()
1137 dentry->d_fsdata = NULL; in ceph_d_release()
1140 static int ceph_snapdir_d_revalidate(struct dentry *dentry, in ceph_snapdir_d_revalidate() argument
1156 static void ceph_d_prune(struct dentry *dentry) in ceph_d_prune() argument
1158 dout("ceph_d_prune %p\n", dentry); in ceph_d_prune()
1161 if (IS_ROOT(dentry)) in ceph_d_prune()
1165 if (d_unhashed(dentry)) in ceph_d_prune()
1172 ceph_dir_clear_complete(d_inode(dentry->d_parent)); in ceph_d_prune()
1291 void ceph_dentry_lru_add(struct dentry *dn) in ceph_dentry_lru_add()
1304 void ceph_dentry_lru_touch(struct dentry *dn) in ceph_dentry_lru_touch()
1317 void ceph_dentry_lru_del(struct dentry *dn) in ceph_dentry_lru_del()
1334 unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) in ceph_dentry_hash()