Skip to content

Commit 997def2

Browse files
Mark TinguelyBen Myers
authored andcommitted
xfs: fix node forward in xfs_node_toosmall
Commit f5ea110 cleans up the disk to host conversions for node directory entries, but because a variable is reused in xfs_node_toosmall() the next node is not correctly found. If the original node is small enough (<= 3/8 of the node size), this change may incorrectly cause a node collapse when it should not. That will cause an assert in xfstest generic/319: Assertion failed: first <= last && last < BBTOB(bp->b_length), file: /root/newest/xfs/fs/xfs/xfs_trans_buf.c, line: 569 Keep the original node header to get the correct forward node. (When a node is considered for a merge with a sibling, it overwrites the sibling pointers of the original incore nodehdr with the sibling's pointers. This leads to loop considering the original node as a merge candidate with itself in the second pass, and so it incorrectly determines a merge should occur.) Signed-off-by: Mark Tinguely <tinguely@sgi.com> Reviewed-by: Ben Myers <bpm@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com> [v3: added Dave Chinner's (slightly modified) suggestion to the commit header, cleaned up whitespace. -bpm]
1 parent 566055d commit 997def2

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

fs/xfs/xfs_da_btree.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,7 @@ xfs_da3_node_toosmall(
12241224
/* start with smaller blk num */
12251225
forward = nodehdr.forw < nodehdr.back;
12261226
for (i = 0; i < 2; forward = !forward, i++) {
1227+
struct xfs_da3_icnode_hdr thdr;
12271228
if (forward)
12281229
blkno = nodehdr.forw;
12291230
else
@@ -1236,10 +1237,10 @@ xfs_da3_node_toosmall(
12361237
return(error);
12371238

12381239
node = bp->b_addr;
1239-
xfs_da3_node_hdr_from_disk(&nodehdr, node);
1240+
xfs_da3_node_hdr_from_disk(&thdr, node);
12401241
xfs_trans_brelse(state->args->trans, bp);
12411242

1242-
if (count - nodehdr.count >= 0)
1243+
if (count - thdr.count >= 0)
12431244
break; /* fits with at least 25% to spare */
12441245
}
12451246
if (i >= 2) {

0 commit comments

Comments
 (0)