Lines Matching +full:0 +full:- +full:indexed
1 // SPDX-License-Identifier: GPL-2.0-only
7 * Copyright (C) 2017-2018 CTERA Networks. All Rights Reserved.
24 return 0; in ovl_encode_maybe_copy_up()
41 * Before encoding a non-upper directory file handle from real layer N, we need
53 * copied up and renamed, upper dir /a will be indexed by lower dir /a from
54 * layer 1. The dir /a from layer 2 will never be indexed, so the algorithm (*)
62 * ovl_lookup_real_ancestor() will find the indexed ancestor /a/b and decoding
66 * entry /a in the lower layers above layer N and find the indexed dir /a from
82 if (dentry == dentry->d_sb->s_root) in ovl_connectable_layer()
83 return oe->numlower; in ovl_connectable_layer()
91 return 0; in ovl_connectable_layer()
93 /* We can get upper/overlay path from indexed/lower dentry */ in ovl_connectable_layer()
94 return oe->lowerstack[0].layer->idx; in ovl_connectable_layer()
103 * Return the connected origin layer or < 0 on error.
109 int err = 0; in ovl_connect_layer()
111 if (WARN_ON(dentry == dentry->d_sb->s_root) || in ovl_connect_layer()
113 return -EIO; in ovl_connect_layer()
115 origin_layer = OVL_E(dentry)->lowerstack[0].layer->idx; in ovl_connect_layer()
124 err = -EIO; in ovl_connect_layer()
137 /* If @parent is connected or indexed we are done */ in ovl_connect_layer()
158 * encoding also after copy up. If non-pure upper is not indexed, then it was
161 * file handle. Overlay root dentry is a private case of non-indexed upper.
167 * --------------------------------
169 * Non-indexed upper | U
170 * Indexed upper | L (*)
171 * Non-upper | L (*)
177 * possible when there are redirects in lower layers and non-indexed merge dirs.
181 * Return 0 for upper file handle, > 0 for lower file handle or < 0 on error.
185 struct ovl_fs *ofs = dentry->d_sb->s_fs_info; in ovl_check_encode_origin()
189 return 0; in ovl_check_encode_origin()
192 * Upper file handle for non-indexed upper. in ovl_check_encode_origin()
194 * Root is never indexed, so if there's an upper layer, encode upper for in ovl_check_encode_origin()
199 return 0; in ovl_check_encode_origin()
203 * lower dir or under a non-indexed upper is not always possible. in ovl_check_encode_origin()
210 /* Lower file handle for indexed and non-upper dir/non-dir */ in ovl_check_encode_origin()
225 if (enc_lower < 0) in ovl_dentry_to_fid()
265 if (bytes <= 0) in ovl_encode_fh()
283 struct dentry *lower = lowerpath ? lowerpath->dentry : NULL; in ovl_obtain_alias()
296 return ERR_PTR(-EIO); in ovl_obtain_alias()
312 dentry = d_alloc_anon(inode->i_sb); in ovl_obtain_alias()
315 oe = ovl_alloc_entry(lower ? 1 : 0); in ovl_obtain_alias()
320 oe->lowerstack->dentry = dget(lower); in ovl_obtain_alias()
321 oe->lowerstack->layer = lowerpath->layer; in ovl_obtain_alias()
323 dentry->d_fsdata = oe; in ovl_obtain_alias()
334 dentry = ERR_PTR(-ENOMEM); in ovl_obtain_alias()
343 struct ovl_entry *oe = dentry->d_fsdata; in ovl_dentry_real_at()
349 for (i = 0; i < oe->numlower; i++) { in ovl_dentry_real_at()
350 if (oe->lowerstack[i].layer->idx == idx) in ovl_dentry_real_at()
351 return oe->lowerstack[i].dentry; in ovl_dentry_real_at()
376 * connected overlay dir, we return -ECHILD and restart the lookup of in ovl_lookup_real_one()
380 err = -ECHILD; in ovl_lookup_real_one()
382 if (ovl_dentry_real_at(connected, layer->idx) != parent) in ovl_lookup_real_one()
396 } else if (!this || !this->d_inode) { in ovl_lookup_real_one()
398 err = -ENOENT; in ovl_lookup_real_one()
400 } else if (ovl_dentry_real_at(this, layer->idx) != real) { in ovl_lookup_real_one()
402 err = -ESTALE; in ovl_lookup_real_one()
414 real, layer->idx, connected, err); in ovl_lookup_real_one()
424 * Lookup an indexed or hashed overlay dentry by real inode.
430 struct ovl_fs *ofs = sb->s_fs_info; in ovl_lookup_real_inode()
439 inode = ovl_lookup_inode(sb, real, !layer->idx); in ovl_lookup_real_inode()
451 if (!this && layer->idx && ofs->indexdir && !WARN_ON(!d_is_dir(real))) { in ovl_lookup_real_inode()
468 * back lower parents to the topmost indexed parent. The second in ovl_lookup_real_inode()
469 * recursive call walks back from indexed upper to the topmost in ovl_lookup_real_inode()
472 this = ovl_lookup_real(sb, upper, &ofs->layers[0]); in ovl_lookup_real_inode()
479 if (ovl_dentry_real_at(this, layer->idx) != real) { in ovl_lookup_real_inode()
481 this = ERR_PTR(-EIO); in ovl_lookup_real_inode()
488 * Lookup an indexed or hashed overlay dentry, whose real dentry is an
496 struct dentry *ancestor = ERR_PTR(-EIO); in ovl_lookup_real_ancestor()
498 if (real == layer->mnt->mnt_root) in ovl_lookup_real_ancestor()
499 return dget(sb->s_root); in ovl_lookup_real_ancestor()
501 /* Find the topmost indexed or hashed ancestor */ in ovl_lookup_real_ancestor()
514 if (parent == layer->mnt->mnt_root) { in ovl_lookup_real_ancestor()
515 ancestor = dget(sb->s_root); in ovl_lookup_real_ancestor()
525 ancestor = ERR_PTR(-EXDEV); in ovl_lookup_real_ancestor()
549 int err = 0; in ovl_lookup_real()
559 layer->idx); in ovl_lookup_real()
580 if (parent == layer->mnt->mnt_root) { in ovl_lookup_real()
582 connected = dget(sb->s_root); in ovl_lookup_real()
593 err = -EXDEV; in ovl_lookup_real()
616 if (err == -ECHILD) { in ovl_lookup_real()
638 real, layer->idx, connected, err); in ovl_lookup_real()
651 struct ovl_fs *ofs = sb->s_fs_info; in ovl_get_dentry()
652 const struct ovl_layer *layer = upper ? &ofs->layers[0] : lowerpath->layer; in ovl_get_dentry()
653 struct dentry *real = upper ?: (index ?: lowerpath->dentry); in ovl_get_dentry()
656 * Obtain a disconnected overlay dentry from a non-dir real dentry in ovl_get_dentry()
663 if ((real->d_flags & DCACHE_DISCONNECTED) || d_unhashed(real)) in ovl_get_dentry()
664 return ERR_PTR(-ENOENT); in ovl_get_dentry()
676 struct ovl_fs *ofs = sb->s_fs_info; in ovl_upper_fh_to_d()
681 return ERR_PTR(-EACCES); in ovl_upper_fh_to_d()
696 struct ovl_fs *ofs = sb->s_fs_info; in ovl_lower_fh_to_d()
710 !(origin.dentry->d_flags & DCACHE_DISCONNECTED)) { in ovl_lower_fh_to_d()
723 /* Then lookup indexed upper/whiteout by origin fh */ in ovl_lower_fh_to_d()
724 if (ofs->indexdir) { in ovl_lower_fh_to_d()
760 /* Get a connected non-upper dir or disconnected non-dir */ in ovl_lower_fh_to_d()
777 /* If on-wire inner fid is aligned - nothing to do */ in ovl_fid_to_fh()
782 return ERR_PTR(-EINVAL); in ovl_fid_to_fh()
785 return ERR_PTR(-EINVAL); in ovl_fid_to_fh()
789 return ERR_PTR(-ENOMEM); in ovl_fid_to_fh()
792 memcpy(&fh->fb, fid, buflen - OVL_FH_WIRE_OFFSET); in ovl_fid_to_fh()
802 unsigned int flags = 0; in ovl_fh_to_dentry()
814 flags = fh->fb.flags; in ovl_fh_to_dentry()
819 if (IS_ERR(dentry) && err != -ESTALE) in ovl_fh_to_dentry()
823 /* We may have needed to re-align OVL_FILEID_V0 */ in ovl_fh_to_dentry()
840 return ERR_PTR(-EACCES); in ovl_fh_to_parent()
851 return -EIO; in ovl_get_name()
861 return ERR_PTR(-EIO); in ovl_get_parent()