Lines Matching refs:index
188 * index entries correctly.
551 /* Get upper dentry from index */
552 struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index,
558 if (!d_is_dir(index))
559 return dget(index);
561 fh = ovl_get_fh(ofs, index, OVL_XATTR_UPPER);
572 pr_warn_ratelimited("invalid index upper (%pd2, upper=%pd2).\n",
573 index, upper);
582 * Verify that an index entry name matches the origin file handle stored in
586 int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index)
595 if (!d_inode(index))
599 if (index->d_name.len < sizeof(struct ovl_fb)*2)
603 len = index->d_name.len / 2;
609 if (hex2bin(fh->buf, index->d_name.name, len))
617 * Whiteout index entries are used as an indication that an exported
621 if (ovl_is_whiteout(index))
625 * Verifying directory index entries are not stale is expensive, so
626 * only verify stale dir index if NFS export is enabled.
628 if (d_is_dir(index) && !ofs->config.nfs_export)
632 * Directory index entries should have 'upper' xattr pointing to the
633 * real upper dir. Non-dir index entries are hardlinks to the upper
634 * real inode. For non-dir index, we can read the copy up origin xattr
635 * directly from the index dentry, but for dir index we first need to
638 upper = ovl_index_upper(ofs, index, false);
642 * Directory index entries with no 'upper' xattr need to be
643 * removed. When dir index entry has a stale 'upper' xattr,
645 * index as orphan entry that needs to be whited out.
659 /* Check if non-dir index is orphan and don't warn before cleaning it */
660 if (!d_is_dir(index) && d_inode(index)->i_nlink == 1) {
661 err = ovl_check_origin_fh(ofs, fh, false, index, &stack);
665 if (ovl_get_nlink(ofs, origin.dentry, index, 0) == 0)
675 pr_warn_ratelimited("failed to verify index (%pd2, ftype=%x, err=%i)\n",
676 index, d_inode(index)->i_mode & S_IFMT, err);
680 pr_warn_ratelimited("orphan index entry (%pd2, ftype=%x, nlink=%u)\n",
681 index, d_inode(index)->i_mode & S_IFMT,
682 d_inode(index)->i_nlink);
703 * Lookup in indexdir for the index entry of a lower real inode or a copy up
704 * origin inode. The index entry name is the hex representation of the lower
707 * If the index dentry in negative, then either no lower aliases have been
711 * If the index dentry for a copy up origin inode is positive, but points
714 * index dir was cleared. Either way, that index cannot be used to identify
733 /* Lookup index by file handle for NFS export */
736 struct dentry *index;
744 index = lookup_positive_unlocked(name.name, ofs->indexdir, name.len);
746 if (IS_ERR(index)) {
747 if (PTR_ERR(index) == -ENOENT)
748 index = NULL;
749 return index;
752 if (ovl_is_whiteout(index))
754 else if (ovl_dentry_weird(index))
757 return index;
759 dput(index);
766 struct dentry *index;
776 index = lookup_one_positive_unlocked(ovl_upper_mnt_idmap(ofs), name.name,
778 if (IS_ERR(index)) {
779 err = PTR_ERR(index);
781 index = NULL;
784 pr_warn_ratelimited("failed inode index lookup (ino=%lu, key=%.*s, err=%i);\n"
785 "overlayfs: mount with '-o index=off' to disable inodes index.\n",
791 inode = d_inode(index);
792 if (ovl_is_whiteout(index) && !verify) {
794 * When index lookup is called with !verify for decoding an
795 * overlay file handle, a whiteout index implies that decode
799 dput(index);
800 index = ERR_PTR(-ESTALE);
802 } else if (ovl_dentry_weird(index) || ovl_is_whiteout(index) ||
806 * except for the case of a whiteout index. A whiteout
807 * index should only exist if all lower aliases have been
809 * whose index is a whiteout should be treated as an error.
811 pr_warn_ratelimited("bad index found (index=%pd2, ftype=%x, origin ftype=%x).\n",
812 index, d_inode(index)->i_mode & S_IFMT,
817 pr_warn_ratelimited("suspected uncovered redirected dir found (origin=%pd2, index=%pd2).\n",
818 origin, index);
822 /* Verify that dir index 'upper' xattr points to upper dir */
823 err = ovl_verify_upper(ofs, index, upper, false);
826 pr_warn_ratelimited("suspected multiply redirected dir found (upper=%pd2, origin=%pd2, index=%pd2).\n",
827 upper, origin, index);
836 return index;
839 dput(index);
840 index = NULL;
844 dput(index);
845 index = ERR_PTR(-EIO);
1011 struct dentry *index = NULL;
1124 * case, only verified origin is used for index lookup.
1126 * For non-dir dentry, if index=on, then ensure origin
1132 (!d.is_dir && ofs->config.index && origin_path))) {
1219 * Always lookup index if there is no-upperdentry.
1224 * For directories, lookup index by lower inode and verify it matches
1225 * upper inode. We only trust dir index if we verified that lower dir
1226 * matches origin, otherwise dir index entries may be inconsistent
1233 * For metacopy upper, we set a verified origin already if index
1242 index = ovl_lookup_index(ofs, upperdentry, origin, true);
1243 if (IS_ERR(index)) {
1244 err = PTR_ERR(index);
1245 index = NULL;
1264 else if (index) {
1266 .dentry = upperdentry = dget(index),
1292 .index = index,
1319 dput(index);
1327 dput(index);