ataraid module has subdisk pseudo-driver which attaches to ata diskis. It calls ata_raid_read_metadata() function which allocate memory which shares between all subdisks in RAID: if (!raidp[array]) { raidp[array] = (struct ar_softc *)malloc(sizeof(struct ar_softc), M_AR, M_NOWAIT | M_ZERO); if (!raidp[array]) { device_printf(parent, "failed to allocate metadata storage\n"); goto adaptec_out; } } (Similar code has all ata_raid_xxxx_read_meta functions) Pointer to this memory stored in static local array ata_raid_arrays[]. This memory not freed when ataraid module unloads. Attached patch adds freeing memory on module unload. Because ataraid(4) module has two kernel modules - subdisk and ataraid, they both will be unloaded when `kldunload ataraid`. And all subdisks will be detached. So we can free shared memory between subdisks, but we should reset all pointers before freeing, because ata_raid_subdisk_detach() method will be called on module unload and this method can do access to this memory after freeing. I'm not 100% sure in correctness of this patch, so it needs review..
Andrey V. Elsukov wrote: > I'm not 100% sure in correctness of this patch, so it needs review.. I forgot to mention that it works for me. Without patch after unload module system reports that 1k ar_driver-type memory leaked. After patch this message gone. I have only one RAID configured on Intel Matrix. -- WBR, Andrey V. Elsukov
atapicam is no more after FreeBSD 9.x. Long live atacam and friends.