On Fri, Nov 11, 2011 at 8:56 PM, e-t172 <e-t...@akegroup.org> wrote: > +static int hdev_co_discard(BlockDriverState *bs, int64_t sector_num, > + int nb_sectors) > +{ > + BDRVRawState *s = bs->opaque; > + int fd = s->fd; > + uint64_t range[2]; > + > + range[0] = sector_num << 9; > + range[1] = nb_sectors << 9; > + if (ioctl(fd, BLKDISCARD, &range)) { > + return -errno; > + } > + return 0; > +}
Is ioctl(BLKDISCARD) guaranteed non-blocking? I think we need to use paio_ioctl() here instead to do this asynchronously. Let's also be careful about Linux-specific ioctls. This code should not poke an unsupported ioctl() on OSes which do not support BLKDISCARD. We definitely need a plan when #if !defined(__linux__). Stefan