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) && ofs->upper_mnt) in ovl_check_encode_origin()
208 return ovl_connect_layer(dentry); in ovl_check_encode_origin()
214 static int ovl_d_to_fh(struct dentry *dentry, char *buf, int buflen) in ovl_d_to_fh() argument
223 err = enc_lower = ovl_check_encode_origin(dentry); in ovl_d_to_fh()
228 fh = ovl_encode_real_fh(enc_lower ? ovl_dentry_lower(dentry) : in ovl_d_to_fh()
229 ovl_dentry_upper(dentry), !enc_lower); in ovl_d_to_fh()
246 dentry, err, buflen, fh ? (int)fh->len : 0, in ovl_d_to_fh()
251 static int ovl_dentry_to_fh(struct dentry *dentry, u32 *fid, int *max_len) in ovl_dentry_to_fh() argument
255 res = ovl_d_to_fh(dentry, (char *)fid, len); in ovl_dentry_to_fh()
269 struct dentry *dentry; in ovl_encode_fh() local
276 dentry = d_find_any_alias(inode); in ovl_encode_fh()
277 if (WARN_ON(!dentry)) in ovl_encode_fh()
280 type = ovl_dentry_to_fh(dentry, fid, max_len); in ovl_encode_fh()
282 dput(dentry); in ovl_encode_fh()
289 static struct dentry *ovl_obtain_alias(struct super_block *sb, in ovl_obtain_alias()
290 struct dentry *upper_alias, in ovl_obtain_alias()
292 struct dentry *index) in ovl_obtain_alias()
294 struct dentry *lower = lowerpath ? lowerpath->dentry : NULL; in ovl_obtain_alias()
295 struct dentry *upper = upper_alias ?: index; in ovl_obtain_alias()
296 struct dentry *dentry; in ovl_obtain_alias() local
319 dentry = d_find_any_alias(inode); in ovl_obtain_alias()
320 if (!dentry) { in ovl_obtain_alias()
321 dentry = d_alloc_anon(inode->i_sb); in ovl_obtain_alias()
322 if (!dentry) in ovl_obtain_alias()
329 oe->lowerstack->dentry = dget(lower); in ovl_obtain_alias()
332 dentry->d_fsdata = oe; in ovl_obtain_alias()
334 ovl_dentry_set_upper_alias(dentry); in ovl_obtain_alias()
337 return d_instantiate_anon(dentry, inode); in ovl_obtain_alias()
341 dput(dentry); in ovl_obtain_alias()
346 static struct dentry *ovl_dentry_real_at(struct dentry *dentry, int idx) in ovl_dentry_real_at() argument
348 struct ovl_entry *oe = dentry->d_fsdata; in ovl_dentry_real_at()
352 return ovl_dentry_upper(dentry); in ovl_dentry_real_at()
356 return oe->lowerstack[i].dentry; in ovl_dentry_real_at()
368 static struct dentry *ovl_lookup_real_one(struct dentry *connected, in ovl_lookup_real_one()
369 struct dentry *real, in ovl_lookup_real_one()
373 struct dentry *this, *parent = NULL; in ovl_lookup_real_one()
424 static struct dentry *ovl_lookup_real(struct super_block *sb,
425 struct dentry *real,
431 static struct dentry *ovl_lookup_real_inode(struct super_block *sb, in ovl_lookup_real_inode()
432 struct dentry *real, in ovl_lookup_real_inode()
437 struct dentry *index = NULL; in ovl_lookup_real_inode()
438 struct dentry *this = NULL; in ovl_lookup_real_inode()
465 struct dentry *upper = ovl_index_upper(ofs, index); in ovl_lookup_real_inode()
497 static struct dentry *ovl_lookup_real_ancestor(struct super_block *sb, in ovl_lookup_real_ancestor()
498 struct dentry *real, in ovl_lookup_real_ancestor()
501 struct dentry *next, *parent = NULL; in ovl_lookup_real_ancestor()
502 struct dentry *ancestor = ERR_PTR(-EIO); in ovl_lookup_real_ancestor()
550 static struct dentry *ovl_lookup_real(struct super_block *sb, in ovl_lookup_real()
551 struct dentry *real, in ovl_lookup_real()
554 struct dentry *connected; in ovl_lookup_real()
562 struct dentry *next, *this; in ovl_lookup_real()
563 struct dentry *parent = NULL; in ovl_lookup_real()
564 struct dentry *real_connected = ovl_dentry_real_at(connected, in ovl_lookup_real()
652 static struct dentry *ovl_get_dentry(struct super_block *sb, in ovl_get_dentry()
653 struct dentry *upper, in ovl_get_dentry()
655 struct dentry *index) in ovl_get_dentry()
660 struct dentry *real = upper ?: (index ?: lowerpath->dentry); in ovl_get_dentry()
680 static struct dentry *ovl_upper_fh_to_d(struct super_block *sb, in ovl_upper_fh_to_d()
684 struct dentry *dentry; in ovl_upper_fh_to_d() local
685 struct dentry *upper; in ovl_upper_fh_to_d()
694 dentry = ovl_get_dentry(sb, upper, NULL, NULL); in ovl_upper_fh_to_d()
697 return dentry; in ovl_upper_fh_to_d()
700 static struct dentry *ovl_lower_fh_to_d(struct super_block *sb, in ovl_lower_fh_to_d()
706 struct dentry *dentry = NULL; in ovl_lower_fh_to_d() local
707 struct dentry *index = NULL; in ovl_lower_fh_to_d()
716 if (!d_is_dir(origin.dentry) || in ovl_lower_fh_to_d()
717 !(origin.dentry->d_flags & DCACHE_DISCONNECTED)) { in ovl_lower_fh_to_d()
718 inode = ovl_lookup_inode(sb, origin.dentry, false); in ovl_lower_fh_to_d()
723 dentry = d_find_any_alias(inode); in ovl_lower_fh_to_d()
725 if (dentry) in ovl_lower_fh_to_d()
742 struct dentry *upper = ovl_index_upper(ofs, index); in ovl_lower_fh_to_d()
748 dentry = ovl_get_dentry(sb, upper, NULL, NULL); in ovl_lower_fh_to_d()
754 if (d_is_dir(origin.dentry)) { in ovl_lower_fh_to_d()
755 dput(origin.dentry); in ovl_lower_fh_to_d()
756 origin.dentry = NULL; in ovl_lower_fh_to_d()
762 err = ovl_verify_origin(index, origin.dentry, false); in ovl_lower_fh_to_d()
768 dentry = ovl_get_dentry(sb, NULL, &origin, index); in ovl_lower_fh_to_d()
771 dput(origin.dentry); in ovl_lower_fh_to_d()
773 return dentry; in ovl_lower_fh_to_d()
776 dentry = ERR_PTR(err); in ovl_lower_fh_to_d()
780 static struct dentry *ovl_fh_to_dentry(struct super_block *sb, struct fid *fid, in ovl_fh_to_dentry()
783 struct dentry *dentry = NULL; in ovl_fh_to_dentry() local
798 dentry = (flags & OVL_FH_FLAG_PATH_UPPER) ? in ovl_fh_to_dentry()
801 err = PTR_ERR(dentry); in ovl_fh_to_dentry()
802 if (IS_ERR(dentry) && err != -ESTALE) in ovl_fh_to_dentry()
805 return dentry; in ovl_fh_to_dentry()
813 static struct dentry *ovl_fh_to_parent(struct super_block *sb, struct fid *fid, in ovl_fh_to_parent()
820 static int ovl_get_name(struct dentry *parent, char *name, in ovl_get_name()
821 struct dentry *child) in ovl_get_name()
831 static struct dentry *ovl_get_parent(struct dentry *dentry) in ovl_get_parent() argument