]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: better xfs_trans_alloc interface
authorChristoph Hellwig <hch@lst.de>
Tue, 21 Jun 2016 23:32:40 +0000 (09:32 +1000)
committerDave Chinner <david@fromorbit.com>
Tue, 21 Jun 2016 23:32:40 +0000 (09:32 +1000)
Source kernel commit 253f4911f297b83745938b7f2c5649b94730b002

Merge xfs_trans_reserve and xfs_trans_alloc into a single function call
that returns a transaction with all the required log and block reservations,
and which allows passing transaction flags directly to avoid the cumbersome
_xfs_trans_alloc interface.

While we're at it we also get rid of the transaction type argument that has
been superflous since we stopped supporting the non-CIL logging mode.  The
guts of it will be removed in another patch.

[dchinner: fixed transaction leak in error path in xfs_setattr_nonsize]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
14 files changed:
include/xfs_trans.h
libxfs/libxfs_api_defs.h
libxfs/libxfs_priv.h
libxfs/trans.c
libxfs/util.c
libxfs/xfs_attr.c
libxfs/xfs_bmap.c
libxfs/xfs_sb.c
libxfs/xfs_shared.h
mkfs/proto.c
mkfs/xfs_mkfs.c
repair/phase5.c
repair/phase6.c
repair/phase7.c

index 0c7a90adc8194f1f5e9ef6798690ed15b67f0e08..b4bd1eb4dcc38105bc148c497d5ab57b6cdcc7e0 100644 (file)
@@ -87,9 +87,9 @@ typedef struct xfs_trans {
 void   xfs_trans_init(struct xfs_mount *);
 int    xfs_trans_roll(struct xfs_trans **, struct xfs_inode *);
 
-xfs_trans_t    *libxfs_trans_alloc(struct xfs_mount *, int);
-int    libxfs_trans_reserve(struct xfs_trans *, struct xfs_trans_res *,
-                                    uint, uint);
+int    libxfs_trans_alloc(struct xfs_mount *mp, struct xfs_trans_res *resp,
+                          uint blocks, uint rtextents, uint flags,
+                          struct xfs_trans **tpp);
 int    libxfs_trans_commit(struct xfs_trans *);
 void   libxfs_trans_cancel(struct xfs_trans *);
 struct xfs_buf *libxfs_trans_getsb(struct xfs_trans *, struct xfs_mount *, int);
index 685c7a70db436404a18efb7ce6c8038fc7c2b031..290dc1d7dd961506bdd0b2782a6ba61611d65780 100644 (file)
@@ -55,7 +55,6 @@
 #define xfs_trans_read_buf_map         libxfs_trans_read_buf_map
 #define xfs_trans_roll                 libxfs_trans_roll
 #define xfs_trans_get_buf_map          libxfs_trans_get_buf_map
-#define xfs_trans_reserve              libxfs_trans_reserve
 #define xfs_trans_resv_calc            libxfs_trans_resv_calc
 
 #define xfs_attr_get                   libxfs_attr_get
index c14faca002cba36e3660aaa55567d3427751b440..608d5c379b4b00897966bda38a22ccf7559ab63a 100644 (file)
@@ -361,7 +361,6 @@ roundup_64(__uint64_t x, __uint32_t y)
 #define XFS_MOUNT_RDONLY               0       /* ignored in userspace */
 
 
-#define _xfs_trans_alloc(mp, type, f)  libxfs_trans_alloc(mp, type)
 #define xfs_trans_get_block_res(tp)    1
 #define xfs_trans_set_sync(tp)         ((void) 0)
 #define xfs_trans_ordered_buf(tp, bp)  ((void) 0)
index 03889502acd3a2e011117771603cf185db841543..521a049be80ead87ecaab7a0a7a95d9d80b19d47 100644 (file)
@@ -119,7 +119,6 @@ libxfs_trans_roll(
         */
        tres.tr_logres = trans->t_log_res;
        tres.tr_logcount = trans->t_log_count;
-       *tpp = libxfs_trans_alloc(trans->t_mountp, trans->t_type);
 
        /*
         * Commit the current transaction.
@@ -132,7 +131,6 @@ libxfs_trans_roll(
        if (error)
                return error;
 
-       trans = *tpp;
 
        /*
         * Reserve space in the log for th next transaction.
@@ -143,7 +141,8 @@ libxfs_trans_roll(
         * the prior and the next transactions.
         */
        tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
-       error = xfs_trans_reserve(trans, &tres, 0, 0);
+       error = libxfs_trans_alloc(trans->t_mountp, &tres, 0, 0, 0, tpp);
+       trans = *tpp;
        /*
         *  Ensure that the inode is in the new transaction and locked.
         */
@@ -155,12 +154,28 @@ libxfs_trans_roll(
        return 0;
 }
 
-xfs_trans_t *
+int
 libxfs_trans_alloc(
-       xfs_mount_t     *mp,
-       int             type)
+       struct xfs_mount        *mp,
+       struct xfs_trans_res    *resp,
+       unsigned int            blocks,
+       unsigned int            rtextents,
+       unsigned int            flags,
+       struct xfs_trans        **tpp)
+
 {
-       xfs_trans_t     *ptr;
+       struct xfs_sb   *sb = &mp->m_sb;
+       struct xfs_trans *ptr;
+
+       /*
+        * Attempt to reserve the needed disk blocks by decrementing
+        * the number needed from the number available.  This will
+        * fail if the count would go below zero.
+        */
+       if (blocks > 0) {
+               if (sb->sb_fdblocks < blocks)
+                       return -ENOSPC;
+       }
 
        if ((ptr = calloc(sizeof(xfs_trans_t), 1)) == NULL) {
                fprintf(stderr, _("%s: xact calloc failed (%d bytes): %s\n"),
@@ -168,33 +183,11 @@ libxfs_trans_alloc(
                exit(1);
        }
        ptr->t_mountp = mp;
-       ptr->t_type = type;
        INIT_LIST_HEAD(&ptr->t_items);
 #ifdef XACT_DEBUG
        fprintf(stderr, "allocated new transaction %p\n", ptr);
 #endif
-       return ptr;
-}
-
-int
-libxfs_trans_reserve(
-       struct xfs_trans        *tp,
-       struct xfs_trans_res    *resp,
-       uint                    blocks,
-       uint                    rtextents)
-{
-       xfs_sb_t        *mpsb = &tp->t_mountp->m_sb;
-
-       /*
-        * Attempt to reserve the needed disk blocks by decrementing
-        * the number needed from the number available.  This will
-        * fail if the count would go below zero.
-        */
-       if (blocks > 0) {
-               if (mpsb->sb_fdblocks < blocks)
-                       return -ENOSPC;
-       }
-       /* user space, don't need log/RT stuff (preserve the API though) */
+       *tpp = ptr;
        return 0;
 }
 
index f3b9895438f9e65bf4b7b030c2dc8a678d7bc4f2..37941246eb5dc97acb513be216053dbd20f72595 100644 (file)
@@ -541,10 +541,9 @@ libxfs_alloc_file_space(
        while (allocatesize_fsb && !error) {
                datablocks = allocatesize_fsb;
 
-               tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT);
                resblks = (uint)XFS_DIOSTRAT_SPACE_RES(mp, datablocks);
-               error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write,
-                                         resblks, 0);
+               error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks,
+                                       0, 0, &tp);
                /*
                 * Check for running out of space
                 */
index afe3dcb5c216f72c991e9a8bfaa4cebe2b3b59d6..ad340c41288dc392458c23a3feda65548043715b 100644 (file)
@@ -235,37 +235,21 @@ xfs_attr_set(
                        return error;
        }
 
-       /*
-        * Start our first transaction of the day.
-        *
-        * All future transactions during this code must be "chained" off
-        * this one via the trans_dup() call.  All transactions will contain
-        * the inode, and the inode will always be marked with trans_ihold().
-        * Since the inode will be locked in all transactions, we must log
-        * the inode in every transaction to let it float upward through
-        * the log.
-        */
-       args.trans = xfs_trans_alloc(mp, XFS_TRANS_ATTR_SET);
+       tres.tr_logres = M_RES(mp)->tr_attrsetm.tr_logres +
+                        M_RES(mp)->tr_attrsetrt.tr_logres * args.total;
+       tres.tr_logcount = XFS_ATTRSET_LOG_COUNT;
+       tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
 
        /*
         * Root fork attributes can use reserved data blocks for this
         * operation if necessary
         */
-
-       if (rsvd)
-               args.trans->t_flags |= XFS_TRANS_RESERVE;
-
-       tres.tr_logres = M_RES(mp)->tr_attrsetm.tr_logres +
-                        M_RES(mp)->tr_attrsetrt.tr_logres * args.total;
-       tres.tr_logcount = XFS_ATTRSET_LOG_COUNT;
-       tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
-       error = xfs_trans_reserve(args.trans, &tres, args.total, 0);
-       if (error) {
-               xfs_trans_cancel(args.trans);
+       error = xfs_trans_alloc(mp, &tres, args.total, 0,
+                       rsvd ? XFS_TRANS_RESERVE : 0, &args.trans);
+       if (error)
                return error;
-       }
-       xfs_ilock(dp, XFS_ILOCK_EXCL);
 
+       xfs_ilock(dp, XFS_ILOCK_EXCL);
        error = xfs_trans_reserve_quota_nblks(args.trans, dp, args.total, 0,
                                rsvd ? XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES :
                                       XFS_QMOPT_RES_REGBLKS);
@@ -421,32 +405,16 @@ xfs_attr_remove(
        if (error)
                return error;
 
-       /*
-        * Start our first transaction of the day.
-        *
-        * All future transactions during this code must be "chained" off
-        * this one via the trans_dup() call.  All transactions will contain
-        * the inode, and the inode will always be marked with trans_ihold().
-        * Since the inode will be locked in all transactions, we must log
-        * the inode in every transaction to let it float upward through
-        * the log.
-        */
-       args.trans = xfs_trans_alloc(mp, XFS_TRANS_ATTR_RM);
-
        /*
         * Root fork attributes can use reserved data blocks for this
         * operation if necessary
         */
-
-       if (flags & ATTR_ROOT)
-               args.trans->t_flags |= XFS_TRANS_RESERVE;
-
-       error = xfs_trans_reserve(args.trans, &M_RES(mp)->tr_attrrm,
-                                 XFS_ATTRRM_SPACE_RES(mp), 0);
-       if (error) {
-               xfs_trans_cancel(args.trans);
+       error = xfs_trans_alloc(mp, &M_RES(mp)->tr_attrrm,
+                       XFS_ATTRRM_SPACE_RES(mp), 0,
+                       (flags & ATTR_ROOT) ? XFS_TRANS_RESERVE : 0,
+                       &args.trans);
+       if (error)
                return error;
-       }
 
        xfs_ilock(dp, XFS_ILOCK_EXCL);
        /*
index cbcfd72f771e0bd450a04a7f875ef005ae7802d0..c2a2c53327e5bccce1fbbaaef787a48112d206cc 100644 (file)
@@ -1113,15 +1113,14 @@ xfs_bmap_add_attrfork(
 
        mp = ip->i_mount;
        ASSERT(!XFS_NOT_DQATTACHED(mp, ip));
-       tp = xfs_trans_alloc(mp, XFS_TRANS_ADDAFORK);
+
        blks = XFS_ADDAFORK_SPACE_RES(mp);
-       if (rsvd)
-               tp->t_flags |= XFS_TRANS_RESERVE;
-       error = xfs_trans_reserve(tp, &M_RES(mp)->tr_addafork, blks, 0);
-       if (error) {
-               xfs_trans_cancel(tp);
+
+       error = xfs_trans_alloc(mp, &M_RES(mp)->tr_addafork, blks, 0,
+                       rsvd ? XFS_TRANS_RESERVE : 0, &tp);
+       if (error)
                return error;
-       }
+
        xfs_ilock(ip, XFS_ILOCK_EXCL);
        error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ?
                        XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES :
@@ -6018,13 +6017,10 @@ xfs_bmap_split_extent(
        xfs_fsblock_t           firstfsb;
        int                     error;
 
-       tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT);
-       error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write,
-                       XFS_DIOSTRAT_SPACE_RES(mp, 0), 0);
-       if (error) {
-               xfs_trans_cancel(tp);
+       error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write,
+                       XFS_DIOSTRAT_SPACE_RES(mp, 0), 0, 0, &tp);
+       if (error)
                return error;
-       }
 
        xfs_ilock(ip, XFS_ILOCK_EXCL);
        xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
index 78ad8895e378f9ce967acc4eb4536a3ed2f2d038..45db6ae8e15a5afb4948d0de3fb31893057e39a7 100644 (file)
@@ -820,12 +820,10 @@ xfs_sync_sb(
        struct xfs_trans        *tp;
        int                     error;
 
-       tp = _xfs_trans_alloc(mp, XFS_TRANS_SB_CHANGE, KM_SLEEP);
-       error = xfs_trans_reserve(tp, &M_RES(mp)->tr_sb, 0, 0);
-       if (error) {
-               xfs_trans_cancel(tp);
+       error = xfs_trans_alloc(mp, &M_RES(mp)->tr_sb, 0, 0,
+                       XFS_TRANS_NO_WRITECOUNT, &tp);
+       if (error)
                return error;
-       }
 
        xfs_log_sb(tp);
        if (wait)
index 81ac870834da9e63515553e3fa291318acd1e73a..7d4ab6439081bdb0eef14d8f085ca3521ad50d97 100644 (file)
@@ -181,8 +181,9 @@ int xfs_log_calc_minimum_size(struct xfs_mount *);
 #define        XFS_TRANS_SYNC          0x08    /* make commit synchronous */
 #define XFS_TRANS_DQ_DIRTY     0x10    /* at least one dquot in trx dirty */
 #define XFS_TRANS_RESERVE      0x20    /* OK to use reserved data blocks */
-#define XFS_TRANS_FREEZE_PROT  0x40    /* Transaction has elevated writer
-                                          count in superblock */
+#define XFS_TRANS_NO_WRITECOUNT 0x40   /* do not elevate SB writecount */
+#define XFS_TRANS_NOFS         0x80    /* pass KM_NOFS to kmem_alloc */
+
 /*
  * Field values for xfs_trans_mod_sb.
  */
index 09a9439f0205cb1112716f6435377511744eb499..5f7f0b40b607389b8fa4d81d90e045827869c182 100644 (file)
@@ -25,7 +25,7 @@
  */
 static char *getstr(char **pp);
 static void fail(char *msg, int i);
-static void getres(xfs_trans_t *tp, uint blocks);
+static struct xfs_trans * getres(struct xfs_mount *mp, uint blocks);
 static void rsvfile(xfs_mount_t *mp, xfs_inode_t *ip, long long len);
 static int newfile(xfs_trans_t *tp, xfs_inode_t *ip, xfs_bmap_free_t *flist,
        xfs_fsblock_t *first, int dolocal, int logit, char *buf, int len);
@@ -125,25 +125,25 @@ res_failed(
        fail(_("cannot reserve space"), i);
 }
 
-static void
+static struct xfs_trans *
 getres(
-       xfs_trans_t     *tp,
+       struct xfs_mount *mp,
        uint            blocks)
 {
+       struct xfs_trans *tp;
        int             i;
-       xfs_mount_t     *mp;
        uint            r;
 
-       mp = tp->t_mountp;
        for (i = 0, r = MKFS_BLOCKRES(blocks); r >= blocks; r--) {
                struct xfs_trans_res    tres = {0};
 
-               i = -libxfs_trans_reserve(tp, &tres, r, 0);
+               i = -libxfs_trans_alloc(mp, &tres, r, 0, 0, &tp);
                if (i == 0)
-                       return;
+                       return tp;
        }
        res_failed(i);
        /* NOTREACHED */
+       return NULL;
 }
 
 static char *
@@ -192,6 +192,7 @@ rsvfile(
 {
        int             error;
        xfs_trans_t     *tp;
+       struct xfs_trans_res tres = {0};
 
        error = -libxfs_alloc_file_space(ip, 0, llen, 1, 0);
 
@@ -203,8 +204,7 @@ rsvfile(
        /*
         * update the inode timestamp, mode, and prealloc flag bits
         */
-       tp = libxfs_trans_alloc(mp, 0);
-
+       libxfs_trans_alloc(mp, &tres, 0, 0, 0, &tp);
        libxfs_trans_ijoin(tp, ip, 0);
 
        VFS_I(ip)->i_mode &= ~S_ISUID;
@@ -454,13 +454,12 @@ parseproto(
        xname.name = (unsigned char *)name;
        xname.len = name ? strlen(name) : 0;
        xname.type = 0;
-       tp = libxfs_trans_alloc(mp, 0);
        flags = XFS_ILOG_CORE;
        xfs_bmap_init(&flist, &first);
        switch (fmt) {
        case IF_REGULAR:
                buf = newregfile(pp, &len);
-               getres(tp, XFS_B_TO_FSB(mp, len));
+               tp = getres(mp, XFS_B_TO_FSB(mp, len));
                error = -libxfs_inode_alloc(&tp, pip, mode|S_IFREG, 1, 0,
                                           &creds, fsxp, &ip);
                if (error)
@@ -483,7 +482,7 @@ parseproto(
                                progname, value, name);
                        exit(1);
                }
-               getres(tp, XFS_B_TO_FSB(mp, llen));
+               tp = getres(mp, XFS_B_TO_FSB(mp, llen));
 
                error = -libxfs_inode_alloc(&tp, pip, mode|S_IFREG, 1, 0,
                                          &creds, fsxp, &ip);
@@ -505,7 +504,7 @@ parseproto(
                return;
 
        case IF_BLOCK:
-               getres(tp, 0);
+               tp = getres(mp, 0);
                majdev = getnum(getstr(pp), 0, 0, false);
                mindev = getnum(getstr(pp), 0, 0, false);
                error = -libxfs_inode_alloc(&tp, pip, mode|S_IFBLK, 1,
@@ -520,7 +519,7 @@ parseproto(
                break;
 
        case IF_CHAR:
-               getres(tp, 0);
+               tp = getres(mp, 0);
                majdev = getnum(getstr(pp), 0, 0, false);
                mindev = getnum(getstr(pp), 0, 0, false);
                error = -libxfs_inode_alloc(&tp, pip, mode|S_IFCHR, 1,
@@ -534,7 +533,7 @@ parseproto(
                break;
 
        case IF_FIFO:
-               getres(tp, 0);
+               tp = getres(mp, 0);
                error = -libxfs_inode_alloc(&tp, pip, mode|S_IFIFO, 1, 0,
                                &creds, fsxp, &ip);
                if (error)
@@ -546,7 +545,7 @@ parseproto(
        case IF_SYMLINK:
                buf = getstr(pp);
                len = (int)strlen(buf);
-               getres(tp, XFS_B_TO_FSB(mp, len));
+               tp = getres(mp, XFS_B_TO_FSB(mp, len));
                error = -libxfs_inode_alloc(&tp, pip, mode|S_IFLNK, 1, 0,
                                &creds, fsxp, &ip);
                if (error)
@@ -557,7 +556,7 @@ parseproto(
                newdirent(mp, tp, pip, &xname, ip->i_ino, &first, &flist);
                break;
        case IF_DIRECTORY:
-               getres(tp, 0);
+               tp = getres(mp, 0);
                error = -libxfs_inode_alloc(&tp, pip, mode|S_IFDIR, 1, 0,
                                &creds, fsxp, &ip);
                if (error)
@@ -649,8 +648,7 @@ rtinit(
        /*
         * First, allocate the inodes.
         */
-       tp = libxfs_trans_alloc(mp, 0);
-       i = -libxfs_trans_reserve(tp, &tres, MKFS_BLOCKRES_INODE, 0);
+       i = -libxfs_trans_alloc(mp, &tres, MKFS_BLOCKRES_INODE, 0, 0, &tp);
        if (i)
                res_failed(i);
 
@@ -687,9 +685,9 @@ rtinit(
        /*
         * Next, give the bitmap file some zero-filled blocks.
         */
-       tp = libxfs_trans_alloc(mp, 0);
-       i = -libxfs_trans_reserve(tp, &tres, mp->m_sb.sb_rbmblocks +
-                                (XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1), 0);
+       i = -libxfs_trans_alloc(mp, &tres,
+               mp->m_sb.sb_rbmblocks + (XFS_BM_MAXLEVELS(mp,XFS_DATA_FORK) - 1),
+                               0, 0, &tp);
        if (i)
                res_failed(i);
 
@@ -723,10 +721,10 @@ rtinit(
        /*
         * Give the summary file some zero-filled blocks.
         */
-       tp = libxfs_trans_alloc(mp, 0);
        nsumblocks = mp->m_rsumsize >> mp->m_sb.sb_blocklog;
-       i = -libxfs_trans_reserve(tp, &tres, nsumblocks +
-                                (XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1), 0);
+       i = -libxfs_trans_alloc(mp, &tres,
+                       nsumblocks + (XFS_BM_MAXLEVELS(mp,XFS_DATA_FORK) - 1),
+                               0, 0, &tp);
        if (i)
                res_failed(i);
        libxfs_trans_ijoin(tp, rsumip, 0);
@@ -760,8 +758,7 @@ rtinit(
         * Do one transaction per bitmap block.
         */
        for (bno = 0; bno < mp->m_sb.sb_rextents; bno = ebno) {
-               tp = libxfs_trans_alloc(mp, 0);
-               i = -libxfs_trans_reserve(tp, &tres, 0, 0);
+               i = -libxfs_trans_alloc(mp, &tres, 0, 0, 0, &tp);
                if (i)
                        res_failed(i);
                libxfs_trans_ijoin(tp, rbmip, 0);
index 82c9eaafad68627bd86dfd303c83c43e1ab9c2e6..8007dd0c6c67a774a259fd05e434b2071b6c1c55 100644 (file)
@@ -3136,15 +3136,16 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
                xfs_trans_t     *tp;
                struct xfs_trans_res tres = {0};
 
+               c = libxfs_trans_alloc(mp, &tres, worst_freelist, 0, 0, &tp);
+               if (c)
+                       res_failed(c);
+
                memset(&args, 0, sizeof(args));
-               args.tp = tp = libxfs_trans_alloc(mp, 0);
+               args.tp = tp;
                args.mp = mp;
                args.agno = agno;
                args.alignment = 1;
                args.pag = xfs_perag_get(mp,agno);
-               c = -libxfs_trans_reserve(tp, &tres, worst_freelist, 0);
-               if (c)
-                       res_failed(c);
 
                libxfs_alloc_fix_freelist(&args, 0);
                xfs_perag_put(args.pag);
index 5d48848142a51d76f16a3bf34ce6760449eaa240..bc6f503663ba349d26e0e0b8104e1a96812993f0 100644 (file)
@@ -1505,13 +1505,13 @@ build_agf_agfl(xfs_mount_t      *mp,
                int             error;
 
                memset(&args, 0, sizeof(args));
-               args.tp = tp = libxfs_trans_alloc(mp, 0);
+               args.pag = xfs_perag_get(mp,agno);
+               libxfs_trans_alloc(mp, &tres,
+                       xfs_alloc_min_freelist(mp, args.pag), 0, 0, &tp);
+               args.tp = tp;
                args.mp = mp;
                args.agno = agno;
                args.alignment = 1;
-               args.pag = xfs_perag_get(mp,agno);
-               libxfs_trans_reserve(tp, &tres,
-                                    xfs_alloc_min_freelist(mp, args.pag), 0);
                error = libxfs_alloc_fix_freelist(&args, 0);
                xfs_perag_put(args.pag);
                if (error) {
index 774e2cd7670c243a619a64d20cb54bdacc532237..419eb8939956c3976312494c3087534606b7b670 100644 (file)
@@ -494,9 +494,7 @@ mk_rbmino(xfs_mount_t *mp)
        /*
         * first set up inode
         */
-       tp = libxfs_trans_alloc(mp, 0);
-
-       i = -libxfs_trans_reserve(tp, &tres, 10, 0);
+       i = -libxfs_trans_alloc(mp, &tres, 10, 0, 0, &tp);
        if (i)
                res_failed(i);
 
@@ -544,9 +542,9 @@ mk_rbmino(xfs_mount_t *mp)
         * then allocate blocks for file and fill with zeroes (stolen
         * from mkfs)
         */
-       tp = libxfs_trans_alloc(mp, 0);
-       error = -libxfs_trans_reserve(tp, &tres, mp->m_sb.sb_rbmblocks +
-                               (XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1), 0);
+       error = -libxfs_trans_alloc(mp, &tres,
+               mp->m_sb.sb_rbmblocks + (XFS_BM_MAXLEVELS(mp,XFS_DATA_FORK) - 1),
+                                  0, 0, &tp);
        if (error)
                res_failed(error);
 
@@ -598,9 +596,7 @@ fill_rbmino(xfs_mount_t *mp)
        bmp = btmcompute;
        bno = 0;
 
-       tp = libxfs_trans_alloc(mp, 0);
-
-       error = -libxfs_trans_reserve(tp, &tres, 10, 0);
+       error = -libxfs_trans_alloc(mp, &tres, 10, 0, 0, &tp);
        if (error)
                res_failed(error);
 
@@ -671,9 +667,7 @@ fill_rsumino(xfs_mount_t *mp)
        bno = 0;
        end_bno = mp->m_rsumsize >> mp->m_sb.sb_blocklog;
 
-       tp = libxfs_trans_alloc(mp, 0);
-
-       error = -libxfs_trans_reserve(tp, &tres, 10, 0);
+       error = -libxfs_trans_alloc(mp, &tres, 10, 0, 0, &tp);
        if (error)
                res_failed(error);
 
@@ -747,9 +741,7 @@ mk_rsumino(xfs_mount_t *mp)
        /*
         * first set up inode
         */
-       tp = libxfs_trans_alloc(mp, 0);
-
-       i = -libxfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 10, 0);
+       i = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 10, 0, 0, &tp);
        if (i)
                res_failed(i);
 
@@ -797,15 +789,15 @@ mk_rsumino(xfs_mount_t *mp)
         * then allocate blocks for file and fill with zeroes (stolen
         * from mkfs)
         */
-       tp = libxfs_trans_alloc(mp, 0);
        xfs_bmap_init(&flist, &first);
 
        nsumblocks = mp->m_rsumsize >> mp->m_sb.sb_blocklog;
        tres.tr_logres = BBTOB(128);
        tres.tr_logcount = XFS_DEFAULT_PERM_LOG_COUNT;
        tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
-       error = -libxfs_trans_reserve(tp, &tres, mp->m_sb.sb_rbmblocks +
-                             (XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1), 0);
+       error = -libxfs_trans_alloc(mp, &tres,
+               mp->m_sb.sb_rbmblocks + (XFS_BM_MAXLEVELS(mp,XFS_DATA_FORK) - 1),
+                                   0, 0, &tp);
        if (error)
                res_failed(error);
 
@@ -854,10 +846,8 @@ mk_root_dir(xfs_mount_t *mp)
        int             vers;
        int             times;
 
-       tp = libxfs_trans_alloc(mp, 0);
        ip = NULL;
-
-       i = -libxfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 10, 0);
+       i = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 10, 0, 0, &tp);
        if (i)
                res_failed(i);
 
@@ -953,12 +943,9 @@ mk_orphanage(xfs_mount_t *mp)
        /*
         * could not be found, create it
         */
-
-       tp = libxfs_trans_alloc(mp, 0);
        xfs_bmap_init(&flist, &first);
-
        nres = XFS_MKDIR_SPACE_RES(mp, xname.len);
-       i = -libxfs_trans_reserve(tp, &M_RES(mp)->tr_mkdir, nres, 0);
+       i = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_mkdir, nres, 0, 0, &tp);
        if (i)
                res_failed(i);
 
@@ -1092,8 +1079,6 @@ mv_orphanage(
                xname.len = snprintf((char *)fname, sizeof(fname), "%llu.%d",
                                        (unsigned long long)ino, ++incr);
 
-       tp = libxfs_trans_alloc(mp, 0);
-
        if ((err = -libxfs_iget(mp, NULL, ino, 0, &ino_p, 0)))
                do_error(_("%d - couldn't iget disconnected inode\n"), err);
 
@@ -1112,8 +1097,8 @@ mv_orphanage(
                if (err) {
                        ASSERT(err == ENOENT);
 
-                       err = -libxfs_trans_reserve(tp, &M_RES(mp)->tr_rename,
-                                                  nres, 0);
+                       err = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_rename,
+                                                 nres, 0, 0, &tp);
                        if (err)
                                do_error(
        _("space reservation failed (%d), filesystem may be out of space\n"),
@@ -1154,8 +1139,8 @@ mv_orphanage(
 
                        libxfs_trans_commit(tp);
                } else  {
-                       err = -libxfs_trans_reserve(tp, &M_RES(mp)->tr_rename,
-                                                  nres, 0);
+                       err = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_rename,
+                                                 nres, 0, 0, &tp);
                        if (err)
                                do_error(
        _("space reservation failed (%d), filesystem may be out of space\n"),
@@ -1210,8 +1195,8 @@ mv_orphanage(
                 * also accounted for in the create
                 */
                nres = XFS_DIRENTER_SPACE_RES(mp, xname.len);
-               err = -libxfs_trans_reserve(tp, &M_RES(mp)->tr_remove,
-                                          nres, 0);
+               err = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_remove,
+                                         nres, 0, 0, &tp);
                if (err)
                        do_error(
        _("space reservation failed (%d), filesystem may be out of space\n"),
@@ -1306,9 +1291,8 @@ longform_dir2_rebuild(
 
        xfs_bmap_init(&flist, &firstblock);
 
-       tp = libxfs_trans_alloc(mp, 0);
        nres = XFS_REMOVE_SPACE_RES(mp);
-       error = -libxfs_trans_reserve(tp, &M_RES(mp)->tr_remove, nres, 0);
+       error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_remove, nres, 0, 0, &tp);
        if (error)
                res_failed(error);
        libxfs_trans_ijoin(tp, ip, 0);
@@ -1349,10 +1333,9 @@ longform_dir2_rebuild(
                                                p->name.name[1] == '.'))))
                        continue;
 
-               tp = libxfs_trans_alloc(mp, 0);
                nres = XFS_CREATE_SPACE_RES(mp, p->name.len);
-               error = -libxfs_trans_reserve(tp, &M_RES(mp)->tr_create,
-                                            nres, 0);
+               error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_create,
+                                           nres, 0, 0, &tp);
                if (error)
                        res_failed(error);
 
@@ -1406,9 +1389,8 @@ dir2_kill_block(
        int             nres;
        xfs_trans_t     *tp;
 
-       tp = libxfs_trans_alloc(mp, 0);
        nres = XFS_REMOVE_SPACE_RES(mp);
-       error = -libxfs_trans_reserve(tp, &M_RES(mp)->tr_remove, nres, 0);
+       error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_remove, nres, 0, 0, &tp);
        if (error)
                res_failed(error);
        libxfs_trans_ijoin(tp, ip, 0);
@@ -1598,8 +1580,7 @@ longform_dir2_entry_check_data(
        if (freetab->nents < db + 1)
                freetab->nents = db + 1;
 
-       tp = libxfs_trans_alloc(mp, 0);
-       error = -libxfs_trans_reserve(tp, &M_RES(mp)->tr_remove, 0, 0);
+       error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_remove, 0, 0, 0, &tp);
        if (error)
                res_failed(error);
        da.trans = tp;
@@ -2902,7 +2883,6 @@ process_dir_inode(
                        break;
 
                case XFS_DINODE_FMT_LOCAL:
-                       tp = libxfs_trans_alloc(mp, 0);
                        /*
                         * using the remove reservation is overkill
                         * since at most we'll only need to log the
@@ -2910,8 +2890,8 @@ process_dir_inode(
                         * new define in ourselves.
                         */
                        nres = no_modify ? 0 : XFS_REMOVE_SPACE_RES(mp);
-                       error = -libxfs_trans_reserve(tp, &M_RES(mp)->tr_remove,
-                                                    nres, 0);
+                       error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_remove,
+                                                   nres, 0, 0, &tp);
                        if (error)
                                res_failed(error);
 
@@ -2951,11 +2931,9 @@ process_dir_inode(
 
                do_warn(_("recreating root directory .. entry\n"));
 
-               tp = libxfs_trans_alloc(mp, 0);
-               ASSERT(tp != NULL);
-
                nres = XFS_MKDIR_SPACE_RES(mp, 2);
-               error = -libxfs_trans_reserve(tp, &M_RES(mp)->tr_mkdir, nres, 0);
+               error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_mkdir,
+                                           nres, 0, 0, &tp);
                if (error)
                        res_failed(error);
 
@@ -3010,12 +2988,9 @@ process_dir_inode(
                        do_warn(
        _("creating missing \".\" entry in dir ino %" PRIu64 "\n"), ino);
 
-                       tp = libxfs_trans_alloc(mp, 0);
-                       ASSERT(tp != NULL);
-
                        nres = XFS_MKDIR_SPACE_RES(mp, 1);
-                       error = -libxfs_trans_reserve(tp, &M_RES(mp)->tr_mkdir,
-                                                    nres, 0);
+                       error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_mkdir,
+                                                   nres, 0, 0, &tp);
                        if (error)
                                res_failed(error);
 
index 3e234b980ce8750ebebf0ecc6d720b755d434d98..8bce117d3d38bec9645f0fe8479e91ff3186c60d 100644 (file)
@@ -40,10 +40,8 @@ update_inode_nlinks(
        int                     dirty;
        int                     nres;
 
-       tp = libxfs_trans_alloc(mp, XFS_TRANS_REMOVE);
-
        nres = no_modify ? 0 : 10;
-       error = -libxfs_trans_reserve(tp, &M_RES(mp)->tr_remove, nres, 0);
+       error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_remove, nres, 0, 0, &tp);
        ASSERT(error == 0);
 
        error = -libxfs_trans_iget(mp, tp, ino, 0, 0, &ip);