• Home
  • Raw
  • Download

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_mutex */ 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
867 err = ceph_security_init_secctx(dentry, mode, &as_ctx); in ceph_mknod()
872 dir, dentry, mode, rdev); in ceph_mknod()
878 req->r_dentry = dget(dentry); in ceph_mknod()
893 err = ceph_handle_notrace_create(dir, dentry); in ceph_mknod()
897 ceph_init_inode_acls(d_inode(dentry), &as_ctx); in ceph_mknod()
899 d_drop(dentry); in ceph_mknod()
905 struct dentry *dentry, umode_t mode, bool excl) in ceph_create() argument
907 return ceph_mknod(mnt_userns, dir, dentry, mode, 0); in ceph_create()
911 struct dentry *dentry, const char *dest) in ceph_symlink() argument
926 err = ceph_security_init_secctx(dentry, S_IFLNK | 0777, &as_ctx); in ceph_symlink()
930 dout("symlink in dir %p dentry %p to '%s'\n", dir, dentry, dest); in ceph_symlink()
946 req->r_dentry = dget(dentry); in ceph_symlink()
956 err = ceph_handle_notrace_create(dir, dentry); in ceph_symlink()
960 d_drop(dentry); in ceph_symlink()
966 struct dentry *dentry, umode_t mode) in ceph_mkdir() argument
978 dentry, dentry); in ceph_mkdir()
980 dout("mkdir dir %p dn %p mode 0%ho\n", dir, dentry, mode); in ceph_mkdir()
996 err = ceph_security_init_secctx(dentry, mode, &as_ctx); in ceph_mkdir()
1006 req->r_dentry = dget(dentry); in ceph_mkdir()
1022 err = ceph_handle_notrace_create(dir, dentry); in ceph_mkdir()
1026 ceph_init_inode_acls(d_inode(dentry), &as_ctx); in ceph_mkdir()
1028 d_drop(dentry); in ceph_mkdir()
1033 static int ceph_link(struct dentry *old_dentry, struct inode *dir, in ceph_link()
1034 struct dentry *dentry) in ceph_link() argument
1044 old_dentry, dentry); in ceph_link()
1047 d_drop(dentry); in ceph_link()
1050 req->r_dentry = dget(dentry); in ceph_link()
1062 d_drop(dentry); in ceph_link()
1065 d_instantiate(dentry, d_inode(old_dentry)); in ceph_link()
1107 static int get_caps_for_async_unlink(struct inode *dir, struct dentry *dentry) in get_caps_for_async_unlink() argument
1124 spin_lock(&dentry->d_lock); in get_caps_for_async_unlink()
1125 di = ceph_dentry(dentry); in get_caps_for_async_unlink()
1133 spin_unlock(&dentry->d_lock); in get_caps_for_async_unlink()
1146 static int ceph_unlink(struct inode *dir, struct dentry *dentry) in ceph_unlink() argument
1150 struct inode *inode = d_inode(dentry); in ceph_unlink()
1158 dout("rmsnap dir %p '%pd' dn %p\n", dir, dentry, dentry); in ceph_unlink()
1162 dir, dentry, inode); in ceph_unlink()
1163 op = d_is_dir(dentry) ? in ceph_unlink()
1173 req->r_dentry = dget(dentry); in ceph_unlink()
1182 (req->r_dir_caps = get_caps_for_async_unlink(dir, dentry))) { in ceph_unlink()
1184 dentry->d_name.len, dentry->d_name.name, in ceph_unlink()
1188 req->r_old_inode = d_inode(dentry); in ceph_unlink()
1197 d_delete(dentry); in ceph_unlink()
1207 d_delete(dentry); in ceph_unlink()
1216 struct dentry *old_dentry, struct inode *new_dir, in ceph_rename()
1217 struct dentry *new_dentry, unsigned int flags) in ceph_rename()
1285 struct dentry *dn = di->dentry; in __ceph_dentry_lease_touch()
1319 struct dentry *dn = di->dentry; in __ceph_dentry_dir_lease_touch()
1357 mdsc = ceph_sb_to_client(di->dentry->d_sb)->mdsc; in __dentry_lease_unlist()
1380 int (*check)(struct dentry*, void*)) in __dentry_leases_walk() argument
1383 struct dentry *dentry, *last = NULL; in __dentry_leases_walk() local
1396 dentry = di->dentry; in __dentry_leases_walk()
1397 if (last == dentry) in __dentry_leases_walk()
1400 if (!spin_trylock(&dentry->d_lock)) in __dentry_leases_walk()
1403 if (__lockref_is_dead(&dentry->d_lockref)) { in __dentry_leases_walk()
1408 ret = check(dentry, lwc); in __dentry_leases_walk()
1413 last = dentry; in __dentry_leases_walk()
1418 if (dentry->d_lockref.count > 0) { in __dentry_leases_walk()
1427 dget_dlock(dentry); in __dentry_leases_walk()
1431 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1440 dentry = di->dentry; in __dentry_leases_walk()
1441 spin_lock(&dentry->d_lock); in __dentry_leases_walk()
1458 spin_unlock(&dentry->d_lock); in __dentry_leases_walk()
1460 dput(dentry); in __dentry_leases_walk()
1465 static int __dentry_lease_check(struct dentry *dentry, void *arg) in __dentry_lease_check() argument
1467 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dentry_lease_check()
1472 ret = __dir_lease_try_check(dentry); in __dentry_lease_check()
1480 static int __dir_lease_check(struct dentry *dentry, void *arg) in __dir_lease_check() argument
1483 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dir_lease_check()
1485 int ret = __dir_lease_try_check(dentry); in __dir_lease_check()
1496 if (dentry->d_lockref.count > 0 || in __dir_lease_check()
1541 void ceph_invalidate_dentry_lease(struct dentry *dentry) in ceph_invalidate_dentry_lease() argument
1543 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_invalidate_dentry_lease()
1544 spin_lock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1549 spin_unlock(&dentry->d_lock); in ceph_invalidate_dentry_lease()
1580 static int dentry_lease_is_valid(struct dentry *dentry, unsigned int flags) in dentry_lease_is_valid() argument
1587 spin_lock(&dentry->d_lock); in dentry_lease_is_valid()
1588 di = ceph_dentry(dentry); in dentry_lease_is_valid()
1609 spin_unlock(&dentry->d_lock); in dentry_lease_is_valid()
1612 ceph_mdsc_lease_send_msg(session, dentry, in dentry_lease_is_valid()
1616 dout("dentry_lease_is_valid - dentry %p = %d\n", dentry, valid); in dentry_lease_is_valid()
1623 static int __dir_lease_try_check(const struct dentry *dentry) in __dir_lease_try_check() argument
1625 struct ceph_dentry_info *di = ceph_dentry(dentry); in __dir_lease_try_check()
1632 if (IS_ROOT(dentry)) in __dir_lease_try_check()
1635 dir = d_inode(dentry->d_parent); in __dir_lease_try_check()
1655 static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry, in dir_lease_is_valid() argument
1671 spin_lock(&dentry->d_lock); in dir_lease_is_valid()
1672 di = ceph_dentry(dentry); in dir_lease_is_valid()
1673 if (dir == d_inode(dentry->d_parent) && in dir_lease_is_valid()
1678 spin_unlock(&dentry->d_lock); in dir_lease_is_valid()
1681 dir, (unsigned)atomic_read(&ci->i_shared_gen), dentry, valid); in dir_lease_is_valid()
1688 static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags) in ceph_d_revalidate() argument
1691 struct dentry *parent; in ceph_d_revalidate()
1696 parent = READ_ONCE(dentry->d_parent); in ceph_d_revalidate()
1700 inode = d_inode_rcu(dentry); in ceph_d_revalidate()
1702 parent = dget_parent(dentry); in ceph_d_revalidate()
1704 inode = d_inode(dentry); in ceph_d_revalidate()
1707 dout("d_revalidate %p '%pd' inode %p offset 0x%llx\n", dentry, in ceph_d_revalidate()
1708 dentry, inode, ceph_dentry(dentry)->offset); in ceph_d_revalidate()
1714 dout("d_revalidate %p '%pd' inode %p is SNAPPED\n", dentry, in ceph_d_revalidate()
1715 dentry, inode); in ceph_d_revalidate()
1720 valid = dentry_lease_is_valid(dentry, flags); in ceph_d_revalidate()
1723 if (valid || dir_lease_is_valid(dir, dentry, mdsc)) { in ceph_d_revalidate()
1745 req->r_dentry = dget(dentry); in ceph_d_revalidate()
1758 if (d_really_is_positive(dentry) && in ceph_d_revalidate()
1759 d_inode(dentry) == req->r_target_inode) in ceph_d_revalidate()
1763 if (d_really_is_negative(dentry)) in ceph_d_revalidate()
1771 dentry, err); in ceph_d_revalidate()
1777 dout("d_revalidate %p %s\n", dentry, valid ? "valid" : "invalid"); in ceph_d_revalidate()
1791 static int ceph_d_delete(const struct dentry *dentry) in ceph_d_delete() argument
1796 if (d_really_is_negative(dentry)) in ceph_d_delete()
1798 if (ceph_snap(d_inode(dentry)) != CEPH_NOSNAP) in ceph_d_delete()
1801 di = ceph_dentry(dentry); in ceph_d_delete()
1805 if (__dir_lease_try_check(dentry)) in ceph_d_delete()
1814 static void ceph_d_release(struct dentry *dentry) in ceph_d_release() argument
1816 struct ceph_dentry_info *di = ceph_dentry(dentry); in ceph_d_release()
1817 struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); in ceph_d_release()
1819 dout("d_release %p\n", dentry); in ceph_d_release()
1823 spin_lock(&dentry->d_lock); in ceph_d_release()
1825 dentry->d_fsdata = NULL; in ceph_d_release()
1826 spin_unlock(&dentry->d_lock); in ceph_d_release()
1838 static void ceph_d_prune(struct dentry *dentry) in ceph_d_prune() argument
1843 dout("ceph_d_prune %pd %p\n", dentry, dentry); in ceph_d_prune()
1846 if (IS_ROOT(dentry)) in ceph_d_prune()
1850 dir_ci = ceph_inode(d_inode(dentry->d_parent)); in ceph_d_prune()
1855 if (d_really_is_negative(dentry)) in ceph_d_prune()
1859 if (!d_unhashed(dentry)) { in ceph_d_prune()
1867 di = ceph_dentry(dentry); in ceph_d_prune()
1930 unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) in ceph_dentry_hash()