I’m currently developing a virtual SCSI device driver using IOKit. My driver loads fine and I’m able to format my device using ExFat, FAT32 or HFS+.
I am also able to copy files to and from my virtual device using a CLI with any of these file systems. Using either ExFat or FAT32, I can also copy or view files from my virtual device using Finder, but not when the drive is formatted HFS+ (Journaled).
When using HFS+, I get kernel panics associated with either Finder, Spotlight or Preview. This occurs, for example, when the system tries to preview the file after it has been copied to the disk. Here's a sample log from a kernel panic:
Mon Jun 30 22:47:51 2014
panic(cpu 4 caller 0xffffff8005dd1401): "cluster_read_copy: failed to get pagelist"@/SourceCache/xnu/xnu-2422.100.13/bsd/vfs/vfs_cluster.c:3732
Backtrace (CPU 4), Frame : Return Address
0xffffff80e9aa3810 : 0xffffff8005c22fa9
0xffffff80e9aa3890 : 0xffffff8005dd1401
0xffffff80e9aa3a30 : 0xffffff8005dd0a85
0xffffff80e9aa3cf0 : 0xffffff8005f6b876
0xffffff80e9aa3d80 : 0xffffff8005dfdd21
0xffffff80e9aa3e00 : 0xffffff8005df38d5
0xffffff80e9aa3e50 : 0xffffff8005ff1cfe
0xffffff80e9aa3ef0 : 0xffffff8005ff1e79
0xffffff80e9aa3f50 : 0xffffff8006040653
0xffffff80e9aa3fb0 : 0xffffff8005cf3c56
BSD process name corresponding to current thread: Finder
Boot args: debug=0x144
Mac OS version:
13D65
Kernel version:
Darwin Kernel Version 13.2.0: Thu Apr 17 23:03:13 PDT 2014; root:xnu-2422.100.13~1/RELEASE_X86_64
Here's the stack trace for the above panic log:
mach_kernel`panic + 201 at debug.c:353
mach_kernel`cluster_read_copy + 2001 at vfs_cluster.c:3732
mach_kernel`cluster_read_ext + 5045 at vfs_cluster.c:3441
mach_kernel`hfs_vnop_read + 566 at hfs_readwrite.c
mach_kernel`VNOP_READ + 225 at kpi_vfs.c:3247
mach_kernel`vn_read + 245 at vfs_vnops.c:939
mach_kernel`dofileread + 174 at sys_generic.c:377
mach_kernel`pread_nocancel + 137 at sys_generic.c:266
mach_kernel`unix_syscall64 + 499 at systemcalls.c:370
mach_kernel`hndl_unix_scall64 + 22
I've had difficulty determining the problem but as implied above have narrowed down to HFS+. Is there something special about HFS+ that could cause this?
Since the problem has to do with the VFS and paging(?) I’m beginning to wonder whether I’m handling my IOMemoryDescriptors correctly (I believe I am, based on what I've read in Apple docs). Anyone experience similar problems? Is this typically indicative of a particular type of problem?
UPDATE: I've verified that disabling journaling in HFS+ does not have an effect on the above results.
UPDATE2: The panic logs are consistent each time. The panic occurs only when ALL of the following conditions have been met:
- HFS+ is used
- File is copied to the device (for a single file > a few MB)
- File is copied using Finder (but not terminal, for example)
The kernel consistently panics right as the first file finishes copying to the device. Many small files equal to or larger than several MB can be copied without causing a panic. I can even copy files large files (> 30 MB) to the volume using terminal and read / open them in Finder.