From: Christoph Hellwig Date: Mon, 10 Aug 2020 20:32:06 +0000 (-0400) Subject: xfs: remove xfs_ifork_ops X-Git-Tag: v5.8.0-rc0~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1fecabf9cfe67d1d692196e169d800cf918a3360;p=thirdparty%2Fxfsprogs-dev.git xfs: remove xfs_ifork_ops Source kernel commit: 1934c8bd81bee4c239478b03a59addf5fe8e2785 xfs_ifork_ops add up to two indirect calls per inode read and flush, despite just having a single instance in the kernel. In xfsprogs phase6 in xfs_repair overrides the verify_dir method to deal with inodes that do not have a valid parent, but that can be fixed pretty easily by ensuring they always have a valid looking parent. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Eric Sandeen --- diff --git a/db/attrset.c b/db/attrset.c index b86ecec70..98a08a490 100644 --- a/db/attrset.c +++ b/db/attrset.c @@ -153,8 +153,7 @@ attr_set_f( memset(args.value, 'v', args.valuelen); } - if (libxfs_iget(mp, NULL, iocur_top->ino, 0, &args.dp, - &xfs_default_ifork_ops)) { + if (libxfs_iget(mp, NULL, iocur_top->ino, 0, &args.dp)) { dbprintf(_("failed to iget inode %llu\n"), (unsigned long long)iocur_top->ino); goto out; @@ -238,8 +237,7 @@ attr_remove_f( return 0; } - if (libxfs_iget(mp, NULL, iocur_top->ino, 0, &args.dp, - &xfs_default_ifork_ops)) { + if (libxfs_iget(mp, NULL, iocur_top->ino, 0, &args.dp)) { dbprintf(_("failed to iget inode %llu\n"), (unsigned long long)iocur_top->ino); goto out; diff --git a/include/xfs_inode.h b/include/xfs_inode.h index 3caeeb39e..b49921da4 100644 --- a/include/xfs_inode.h +++ b/include/xfs_inode.h @@ -78,7 +78,6 @@ typedef struct xfs_inode { unsigned int i_cformat; /* format of cow fork */ xfs_fsize_t i_size; /* in-memory size */ - struct xfs_ifork_ops *i_fork_ops; /* fork verifiers */ struct inode i_vnode; } xfs_inode_t; @@ -161,8 +160,7 @@ extern struct timespec64 current_time(struct inode *inode); /* Inode Cache Interfaces */ extern bool libxfs_inode_verify_forks(struct xfs_inode *ip); extern int libxfs_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, - uint, struct xfs_inode **, - struct xfs_ifork_ops *); + uint, struct xfs_inode **); extern void libxfs_irele(struct xfs_inode *ip); #endif /* __XFS_INODE_H__ */ diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 1a7cdbf96..e7e42e93a 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -60,7 +60,6 @@ #define xfs_da_hashname libxfs_da_hashname #define xfs_da_read_buf libxfs_da_read_buf #define xfs_da_shrink_inode libxfs_da_shrink_inode -#define xfs_default_ifork_ops libxfs_default_ifork_ops #define xfs_defer_cancel libxfs_defer_cancel #define xfs_defer_finish libxfs_defer_finish #define xfs_dinode_calc_crc libxfs_dinode_calc_crc diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c index 80b4716f4..4f09a0005 100644 --- a/libxfs/rdwr.c +++ b/libxfs/rdwr.c @@ -1234,10 +1234,7 @@ libxfs_inode_verify_forks( struct xfs_ifork *ifp; xfs_failaddr_t fa; - if (!ip->i_fork_ops) - return true; - - fa = xfs_ifork_verify_data(ip, ip->i_fork_ops); + fa = xfs_ifork_verify_data(ip); if (fa) { ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); xfs_inode_verifier_error(ip, -EFSCORRUPTED, "data fork", @@ -1245,7 +1242,7 @@ libxfs_inode_verify_forks( return false; } - fa = xfs_ifork_verify_attr(ip, ip->i_fork_ops); + fa = xfs_ifork_verify_attr(ip); if (fa) { ifp = XFS_IFORK_PTR(ip, XFS_ATTR_FORK); xfs_inode_verifier_error(ip, -EFSCORRUPTED, "attr fork", @@ -1262,8 +1259,7 @@ libxfs_iget( struct xfs_trans *tp, xfs_ino_t ino, uint lock_flags, - struct xfs_inode **ipp, - struct xfs_ifork_ops *ifork_ops) + struct xfs_inode **ipp) { struct xfs_inode *ip; struct xfs_dinode *dip; @@ -1292,8 +1288,6 @@ libxfs_iget( if (error) goto out_destroy; - ip->i_fork_ops = ifork_ops; - if (!libxfs_inode_verify_forks(ip)) { libxfs_irele(ip); return -EFSCORRUPTED; diff --git a/libxfs/util.c b/libxfs/util.c index dc3d050dd..dce8e1a8e 100644 --- a/libxfs/util.c +++ b/libxfs/util.c @@ -247,8 +247,7 @@ libxfs_ialloc( } ASSERT(*ialloc_context == NULL); - error = libxfs_iget(tp->t_mountp, tp, ino, 0, &ip, - &xfs_default_ifork_ops); + error = libxfs_iget(tp->t_mountp, tp, ino, 0, &ip); if (error != 0) return error; ASSERT(ip != NULL); diff --git a/libxfs/xfs_inode_fork.c b/libxfs/xfs_inode_fork.c index 9e8edd45c..fb9825326 100644 --- a/libxfs/xfs_inode_fork.c +++ b/libxfs/xfs_inode_fork.c @@ -671,18 +671,10 @@ xfs_ifork_init_cow( ip->i_cnextents = 0; } -/* Default fork content verifiers. */ -struct xfs_ifork_ops xfs_default_ifork_ops = { - .verify_attr = xfs_attr_shortform_verify, - .verify_dir = xfs_dir2_sf_verify, - .verify_symlink = xfs_symlink_shortform_verify, -}; - /* Verify the inline contents of the data fork of an inode. */ xfs_failaddr_t xfs_ifork_verify_data( - struct xfs_inode *ip, - struct xfs_ifork_ops *ops) + struct xfs_inode *ip) { /* Non-local data fork, we're done. */ if (ip->i_d.di_format != XFS_DINODE_FMT_LOCAL) @@ -691,9 +683,9 @@ xfs_ifork_verify_data( /* Check the inline data fork if there is one. */ switch (VFS_I(ip)->i_mode & S_IFMT) { case S_IFDIR: - return ops->verify_dir(ip); + return xfs_dir2_sf_verify(ip); case S_IFLNK: - return ops->verify_symlink(ip); + return xfs_symlink_shortform_verify(ip); default: return NULL; } @@ -702,13 +694,12 @@ xfs_ifork_verify_data( /* Verify the inline contents of the attr fork of an inode. */ xfs_failaddr_t xfs_ifork_verify_attr( - struct xfs_inode *ip, - struct xfs_ifork_ops *ops) + struct xfs_inode *ip) { /* There has to be an attr fork allocated if aformat is local. */ if (ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL) return NULL; if (!XFS_IFORK_PTR(ip, XFS_ATTR_FORK)) return __this_address; - return ops->verify_attr(ip); + return xfs_attr_shortform_verify(ip); } diff --git a/libxfs/xfs_inode_fork.h b/libxfs/xfs_inode_fork.h index 8487b0c88..3f84d33ab 100644 --- a/libxfs/xfs_inode_fork.h +++ b/libxfs/xfs_inode_fork.h @@ -176,18 +176,7 @@ extern struct kmem_zone *xfs_ifork_zone; extern void xfs_ifork_init_cow(struct xfs_inode *ip); -typedef xfs_failaddr_t (*xfs_ifork_verifier_t)(struct xfs_inode *); - -struct xfs_ifork_ops { - xfs_ifork_verifier_t verify_symlink; - xfs_ifork_verifier_t verify_dir; - xfs_ifork_verifier_t verify_attr; -}; -extern struct xfs_ifork_ops xfs_default_ifork_ops; - -xfs_failaddr_t xfs_ifork_verify_data(struct xfs_inode *ip, - struct xfs_ifork_ops *ops); -xfs_failaddr_t xfs_ifork_verify_attr(struct xfs_inode *ip, - struct xfs_ifork_ops *ops); +xfs_failaddr_t xfs_ifork_verify_data(struct xfs_inode *ip); +xfs_failaddr_t xfs_ifork_verify_attr(struct xfs_inode *ip); #endif /* __XFS_INODE_FORK_H__ */ diff --git a/repair/phase6.c b/repair/phase6.c index 898e088b6..f69582d47 100644 --- a/repair/phase6.c +++ b/repair/phase6.c @@ -477,8 +477,7 @@ mk_rbmino(xfs_mount_t *mp) if (i) res_failed(i); - error = -libxfs_iget(mp, tp, mp->m_sb.sb_rbmino, 0, &ip, - &xfs_default_ifork_ops); + error = -libxfs_iget(mp, tp, mp->m_sb.sb_rbmino, 0, &ip); if (error) { do_error( _("couldn't iget realtime bitmap inode -- error - %d\n"), @@ -576,8 +575,7 @@ fill_rbmino(xfs_mount_t *mp) if (error) res_failed(error); - error = -libxfs_iget(mp, tp, mp->m_sb.sb_rbmino, 0, &ip, - &xfs_default_ifork_ops); + error = -libxfs_iget(mp, tp, mp->m_sb.sb_rbmino, 0, &ip); if (error) { do_error( _("couldn't iget realtime bitmap inode -- error - %d\n"), @@ -647,8 +645,7 @@ fill_rsumino(xfs_mount_t *mp) if (error) res_failed(error); - error = -libxfs_iget(mp, tp, mp->m_sb.sb_rsumino, 0, &ip, - &xfs_default_ifork_ops); + error = -libxfs_iget(mp, tp, mp->m_sb.sb_rsumino, 0, &ip); if (error) { do_error( _("couldn't iget realtime summary inode -- error - %d\n"), @@ -720,8 +717,7 @@ mk_rsumino(xfs_mount_t *mp) if (i) res_failed(i); - error = -libxfs_iget(mp, tp, mp->m_sb.sb_rsumino, 0, &ip, - &xfs_default_ifork_ops); + error = -libxfs_iget(mp, tp, mp->m_sb.sb_rsumino, 0, &ip); if (error) { do_error( _("couldn't iget realtime summary inode -- error - %d\n"), @@ -819,8 +815,7 @@ mk_root_dir(xfs_mount_t *mp) if (i) res_failed(i); - error = -libxfs_iget(mp, tp, mp->m_sb.sb_rootino, 0, &ip, - &xfs_default_ifork_ops); + error = -libxfs_iget(mp, tp, mp->m_sb.sb_rootino, 0, &ip); if (error) { do_error(_("could not iget root inode -- error - %d\n"), error); } @@ -894,8 +889,7 @@ mk_orphanage(xfs_mount_t *mp) * would have been cleared in phase3 and phase4. */ - i = -libxfs_iget(mp, NULL, mp->m_sb.sb_rootino, 0, &pip, - &xfs_default_ifork_ops); + i = -libxfs_iget(mp, NULL, mp->m_sb.sb_rootino, 0, &pip); if (i) do_error(_("%d - couldn't iget root inode to obtain %s\n"), i, ORPHANAGE); @@ -919,8 +913,7 @@ mk_orphanage(xfs_mount_t *mp) * use iget/ijoin instead of trans_iget because the ialloc * wrapper can commit the transaction and start a new one */ -/* i = -libxfs_iget(mp, NULL, mp->m_sb.sb_rootino, 0, &pip, - &xfs_default_ifork_ops); +/* i = -libxfs_iget(mp, NULL, mp->m_sb.sb_rootino, 0, &pip); if (i) do_error(_("%d - couldn't iget root inode to make %s\n"), i, ORPHANAGE);*/ @@ -1028,8 +1021,7 @@ mv_orphanage( xname.len = snprintf((char *)fname, sizeof(fname), "%llu", (unsigned long long)ino); - err = -libxfs_iget(mp, NULL, orphanage_ino, 0, &orphanage_ip, - &xfs_default_ifork_ops); + err = -libxfs_iget(mp, NULL, orphanage_ino, 0, &orphanage_ip); if (err) do_error(_("%d - couldn't iget orphanage inode\n"), err); /* @@ -1042,7 +1034,7 @@ mv_orphanage( (unsigned long long)ino, ++incr); /* Orphans may not have a proper parent, so use custom ops here */ - err = -libxfs_iget(mp, NULL, ino, 0, &ino_p, &xfs_default_ifork_ops); + err = -libxfs_iget(mp, NULL, ino, 0, &ino_p); if (err) do_error(_("%d - couldn't iget disconnected inode\n"), err); @@ -2816,7 +2808,7 @@ process_dir_inode( ASSERT(!is_inode_refchecked(irec, ino_offset) || dotdot_update); - error = -libxfs_iget(mp, NULL, ino, 0, &ip, &xfs_default_ifork_ops); + error = -libxfs_iget(mp, NULL, ino, 0, &ip); if (error) { if (!no_modify) do_error( diff --git a/repair/phase7.c b/repair/phase7.c index 47e76b560..30cb46f9a 100644 --- a/repair/phase7.c +++ b/repair/phase7.c @@ -33,7 +33,7 @@ update_inode_nlinks( error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_remove, nres, 0, 0, &tp); ASSERT(error == 0); - error = -libxfs_iget(mp, tp, ino, 0, &ip, &xfs_default_ifork_ops); + error = -libxfs_iget(mp, tp, ino, 0, &ip); if (error) { if (!no_modify) do_error( diff --git a/repair/quotacheck.c b/repair/quotacheck.c index 0df1f2be5..87f81c3d2 100644 --- a/repair/quotacheck.c +++ b/repair/quotacheck.c @@ -210,7 +210,7 @@ quotacheck_adjust( ino == mp->m_sb.sb_pquotino) return; - error = -libxfs_iget(mp, NULL, ino, 0, &ip, &xfs_default_ifork_ops); + error = -libxfs_iget(mp, NULL, ino, 0, &ip); if (error) { do_warn( _("could not open file %"PRIu64" for quotacheck, err=%d\n"), @@ -367,7 +367,7 @@ quotacheck_verify( if (!dquots || !chkd_flags) return; - error = -libxfs_iget(mp, NULL, ino, 0, &ip, &xfs_default_ifork_ops); + error = -libxfs_iget(mp, NULL, ino, 0, &ip); if (error) { do_warn( _("could not open %s inode %"PRIu64" for quotacheck, err=%d\n"), diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index d687edeaa..5efc5586b 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -459,8 +459,7 @@ has_plausible_rootdir( int error; bool ret = false; - error = -libxfs_iget(mp, NULL, mp->m_sb.sb_rootino, 0, &ip, - &xfs_default_ifork_ops); + error = -libxfs_iget(mp, NULL, mp->m_sb.sb_rootino, 0, &ip); if (error) goto out; if (!S_ISDIR(VFS_I(ip)->i_mode))