Lines Matching refs:dentry
20 int ovl_want_write(struct dentry *dentry) in ovl_want_write() argument
22 struct ovl_fs *ofs = OVL_FS(dentry->d_sb); in ovl_want_write()
26 void ovl_drop_write(struct dentry *dentry) in ovl_drop_write() argument
28 struct ovl_fs *ofs = OVL_FS(dentry->d_sb); in ovl_drop_write()
32 struct dentry *ovl_workdir(struct dentry *dentry) in ovl_workdir() argument
34 struct ovl_fs *ofs = OVL_FS(dentry->d_sb); in ovl_workdir()
64 struct dentry *ovl_indexdir(struct super_block *sb) in ovl_indexdir()
98 dget(src[i].dentry); in ovl_stack_cpy()
106 dput(stack[i].dentry); in ovl_stack_put()
134 bool ovl_dentry_remote(struct dentry *dentry) in ovl_dentry_remote() argument
136 return dentry->d_flags & OVL_D_REVALIDATE; in ovl_dentry_remote()
139 void ovl_dentry_update_reval(struct dentry *dentry, struct dentry *realdentry) in ovl_dentry_update_reval() argument
144 spin_lock(&dentry->d_lock); in ovl_dentry_update_reval()
145 dentry->d_flags |= realdentry->d_flags & OVL_D_REVALIDATE; in ovl_dentry_update_reval()
146 spin_unlock(&dentry->d_lock); in ovl_dentry_update_reval()
149 void ovl_dentry_init_reval(struct dentry *dentry, struct dentry *upperdentry, in ovl_dentry_init_reval() argument
152 return ovl_dentry_init_flags(dentry, upperdentry, oe, OVL_D_REVALIDATE); in ovl_dentry_init_reval()
155 void ovl_dentry_init_flags(struct dentry *dentry, struct dentry *upperdentry, in ovl_dentry_init_flags() argument
163 for (i = 0; i < ovl_numlower(oe) && lowerstack[i].dentry; i++) in ovl_dentry_init_flags()
164 flags |= lowerstack[i].dentry->d_flags; in ovl_dentry_init_flags()
166 spin_lock(&dentry->d_lock); in ovl_dentry_init_flags()
167 dentry->d_flags &= ~mask; in ovl_dentry_init_flags()
168 dentry->d_flags |= flags & mask; in ovl_dentry_init_flags()
169 spin_unlock(&dentry->d_lock); in ovl_dentry_init_flags()
172 bool ovl_dentry_weird(struct dentry *dentry) in ovl_dentry_weird() argument
174 return dentry->d_flags & (DCACHE_NEED_AUTOMOUNT | in ovl_dentry_weird()
180 enum ovl_path_type ovl_path_type(struct dentry *dentry) in ovl_path_type() argument
182 struct ovl_entry *oe = OVL_E(dentry); in ovl_path_type()
185 if (ovl_dentry_upper(dentry)) { in ovl_path_type()
192 if (ovl_test_flag(OVL_CONST_INO, d_inode(dentry))) in ovl_path_type()
194 if (d_is_dir(dentry) || in ovl_path_type()
195 !ovl_has_upperdata(d_inode(dentry))) in ovl_path_type()
205 void ovl_path_upper(struct dentry *dentry, struct path *path) in ovl_path_upper() argument
207 struct ovl_fs *ofs = OVL_FS(dentry->d_sb); in ovl_path_upper()
210 path->dentry = ovl_dentry_upper(dentry); in ovl_path_upper()
213 void ovl_path_lower(struct dentry *dentry, struct path *path) in ovl_path_lower() argument
215 struct ovl_entry *oe = OVL_E(dentry); in ovl_path_lower()
220 path->dentry = lowerpath->dentry; in ovl_path_lower()
226 void ovl_path_lowerdata(struct dentry *dentry, struct path *path) in ovl_path_lowerdata() argument
228 struct ovl_entry *oe = OVL_E(dentry); in ovl_path_lowerdata()
230 struct dentry *lowerdata_dentry = ovl_lowerdata_dentry(oe); in ovl_path_lowerdata()
233 path->dentry = lowerdata_dentry; in ovl_path_lowerdata()
246 enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path) in ovl_path_real() argument
248 enum ovl_path_type type = ovl_path_type(dentry); in ovl_path_real()
251 ovl_path_lower(dentry, path); in ovl_path_real()
253 ovl_path_upper(dentry, path); in ovl_path_real()
258 enum ovl_path_type ovl_path_realdata(struct dentry *dentry, struct path *path) in ovl_path_realdata() argument
260 enum ovl_path_type type = ovl_path_type(dentry); in ovl_path_realdata()
262 WARN_ON_ONCE(d_is_dir(dentry)); in ovl_path_realdata()
265 ovl_path_lowerdata(dentry, path); in ovl_path_realdata()
267 ovl_path_upper(dentry, path); in ovl_path_realdata()
272 struct dentry *ovl_dentry_upper(struct dentry *dentry) in ovl_dentry_upper() argument
274 return ovl_upperdentry_dereference(OVL_I(d_inode(dentry))); in ovl_dentry_upper()
277 struct dentry *ovl_dentry_lower(struct dentry *dentry) in ovl_dentry_lower() argument
279 struct ovl_entry *oe = OVL_E(dentry); in ovl_dentry_lower()
281 return ovl_numlower(oe) ? ovl_lowerstack(oe)->dentry : NULL; in ovl_dentry_lower()
284 const struct ovl_layer *ovl_layer_lower(struct dentry *dentry) in ovl_layer_lower() argument
286 struct ovl_entry *oe = OVL_E(dentry); in ovl_layer_lower()
297 struct dentry *ovl_dentry_lowerdata(struct dentry *dentry) in ovl_dentry_lowerdata() argument
299 return ovl_lowerdata_dentry(OVL_E(dentry)); in ovl_dentry_lowerdata()
302 int ovl_dentry_set_lowerdata(struct dentry *dentry, struct ovl_path *datapath) in ovl_dentry_set_lowerdata() argument
304 struct ovl_entry *oe = OVL_E(dentry); in ovl_dentry_set_lowerdata()
306 struct dentry *datadentry = datapath->dentry; in ovl_dentry_set_lowerdata()
318 WRITE_ONCE(lowerdata->dentry, dget(datadentry)); in ovl_dentry_set_lowerdata()
320 ovl_dentry_update_reval(dentry, datadentry); in ovl_dentry_set_lowerdata()
325 struct dentry *ovl_dentry_real(struct dentry *dentry) in ovl_dentry_real() argument
327 return ovl_dentry_upper(dentry) ?: ovl_dentry_lower(dentry); in ovl_dentry_real()
330 struct dentry *ovl_i_dentry_upper(struct inode *inode) in ovl_i_dentry_upper()
339 path->dentry = ovl_i_dentry_upper(inode); in ovl_i_path_real()
340 if (!path->dentry) { in ovl_i_path_real()
341 path->dentry = lowerpath->dentry; in ovl_i_path_real()
347 return path->dentry ? d_inode_rcu(path->dentry) : NULL; in ovl_i_path_real()
352 struct dentry *upperdentry = ovl_i_dentry_upper(inode); in ovl_inode_upper()
361 return lowerpath ? d_inode(lowerpath->dentry) : NULL; in ovl_inode_lower()
372 struct dentry *lowerdata = ovl_lowerdata_dentry(OVL_I_E(inode)); in ovl_inode_lowerdata()
408 void ovl_dentry_set_flag(unsigned long flag, struct dentry *dentry) in ovl_dentry_set_flag() argument
410 set_bit(flag, OVL_E_FLAGS(dentry)); in ovl_dentry_set_flag()
413 void ovl_dentry_clear_flag(unsigned long flag, struct dentry *dentry) in ovl_dentry_clear_flag() argument
415 clear_bit(flag, OVL_E_FLAGS(dentry)); in ovl_dentry_clear_flag()
418 bool ovl_dentry_test_flag(unsigned long flag, struct dentry *dentry) in ovl_dentry_test_flag() argument
420 return test_bit(flag, OVL_E_FLAGS(dentry)); in ovl_dentry_test_flag()
423 bool ovl_dentry_is_opaque(struct dentry *dentry) in ovl_dentry_is_opaque() argument
425 return ovl_dentry_test_flag(OVL_E_OPAQUE, dentry); in ovl_dentry_is_opaque()
428 bool ovl_dentry_is_whiteout(struct dentry *dentry) in ovl_dentry_is_whiteout() argument
430 return !dentry->d_inode && ovl_dentry_is_opaque(dentry); in ovl_dentry_is_whiteout()
433 void ovl_dentry_set_opaque(struct dentry *dentry) in ovl_dentry_set_opaque() argument
435 ovl_dentry_set_flag(OVL_E_OPAQUE, dentry); in ovl_dentry_set_opaque()
444 bool ovl_dentry_has_upper_alias(struct dentry *dentry) in ovl_dentry_has_upper_alias() argument
446 return ovl_dentry_test_flag(OVL_E_UPPER_ALIAS, dentry); in ovl_dentry_has_upper_alias()
449 void ovl_dentry_set_upper_alias(struct dentry *dentry) in ovl_dentry_set_upper_alias() argument
451 ovl_dentry_set_flag(OVL_E_UPPER_ALIAS, dentry); in ovl_dentry_set_upper_alias()
494 bool ovl_dentry_needs_data_copy_up_locked(struct dentry *dentry, int flags) in ovl_dentry_needs_data_copy_up_locked() argument
499 return !ovl_test_flag(OVL_UPPERDATA, d_inode(dentry)); in ovl_dentry_needs_data_copy_up_locked()
502 bool ovl_dentry_needs_data_copy_up(struct dentry *dentry, int flags) in ovl_dentry_needs_data_copy_up() argument
507 return !ovl_has_upperdata(d_inode(dentry)); in ovl_dentry_needs_data_copy_up()
510 const char *ovl_dentry_get_redirect(struct dentry *dentry) in ovl_dentry_get_redirect() argument
512 return OVL_I(d_inode(dentry))->redirect; in ovl_dentry_get_redirect()
515 void ovl_dentry_set_redirect(struct dentry *dentry, const char *redirect) in ovl_dentry_set_redirect() argument
517 struct ovl_inode *oi = OVL_I(d_inode(dentry)); in ovl_dentry_set_redirect()
523 void ovl_inode_update(struct inode *inode, struct dentry *upperdentry) in ovl_inode_update()
540 static void ovl_dir_version_inc(struct dentry *dentry, bool impurity) in ovl_dir_version_inc() argument
542 struct inode *inode = d_inode(dentry); in ovl_dir_version_inc()
545 WARN_ON(!d_is_dir(dentry)); in ovl_dir_version_inc()
557 void ovl_dir_modified(struct dentry *dentry, bool impurity) in ovl_dir_modified() argument
560 ovl_copyattr(d_inode(dentry)); in ovl_dir_modified()
562 ovl_dir_version_inc(dentry, impurity); in ovl_dir_modified()
571 bool ovl_is_whiteout(struct dentry *dentry) in ovl_is_whiteout() argument
573 struct inode *inode = dentry->d_inode; in ovl_is_whiteout()
580 struct inode *inode = d_inode(path->dentry); in ovl_path_open()
610 static bool ovl_already_copied_up_locked(struct dentry *dentry, int flags) in ovl_already_copied_up_locked() argument
612 bool disconnected = dentry->d_flags & DCACHE_DISCONNECTED; in ovl_already_copied_up_locked()
614 if (ovl_dentry_upper(dentry) && in ovl_already_copied_up_locked()
615 (ovl_dentry_has_upper_alias(dentry) || disconnected) && in ovl_already_copied_up_locked()
616 !ovl_dentry_needs_data_copy_up_locked(dentry, flags)) in ovl_already_copied_up_locked()
622 bool ovl_already_copied_up(struct dentry *dentry, int flags) in ovl_already_copied_up() argument
624 bool disconnected = dentry->d_flags & DCACHE_DISCONNECTED; in ovl_already_copied_up()
639 if (ovl_dentry_upper(dentry) && in ovl_already_copied_up()
640 (ovl_dentry_has_upper_alias(dentry) || disconnected) && in ovl_already_copied_up()
641 !ovl_dentry_needs_data_copy_up(dentry, flags)) in ovl_already_copied_up()
647 int ovl_copy_up_start(struct dentry *dentry, int flags) in ovl_copy_up_start() argument
649 struct inode *inode = d_inode(dentry); in ovl_copy_up_start()
653 if (!err && ovl_already_copied_up_locked(dentry, flags)) { in ovl_copy_up_start()
661 void ovl_copy_up_end(struct dentry *dentry) in ovl_copy_up_end() argument
663 ovl_inode_unlock(d_inode(dentry)); in ovl_copy_up_end()
725 res = ovl_setxattr(ofs, upperpath->dentry, OVL_XATTR_UUID, sb->s_uuid.b, in ovl_init_uuid_xattr()
734 set ? "set" : "get", upperpath->dentry, res); in ovl_init_uuid_xattr()
744 if (!d_is_dir(path->dentry)) in ovl_path_check_dir_xattr()
780 int ovl_check_setxattr(struct ovl_fs *ofs, struct dentry *upperdentry, in ovl_check_setxattr()
800 int ovl_set_impure(struct dentry *dentry, struct dentry *upperdentry) in ovl_set_impure() argument
802 struct ovl_fs *ofs = OVL_FS(dentry->d_sb); in ovl_set_impure()
805 if (ovl_test_flag(OVL_IMPURE, d_inode(dentry))) in ovl_set_impure()
814 ovl_set_flag(OVL_IMPURE, d_inode(dentry)); in ovl_set_impure()
822 void ovl_check_protattr(struct inode *inode, struct dentry *upper) in ovl_check_protattr()
857 int ovl_set_protattr(struct inode *inode, struct dentry *upper, in ovl_set_protattr()
905 bool ovl_inuse_trylock(struct dentry *dentry) in ovl_inuse_trylock() argument
907 struct inode *inode = d_inode(dentry); in ovl_inuse_trylock()
920 void ovl_inuse_unlock(struct dentry *dentry) in ovl_inuse_unlock() argument
922 if (dentry) { in ovl_inuse_unlock()
923 struct inode *inode = d_inode(dentry); in ovl_inuse_unlock()
932 bool ovl_is_inuse(struct dentry *dentry) in ovl_is_inuse() argument
934 struct inode *inode = d_inode(dentry); in ovl_is_inuse()
947 bool ovl_need_index(struct dentry *dentry) in ovl_need_index() argument
949 struct dentry *lower = ovl_dentry_lower(dentry); in ovl_need_index()
951 if (!lower || !ovl_indexdir(dentry->d_sb)) in ovl_need_index()
955 if (ovl_index_all(dentry->d_sb)) in ovl_need_index()
966 static void ovl_cleanup_index(struct dentry *dentry) in ovl_cleanup_index() argument
968 struct ovl_fs *ofs = OVL_FS(dentry->d_sb); in ovl_cleanup_index()
969 struct dentry *indexdir = ovl_indexdir(dentry->d_sb); in ovl_cleanup_index()
971 struct dentry *lowerdentry = ovl_dentry_lower(dentry); in ovl_cleanup_index()
972 struct dentry *upperdentry = ovl_dentry_upper(dentry); in ovl_cleanup_index()
973 struct dentry *index = NULL; in ovl_cleanup_index()
995 set_nlink(d_inode(dentry), inode->i_nlink - 1); in ovl_cleanup_index()
996 ovl_set_nlink_upper(dentry); in ovl_cleanup_index()
1005 } else if (ovl_index_all(dentry->d_sb)) { in ovl_cleanup_index()
1007 err = ovl_cleanup_and_whiteout(OVL_FS(dentry->d_sb), in ovl_cleanup_index()
1024 pr_err("cleanup index of '%pd2' failed (%i)\n", dentry, err); in ovl_cleanup_index()
1032 int ovl_nlink_start(struct dentry *dentry) in ovl_nlink_start() argument
1034 struct inode *inode = d_inode(dentry); in ovl_nlink_start()
1055 if (ovl_need_index(dentry) && !ovl_dentry_has_upper_alias(dentry)) { in ovl_nlink_start()
1056 err = ovl_copy_up(dentry); in ovl_nlink_start()
1065 if (d_is_dir(dentry) || !ovl_test_flag(OVL_INDEX, inode)) in ovl_nlink_start()
1068 old_cred = ovl_override_creds(dentry->d_sb); in ovl_nlink_start()
1075 err = ovl_set_nlink_upper(dentry); in ovl_nlink_start()
1085 void ovl_nlink_end(struct dentry *dentry) in ovl_nlink_end() argument
1087 struct inode *inode = d_inode(dentry); in ovl_nlink_end()
1092 old_cred = ovl_override_creds(dentry->d_sb); in ovl_nlink_end()
1093 ovl_cleanup_index(dentry); in ovl_nlink_end()
1100 int ovl_lock_rename_workdir(struct dentry *workdir, struct dentry *upperdir) in ovl_lock_rename_workdir()
1129 if (!S_ISREG(d_inode(path->dentry)->i_mode)) in ovl_check_metacopy_xattr()
1156 path->dentry); in ovl_check_metacopy_xattr()
1161 path->dentry); in ovl_check_metacopy_xattr()
1166 path->dentry); in ovl_check_metacopy_xattr()
1177 int ovl_set_metacopy_xattr(struct ovl_fs *ofs, struct dentry *d, struct ovl_metacopy *metacopy) in ovl_set_metacopy_xattr()
1189 bool ovl_is_metacopy_dentry(struct dentry *dentry) in ovl_is_metacopy_dentry() argument
1191 struct ovl_entry *oe = OVL_E(dentry); in ovl_is_metacopy_dentry()
1193 if (!d_is_reg(dentry)) in ovl_is_metacopy_dentry()
1196 if (ovl_dentry_upper(dentry)) { in ovl_is_metacopy_dentry()
1197 if (!ovl_has_upperdata(d_inode(dentry))) in ovl_is_metacopy_dentry()
1254 struct inode *inode = d_inode(datapath->dentry); in ovl_ensure_verity_loaded()
1283 !S_ISREG(d_inode(metapath->dentry)->i_mode)) in ovl_validate_verity()
1293 metapath->dentry); in ovl_validate_verity()
1304 datapath->dentry); in ovl_validate_verity()
1308 digest_size = fsverity_get_digest(d_inode(datapath->dentry), actual_digest, in ovl_validate_verity()
1311 pr_warn_ratelimited("lower file '%pd' has no fs-verity digest\n", datapath->dentry); in ovl_validate_verity()
1319 datapath->dentry); in ovl_validate_verity()
1331 if (!ofs->config.verity_mode || !S_ISREG(d_inode(src->dentry)->i_mode)) in ovl_get_verity_digest()
1337 src->dentry); in ovl_get_verity_digest()
1341 digest_size = fsverity_get_digest(d_inode(src->dentry), in ovl_get_verity_digest()
1347 src->dentry); in ovl_get_verity_digest()