site_archiver@lists.apple.com Delivered-To: Darwin-kernel@lists.apple.com Dkim-filter: OpenDKIM Filter v2.10.3 mail.lundman.net EE174152546 Dkim-signature: v=1; a=rsa-sha256; c=simple/simple; d=lundman.net; s=dkim; t=1541385405; bh=mE9ESBwusbpLCIa9tB4PkQMfeCaEpBq3O+dzW04WJA4=; h=To:From:Subject:Date; b=XTAuK2vwVlEZ8pUc07sEhiovQVaSNcCfY32U2iRX+pulLwhbTSHd/dPDKJ6oJGAfK fJiipjIp0j89ELlU8Ce5F3sWV2nnQFp6EFuyXjotKe1pjpzodTV/TfYRVDSlpbTZjV kFgMx+DBnAd9832GsW9+nikBHYImWn8HgwfUpgbI= Openpgp: preference=signencrypt User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.3 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 | <lundman@lundman.net> 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 (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.... This email sent to site_archiver@lists.apple.com