Lines Matching refs:dentry
19 static int ovl_encode_maybe_copy_up(struct dentry *dentry) in ovl_encode_maybe_copy_up() argument
23 if (ovl_dentry_upper(dentry)) in ovl_encode_maybe_copy_up()
26 err = ovl_want_write(dentry); in ovl_encode_maybe_copy_up()
28 err = ovl_copy_up(dentry); in ovl_encode_maybe_copy_up()
29 ovl_drop_write(dentry); in ovl_encode_maybe_copy_up()
34 dentry, err); in ovl_encode_maybe_copy_up()
77 static int ovl_connectable_layer(struct dentry *dentry) in ovl_connectable_layer() argument
79 struct ovl_entry *oe = OVL_E(dentry); in ovl_connectable_layer()
82 if (dentry == dentry->d_sb->s_root) in ovl_connectable_layer()
89 if (ovl_dentry_upper(dentry) && in ovl_connectable_layer()
90 !ovl_test_flag(OVL_INDEX, d_inode(dentry))) in ovl_connectable_layer()
105 static int ovl_connect_layer(struct dentry *dentry) in ovl_connect_layer() argument
107 struct dentry *next, *parent = NULL; in ovl_connect_layer()
108 struct ovl_entry *oe = OVL_E(dentry); in ovl_connect_layer()
112 if (WARN_ON(dentry == dentry->d_sb->s_root) || in ovl_connect_layer()
113 WARN_ON(!ovl_dentry_lower(dentry))) in ovl_connect_layer()
117 if (ovl_dentry_test_flag(OVL_E_CONNECTED, dentry)) in ovl_connect_layer()
121 next = dget(dentry); in ovl_connect_layer()
151 ovl_dentry_set_flag(OVL_E_CONNECTED, dentry); in ovl_connect_layer()
184 static int ovl_check_encode_origin(struct dentry *dentry) in ovl_check_encode_origin() argument
186 struct ovl_fs *ofs = OVL_FS(dentry->d_sb); in ovl_check_encode_origin()
190 if (!ovl_dentry_upper(dentry) && !decodable) in ovl_check_encode_origin()
194 if (!ovl_dentry_lower(dentry)) in ovl_check_encode_origin()
201 if (dentry == dentry->d_sb->s_root) in ovl_check_encode_origin()
207 if (ovl_dentry_upper(dentry) && decodable && in ovl_check_encode_origin()
208 !ovl_test_flag(OVL_INDEX, d_inode(dentry))) in ovl_check_encode_origin()
217 if (d_is_dir(dentry) && ovl_upper_mnt(ofs) && decodable) in ovl_check_encode_origin()
218 return ovl_connect_layer(dentry); in ovl_check_encode_origin()
224 static int ovl_dentry_to_fid(struct ovl_fs *ofs, struct dentry *dentry, in ovl_dentry_to_fid() argument
235 err = enc_lower = ovl_check_encode_origin(dentry); in ovl_dentry_to_fid()
240 fh = ovl_encode_real_fh(ofs, enc_lower ? ovl_dentry_lower(dentry) : in ovl_dentry_to_fid()
241 ovl_dentry_upper(dentry), !enc_lower); in ovl_dentry_to_fid()
256 dentry, err); in ovl_dentry_to_fid()
264 struct dentry *dentry; in ovl_encode_fh() local
271 dentry = d_find_any_alias(inode); in ovl_encode_fh()
272 if (!dentry) in ovl_encode_fh()
275 bytes = ovl_dentry_to_fid(ofs, dentry, fid, buflen); in ovl_encode_fh()
276 dput(dentry); in ovl_encode_fh()
290 static struct dentry *ovl_obtain_alias(struct super_block *sb, in ovl_obtain_alias()
291 struct dentry *upper_alias, in ovl_obtain_alias()
293 struct dentry *index) in ovl_obtain_alias()
295 struct dentry *lower = lowerpath ? lowerpath->dentry : NULL; in ovl_obtain_alias()
296 struct dentry *upper = upper_alias ?: index; in ovl_obtain_alias()
297 struct dentry *dentry; in ovl_obtain_alias() local
314 ovl_lowerstack(oe)->dentry = dget(lower); in ovl_obtain_alias()
328 dentry = d_find_any_alias(inode); in ovl_obtain_alias()
329 if (dentry) in ovl_obtain_alias()
332 dentry = d_alloc_anon(inode->i_sb); in ovl_obtain_alias()
333 if (unlikely(!dentry)) in ovl_obtain_alias()
337 ovl_dentry_set_upper_alias(dentry); in ovl_obtain_alias()
339 ovl_dentry_init_reval(dentry, upper, OVL_I_E(inode)); in ovl_obtain_alias()
341 return d_instantiate_anon(dentry, inode); in ovl_obtain_alias()
344 dput(dentry); in ovl_obtain_alias()
345 dentry = ERR_PTR(-ENOMEM); in ovl_obtain_alias()
348 return dentry; in ovl_obtain_alias()
352 static struct dentry *ovl_dentry_real_at(struct dentry *dentry, int idx) in ovl_dentry_real_at() argument
354 struct ovl_entry *oe = OVL_E(dentry); in ovl_dentry_real_at()
359 return ovl_dentry_upper(dentry); in ovl_dentry_real_at()
363 return lowerstack[i].dentry; in ovl_dentry_real_at()
375 static struct dentry *ovl_lookup_real_one(struct dentry *connected, in ovl_lookup_real_one()
376 struct dentry *real, in ovl_lookup_real_one()
380 struct dentry *this, *parent = NULL; in ovl_lookup_real_one()
436 static struct dentry *ovl_lookup_real(struct super_block *sb,
437 struct dentry *real,
443 static struct dentry *ovl_lookup_real_inode(struct super_block *sb, in ovl_lookup_real_inode()
444 struct dentry *real, in ovl_lookup_real_inode()
448 struct dentry *index = NULL; in ovl_lookup_real_inode()
449 struct dentry *this = NULL; in ovl_lookup_real_inode()
476 struct dentry *upper = ovl_index_upper(ofs, index, true); in ovl_lookup_real_inode()
508 static struct dentry *ovl_lookup_real_ancestor(struct super_block *sb, in ovl_lookup_real_ancestor()
509 struct dentry *real, in ovl_lookup_real_ancestor()
512 struct dentry *next, *parent = NULL; in ovl_lookup_real_ancestor()
513 struct dentry *ancestor = ERR_PTR(-EIO); in ovl_lookup_real_ancestor()
561 static struct dentry *ovl_lookup_real(struct super_block *sb, in ovl_lookup_real()
562 struct dentry *real, in ovl_lookup_real()
565 struct dentry *connected; in ovl_lookup_real()
573 struct dentry *next, *this; in ovl_lookup_real()
574 struct dentry *parent = NULL; in ovl_lookup_real()
575 struct dentry *real_connected = ovl_dentry_real_at(connected, in ovl_lookup_real()
663 static struct dentry *ovl_get_dentry(struct super_block *sb, in ovl_get_dentry()
664 struct dentry *upper, in ovl_get_dentry()
666 struct dentry *index) in ovl_get_dentry()
670 struct dentry *real = upper ?: (index ?: lowerpath->dentry); in ovl_get_dentry()
690 static struct dentry *ovl_upper_fh_to_d(struct super_block *sb, in ovl_upper_fh_to_d()
694 struct dentry *dentry; in ovl_upper_fh_to_d() local
695 struct dentry *upper; in ovl_upper_fh_to_d()
704 dentry = ovl_get_dentry(sb, upper, NULL, NULL); in ovl_upper_fh_to_d()
707 return dentry; in ovl_upper_fh_to_d()
710 static struct dentry *ovl_lower_fh_to_d(struct super_block *sb, in ovl_lower_fh_to_d()
716 struct dentry *dentry = NULL; in ovl_lower_fh_to_d() local
717 struct dentry *index = NULL; in ovl_lower_fh_to_d()
726 if (!d_is_dir(origin.dentry) || in ovl_lower_fh_to_d()
727 !(origin.dentry->d_flags & DCACHE_DISCONNECTED)) { in ovl_lower_fh_to_d()
728 inode = ovl_lookup_inode(sb, origin.dentry, false); in ovl_lower_fh_to_d()
733 dentry = d_find_any_alias(inode); in ovl_lower_fh_to_d()
735 if (dentry) in ovl_lower_fh_to_d()
752 struct dentry *upper = ovl_index_upper(ofs, index, true); in ovl_lower_fh_to_d()
758 dentry = ovl_get_dentry(sb, upper, NULL, NULL); in ovl_lower_fh_to_d()
764 if (d_is_dir(origin.dentry)) { in ovl_lower_fh_to_d()
765 dput(origin.dentry); in ovl_lower_fh_to_d()
766 origin.dentry = NULL; in ovl_lower_fh_to_d()
772 err = ovl_verify_origin(ofs, index, origin.dentry, false); in ovl_lower_fh_to_d()
778 dentry = ovl_get_dentry(sb, NULL, &origin, index); in ovl_lower_fh_to_d()
781 dput(origin.dentry); in ovl_lower_fh_to_d()
783 return dentry; in ovl_lower_fh_to_d()
786 dentry = ERR_PTR(err); in ovl_lower_fh_to_d()
813 static struct dentry *ovl_fh_to_dentry(struct super_block *sb, struct fid *fid, in ovl_fh_to_dentry()
816 struct dentry *dentry = NULL; in ovl_fh_to_dentry() local
832 dentry = (flags & OVL_FH_FLAG_PATH_UPPER) ? in ovl_fh_to_dentry()
835 err = PTR_ERR(dentry); in ovl_fh_to_dentry()
836 if (IS_ERR(dentry) && err != -ESTALE) in ovl_fh_to_dentry()
844 return dentry; in ovl_fh_to_dentry()
849 dentry = ERR_PTR(err); in ovl_fh_to_dentry()
853 static struct dentry *ovl_fh_to_parent(struct super_block *sb, struct fid *fid, in ovl_fh_to_parent()
860 static int ovl_get_name(struct dentry *parent, char *name, in ovl_get_name()
861 struct dentry *child) in ovl_get_name()
871 static struct dentry *ovl_get_parent(struct dentry *dentry) in ovl_get_parent() argument