Original text: ASM Disk Directory
Author: Bane Radulovic
Translator: Guo Xurui, Warbury Technology Product Delivery Manager, is responsible for the overall delivery management, technical support and maintenance services of QData Cloud high-performance database cloud platform, QBackup database second-level backup recovery cloud platform and other products.
Revision: Wei Xinghua
Editorial Responsibility: Zhong Peiyi
This article describes file 2 of ASM meta-information. ASM file 2 is the disk directory of ASM, which tracks all disks in the disk group. Because the disk group is a separate storage unit in ASM, each disk group will have its own disk directory.
Translator's Note: Each disk group in ASM is self-explanatory, and there is no information dependency between disk groups.
For ASM, the disk directory is only a common ASM file, and there will be its entries in the ASM file directory. If the disk group makes redundancy strategy, it will mirror accordingly, and expand the space according to the actual needs like other files.
Each disk directory entry maintains some of the following information:
- Disk number
- Status of Disks
- Name of disk
- The Failgroup name
- Created timestamp
- Failure timestamp
- Time from Failure Timestamp to Current Time
- resize target value
- Disk repair time
- Zone Information
V$ASM_DISK view
Most of the information about the disk directory can be obtained from view V$ASM_DISK, where each disk has a row of records, including which disks are not yet any disk group. Each query of this view results in ASM performing disk discovery operations, so querying this view is costly.
The following example shows the output of querying the V$ASM_DISK view in the ASM instance:
SQL> SELECT group_number, disk_number, state, name, mount_status
FROM v$asm_disk;
GROUP_NUMBER DISK_NUMBER STATE NAME MOUNT_S
------------ ----------- -------- ------------ -------
0 0 NORMAL CLOSED
0 1 NORMAL CLOSED
0 2 NORMAL CLOSED
0 6 NORMAL CLOSED
1 0 NORMAL ASMDISK1 CACHED
1 1 NORMAL ASMDISK2 CACHED
1 2 NORMAL ASMDISK3 CACHED
1 3 NORMAL ASMDISK4 CACHED
2 0 NORMAL ASMDISK5 CACHED
2 1 NORMAL ASMDISK6 CACHED
10 rows selected.
SQL>
We obtained all the disks identified by ASM, including those that are not currently mount ing disk groups (GROUP_NUMBER=0).
V$ASM_DISK_STAT view
View V $ASM_DISK_STAT shows the same information as V $ASM_DISK, but querying V $ASM_DISK_STAT does not perform the operation of discovering all disks. Its information comes from the SGA area of the ASM instance, and the cost of querying V$ASM_DISK_STAT is not high, because the operation of discovering disks is not carried out, but the results of this query may not reflect the status of the system disks in real time.
Translator's Note: The information in V$ASM_DISK_STAT can only reflect the disk information of the current mounted disk group, not only the information of the newly added disk of the system.
The following query shows the output of querying the V$ASM_DISK_STAT view in the ASM instance:
SQL> SELECT group_number, disk_number, state, name, mount_status
FROM v$asm_disk_stat;
GROUP_NUMBER DISK_NUMBER STATE NAME MOUNT_S
------------ ----------- -------- ------------ -------
1 0 NORMAL ASMDISK1 CACHED
1 1 NORMAL ASMDISK2 CACHED
1 2 NORMAL ASMDISK3 CACHED
1 3 NORMAL ASMDISK4 CACHED
2 0 NORMAL ASMDISK5 CACHED
2 1 NORMAL ASMDISK6 CACHED
6 rows selected.
SQL>
This time, we only saw the disks on mount's disk group.
Locating the disk directory
We can query the solid-state table X$KFFXP in the ASM instance to see which AU belongs to ASM No. 2 file. At the same time, we can get the disk name of ASM through the join view V$ASM_DISK_STAT. Let's query a disk group:
SQL> SELECT x.xnum_kffxp "Extent",
x.au_kffxp "AU",
x.disk_kffxp "Disk #",
d.name "Disk name"
FROM x$kffxp x, v$asm_disk_stat d
WHERE x.group_kffxp=d.group_number
and x.disk_kffxp=d.disk_number
and x.group_kffxp=1
and x.number_kffxp=2
ORDER BY 1, 2;
Extent AU Disk # Disk name
--------- ---------- ---------- ---------
0 2 3 ASMDISK4
0 3 0 ASMDISK1
0 3 1 ASMDISK2
SQL>
The results above show two things: ASM's disk directory is mirrored three times, and the current size of the disk directory is three physical extent s (in this case, three AU s). Again, even in a normal redundant disk group, ASM's disk directory is mirrored three times.
Let's use the kfed tool to see the contents of the disk directory. Since the data is the same in three AUs, we just need to look at the contents of the first AU. Here is AU 2 of ASMDISK4:
$ kfed read /dev/oracleasm/disks/ASMDISK4 aun=2 | more
kfbh.endian: 1 ; 0x000: 0x01
kfbh.hard: 130 ; 0x001: 0x82
kfbh.type: 6 ; 0x002: KFBTYP_DISKDIR
...
kfddde[0].entry.incarn: 1 ; 0x024: A=1 NUMM=0x0
kfddde[0].entry.hash: 0 ; 0x028: 0x00000000
kfddde[0].entry.refer.number:4294967295 ; 0x02c: 0xffffffff
kfddde[0].entry.refer.incarn: 0 ; 0x030: A=0 NUMM=0x0
kfddde[0].dsknum: 0 ; 0x034: 0x0000
kfddde[0].state: 2 ; 0x036: KFDSTA_NORMAL
kfddde[0].ddchgfl: 132 ; 0x037: 0x84
kfddde[0].dskname: ASMDISK1 ; 0x038: length=8
kfddde[0].fgname: ASMDISK1 ; 0x058: length=8
kfddde[0].crestmp.hi: 32960657 ; 0x078: HOUR=0x11 DAYS=0x4 MNTH=0xc YEAR=0x7db
kfddde[0].crestmp.lo: 2843202560 ; 0x07c: USEC=0x0 MSEC=0x1f5 SECS=0x17 MINS=0x2a
kfddde[0].failstmp.hi: 0 ; 0x080: HOUR=0x0 DAYS=0x0 MNTH=0x0 YEAR=0x0
kfddde[0].failstmp.lo: 0 ; 0x084: USEC=0x0 MSEC=0x0 SECS=0x0 MINS=0x0
kfddde[0].timer: 0 ; 0x088: 0x00000000
kfddde[0].size: 4094 ; 0x08c: 0x00000ffe
kfddde[0].srRloc.super.hiStart: 0 ; 0x090: 0x00000000
kfddde[0].srRloc.super.loStart: 0 ; 0x094: 0x00000000
kfddde[0].srRloc.super.length: 0 ; 0x098: 0x00000000
kfddde[0].srRloc.incarn: 0 ; 0x09c: 0x00000000
kfddde[0].dskrprtm: 0 ; 0x0a0: 0x00000000
kfddde[0].zones[0].start: 0 ; 0x0a4: 0x00000000
kfddde[0].zones[0].size: 4094 ; 0x0a8: 0x00000ffe
kfddde[0].zones[0].used: 47 ; 0x0ac: 0x0000002f
...
kfddde[1].entry.incarn: 1 ; 0x1e4: A=1 NUMM=0x0
kfddde[1].entry.hash: 1 ; 0x1e8: 0x00000001
kfddde[1].entry.refer.number:4294967295 ; 0x1ec: 0xffffffff
kfddde[1].entry.refer.incarn: 0 ; 0x1f0: A=0 NUMM=0x0
kfddde[1].dsknum: 1 ; 0x1f4: 0x0001
kfddde[1].state: 2 ; 0x1f6: KFDSTA_NORMAL
kfddde[1].ddchgfl: 132 ; 0x1f7: 0x84
kfddde[1].dskname: ASMDISK2 ; 0x1f8: length=8
...
kfddde[2].entry.incarn: 1 ; 0x3a4: A=1 NUMM=0x0
kfddde[2].entry.hash: 2 ; 0x3a8: 0x00000002
kfddde[2].entry.refer.number:4294967295 ; 0x3ac: 0xffffffff
kfddde[2].entry.refer.incarn: 0 ; 0x3b0: A=0 NUMM=0x0
kfddde[2].dsknum: 2 ; 0x3b4: 0x0002
kfddde[2].state: 2 ; 0x3b6: KFDSTA_NORMAL
kfddde[2].ddchgfl: 132 ; 0x3b7: 0x84
kfddde[2].dskname: ASMDISK3 ; 0x3b8: length=8
...
$
The kfbh.type in the output information is KFBTYP_DISKDIR, which represents a disk directory. The information of the disks in ASM is stored in the area of kfddde that outputs the contents above, kfddde[0] is about disk 0, kfddde[1] is about disk 1, and so on. In this way, we can know all the disk information in the disk group. As you can see, most of the information can be obtained through view V$ASM_DISK, rather than through kfed.
Conclusion
The ASM disk directory maintains information about all disks in the ASM disk group, which can be basically accessed through view V$ASM_DISK or through the kfed tool.