xfs
[Top] [All Lists]

[PATCH 16/18] xfs: pass xfs_da_args to xfs_attr_leaf_newentsize

To: xfs@xxxxxxxxxxx
Subject: [PATCH 16/18] xfs: pass xfs_da_args to xfs_attr_leaf_newentsize
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Thu, 8 May 2014 18:19:46 +1000
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1399537188-26509-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1399537188-26509-1-git-send-email-david@xxxxxxxxxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

As it's only ever called from contexts where the xfs_da_args is
present and contains all the information needed inside the args
structure.

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
---
 fs/xfs/xfs_attr.c      |  4 +---
 fs/xfs/xfs_attr_leaf.c | 47 +++++++++++++++++------------------------------
 fs/xfs/xfs_attr_leaf.h |  3 +--
 3 files changed, 19 insertions(+), 35 deletions(-)

diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index ab2679a..39fad96 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -198,9 +198,7 @@ xfs_attr_calc_size(
         * Determine space new attribute will use, and if it would be
         * "local" or "remote" (note: local != inline).
         */
-       size = xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
-                                       args->geo->blksize, local);
-
+       size = xfs_attr_leaf_newentsize(args, local);
        nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK);
        if (*local) {
                if (size > (args->geo->blksize / 2)) {
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index ab652e9..c0c6132 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -1075,8 +1075,7 @@ xfs_attr3_leaf_add(
        leaf = bp->b_addr;
        xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf);
        ASSERT(args->index >= 0 && args->index <= ichdr.count);
-       entsize = xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
-                          args->geo->blksize, NULL);
+       entsize = xfs_attr_leaf_newentsize(args, NULL);
 
        /*
         * Search through freemap for first-fit on new name length.
@@ -1178,14 +1177,11 @@ xfs_attr3_leaf_add_work(
        ASSERT(ichdr->freemap[mapindex].base < XFS_LBSIZE(mp));
        ASSERT((ichdr->freemap[mapindex].base & 0x3) == 0);
        ASSERT(ichdr->freemap[mapindex].size >=
-               xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
-                                        args->geo->blksize, NULL));
+               xfs_attr_leaf_newentsize(args, NULL));
        ASSERT(ichdr->freemap[mapindex].size < XFS_LBSIZE(mp));
        ASSERT((ichdr->freemap[mapindex].size & 0x3) == 0);
 
-       ichdr->freemap[mapindex].size -=
-                       xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
-                                                args->geo->blksize, &tmp);
+       ichdr->freemap[mapindex].size -= xfs_attr_leaf_newentsize(args, &tmp);
 
        entry->nameidx = cpu_to_be16(ichdr->freemap[mapindex].base +
                                     ichdr->freemap[mapindex].size);
@@ -1593,9 +1589,7 @@ xfs_attr3_leaf_figure_balance(
        max = ichdr1->count + ichdr2->count;
        half = (max + 1) * sizeof(*entry);
        half += ichdr1->usedbytes + ichdr2->usedbytes +
-                       xfs_attr_leaf_newentsize(state->args->namelen,
-                                                state->args->valuelen,
-                                                state->blocksize, NULL);
+                       xfs_attr_leaf_newentsize(state->args, NULL);
        half /= 2;
        lastdelta = state->blocksize;
        entry = xfs_attr3_leaf_entryp(leaf1);
@@ -1607,10 +1601,7 @@ xfs_attr3_leaf_figure_balance(
                 */
                if (count == blk1->index) {
                        tmp = totallen + sizeof(*entry) +
-                               xfs_attr_leaf_newentsize(
-                                               state->args->namelen,
-                                               state->args->valuelen,
-                                               state->blocksize, NULL);
+                               xfs_attr_leaf_newentsize(state->args, NULL);
                        if (XFS_ATTR_ABS(half - tmp) > lastdelta)
                                break;
                        lastdelta = XFS_ATTR_ABS(half - tmp);
@@ -1646,10 +1637,7 @@ xfs_attr3_leaf_figure_balance(
        totallen -= count * sizeof(*entry);
        if (foundit) {
                totallen -= sizeof(*entry) +
-                               xfs_attr_leaf_newentsize(
-                                               state->args->namelen,
-                                               state->args->valuelen,
-                                               state->blocksize, NULL);
+                               xfs_attr_leaf_newentsize(state->args, NULL);
        }
 
        *countarg = count;
@@ -2440,22 +2428,21 @@ xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int 
index)
  * a "local" or a "remote" attribute.
  */
 int
-xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize, int *local)
+xfs_attr_leaf_newentsize(
+       struct xfs_da_args      *args,
+       int                     *local)
 {
-       int size;
+       int                     size;
 
-       size = xfs_attr_leaf_entsize_local(namelen, valuelen);
-       if (size < xfs_attr_leaf_entsize_local_max(blocksize)) {
-               if (local) {
+       size = xfs_attr_leaf_entsize_local(args->namelen, args->valuelen);
+       if (size < xfs_attr_leaf_entsize_local_max(args->geo->blksize)) {
+               if (local)
                        *local = 1;
-               }
-       } else {
-               size = xfs_attr_leaf_entsize_remote(namelen);
-               if (local) {
-                       *local = 0;
-               }
+               return size;
        }
-       return size;
+       if (local)
+               *local = 0;
+       return xfs_attr_leaf_entsize_remote(args->namelen);
 }
 
 
diff --git a/fs/xfs/xfs_attr_leaf.h b/fs/xfs/xfs_attr_leaf.h
index 3ec5ec0..e2929da 100644
--- a/fs/xfs/xfs_attr_leaf.h
+++ b/fs/xfs/xfs_attr_leaf.h
@@ -96,8 +96,7 @@ int   xfs_attr3_root_inactive(struct xfs_trans **trans, 
struct xfs_inode *dp);
 xfs_dahash_t   xfs_attr_leaf_lasthash(struct xfs_buf *bp, int *count);
 int    xfs_attr_leaf_order(struct xfs_buf *leaf1_bp,
                                   struct xfs_buf *leaf2_bp);
-int    xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize,
-                                       int *local);
+int    xfs_attr_leaf_newentsize(struct xfs_da_args *args, int *local);
 int    xfs_attr3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp,
                        xfs_dablk_t bno, xfs_daddr_t mappedbno,
                        struct xfs_buf **bpp);
-- 
1.9.0

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