xfs: refactor xfs_iget calls from log intent recovery
authorDarrick J. Wong <djwong@kernel.org>
Sun, 8 Aug 2021 15:27:13 +0000 (08:27 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 9 Aug 2021 22:57:59 +0000 (15:57 -0700)
Hoist the code from xfs_bui_item_recover that igets an inode and marks
it as being part of log intent recovery.  The next patch will want a
common function.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
fs/xfs/libxfs/xfs_log_recover.h
fs/xfs/xfs_bmap_item.c
fs/xfs/xfs_log_recover.c

index 3cca2bfe714cb202b3b51ccf6623da33476c21b0..ff69a00008176e640708bd08b9cab27e098630c2 100644 (file)
@@ -122,6 +122,8 @@ void xlog_buf_readahead(struct xlog *log, xfs_daddr_t blkno, uint len,
                const struct xfs_buf_ops *ops);
 bool xlog_is_buffer_cancelled(struct xlog *log, xfs_daddr_t blkno, uint len);
 
+int xlog_recover_iget(struct xfs_mount *mp, xfs_ino_t ino,
+               struct xfs_inode **ipp);
 void xlog_recover_release_intent(struct xlog *log, unsigned short intent_type,
                uint64_t intent_id);
 
index 3d6f70da8820ed321630a0437fa54a46e62083a6..03159970133ffed2821f7ebf916d9d41520a01ed 100644 (file)
@@ -24,7 +24,6 @@
 #include "xfs_error.h"
 #include "xfs_log_priv.h"
 #include "xfs_log_recover.h"
-#include "xfs_quota.h"
 
 kmem_zone_t    *xfs_bui_zone;
 kmem_zone_t    *xfs_bud_zone;
@@ -487,18 +486,10 @@ xfs_bui_item_recover(
                        XFS_ATTR_FORK : XFS_DATA_FORK;
        bui_type = bmap->me_flags & XFS_BMAP_EXTENT_TYPE_MASK;
 
-       /* Grab the inode. */
-       error = xfs_iget(mp, NULL, bmap->me_owner, 0, 0, &ip);
+       error = xlog_recover_iget(mp, bmap->me_owner, &ip);
        if (error)
                return error;
 
-       error = xfs_qm_dqattach(ip);
-       if (error)
-               goto err_rele;
-
-       if (VFS_I(ip)->i_nlink == 0)
-               xfs_iflags_set(ip, XFS_IRECOVERY);
-
        /* Allocate transaction and do the work. */
        error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate,
                        XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK), 0, 0, &tp);
index 1d324c8bac6bf7c3565346a81266f61cc5e86705..1d4213302078797a1d111d842ec344b05c639369 100644 (file)
@@ -26,6 +26,8 @@
 #include "xfs_error.h"
 #include "xfs_buf_item.h"
 #include "xfs_ag.h"
+#include "xfs_quota.h"
+
 
 #define BLK_AVG(blk1, blk2)    ((blk1+blk2) >> 1)
 
@@ -1754,6 +1756,30 @@ xlog_recover_release_intent(
        spin_unlock(&ailp->ail_lock);
 }
 
+int
+xlog_recover_iget(
+       struct xfs_mount        *mp,
+       xfs_ino_t               ino,
+       struct xfs_inode        **ipp)
+{
+       int                     error;
+
+       error = xfs_iget(mp, NULL, ino, 0, 0, ipp);
+       if (error)
+               return error;
+
+       error = xfs_qm_dqattach(*ipp);
+       if (error) {
+               xfs_irele(*ipp);
+               return error;
+       }
+
+       if (VFS_I(*ipp)->i_nlink == 0)
+               xfs_iflags_set(*ipp, XFS_IRECOVERY);
+
+       return 0;
+}
+
 /******************************************************************************
  *
  *             Log recover routines