From: Christoph Hellwig Date: Wed, 17 Jul 2024 06:42:42 +0000 (+0200) Subject: xfs: merge xfs_imeta_dir_lookup into xfs_imeta_lookup_component X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=8e4108b0e9627212b4cd7f5cbff0b10a43f9eaad;p=users%2Fhch%2Fxfsprogs.git xfs: merge xfs_imeta_dir_lookup into xfs_imeta_lookup_component Source kernel commit: a0f9d3e6f7e57539d852f58abe4be20e8467cec5 No real need to keep these two separate. Signed-off-by: Christoph Hellwig --- diff --git a/libxfs/xfs_imeta.c b/libxfs/xfs_imeta.c index 312a6771d..0efdc3f7c 100644 --- a/libxfs/xfs_imeta.c +++ b/libxfs/xfs_imeta.c @@ -68,77 +68,53 @@ xfs_imeta_set_xname( } /* - * Look up the inode number and filetype for an exact name in a directory. + * Given a parent directory @dp and a metadata inode path component @xname, + * Look up the inode number in the directory, returning it in @ino. + * @xname.type must match the directory entry's ftype. + * * Caller must hold ILOCK_EXCL. */ static inline int -xfs_imeta_dir_lookup( +xfs_imeta_lookup_component( struct xfs_trans *tp, struct xfs_inode *dp, struct xfs_name *xname, xfs_ino_t *ino) { + struct xfs_mount *mp = dp->i_mount; struct xfs_da_args args = { .trans = tp, .dp = dp, - .geo = dp->i_mount->m_dir_geo, + .geo = mp->m_dir_geo, .name = xname->name, .namelen = xname->len, - .hashval = xfs_dir2_hashname(dp->i_mount, xname), + .hashval = xfs_dir2_hashname(mp, xname), .whichfork = XFS_DATA_FORK, .op_flags = XFS_DA_OP_OKNOENT, .owner = dp->i_ino, }; int error; - if (xfs_is_shutdown(dp->i_mount)) + if (!S_ISDIR(VFS_I(dp)->i_mode)) + goto corrupt; + if (xfs_is_shutdown(mp)) return -EIO; error = xfs_dir_lookup_args(&args); if (error) return error; - *ino = args.inumber; - xname->type = args.filetype; - return 0; -} + if (!xfs_verify_ino(mp, args.inumber)) + goto corrupt; + if (xname->type != XFS_DIR3_FT_UNKNOWN && xname->type != args.filetype) + goto corrupt; -/* - * Given a parent directory @dp and a metadata inode path component @xname, - * Look up the inode number in the directory, returning it in @ino. - * @xname.type must match the directory entry's ftype. - * - * Caller must hold ILOCK_EXCL. - */ -static inline int -xfs_imeta_lookup_component( - struct xfs_trans *tp, - struct xfs_inode *dp, - struct xfs_name *xname, - xfs_ino_t *ino) -{ - int type_wanted = xname->type; - int error; - - if (!S_ISDIR(VFS_I(dp)->i_mode)) { - xfs_fs_mark_sick(dp->i_mount, XFS_SICK_FS_METADIR); - return -EFSCORRUPTED; - } - - error = xfs_imeta_dir_lookup(tp, dp, xname, ino); - if (error) - return error; - if (!xfs_verify_ino(dp->i_mount, *ino)) { - xfs_fs_mark_sick(dp->i_mount, XFS_SICK_FS_METADIR); - return -EFSCORRUPTED; - } - if (type_wanted != XFS_DIR3_FT_UNKNOWN && xname->type != type_wanted) { - xfs_fs_mark_sick(dp->i_mount, XFS_SICK_FS_METADIR); - return -EFSCORRUPTED; - } - - trace_xfs_imeta_lookup_component(dp, xname, *ino); + trace_xfs_imeta_lookup_component(dp, xname, args.inumber); + *ino = args.inumber; return 0; +corrupt: + xfs_fs_mark_sick(mp, XFS_SICK_FS_METADIR); + return -EFSCORRUPTED; } /*