xfs
[Top] [All Lists]

[PATCH v3 3/4] xfs: replace on-stack xfs_trans_res with pointer in xfs_c

To: xfs@xxxxxxxxxxx
Subject: [PATCH v3 3/4] xfs: replace on-stack xfs_trans_res with pointer in xfs_create()
From: Brian Foster <bfoster@xxxxxxxxxx>
Date: Tue, 15 Apr 2014 12:18:25 -0400
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1397578706-5385-1-git-send-email-bfoster@xxxxxxxxxx>
References: <1397578706-5385-1-git-send-email-bfoster@xxxxxxxxxx>
There's no need to store a full struct xfs_trans_res on the stack in
xfs_create() and copy the fields. Use a pointer to the appropriate
structures embedded in the xfs_mount.

Signed-off-by: Brian Foster <bfoster@xxxxxxxxxx>
---
 fs/xfs/xfs_inode.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 0e63c7d..f8a232a 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1158,7 +1158,7 @@ xfs_create(
        struct xfs_dquot        *udqp = NULL;
        struct xfs_dquot        *gdqp = NULL;
        struct xfs_dquot        *pdqp = NULL;
-       struct xfs_trans_res    tres;
+       struct xfs_trans_res    *tres;
        uint                    resblks;
 
        trace_xfs_create(dp, name);
@@ -1181,13 +1181,11 @@ xfs_create(
        if (is_dir) {
                rdev = 0;
                resblks = XFS_MKDIR_SPACE_RES(mp, name->len);
-               tres.tr_logres = M_RES(mp)->tr_mkdir.tr_logres;
-               tres.tr_logcount = XFS_MKDIR_LOG_COUNT;
+               tres = &M_RES(mp)->tr_mkdir;
                tp = xfs_trans_alloc(mp, XFS_TRANS_MKDIR);
        } else {
                resblks = XFS_CREATE_SPACE_RES(mp, name->len);
-               tres.tr_logres = M_RES(mp)->tr_create.tr_logres;
-               tres.tr_logcount = XFS_CREATE_LOG_COUNT;
+               tres = &M_RES(mp)->tr_create;
                tp = xfs_trans_alloc(mp, XFS_TRANS_CREATE);
        }
 
@@ -1199,17 +1197,16 @@ xfs_create(
         * the case we'll drop the one we have and get a more
         * appropriate transaction later.
         */
-       tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
-       error = xfs_trans_reserve(tp, &tres, resblks, 0);
+       error = xfs_trans_reserve(tp, tres, resblks, 0);
        if (error == ENOSPC) {
                /* flush outstanding delalloc blocks and retry */
                xfs_flush_inodes(mp);
-               error = xfs_trans_reserve(tp, &tres, resblks, 0);
+               error = xfs_trans_reserve(tp, tres, resblks, 0);
        }
        if (error == ENOSPC) {
                /* No space at all so try a "no-allocation" reservation */
                resblks = 0;
-               error = xfs_trans_reserve(tp, &tres, 0, 0);
+               error = xfs_trans_reserve(tp, tres, 0, 0);
        }
        if (error) {
                cancel_flags = 0;
-- 
1.8.3.1

<Prev in Thread] Current Thread [Next in Thread>