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()
91 return 0; in ovl_connectable_layer()
93 /* We can get upper/overlay path from indexed/lower dentry */ in ovl_connectable_layer()
94 return ovl_lowerstack(oe)->layer->idx; in ovl_connectable_layer()
103 * Return the connected origin layer or < 0 on error.
110 int err = 0; in ovl_connect_layer()
112 if (WARN_ON(dentry == dentry->d_sb->s_root) || in ovl_connect_layer()
114 return -EIO; in ovl_connect_layer()
116 origin_layer = ovl_lowerstack(oe)->layer->idx; in ovl_connect_layer()
125 err = -EIO; in ovl_connect_layer()
138 /* If @parent is connected or indexed we are done */ in ovl_connect_layer()
159 * encoding also after copy up. If non-pure upper is not indexed, then it was
162 * file handle. Overlay root dentry is a private case of non-indexed upper.
168 * --------------------------------
170 * Non-indexed upper | U
171 * Indexed upper | L (*)
172 * Non-upper | L (*)
178 * possible when there are redirects in lower layers and non-indexed merge dirs.
180 * of a decodable file handle for non-upper dir.
182 * Return 0 for upper file handle, > 0 for lower file handle or < 0 on error.
186 struct ovl_fs *ofs = OVL_FS(dentry->d_sb); in ovl_check_encode_origin()
187 bool decodable = ofs->config.nfs_export; in ovl_check_encode_origin()
193 /* Lower file handle for non-upper non-decodable */ in ovl_check_encode_origin()
199 return 0; in ovl_check_encode_origin()
202 * Root is never indexed, so if there's an upper layer, encode upper for in ovl_check_encode_origin()
205 if (dentry == dentry->d_sb->s_root) in ovl_check_encode_origin()
206 return 0; in ovl_check_encode_origin()
209 * Upper decodable file handle for non-indexed upper. in ovl_check_encode_origin()
213 return 0; in ovl_check_encode_origin()
217 * lower dir or under a non-indexed upper is not always possible. in ovl_check_encode_origin()
224 /* Lower file handle for indexed and non-upper dir/non-dir */ in ovl_check_encode_origin()
240 if (enc_lower < 0) in ovl_dentry_to_fid()
267 struct ovl_fs *ofs = OVL_FS(inode->i_sb); in ovl_encode_fh()
281 if (bytes <= 0) in ovl_encode_fh()
299 struct dentry *lower = lowerpath ? lowerpath->dentry : NULL; in ovl_obtain_alias()
310 return ERR_PTR(-EIO); in ovl_obtain_alias()
314 return ERR_PTR(-ENOMEM); in ovl_obtain_alias()
318 ovl_lowerstack(oe)->dentry = dget(lower); in ovl_obtain_alias()
319 ovl_lowerstack(oe)->layer = lowerpath->layer; in ovl_obtain_alias()
336 dentry = d_alloc_anon(inode->i_sb); in ovl_obtain_alias()
349 dentry = ERR_PTR(-ENOMEM); in ovl_obtain_alias()
365 for (i = 0; i < ovl_numlower(oe); i++) { in ovl_dentry_real_at()
366 if (lowerstack[i].layer->idx == idx) in ovl_dentry_real_at()
392 * connected overlay dir, we return -ECHILD and restart the lookup of in ovl_lookup_real_one()
396 err = -ECHILD; in ovl_lookup_real_one()
398 if (ovl_dentry_real_at(connected, layer->idx) != parent) in ovl_lookup_real_one()
410 * permission checking altogether, but for now just use non-idmap in ovl_lookup_real_one()
418 } else if (!this || !this->d_inode) { in ovl_lookup_real_one()
420 err = -ENOENT; in ovl_lookup_real_one()
422 } else if (ovl_dentry_real_at(this, layer->idx) != real) { in ovl_lookup_real_one()
424 err = -ESTALE; in ovl_lookup_real_one()
435 real, layer->idx, connected, err); in ovl_lookup_real_one()
445 * Lookup an indexed or hashed overlay dentry by real inode.
460 inode = ovl_lookup_inode(sb, real, !layer->idx); in ovl_lookup_real_inode()
472 if (!this && layer->idx && ofs->indexdir && !WARN_ON(!d_is_dir(real))) { in ovl_lookup_real_inode()
489 * back lower parents to the topmost indexed parent. The second in ovl_lookup_real_inode()
490 * recursive call walks back from indexed upper to the topmost in ovl_lookup_real_inode()
493 this = ovl_lookup_real(sb, upper, &ofs->layers[0]); in ovl_lookup_real_inode()
500 if (ovl_dentry_real_at(this, layer->idx) != real) { in ovl_lookup_real_inode()
502 this = ERR_PTR(-EIO); in ovl_lookup_real_inode()
509 * Lookup an indexed or hashed overlay dentry, whose real dentry is an
517 struct dentry *ancestor = ERR_PTR(-EIO); in ovl_lookup_real_ancestor()
519 if (real == layer->mnt->mnt_root) in ovl_lookup_real_ancestor()
520 return dget(sb->s_root); in ovl_lookup_real_ancestor()
522 /* Find the topmost indexed or hashed ancestor */ in ovl_lookup_real_ancestor()
535 if (parent == layer->mnt->mnt_root) { in ovl_lookup_real_ancestor()
536 ancestor = dget(sb->s_root); in ovl_lookup_real_ancestor()
546 ancestor = ERR_PTR(-EXDEV); in ovl_lookup_real_ancestor()
570 int err = 0; in ovl_lookup_real()
580 layer->idx); in ovl_lookup_real()
601 if (parent == layer->mnt->mnt_root) { in ovl_lookup_real()
603 connected = dget(sb->s_root); in ovl_lookup_real()
614 err = -EXDEV; in ovl_lookup_real()
637 if (err == -ECHILD) { in ovl_lookup_real()
659 real, layer->idx, connected, err); in ovl_lookup_real()
673 const struct ovl_layer *layer = upper ? &ofs->layers[0] : lowerpath->layer; in ovl_get_dentry()
674 struct dentry *real = upper ?: (index ?: lowerpath->dentry); in ovl_get_dentry()
677 * Obtain a disconnected overlay dentry from a non-dir real dentry in ovl_get_dentry()
684 if ((real->d_flags & DCACHE_DISCONNECTED) || d_unhashed(real)) in ovl_get_dentry()
685 return ERR_PTR(-ENOENT); in ovl_get_dentry()
702 return ERR_PTR(-EACCES); in ovl_upper_fh_to_d()
731 !(origin.dentry->d_flags & DCACHE_DISCONNECTED)) { in ovl_lower_fh_to_d()
744 /* Then lookup indexed upper/whiteout by origin fh */ in ovl_lower_fh_to_d()
745 if (ofs->indexdir) { in ovl_lower_fh_to_d()
781 /* Get a connected non-upper dir or disconnected non-dir */ in ovl_lower_fh_to_d()
798 /* If on-wire inner fid is aligned - nothing to do */ in ovl_fid_to_fh()
803 return ERR_PTR(-EINVAL); in ovl_fid_to_fh()
806 return ERR_PTR(-EINVAL); in ovl_fid_to_fh()
810 return ERR_PTR(-ENOMEM); in ovl_fid_to_fh()
813 memcpy(fh->buf, fid, buflen - OVL_FH_WIRE_OFFSET); in ovl_fid_to_fh()
823 unsigned int flags = 0; in ovl_fh_to_dentry()
835 flags = fh->fb.flags; in ovl_fh_to_dentry()
840 if (IS_ERR(dentry) && err != -ESTALE) in ovl_fh_to_dentry()
844 /* We may have needed to re-align OVL_FILEID_V0 */ in ovl_fh_to_dentry()
861 return ERR_PTR(-EACCES); in ovl_fh_to_parent()
872 return -EIO; in ovl_get_name()
882 return ERR_PTR(-EIO); in ovl_get_parent()
893 /* encode_fh() encodes non-decodable file handles with nfs_export=off */