]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: remove xfs_ifork_ops
authorChristoph Hellwig <hch@lst.de>
Mon, 10 Aug 2020 20:32:06 +0000 (16:32 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Mon, 10 Aug 2020 20:32:06 +0000 (16:32 -0400)
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 <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
db/attrset.c
include/xfs_inode.h
libxfs/libxfs_api_defs.h
libxfs/rdwr.c
libxfs/util.c
libxfs/xfs_inode_fork.c
libxfs/xfs_inode_fork.h
repair/phase6.c
repair/phase7.c
repair/quotacheck.c
repair/xfs_repair.c

index b86ecec70912348b53a51a77b4b7b1e5e795ee18..98a08a490a2459eb3904481bf5be49abda9e740f 100644 (file)
@@ -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;
index 3caeeb39ed6cbbdea61fa0866bd510cc95a620c4..b49921da4850c395a61384f8d0858560d2eded9c 100644 (file)
@@ -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__ */
index 1a7cdbf96218677bff4b00131613e3773d1c631a..e7e42e93a07e4b6f595bdd10e0edd21622a537b9 100644 (file)
@@ -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
index 80b4716f4345cd1342eefd04a7df62de640302ab..4f09a00058ae8347824c0e5ae91050857bfa9aff 100644 (file)
@@ -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;
index dc3d050dd2fb98a43b04187efa9e578290b20da4..dce8e1a8ed8445a9f90f0e5f1433780b66d67208 100644 (file)
@@ -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);
index 9e8edd45c92b96005956b641b80eebbaa1a7dc1a..fb9825326c1c55ddf103f035d61d09c553e3f0a2 100644 (file)
@@ -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);
 }
index 8487b0c88a75e04b276c1a7f771bed8b0e87d6a0..3f84d33abd3b7a665738db0062a2c524ab9cb323 100644 (file)
@@ -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__ */
index 898e088b6e5ce63773360ba1a8f260d6321d95f7..f69582d47f733e6fd2e3dba82db70e6a18705f74 100644 (file)
@@ -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(
index 47e76b560ba0db977fc15d0bdfd72eea1f0cee33..30cb46f9a57d25546cc1007f7de002be79117c99 100644 (file)
@@ -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(
index 0df1f2be5bc2d58108774087d53ea6d27c2a6cc7..87f81c3d2dbbb301c13dc11ff9deffaa774673f1 100644 (file)
@@ -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"),
index d687edeaaaf3ef326c67c891b9ef526778c00364..5efc5586bf16d73a8f57454544ed072b1b6a8232 100644 (file)
@@ -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))