Received: from eggs.gnu.org ([208.118.235.92]:38049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URl3c-0004Z5-57 for qemu-devel@nongnu.org; Mon, 15 Apr 2013 11:11:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URl3a-0003zf-Ic for qemu-devel@nongnu.org; Mon, 15 Apr 2013 11:11:00 -0400 Received: from mail-da0-x22b.google.com ([2607:f8b0:400e:c00::22b]:33296) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URl3a-0003yU-Cq for qemu-devel@nongnu.org; Mon, 15 Apr 2013 11:10:58 -0400 Received: by mail-da0-f43.google.com with SMTP id u36so2110280dak.2 for ; Mon, 15 Apr 2013 08:10:56 -0700 (PDT) Date: Tue, 16 Apr 2013 00:10:52 +0900 Message-ID: From: MORITA Kazutaka In-Reply-To: <1365916604-12362-1-git-send-email-namei.unix@gmail.com> References: <1365852442-28941-5-git-send-email-namei.unix@gmail.com> <1365916604-12362-1-git-send-email-namei.unix@gmail.com> MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Subject: Re: [Qemu-devel] [sheepdog] [PATCH for QEMU v3] sheepdog: add discard/trim support for sheepdog List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liu Yuan Cc: Kevin Wolf , Paolo Bonzini , sheepdog@lists.wpkg.org, qemu-devel@nongnu.org, Stefan Hajnoczi At Sun, 14 Apr 2013 13:16:44 +0800, Liu Yuan wrote: > > From: Liu Yuan > > 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