Skip to contentSkip to conversation

xfsprogs: reduce bb_numrecs in bno/cnt btrees when log consumes all agf space

PATCH Superseded Brian Foster 2 participants 3 messages Mar 18, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfsprogs: reduce bb_numrecs in bno/cnt btrees when log consumes all agf space

The mkfs code currently creates a single free space extent record for each of the bno and cnt btrees in each AG. The start block of the record is pushed forward on the AG that hosts an internal log. If the log happens to consume all available space in the AG, the start block becomes equal to sb->sb_agblocks and thus invalid. This causes xfs_repair to complain.

For example, the following sequence:

	mkfs.xfs -d file,name=./fs.img,size=50g,agsize=16m
	xfs_repair ./fs.img

... produces the following xfs_repair output:

Phase 1 - find and verify superblock...
Phase 2 - using internal log
- scan filesystem freespace and inode maps...
invalid start block 4096 in record 0 of bno btree block 1600/1 invalid start block 4096 in record 0 of cnt btree block 1600/2
- found root inode chunk
...

xfs_repair appears to correct the numrecs value such that subsequent checks are successful. The sequence above is pulled from xfstests

Modify mkfs.xfs such that we check the block count value of the free space record for the log AG after the log is accounted for. If no space is left for the record, reset the record count to 0.

---
 mkfs/xfs_mkfs.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
mkfs/xfs_mkfs.c +6 -0
index c84448e..c4ae15b 100644
@@ -2594,6 +2594,9 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
 		}
 		arec->ar_blockcount = cpu_to_be32(agsize - 
 					be32_to_cpu(arec->ar_startblock));
+		if (!arec->ar_blockcount)
+			block->bb_numrecs = cpu_to_be16(0);
+
 		libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 
 		/*
@@ -2627,6 +2630,9 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
 		}
 		arec->ar_blockcount = cpu_to_be32(agsize - 
 					be32_to_cpu(arec->ar_startblock));
+		if (!arec->ar_blockcount)
+			block->bb_numrecs = cpu_to_be16(0);
+
 		libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 
 		/*
Signature · 6 lines
1.7.7.6

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#1 lore raw
Quoted 22 lines · Brian Foster

The mkfs code currently creates a single free space extent record for each of the bno and cnt btrees in each AG. The start block of the record is pushed forward on the AG that hosts an internal log. If the log happens to consume all available space in the AG, the start block becomes equal to sb->sb_agblocks and thus invalid. This causes xfs_repair to complain.

For example, the following sequence:

	mkfs.xfs -d file,name=./fs.img,size=50g,agsize=16m
	xfs_repair ./fs.img

... produces the following xfs_repair output:

Phase 1 - find and verify superblock...
Phase 2 - using internal log
- scan filesystem freespace and inode maps...
invalid start block 4096 in record 0 of bno btree block 1600/1 invalid start block 4096 in record 0 of cnt btree block 1600/2
- found root inode chunk
...

Quoted 3 lines

xfs_repair appears to correct the numrecs value such that subsequent checks are successful. The sequence above is pulled from xfstests

For some reason my commit log got munged here. :/ This should say this was "pulled from xfstests #250, which fails due to this behavior." I'll send out a v2 with at least a new commit log when this gets some review...

Brian

Quoted 25 lines

Modify mkfs.xfs such that we check the block count value of the free space record for the log AG after the log is accounted for. If no space is left for the record, reset the record count to 0.

---
 mkfs/xfs_mkfs.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
mkfs/xfs_mkfs.c +3 -0
index c84448e..c4ae15b 100644
@@ -2594,6 +2594,9 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
 		}
 		arec->ar_blockcount = cpu_to_be32(agsize - 
 					be32_to_cpu(arec->ar_startblock));
+		if (!arec->ar_blockcount)
+			block->bb_numrecs = cpu_to_be16(0);
+
 		libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 
 		/*

mkfs/xfs_mkfs.c an AG size that is one stripe unit smaller, for example %llu.\n"), · line 2638

Quoted 9 lines
mkfs/xfs_mkfs.c +3 -0
@@ -2627,6 +2630,9 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
 		}
 		arec->ar_blockcount = cpu_to_be32(agsize - 
 					be32_to_cpu(arec->ar_startblock));
+		if (!arec->ar_blockcount)
+			block->bb_numrecs = cpu_to_be16(0);
+
 		libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
 
 		/*

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw
In reply to Brian Foster
Quoted 39 lines · Brian Foster

The mkfs code currently creates a single free space extent record for each of the bno and cnt btrees in each AG. The start block of the record is pushed forward on the AG that hosts an internal log. If the log happens to consume all available space in the AG, the start block becomes equal to sb->sb_agblocks and thus invalid. This causes xfs_repair to complain.

For example, the following sequence:

	mkfs.xfs -d file,name=./fs.img,size=50g,agsize=16m
	xfs_repair ./fs.img

... produces the following xfs_repair output:

Phase 1 - find and verify superblock...
Phase 2 - using internal log
- scan filesystem freespace and inode maps...
invalid start block 4096 in record 0 of bno btree block 1600/1 invalid start block 4096 in record 0 of cnt btree block 1600/2
- found root inode chunk
...

xfs_repair appears to correct the numrecs value such that subsequent checks are successful. The sequence above is pulled from xfstests

Modify mkfs.xfs such that we check the block count value of the free space record for the log AG after the log is accounted for. If no space is left for the record, reset the record count to 0.

---
 mkfs/xfs_mkfs.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
mkfs/xfs_mkfs.c +0 -0
index c84448e..c4ae15b 100644

mkfs/xfs_mkfs.c an AG size that is one stripe unit smaller, for example %llu.\n"), · line 2598

Quoted 5 lines
mkfs/xfs_mkfs.c +2 -0
@@ -2594,6 +2594,9 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
 		}
 		arec->ar_blockcount = cpu_to_be32(agsize - 
 					be32_to_cpu(arec->ar_startblock));
+		if (!arec->ar_blockcount)
+			block->bb_numrecs = cpu_to_be16(0);

You don't need to endian swap zero. block->bb_numrecs = 0; is just fine. I'd also add a comment to explain why this is being done....

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs