At Sun, 14 Apr 2013 13:16:44 +0800, Liu Yuan wrote: > > From: Liu Yuan <tailai...@taobao.com> > > The 'TRIM' command from VM that is to release underlying data storage for > better thin-provision is already supported by the Sheepdog. > > This patch adds the TRIM support at QEMU part. > > For older Sheepdog that doesn't support it, we return EIO to upper layer.
I think we can safely return 0 without doing anything when the server doesn't support SD_OP_DISCARD. Actually, if the block driver doesn't support the discard operation, bdrv_co_discard() in block.c returns 0. > diff --git a/block/sheepdog.c b/block/sheepdog.c > index 987018e..e852d4e 100644 > --- a/block/sheepdog.c > +++ b/block/sheepdog.c > @@ -34,6 +34,7 @@ > #define SD_OP_GET_VDI_INFO 0x14 > #define SD_OP_READ_VDIS 0x15 > #define SD_OP_FLUSH_VDI 0x16 > +#define SD_OP_DISCARD 0x17 This is an opcode for objects, so I prefer SD_OP_DISCARD_OBJ. > > +static int sd_co_discard(BlockDriverState *bs, int64_t sector_num, > + int nb_sectors) Should add coroutine_fn. Thanks, Kazutaka