// SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2004-2005 Silicon Graphics, Inc. * All Rights Reserved.
*/ #include"xfs.h" #include"xfs_shared.h" #include"xfs_format.h" #include"xfs_log_format.h" #include"xfs_trans_resv.h" #include"xfs_mount.h" #include"xfs_dir2.h" #include"xfs_export.h" #include"xfs_inode.h" #include"xfs_trans.h" #include"xfs_inode_item.h" #include"xfs_icache.h" #include"xfs_pnfs.h"
/* * Note that we only accept fileids which are long enough rather than allow * the parent generation number to default to zero. XFS considers zero a * valid generation number not an invalid/wildcard value.
*/ staticint xfs_fileid_length(int fileid_type)
{ switch (fileid_type) { case FILEID_INO32_GEN: return 2; case FILEID_INO32_GEN_PARENT: return 4; case FILEID_INO32_GEN | XFS_FILEID_TYPE_64FLAG: return 3; case FILEID_INO32_GEN_PARENT | XFS_FILEID_TYPE_64FLAG: return 6;
} return FILEID_INVALID;
}
/* Directories don't need their parent encoded, they have ".." */ if (!parent)
fileid_type = FILEID_INO32_GEN; else
fileid_type = FILEID_INO32_GEN_PARENT;
/* * If the filesystem may contain 64bit inode numbers, we need * to use larger file handles that can represent them. * * While we only allocate inodes that do not fit into 32 bits any * large enough filesystem may contain them, thus the slightly * confusing looking conditional below.
*/ if (!xfs_has_small_inums(mp) || xfs_is_inode32(mp))
fileid_type |= XFS_FILEID_TYPE_64FLAG;
/* * Only encode if there is enough space given. In practice * this means we can't export a filesystem with 64bit inodes * over NFSv2 with the subtree_check export option; the other * seven combinations work. The real answer is "don't use v2".
*/
len = xfs_fileid_length(fileid_type); if (*max_len < len) {
*max_len = len; return FILEID_INVALID;
}
*max_len = len;
/* * NFS can sometimes send requests for ino 0. Fail them gracefully.
*/ if (ino == 0) return ERR_PTR(-ESTALE);
/* * The XFS_IGET_UNTRUSTED means that an invalid inode number is just * fine and not an indication of a corrupted filesystem as clients can * send invalid file handles and we have to handle it gracefully..
*/
error = xfs_iget(mp, NULL, ino, XFS_IGET_UNTRUSTED, 0, &ip); if (error) {
/* * EINVAL means the inode cluster doesn't exist anymore. * EFSCORRUPTED means the metadata pointing to the inode cluster * or the inode cluster itself is corrupt. This implies the * filehandle is stale, so we should translate it here. * We don't use ESTALE directly down the chain to not * confuse applications using bulkstat that expect EINVAL.
*/ switch (error) { case -EINVAL: case -ENOENT: case -EFSCORRUPTED:
error = -ESTALE; break; default: break;
} return ERR_PTR(error);
}
/* * Reload the incore unlinked list to avoid failure in inodegc. * Use an unlocked check here because unrecovered unlinked inodes * should be somewhat rare.
*/ if (xfs_inode_unlinked_incomplete(ip)) {
error = xfs_inode_reload_unlinked(ip); if (error) {
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
xfs_irele(ip); return ERR_PTR(error);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.