Lines Matching +full:encode +full:- +full:only

1 // SPDX-License-Identifier: GPL-2.0-only
7 * Copyright (C) 2017-2018 CTERA Networks. All Rights Reserved.
33 pr_warn_ratelimited("failed to copy up on encode (%pd2, err=%i)\n", in ovl_encode_maybe_copy_up()
41 * Before encoding a non-upper directory file handle from real layer N, we need
59 * /a/b/c, which is "layer 2 connectable", on encode time. That ancestor is
82 if (dentry == dentry->d_sb->s_root) in ovl_connectable_layer()
83 return oe->numlower; in ovl_connectable_layer()
94 return oe->lowerstack[0].layer->idx; in ovl_connectable_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()
156 * We only need to encode origin if there is a chance that the same object was
158 * encoding also after copy up. If non-pure upper is not indexed, then it was
160 * about staying consistent with pre copy up encoding and we encode an upper
161 * file handle. Overlay root dentry is a private case of non-indexed upper.
167 * --------------------------------
169 * Non-indexed upper | U
171 * Non-upper | L (*)
177 * possible when there are redirects in lower layers and non-indexed merge dirs.
178 * To mitigate those case, we may copy up the lower dir ancestor before encode
185 struct ovl_fs *ofs = dentry->d_sb->s_fs_info; 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()
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()
222 * Check if we should encode a lower or upper file handle and maybe in ovl_dentry_to_fid()
229 /* Encode an upper or lower file handle */ in ovl_dentry_to_fid()
245 pr_warn_ratelimited("failed to encode file handle (%pd2, err=%i)\n", in ovl_dentry_to_fid()
253 struct ovl_fs *ofs = OVL_FS(inode->i_sb); in ovl_encode_fh()
257 /* TODO: encode connectable file handles */ in ovl_encode_fh()
285 struct dentry *lower = lowerpath ? lowerpath->dentry : NULL; in ovl_obtain_alias()
298 return ERR_PTR(-EIO); in ovl_obtain_alias()
314 dentry = d_alloc_anon(inode->i_sb); in ovl_obtain_alias()
322 oe->lowerstack->dentry = dget(lower); in ovl_obtain_alias()
323 oe->lowerstack->layer = lowerpath->layer; in ovl_obtain_alias()
325 dentry->d_fsdata = oe; in ovl_obtain_alias()
336 dentry = ERR_PTR(-ENOMEM); in ovl_obtain_alias()
345 struct ovl_entry *oe = dentry->d_fsdata; in ovl_dentry_real_at()
351 for (i = 0; i < oe->numlower; i++) { in ovl_dentry_real_at()
352 if (oe->lowerstack[i].layer->idx == idx) in ovl_dentry_real_at()
353 return oe->lowerstack[i].dentry; in ovl_dentry_real_at()
378 * connected overlay dir, we return -ECHILD and restart the lookup of in ovl_lookup_real_one()
382 err = -ECHILD; in ovl_lookup_real_one()
384 if (ovl_dentry_real_at(connected, layer->idx) != parent) in ovl_lookup_real_one()
390 * care about returning ESTALE, only from dereferencing a free name in ovl_lookup_real_one()
396 * permission checking altogether, but for now just use non-mnt_userns in ovl_lookup_real_one()
404 } else if (!this || !this->d_inode) { in ovl_lookup_real_one()
406 err = -ENOENT; in ovl_lookup_real_one()
408 } else if (ovl_dentry_real_at(this, layer->idx) != real) { in ovl_lookup_real_one()
410 err = -ESTALE; in ovl_lookup_real_one()
421 real, layer->idx, connected, err); in ovl_lookup_real_one()
437 struct ovl_fs *ofs = sb->s_fs_info; in ovl_lookup_real_inode()
446 inode = ovl_lookup_inode(sb, real, !layer->idx); in ovl_lookup_real_inode()
458 if (!this && layer->idx && ofs->indexdir && !WARN_ON(!d_is_dir(real))) { in ovl_lookup_real_inode()
479 this = ovl_lookup_real(sb, upper, &ofs->layers[0]); in ovl_lookup_real_inode()
486 if (ovl_dentry_real_at(this, layer->idx) != real) { in ovl_lookup_real_inode()
488 this = ERR_PTR(-EIO); in ovl_lookup_real_inode()
503 struct dentry *ancestor = ERR_PTR(-EIO); in ovl_lookup_real_ancestor()
505 if (real == layer->mnt->mnt_root) in ovl_lookup_real_ancestor()
506 return dget(sb->s_root); in ovl_lookup_real_ancestor()
521 if (parent == layer->mnt->mnt_root) { in ovl_lookup_real_ancestor()
522 ancestor = dget(sb->s_root); in ovl_lookup_real_ancestor()
532 ancestor = ERR_PTR(-EXDEV); in ovl_lookup_real_ancestor()
566 layer->idx); in ovl_lookup_real()
587 if (parent == layer->mnt->mnt_root) { in ovl_lookup_real()
589 connected = dget(sb->s_root); in ovl_lookup_real()
600 err = -EXDEV; in ovl_lookup_real()
623 if (err == -ECHILD) { in ovl_lookup_real()
645 real, layer->idx, connected, err); in ovl_lookup_real()
658 struct ovl_fs *ofs = sb->s_fs_info; in ovl_get_dentry()
659 const struct ovl_layer *layer = upper ? &ofs->layers[0] : lowerpath->layer; in ovl_get_dentry()
660 struct dentry *real = upper ?: (index ?: lowerpath->dentry); in ovl_get_dentry()
663 * Obtain a disconnected overlay dentry from a non-dir real dentry in ovl_get_dentry()
670 if ((real->d_flags & DCACHE_DISCONNECTED) || d_unhashed(real)) in ovl_get_dentry()
671 return ERR_PTR(-ENOENT); in ovl_get_dentry()
683 struct ovl_fs *ofs = sb->s_fs_info; in ovl_upper_fh_to_d()
688 return ERR_PTR(-EACCES); in ovl_upper_fh_to_d()
703 struct ovl_fs *ofs = sb->s_fs_info; in ovl_lower_fh_to_d()
717 !(origin.dentry->d_flags & DCACHE_DISCONNECTED)) { in ovl_lower_fh_to_d()
731 if (ofs->indexdir) { in ovl_lower_fh_to_d()
767 /* Get a connected non-upper dir or disconnected non-dir */ in ovl_lower_fh_to_d()
784 /* If on-wire inner fid is aligned - nothing to do */ in ovl_fid_to_fh()
789 return ERR_PTR(-EINVAL); in ovl_fid_to_fh()
792 return ERR_PTR(-EINVAL); in ovl_fid_to_fh()
796 return ERR_PTR(-ENOMEM); in ovl_fid_to_fh()
799 memcpy(&fh->fb, fid, buflen - OVL_FH_WIRE_OFFSET); in ovl_fid_to_fh()
821 flags = fh->fb.flags; in ovl_fh_to_dentry()
826 if (IS_ERR(dentry) && err != -ESTALE) in ovl_fh_to_dentry()
830 /* We may have needed to re-align OVL_FILEID_V0 */ in ovl_fh_to_dentry()
847 return ERR_PTR(-EACCES); in ovl_fh_to_parent()
858 return -EIO; in ovl_get_name()
868 return ERR_PTR(-EIO); in ovl_get_parent()