Lines Matching refs:dentry

19 static int ovl_encode_maybe_copy_up(struct dentry *dentry)
23 if (ovl_dentry_upper(dentry))
26 err = ovl_want_write(dentry);
28 err = ovl_copy_up(dentry);
29 ovl_drop_write(dentry);
34 dentry, err);
42 * to check if it will be possible to reconnect an overlay dentry from the real
43 * lower decoded dentry. This is done by following the overlay ancestry up to a
52 * The overlay dentry /a is NOT "layer 2 connectable", because if dir /a is
56 * dentry from the connected lower dentry /a/b/c.
61 * and when the time comes to decode the file handle from lower dentry /a/b/c,
63 * a connected overlay dentry will be accomplished.
77 static int ovl_connectable_layer(struct dentry *dentry)
79 struct ovl_entry *oe = OVL_E(dentry);
82 if (dentry == dentry->d_sb->s_root)
89 if (ovl_dentry_upper(dentry) &&
90 !ovl_test_flag(OVL_INDEX, d_inode(dentry)))
93 /* We can get upper/overlay path from indexed/lower dentry */
98 * @dentry is "connected" if all ancestors up to root or a "connected" ancestor
100 * copy up a "connectable" ancestor to make it "connected". A "connected" dentry
101 * cannot become non "connected", so cache positive result in dentry flags.
105 static int ovl_connect_layer(struct dentry *dentry)
107 struct dentry *next, *parent = NULL;
111 if (WARN_ON(dentry == dentry->d_sb->s_root) ||
112 WARN_ON(!ovl_dentry_lower(dentry)))
115 origin_layer = OVL_E(dentry)->lowerstack[0].layer->idx;
116 if (ovl_dentry_test_flag(OVL_E_CONNECTED, dentry))
119 /* Find the topmost origin layer connectable ancestor of @dentry */
120 next = dget(dentry);
150 ovl_dentry_set_flag(OVL_E_CONNECTED, dentry);
161 * file handle. Overlay root dentry is a private case of non-indexed upper.
176 * (*) Connecting an overlay dir from real lower dentry is not always
183 static int ovl_check_encode_origin(struct dentry *dentry)
185 struct ovl_fs *ofs = dentry->d_sb->s_fs_info;
188 if (!ovl_dentry_lower(dentry))
197 if (ovl_dentry_upper(dentry) &&
198 !ovl_test_flag(OVL_INDEX, d_inode(dentry)))
207 if (d_is_dir(dentry) && ovl_upper_mnt(ofs))
208 return ovl_connect_layer(dentry);
214 static int ovl_dentry_to_fid(struct dentry *dentry, u32 *fid, int buflen)
224 err = enc_lower = ovl_check_encode_origin(dentry);
229 fh = ovl_encode_real_fh(enc_lower ? ovl_dentry_lower(dentry) :
230 ovl_dentry_upper(dentry), !enc_lower);
245 dentry, err);
252 struct dentry *dentry;
259 dentry = d_find_any_alias(inode);
260 if (!dentry)
263 bytes = ovl_dentry_to_fid(dentry, fid, buflen);
264 dput(dentry);
276 * Find or instantiate an overlay dentry from real dentries and index.
278 static struct dentry *ovl_obtain_alias(struct super_block *sb,
279 struct dentry *upper_alias,
281 struct dentry *index)
283 struct dentry *lower = lowerpath ? lowerpath->dentry : NULL;
284 struct dentry *upper = upper_alias ?: index;
285 struct dentry *dentry;
308 dentry = d_find_any_alias(inode);
309 if (dentry)
312 dentry = d_alloc_anon(inode->i_sb);
313 if (unlikely(!dentry))
320 oe->lowerstack->dentry = dget(lower);
323 dentry->d_fsdata = oe;
325 ovl_dentry_set_upper_alias(dentry);
327 ovl_dentry_init_reval(dentry, upper);
329 return d_instantiate_anon(dentry, inode);
332 dput(dentry);
333 dentry = ERR_PTR(-ENOMEM);
336 return dentry;
339 /* Get the upper or lower dentry in stach whose on layer @idx */
340 static struct dentry *ovl_dentry_real_at(struct dentry *dentry, int idx)
342 struct ovl_entry *oe = dentry->d_fsdata;
346 return ovl_dentry_upper(dentry);
350 return oe->lowerstack[i].dentry;
357 * Lookup a child overlay dentry to get a connected overlay dentry whose real
358 * dentry is @real. If @real is on upper layer, we lookup a child overlay
359 * dentry with the same name as the real dentry. Otherwise, we need to consult
362 static struct dentry *ovl_lookup_real_one(struct dentry *connected,
363 struct dentry *real,
367 struct dentry *this, *parent = NULL;
372 * Lookup child overlay dentry by real name. The dir mutex protects us
373 * from racing with overlay rename. If the overlay dentry that is above
385 * We also need to take a snapshot of real dentry name to protect us
388 * pointer because we hold no lock on the real dentry.
418 static struct dentry *ovl_lookup_real(struct super_block *sb,
419 struct dentry *real,
423 * Lookup an indexed or hashed overlay dentry by real inode.
425 static struct dentry *ovl_lookup_real_inode(struct super_block *sb,
426 struct dentry *real,
430 struct dentry *index = NULL;
431 struct dentry *this = NULL;
436 * overlay dentry in inode/dcache.
458 struct dentry *upper = ovl_index_upper(ofs, index);
487 * Lookup an indexed or hashed overlay dentry, whose real dentry is an
490 static struct dentry *ovl_lookup_real_ancestor(struct super_block *sb,
491 struct dentry *real,
494 struct dentry *next, *parent = NULL;
495 struct dentry *ancestor = ERR_PTR(-EIO);
506 * Lookup a matching overlay dentry in inode/dentry
539 * Lookup a connected overlay dentry whose real dentry is @real.
540 * If @real is on upper layer, we lookup a child overlay dentry with the same
541 * path the real dentry. Otherwise, we need to consult index for lookup.
543 static struct dentry *ovl_lookup_real(struct super_block *sb,
544 struct dentry *real,
547 struct dentry *connected;
555 struct dentry *next, *this;
556 struct dentry *parent = NULL;
557 struct dentry *real_connected = ovl_dentry_real_at(connected,
563 /* Find the topmost dentry not yet connected */
643 * Get an overlay dentry from upper/lower real dentries and index.
645 static struct dentry *ovl_get_dentry(struct super_block *sb,
646 struct dentry *upper,
648 struct dentry *index)
652 struct dentry *real = upper ?: (index ?: lowerpath->dentry);
655 * Obtain a disconnected overlay dentry from a non-dir real dentry
666 * If real dentry is connected and hashed, get a connected overlay
667 * dentry whose real dentry is @real.
672 static struct dentry *ovl_upper_fh_to_d(struct super_block *sb,
676 struct dentry *dentry;
677 struct dentry *upper;
686 dentry = ovl_get_dentry(sb, upper, NULL, NULL);
689 return dentry;
692 static struct dentry *ovl_lower_fh_to_d(struct super_block *sb,
698 struct dentry *dentry = NULL;
699 struct dentry *index = NULL;
708 if (!d_is_dir(origin.dentry) ||
709 !(origin.dentry->d_flags & DCACHE_DISCONNECTED)) {
710 inode = ovl_lookup_inode(sb, origin.dentry, false);
715 dentry = d_find_any_alias(inode);
717 if (dentry)
734 struct dentry *upper = ovl_index_upper(ofs, index);
740 dentry = ovl_get_dentry(sb, upper, NULL, NULL);
745 /* Find origin.dentry again with ovl_acceptable() layer check */
746 if (d_is_dir(origin.dentry)) {
747 dput(origin.dentry);
748 origin.dentry = NULL;
754 err = ovl_verify_origin(ofs, index, origin.dentry, false);
760 dentry = ovl_get_dentry(sb, NULL, &origin, index);
763 dput(origin.dentry);
765 return dentry;
768 dentry = ERR_PTR(err);
795 static struct dentry *ovl_fh_to_dentry(struct super_block *sb, struct fid *fid,
798 struct dentry *dentry = NULL;
814 dentry = (flags & OVL_FH_FLAG_PATH_UPPER) ?
817 err = PTR_ERR(dentry);
818 if (IS_ERR(dentry) && err != -ESTALE)
826 return dentry;
831 dentry = ERR_PTR(err);
835 static struct dentry *ovl_fh_to_parent(struct super_block *sb, struct fid *fid,
842 static int ovl_get_name(struct dentry *parent, char *name,
843 struct dentry *child)
853 static struct dentry *ovl_get_parent(struct dentry *dentry)