@@ -356,7 +356,6 @@ xfs_da3_split(
356356 struct xfs_da_state_blk * newblk ;
357357 struct xfs_da_state_blk * addblk ;
358358 struct xfs_da_intnode * node ;
359- struct xfs_buf * bp ;
360359 int max ;
361360 int action = 0 ;
362361 int error ;
@@ -397,7 +396,9 @@ xfs_da3_split(
397396 break ;
398397 }
399398 /*
400- * Entry wouldn't fit, split the leaf again.
399+ * Entry wouldn't fit, split the leaf again. The new
400+ * extrablk will be consumed by xfs_da3_node_split if
401+ * the node is split.
401402 */
402403 state -> extravalid = 1 ;
403404 if (state -> inleaf ) {
@@ -445,6 +446,14 @@ xfs_da3_split(
445446 if (!addblk )
446447 return 0 ;
447448
449+ /*
450+ * xfs_da3_node_split() should have consumed any extra blocks we added
451+ * during a double leaf split in the attr fork. This is guaranteed as
452+ * we can't be here if the attr fork only has a single leaf block.
453+ */
454+ ASSERT (state -> extravalid == 0 ||
455+ state -> path .blk [max ].magic == XFS_DIR2_LEAFN_MAGIC );
456+
448457 /*
449458 * Split the root node.
450459 */
@@ -457,43 +466,33 @@ xfs_da3_split(
457466 }
458467
459468 /*
460- * Update pointers to the node which used to be block 0 and
461- * just got bumped because of the addition of a new root node.
462- * There might be three blocks involved if a double split occurred,
463- * and the original block 0 could be at any position in the list .
469+ * Update pointers to the node which used to be block 0 and just got
470+ * bumped because of the addition of a new root node. Note that the
471+ * original block 0 could be at any position in the list of blocks in
472+ * the tree .
464473 *
465- * Note: the magic numbers and sibling pointers are in the same
466- * physical place for both v2 and v3 headers (by design). Hence it
467- * doesn't matter which version of the xfs_da_intnode structure we use
468- * here as the result will be the same using either structure.
474+ * Note: the magic numbers and sibling pointers are in the same physical
475+ * place for both v2 and v3 headers (by design). Hence it doesn't matter
476+ * which version of the xfs_da_intnode structure we use here as the
477+ * result will be the same using either structure.
469478 */
470479 node = oldblk -> bp -> b_addr ;
471480 if (node -> hdr .info .forw ) {
472- if (be32_to_cpu (node -> hdr .info .forw ) == addblk -> blkno ) {
473- bp = addblk -> bp ;
474- } else {
475- ASSERT (state -> extravalid );
476- bp = state -> extrablk .bp ;
477- }
478- node = bp -> b_addr ;
481+ ASSERT (be32_to_cpu (node -> hdr .info .forw ) == addblk -> blkno );
482+ node = addblk -> bp -> b_addr ;
479483 node -> hdr .info .back = cpu_to_be32 (oldblk -> blkno );
480- xfs_trans_log_buf (state -> args -> trans , bp ,
481- XFS_DA_LOGRANGE (node , & node -> hdr .info ,
482- sizeof (node -> hdr .info )));
484+ xfs_trans_log_buf (state -> args -> trans , addblk -> bp ,
485+ XFS_DA_LOGRANGE (node , & node -> hdr .info ,
486+ sizeof (node -> hdr .info )));
483487 }
484488 node = oldblk -> bp -> b_addr ;
485489 if (node -> hdr .info .back ) {
486- if (be32_to_cpu (node -> hdr .info .back ) == addblk -> blkno ) {
487- bp = addblk -> bp ;
488- } else {
489- ASSERT (state -> extravalid );
490- bp = state -> extrablk .bp ;
491- }
492- node = bp -> b_addr ;
490+ ASSERT (be32_to_cpu (node -> hdr .info .back ) == addblk -> blkno );
491+ node = addblk -> bp -> b_addr ;
493492 node -> hdr .info .forw = cpu_to_be32 (oldblk -> blkno );
494- xfs_trans_log_buf (state -> args -> trans , bp ,
495- XFS_DA_LOGRANGE (node , & node -> hdr .info ,
496- sizeof (node -> hdr .info )));
493+ xfs_trans_log_buf (state -> args -> trans , addblk -> bp ,
494+ XFS_DA_LOGRANGE (node , & node -> hdr .info ,
495+ sizeof (node -> hdr .info )));
497496 }
498497 addblk -> bp = NULL ;
499498 return 0 ;
0 commit comments