Lines Matching refs:dentry

35 static int ceph_d_init(struct dentry *dentry)  in ceph_d_init()  argument
43 di->dentry = dentry; in ceph_d_init()
46 dentry->d_fsdata = di; in ceph_d_init()
47 ceph_dentry_lru_add(dentry); in ceph_d_init()
120 static struct dentry *
121 __dcache_find_get_entry(struct dentry *parent, u64 idx, in __dcache_find_get_entry()
125 struct dentry *dentry; in __dcache_find_get_entry() local
126 unsigned idx_mask = (PAGE_SIZE / sizeof(struct dentry *)) - 1; in __dcache_find_get_entry()
127 loff_t ptr_pos = idx * sizeof(struct dentry *); in __dcache_find_get_entry()
153 dentry = cache_ctl->dentries[cache_ctl->index]; in __dcache_find_get_entry()
155 dentry = NULL; in __dcache_find_get_entry()
157 if (dentry && !lockref_get_not_dead(&dentry->d_lockref)) in __dcache_find_get_entry()
158 dentry = NULL; in __dcache_find_get_entry()
160 return dentry ? : ERR_PTR(-EAGAIN); in __dcache_find_get_entry()
178 struct dentry *parent = file->f_path.dentry; in __dcache_readdir()
180 struct dentry *dentry, *last = NULL; in __dcache_readdir() local
190 u64 count = div_u64(i_size_read(dir), sizeof(struct dentry *)); in __dcache_readdir()
193 dentry = __dcache_find_get_entry(parent, idx + step, in __dcache_readdir()
195 if (!dentry) { in __dcache_readdir()
200 if (IS_ERR(dentry)) { in __dcache_readdir()
201 err = PTR_ERR(dentry); in __dcache_readdir()
204 di = ceph_dentry(dentry); in __dcache_readdir()
205 spin_lock(&dentry->d_lock); in __dcache_readdir()
212 spin_unlock(&dentry->d_lock); in __dcache_readdir()
213 dput(dentry); in __dcache_readdir()
222 dentry = __dcache_find_get_entry(parent, idx++, &cache_ctl); in __dcache_readdir()
223 if (!dentry) { in __dcache_readdir()
228 if (IS_ERR(dentry)) { in __dcache_readdir()
229 err = PTR_ERR(dentry); in __dcache_readdir()
233 spin_lock(&dentry->d_lock); in __dcache_readdir()
234 di = ceph_dentry(dentry); in __dcache_readdir()
235 if (d_unhashed(dentry) || in __dcache_readdir()
236 d_really_is_negative(dentry) || in __dcache_readdir()
238 spin_unlock(&dentry->d_lock); in __dcache_readdir()
239 dput(dentry); in __dcache_readdir()
246 spin_unlock(&dentry->d_lock); in __dcache_readdir()
250 dentry, dentry, d_inode(dentry)); in __dcache_readdir()
252 if (!dir_emit(ctx, dentry->d_name.name, in __dcache_readdir()
253 dentry->d_name.len, in __dcache_readdir()
254 ceph_translate_ino(dentry->d_sb, in __dcache_readdir()
255 d_inode(dentry)->i_ino), in __dcache_readdir()
256 d_inode(dentry)->i_mode >> 12)) { in __dcache_readdir()
257 dput(dentry); in __dcache_readdir()
265 last = dentry; in __dcache_readdir()
267 dput(dentry); in __dcache_readdir()
325 ino_t ino = parent_ino(file->f_path.dentry); in ceph_readdir()
412 req->r_dentry = dget(file->f_path.dentry); in ceph_readdir()
565 sizeof(struct dentry*)); in ceph_readdir()
662 struct dentry *dentry, int err) in ceph_handle_snapdir() argument
664 struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); in ceph_handle_snapdir()
665 struct inode *parent = d_inode(dentry->d_parent); /* we hold i_mutex */ in ceph_handle_snapdir()
670 strcmp(dentry->d_name.name, in ceph_handle_snapdir()
674 dentry, dentry, inode); in ceph_handle_snapdir()
675 BUG_ON(!d_unhashed(dentry)); in ceph_handle_snapdir()
676 d_add(dentry, inode); in ceph_handle_snapdir()
693 struct dentry *ceph_finish_lookup(struct ceph_mds_request *req, in ceph_finish_lookup()
694 struct dentry *dentry, int err) in ceph_finish_lookup() argument
701 dentry, d_inode(dentry)); in ceph_finish_lookup()
702 if (d_really_is_positive(dentry)) { in ceph_finish_lookup()
703 d_drop(dentry); in ceph_finish_lookup()
706 d_add(dentry, NULL); in ceph_finish_lookup()
711 dentry = ERR_PTR(err); in ceph_finish_lookup()
712 else if (dentry != req->r_dentry) in ceph_finish_lookup()
713 dentry = dget(req->r_dentry); /* we got spliced */ in ceph_finish_lookup()
715 dentry = NULL; in ceph_finish_lookup()
716 return dentry; in ceph_finish_lookup()
719 static bool is_root_ceph_dentry(struct inode *inode, struct dentry *dentry) in is_root_ceph_dentry() argument
722 strncmp(dentry->d_name.name, ".ceph", 5) == 0; in is_root_ceph_dentry()
729 static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, in ceph_lookup() argument
740 dir, dentry, dentry); in ceph_lookup()
742 if (dentry->d_name.len > NAME_MAX) in ceph_lookup()
746 if (d_really_is_negative(dentry)) { in ceph_lookup()
748 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_lookup()
752 if (strncmp(dentry->d_name.name, in ceph_lookup()
754 dentry->d_name.len) && in ceph_lookup()
755 !is_root_ceph_dentry(dir, dentry) && in ceph_lookup()
761 d_add(dentry, NULL); in ceph_lookup()
773 req->r_dentry = dget(dentry); in ceph_lookup()
784 err = ceph_handle_snapdir(req, dentry, err); in ceph_lookup()
785 dentry = ceph_finish_lookup(req, dentry, err); in ceph_lookup()
787 dout("lookup result=%p\n", dentry); in ceph_lookup()
788 return dentry; in ceph_lookup()
795 int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry) in ceph_handle_notrace_create() argument
797 struct dentry *result = ceph_lookup(dir, dentry, 0); in ceph_handle_notrace_create()
818 static int ceph_mknod(struct inode *dir, struct dentry *dentry, in ceph_mknod() argument
840 dir, dentry, mode, rdev); in ceph_mknod()
846 req->r_dentry = dget(dentry); in ceph_mknod()
860 err = ceph_handle_notrace_create(dir, dentry); in ceph_mknod()
864 ceph_init_inode_acls(d_inode(dentry), &acls); in ceph_mknod()
866 d_drop(dentry); in ceph_mknod()
871 static int ceph_create(struct inode *dir, struct dentry *dentry, umode_t mode, in ceph_create() argument
874 return ceph_mknod(dir, dentry, mode, 0); in ceph_create()
877 static int ceph_symlink(struct inode *dir, struct dentry *dentry, in ceph_symlink() argument
893 dout("symlink in dir %p dentry %p to '%s'\n", dir, dentry, dest); in ceph_symlink()
907 req->r_dentry = dget(dentry); in ceph_symlink()
913 err = ceph_handle_notrace_create(dir, dentry); in ceph_symlink()
917 d_drop(dentry); in ceph_symlink()
921 static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) in ceph_mkdir() argument
934 dentry, dentry); in ceph_mkdir()
936 dout("mkdir dir %p dn %p mode 0%ho\n", dir, dentry, mode); in ceph_mkdir()
959 req->r_dentry = dget(dentry); in ceph_mkdir()
974 err = ceph_handle_notrace_create(dir, dentry); in ceph_mkdir()
978 ceph_init_inode_acls(d_inode(dentry), &acls); in ceph_mkdir()
980 d_drop(dentry); in ceph_mkdir()
985 static int ceph_link(struct dentry *old_dentry, struct inode *dir, in ceph_link()
986 struct dentry *dentry) in ceph_link() argument
997 old_dentry, dentry); in ceph_link()
1000 d_drop(dentry); in ceph_link()
1003 req->r_dentry = dget(dentry); in ceph_link()
1014 d_drop(dentry); in ceph_link()
1017 d_instantiate(dentry, d_inode(old_dentry)); in ceph_link()
1026 static int ceph_unlink(struct inode *dir, struct dentry *dentry) in ceph_unlink() argument
1030 struct inode *inode = d_inode(dentry); in ceph_unlink()
1037 dout("rmsnap dir %p '%pd' dn %p\n", dir, dentry, dentry); in ceph_unlink()
1041 dir, dentry, inode); in ceph_unlink()
1042 op = d_is_dir(dentry) ? in ceph_unlink()
1051 req->r_dentry = dget(dentry); in ceph_unlink()
1060 d_delete(dentry); in ceph_unlink()
1066 static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry, in ceph_rename()
1067 struct inode *new_dir, struct dentry *new_dentry, in ceph_rename()
1130 void ceph_invalidate_dentry_lease(struct dentry *dentry) in ceph_invalidate_dentry_lease() argument
1132 spin_lock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1133 ceph_dentry(dentry)->time = jiffies; in ceph_invalidate_dentry_lease()
1134 ceph_dentry(dentry)->lease_shared_gen = 0; in ceph_invalidate_dentry_lease()
1135 spin_unlock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1142 static int dentry_lease_is_valid(struct dentry *dentry, unsigned int flags, in dentry_lease_is_valid() argument
1153 spin_lock(&dentry->d_lock); in dentry_lease_is_valid()
1154 di = ceph_dentry(dentry); in dentry_lease_is_valid()
1184 spin_unlock(&dentry->d_lock); in dentry_lease_is_valid()
1187 ceph_mdsc_lease_send_msg(session, dir, dentry, in dentry_lease_is_valid()
1191 dout("dentry_lease_is_valid - dentry %p = %d\n", dentry, valid); in dentry_lease_is_valid()
1198 static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry) in dir_lease_is_valid() argument
1201 struct ceph_dentry_info *di = ceph_dentry(dentry); in dir_lease_is_valid()
1210 dentry, (unsigned)di->lease_shared_gen, valid); in dir_lease_is_valid()
1217 static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags) in ceph_d_revalidate() argument
1220 struct dentry *parent; in ceph_d_revalidate()
1224 parent = READ_ONCE(dentry->d_parent); in ceph_d_revalidate()
1229 parent = dget_parent(dentry); in ceph_d_revalidate()
1233 dout("d_revalidate %p '%pd' inode %p offset %lld\n", dentry, in ceph_d_revalidate()
1234 dentry, d_inode(dentry), ceph_dentry(dentry)->offset); in ceph_d_revalidate()
1238 dout("d_revalidate %p '%pd' inode %p is SNAPPED\n", dentry, in ceph_d_revalidate()
1239 dentry, d_inode(dentry)); in ceph_d_revalidate()
1241 } else if (d_really_is_positive(dentry) && in ceph_d_revalidate()
1242 ceph_snap(d_inode(dentry)) == CEPH_SNAPDIR) { in ceph_d_revalidate()
1245 valid = dentry_lease_is_valid(dentry, flags, dir); in ceph_d_revalidate()
1248 if (valid || dir_lease_is_valid(dir, dentry)) { in ceph_d_revalidate()
1249 if (d_really_is_positive(dentry)) in ceph_d_revalidate()
1250 valid = ceph_is_any_caps(d_inode(dentry)); in ceph_d_revalidate()
1270 req->r_dentry = dget(dentry); in ceph_d_revalidate()
1282 if (d_really_is_positive(dentry) && in ceph_d_revalidate()
1283 d_inode(dentry) == req->r_target_inode) in ceph_d_revalidate()
1287 if (d_really_is_negative(dentry)) in ceph_d_revalidate()
1295 dentry, err); in ceph_d_revalidate()
1299 dout("d_revalidate %p %s\n", dentry, valid ? "valid" : "invalid"); in ceph_d_revalidate()
1301 ceph_dentry_lru_touch(dentry); in ceph_d_revalidate()
1314 static void ceph_d_release(struct dentry *dentry) in ceph_d_release() argument
1316 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_d_release()
1318 dout("d_release %p\n", dentry); in ceph_d_release()
1319 ceph_dentry_lru_del(dentry); in ceph_d_release()
1321 spin_lock(&dentry->d_lock); in ceph_d_release()
1322 dentry->d_fsdata = NULL; in ceph_d_release()
1323 spin_unlock(&dentry->d_lock); in ceph_d_release()
1336 static void ceph_d_prune(struct dentry *dentry) in ceph_d_prune() argument
1341 dout("ceph_d_prune %pd %p\n", dentry, dentry); in ceph_d_prune()
1344 if (IS_ROOT(dentry)) in ceph_d_prune()
1348 dir_ci = ceph_inode(d_inode(dentry->d_parent)); in ceph_d_prune()
1353 if (d_really_is_negative(dentry)) in ceph_d_prune()
1357 if (!d_unhashed(dentry)) { in ceph_d_prune()
1365 di = ceph_dentry(dentry); in ceph_d_prune()
1427 void ceph_dentry_lru_add(struct dentry *dn) in ceph_dentry_lru_add()
1440 void ceph_dentry_lru_touch(struct dentry *dn) in ceph_dentry_lru_touch()
1453 void ceph_dentry_lru_del(struct dentry *dn) in ceph_dentry_lru_del()
1470 unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) in ceph_dentry_hash()