'Trim length bytes from offset.
If the volume is an rbd do a discard() otherwise assume it is a file
and pad with zeroes.'

def _discard_bytes(self, volume, offset, length):

    if length:
        LOG.debug('Discarding    %(length)s    bytes    from    offset    %(offset)s', {'length': length, 'offset': offset})
        if self._file_is_rbd(volume):
            volume.rbd_image.discard(offset, length)
        else:
            zeroes = ('\x00' * self.chunk_size)
            chunks = int((length / self.chunk_size))
            for chunk in range(0, chunks):
                LOG.debug('Writing    zeroes    chunk    %d', chunk)
                volume.write(zeroes)
                volume.flush()
                eventlet.sleep(0)
            rem = int((length % self.chunk_size))
            if rem:
                zeroes = ('\x00' * rem)
                volume.write(zeroes)
                volume.flush()
