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;
108 struct ovl_entry *oe = OVL_E(dentry);
112 if (WARN_ON(dentry == dentry->d_sb->s_root) ||
113 WARN_ON(!ovl_dentry_lower(dentry)))
117 if (ovl_dentry_test_flag(OVL_E_CONNECTED, dentry))
120 /* Find the topmost origin layer connectable ancestor of @dentry */
121 next = dget(dentry);
151 ovl_dentry_set_flag(OVL_E_CONNECTED, dentry);
162 * file handle. Overlay root dentry is a private case of non-indexed upper.
177 * (*) Decoding a connected overlay dir from real lower dentry is not always
184 static int ovl_check_encode_origin(struct dentry *dentry)
186 struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
190 if (!ovl_dentry_upper(dentry) && !decodable)
194 if (!ovl_dentry_lower(dentry))
201 if (dentry == dentry->d_sb->s_root)
207 if (ovl_dentry_upper(dentry) && decodable &&
208 !ovl_test_flag(OVL_INDEX, d_inode(dentry)))
217 if (d_is_dir(dentry) && ovl_upper_mnt(ofs) && decodable)
218 return ovl_connect_layer(dentry);
224 static int ovl_dentry_to_fid(struct ovl_fs *ofs, struct dentry *dentry,
235 err = enc_lower = ovl_check_encode_origin(dentry);
240 fh = ovl_encode_real_fh(ofs, enc_lower ? ovl_dentry_lower(dentry) :
241 ovl_dentry_upper(dentry), !enc_lower);
256 dentry, err);
264 struct dentry *dentry;
271 dentry = d_find_any_alias(inode);
272 if (!dentry)
275 bytes = ovl_dentry_to_fid(ofs, dentry, fid, buflen);
276 dput(dentry);
288 * Find or instantiate an overlay dentry from real dentries and index.
290 static struct dentry *ovl_obtain_alias(struct super_block *sb,
291 struct dentry *upper_alias,
293 struct dentry *index)
295 struct dentry *lower = lowerpath ? lowerpath->dentry : NULL;
296 struct dentry *upper = upper_alias ?: index;
297 struct dentry *dentry;
314 ovl_lowerstack(oe)->dentry = dget(lower);
328 dentry = d_find_any_alias(inode);
329 if (dentry)
332 dentry = d_alloc_anon(inode->i_sb);
333 if (unlikely(!dentry))
337 ovl_dentry_set_upper_alias(dentry);
339 ovl_dentry_init_reval(dentry, upper, OVL_I_E(inode));
341 return d_instantiate_anon(dentry, inode);
344 dput(dentry);
345 dentry = ERR_PTR(-ENOMEM);
348 return dentry;
351 /* Get the upper or lower dentry in stack whose on layer @idx */
352 static struct dentry *ovl_dentry_real_at(struct dentry *dentry, int idx)
354 struct ovl_entry *oe = OVL_E(dentry);
359 return ovl_dentry_upper(dentry);
363 return lowerstack[i].dentry;
370 * Lookup a child overlay dentry to get a connected overlay dentry whose real
371 * dentry is @real. If @real is on upper layer, we lookup a child overlay
372 * dentry with the same name as the real dentry. Otherwise, we need to consult
375 static struct dentry *ovl_lookup_real_one(struct dentry *connected,
376 struct dentry *real,
380 struct dentry *this, *parent = NULL;
385 * Lookup child overlay dentry by real name. The dir mutex protects us
386 * from racing with overlay rename. If the overlay dentry that is above
398 * We also need to take a snapshot of real dentry name to protect us
401 * pointer because we hold no lock on the real dentry.
436 static struct dentry *ovl_lookup_real(struct super_block *sb,
437 struct dentry *real,
441 * Lookup an indexed or hashed overlay dentry by real inode.
443 static struct dentry *ovl_lookup_real_inode(struct super_block *sb,
444 struct dentry *real,
448 struct dentry *index = NULL;
449 struct dentry *this = NULL;
454 * overlay dentry in inode/dcache.
476 struct dentry *upper = ovl_index_upper(ofs, index, true);
505 * Lookup an indexed or hashed overlay dentry, whose real dentry is an
508 static struct dentry *ovl_lookup_real_ancestor(struct super_block *sb,
509 struct dentry *real,
512 struct dentry *next, *parent = NULL;
513 struct dentry *ancestor = ERR_PTR(-EIO);
524 * Lookup a matching overlay dentry in inode/dentry
557 * Lookup a connected overlay dentry whose real dentry is @real.
558 * If @real is on upper layer, we lookup a child overlay dentry with the same
559 * path the real dentry. Otherwise, we need to consult index for lookup.
561 static struct dentry *ovl_lookup_real(struct super_block *sb,
562 struct dentry *real,
565 struct dentry *connected;
573 struct dentry *next, *this;
574 struct dentry *parent = NULL;
575 struct dentry *real_connected = ovl_dentry_real_at(connected,
581 /* Find the topmost dentry not yet connected */
661 * Get an overlay dentry from upper/lower real dentries and index.
663 static struct dentry *ovl_get_dentry(struct super_block *sb,
664 struct dentry *upper,
666 struct dentry *index)
670 struct dentry *real = upper ?: (index ?: lowerpath->dentry);
673 * Obtain a disconnected overlay dentry from a non-dir real dentry
684 * If real dentry is connected and hashed, get a connected overlay
685 * dentry whose real dentry is @real.
690 static struct dentry *ovl_upper_fh_to_d(struct super_block *sb,
694 struct dentry *dentry;
695 struct dentry *upper;
704 dentry = ovl_get_dentry(sb, upper, NULL, NULL);
707 return dentry;
710 static struct dentry *ovl_lower_fh_to_d(struct super_block *sb,
716 struct dentry *dentry = NULL;
717 struct dentry *index = NULL;
726 if (!d_is_dir(origin.dentry) ||
727 !(origin.dentry->d_flags & DCACHE_DISCONNECTED)) {
728 inode = ovl_lookup_inode(sb, origin.dentry, false);
733 dentry = d_find_any_alias(inode);
735 if (dentry)
752 struct dentry *upper = ovl_index_upper(ofs, index, true);
758 dentry = ovl_get_dentry(sb, upper, NULL, NULL);
763 /* Find origin.dentry again with ovl_acceptable() layer check */
764 if (d_is_dir(origin.dentry)) {
765 dput(origin.dentry);
766 origin.dentry = NULL;
772 err = ovl_verify_origin(ofs, index, origin.dentry, false);
778 dentry = ovl_get_dentry(sb, NULL, &origin, index);
781 dput(origin.dentry);
783 return dentry;
786 dentry = ERR_PTR(err);
813 static struct dentry *ovl_fh_to_dentry(struct super_block *sb, struct fid *fid,
816 struct dentry *dentry = NULL;
832 dentry = (flags & OVL_FH_FLAG_PATH_UPPER) ?
835 err = PTR_ERR(dentry);
836 if (IS_ERR(dentry) && err != -ESTALE)
844 return dentry;
849 dentry = ERR_PTR(err);
853 static struct dentry *ovl_fh_to_parent(struct super_block *sb, struct fid *fid,
860 static int ovl_get_name(struct dentry *parent, char *name,
861 struct dentry *child)
871 static struct dentry *ovl_get_parent(struct dentry *dentry)