Lines Matching refs:dentry
22 static int ovl_encode_maybe_copy_up(struct dentry *dentry) in ovl_encode_maybe_copy_up() argument
26 if (ovl_dentry_upper(dentry)) in ovl_encode_maybe_copy_up()
29 err = ovl_want_write(dentry); in ovl_encode_maybe_copy_up()
31 err = ovl_copy_up(dentry); in ovl_encode_maybe_copy_up()
32 ovl_drop_write(dentry); in ovl_encode_maybe_copy_up()
37 dentry, err); in ovl_encode_maybe_copy_up()
80 static int ovl_connectable_layer(struct dentry *dentry) in ovl_connectable_layer() argument
82 struct ovl_entry *oe = OVL_E(dentry); in ovl_connectable_layer()
85 if (dentry == dentry->d_sb->s_root) in ovl_connectable_layer()
92 if (ovl_dentry_upper(dentry) && in ovl_connectable_layer()
93 !ovl_test_flag(OVL_INDEX, d_inode(dentry))) in ovl_connectable_layer()
108 static int ovl_connect_layer(struct dentry *dentry) in ovl_connect_layer() argument
110 struct dentry *next, *parent = NULL; in ovl_connect_layer()
114 if (WARN_ON(dentry == dentry->d_sb->s_root) || in ovl_connect_layer()
115 WARN_ON(!ovl_dentry_lower(dentry))) in ovl_connect_layer()
118 origin_layer = OVL_E(dentry)->lowerstack[0].layer->idx; in ovl_connect_layer()
119 if (ovl_dentry_test_flag(OVL_E_CONNECTED, dentry)) in ovl_connect_layer()
123 next = dget(dentry); in ovl_connect_layer()
153 ovl_dentry_set_flag(OVL_E_CONNECTED, dentry); in ovl_connect_layer()
186 static int ovl_check_encode_origin(struct dentry *dentry) in ovl_check_encode_origin() argument
188 struct ovl_fs *ofs = dentry->d_sb->s_fs_info; in ovl_check_encode_origin()
191 if (!ovl_dentry_lower(dentry)) in ovl_check_encode_origin()
200 if (ovl_dentry_upper(dentry) && in ovl_check_encode_origin()
201 !ovl_test_flag(OVL_INDEX, d_inode(dentry))) in ovl_check_encode_origin()
210 if (d_is_dir(dentry) && ofs->upper_mnt) in ovl_check_encode_origin()
211 return ovl_connect_layer(dentry); in ovl_check_encode_origin()
217 static int ovl_d_to_fh(struct dentry *dentry, char *buf, int buflen) in ovl_d_to_fh() argument
226 err = enc_lower = ovl_check_encode_origin(dentry); in ovl_d_to_fh()
231 fh = ovl_encode_real_fh(enc_lower ? ovl_dentry_lower(dentry) : in ovl_d_to_fh()
232 ovl_dentry_upper(dentry), !enc_lower); in ovl_d_to_fh()
250 dentry, err, buflen, fh ? (int)fh->len : 0, in ovl_d_to_fh()
255 static int ovl_dentry_to_fh(struct dentry *dentry, u32 *fid, int *max_len) in ovl_dentry_to_fh() argument
259 res = ovl_d_to_fh(dentry, (char *)fid, len); in ovl_dentry_to_fh()
273 struct dentry *dentry; in ovl_encode_fh() local
280 dentry = d_find_any_alias(inode); in ovl_encode_fh()
281 if (WARN_ON(!dentry)) in ovl_encode_fh()
284 type = ovl_dentry_to_fh(dentry, fid, max_len); in ovl_encode_fh()
286 dput(dentry); in ovl_encode_fh()
293 static struct dentry *ovl_obtain_alias(struct super_block *sb, in ovl_obtain_alias()
294 struct dentry *upper_alias, in ovl_obtain_alias()
296 struct dentry *index) in ovl_obtain_alias()
298 struct dentry *lower = lowerpath ? lowerpath->dentry : NULL; in ovl_obtain_alias()
299 struct dentry *upper = upper_alias ?: index; in ovl_obtain_alias()
300 struct dentry *dentry; in ovl_obtain_alias() local
323 dentry = d_find_any_alias(inode); in ovl_obtain_alias()
324 if (!dentry) { in ovl_obtain_alias()
325 dentry = d_alloc_anon(inode->i_sb); in ovl_obtain_alias()
326 if (!dentry) in ovl_obtain_alias()
333 oe->lowerstack->dentry = dget(lower); in ovl_obtain_alias()
336 dentry->d_fsdata = oe; in ovl_obtain_alias()
338 ovl_dentry_set_upper_alias(dentry); in ovl_obtain_alias()
341 return d_instantiate_anon(dentry, inode); in ovl_obtain_alias()
345 dput(dentry); in ovl_obtain_alias()
350 static struct dentry *ovl_dentry_real_at(struct dentry *dentry, int idx) in ovl_dentry_real_at() argument
352 struct ovl_entry *oe = dentry->d_fsdata; in ovl_dentry_real_at()
356 return ovl_dentry_upper(dentry); in ovl_dentry_real_at()
360 return oe->lowerstack[i].dentry; in ovl_dentry_real_at()
372 static struct dentry *ovl_lookup_real_one(struct dentry *connected, in ovl_lookup_real_one()
373 struct dentry *real, in ovl_lookup_real_one()
377 struct dentry *this, *parent = NULL; in ovl_lookup_real_one()
428 static struct dentry *ovl_lookup_real(struct super_block *sb,
429 struct dentry *real,
435 static struct dentry *ovl_lookup_real_inode(struct super_block *sb, in ovl_lookup_real_inode()
436 struct dentry *real, in ovl_lookup_real_inode()
441 struct dentry *index = NULL; in ovl_lookup_real_inode()
442 struct dentry *this = NULL; in ovl_lookup_real_inode()
469 struct dentry *upper = ovl_index_upper(ofs, index); in ovl_lookup_real_inode()
501 static struct dentry *ovl_lookup_real_ancestor(struct super_block *sb, in ovl_lookup_real_ancestor()
502 struct dentry *real, in ovl_lookup_real_ancestor()
505 struct dentry *next, *parent = NULL; in ovl_lookup_real_ancestor()
506 struct dentry *ancestor = ERR_PTR(-EIO); in ovl_lookup_real_ancestor()
554 static struct dentry *ovl_lookup_real(struct super_block *sb, in ovl_lookup_real()
555 struct dentry *real, in ovl_lookup_real()
558 struct dentry *connected; in ovl_lookup_real()
566 struct dentry *next, *this; in ovl_lookup_real()
567 struct dentry *parent = NULL; in ovl_lookup_real()
568 struct dentry *real_connected = ovl_dentry_real_at(connected, in ovl_lookup_real()
656 static struct dentry *ovl_get_dentry(struct super_block *sb, in ovl_get_dentry()
657 struct dentry *upper, in ovl_get_dentry()
659 struct dentry *index) in ovl_get_dentry()
664 struct dentry *real = upper ?: (index ?: lowerpath->dentry); in ovl_get_dentry()
684 static struct dentry *ovl_upper_fh_to_d(struct super_block *sb, in ovl_upper_fh_to_d()
688 struct dentry *dentry; in ovl_upper_fh_to_d() local
689 struct dentry *upper; in ovl_upper_fh_to_d()
698 dentry = ovl_get_dentry(sb, upper, NULL, NULL); in ovl_upper_fh_to_d()
701 return dentry; in ovl_upper_fh_to_d()
704 static struct dentry *ovl_lower_fh_to_d(struct super_block *sb, in ovl_lower_fh_to_d()
710 struct dentry *dentry = NULL; in ovl_lower_fh_to_d() local
711 struct dentry *index = NULL; in ovl_lower_fh_to_d()
720 if (!d_is_dir(origin.dentry) || in ovl_lower_fh_to_d()
721 !(origin.dentry->d_flags & DCACHE_DISCONNECTED)) { in ovl_lower_fh_to_d()
722 inode = ovl_lookup_inode(sb, origin.dentry, false); in ovl_lower_fh_to_d()
727 dentry = d_find_any_alias(inode); in ovl_lower_fh_to_d()
729 if (dentry) in ovl_lower_fh_to_d()
746 struct dentry *upper = ovl_index_upper(ofs, index); in ovl_lower_fh_to_d()
752 dentry = ovl_get_dentry(sb, upper, NULL, NULL); in ovl_lower_fh_to_d()
758 if (d_is_dir(origin.dentry) && in ovl_lower_fh_to_d()
759 (origin.dentry->d_flags & DCACHE_DISCONNECTED)) { in ovl_lower_fh_to_d()
760 dput(origin.dentry); in ovl_lower_fh_to_d()
761 origin.dentry = NULL; in ovl_lower_fh_to_d()
767 err = ovl_verify_origin(index, origin.dentry, false); in ovl_lower_fh_to_d()
772 dentry = ovl_get_dentry(sb, NULL, &origin, index); in ovl_lower_fh_to_d()
775 dput(origin.dentry); in ovl_lower_fh_to_d()
777 return dentry; in ovl_lower_fh_to_d()
780 dentry = ERR_PTR(err); in ovl_lower_fh_to_d()
784 static struct dentry *ovl_fh_to_dentry(struct super_block *sb, struct fid *fid, in ovl_fh_to_dentry()
787 struct dentry *dentry = NULL; in ovl_fh_to_dentry() local
802 dentry = (flags & OVL_FH_FLAG_PATH_UPPER) ? in ovl_fh_to_dentry()
805 err = PTR_ERR(dentry); in ovl_fh_to_dentry()
806 if (IS_ERR(dentry) && err != -ESTALE) in ovl_fh_to_dentry()
809 return dentry; in ovl_fh_to_dentry()
817 static struct dentry *ovl_fh_to_parent(struct super_block *sb, struct fid *fid, in ovl_fh_to_parent()
824 static int ovl_get_name(struct dentry *parent, char *name, in ovl_get_name()
825 struct dentry *child) in ovl_get_name()
835 static struct dentry *ovl_get_parent(struct dentry *dentry) in ovl_get_parent() argument