[Top] [All Lists]

[PATCH v2 3/3] xfs: kill unnecessary firstused overflow check on attr3 l

To: xfs@xxxxxxxxxxx
Subject: [PATCH v2 3/3] xfs: kill unnecessary firstused overflow check on attr3 leaf removal
From: Brian Foster <bfoster@xxxxxxxxxx>
Date: Mon, 30 Mar 2015 11:12:45 -0400
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1427728365-15842-1-git-send-email-bfoster@xxxxxxxxxx>
References: <1427728365-15842-1-git-send-email-bfoster@xxxxxxxxxx>
xfs_attr3_leaf_remove() removes an attribute from an attr leaf block. If
the attribute nameval data happens to be at the start of the nameval
region, a new start offset (firstused) for the region is calculated
(since the region grows from the tail of the block to the start). Once
the new firstused is calculated, it is checked for zero in an apparent
overflow check.

Now that the in-core firstused is 32-bit, overflow is not possible and
this check can be removed. Since the purpose for this check is not
documented and appears to exist since the port to Linux, be conservative
and replace it with an assert.

Signed-off-by: Brian Foster <bfoster@xxxxxxxxxx>
 fs/xfs/libxfs/xfs_attr_leaf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index 149ef3f..04e79d5 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -1996,8 +1996,7 @@ xfs_attr3_leaf_remove(
                                tmp = be16_to_cpu(entry->nameidx);
                ichdr.firstused = tmp;
-               if (!ichdr.firstused)
-                       ichdr.firstused = tmp - XFS_ATTR_LEAF_NAME_ALIGN;
+               ASSERT(ichdr.firstused != 0);
        } else {
                ichdr.holes = 1;        /* mark as needing compaction */

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