]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: get rid of xfs_dir_ialloc()
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: b652afd937033911944d7f681f2031b006961f1d

This is just a simple wrapper around the per-ag inode allocation
that doesn't need to exist. The internal mechanism to select and
allocate within an AG does not need to be exposed outside
xfs_ialloc.c, and it being exposed simply makes it harder to follow
the code and simplify it.

This is simplified by internalising xf_dialloc_select_ag() and
xfs_dialloc_ag() into a single xfs_dialloc() function and then
xfs_dir_ialloc() can go away.

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

index f8ea3d2ae345eb49af8a9e2b9d5428ec330f3290..905f178479a3c005f689f304eb27a02557a696b4 100644 (file)
@@ -514,7 +514,6 @@ libxfs_dir_ialloc(
        struct fsxattr          *fsx,
        struct xfs_inode        **ipp)
 {
-       struct xfs_buf          *agibp;
        xfs_ino_t               parent_ino = dp ? dp->i_ino : 0;
        xfs_ino_t               ino;
        int                     error;
@@ -523,19 +522,10 @@ libxfs_dir_ialloc(
         * Call the space management code to pick the on-disk inode to be
         * allocated.
         */
-       error = xfs_dialloc_select_ag(tpp, parent_ino, mode, &agibp);
+       error = xfs_dialloc(tpp, parent_ino, mode, &ino);
        if (error)
                return error;
 
-       if (!agibp)
-               return -ENOSPC;
-
-       /* Allocate an inode from the selected AG */
-       error = xfs_dialloc_ag(*tpp, agibp, parent_ino, &ino);
-       if (error)
-               return error;
-       ASSERT(ino != NULLFSINO);
-
        return libxfs_init_new_inode(*tpp, dp, ino, mode, nlink, rdev, cr,
                                fsx, ipp);
 }
index 573a78041b36fd5b503efdd301a1250aa770062a..b133b2edf1f6872a0385cac98d06cd3b9a7bdbf3 100644 (file)
@@ -1423,7 +1423,7 @@ xfs_dialloc_ag_update_inobt(
  * The caller selected an AG for us, and made sure that free inodes are
  * available.
  */
-int
+static int
 xfs_dialloc_ag(
        struct xfs_trans        *tp,
        struct xfs_buf          *agbp,
@@ -1597,24 +1597,23 @@ xfs_ialloc_next_ag(
  * can be allocated, -ENOSPC be returned.
  */
 int
-xfs_dialloc_select_ag(
+xfs_dialloc(
        struct xfs_trans        **tpp,
        xfs_ino_t               parent,
        umode_t                 mode,
-       struct xfs_buf          **IO_agbp)
+       xfs_ino_t               *new_ino)
 {
        struct xfs_mount        *mp = (*tpp)->t_mountp;
        struct xfs_buf          *agbp;
        xfs_agnumber_t          agno;
-       int                     error;
+       int                     error = 0;
        xfs_agnumber_t          start_agno;
        struct xfs_perag        *pag;
        struct xfs_ino_geometry *igeo = M_IGEO(mp);
        bool                    okalloc = true;
        int                     needspace;
        int                     flags;
-
-       *IO_agbp = NULL;
+       xfs_ino_t               ino;
 
        /*
         * Directories, symlinks, and regular files frequently allocate at least
@@ -1760,7 +1759,11 @@ nextag:
        return error ? error : -ENOSPC;
 found_ag:
        xfs_perag_put(pag);
-       *IO_agbp = agbp;
+       /* Allocate an inode in the found AG */
+       error = xfs_dialloc_ag(*tpp, agbp, parent, &ino);
+       if (error)
+               return error;
+       *new_ino = ino;
        return 0;
 }
 
index 3511086a7ae107e905fa244c4882fffd51299245..886f6748fb2250144f043904b8820232a738dc17 100644 (file)
@@ -33,30 +33,11 @@ xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o)
 }
 
 /*
- * Allocate an inode on disk.
- * Mode is used to tell whether the new inode will need space, and whether
- * it is a directory.
- *
- * There are two phases to inode allocation: selecting an AG and ensuring
- * that it contains free inodes, followed by allocating one of the free
- * inodes. xfs_dialloc_select_ag() does the former and returns a locked AGI
- * to the caller, ensuring that followup call to xfs_dialloc_ag() will
- * have free inodes to allocate from. xfs_dialloc_ag() will return the inode
- * number of the free inode we allocated.
+ * Allocate an inode on disk.  Mode is used to tell whether the new inode will
+ * need space, and whether it is a directory.
  */
-int                                    /* error */
-xfs_dialloc_select_ag(
-       struct xfs_trans **tpp,         /* double pointer of transaction */
-       xfs_ino_t       parent,         /* parent inode (directory) */
-       umode_t         mode,           /* mode bits for new inode */
-       struct xfs_buf  **IO_agbp);
-
-int
-xfs_dialloc_ag(
-       struct xfs_trans        *tp,
-       struct xfs_buf          *agbp,
-       xfs_ino_t               parent,
-       xfs_ino_t               *inop);
+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