openzfsonosx / zfs

OpenZFS on OS X

Home Page:https://openzfsonosx.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

zvol block size mis-match

mfhwaltz opened this issue · comments

When creating a zvol on macOS, the OS always sees the resulting block device as having a block size of 512 Bytes regardless of the volblocksize for that zvol.

Mojave:~ root# uname -a|perl -p -e 's/\s\S+/ <redacted>/'
Darwin <redacted> 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
Mojave:~ root# zfs version
zfs-1.9.0-1
zfs-kmod-1.9.0-1
Mojave:~ root# diskutil list disk0
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                 Apple_APFS Container disk2         274.7 GB   disk0s2
   3:                        ZFS                         725.3 GB   disk0s3
Mojave:~ root# zpool create -m none -O compression=on testpool disk0s3
Mojave:~ root# zpool list
NAME       SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
testpool   672G   408K   672G        -         -     0%     0%  1.00x  ONLINE  -
Mojave:~ root# zfs create -s -V 10G testpool/testvol1
Mojave:~ root# zfs create -s -b 4k -V 20G testpool/testvol2
Mojave:~ root# zfs list
NAME                USED  AVAIL  REFER  MOUNTPOINT
testpool            556K   651G    96K  none
testpool/testvol1    56K   651G    56K  -
testpool/testvol2    56K   651G    56K  -
Mojave:~ root# zfs get volblocksize testpool/testvol1
NAME               PROPERTY      VALUE     SOURCE
testpool/testvol1  volblocksize  128K      default
Mojave:~ root# zfs get volblocksize testpool/testvol2
NAME               PROPERTY      VALUE     SOURCE
testpool/testvol2  volblocksize  4K        -
Mojave:~ root# diskutil info disk4
   Device Identifier:         disk4
   Device Node:               /dev/disk4
   Whole:                     Yes
   Part of Whole:             disk4
   Device / Media Name:       ZVOL testpool/testvol1

   Volume Name:               Not applicable (no file system)
   Mounted:                   Not applicable (no file system)
   File System:               None

   Content (IOContent):       None
   OS Can Be Installed:       No
   Media Type:                Generic
   Protocol:                  Disk Image
   SMART Status:              Not Supported

   Disk Size:                 10.7 GB (10737418240 Bytes) (exactly 20971520 512-Byte-Units)
   Device Block Size:         512 Bytes

   Read-Only Media:           No
   Read-Only Volume:          Not applicable (no file system)

   Device Location:           External
   Removable Media:           Fixed

   Solid State:               Yes
   Virtual:                   Yes

Mojave:~ root# diskutil info disk5
   Device Identifier:         disk5
   Device Node:               /dev/disk5
   Whole:                     Yes
   Part of Whole:             disk5
   Device / Media Name:       ZVOL testpool/testvol2

   Volume Name:               Not applicable (no file system)
   Mounted:                   Not applicable (no file system)
   File System:               None

   Content (IOContent):       None
   OS Can Be Installed:       No
   Media Type:                Generic
   Protocol:                  Disk Image
   SMART Status:              Not Supported

   Disk Size:                 21.5 GB (21474836480 Bytes) (exactly 41943040 512-Byte-Units)
   Device Block Size:         512 Bytes

   Read-Only Media:           No
   Read-Only Volume:          Not applicable (no file system)

   Device Location:           External
   Removable Media:           Fixed

   Solid State:               Yes
   Virtual:                   Yes

Mojave:~ root# 

That is correct - turns out the IO layer in XNU kernels (at least back in 10.8 when we looked at it) can only do two sizes, 512, and 4096 - everything else is an error. So you can set the recordsize that ZFS will use with the TXGs and all that logic, but when it comes to issuing IO to the devices, it has to use one of the two sizes. We should check if there has been any improvements in this area by Apple, but it seems unlikely.