* [PATCH v2] xfsprogs: reduce bb_numrecs in bno/cnt btrees when log consumes all agf space
@ 2013-03-19 13:23 Brian Foster
2013-03-19 19:26 ` Dave Chinner
2013-03-22 20:59 ` Rich Johnston
0 siblings, 2 replies; 3+ messages in thread
From: Brian Foster @ 2013-03-19 13:23 UTC (permalink / raw)
To: xfs
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
test #250, which fails due to this behavior.
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.
Signed-off-by: Brian Foster <bfoster@redhat.com>
---
v2:
- Drop the byte swap.
- Add a comment.
- Fix up the commit log description.
mkfs/xfs_mkfs.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index c84448e..c57a855 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -2592,8 +2592,17 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
*/
be32_add_cpu(&arec->ar_startblock, logblocks);
}
+ /*
+ * Calculate the record block count and check for the case where
+ * the log might have consumed all available space in the AG. If
+ * so, reset the record count to 0 to avoid exposure of an invalid
+ * record start block.
+ */
arec->ar_blockcount = cpu_to_be32(agsize -
be32_to_cpu(arec->ar_startblock));
+ if (!arec->ar_blockcount)
+ block->bb_numrecs = 0;
+
libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
/*
@@ -2625,8 +2634,17 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
}
be32_add_cpu(&arec->ar_startblock, logblocks);
}
+ /*
+ * Calculate the record block count and check for the case where
+ * the log might have consumed all available space in the AG. If
+ * so, reset the record count to 0 to avoid exposure of an invalid
+ * record start block.
+ */
arec->ar_blockcount = cpu_to_be32(agsize -
be32_to_cpu(arec->ar_startblock));
+ if (!arec->ar_blockcount)
+ block->bb_numrecs = 0;
+
libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
/*
--
1.7.7.6
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] xfsprogs: reduce bb_numrecs in bno/cnt btrees when log consumes all agf space
2013-03-19 13:23 [PATCH v2] xfsprogs: reduce bb_numrecs in bno/cnt btrees when log consumes all agf space Brian Foster
@ 2013-03-19 19:26 ` Dave Chinner
2013-03-22 20:59 ` Rich Johnston
1 sibling, 0 replies; 3+ messages in thread
From: Dave Chinner @ 2013-03-19 19:26 UTC (permalink / raw)
To: Brian Foster; +Cc: xfs
On Tue, Mar 19, 2013 at 09:23:35AM -0400, Brian Foster wrote:
> 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
> test #250, which fails due to this behavior.
>
> 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.
>
> Signed-off-by: Brian Foster <bfoster@redhat.com>
> ---
>
> v2:
> - Drop the byte swap.
> - Add a comment.
> - Fix up the commit log description.
Looks good.
Reviewed-by: Dave Chinner <dchinner@redhat.com>
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] xfsprogs: reduce bb_numrecs in bno/cnt btrees when log consumes all agf space
2013-03-19 13:23 [PATCH v2] xfsprogs: reduce bb_numrecs in bno/cnt btrees when log consumes all agf space Brian Foster
2013-03-19 19:26 ` Dave Chinner
@ 2013-03-22 20:59 ` Rich Johnston
1 sibling, 0 replies; 3+ messages in thread
From: Rich Johnston @ 2013-03-22 20:59 UTC (permalink / raw)
To: Brian Foster; +Cc: xfs
Thanks for submitting this patch Brian, it has been committed.
Thanks
--Rich
commit 64ae7fcf6d1284e6905879697b55c4146fa881cf
Author: Brian Foster <bfoster@redhat.com>
Date: Tue Mar 19 13:23:35 2013 +0000
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
test #250, which fails due to this behavior.
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.
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Rich Johnston <rjohnston@sgi.com>
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-22 20:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-19 13:23 [PATCH v2] xfsprogs: reduce bb_numrecs in bno/cnt btrees when log consumes all agf space Brian Foster
2013-03-19 19:26 ` Dave Chinner
2013-03-22 20:59 ` Rich Johnston
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox