[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] block/raw-posix.c: add BLKDISCARD support
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH] block/raw-posix.c: add BLKDISCARD support |
Date: |
Mon, 14 Nov 2011 14:08:13 +0000 |
On Fri, Nov 11, 2011 at 8:56 PM, e-t172 <address@hidden> 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