projects
/
xfstests-dev.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e7d2c01
)
Fix fdblocks accounting, need to consider cleared agfl blocks too; add shortcut ...
author
fsgqa
<fsgqa>
Fri, 29 Aug 2003 00:36:39 +0000
(
00:36
+0000)
committer
fsgqa
<fsgqa>
Fri, 29 Aug 2003 00:36:39 +0000
(
00:36
+0000)
tools/ag-wipe
patch
|
blob
|
history
diff --git
a/tools/ag-wipe
b/tools/ag-wipe
index 2fcac987c0273f169a358980d3dfdbbb59fb31ad..cde01b91a3d8ea440d3e278ab5fd9a43d72c7d3a 100755
(executable)
--- a/
tools/ag-wipe
+++ b/
tools/ag-wipe
@@
-45,7
+45,7
@@
use Getopt::Std;
#
my @sbprint = ( '"print fdblocks"', '"print agcount"' );
#
my @sbprint = ( '"print fdblocks"', '"print agcount"' );
-my @agfprint = ( '"print freeblks"' );
+my @agfprint = ( '"print freeblks"'
, '"print flcount"'
);
my @agfcommands = ( '"write freeblks 0"',
'"write longest 0"', '"write flcount 0"',
'"write bnolevel 1"', '"write cntlevel 1"',
my @agfcommands = ( '"write freeblks 0"',
'"write longest 0"', '"write flcount 0"',
'"write bnolevel 1"', '"write cntlevel 1"',
@@
-58,10
+58,11
@@
my @cntcommands = ( '"addr cntroot"', '"write numrecs 0"',
'"write leftsib -1"', '"write rightsib -1"' );
my %opt;
'"write leftsib -1"', '"write rightsib -1"' );
my %opt;
-getopts('f:l:v', \%opt);
-die "Usage: ag-wipe [-f firstAG] [-l lastAG] [-v] device\n" unless (@ARGV == 1);
+getopts('
c
f:l:v', \%opt);
+die "Usage: ag-wipe [-f firstAG] [-l lastAG] [-
c
v] device\n" unless (@ARGV == 1);
my $device = shift @ARGV;
die "$device: no such file\n" unless (-e $device);
my $device = shift @ARGV;
die "$device: no such file\n" unless (-e $device);
+my $clearall = defined($opt{'c'}) ? 1 : 0;
my $verbose = defined($opt{'v'}) ? 1 : 0;
my $nagfirst = defined($opt{'f'}) ? $opt{'f'} : 0;
my $naglast = defined($opt{'l'}) ? $opt{'l'} : 0;
my $verbose = defined($opt{'v'}) ? 1 : 0;
my $nagfirst = defined($opt{'f'}) ? $opt{'f'} : 0;
my $naglast = defined($opt{'l'}) ? $opt{'l'} : 0;
@@
-88,20
+89,27
@@
sub xfs_db {
my %sb = xfs_db 'sb', @sbprint;
print "=== Initially ", $sb{'fdblocks'}, " blocks free across ",
$sb{'agcount'}, " AGs\n";
my %sb = xfs_db 'sb', @sbprint;
print "=== Initially ", $sb{'fdblocks'}, " blocks free across ",
$sb{'agcount'}, " AGs\n";
+if ($clearall && ($nagfirst || $naglast)) {
+ print STDERR " o Clearall specified with first/last AG, quiting\n";
+ exit(1);
+}
if ($nagfirst >= $sb{'agcount'}) {
print " o First AG number is too large, quiting\n";
if ($nagfirst >= $sb{'agcount'}) {
print " o First AG number is too large, quiting\n";
- exit(
0
);
+ exit(
1
);
}
if ($naglast >= $sb{'agcount'}) {
print " o Last AG number is too large, quiting\n";
}
if ($naglast >= $sb{'agcount'}) {
print " o Last AG number is too large, quiting\n";
- exit(
0
);
+ exit(
1
);
}
if ($naglast - $nagfirst < 0) {
print " o No AGs to clear, quiting\n";
}
if ($naglast - $nagfirst < 0) {
print " o No AGs to clear, quiting\n";
- exit(0);
+ exit(1);
+}
+if ($clearall) {
+ $naglast = $sb{'agcount'} - 2;
}
}
-print "=== Wiping ", $naglast - $nagfirst,
+print "=== Wiping ", $naglast - $nagfirst
+ 1
,
" AGs starting from AG #", $nagfirst, "\n";
my $ag = $nagfirst;
" AGs starting from AG #", $nagfirst, "\n";
my $ag = $nagfirst;
@@
-114,8
+122,9
@@
while ($ag <= $naglast) {
%agf = xfs_db "'agf $ag'", @agfprint;
xfs_db "'agf $ag'", @agfcommands;
%agf = xfs_db "'agf $ag'", @agfprint;
xfs_db "'agf $ag'", @agfcommands;
- $sb{'fdblocks'} -= $agf{'freeblks'};
- print " cleared ", $agf{'freeblks'}, " blocks from AG#", $ag, "\n";
+ my $blockcnt = $agf{'freeblks'} + $agf{'flcount'};
+ $sb{'fdblocks'} -= $blockcnt;
+ print " cleared ", $blockcnt, " blocks from AG#", $ag, "\n";
%btree = xfs_db "'agf $ag'", @bnoprint;
xfs_db "'agf $ag'", @bnocommands;
%btree = xfs_db "'agf $ag'", @bnoprint;
xfs_db "'agf $ag'", @bnocommands;