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
41 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dentry->d_sb); in ceph_d_init()
47 di->dentry = dentry; in ceph_d_init()
50 dentry->d_fsdata = di; in ceph_d_init()
127 static struct dentry *
128 __dcache_find_get_entry(struct dentry *parent, u64 idx, in __dcache_find_get_entry()
132 struct dentry *dentry; in __dcache_find_get_entry() local
133 unsigned idx_mask = (PAGE_SIZE / sizeof(struct dentry *)) - 1; in __dcache_find_get_entry()
134 loff_t ptr_pos = idx * sizeof(struct dentry *); in __dcache_find_get_entry()
160 dentry = cache_ctl->dentries[cache_ctl->index]; in __dcache_find_get_entry()
162 dentry = NULL; in __dcache_find_get_entry()
164 if (dentry && !lockref_get_not_dead(&dentry->d_lockref)) in __dcache_find_get_entry()
165 dentry = NULL; in __dcache_find_get_entry()
167 return dentry ? : ERR_PTR(-EAGAIN); in __dcache_find_get_entry()
185 struct dentry *parent = file->f_path.dentry; in __dcache_readdir()
187 struct dentry *dentry, *last = NULL; in __dcache_readdir() local
197 u64 count = div_u64(i_size_read(dir), sizeof(struct dentry *)); in __dcache_readdir()
200 dentry = __dcache_find_get_entry(parent, idx + step, in __dcache_readdir()
202 if (!dentry) { in __dcache_readdir()
207 if (IS_ERR(dentry)) { in __dcache_readdir()
208 err = PTR_ERR(dentry); in __dcache_readdir()
211 di = ceph_dentry(dentry); in __dcache_readdir()
212 spin_lock(&dentry->d_lock); in __dcache_readdir()
219 spin_unlock(&dentry->d_lock); in __dcache_readdir()
220 dput(dentry); in __dcache_readdir()
229 dentry = __dcache_find_get_entry(parent, idx++, &cache_ctl); in __dcache_readdir()
230 if (!dentry) { in __dcache_readdir()
235 if (IS_ERR(dentry)) { in __dcache_readdir()
236 err = PTR_ERR(dentry); in __dcache_readdir()
240 spin_lock(&dentry->d_lock); in __dcache_readdir()
241 di = ceph_dentry(dentry); in __dcache_readdir()
242 if (d_unhashed(dentry) || in __dcache_readdir()
243 d_really_is_negative(dentry) || in __dcache_readdir()
245 spin_unlock(&dentry->d_lock); in __dcache_readdir()
246 dput(dentry); in __dcache_readdir()
254 spin_unlock(&dentry->d_lock); in __dcache_readdir()
258 dentry, dentry, d_inode(dentry)); in __dcache_readdir()
260 if (!dir_emit(ctx, dentry->d_name.name, in __dcache_readdir()
261 dentry->d_name.len, ceph_present_inode(d_inode(dentry)), in __dcache_readdir()
262 d_inode(dentry)->i_mode >> 12)) { in __dcache_readdir()
263 dput(dentry); in __dcache_readdir()
271 last = dentry; in __dcache_readdir()
273 dput(dentry); in __dcache_readdir()
331 struct dentry *dentry = file->f_path.dentry; in ceph_readdir() local
333 spin_lock(&dentry->d_lock); in ceph_readdir()
334 ino = ceph_present_inode(dentry->d_parent->d_inode); in ceph_readdir()
335 spin_unlock(&dentry->d_lock); in ceph_readdir()
425 req->r_dentry = dget(file->f_path.dentry); in ceph_readdir()
581 sizeof(struct dentry*)); in ceph_readdir()
679 struct dentry *ceph_handle_snapdir(struct ceph_mds_request *req, in ceph_handle_snapdir()
680 struct dentry *dentry) in ceph_handle_snapdir() argument
682 struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); in ceph_handle_snapdir()
683 struct inode *parent = d_inode(dentry->d_parent); /* we hold i_rwsem */ in ceph_handle_snapdir()
687 strcmp(dentry->d_name.name, fsc->mount_options->snapdir_name) == 0) { in ceph_handle_snapdir()
688 struct dentry *res; in ceph_handle_snapdir()
691 res = d_splice_alias(inode, dentry); in ceph_handle_snapdir()
693 dentry, dentry, inode, res); in ceph_handle_snapdir()
695 dentry = res; in ceph_handle_snapdir()
697 return dentry; in ceph_handle_snapdir()
711 struct dentry *ceph_finish_lookup(struct ceph_mds_request *req, in ceph_finish_lookup()
712 struct dentry *dentry, int err) in ceph_finish_lookup() argument
719 dentry, d_inode(dentry)); in ceph_finish_lookup()
720 if (d_really_is_positive(dentry)) { in ceph_finish_lookup()
721 d_drop(dentry); in ceph_finish_lookup()
724 d_add(dentry, NULL); in ceph_finish_lookup()
729 dentry = ERR_PTR(err); in ceph_finish_lookup()
730 else if (dentry != req->r_dentry) in ceph_finish_lookup()
731 dentry = dget(req->r_dentry); /* we got spliced */ in ceph_finish_lookup()
733 dentry = NULL; in ceph_finish_lookup()
734 return dentry; in ceph_finish_lookup()
737 static bool is_root_ceph_dentry(struct inode *inode, struct dentry *dentry) in is_root_ceph_dentry() argument
740 strncmp(dentry->d_name.name, ".ceph", 5) == 0; in is_root_ceph_dentry()
747 static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, in ceph_lookup() argument
758 dir, dentry, dentry); in ceph_lookup()
760 if (dentry->d_name.len > NAME_MAX) in ceph_lookup()
764 if (d_really_is_negative(dentry)) { in ceph_lookup()
766 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_lookup()
770 if (strncmp(dentry->d_name.name, in ceph_lookup()
772 dentry->d_name.len) && in ceph_lookup()
773 !is_root_ceph_dentry(dir, dentry) && in ceph_lookup()
780 d_add(dentry, NULL); in ceph_lookup()
792 req->r_dentry = dget(dentry); in ceph_lookup()
805 struct dentry *res; in ceph_lookup()
807 res = ceph_handle_snapdir(req, dentry); in ceph_lookup()
811 dentry = res; in ceph_lookup()
815 dentry = ceph_finish_lookup(req, dentry, err); in ceph_lookup()
817 dout("lookup result=%p\n", dentry); in ceph_lookup()
818 return dentry; in ceph_lookup()
825 int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry) in ceph_handle_notrace_create() argument
827 struct dentry *result = ceph_lookup(dir, dentry, 0); in ceph_handle_notrace_create()
849 struct dentry *dentry, umode_t mode, dev_t rdev) in ceph_mknod() argument
859 err = ceph_wait_on_conflict_unlink(dentry); in ceph_mknod()
871 err = ceph_security_init_secctx(dentry, mode, &as_ctx); in ceph_mknod()
876 dir, dentry, mode, rdev); in ceph_mknod()
882 req->r_dentry = dget(dentry); in ceph_mknod()
897 err = ceph_handle_notrace_create(dir, dentry); in ceph_mknod()
901 ceph_init_inode_acls(d_inode(dentry), &as_ctx); in ceph_mknod()
903 d_drop(dentry); in ceph_mknod()
909 struct dentry *dentry, umode_t mode, bool excl) in ceph_create() argument
911 return ceph_mknod(mnt_userns, dir, dentry, mode, 0); in ceph_create()
915 struct dentry *dentry, const char *dest) in ceph_symlink() argument
925 err = ceph_wait_on_conflict_unlink(dentry); in ceph_symlink()
934 err = ceph_security_init_secctx(dentry, S_IFLNK | 0777, &as_ctx); in ceph_symlink()
938 dout("symlink in dir %p dentry %p to '%s'\n", dir, dentry, dest); in ceph_symlink()
954 req->r_dentry = dget(dentry); in ceph_symlink()
964 err = ceph_handle_notrace_create(dir, dentry); in ceph_symlink()
968 d_drop(dentry); in ceph_symlink()
974 struct dentry *dentry, umode_t mode) in ceph_mkdir() argument
982 err = ceph_wait_on_conflict_unlink(dentry); in ceph_mkdir()
990 dentry, dentry); in ceph_mkdir()
992 dout("mkdir dir %p dn %p mode 0%ho\n", dir, dentry, mode); in ceph_mkdir()
1009 err = ceph_security_init_secctx(dentry, mode, &as_ctx); in ceph_mkdir()
1019 req->r_dentry = dget(dentry); in ceph_mkdir()
1035 err = ceph_handle_notrace_create(dir, dentry); in ceph_mkdir()
1039 ceph_init_inode_acls(d_inode(dentry), &as_ctx); in ceph_mkdir()
1041 d_drop(dentry); in ceph_mkdir()
1046 static int ceph_link(struct dentry *old_dentry, struct inode *dir, in ceph_link()
1047 struct dentry *dentry) in ceph_link() argument
1053 err = ceph_wait_on_conflict_unlink(dentry); in ceph_link()
1061 old_dentry, dentry); in ceph_link()
1064 d_drop(dentry); in ceph_link()
1067 req->r_dentry = dget(dentry); in ceph_link()
1079 d_drop(dentry); in ceph_link()
1082 d_instantiate(dentry, d_inode(old_dentry)); in ceph_link()
1091 struct dentry *dentry = req->r_dentry; in ceph_async_unlink_cb() local
1092 struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); in ceph_async_unlink_cb()
1093 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_async_unlink_cb()
1099 __func__, dentry, dentry); in ceph_async_unlink_cb()
1105 spin_lock(&dentry->d_lock); in ceph_async_unlink_cb()
1108 spin_unlock(&dentry->d_lock); in ceph_async_unlink_cb()
1119 char *path = ceph_mdsc_build_path(dentry, &pathlen, in ceph_async_unlink_cb()
1127 if (!d_unhashed(dentry)) in ceph_async_unlink_cb()
1128 d_drop(dentry); in ceph_async_unlink_cb()
1142 static int get_caps_for_async_unlink(struct inode *dir, struct dentry *dentry) in get_caps_for_async_unlink() argument
1159 spin_lock(&dentry->d_lock); in get_caps_for_async_unlink()
1160 di = ceph_dentry(dentry); in get_caps_for_async_unlink()
1168 spin_unlock(&dentry->d_lock); in get_caps_for_async_unlink()
1181 static int ceph_unlink(struct inode *dir, struct dentry *dentry) in ceph_unlink() argument
1185 struct inode *inode = d_inode(dentry); in ceph_unlink()
1193 dout("rmsnap dir %p '%pd' dn %p\n", dir, dentry, dentry); in ceph_unlink()
1197 dir, dentry, inode); in ceph_unlink()
1198 op = d_is_dir(dentry) ? in ceph_unlink()
1208 req->r_dentry = dget(dentry); in ceph_unlink()
1217 (req->r_dir_caps = get_caps_for_async_unlink(dir, dentry))) { in ceph_unlink()
1218 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_unlink()
1221 dentry->d_name.len, dentry->d_name.name, in ceph_unlink()
1225 req->r_old_inode = d_inode(dentry); in ceph_unlink()
1228 spin_lock(&dentry->d_lock); in ceph_unlink()
1230 spin_unlock(&dentry->d_lock); in ceph_unlink()
1234 dentry->d_name.hash); in ceph_unlink()
1244 d_delete(dentry); in ceph_unlink()
1250 spin_lock(&dentry->d_lock); in ceph_unlink()
1252 spin_unlock(&dentry->d_lock); in ceph_unlink()
1264 d_delete(dentry); in ceph_unlink()
1273 struct dentry *old_dentry, struct inode *new_dir, in ceph_rename()
1274 struct dentry *new_dentry, unsigned int flags) in ceph_rename()
1346 struct dentry *dn = di->dentry; in __ceph_dentry_lease_touch()
1380 struct dentry *dn = di->dentry; in __ceph_dentry_dir_lease_touch()
1418 mdsc = ceph_sb_to_client(di->dentry->d_sb)->mdsc; in __dentry_lease_unlist()
1441 int (*check)(struct dentry*, void*)) in __dentry_leases_walk() argument
1444 struct dentry *dentry, *last = NULL; in __dentry_leases_walk() local
1457 dentry = di->dentry; in __dentry_leases_walk()
1458 if (last == dentry) in __dentry_leases_walk()
1461 if (!spin_trylock(&dentry->d_lock)) in __dentry_leases_walk()
1464 if (__lockref_is_dead(&dentry->d_lockref)) { in __dentry_leases_walk()
1469 ret = check(dentry, lwc); in __dentry_leases_walk()
1474 last = dentry; in __dentry_leases_walk()
1479 if (dentry->d_lockref.count > 0) { in __dentry_leases_walk()
1488 dget_dlock(dentry); in __dentry_leases_walk()
1492 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1501 dentry = di->dentry; in __dentry_leases_walk()
1502 spin_lock(&dentry->d_lock); in __dentry_leases_walk()
1519 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1521 dput(dentry); in __dentry_leases_walk()
1526 static int __dentry_lease_check(struct dentry *dentry, void *arg) in __dentry_lease_check() argument
1528 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dentry_lease_check()
1533 ret = __dir_lease_try_check(dentry); in __dentry_lease_check()
1541 static int __dir_lease_check(struct dentry *dentry, void *arg) in __dir_lease_check() argument
1544 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dir_lease_check()
1546 int ret = __dir_lease_try_check(dentry); in __dir_lease_check()
1557 if (dentry->d_lockref.count > 0 || in __dir_lease_check()
1602 void ceph_invalidate_dentry_lease(struct dentry *dentry) in ceph_invalidate_dentry_lease() argument
1604 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_invalidate_dentry_lease()
1605 spin_lock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1610 spin_unlock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1641 static int dentry_lease_is_valid(struct dentry *dentry, unsigned int flags) in dentry_lease_is_valid() argument
1648 spin_lock(&dentry->d_lock); in dentry_lease_is_valid()
1649 di = ceph_dentry(dentry); in dentry_lease_is_valid()
1670 spin_unlock(&dentry->d_lock); in dentry_lease_is_valid()
1673 ceph_mdsc_lease_send_msg(session, dentry, in dentry_lease_is_valid()
1677 dout("dentry_lease_is_valid - dentry %p = %d\n", dentry, valid); in dentry_lease_is_valid()
1684 static int __dir_lease_try_check(const struct dentry *dentry) in __dir_lease_try_check() argument
1686 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dir_lease_try_check()
1693 if (IS_ROOT(dentry)) in __dir_lease_try_check()
1696 dir = d_inode(dentry->d_parent); in __dir_lease_try_check()
1716 static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry, in dir_lease_is_valid() argument
1732 spin_lock(&dentry->d_lock); in dir_lease_is_valid()
1733 di = ceph_dentry(dentry); in dir_lease_is_valid()
1734 if (dir == d_inode(dentry->d_parent) && in dir_lease_is_valid()
1739 spin_unlock(&dentry->d_lock); in dir_lease_is_valid()
1742 dir, (unsigned)atomic_read(&ci->i_shared_gen), dentry, valid); in dir_lease_is_valid()
1749 static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags) in ceph_d_revalidate() argument
1752 struct dentry *parent; in ceph_d_revalidate()
1757 parent = READ_ONCE(dentry->d_parent); in ceph_d_revalidate()
1761 inode = d_inode_rcu(dentry); in ceph_d_revalidate()
1763 parent = dget_parent(dentry); in ceph_d_revalidate()
1765 inode = d_inode(dentry); in ceph_d_revalidate()
1768 dout("d_revalidate %p '%pd' inode %p offset 0x%llx\n", dentry, in ceph_d_revalidate()
1769 dentry, inode, ceph_dentry(dentry)->offset); in ceph_d_revalidate()
1775 dout("d_revalidate %p '%pd' inode %p is SNAPPED\n", dentry, in ceph_d_revalidate()
1776 dentry, inode); in ceph_d_revalidate()
1781 valid = dentry_lease_is_valid(dentry, flags); in ceph_d_revalidate()
1784 if (valid || dir_lease_is_valid(dir, dentry, mdsc)) { in ceph_d_revalidate()
1806 req->r_dentry = dget(dentry); in ceph_d_revalidate()
1819 if (d_really_is_positive(dentry) && in ceph_d_revalidate()
1820 d_inode(dentry) == req->r_target_inode) in ceph_d_revalidate()
1824 if (d_really_is_negative(dentry)) in ceph_d_revalidate()
1832 dentry, err); in ceph_d_revalidate()
1838 dout("d_revalidate %p %s\n", dentry, valid ? "valid" : "invalid"); in ceph_d_revalidate()
1852 static int ceph_d_delete(const struct dentry *dentry) in ceph_d_delete() argument
1857 if (d_really_is_negative(dentry)) in ceph_d_delete()
1859 if (ceph_snap(d_inode(dentry)) != CEPH_NOSNAP) in ceph_d_delete()
1862 di = ceph_dentry(dentry); in ceph_d_delete()
1866 if (__dir_lease_try_check(dentry)) in ceph_d_delete()
1875 static void ceph_d_release(struct dentry *dentry) in ceph_d_release() argument
1877 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_d_release()
1878 struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); in ceph_d_release()
1880 dout("d_release %p\n", dentry); in ceph_d_release()
1884 spin_lock(&dentry->d_lock); in ceph_d_release()
1886 dentry->d_fsdata = NULL; in ceph_d_release()
1887 spin_unlock(&dentry->d_lock); in ceph_d_release()
1899 static void ceph_d_prune(struct dentry *dentry) in ceph_d_prune() argument
1904 dout("ceph_d_prune %pd %p\n", dentry, dentry); in ceph_d_prune()
1907 if (IS_ROOT(dentry)) in ceph_d_prune()
1911 dir_ci = ceph_inode(d_inode(dentry->d_parent)); in ceph_d_prune()
1916 if (d_really_is_negative(dentry)) in ceph_d_prune()
1920 if (!d_unhashed(dentry)) { in ceph_d_prune()
1928 di = ceph_dentry(dentry); in ceph_d_prune()
1991 unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) in ceph_dentry_hash()