[RFC] Implement discard for AIO on certain file systems#167
[RFC] Implement discard for AIO on certain file systems#167robertbreker wants to merge 3 commits intoxapi-project:masterfrom
Conversation
With this commit, tapdisk is able to understand and pass-through discard request to tapdisk drivers which support it. Each discard messages on the xen blkif is handled as follows: 1. xenio_blkif_get_request() gets discard requests from the ring. It decodes the request depending on the blkif protocol type and converts them into generic blkif_request_discard_t using blkif_get_req_discard. 2. tapdisk_xenblkif_make_vbd_request() iterates the message counter blkback_stats.st_ds_req for discards. 3. tapdisk_xenblkif_parse_request_discard() converts the discard request into a td_vbd_request with a start sector (sec) and a length (discard_nr_sectors). 3. The td_vbd_request is encapsulated into a td_request_t and is sanity checked in tapdisk_image_check_td_request, tapdisk_image_check_request and the new td_queue_discard method. 4. Ultimately the request is handled in td_queue_discard. If the tapdisk driver implements td_queue_discard, the request is passed through to that. If not, the request is failed with -EOPNOTSUPP. This commit has been dev-tested using: * v8 Windows PV drivers that include XenDisk and thereby implement discard * Linux xen-blkfront that implements discard Signed-off-by: Robert Breker <robert.breker@citrix.com>
This commit enables discard for images accessed using block_aio: - For discard support, the image must be stored on a filesystem that supports hole punching. To determine this, there is a whitelist in util.c:is_hole_punching_supported_for_fd(), that filters based on the kernel version and filesystem. - Discard request are handled as synchronous hole punches into the image. This commit has been dev-tested using: * v8 Windows PV drivers that include XenDisk and thereby implement discard * Linux xen-blkfront that implements discard Signed-off-by: Robert Breker <robert.breker@citrix.com>
The discard capability is announced for vbds if the following two conditions apply: * The backing tapdisk indicates discard support for the image that is attached to the vbd (i.e. block-aio is used in combination with a capable filesystem) * tapback is not run with the --nodiscard overwrite If discard is enabled, the discard granularity (discard_granularity) is statically announced as the sector size of the vbd. The alignment (discard_alignment) is statically announced as 0. Secure discard (discard_secure) is never guaranteed. This commit has been dev-tested using: * v8 Windows PV drivers that include XenDisk and thereby implement discard * Linux xen-blkfront that implements discard Signed-off-by: Robert Breker <robert.breker@citrix.com>
ef8c442 to
4988fb0
Compare
|
I've squeezed the changes and grouped them so they are easier to review. The elephant in the room is still the potential request reordering of discards, as raised by Felipe:
|
|
Regarding the reordering of requests:
As the next step I'd suggest:
This will need some more thoughts both from @malcolmcrossley and myself to be certain. |
Discard support is announced to the guest, if each of the following conditions
is true:
punching in tapdisk-util.c:is_hole_punching_supported_for_fd()
Discard requests are translated into the following request on the file system:
This commit has been dev-tested using:
Signed-off-by: Robert Breker robert.breker@citrix.com