Lines Matching refs:dentry
18 int ovl_want_write(struct dentry *dentry) in ovl_want_write() argument
20 struct ovl_fs *ofs = dentry->d_sb->s_fs_info; in ovl_want_write()
24 void ovl_drop_write(struct dentry *dentry) in ovl_drop_write() argument
26 struct ovl_fs *ofs = dentry->d_sb->s_fs_info; in ovl_drop_write()
30 struct dentry *ovl_workdir(struct dentry *dentry) in ovl_workdir() argument
32 struct ovl_fs *ofs = dentry->d_sb->s_fs_info; in ovl_workdir()
67 struct dentry *ovl_indexdir(struct super_block *sb) in ovl_indexdir()
103 bool ovl_dentry_remote(struct dentry *dentry) in ovl_dentry_remote() argument
105 return dentry->d_flags & OVL_D_REVALIDATE; in ovl_dentry_remote()
108 void ovl_dentry_update_reval(struct dentry *dentry, struct dentry *realdentry) in ovl_dentry_update_reval() argument
113 spin_lock(&dentry->d_lock); in ovl_dentry_update_reval()
114 dentry->d_flags |= realdentry->d_flags & OVL_D_REVALIDATE; in ovl_dentry_update_reval()
115 spin_unlock(&dentry->d_lock); in ovl_dentry_update_reval()
118 void ovl_dentry_init_reval(struct dentry *dentry, struct dentry *upperdentry) in ovl_dentry_init_reval() argument
120 return ovl_dentry_init_flags(dentry, upperdentry, OVL_D_REVALIDATE); in ovl_dentry_init_reval()
123 void ovl_dentry_init_flags(struct dentry *dentry, struct dentry *upperdentry, in ovl_dentry_init_flags() argument
126 struct ovl_entry *oe = OVL_E(dentry); in ovl_dentry_init_flags()
132 flags |= oe->lowerstack[i].dentry->d_flags; in ovl_dentry_init_flags()
134 spin_lock(&dentry->d_lock); in ovl_dentry_init_flags()
135 dentry->d_flags &= ~mask; in ovl_dentry_init_flags()
136 dentry->d_flags |= flags & mask; in ovl_dentry_init_flags()
137 spin_unlock(&dentry->d_lock); in ovl_dentry_init_flags()
140 bool ovl_dentry_weird(struct dentry *dentry) in ovl_dentry_weird() argument
142 return dentry->d_flags & (DCACHE_NEED_AUTOMOUNT | in ovl_dentry_weird()
148 enum ovl_path_type ovl_path_type(struct dentry *dentry) in ovl_path_type() argument
150 struct ovl_entry *oe = dentry->d_fsdata; in ovl_path_type()
153 if (ovl_dentry_upper(dentry)) { in ovl_path_type()
160 if (ovl_test_flag(OVL_CONST_INO, d_inode(dentry))) in ovl_path_type()
162 if (d_is_dir(dentry) || in ovl_path_type()
163 !ovl_has_upperdata(d_inode(dentry))) in ovl_path_type()
173 void ovl_path_upper(struct dentry *dentry, struct path *path) in ovl_path_upper() argument
175 struct ovl_fs *ofs = dentry->d_sb->s_fs_info; in ovl_path_upper()
178 path->dentry = ovl_dentry_upper(dentry); in ovl_path_upper()
181 void ovl_path_lower(struct dentry *dentry, struct path *path) in ovl_path_lower() argument
183 struct ovl_entry *oe = dentry->d_fsdata; in ovl_path_lower()
187 path->dentry = oe->lowerstack[0].dentry; in ovl_path_lower()
193 void ovl_path_lowerdata(struct dentry *dentry, struct path *path) in ovl_path_lowerdata() argument
195 struct ovl_entry *oe = dentry->d_fsdata; in ovl_path_lowerdata()
199 path->dentry = oe->lowerstack[oe->numlower - 1].dentry; in ovl_path_lowerdata()
205 enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path) in ovl_path_real() argument
207 enum ovl_path_type type = ovl_path_type(dentry); in ovl_path_real()
210 ovl_path_lower(dentry, path); in ovl_path_real()
212 ovl_path_upper(dentry, path); in ovl_path_real()
217 struct dentry *ovl_dentry_upper(struct dentry *dentry) in ovl_dentry_upper() argument
219 return ovl_upperdentry_dereference(OVL_I(d_inode(dentry))); in ovl_dentry_upper()
222 struct dentry *ovl_dentry_lower(struct dentry *dentry) in ovl_dentry_lower() argument
224 struct ovl_entry *oe = dentry->d_fsdata; in ovl_dentry_lower()
226 return oe->numlower ? oe->lowerstack[0].dentry : NULL; in ovl_dentry_lower()
229 const struct ovl_layer *ovl_layer_lower(struct dentry *dentry) in ovl_layer_lower() argument
231 struct ovl_entry *oe = dentry->d_fsdata; in ovl_layer_lower()
242 struct dentry *ovl_dentry_lowerdata(struct dentry *dentry) in ovl_dentry_lowerdata() argument
244 struct ovl_entry *oe = dentry->d_fsdata; in ovl_dentry_lowerdata()
246 return oe->numlower ? oe->lowerstack[oe->numlower - 1].dentry : NULL; in ovl_dentry_lowerdata()
249 struct dentry *ovl_dentry_real(struct dentry *dentry) in ovl_dentry_real() argument
251 return ovl_dentry_upper(dentry) ?: ovl_dentry_lower(dentry); in ovl_dentry_real()
254 struct dentry *ovl_i_dentry_upper(struct inode *inode) in ovl_i_dentry_upper()
261 struct dentry *upperdentry = ovl_i_dentry_upper(inode); in ovl_inode_upper()
307 void ovl_dentry_set_flag(unsigned long flag, struct dentry *dentry) in ovl_dentry_set_flag() argument
309 set_bit(flag, &OVL_E(dentry)->flags); in ovl_dentry_set_flag()
312 void ovl_dentry_clear_flag(unsigned long flag, struct dentry *dentry) in ovl_dentry_clear_flag() argument
314 clear_bit(flag, &OVL_E(dentry)->flags); in ovl_dentry_clear_flag()
317 bool ovl_dentry_test_flag(unsigned long flag, struct dentry *dentry) in ovl_dentry_test_flag() argument
319 return test_bit(flag, &OVL_E(dentry)->flags); in ovl_dentry_test_flag()
322 bool ovl_dentry_is_opaque(struct dentry *dentry) in ovl_dentry_is_opaque() argument
324 return ovl_dentry_test_flag(OVL_E_OPAQUE, dentry); in ovl_dentry_is_opaque()
327 bool ovl_dentry_is_whiteout(struct dentry *dentry) in ovl_dentry_is_whiteout() argument
329 return !dentry->d_inode && ovl_dentry_is_opaque(dentry); in ovl_dentry_is_whiteout()
332 void ovl_dentry_set_opaque(struct dentry *dentry) in ovl_dentry_set_opaque() argument
334 ovl_dentry_set_flag(OVL_E_OPAQUE, dentry); in ovl_dentry_set_opaque()
343 bool ovl_dentry_has_upper_alias(struct dentry *dentry) in ovl_dentry_has_upper_alias() argument
345 return ovl_dentry_test_flag(OVL_E_UPPER_ALIAS, dentry); in ovl_dentry_has_upper_alias()
348 void ovl_dentry_set_upper_alias(struct dentry *dentry) in ovl_dentry_set_upper_alias() argument
350 ovl_dentry_set_flag(OVL_E_UPPER_ALIAS, dentry); in ovl_dentry_set_upper_alias()
393 bool ovl_dentry_needs_data_copy_up_locked(struct dentry *dentry, int flags) in ovl_dentry_needs_data_copy_up_locked() argument
398 return !ovl_test_flag(OVL_UPPERDATA, d_inode(dentry)); in ovl_dentry_needs_data_copy_up_locked()
401 bool ovl_dentry_needs_data_copy_up(struct dentry *dentry, int flags) in ovl_dentry_needs_data_copy_up() argument
406 return !ovl_has_upperdata(d_inode(dentry)); in ovl_dentry_needs_data_copy_up()
416 const char *ovl_dentry_get_redirect(struct dentry *dentry) in ovl_dentry_get_redirect() argument
418 return OVL_I(d_inode(dentry))->redirect; in ovl_dentry_get_redirect()
421 void ovl_dentry_set_redirect(struct dentry *dentry, const char *redirect) in ovl_dentry_set_redirect() argument
423 struct ovl_inode *oi = OVL_I(d_inode(dentry)); in ovl_dentry_set_redirect()
429 void ovl_inode_update(struct inode *inode, struct dentry *upperdentry) in ovl_inode_update()
446 static void ovl_dir_version_inc(struct dentry *dentry, bool impurity) in ovl_dir_version_inc() argument
448 struct inode *inode = d_inode(dentry); in ovl_dir_version_inc()
451 WARN_ON(!d_is_dir(dentry)); in ovl_dir_version_inc()
459 if (!ovl_dir_is_real(dentry) || impurity) in ovl_dir_version_inc()
463 void ovl_dir_modified(struct dentry *dentry, bool impurity) in ovl_dir_modified() argument
466 ovl_copyattr(d_inode(ovl_dentry_upper(dentry)), d_inode(dentry)); in ovl_dir_modified()
468 ovl_dir_version_inc(dentry, impurity); in ovl_dir_modified()
471 u64 ovl_dentry_version_get(struct dentry *dentry) in ovl_dentry_version_get() argument
473 struct inode *inode = d_inode(dentry); in ovl_dentry_version_get()
479 bool ovl_is_whiteout(struct dentry *dentry) in ovl_is_whiteout() argument
481 struct inode *inode = dentry->d_inode; in ovl_is_whiteout()
488 struct inode *inode = d_inode(path->dentry); in ovl_path_open()
517 static bool ovl_already_copied_up_locked(struct dentry *dentry, int flags) in ovl_already_copied_up_locked() argument
519 bool disconnected = dentry->d_flags & DCACHE_DISCONNECTED; in ovl_already_copied_up_locked()
521 if (ovl_dentry_upper(dentry) && in ovl_already_copied_up_locked()
522 (ovl_dentry_has_upper_alias(dentry) || disconnected) && in ovl_already_copied_up_locked()
523 !ovl_dentry_needs_data_copy_up_locked(dentry, flags)) in ovl_already_copied_up_locked()
529 bool ovl_already_copied_up(struct dentry *dentry, int flags) in ovl_already_copied_up() argument
531 bool disconnected = dentry->d_flags & DCACHE_DISCONNECTED; in ovl_already_copied_up()
546 if (ovl_dentry_upper(dentry) && in ovl_already_copied_up()
547 (ovl_dentry_has_upper_alias(dentry) || disconnected) && in ovl_already_copied_up()
548 !ovl_dentry_needs_data_copy_up(dentry, flags)) in ovl_already_copied_up()
554 int ovl_copy_up_start(struct dentry *dentry, int flags) in ovl_copy_up_start() argument
556 struct inode *inode = d_inode(dentry); in ovl_copy_up_start()
560 if (!err && ovl_already_copied_up_locked(dentry, flags)) { in ovl_copy_up_start()
568 void ovl_copy_up_end(struct dentry *dentry) in ovl_copy_up_end() argument
570 ovl_inode_unlock(d_inode(dentry)); in ovl_copy_up_end()
573 bool ovl_check_origin_xattr(struct ovl_fs *ofs, struct dentry *dentry) in ovl_check_origin_xattr() argument
577 res = ovl_do_getxattr(ofs, dentry, OVL_XATTR_ORIGIN, NULL, 0); in ovl_check_origin_xattr()
586 bool ovl_check_dir_xattr(struct super_block *sb, struct dentry *dentry, in ovl_check_dir_xattr() argument
592 if (!d_is_dir(dentry)) in ovl_check_dir_xattr()
595 res = ovl_do_getxattr(OVL_FS(sb), dentry, ox, &val, 1); in ovl_check_dir_xattr()
623 int ovl_check_setxattr(struct dentry *dentry, struct dentry *upperdentry, in ovl_check_setxattr() argument
628 struct ovl_fs *ofs = dentry->d_sb->s_fs_info; in ovl_check_setxattr()
644 int ovl_set_impure(struct dentry *dentry, struct dentry *upperdentry) in ovl_set_impure() argument
648 if (ovl_test_flag(OVL_IMPURE, d_inode(dentry))) in ovl_set_impure()
655 err = ovl_check_setxattr(dentry, upperdentry, OVL_XATTR_IMPURE, in ovl_set_impure()
658 ovl_set_flag(OVL_IMPURE, d_inode(dentry)); in ovl_set_impure()
667 bool ovl_inuse_trylock(struct dentry *dentry) in ovl_inuse_trylock() argument
669 struct inode *inode = d_inode(dentry); in ovl_inuse_trylock()
682 void ovl_inuse_unlock(struct dentry *dentry) in ovl_inuse_unlock() argument
684 if (dentry) { in ovl_inuse_unlock()
685 struct inode *inode = d_inode(dentry); in ovl_inuse_unlock()
694 bool ovl_is_inuse(struct dentry *dentry) in ovl_is_inuse() argument
696 struct inode *inode = d_inode(dentry); in ovl_is_inuse()
709 bool ovl_need_index(struct dentry *dentry) in ovl_need_index() argument
711 struct dentry *lower = ovl_dentry_lower(dentry); in ovl_need_index()
713 if (!lower || !ovl_indexdir(dentry->d_sb)) in ovl_need_index()
717 if (ovl_index_all(dentry->d_sb)) in ovl_need_index()
728 static void ovl_cleanup_index(struct dentry *dentry) in ovl_cleanup_index() argument
730 struct dentry *indexdir = ovl_indexdir(dentry->d_sb); in ovl_cleanup_index()
732 struct dentry *lowerdentry = ovl_dentry_lower(dentry); in ovl_cleanup_index()
733 struct dentry *upperdentry = ovl_dentry_upper(dentry); in ovl_cleanup_index()
734 struct dentry *index = NULL; in ovl_cleanup_index()
756 set_nlink(d_inode(dentry), inode->i_nlink - 1); in ovl_cleanup_index()
757 ovl_set_nlink_upper(dentry); in ovl_cleanup_index()
766 } else if (ovl_index_all(dentry->d_sb)) { in ovl_cleanup_index()
768 err = ovl_cleanup_and_whiteout(OVL_FS(dentry->d_sb), in ovl_cleanup_index()
785 pr_err("cleanup index of '%pd2' failed (%i)\n", dentry, err); in ovl_cleanup_index()
793 int ovl_nlink_start(struct dentry *dentry) in ovl_nlink_start() argument
795 struct inode *inode = d_inode(dentry); in ovl_nlink_start()
816 if (ovl_need_index(dentry) && !ovl_dentry_has_upper_alias(dentry)) { in ovl_nlink_start()
817 err = ovl_copy_up(dentry); in ovl_nlink_start()
826 if (d_is_dir(dentry) || !ovl_test_flag(OVL_INDEX, inode)) in ovl_nlink_start()
829 old_cred = ovl_override_creds(dentry->d_sb); in ovl_nlink_start()
836 err = ovl_set_nlink_upper(dentry); in ovl_nlink_start()
837 ovl_revert_creds(dentry->d_sb, old_cred); in ovl_nlink_start()
846 void ovl_nlink_end(struct dentry *dentry) in ovl_nlink_end() argument
848 struct inode *inode = d_inode(dentry); in ovl_nlink_end()
853 old_cred = ovl_override_creds(dentry->d_sb); in ovl_nlink_end()
854 ovl_cleanup_index(dentry); in ovl_nlink_end()
855 ovl_revert_creds(dentry->d_sb, old_cred); in ovl_nlink_end()
861 int ovl_lock_rename_workdir(struct dentry *workdir, struct dentry *upperdir) in ovl_lock_rename_workdir()
881 int ovl_check_metacopy_xattr(struct ovl_fs *ofs, struct dentry *dentry) in ovl_check_metacopy_xattr() argument
886 if (!S_ISREG(d_inode(dentry)->i_mode)) in ovl_check_metacopy_xattr()
889 res = ovl_do_getxattr(ofs, dentry, OVL_XATTR_METACOPY, NULL, 0); in ovl_check_metacopy_xattr()
902 bool ovl_is_metacopy_dentry(struct dentry *dentry) in ovl_is_metacopy_dentry() argument
904 struct ovl_entry *oe = dentry->d_fsdata; in ovl_is_metacopy_dentry()
906 if (!d_is_reg(dentry)) in ovl_is_metacopy_dentry()
909 if (ovl_dentry_upper(dentry)) { in ovl_is_metacopy_dentry()
910 if (!ovl_has_upperdata(d_inode(dentry))) in ovl_is_metacopy_dentry()
918 char *ovl_get_redirect_xattr(struct ovl_fs *ofs, struct dentry *dentry, in ovl_get_redirect_xattr() argument
924 res = ovl_do_getxattr(ofs, dentry, OVL_XATTR_REDIRECT, NULL, 0); in ovl_get_redirect_xattr()
936 res = ovl_do_getxattr(ofs, dentry, OVL_XATTR_REDIRECT, buf, res); in ovl_get_redirect_xattr()