xfs: pass the icreate args object to xfs_dialloc
authorDarrick J. Wong <djwong@kernel.org>
Fri, 30 Aug 2024 22:36:49 +0000 (15:36 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Sun, 1 Sep 2024 15:58:19 +0000 (08:58 -0700)
Pass the xfs_icreate_args object to xfs_dialloc since we can extract the
relevant mode (really just the file type) and parent inumber from there.
This simplifies the calling convention in preparation for the next
patch.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/libxfs/xfs_ialloc.c
fs/xfs/libxfs/xfs_ialloc.h
fs/xfs/scrub/tempfile.c
fs/xfs/xfs_inode.c
fs/xfs/xfs_qm.c
fs/xfs/xfs_symlink.c

index 0af5b7a..fc70601 100644 (file)
@@ -1855,11 +1855,12 @@ out_release:
 int
 xfs_dialloc(
        struct xfs_trans        **tpp,
-       xfs_ino_t               parent,
-       umode_t                 mode,
+       const struct xfs_icreate_args *args,
        xfs_ino_t               *new_ino)
 {
        struct xfs_mount        *mp = (*tpp)->t_mountp;
+       xfs_ino_t               parent = args->pip ? args->pip->i_ino : 0;
+       umode_t                 mode = args->mode & S_IFMT;
        xfs_agnumber_t          agno;
        int                     error = 0;
        xfs_agnumber_t          start_agno;
index b549627..3a13231 100644 (file)
@@ -33,11 +33,13 @@ xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o)
        return xfs_buf_offset(b, o << (mp)->m_sb.sb_inodelog);
 }
 
+struct xfs_icreate_args;
+
 /*
  * Allocate an inode on disk.  Mode is used to tell whether the new inode will
  * need space, and whether it is a directory.
  */
-int xfs_dialloc(struct xfs_trans **tpp, xfs_ino_t parent, umode_t mode,
+int xfs_dialloc(struct xfs_trans **tpp, const struct xfs_icreate_args *args,
                xfs_ino_t *new_ino);
 
 int xfs_difree(struct xfs_trans *tp, struct xfs_perag *pag,
index d390d56..177f922 100644 (file)
@@ -88,7 +88,7 @@ xrep_tempfile_create(
                goto out_release_dquots;
 
        /* Allocate inode, set up directory. */
-       error = xfs_dialloc(&tp, dp->i_ino, mode, &ino);
+       error = xfs_dialloc(&tp, &args, &ino);
        if (error)
                goto out_trans_cancel;
        error = xfs_icreate(tp, ino, &args, &sc->tempip);
index 7dc6f32..9ea7a18 100644 (file)
@@ -704,7 +704,7 @@ xfs_create(
         * entry pointing to them, but a directory also the "." entry
         * pointing to itself.
         */
-       error = xfs_dialloc(&tp, dp->i_ino, args->mode, &ino);
+       error = xfs_dialloc(&tp, args, &ino);
        if (!error)
                error = xfs_icreate(tp, ino, args, &du.ip);
        if (error)
@@ -812,7 +812,7 @@ xfs_create_tmpfile(
        if (error)
                goto out_release_dquots;
 
-       error = xfs_dialloc(&tp, dp->i_ino, args->mode, &ino);
+       error = xfs_dialloc(&tp, args, &ino);
        if (!error)
                error = xfs_icreate(tp, ino, args, &ip);
        if (error)
index 9490b91..63f6ca2 100644 (file)
@@ -799,7 +799,7 @@ xfs_qm_qino_alloc(
                };
                xfs_ino_t       ino;
 
-               error = xfs_dialloc(&tp, 0, S_IFREG, &ino);
+               error = xfs_dialloc(&tp, &args, &ino);
                if (!error)
                        error = xfs_icreate(tp, ino, &args, ipp);
                if (error) {
index 77f19e2..4252b07 100644 (file)
@@ -165,7 +165,7 @@ xfs_symlink(
        /*
         * Allocate an inode for the symlink.
         */
-       error = xfs_dialloc(&tp, dp->i_ino, S_IFLNK, &ino);
+       error = xfs_dialloc(&tp, &args, &ino);
        if (!error)
                error = xfs_icreate(tp, ino, &args, &du.ip);
        if (error)