Sašo Kiselkov
2013-02-27 00:30:07 UTC
So I've been working on getting some initial support for SCSI Unmap and
SATA TRIM into ZFS and my work can so far be viewed here:
http://cr.illumos.org/~webrev/skiselkov/zfs_unmap/
My changes so far consist of:
1) Altering dkioc_free_t to take a linked list of dkioc_free_extent_t's,
so that we can exploit the underlying commands to their fullest
potential (issuing a single Unmap/TRIM command for multiple extents,
not one command per extent).
2) Altering stmf_sbd/sbd.c, stmf_sbd/sbd_scsi.c and zfs/zvol.c to
exploit the above API change.
3) Implemented walking of the freed_map in metaslab_sync_done to notify
the vdevs of freed extents (via DKIOCFREE zio's).
4) Implemented support for DKIOCFREE zio's in vdev_disk_io_start to
issue the ioctl to the underlying sd layer.
5) Tested 3&4 to at least make sure it doesn't bomb on boot.
The current implementation is limited to issuing DKIOCFREE ioctl's only
for leaf disk-vdevs and mirror vdevs, since raidz vdevs can vary their
layout geometry and we'd need to do some smart extent offset
recalculation there to get it right for leaf vdevs.
My questions to the kind people here are:
1) Won't the changes in dkioc_free_t break external applications? My
guess is no, since I'm not aware of anybody using this interface
externally (other than COMSTAR, which I updated).
2) Do you think doing unmap in metaslab_sync_done is a good way to go
about it? In particular, I'm not sure if this won't make implementing
it for raidz at a later date harder or impossible.
3) I'm a bit dubious about whether I understand space_map internals
right and am walking the extents in freed_map in metaslab_vdev_free
correctly (the code for space_maps is completely undocumented, so
I'm inferring how they work by learning from their other uses).
Specifically, I'd also like to ask for somebody to please help me
implement DKIOCFREE ioctl support in sd.c (i.e. encode a SCSI Unmap and
SATA TRIM) - I believe this requires digging around deep in driver
bowels and I don't feel like I'm skilled enough to do it just yet. At
the moment the ZFS ioctl calls simply hit ldi_ioctl which returns an
ENOTSUP, which prompts the vdev to stop making these calls (subsequent
DKIOCFREE zio's are not even attempted and simply return ENOTSUP right
away). Another issue is that while I have documentation for the SCSI
Unmap command structure, I don't for SATA TRIM (subscription required -
yay!). If by some lucky coincidence I figure out how to add support for
DKIOCFREE in sd.c, if somebody could please provide me the correct
command structure for SATA, I'd greatly appreciate.
Please let me know what you think. Thanks!
Cheers,
--
Saso
SATA TRIM into ZFS and my work can so far be viewed here:
http://cr.illumos.org/~webrev/skiselkov/zfs_unmap/
My changes so far consist of:
1) Altering dkioc_free_t to take a linked list of dkioc_free_extent_t's,
so that we can exploit the underlying commands to their fullest
potential (issuing a single Unmap/TRIM command for multiple extents,
not one command per extent).
2) Altering stmf_sbd/sbd.c, stmf_sbd/sbd_scsi.c and zfs/zvol.c to
exploit the above API change.
3) Implemented walking of the freed_map in metaslab_sync_done to notify
the vdevs of freed extents (via DKIOCFREE zio's).
4) Implemented support for DKIOCFREE zio's in vdev_disk_io_start to
issue the ioctl to the underlying sd layer.
5) Tested 3&4 to at least make sure it doesn't bomb on boot.
The current implementation is limited to issuing DKIOCFREE ioctl's only
for leaf disk-vdevs and mirror vdevs, since raidz vdevs can vary their
layout geometry and we'd need to do some smart extent offset
recalculation there to get it right for leaf vdevs.
My questions to the kind people here are:
1) Won't the changes in dkioc_free_t break external applications? My
guess is no, since I'm not aware of anybody using this interface
externally (other than COMSTAR, which I updated).
2) Do you think doing unmap in metaslab_sync_done is a good way to go
about it? In particular, I'm not sure if this won't make implementing
it for raidz at a later date harder or impossible.
3) I'm a bit dubious about whether I understand space_map internals
right and am walking the extents in freed_map in metaslab_vdev_free
correctly (the code for space_maps is completely undocumented, so
I'm inferring how they work by learning from their other uses).
Specifically, I'd also like to ask for somebody to please help me
implement DKIOCFREE ioctl support in sd.c (i.e. encode a SCSI Unmap and
SATA TRIM) - I believe this requires digging around deep in driver
bowels and I don't feel like I'm skilled enough to do it just yet. At
the moment the ZFS ioctl calls simply hit ldi_ioctl which returns an
ENOTSUP, which prompts the vdev to stop making these calls (subsequent
DKIOCFREE zio's are not even attempted and simply return ENOTSUP right
away). Another issue is that while I have documentation for the SCSI
Unmap command structure, I don't for SATA TRIM (subscription required -
yay!). If by some lucky coincidence I figure out how to add support for
DKIOCFREE in sd.c, if somebody could please provide me the correct
command structure for SATA, I'd greatly appreciate.
Please let me know what you think. Thanks!
Cheers,
--
Saso