Oracle 12c: Oracle ASM Filter Driver (AFD)


27.09.2014
by Kamil Stawiarski

In Oracle 12c (12.1.0.2 to be exact) we can find a cool new feature: Oracle ASM Filter Driver.
Quoting after the documentiation:

Oracle ASM Filter Driver (Oracle ASMFD) is a kernel module that resides in the I/O path of the Oracle ASM disks. Oracle ASM uses the filter driver to validate write I/O requests to Oracle ASM disks.

The Oracle ASMFD simplifies the configuration and management of disk devices by eliminating the need to rebind disk devices used with Oracle ASM each time the system is restarted.

The Oracle ASM Filter Driver rejects any I/O requests that are invalid. This action eliminates accidental overwrites of Oracle ASM disks that would cause corruption in the disks and files within the disk group. For example, the Oracle ASM Filter Driver filters out all non-Oracle I/Os which could cause accidental overwrites.

After installation of Oracle Grid Infrastructure, you can optionally configure Oracle ASMFD for your system. If ASMLIB is configured for an existing Oracle ASM installation, then you must explicitly migrate the existing ASMLIB configuration to Oracle ASMFD.

So let’s find out how it works 🙂

I have Oracle 12.1.0.2 installed on OEL 6.5 with UEK3. Since I’m using ASMLib, I have to migrate to AFD, using the asmcmd tool:

– First of all, I have to shutdown the HAS services:

[root@skiper ~]# crsctl stop has
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'skiper'
CRS-2673: Attempting to stop 'ora.LISTENER.lsnr' on 'skiper'
CRS-2673: Attempting to stop 'ora.DATA.dg' on 'skiper'
CRS-2677: Stop of 'ora.DATA.dg' on 'skiper' succeeded
CRS-2673: Attempting to stop 'ora.asm' on 'skiper'
CRS-2677: Stop of 'ora.LISTENER.lsnr' on 'skiper' succeeded
CRS-2677: Stop of 'ora.asm' on 'skiper' succeeded
CRS-2673: Attempting to stop 'ora.evmd' on 'skiper'
CRS-2677: Stop of 'ora.evmd' on 'skiper' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'skiper'
CRS-2677: Stop of 'ora.cssd' on 'skiper' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'skiper' has completed
CRS-4133: Oracle High Availability Services has been stopped.

– Then I have to use the asmcmd tool as the root user to enable the AFD driver:

[root@skiper ~]# asmcmd afd_configure
Connected to an idle instance.
AFD-627: AFD distribution files found.
AFD-636: Installing requested AFD software.
AFD-637: Loading installed AFD drivers.
AFD-9321: Creating udev for AFD.
AFD-9323: Creating module dependencies - this may take some time.
AFD-9154: Loading 'oracleafd.ko' driver.
AFD-649: Verifying AFD devices.
AFD-9156: Detecting control device '/dev/oracleafd/admin'.
AFD-638: AFD installation correctness verified.
Modifying resource dependencies - this may take some time.
ASMCMD-9524: AFD configuration failed 'ERROR: OHASD start failed'

You can ignore the last error and start the HAS services manualy 🙂

After this configuration we will find the new udev rules:

[root@skiper ~]# cat /etc/udev/rules.d/53-afd.rules
#
# AFD devices
KERNEL=="oracleafd/.*", OWNER="oracle", GROUP="dba", MODE="0770"
KERNEL=="oracleafd/*", OWNER="oracle", GROUP="dba", MODE="0770"
KERNEL=="oracleafd/disks/*", OWNER="oracle", GROUP="dba", MODE="0660"

And the prefix of the ASM devices will change to "AFD:*"

[oracle@skiper ~]$ asmcmd
ASMCMD> lsdsk
Path
AFD:DATA
ASMCMD> afd_lsdsk
--------------------------------------------------------------------------------
Label                     Filtering   Path
================================================================================
DATA                       DISABLED   /dev/sdb1

OK. So now let’s try to start the actual filtering and do some tests with my favourite tool: "dd" 🙂

ASMCMD> afd_filter -e
ASMCMD> afd_lsdsk
--------------------------------------------------------------------------------
Label                     Filtering   Path
================================================================================
DATA                        ENABLED   /dev/sdb1

[root@skiper ~]# dd if=/dev/zero of=/dev/sdb1 bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 4.43353 s, 242 MB/s

[root@skiper ~]# tail -10 /var/log/messages
Sep 23 22:04:31 skiper kernel: F 4299051.469/140923200431 flush-8:16[13961]  afd_mkrequest_fn: write IO on ASM managed device (major=8/minor=17)  not supported i=1 start=1361920 seccnt=1  pstart=63  pend=25157790

As you can see, the AFD has prohibited overwriting the device, that is a part of the ASM diskgroup. So it’s pretty cool.
The bad news is, that after enabling this feature I got a lot of "kernel panic" situations 🙁

So to sum up: great feature and I will be happy using it in production… but maybe in R2.


Contact us

Database Whisperers sp. z o. o. sp. k.
al. Jerozolimskie 200, 3rd floor, room 342
02-486 Warszawa
NIP: 5272744987
REGON:362524978
+48 508 943 051
+48 661 966 009
info@ora-600.pl

Newsletter Sign up to be updated