Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Implement discard for AIO on certain file systems #167

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Commits on Oct 7, 2015

  1. Add support for discard to tapdisk

    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 <[email protected]>
    Robert Breker committed Oct 7, 2015
    Configuration menu
    Copy the full SHA
    1a51656 View commit details
    Browse the repository at this point in the history
  2. Add discard support to the block_aio driver

    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 <[email protected]>
    Robert Breker committed Oct 7, 2015
    Configuration menu
    Copy the full SHA
    442ee66 View commit details
    Browse the repository at this point in the history
  3. Have tapback announce the discard capability for vbds

    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 <[email protected]>
    Robert Breker committed Oct 7, 2015
    Configuration menu
    Copy the full SHA
    4988fb0 View commit details
    Browse the repository at this point in the history