]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: use perag through unlink processing
authorDave Chinner <dchinner@redhat.com>
Fri, 15 Oct 2021 20:28:26 +0000 (16:28 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Fri, 15 Oct 2021 20:28:26 +0000 (16:28 -0400)
Source kernel commit: f40aadb2bb64fe0a3d9b59957e70796d629cdee2

Unlinked lists are held in the perag, and freeing of inodes needs to
be passed a perag, too, so look up the perag early in the unlink
processing and use it throughout.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_ialloc.c
libxfs/xfs_ialloc.h

index a1454908554e529db60076d5426c123ed0d75ff0..e24136a46152c48b99fcd0f2e21c8ab337ede21e 100644 (file)
@@ -2129,35 +2129,33 @@ error:
  */
 int
 xfs_difree(
-       struct xfs_trans        *tp,            /* transaction pointer */
-       xfs_ino_t               inode,          /* inode to be freed */
-       struct xfs_icluster     *xic)   /* cluster info if deleted */
+       struct xfs_trans        *tp,
+       struct xfs_perag        *pag,
+       xfs_ino_t               inode,
+       struct xfs_icluster     *xic)
 {
        /* REFERENCED */
        xfs_agblock_t           agbno;  /* block number containing inode */
        struct xfs_buf          *agbp;  /* buffer for allocation group header */
        xfs_agino_t             agino;  /* allocation group inode number */
-       xfs_agnumber_t          agno;   /* allocation group number */
        int                     error;  /* error return value */
        struct xfs_mount        *mp = tp->t_mountp;
        struct xfs_inobt_rec_incore rec;/* btree record */
-       struct xfs_perag        *pag;
 
        /*
         * Break up inode number into its components.
         */
-       agno = XFS_INO_TO_AGNO(mp, inode);
-       if (agno >= mp->m_sb.sb_agcount) {
-               xfs_warn(mp, "%s: agno >= mp->m_sb.sb_agcount (%d >= %d).",
-                       __func__, agno, mp->m_sb.sb_agcount);
+       if (pag->pag_agno != XFS_INO_TO_AGNO(mp, inode)) {
+               xfs_warn(mp, "%s: agno != pag->pag_agno (%d != %d).",
+                       __func__, XFS_INO_TO_AGNO(mp, inode), pag->pag_agno);
                ASSERT(0);
                return -EINVAL;
        }
        agino = XFS_INO_TO_AGINO(mp, inode);
-       if (inode != XFS_AGINO_TO_INO(mp, agno, agino))  {
+       if (inode != XFS_AGINO_TO_INO(mp, pag->pag_agno, agino))  {
                xfs_warn(mp, "%s: inode != XFS_AGINO_TO_INO() (%llu != %llu).",
                        __func__, (unsigned long long)inode,
-                       (unsigned long long)XFS_AGINO_TO_INO(mp, agno, agino));
+                       (unsigned long long)XFS_AGINO_TO_INO(mp, pag->pag_agno, agino));
                ASSERT(0);
                return -EINVAL;
        }
@@ -2171,7 +2169,7 @@ xfs_difree(
        /*
         * Get the allocation group header.
         */
-       error = xfs_ialloc_read_agi(mp, tp, agno, &agbp);
+       error = xfs_ialloc_read_agi(mp, tp, pag->pag_agno, &agbp);
        if (error) {
                xfs_warn(mp, "%s: xfs_ialloc_read_agi() returned error %d.",
                        __func__, error);
@@ -2181,7 +2179,6 @@ xfs_difree(
        /*
         * Fix up the inode allocation btree.
         */
-       pag = agbp->b_pag;
        error = xfs_difree_inobt(mp, tp, agbp, pag, agino, xic, &rec);
        if (error)
                goto error0;
index 886f6748fb2250144f043904b8820232a738dc17..9df7c80408ffc5919bafd9d4542faf1c07f83937 100644 (file)
@@ -39,17 +39,8 @@ xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o)
 int xfs_dialloc(struct xfs_trans **tpp, xfs_ino_t parent, umode_t mode,
                xfs_ino_t *new_ino);
 
-/*
- * Free disk inode.  Carefully avoids touching the incore inode, all
- * manipulations incore are the caller's responsibility.
- * The on-disk inode is not changed by this operation, only the
- * btree (free inode mask) is changed.
- */
-int                                    /* error */
-xfs_difree(
-       struct xfs_trans *tp,           /* transaction pointer */
-       xfs_ino_t       inode,          /* inode to be freed */
-       struct xfs_icluster *ifree);    /* cluster info if deleted */
+int xfs_difree(struct xfs_trans *tp, struct xfs_perag *pag,
+               xfs_ino_t ino, struct xfs_icluster *ifree);
 
 /*
  * Return the location of the inode in imap, for mapping it into a buffer.