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()
111 if (WARN_ON(dentry == dentry->d_sb->s_root) || in ovl_connect_layer()
112 WARN_ON(!ovl_dentry_lower(dentry))) in ovl_connect_layer()
115 origin_layer = OVL_E(dentry)->lowerstack[0].layer->idx; in ovl_connect_layer()
116 if (ovl_dentry_test_flag(OVL_E_CONNECTED, dentry)) in ovl_connect_layer()
120 next = dget(dentry); in ovl_connect_layer()
150 ovl_dentry_set_flag(OVL_E_CONNECTED, dentry); in ovl_connect_layer()
183 static int ovl_check_encode_origin(struct dentry *dentry) in ovl_check_encode_origin() argument
185 struct ovl_fs *ofs = dentry->d_sb->s_fs_info; in ovl_check_encode_origin()
188 if (!ovl_dentry_lower(dentry)) in ovl_check_encode_origin()
197 if (ovl_dentry_upper(dentry) && in ovl_check_encode_origin()
198 !ovl_test_flag(OVL_INDEX, d_inode(dentry))) in ovl_check_encode_origin()
207 if (d_is_dir(dentry) && ovl_upper_mnt(ofs)) in ovl_check_encode_origin()
208 return ovl_connect_layer(dentry); in ovl_check_encode_origin()
214 static int ovl_dentry_to_fid(struct dentry *dentry, u32 *fid, int buflen) in ovl_dentry_to_fid() argument
224 err = enc_lower = ovl_check_encode_origin(dentry); in ovl_dentry_to_fid()
229 fh = ovl_encode_real_fh(enc_lower ? ovl_dentry_lower(dentry) : in ovl_dentry_to_fid()
230 ovl_dentry_upper(dentry), !enc_lower); in ovl_dentry_to_fid()
245 dentry, err); in ovl_dentry_to_fid()
252 struct dentry *dentry; in ovl_encode_fh() local
259 dentry = d_find_any_alias(inode); in ovl_encode_fh()
260 if (!dentry) in ovl_encode_fh()
263 bytes = ovl_dentry_to_fid(dentry, fid, buflen); in ovl_encode_fh()
264 dput(dentry); in ovl_encode_fh()
278 static struct dentry *ovl_obtain_alias(struct super_block *sb, in ovl_obtain_alias()
279 struct dentry *upper_alias, in ovl_obtain_alias()
281 struct dentry *index) in ovl_obtain_alias()
283 struct dentry *lower = lowerpath ? lowerpath->dentry : NULL; in ovl_obtain_alias()
284 struct dentry *upper = upper_alias ?: index; in ovl_obtain_alias()
285 struct dentry *dentry; in ovl_obtain_alias() local
308 dentry = d_find_any_alias(inode); in ovl_obtain_alias()
309 if (dentry) in ovl_obtain_alias()
312 dentry = d_alloc_anon(inode->i_sb); in ovl_obtain_alias()
313 if (unlikely(!dentry)) in ovl_obtain_alias()
320 oe->lowerstack->dentry = dget(lower); in ovl_obtain_alias()
323 dentry->d_fsdata = oe; in ovl_obtain_alias()
325 ovl_dentry_set_upper_alias(dentry); in ovl_obtain_alias()
327 ovl_dentry_update_reval(dentry, upper, in ovl_obtain_alias()
330 return d_instantiate_anon(dentry, inode); in ovl_obtain_alias()
333 dput(dentry); in ovl_obtain_alias()
334 dentry = ERR_PTR(-ENOMEM); in ovl_obtain_alias()
337 return dentry; in ovl_obtain_alias()
341 static struct dentry *ovl_dentry_real_at(struct dentry *dentry, int idx) in ovl_dentry_real_at() argument
343 struct ovl_entry *oe = dentry->d_fsdata; in ovl_dentry_real_at()
347 return ovl_dentry_upper(dentry); in ovl_dentry_real_at()
351 return oe->lowerstack[i].dentry; in ovl_dentry_real_at()
363 static struct dentry *ovl_lookup_real_one(struct dentry *connected, in ovl_lookup_real_one()
364 struct dentry *real, in ovl_lookup_real_one()
368 struct dentry *this, *parent = NULL; in ovl_lookup_real_one()
419 static struct dentry *ovl_lookup_real(struct super_block *sb,
420 struct dentry *real,
426 static struct dentry *ovl_lookup_real_inode(struct super_block *sb, in ovl_lookup_real_inode()
427 struct dentry *real, in ovl_lookup_real_inode()
431 struct dentry *index = NULL; in ovl_lookup_real_inode()
432 struct dentry *this = NULL; in ovl_lookup_real_inode()
459 struct dentry *upper = ovl_index_upper(ofs, index); in ovl_lookup_real_inode()
491 static struct dentry *ovl_lookup_real_ancestor(struct super_block *sb, in ovl_lookup_real_ancestor()
492 struct dentry *real, in ovl_lookup_real_ancestor()
495 struct dentry *next, *parent = NULL; in ovl_lookup_real_ancestor()
496 struct dentry *ancestor = ERR_PTR(-EIO); in ovl_lookup_real_ancestor()
544 static struct dentry *ovl_lookup_real(struct super_block *sb, in ovl_lookup_real()
545 struct dentry *real, in ovl_lookup_real()
548 struct dentry *connected; in ovl_lookup_real()
556 struct dentry *next, *this; in ovl_lookup_real()
557 struct dentry *parent = NULL; in ovl_lookup_real()
558 struct dentry *real_connected = ovl_dentry_real_at(connected, in ovl_lookup_real()
646 static struct dentry *ovl_get_dentry(struct super_block *sb, in ovl_get_dentry()
647 struct dentry *upper, in ovl_get_dentry()
649 struct dentry *index) in ovl_get_dentry()
653 struct dentry *real = upper ?: (index ?: lowerpath->dentry); in ovl_get_dentry()
673 static struct dentry *ovl_upper_fh_to_d(struct super_block *sb, in ovl_upper_fh_to_d()
677 struct dentry *dentry; in ovl_upper_fh_to_d() local
678 struct dentry *upper; in ovl_upper_fh_to_d()
687 dentry = ovl_get_dentry(sb, upper, NULL, NULL); in ovl_upper_fh_to_d()
690 return dentry; in ovl_upper_fh_to_d()
693 static struct dentry *ovl_lower_fh_to_d(struct super_block *sb, in ovl_lower_fh_to_d()
699 struct dentry *dentry = NULL; in ovl_lower_fh_to_d() local
700 struct dentry *index = NULL; in ovl_lower_fh_to_d()
709 if (!d_is_dir(origin.dentry) || in ovl_lower_fh_to_d()
710 !(origin.dentry->d_flags & DCACHE_DISCONNECTED)) { in ovl_lower_fh_to_d()
711 inode = ovl_lookup_inode(sb, origin.dentry, false); in ovl_lower_fh_to_d()
716 dentry = d_find_any_alias(inode); in ovl_lower_fh_to_d()
718 if (dentry) in ovl_lower_fh_to_d()
735 struct dentry *upper = ovl_index_upper(ofs, index); in ovl_lower_fh_to_d()
741 dentry = ovl_get_dentry(sb, upper, NULL, NULL); in ovl_lower_fh_to_d()
747 if (d_is_dir(origin.dentry)) { in ovl_lower_fh_to_d()
748 dput(origin.dentry); in ovl_lower_fh_to_d()
749 origin.dentry = NULL; in ovl_lower_fh_to_d()
755 err = ovl_verify_origin(ofs, index, origin.dentry, false); in ovl_lower_fh_to_d()
761 dentry = ovl_get_dentry(sb, NULL, &origin, index); in ovl_lower_fh_to_d()
764 dput(origin.dentry); in ovl_lower_fh_to_d()
766 return dentry; in ovl_lower_fh_to_d()
769 dentry = ERR_PTR(err); in ovl_lower_fh_to_d()
796 static struct dentry *ovl_fh_to_dentry(struct super_block *sb, struct fid *fid, in ovl_fh_to_dentry()
799 struct dentry *dentry = NULL; in ovl_fh_to_dentry() local
815 dentry = (flags & OVL_FH_FLAG_PATH_UPPER) ? in ovl_fh_to_dentry()
818 err = PTR_ERR(dentry); in ovl_fh_to_dentry()
819 if (IS_ERR(dentry) && err != -ESTALE) in ovl_fh_to_dentry()
827 return dentry; in ovl_fh_to_dentry()
832 dentry = ERR_PTR(err); in ovl_fh_to_dentry()
836 static struct dentry *ovl_fh_to_parent(struct super_block *sb, struct fid *fid, in ovl_fh_to_parent()
843 static int ovl_get_name(struct dentry *parent, char *name, in ovl_get_name()
844 struct dentry *child) in ovl_get_name()
854 static struct dentry *ovl_get_parent(struct dentry *dentry) in ovl_get_parent() argument