【转】ASM file extent map

Extents smallWhen ASM creates a file, e.g. on a request from an RDBMS instance, it allocates space in extents. Once the file is created, ASM passes the extent map to the RDBMS instance that can then access the file without involving ASM. If a file extent needs to be relocated (e.g. due to a disk group rebalance), ASM would advise RDBMS instance about the modifications to the extent map.

We can access ASM file extent maps by querying X$KFFXP in ASM instance. There is one row in X$KFFXP for every physical extent of every file in every mounted disk group.

The important columns of X$KFFXP are:

  • GROUP_KFFXP The disk group number. Note that the disk group number is not persistent, i.e. it can change every time the disk group is mounted. Same as V$ASM_DISKGROUP.GROUP_NUMBER.
  • NUMBER_KFFXP The file number – same as V$ASM_FILE.FILE_NUMBER. Note that this is an ASM file number, not to be confused with the database datafile number. File numbers under 256 are reserved for ASM metadata files.
  • INCARN_KFFXP The file incarnation number. It is changed every time an ASM file number is reused for a new file. Same as V$ASM_FILE.INCARNATION. Note that ASM file name ends in NUMBER_KFFXP.INCARN_KFFXP.
  • XNUM_KFFXP The virtual extent number. For external redundancy disk groups this is the same as the physical extent. For normal redundancy disk groups this is the physical extent divided by 2. For high redundancy disk groups this is the physical extent divided by 3.
  • PXN_KFFXP The physical extent number. The first physical extent of a file is number 0.
  • LXN_KFFXP The physical extent number within the virtual extent. 0 = primary extent, 1 = secondary extent, 2 = third copy of the extent.
  • DISK_KFFXP The disk number –  same as V$ASM_DISK.DISK_NUMBER.
  • AU_KFFXP The allocation unit number.

The following query – in an ASM instance – shows ASM metadata file numbers, names and allocation unit count in disk group number 3:

$ sqlplus / as sysasm
SQL> select NUMBER_KFFXP “ASM file number”, DECODE (NUMBER_KFFXP,
1, ‘File directory’, 2, ‘Disk directory’, 3, ‘Active change directory’, 4, ‘Continuing operations directory’,
5, ‘Template directory’, 6, ‘Alias directory’, 7, ‘ADVM file directory’, 8, ‘Disk free space directory’,
9, ‘Attributes directory’, 10, ‘ASM User directory’, 11, ‘ASM user group directory’, 12, ‘Staleness directory’,
253, ‘spfile for ASM instance’, 254, ‘Stale bit map space registry ‘, 255, ‘Oracle Cluster Repository registry’) “ASM metadata file name”,
count(AU_KFFXP) “Allocation units”
from X$KFFXP
where GROUP_KFFXP=3 and NUMBER_KFFXP<256
group by NUMBER_KFFXP
order by 1;

ASM file number ASM metadata file name             Allocation units
————— ———————————- —————-
1 File directory                                    3
2 Disk directory                                    3
3 Active change directory                          69
4 Continuing operations directory                   6
5 Template directory                                3
6 Alias directory                                   3
8 Disk free space directory                         3
9 Attributes directory                              3
12 Staleness directory                               3
253 spfile for ASM instance                           2
254 Stale bit map space registry                      3
255 Oracle Cluster Repository registry              135

12 rows selected.
SQL>

As we can see, this disk group does not have all types of metadata files. It is interesting to note that there are at least 3 allocation units for each file (except ASM spfile). More on this in a separate post…

Let’s look at the extent map of a database control file.

First see if we have any control files in disk group DATA (run asmcmd as Grid Infrastructure OS user):

$ asmcmd find –type controlfile +DATA “*”
+DATA/DBM/CONTROLFILE/Current.256.738247649
+DATA/BR/CONTROLFILE/Current.299.748434267
$

Now check the disk group number for disk group DATA (connect to ASM instance)

$ sqlplus / as sysasm
SQL> select GROUP_NUMBER from V$ASM_DISKGROUP where NAME=’DATA’;

GROUP_NUMBER
————
1

SQL>

Now look at the extent map for ASM file 256 (+DATA/DBM/CONTROLFILE/Current.256.738247649) in disk group 1:

SQL> select XNUM_KFFXP “Virtual extent”, PXN_KFFXP “Physical extent”, LXN_KFFXP “Extent copy”, DISK_KFFXP “Disk”, AU_KFFXP “Allocation unit”
from X$KFFXP
where GROUP_KFFXP=1 and NUMBER_KFFXP=256 and XNUM_KFFXP<>2147483648
order by 1,2;

Virtual extent Physical extent Extent copy       Disk Allocation unit
————– ————— ———– ———- —————
0               0           0         20               5
0               1           1         29            1903
0               2           2          6              82
1               3           0         22               6
1               4           1         31               8
1               5           2          9               3
2               6           0         30               8
2               7           1         23            1907
2               8           2          7              63
3               9           0         26               2
3              10           1         16            1904
3              11           2          6               4

39             117           0         25            1913
39             118           1         15            1906
39             119           2          3              27

120 rows selected.

SQL>

So this control file is tripple mirrored – each virtual extent has 3 physical extents. And the result shows the actual location of every allocation unit for this file.

Comment

*

沪ICP备14014813号

沪公网安备 31010802001379号