Lines Matching refs:dentry

18 int ovl_want_write(struct dentry *dentry)
20 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
24 void ovl_drop_write(struct dentry *dentry)
26 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
30 struct dentry *ovl_workdir(struct dentry *dentry)
32 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
59 struct dentry *ovl_indexdir(struct super_block *sb)
95 bool ovl_dentry_remote(struct dentry *dentry)
97 return dentry->d_flags & OVL_D_REVALIDATE;
100 void ovl_dentry_update_reval(struct dentry *dentry, struct dentry *realdentry)
105 spin_lock(&dentry->d_lock);
106 dentry->d_flags |= realdentry->d_flags & OVL_D_REVALIDATE;
107 spin_unlock(&dentry->d_lock);
110 void ovl_dentry_init_reval(struct dentry *dentry, struct dentry *upperdentry)
112 return ovl_dentry_init_flags(dentry, upperdentry, OVL_D_REVALIDATE);
115 void ovl_dentry_init_flags(struct dentry *dentry, struct dentry *upperdentry,
118 struct ovl_entry *oe = OVL_E(dentry);
124 flags |= oe->lowerstack[i].dentry->d_flags;
126 spin_lock(&dentry->d_lock);
127 dentry->d_flags &= ~mask;
128 dentry->d_flags |= flags & mask;
129 spin_unlock(&dentry->d_lock);
132 bool ovl_dentry_weird(struct dentry *dentry)
134 return dentry->d_flags & (DCACHE_NEED_AUTOMOUNT |
140 enum ovl_path_type ovl_path_type(struct dentry *dentry)
142 struct ovl_entry *oe = dentry->d_fsdata;
145 if (ovl_dentry_upper(dentry)) {
149 * Non-dir dentry can hold lower dentry of its copy up origin.
152 if (ovl_test_flag(OVL_CONST_INO, d_inode(dentry)))
154 if (d_is_dir(dentry) ||
155 !ovl_has_upperdata(d_inode(dentry)))
165 void ovl_path_upper(struct dentry *dentry, struct path *path)
167 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
170 path->dentry = ovl_dentry_upper(dentry);
173 void ovl_path_lower(struct dentry *dentry, struct path *path)
175 struct ovl_entry *oe = dentry->d_fsdata;
179 path->dentry = oe->lowerstack[0].dentry;
185 void ovl_path_lowerdata(struct dentry *dentry, struct path *path)
187 struct ovl_entry *oe = dentry->d_fsdata;
191 path->dentry = oe->lowerstack[oe->numlower - 1].dentry;
197 enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path)
199 enum ovl_path_type type = ovl_path_type(dentry);
202 ovl_path_lower(dentry, path);
204 ovl_path_upper(dentry, path);
209 struct dentry *ovl_dentry_upper(struct dentry *dentry)
211 return ovl_upperdentry_dereference(OVL_I(d_inode(dentry)));
214 struct dentry *ovl_dentry_lower(struct dentry *dentry)
216 struct ovl_entry *oe = dentry->d_fsdata;
218 return oe->numlower ? oe->lowerstack[0].dentry : NULL;
221 const struct ovl_layer *ovl_layer_lower(struct dentry *dentry)
223 struct ovl_entry *oe = dentry->d_fsdata;
229 * ovl_dentry_lower() could return either a data dentry or metacopy dentry
231 * lower dentry which has data (and not metacopy dentry). This helper
232 * returns the lower data dentry.
234 struct dentry *ovl_dentry_lowerdata(struct dentry *dentry)
236 struct ovl_entry *oe = dentry->d_fsdata;
238 return oe->numlower ? oe->lowerstack[oe->numlower - 1].dentry : NULL;
241 struct dentry *ovl_dentry_real(struct dentry *dentry)
243 return ovl_dentry_upper(dentry) ?: ovl_dentry_lower(dentry);
246 struct dentry *ovl_i_dentry_upper(struct inode *inode)
253 struct dentry *upperdentry = ovl_i_dentry_upper(inode);
299 void ovl_dentry_set_flag(unsigned long flag, struct dentry *dentry)
301 set_bit(flag, &OVL_E(dentry)->flags);
304 void ovl_dentry_clear_flag(unsigned long flag, struct dentry *dentry)
306 clear_bit(flag, &OVL_E(dentry)->flags);
309 bool ovl_dentry_test_flag(unsigned long flag, struct dentry *dentry)
311 return test_bit(flag, &OVL_E(dentry)->flags);
314 bool ovl_dentry_is_opaque(struct dentry *dentry)
316 return ovl_dentry_test_flag(OVL_E_OPAQUE, dentry);
319 bool ovl_dentry_is_whiteout(struct dentry *dentry)
321 return !dentry->d_inode && ovl_dentry_is_opaque(dentry);
324 void ovl_dentry_set_opaque(struct dentry *dentry)
326 ovl_dentry_set_flag(OVL_E_OPAQUE, dentry);
335 bool ovl_dentry_has_upper_alias(struct dentry *dentry)
337 return ovl_dentry_test_flag(OVL_E_UPPER_ALIAS, dentry);
340 void ovl_dentry_set_upper_alias(struct dentry *dentry)
342 ovl_dentry_set_flag(OVL_E_UPPER_ALIAS, dentry);
385 bool ovl_dentry_needs_data_copy_up_locked(struct dentry *dentry, int flags)
390 return !ovl_test_flag(OVL_UPPERDATA, d_inode(dentry));
393 bool ovl_dentry_needs_data_copy_up(struct dentry *dentry, int flags)
398 return !ovl_has_upperdata(d_inode(dentry));
408 const char *ovl_dentry_get_redirect(struct dentry *dentry)
410 return OVL_I(d_inode(dentry))->redirect;
413 void ovl_dentry_set_redirect(struct dentry *dentry, const char *redirect)
415 struct ovl_inode *oi = OVL_I(d_inode(dentry));
421 void ovl_inode_update(struct inode *inode, struct dentry *upperdentry)
438 static void ovl_dir_version_inc(struct dentry *dentry, bool impurity)
440 struct inode *inode = d_inode(dentry);
443 WARN_ON(!d_is_dir(dentry));
451 if (!ovl_dir_is_real(dentry) || impurity)
455 void ovl_dir_modified(struct dentry *dentry, bool impurity)
458 ovl_copyattr(d_inode(ovl_dentry_upper(dentry)), d_inode(dentry));
460 ovl_dir_version_inc(dentry, impurity);
463 u64 ovl_dentry_version_get(struct dentry *dentry)
465 struct inode *inode = d_inode(dentry);
471 bool ovl_is_whiteout(struct dentry *dentry)
473 struct inode *inode = dentry->d_inode;
480 struct inode *inode = d_inode(path->dentry);
509 static bool ovl_already_copied_up_locked(struct dentry *dentry, int flags)
511 bool disconnected = dentry->d_flags & DCACHE_DISCONNECTED;
513 if (ovl_dentry_upper(dentry) &&
514 (ovl_dentry_has_upper_alias(dentry) || disconnected) &&
515 !ovl_dentry_needs_data_copy_up_locked(dentry, flags))
521 bool ovl_already_copied_up(struct dentry *dentry, int flags)
523 bool disconnected = dentry->d_flags & DCACHE_DISCONNECTED;
533 * upper dentry is up-to-date
538 if (ovl_dentry_upper(dentry) &&
539 (ovl_dentry_has_upper_alias(dentry) || disconnected) &&
540 !ovl_dentry_needs_data_copy_up(dentry, flags))
546 int ovl_copy_up_start(struct dentry *dentry, int flags)
548 struct inode *inode = d_inode(dentry);
552 if (!err && ovl_already_copied_up_locked(dentry, flags)) {
560 void ovl_copy_up_end(struct dentry *dentry)
562 ovl_inode_unlock(d_inode(dentry));
565 bool ovl_check_origin_xattr(struct ovl_fs *ofs, struct dentry *dentry)
569 res = ovl_do_getxattr(ofs, dentry, OVL_XATTR_ORIGIN, NULL, 0);
578 bool ovl_check_dir_xattr(struct super_block *sb, struct dentry *dentry,
584 if (!d_is_dir(dentry))
587 res = ovl_do_getxattr(OVL_FS(sb), dentry, ox, &val, 1);
615 int ovl_check_setxattr(struct dentry *dentry, struct dentry *upperdentry,
620 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
636 int ovl_set_impure(struct dentry *dentry, struct dentry *upperdentry)
640 if (ovl_test_flag(OVL_IMPURE, d_inode(dentry)))
647 err = ovl_check_setxattr(dentry, upperdentry, OVL_XATTR_IMPURE,
650 ovl_set_flag(OVL_IMPURE, d_inode(dentry));
659 bool ovl_inuse_trylock(struct dentry *dentry)
661 struct inode *inode = d_inode(dentry);
674 void ovl_inuse_unlock(struct dentry *dentry)
676 if (dentry) {
677 struct inode *inode = d_inode(dentry);
686 bool ovl_is_inuse(struct dentry *dentry)
688 struct inode *inode = d_inode(dentry);
699 * Does this overlay dentry need to be indexed on copy up?
701 bool ovl_need_index(struct dentry *dentry)
703 struct dentry *lower = ovl_dentry_lower(dentry);
705 if (!lower || !ovl_indexdir(dentry->d_sb))
709 if (ovl_index_all(dentry->d_sb))
720 static void ovl_cleanup_index(struct dentry *dentry)
722 struct dentry *indexdir = ovl_indexdir(dentry->d_sb);
724 struct dentry *lowerdentry = ovl_dentry_lower(dentry);
725 struct dentry *upperdentry = ovl_dentry_upper(dentry);
726 struct dentry *index = NULL;
748 set_nlink(d_inode(dentry), inode->i_nlink - 1);
749 ovl_set_nlink_upper(dentry);
758 } else if (ovl_index_all(dentry->d_sb)) {
760 err = ovl_cleanup_and_whiteout(OVL_FS(dentry->d_sb),
777 pr_err("cleanup index of '%pd2' failed (%i)\n", dentry, err);
785 int ovl_nlink_start(struct dentry *dentry)
787 struct inode *inode = d_inode(dentry);
806 * ovl_copy_up_flags(dentry, O_PATH).
808 if (ovl_need_index(dentry) && !ovl_dentry_has_upper_alias(dentry)) {
809 err = ovl_copy_up(dentry);
818 if (d_is_dir(dentry) || !ovl_test_flag(OVL_INDEX, inode))
821 old_cred = ovl_override_creds(dentry->d_sb);
828 err = ovl_set_nlink_upper(dentry);
838 void ovl_nlink_end(struct dentry *dentry)
840 struct inode *inode = d_inode(dentry);
845 old_cred = ovl_override_creds(dentry->d_sb);
846 ovl_cleanup_index(dentry);
853 int ovl_lock_rename_workdir(struct dentry *workdir, struct dentry *upperdir)
873 int ovl_check_metacopy_xattr(struct ovl_fs *ofs, struct dentry *dentry)
878 if (!S_ISREG(d_inode(dentry)->i_mode))
881 res = ovl_do_getxattr(ofs, dentry, OVL_XATTR_METACOPY, NULL, 0);
894 bool ovl_is_metacopy_dentry(struct dentry *dentry)
896 struct ovl_entry *oe = dentry->d_fsdata;
898 if (!d_is_reg(dentry))
901 if (ovl_dentry_upper(dentry)) {
902 if (!ovl_has_upperdata(d_inode(dentry)))
910 char *ovl_get_redirect_xattr(struct ovl_fs *ofs, struct dentry *dentry,
916 res = ovl_do_getxattr(ofs, dentry, OVL_XATTR_REDIRECT, NULL, 0);
928 res = ovl_do_getxattr(ofs, dentry, OVL_XATTR_REDIRECT, buf, res);