1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
|
.TH xfs_db 8
.SH NAME
xfs_db \- debug an XFS filesystem
.SH SYNOPSIS
.B xfs_db
[
.B \-c
.I cmd
] ... [
.BR \-i | r | x | F
] [
.B \-f
] [
.B \-l
.I logdev
] [
.B \-p
.I progname
]
.I device
.br
.B xfs_db \-V
.SH DESCRIPTION
.B xfs_db
is used to examine an XFS filesystem. Under rare circumstances it can also
be used to modify an XFS filesystem, but that task is normally left to
.BR xfs_repair (8)
or to scripts such as
.BR xfs_admin (8)
that run
.BR xfs_db .
.PP
.SH OPTIONS
.TP
.BI \-c " cmd"
.B xfs_db
commands may be run interactively (the default) or as arguments
on the command line. Multiple
.B \-c
arguments may be given. The commands are run in the sequence given,
then the program exits.
.TP
.B \-f
Specifies that the filesystem image to be processed is stored in a
regular file at
.I device
(see the
.BR mkfs.xfs "(8) " -d
.I file
option).
This might happen if an image copy of a filesystem has been made into
an ordinary file with
.BR xfs_copy (8).
.TP
.B \-F
Specifies that we want to continue even if the superblock magic is not
correct. For use in
.BR xfs_metadump .
.TP
.B \-i
Allows execution on a mounted filesystem, provided it is mounted read-only.
Useful for shell scripts
which must only operate on filesystems in a guaranteed consistent state
(either unmounted or mounted read-only). These semantics are slightly
different to that of the
.B -r
option.
.TP
.BI \-l " logdev"
Specifies the device where the filesystems external log resides.
Only for those filesystems which use an external log. See the
.BR mkfs.xfs "(8) " \-l
option, and refer to
.BR xfs (5)
for a detailed description of the XFS log.
.TP
.BI \-p " progname"
Set the program name to
.I progname
for prompts and some error messages, the default value is
.BR xfs_db .
.TP
.B -r
Open
.I device
or
.I filename
read-only. This option is required if the filesystem is mounted.
It is only necessary to omit this flag if a command that changes data
.RB ( write ", " blocktrash ", " crc )
is to be used.
.TP
.B \-x
Specifies expert mode.
This enables the
.RB ( write ", " blocktrash ", " crc
invalidate/revalidate) commands.
.TP
.B \-V
Prints the version number and exits.
.SH CONCEPTS
.B xfs_db
commands can be broken up into two classes. Most commands are for
the navigation and display of data structures in the filesystem.
Other commands are for scanning the filesystem in some way.
.PP
Commands which are used to navigate the filesystem structure take arguments
which reflect the names of filesystem structure fields.
There can be multiple field names separated by dots when the underlying
structures are nested, as in C.
The field names can be indexed (as an array index)
if the underlying field is an array.
The array indices can be specified as a range, two numbers separated by a dash.
.PP
.B xfs_db
maintains a current address in the filesystem.
The granularity of the address is a filesystem structure.
This can be a filesystem block,
an inode or quota (smaller than a filesystem block),
or a directory block (could be larger than a filesystem block).
There are a variety of commands to set the current address.
Associated with the current address is the current data type,
which is the structural type of this data.
Commands which follow the structure of the filesystem always set the type
as well as the address.
Commands which examine pieces of an individual file (inode) need the current
inode to be set, this is done with the
.B inode
command.
.PP
The current address/type information is actually maintained in a
stack that can be explicitly manipulated with the
.BR push ", " pop ", and " stack
commands.
This allows for easy examination of a nested filesystem structure.
Also, the last several locations visited are stored in a ring buffer
which can be manipulated with the
.BR forward ", " back ", and " ring
commands.
.PP
XFS filesystems are divided into a small number of allocation groups.
.B xfs_db
maintains a notion of the current allocation group which is
manipulated by some commands. The initial allocation group is 0.
.SH COMMANDS
.PP
Many commands have extensive online help. Use the
.B help
command for more details on any command.
.TP
.B a
See the
.B addr
command.
.TP
.BI ablock " filoff"
Set current address to the offset
.I filoff
(a filesystem block number) in the attribute area of the current inode.
.TP
.BI "addr [" field-expression ]
Set current address to the value of the
.IR field-expression .
This is used to "follow" a reference in one structure to the object
being referred to. If no argument is given, the current address is printed.
.TP
.BI "agf [" agno ]
Set current address to the AGF block for allocation group
.IR agno .
If no argument is given, use the current allocation group.
.TP
.BI "agfl [" agno ]
Set current address to the AGFL block for allocation group
.IR agno .
If no argument is given, use the current allocation group.
.TP
.BI "agi [" agno ]
Set current address to the AGI block for allocation group
.IR agno .
If no argument is given, use the current allocation group.
.TP
.BI "agresv [" agno ]
Displays the length, free block count, per-AG reservation size, and per-AG
reservation usage for a given AG.
If no argument is given, display information for all AGs.
.TP
.BI "attr_remove [\-r|\-u|\-s] [\-n] " name
Remove the specified extended attribute from the current file.
.RS 1.0i
.TP 0.4i
.B \-r
Sets the attribute in the root namespace.
Only one namespace option can be specified.
.TP
.B \-u
Sets the attribute in the user namespace.
Only one namespace option can be specified.
.TP
.B \-s
Sets the attribute in the secure namespace.
Only one namespace option can be specified.
.TP
.B \-n
Do not enable 'noattr2' mode on V4 filesystems.
.RE
.TP
.BI "attr_set [\-r|\-u|\-s] [\-n] [\-R|\-C] [\-v " namelen "] " name
Sets an extended attribute on the current file with the given name.
.RS 1.0i
.TP 0.4i
.B \-r
Sets the attribute in the root namespace.
Only one namespace option can be specified.
.TP
.B \-u
Sets the attribute in the user namespace.
Only one namespace option can be specified.
.TP
.B \-s
Sets the attribute in the secure namespace.
Only one namespace option can be specified.
.TP
.B \-n
Do not enable 'noattr2' mode on V4 filesystems.
.TP
.B \-R
Replace the attribute.
The command will fail if the attribute does not already exist.
.TP
.B \-C
Create the attribute.
The command will fail if the attribute already exists.
.TP
.B \-v
Set the attribute value to a string of this length containing the letter 'v'.
.RE
.TP
.B b
See the
.B back
command.
.TP
.B back
Move to the previous location in the position ring.
.TP
.B blockfree
Free block usage information collected by the last execution of the
.B blockget
command. This must be done before another
.B blockget
command can be given, presumably with different arguments than the previous one.
.TP
.BI "blockget [\-npvs] [\-b " bno "] ... [\-i " ino "] ..."
Get block usage and check filesystem consistency.
The information is saved for use by a subsequent
.BR blockuse ", " ncheck ", or " blocktrash
command.
.RS 1.0i
.TP 0.4i
.B \-b
is used to specify filesystem block numbers about which verbose
information should be printed.
.TP
.B \-i
is used to specify inode numbers about which verbose information
should be printed.
.TP
.B \-n
is used to save pathnames for inodes visited, this is used to support the
.BR xfs_ncheck (8)
command. It also means that pathnames will be printed for inodes that have
problems. This option uses a lot of memory so is not enabled by default.
.TP
.B \-p
causes error messages to be prefixed with the filesystem name being
processed. This is useful if several copies of
.B xfs_db
are run in parallel.
.TP
.B \-s
restricts output to severe errors only. This is useful if the output is
too long otherwise.
.TP
.B \-v
enables verbose output. Messages will be printed for every block and
inode processed.
.RE
.TP
.BI "blocktrash [-z] [\-o " offset "] [\-n " count "] [\-x " min "] [\-y " max "] [\-s " seed "] [\-0|1|2|3] [\-t " type "] ..."
Trash randomly selected filesystem metadata blocks.
Trashing occurs to randomly selected bits in the chosen blocks.
This command is available only in debugging versions of
.BR xfs_db .
It is useful for testing
.BR xfs_repair "(8).
.RS 1.0i
.TP 0.4i
.BR \-0 " | " -1 " | " -2 " | " -3
These are used to set the operating mode for
.BR blocktrash .
Only one can be used:
.B \-0
changed bits are cleared;
.B \-1
changed bits are set;
.B -2
changed bits are inverted;
.B -3
changed bits are randomized.
.TP
.B \-n
supplies the
.I count
of block-trashings to perform (default 1).
.TP
.B \-o
supplies the bit
.I offset
at which to start trashing the block. If the value is preceded by a '+', the
trashing will start at a randomly chosen offset that is larger than the value
supplied. The default is to randomly choose an offset anywhere in the block.
.TP
.B \-s
supplies a
.I seed
to the random processing.
.TP
.B \-t
gives a
.I type
of blocks to be selected for trashing. Multiple
.B \-t
options may be given. If no
.B \-t
options are given then all metadata types can be trashed.
.TP
.B \-x
sets the
.I minimum
size of bit range to be trashed. The default value is 1.
.TP
.B \-y
sets the
.I maximum
size of bit range to be trashed. The default value is 1024.
.TP
.B \-z
trashes the block at the top of the stack. It is not necessary to
run
.BI blockget
if this option is supplied.
.RE
.TP
.BI "blockuse [\-n] [\-c " count ]
Print usage for current filesystem block(s).
For each block, the type and (if any) inode are printed.
.RS 1.0i
.TP 0.4i
.B \-c
specifies a
.I count
of blocks to process. The default value is 1 (the current block only).
.TP
.B \-n
specifies that file names should be printed. The prior
.B blockget
command must have also specified the
.B \-n
option.
.RE
.TP
.BI "bmap [\-a] [\-d] [" block " [" len ]]
Show the block map for the current inode.
The map display can be restricted to an area of the file with the
.I block
and
.I len
arguments. If
.I block
is given and
.I len
is omitted then 1 is assumed for len.
.IP
The
.B \-a
and
.B \-d
options are used to select the attribute or data
area of the inode, if neither option is given then both areas are shown.
.TP
.B btdump [-a] [-i]
If the cursor points to a btree node, dump the btree from that block downward.
If instead the cursor points to an inode, dump the data fork block mapping btree if there is one.
If the cursor points to a directory or extended attribute btree node, dump that.
By default, only records stored in the btree are dumped.
.RS 1.0i
.TP 0.4i
.B \-a
If the cursor points at an inode, dump the extended attribute block mapping btree, if present.
.TP
.B \-i
Dump all keys and pointers in intermediate btree nodes, and all records in leaf btree nodes.
.RE
.TP
.BI "btheight [\-b " blksz "] [\-n " recs "] [\-w " max "|" min "|" absmax "] btree types..."
For a given number of btree records and a btree type, report the number of
records and blocks for each level of the btree, and the total number of blocks.
The btree type must be given after the options.
A raw btree geometry can be provided in the format
"record_bytes:key_bytes:ptr_bytes:header_type", where header_type is one of
"short", "long", "shortcrc", or "longcrc".
The supported btree types are:
.IR bnobt ,
.IR cntbt ,
.IR inobt ,
.IR finobt ,
.IR bmapbt ,
.IR refcountbt ,
and
.IR rmapbt .
The magic value
.I all
can be used to walk through all btree types.
Options are as follows:
.RS 1.0i
.TP 0.4i
.B \-b
is used to override the btree block size.
The default is the filesystem block size.
.TP
.B \-n
is used to specify the number of records to store.
This argument is required.
.TP
.B \-w absmax
shows the maximum possible height for the given btree types.
.TP
.B \-w max
shows only the best case scenario, which is when the btree blocks are
maximally loaded.
.TP
.B \-w min
shows only the worst case scenario, which is when the btree blocks are
half full.
.RE
.TP
.B check
See the
.B blockget
command.
.TP
.BI "convert " "type number" " [" "type number" "] ... " type
Convert from one address form to another.
The known
.IR type s,
with alternate names, are:
.RS 1.0i
.PD 0
.HP
.B agblock
or
.B agbno
(filesystem block within an allocation group)
.HP
.B agino
or
.B aginode
(inode number within an allocation group)
.HP
.B agnumber
or
.B agno
(allocation group number)
.HP
.B bboff
or
.B daddroff
(byte offset in a
.BR daddr )
.HP
.B blkoff
or
.B fsboff or
.B agboff
(byte offset in a
.B agblock
or
.BR fsblock )
.HP
.B byte
or
.B fsbyte
(byte address in filesystem)
.HP
.B daddr
or
.B bb
(disk address, 512-byte blocks)
.HP
.B fsblock
or
.B fsb
or
.B fsbno
(filesystem block, see the
.B fsblock
command)
.HP
.B ino
or
.B inode
(inode number)
.HP
.B inoidx
or
.B offset
(index of inode in filesystem block)
.HP
.B inooff
or
.B inodeoff
(byte offset in inode)
.PD
.RE
.IP
Only conversions that "make sense" are allowed.
The compound form (with more than three arguments) is useful for
conversions such as
.B convert agno
.I ag
.B agbno
.I agb
.BR fsblock .
.TP
.B crc [\-i|\-r|\-v]
Invalidates, revalidates, or validates the CRC (checksum)
field of the current structure, if it has one.
This command is available only on CRC-enabled filesystems.
With no argument, validation is performed.
Each command will display the resulting CRC value and state.
.RS 1.0i
.TP 0.4i
.B \-i
Invalidate the structure's CRC value (incrementing it by one),
and write it to disk.
.TP
.B \-r
Recalculate the current structure's correct CRC value, and write it to disk.
.TP
.B \-v
Validate and display the current value and state of the structure's CRC.
.RE
.TP
.BI "daddr [" d ]
Set current address to the daddr (512 byte block) given by
.IR d .
If no value for
.I d
is given, the current address is printed, expressed as a daddr.
The type is set to
.B data
(uninterpreted).
.TP
.BI dblock " filoff"
Set current address to the offset
.I filoff
(a filesystem block number) in the data area of the current inode.
.TP
.BI "debug [" flagbits ]
Set debug option bits. These are used for debugging
.BR xfs_db .
If no value is given for
.IR flagbits ,
print the current debug option bits. These are for the use of the implementor.
.TP
.BI "dquot [" \-g | \-p | \-u ] " id"
Set current address to a group, project or user quota block for the given ID. Defaults to user quota.
.TP
.BI "echo [" arg "] ..."
Echo the arguments to the output.
.TP
.B f
See the
.B forward
command.
.TP
.B forward
Move forward to the next entry in the position ring.
.TP
.B frag [\-adflqRrv]
Get file fragmentation data. This prints information about fragmentation
of file data in the filesystem (as opposed to fragmentation of freespace,
for which see the
.B freesp
command). Every file in the filesystem is examined to see how far from ideal
its extent mappings are. A summary is printed giving the totals.
.RS 1.0i
.TP 0.4i
.B \-v
sets verbosity, every inode has information printed for it.
The remaining options select which inodes and extents are examined.
If no options are given then all are assumed set,
otherwise just those given are enabled.
.TP
.B \-a
enables processing of attribute data.
.TP
.B \-d
enables processing of directory data.
.TP
.B \-f
enables processing of regular file data.
.TP
.B \-l
enables processing of symbolic link data.
.TP
.B \-q
enables processing of quota file data.
.TP
.B \-R
enables processing of realtime control file data.
.TP
.B \-r
enables processing of realtime file data.
.RE
.TP
.BI "freesp [\-bcds] [\-A " alignment "] [\-a " ag "] ... [\-e " i "] [\-h " h1 "] ... [\-m " m ]
Summarize free space for the filesystem. The free blocks are examined
and totalled, and displayed in the form of a histogram, with a count
of extents in each range of free extent sizes.
.RS 1.0i
.TP 0.4i
.B \-A
reports only free extents with starting blocks aligned to
.I alignment
blocks.
.TP
.B \-a
adds
.I ag
to the list of allocation groups to be processed. If no
.B \-a
options are given then all allocation groups are processed.
.TP
.B \-b
specifies that the histogram buckets are binary-sized, with the starting
sizes being the powers of 2.
.TP
.B \-c
specifies that
.B freesp
will search the by-size (cnt) space Btree instead of the default
by-block (bno) space Btree.
.TP
.B \-d
specifies that every free extent will be displayed.
.TP
.B \-e
specifies that the histogram buckets are
equal-sized, with the size specified as
.IR i .
.TP
.B \-h
specifies a starting block number for a histogram bucket as
.IR h1 .
Multiple
.BR \-h 's
are given to specify the complete set of buckets.
.TP
.B \-m
specifies that the histogram starting block numbers are powers of
.IR m .
This is the general case of
.BR \-b .
.TP
.B \-s
specifies that a final summary of total free extents,
free blocks, and the average free extent size is printed.
.RE
.TP
.B fsb
See the
.B fsblock
command.
.TP
.BI "fsblock [" fsb ]
Set current address to the fsblock value given by
.IR fsb .
If no value for
.I fsb
is given the current address is printed, expressed as an fsb.
The type is set to
.B data
(uninterpreted). XFS filesystem block numbers are computed
.RI (( agno " << " agshift ") | " agblock )
where
.I agshift
depends on the size of an allocation group. Use the
.B convert
command to convert to and from this form. Block numbers given for file blocks
(for instance from the
.B bmap
command) are in this form.
.TP
.BI "fsmap [ " start " ] [ " end " ]
Prints the mapping of disk blocks used by an XFS filesystem. The map
lists each extent used by files, allocation group metadata,
journalling logs, and static filesystem metadata, as well as any
regions that are unused. All blocks, offsets, and lengths are specified
in units of 512-byte blocks, no matter what the filesystem's block size is.
.BI "The optional " start " and " end " arguments can be used to constrain
the output to a particular range of disk blocks.
.TP
.BI "fuzz [\-c] [\-d] " "field action"
Write garbage into a specific structure field on disk.
Expert mode must be enabled to use this command.
The operation happens immediately; there is no buffering.
.IP
The fuzz command can take the following
.IR action "s"
against a field:
.RS 1.0i
.TP 0.4i
.B zeroes
Clears all bits in the field.
.TP 0.4i
.B ones
Sets all bits in the field.
.TP 0.4i
.B firstbit
Flips the first bit in the field.
For a scalar value, this is the highest bit.
.TP 0.4i
.B middlebit
Flips the middle bit in the field.
.TP 0.4i
.B lastbit
Flips the last bit in the field.
For a scalar value, this is the lowest bit.
.TP 0.4i
.B add
Adds a small value to a scalar field.
.TP 0.4i
.B sub
Subtracts a small value from a scalar field.
.TP 0.4i
.B random
Randomizes the contents of the field.
.RE
.IP
The following switches affect the write behavior:
.RS 1.0i
.TP 0.4i
.B \-c
Skip write verifiers and CRC recalculation; allows invalid data to be written
to disk.
.TP 0.4i
.B \-d
Skip write verifiers but perform CRC recalculation; allows invalid data to be
written to disk to test detection of invalid data.
.RE
.TP
.BI hash " string
Prints the hash value of
.I string
using the hash function of the XFS directory and attribute implementation.
.TP
.BI "help [" command ]
Print help for one or all commands.
.TP
.B info
Displays selected geometry information about the filesystem.
The output will have the same format that
.BR "mkfs.xfs" "(8)"
prints when creating a filesystem or
.BR "xfs_info" "(8)"
prints when querying a filesystem.
.TP
.BI "inode [" inode# ]
Set the current inode number. If no
.I inode#
is given, print the current inode number.
.TP
.BI "label [" label ]
Set the filesystem label. The filesystem label can be used by
.BR mount (8)
instead of using a device special file.
The maximum length of an XFS label is 12 characters \- use of a longer
.I label
will result in truncation and a warning will be issued. If no
.I label
is given, the current filesystem label is printed.
.TP
.BI "log [stop | start " filename ]
Start logging output to
.IR filename ,
stop logging, or print the current logging status.
.TP
.BI "logformat [\-c " cycle "] [\-s " sunit "]"
Reformats the log to the specified log cycle and log stripe unit.
This has the effect of clearing the log destructively.
If the log cycle is not specified, the log is reformatted to the current cycle.
If the log stripe unit is not specified, the stripe unit from the filesystem
superblock is used.
.TP
.B logres
Print transaction reservation size information for each transaction type.
This makes it easier to find discrepancies in the reservation calculations
between xfsprogs and the kernel, which will help when diagnosing minimum
log size calculation errors.
.TP
.BI "ls [\-i] [" paths "]..."
List the contents of a directory.
If a path resolves to a directory, the directory will be listed.
If no paths are supplied and the IO cursor points at a directory inode,
the contents of that directory will be listed.
The output format is:
directory cookie, inode number, file type, hash, name length, name.
.RS 1.0i
.TP 0.4i
.B \-i
Resolve each of the given paths to an inode number and print that number.
If no paths are given and the IO cursor points to an inode, print the inode
number.
.RE
.TP
.BI "metadump [\-egow] " filename
Dumps metadata to a file. See
.BR xfs_metadump (8)
for more information.
.TP
.BI "ncheck [\-s] [\-i " ino "] ..."
Print name-inode pairs. A
.B blockget \-n
command must be run first to gather the information.
.RS 1.0i
.TP 0.4i
.B \-i
specifies an inode number to be printed. If no
.B \-i
options are given then all inodes are printed.
.TP
.B \-s
specifies that only setuid and setgid files are printed.
.RE
.TP
.B p
See the
.B print
command.
.TP
.BI "path " dir_path
Walk the directory tree to an inode using the supplied path.
Absolute and relative paths are supported.
.TP
.B pop
Pop location from the stack.
.TP
.BI "print [" field-expression "] ..."
Print field values.
If no argument is given, print all fields in the current structure.
.TP
.BI "push [" command ]
Push location to the stack. If
.I command
is supplied, set the current location to the results of
.I command
after pushing the old location.
.TP
.B q
See the
.B quit
command.
.TP
.B quit
Exit
.BR xfs_db .
.TP
.BI "ring [" index ]
Show position ring (if no
.I index
argument is given), or move to a specific entry in the position ring given by
.IR index .
.TP
.BI "sb [" agno ]
Set current address to SB header in allocation group
.IR agno .
If no
.I agno
is given, use the current allocation group number.
.TP
.BI "source " source-file
Process commands from
.IR source-file .
.B source
commands can be nested.
.TP
.B stack
View the location stack.
.TP
.BI "type [" type ]
Set the current data type to
.IR type .
If no argument is given, show the current data type.
The possible data types are:
.BR agf ", " agfl ", " agi ", " attr ", " bmapbta ", " bmapbtd ,
.BR bnobt ", " cntbt ", " data ", " dir ", " dir2 ", " dqblk ,
.BR inobt ", " inode ", " log ", " refcntbt ", " rmapbt ", " rtbitmap ,
.BR rtsummary ", " sb ", " symlink " and " text .
See the TYPES section below for more information on these data types.
.TP
.BI "timelimit [" OPTIONS ]
Print the minimum and maximum supported values for inode timestamps,
quota expiration timers, and quota grace periods supported by this
filesystem.
Options include:
.RS 1.0i
.TP 0.4i
.B \--bigtime
Print the time limits of an XFS filesystem with the
.B bigtime
feature enabled.
.TP 0.4i
.B \--classic
Print the time limits of a classic XFS filesystem.
.TP 0.4i
.B \--compact
Print all limits as raw values on a single line.
.TP 0.4i
.B \--pretty
Print the timestamps in the current locale's date and time format instead of
raw seconds since the Unix epoch.
.RE
.TP
.BI "uuid [" uuid " | " generate " | " rewrite " | " restore ]
Set the filesystem universally unique identifier (UUID).
The filesystem UUID can be used by
.BR mount (8)
instead of using a device special file.
The
.I uuid
can be set directly to the desired UUID, or it can
be automatically generated using the
.B generate
option. These options will both write the UUID into every copy of the
superblock in the filesystem. On a CRC-enabled filesystem, this will
set an incompatible superblock flag, and the filesystem will not be
mountable with older kernels. This can be reverted with the
.B restore
option, which will copy the original UUID back into place and clear
the incompatible flag as needed.
.B rewrite
copies the current UUID from the primary superblock
to all secondary copies of the superblock.
If no argument is given, the current filesystem UUID is printed.
.TP
.BI "version [" feature " | " "versionnum features2" ]
Enable selected features for a filesystem (certain features can
be enabled on an unmounted filesystem, after
.BR mkfs.xfs (8)
has created the filesystem).
Support for unwritten extents can be enabled using the
.B extflg
option. Support for version 2 log format can be enabled using the
.B log2
option. Support for extended attributes can be enabled using the
.B attr1
or
.B attr2
option. Once enabled, extended attributes cannot be disabled, but the user
may toggle between
.B attr1
and
.B attr2
at will (older kernels may not support the newer version).
.IP
If no argument is given, the current version and feature bits are printed.
With one argument, this command will write the updated version number
into every copy of the superblock in the filesystem.
If two arguments are given, they will be used as numeric values for the
.I versionnum
and
.I features2
bits respectively, and their string equivalent reported
(but no modifications are made).
.TP
.BI "write [\-c|\-d] [" "field value" "] ..."
Write a value to disk.
Specific fields can be set in structures (struct mode),
or a block can be set to data values (data mode),
or a block can be set to string values (string mode, for symlink blocks).
The operation happens immediately: there is no buffering.
.IP
Struct mode is in effect when the current type is structural,
i.e. not data. For struct mode, the syntax is "\c
.B write
.I field value\c
".
.IP
Data mode is in effect when the current type is data. In this case the
contents of the block can be shifted or rotated left or right, or filled
with a sequence, a constant value, or a random value. In this mode
.B write
with no arguments gives more information on the allowed commands.
.RS 1.0i
.TP 0.4i
.B \-c
Skip write verifiers and CRC recalculation; allows invalid data to be written
to disk.
.TP 0.4i
.B \-d
Skip write verifiers but perform CRC recalculation.
This allows invalid data to be written to disk to
test detection of invalid data. (This is not possible for some types.)
.RE
.SH TYPES
This section gives the fields in each structure type and their meanings.
Note that some types of block cover multiple actual structures,
for instance directory blocks.
.TP 1.0i
.B agf
The AGF block is the header for block allocation information;
it is in the second 512-byte block of each allocation group.
The following fields are defined:
.RS 1.4i
.PD 0
.TP 1.2i
.B magicnum
AGF block magic number, 0x58414746 ('XAGF').
.TP
.B versionnum
version number, currently 1.
.TP
.B seqno
sequence number starting from 0.
.TP
.B length
size in filesystem blocks of the allocation group. All allocation
groups except the last one of the filesystem have the superblock's
.B agblocks
value here.
.TP
.B bnoroot
block number of the root of the Btree holding free space
information sorted by block number.
.TP
.B cntroot
block number of the root of the Btree holding free space
information sorted by block count.
.TP
.B bnolevel
number of levels in the by-block-number Btree.
.TP
.B cntlevel
number of levels in the by-block-count Btree.
.TP
.B flfirst
index into the AGFL block of the first active entry.
.TP
.B fllast
index into the AGFL block of the last active entry.
.TP
.B flcount
count of active entries in the AGFL block.
.TP
.B freeblks
count of blocks represented in the freespace Btrees.
.TP
.B longest
longest free space represented in the freespace Btrees.
.TP
.B btreeblks
number of blocks held in the AGF Btrees.
.PD
.RE
.TP
.B agfl
The AGFL block contains block numbers for use of the block allocator;
it is in the fourth 512-byte block of each allocation group.
Each entry in the active list is a block number within the allocation group
that can be used for any purpose if space runs low.
The AGF block fields
.BR flfirst ", " fllast ", and " flcount
designate which entries are currently active.
Entry space is allocated in a circular manner within the AGFL block.
Fields defined:
.RS 1.4i
.PD 0
.TP 1.2i
.B bno
array of all block numbers. Even those which are not active are printed.
.PD
.RE
.TP
.B agi
The AGI block is the header for inode allocation information;
it is in the third 512-byte block of each allocation group.
Fields defined:
.RS 1.4i
.PD 0
.TP 1.2i
.B magicnum
AGI block magic number, 0x58414749 ('XAGI').
.TP
.B versionnum
version number, currently 1.
.TP
.B seqno
sequence number starting from 0.
.TP
.B length
size in filesystem blocks of the allocation group.
.TP
.B count
count of inodes allocated.
.TP
.B root
block number of the root of the Btree holding inode allocation information.
.TP
.B level
number of levels in the inode allocation Btree.
.TP
.B freecount
count of allocated inodes that are not in use.
.TP
.B newino
last inode number allocated.
.TP
.B dirino
unused.
.TP
.B unlinked
an array of inode numbers within the allocation group. The entries
in the AGI block are the heads of lists which run through the inode
.B next_unlinked
field. These inodes are to be unlinked the next time the filesystem is mounted.
.PD
.RE
.TP
.B attr
An attribute fork is organized as a Btree with the actual data embedded
in the leaf blocks. The root of the Btree is found in block 0 of the fork.
The index (sort order) of the Btree is the hash value of the attribute name.
All the blocks contain a
.B blkinfo
structure at the beginning, see type
.B dir
for a description. Nonleaf blocks are identical in format to those for
version 1 and version 2 directories, see type
.B dir
for a description. Leaf blocks can refer to "local" or "remote" attribute
values. Local values are stored directly in the leaf block.
Leaf blocks contain the following fields:
.RS 1.4i
.PD 0
.TP 1.2i
.B hdr
header containing a
.B blkinfo
structure
.B info
(magic number 0xfbee), a
.B count
of active entries,
.B usedbytes
total bytes of names and values, the
.B firstused
byte in the name area,
.B holes
set if the block needs compaction, and array
.B freemap
as for
.B dir
leaf blocks.
.TP
.B entries
array of structures containing a
.BR hashval ,
.B nameidx
(index into the block of the name), and flags
.BR incomplete ,
.BR root ,
and
.BR local .
.TP
.B nvlist
array of structures describing the attribute names and values. Fields
always present:
.B valuelen
(length of value in bytes),
.BR namelen ,
and
.BR name .
Fields present for local values:
.B value
(value string). Fields present for remote values:
.B valueblk
(fork block number of containing the value).
.PD
.RE
.IP
Remote values are stored in an independent block in the attribute fork.
Prior to v5, value blocks had no structure, but in v5 they acquired a header
structure with the following fields:
.RS 1.4i
.PD 0
.TP 1.2i
.B magic
attr3 remote block magic number, 0x5841524d ('XARM').
.TP
.B offset
Byte offset of this data block within the overall attribute value.
.TP
.B bytes
Number of bytes stored in this block.
.TP
.B crc
Checksum of the attribute block contents.
.TP
.B uuid
Filesystem UUID.
.TP
.B owner
Inode that owns this attribute value.
.TP
.B bno
Block offset of this block within the inode's attribute fork.
.TP
.B lsn
Log serial number of the last time this block was logged.
.TP
.B data
The attribute value data.
.PD
.RE
.TP
.B bmapbt
Files with many extents in their data or attribute fork will have the
extents described by the contents of a Btree for that fork,
instead of being stored directly in the inode.
Each bmap Btree starts with a root block contained within the inode.
The other levels of the Btree are stored in filesystem blocks.
The blocks are linked to sibling left and right blocks at each level,
as well as by pointers from parent to child blocks.
Each block contains the following fields:
.RS 1.4i
.PD 0
.TP 1.2i
.B magic
bmap Btree block magic number, 0x424d4150 ('BMAP').
.TP
.B level
level of this block above the leaf level.
.TP
.B numrecs
number of records or keys in the block.
.TP
.B leftsib
left (logically lower) sibling block, 0 if none.
.TP
.B rightsib
right (logically higher) sibling block, 0 if none.
.TP
.B recs
[leaf blocks only] array of extent records.
Each record contains
.BR startoff ,
.BR startblock ,
.BR blockcount ,
and
.B extentflag
(1 if the extent is unwritten).
.TP
.B keys
[non-leaf blocks only] array of key records. These are the first key
value of each block in the level below this one. Each record contains
.BR startoff .
.TP
.B ptrs
[non-leaf blocks only] array of child block pointers.
Each pointer is a filesystem block number to the next level in the Btree.
.PD
.RE
.TP
.B bnobt
There is one set of filesystem blocks forming the by-block-number
allocation Btree for each allocation group. The root block of this
Btree is designated by the
.B bnoroot
field in the corresponding AGF block.
The blocks are linked to sibling left and right blocks at each level,
as well as by pointers from parent to child blocks.
Each block has the following fields:
.RS 1.4i
.PD 0
.TP 1.2i
.B magic
BNOBT block magic number, 0x41425442 ('ABTB').
.TP
.B level
level number of this block, 0 is a leaf.
.TP
.B numrecs
number of data entries in the block.
.TP
.B leftsib
left (logically lower) sibling block, 0 if none.
.TP
.B rightsib
right (logically higher) sibling block, 0 if none.
.TP
.B recs
[leaf blocks only] array of freespace records. Each record contains
.B startblock
and
.BR blockcount .
.TP
.B keys
[non-leaf blocks only] array of key records. These are the first value
of each block in the level below this one. Each record contains
.B startblock
and
.BR blockcount .
.TP
.B ptrs
[non-leaf blocks only] array of child block pointers. Each pointer is a
block number within the allocation group to the next level in the Btree.
.PD
.RE
.TP
.B cntbt
There is one set of filesystem blocks forming the by-block-count
allocation Btree for each allocation group. The root block of this
Btree is designated by the
.B cntroot
field in the corresponding AGF block. The blocks are linked to sibling
left and right blocks at each level, as well as by pointers from parent
to child blocks. Each block has the following fields:
.RS 1.4i
.PD 0
.TP 1.2i
.B magic
CNTBT block magic number, 0x41425443 ('ABTC').
.TP
.B level
level number of this block, 0 is a leaf.
.TP
.B numrecs
number of data entries in the block.
.TP
.B leftsib
left (logically lower) sibling block, 0 if none.
.TP
.B rightsib
right (logically higher) sibling block, 0 if none.
.TP
.B recs
[leaf blocks only] array of freespace records. Each record contains
.B startblock
and
.BR blockcount .
.TP
.B keys
[non-leaf blocks only] array of key records. These are the first value
of each block in the level below this one. Each record contains
.B blockcount
and
.BR startblock .
.TP
.B ptrs
[non-leaf blocks only] array of child block pointers. Each pointer is a
block number within the allocation group to the next level in the Btree.
.PD
.RE
.TP
.B data
User file blocks, and other blocks whose type is unknown, have this
type for display purposes in
.BR xfs_db .
The block data is displayed in hexadecimal format.
.TP
.B dir
A version 1 directory is organized as a Btree with the directory data
embedded in the leaf blocks. The root of the Btree is found in block 0
of the file. The index (sort order) of the Btree is the hash value of
the entry name. All the blocks contain a
.B blkinfo
structure at the beginning with the following fields:
.RS 1.4i
.PD 0
.TP 1.2i
.B forw
next sibling block.
.TP
.B back
previous sibling block.
.TP
.B magic
magic number for this block type.
.RE
.IP
The non-leaf (node) blocks have the following fields:
.RS 1.4i
.TP 1.2i
.B hdr
header containing a
.B blkinfo
structure
.B info
(magic number 0xfebe), the
.B count
of active entries, and the
.B level
of this block above the leaves.
.TP
.B btree
array of entries containing
.B hashval
and
.B before
fields. The
.B before
value is a block number within the directory file to the child block, the
.B hashval
is the last hash value in that block.
.RE
.IP
The leaf blocks have the following fields:
.RS 1.4i
.TP 1.2i
.B hdr
header containing a
.B blkinfo
structure
.B info
(magic number 0xfeeb), the
.B count
of active entries,
.B namebytes
(total name string bytes),
.B holes
flag (block needs compaction), and
.B freemap
(array of
.BR base ", " size
entries for free regions).
.TP
.B entries
array of structures containing
.BR hashval ,
.B nameidx
(byte index into the block of the name string), and
.BR namelen .
.TP
.B namelist
array of structures containing
.B inumber
and
.BR name .
.RE
.PD
.TP
.B dir2
A version 2 directory has four kinds of blocks.
Data blocks start at offset 0 in the file.
There are two kinds of data blocks: single-block directories have
the leaf information embedded at the end of the block, data blocks
in multi-block directories do not.
Node and leaf blocks start at offset 32GiB (with either a single
leaf block or the root node block).
Freespace blocks start at offset 64GiB.
The node and leaf blocks form a Btree, with references to the data
in the data blocks.
The freespace blocks form an index of longest free spaces within the
data blocks.
.IP
A single-block directory block contains the following fields:
.RS 1.4i
.PD 0
.TP 1.2i
.B bhdr
header containing
.B magic
number 0x58443242 ('XD2B') and an array
.B bestfree
of the longest 3 free spaces in the block
.RB ( offset ", " length ).
.TP
.B bu
array of union structures. Each element is either an entry or a freespace.
For entries, there are the following fields:
.BR inumber ,
.BR namelen ,
.BR name ,
and
.BR tag .
For freespace, there are the following fields:
.B freetag
(0xffff),
.BR length ,
and
.BR tag .
The
.B tag
value is the byte offset in the block of the start of the entry it
is contained in.
.TP
.B bleaf
array of leaf entries containing
.B hashval
and
.BR address .
The
.B address
is a 64-bit word offset into the file.
.TP
.B btail
tail structure containing the total
.B count
of leaf entries and
.B stale
count of unused leaf entries.
.RE
.IP
A data block contains the following fields:
.RS 1.4i
.TP 1.2i
.B dhdr
header containing
.B magic
number 0x58443244 ('XD2D') and an array
.B bestfree
of the longest 3 free spaces in the block
.RB ( offset ", " length ).
.TP
.B du
array of union structures as for
.BR bu .
.RE
.IP
Leaf blocks have two possible forms. If the Btree consists of a single
leaf then the freespace information is in the leaf block,
otherwise it is in separate blocks and the root of the Btree is
a node block. A leaf block contains the following fields:
.RS 1.4i
.TP 1.2i
.B lhdr
header containing a
.B blkinfo
structure
.B info
(magic number 0xd2f1 for the single leaf case, 0xd2ff for the true
Btree case), the total
.B count
of leaf entries, and
.B stale
count of unused leaf entries.
.TP
.B lents
leaf entries, as for
.BR bleaf .
.TP
.B lbests
[single leaf only] array of values which represent the longest freespace
in each data block in the directory.
.TP
.B ltail
[single leaf only] tail structure containing
.B bestcount
count of
.BR lbests .
.RE
.IP
A node block is identical to that for types
.B attr
and
.BR dir .
A freespace block contains the following fields:
.RS 1.4i
.TP 1.2i
.B fhdr
header containing
.B magic
number 0x58443246 ('XD2F'),
.B firstdb
first data block number covered by this freespace block,
.B nvalid
number of valid entries, and
.B nused
number of entries representing real data blocks.
.TP
.B fbests
array of values as for
.BR lbests .
.PD
.RE
.TP
.B dqblk
The quota information is stored in files referred to by the superblock
.B uquotino
and
.B pquotino
fields. Each filesystem block in a quota file contains a constant number of
quota entries. The quota entry size is currently 136 bytes, so with a 4KiB
filesystem block size there are 30 quota entries per block. The
.B dquot
command is used to locate these entries in the filesystem.
The file entries are indexed by the user or project identifier
to determine the block and offset.
Each quota entry has the following fields:
.RS 1.4i
.PD 0
.TP 1.5i
.B magic
magic number, 0x4451 ('DQ').
.TP
.B version
version number, currently 1.
.TP
.B flags
flags, values include 0x01 for user quota, 0x02 for project quota.
.TP
.B id
user or project identifier.
.TP
.B blk_hardlimit
absolute limit on blocks in use.
.TP
.B blk_softlimit
preferred limit on blocks in use.
.TP
.B ino_hardlimit
absolute limit on inodes in use.
.TP
.B ino_softlimit
preferred limit on inodes in use.
.TP
.B bcount
blocks actually in use.
.TP
.B icount
inodes actually in use.
.TP
.B itimer
time when service will be refused if soft limit is violated for inodes.
.TP
.B btimer
time when service will be refused if soft limit is violated for blocks.
.TP
.B iwarns
number of warnings issued about inode limit violations.
.TP
.B bwarns
number of warnings issued about block limit violations.
.TP
.B rtb_hardlimit
absolute limit on realtime blocks in use.
.TP
.B rtb_softlimit
preferred limit on realtime blocks in use.
.TP
.B rtbcount
realtime blocks actually in use.
.TP
.B rtbtimer
time when service will be refused if soft limit is violated for realtime blocks.
.TP
.B rtbwarns
number of warnings issued about realtime block limit violations.
.PD
.RE
.TP
.B inobt
There is one set of filesystem blocks forming the inode allocation Btree for
each allocation group. The root block of this Btree is designated by the
.B root
field in the corresponding AGI block.
The blocks are linked to sibling left and right blocks at each level,
as well as by pointers from parent to child blocks.
Each block has the following fields:
.RS 1.4i
.PD 0
.TP 1.2i
.B magic
INOBT block magic number, 0x49414254 ('IABT').
.TP
.B level
level number of this block, 0 is a leaf.
.TP
.B numrecs
number of data entries in the block.
.TP
.B leftsib
left (logically lower) sibling block, 0 if none.
.TP
.B rightsib
right (logically higher) sibling block, 0 if none.
.TP
.B recs
[leaf blocks only] array of inode records. Each record contains
.B startino
allocation-group relative inode number,
.B freecount
count of free inodes in this chunk, and
.B free
bitmap, LSB corresponds to inode 0.
.TP
.B keys
[non-leaf blocks only] array of key records. These are the first value of each
block in the level below this one. Each record contains
.BR startino .
.TP
.B ptrs
[non-leaf blocks only] array of child block pointers. Each pointer is a
block number within the allocation group to the next level in the Btree.
.PD
.RE
.TP
.B inode
Inodes are allocated in "chunks" of 64 inodes each. Usually a chunk is
multiple filesystem blocks, although there are cases with large filesystem
blocks where a chunk is less than one block. The inode Btree (see
.B inobt
above) refers to the inode numbers per allocation group. The inode numbers
directly reflect the location of the inode block on disk. Use the
.B inode
command to point
.B xfs_db
to a specific inode. Each inode contains four regions:
.BR core ,
.BR next_unlinked ,
.BR u ", and "
.BR a .
.B core
contains the fixed information.
.B next_unlinked
is separated from the core due to journaling considerations, see type
.B agi
field
.BR unlinked .
.B u
is a union structure that is different in size and format depending
on the type and representation of the file data ("data fork").
.B a
is an optional union structure to describe attribute data,
that is different in size, format, and location depending on the presence
and representation of attribute data, and the size of the
.B u
data ("attribute fork").
.B xfs_db
automatically selects the proper union members based on information
in the inode.
.IP
The following are fields in the inode core:
.RS 1.4i
.PD 0
.TP 1.2i
.B magic
inode magic number, 0x494e ('IN').
.TP
.B mode
mode and type of file, as described in
.BR chmod (2),
.BR mknod (2),
and
.BR stat (2).
.TP
.B version
inode version, 1 or 2.
.TP
.B format
format of
.B u
union data (0: xfs_dev_t, 1: local file \- in-inode directory or symlink,
2: extent list, 3: Btree root, 4: unique id [unused]).
.TP
.B nlinkv1
number of links to the file in a version 1 inode.
.TP
.B nlinkv2
number of links to the file in a version 2 inode.
.TP
.B projid_lo
owner's project id (low word; version 2 inode only).
.B projid_hi
owner's project id (high word; version 2 inode only).
.TP
.B uid
owner's user id.
.TP
.B gid
owner's group id.
.TP
.B atime
time last accessed (seconds and nanoseconds).
.TP
.B mtime
time last modified.
.TP
.B ctime
time created or inode last modified.
.TP
.B size
number of bytes in the file.
.TP
.B nblocks
total number of blocks in the file including indirect and attribute.
.TP
.B extsize
basic/minimum extent size for the file.
.TP
.B nextents
number of extents in the data fork.
.TP
.B naextents
number of extents in the attribute fork.
.TP
.B forkoff
attribute fork offset in the inode, in 64-bit words from the start of
.BR u .
.TP
.B aformat
format of
.B a
data (1: local attribute data, 2: extent list, 3: Btree root).
.TP
.B dmevmask
DMAPI event mask.
.TP
.B dmstate
DMAPI state information.
.TP
.B newrtbm
file is the realtime bitmap and is "new" format.
.TP
.B prealloc
file has preallocated data space after EOF.
.TP
.B realtime
file data is in the realtime subvolume.
.TP
.B gen
inode generation number.
.RE
.IP
The following fields are in the
.B u
data fork union:
.RS 1.4i
.TP 1.2i
.B bmbt
bmap Btree root. This looks like a
.B bmapbtd
block with redundant information removed.
.TP
.B bmx
array of extent descriptors.
.TP
.B dev
dev_t for the block or character device.
.TP
.B sfdir
shortform (in-inode) version 1 directory. This consists of a
.B hdr
containing the
.B parent
inode number and a
.B count
of active entries in the directory, followed by an array
.B list
of
.B hdr.count
entries. Each such entry contains
.BR inumber ,
.BR namelen ,
and
.B name
string.
.TP
.B sfdir2
shortform (in-inode) version 2 directory. This consists of a
.B hdr
containing a
.B count
of active entries in the directory, an
.B i8count
of entries with inumbers that don't fit in a 32-bit value, and the
.B parent
inode number, followed by an array
.B list
of
.B hdr.count
entries. Each such entry contains
.BR namelen ,
a saved
.B offset
used when the directory is converted to a larger form, a
.B name
string, and the
.BR inumber .
.TP
.B symlink
symbolic link string value.
.RE
.IP
The following fields are in the
.B a
attribute fork union if it exists:
.RS 1.4i
.TP 1.2i
.B bmbt
bmap Btree root, as above.
.TP
.B bmx
array of extent descriptors.
.TP
.B sfattr
shortform (in-inode) attribute values. This consists of a
.B hdr
containing a
.B totsize
(total size in bytes) and a
.B count
of active entries, followed by an array
.B list
of
.B hdr.count
entries. Each such entry contains
.BR namelen ,
.BR valuelen ,
.BR root
flag,
.BR name ,
and
.BR value .
.PD
.RE
.TP
.B log
Log blocks contain the journal entries for XFS.
It's not useful to examine these with
.BR xfs_db ,
use
.BR xfs_logprint (8)
instead.
.TP
.B refcntbt
There is one set of filesystem blocks forming the reference count Btree for
each allocation group. The root block of this Btree is designated by the
.B refcntroot
field in the corresponding AGF block. The blocks are linked to sibling left
and right blocks at each level, as well as by pointers from parent to child
blocks. Each block has the following fields:
.RS 1.4i
.PD 0
.TP 1.2i
.B magic
REFC block magic number, 0x52334643 ('R3FC').
.TP
.B level
level number of this block, 0 is a leaf.
.TP
.B numrecs
number of data entries in the block.
.TP
.B leftsib
left (logically lower) sibling block, 0 if none.
.TP
.B rightsib
right (logically higher) sibling block, 0 if none.
.TP
.B recs
[leaf blocks only] array of reference count records. Each record contains
.BR startblock ,
.BR blockcount ,
and
.BR refcount .
.TP
.B keys
[non-leaf blocks only] array of key records. These are the first value
of each block in the level below this one. Each record contains
.BR startblock .
.TP
.B ptrs
[non-leaf blocks only] array of child block pointers. Each pointer is a
block number within the allocation group to the next level in the Btree.
.PD
.RE
.TP
.B rmapbt
There is one set of filesystem blocks forming the reverse mapping Btree for
each allocation group. The root block of this Btree is designated by the
.B rmaproot
field in the corresponding AGF block. The blocks are linked to sibling left
and right blocks at each level, as well as by pointers from parent to child
blocks. Each block has the following fields:
.RS 1.4i
.PD 0
.TP 1.2i
.B magic
RMAP block magic number, 0x524d4233 ('RMB3').
.TP
.B level
level number of this block, 0 is a leaf.
.TP
.B numrecs
number of data entries in the block.
.TP
.B leftsib
left (logically lower) sibling block, 0 if none.
.TP
.B rightsib
right (logically higher) sibling block, 0 if none.
.TP
.B recs
[leaf blocks only] array of reference count records. Each record contains
.BR startblock ,
.BR blockcount ,
.BR owner ,
.BR offset ,
.BR attr_fork ,
.BR bmbt_block ,
and
.BR unwritten .
.TP
.B keys
[non-leaf blocks only] array of double-key records. The first ("low") key
contains the first value of each block in the level below this one. The second
("high") key contains the largest key that can be used to identify any record
in the subtree. Each record contains
.BR startblock ,
.BR owner ,
.BR offset ,
.BR attr_fork ,
and
.BR bmbt_block .
.TP
.B ptrs
[non-leaf blocks only] array of child block pointers. Each pointer is a
block number within the allocation group to the next level in the Btree.
.PD
.RE
.TP
.B rtbitmap
If the filesystem has a realtime subvolume, then the
.B rbmino
field in the superblock refers to a file that contains the realtime bitmap.
Each bit in the bitmap file controls the allocation of a single realtime extent
(set == free). The bitmap is processed in 32-bit words, the LSB of a word is
used for the first extent controlled by that bitmap word. The
.B atime
field of the realtime bitmap inode contains a counter
that is used to control where the next new realtime file will start.
.TP
.B rtsummary
If the filesystem has a realtime subvolume, then the
.B rsumino
field in the superblock refers to a file that contains the realtime summary
data. The summary file contains a two-dimensional array of 16-bit values.
Each value counts the number of free extent runs
(consecutive free realtime extents)
of a given range of sizes that starts in a given bitmap block.
The size ranges are binary buckets (low size in the bucket is a power of 2).
There are as many size ranges as are necessary given the size of the
realtime subvolume.
The first dimension is the size range,
the second dimension is the starting bitmap block number
(adjacent entries are for the same size, adjacent bitmap blocks).
.TP
.B sb
There is one sb (superblock) structure per allocation group.
It is the first disk block in the allocation group.
Only the first one (block 0 of the filesystem) is actually used;
the other blocks are redundant information for
.BR xfs_repair (8)
to use if the first superblock is damaged. Fields defined:
.RS 1.4i
.PD 0
.TP 1.2i
.B magicnum
superblock magic number, 0x58465342 ('XFSB').
.TP
.B blocksize
filesystem block size in bytes.
.TP
.B dblocks
number of filesystem blocks present in the data subvolume.
.TP
.B rblocks
number of filesystem blocks present in the realtime subvolume.
.TP
.B rextents
number of realtime extents that
.B rblocks
contain.
.TP
.B uuid
unique identifier of the filesystem.
.TP
.B logstart
starting filesystem block number of the log (journal).
If this value is 0 the log is "external".
.TP
.B rootino
root inode number.
.TP
.B rbmino
realtime bitmap inode number.
.TP
.B rsumino
realtime summary data inode number.
.TP
.B rextsize
realtime extent size in filesystem blocks.
.TP
.B agblocks
size of an allocation group in filesystem blocks.
.TP
.B agcount
number of allocation groups.
.TP
.B rbmblocks
number of realtime bitmap blocks.
.TP
.B logblocks
number of log blocks (filesystem blocks).
.TP
.B versionnum
filesystem version information.
This value is currently 1, 2, 3, or 4 in the low 4 bits.
If the low bits are 4 then the other bits have additional meanings.
1 is the original value.
2 means that attributes were used.
3 means that version 2 inodes (large link counts) were used.
4 is the bitmask version of the version number.
In this case, the other bits are used as flags
(0x0010: attributes were used,
0x0020: version 2 inodes were used,
0x0040: quotas were used,
0x0080: inode cluster alignment is in force,
0x0100: data stripe alignment is in force,
0x0200: the
.B shared_vn
field is used,
0x1000: unwritten extent tracking is on,
0x2000: version 2 directories are in use).
.TP
.B sectsize
sector size in bytes, currently always 512.
This is the size of the superblock and the other header blocks.
.TP
.B inodesize
inode size in bytes.
.TP
.B inopblock
number of inodes per filesystem block.
.TP
.B fname
obsolete, filesystem name.
.TP
.B fpack
obsolete, filesystem pack name.
.TP
.B blocklog
log2 of
.BR blocksize .
.TP
.B sectlog
log2 of
.BR sectsize .
.TP
.B inodelog
log2 of
.BR inodesize .
.TP
.B inopblog
log2 of
.BR inopblock .
.TP
.B agblklog
log2 of
.B agblocks
(rounded up).
.TP
.B rextslog
log2 of
.BR rextents .
.TP
.B inprogress
.BR mkfs.xfs (8)
or
.BR xfs_copy (8)
aborted before completing this filesystem.
.TP
.B imax_pct
maximum percentage of filesystem space used for inode blocks.
.TP
.B icount
number of allocated inodes.
.TP
.B ifree
number of allocated inodes that are not in use.
.TP
.B fdblocks
number of free data blocks.
.TP
.B frextents
number of free realtime extents.
.TP
.B uquotino
user quota inode number.
.TP
.B pquotino
project quota inode number; this is currently unused.
.TP
.B qflags
quota status flags
(0x01: user quota accounting is on,
0x02: user quota limits are enforced,
0x04: quotacheck has been run on user quotas,
0x08: project quota accounting is on,
0x10: project quota limits are enforced,
0x20: quotacheck has been run on project quotas).
.TP
.B flags
random flags. 0x01: only read-only mounts are allowed.
.TP
.B shared_vn
shared version number (shared readonly filesystems).
.TP
.B inoalignmt
inode chunk alignment in filesystem blocks.
.TP
.B unit
stripe or RAID unit.
.TP
.B width
stripe or RAID width.
.TP
.B dirblklog
log2 of directory block size (filesystem blocks).
.PD
.RE
.TP
.B symlink
Symbolic link blocks are used only when the symbolic link value does
not fit inside the inode. The block content is just the string value.
Bytes past the logical end of the symbolic link value have arbitrary values.
.TP
.B text
User file blocks, and other blocks whose type is unknown,
have this type for display purposes in
.BR xfs_db .
The block data is displayed in two columns: Hexadecimal format
and printable ASCII chars.
.SH DIAGNOSTICS
Many messages can come from the
.B check
.RB ( blockget )
command.
If the filesystem is completely corrupt, a core dump might
be produced instead of the message
.RS
.I device
.B is not a valid filesystem
.RE
.PP
If the filesystem is very large (has many files) then
.B check
might run out of memory. In this case the message
.RS
.B out of memory
.RE
is printed.
.PP
The following is a description of the most likely problems and the associated
messages.
Most of the diagnostics produced are only meaningful with an understanding
of the structure of the filesystem.
.TP
.BI "agf_freeblks " n ", counted " m " in ag " a
The freeblocks count in the allocation group header for allocation group
.I a
doesn't match the number of blocks counted free.
.TP
.BI "agf_longest " n ", counted " m " in ag " a
The longest free extent in the allocation group header for allocation group
.I a
doesn't match the longest free extent found in the allocation group.
.TP
.BI "agi_count " n ", counted " m " in ag " a
The allocated inode count in the allocation group header for allocation group
.I a
doesn't match the number of inodes counted in the allocation group.
.TP
.BI "agi_freecount " n ", counted " m " in ag " a
The free inode count in the allocation group header for allocation group
.I a
doesn't match the number of inodes counted free in the allocation group.
.TP
.BI "block " a/b " expected inum 0 got " i
The block number is specified as a pair
(allocation group number, block in the allocation group).
The block is used multiple times (shared), between multiple inodes.
This message usually follows a message of the next type.
.TP
.BI "block " a/b " expected type unknown got " y
The block is used multiple times (shared).
.TP
.BI "block " a/b " type unknown not expected
.SH SEE ALSO
.BR mkfs.xfs (8),
.BR xfs_admin (8),
.BR xfs_copy (8),
.BR xfs_logprint (8),
.BR xfs_metadump (8),
.BR xfs_ncheck (8),
.BR xfs_repair (8),
.BR mount (8),
.BR chmod (2),
.BR mknod (2),
.BR stat (2),
.BR xfs (5).
|