A question about TRIM; DKIOCUNMAP vs unmap
A question about TRIM; DKIOCUNMAP vs unmap
- Subject: A question about TRIM; DKIOCUNMAP vs unmap
- From: Jorgen Lundman <email@hidden>
- Date: Mon, 05 Nov 2018 11:36:44 +0900
- Autocrypt: addr=email@hidden; prefer-encrypt=mutual; keydata= xsDiBD2KhOgRBACHjaJI1Q5XudbpYACUeGAKFxsxhhg46svF6Y0HzzDP+ZMQENVGiqucma0H b/mY9knTJ5F+rQZO+LKG2T4oBH1VdznJkz28tkmZUXGCEmNOZ852Hb1fFRwnbngRylMq7cEV TgupfCWYbC6Qw7eKBlHWjlvFosn/r828j7STe0CtawCgsbMU6598cmwIvOXaSGuDHLnMzfED /0SVpaTDADGymmjZ/RUyl7wc0D/1Dd0N17kZzQuwXQtj0CWnGwC8XWEvYLdAwNoGmzkJgVg4 3l5JPo4Yeuj7hNayRCjQU6jvnSdj0AuItfuE76/YdSG/X+TWAdHsizXtdXxf6KrS5PSjWult b4yL2EoYkiN58SflRa287mwJxatpA/9/axDaElD8Ko4QsskT2FamKLms1clT8IcuN1JNP71h b4gG0sng8jIl534r3KucJjlYEIp6lL3jBD/lcNQqd+UXMsR7KKEuDvW/ZMzQdLMvpyRCN463 jzrclxG1rXuvyeSWKiOnQbcD5pwsff3xlbb3mMovkf6rbXxvZxQlfUAuRM0kSm9yZ2VuIEx1 bmRtYW4gPGx1bmRtYW5AbHVuZG1hbi5uZXQ+wlkEExECABkFAj2KhOgECwcDAgMVAgMDFgIB Ah4BAheAAAoJEPNmEmurHstLXGgAnA7x3Ipz89W9tWjeJZ3AeEF6DAX/AJ4+QReCt51Nnovp 3T17+gy+p91MEc7ATQQ9ioTpEAQA5omoMw1PE/2reQ96uhFr/eFtGEc6136juCE6Lbrrc52j /DwsB0s87miNKfBRUGKXaqLQmfPY9Qajz/MHUHQ9iOkpCGou8RNviJGKFup4qf/g1qzNQ9ud pgkTEc7qZ7qBWG5HcOoIAvM78qvKwV0Sedry6TpOaiWsuL1HWdSGXI8AAwcEALVHV3MQ+a5K vwhX8Pam52AnIEzcw3m7tcSoJikLZhR//spUaZ3++hN+NNlSxgnGJ+VWKyhxc+SA/IO32vFP rAS6HxyfdZtIKPXfwM/8HjTUa4n6DR8ChIrS43X6cz3TZCFVD9tYLLP5cKo6uuPBd807EQN+ GJAzER048LeRiWMNwkYEGBECAAYFAj2KhOoACgkQ82YSa6sey0soMgCgg7zP7pYVB12AgkyN 0aUsovPMPCQAnjaw8yZSKLeBOzplkeFSIIbfWqTs
- Dkim-filter: OpenDKIM Filter v2.10.3 mail.lundman.net EE174152546
- Openpgp: preference=signencrypt
Hello,
Trying to add support to TRIM in filesystem. We have two paths through the
code, the classic BSD buf+vnode way to issue IO, the eventually ends up
calling:
error = VNOP_IOCTL(LH_VNODE(lhp), DKIOCUNMAP,
(caddr_t)&dkun, 0, context);
and confirmed to be sent to device by using:
# fs_usage -f filesys -w | egrep -i 'unmap|trim'
11:21:10.671663 TrimExtent D=0x00000001 B=0x8000000 /dev/disk1s1
0.000000 kernel_task.12741
11:21:10.671666 IOCTL <DKIOCUNMAP> /dev/disk1s1
0.000004 kernel_task.12741
so that appears to work.
The second path through the code is the IOKit way, which eventually drops
down to:
error = LH_MEDIA(lhp)->unmap(LH_CLIENT(lhp),
extents, dkm->dfl_num_exts, 0);
Here, nothing happens. Stepping through the kernel, it passes through a few
layers (about 4 layers from memory) in IOKit, before eventually calling:
IOSCSIBlockCommandsDevice::IsUnmapAllowed()
which returns failure. "trimforce" is enabled.
Since the method IsUnmapAllowed() takes no arguments, I assume it has
nothing to do with the extent array I pass it (I build it the same as XNU
sources does for DKIOCUNMAP).
One option would be to always call VNOP_IOCTL and ignore IOKit's unmap, but
it is not easy to do that (cleanly) when we have opened the device using IOkit.
Anything obvious I have missed? What are the criteria regarding
IsUnmapAllowed() ?
Lund
--
Jorgen Lundman | <email@hidden>
Unix Administrator | +81 (0)90-5578-8500
Shibuya-ku, Tokyo | Japan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden