From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754082AbdC1BoL (ORCPT ); Mon, 27 Mar 2017 21:44:11 -0400 Received: from mga04.intel.com ([192.55.52.120]:24294 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752500AbdC1BoI (ORCPT ); Mon, 27 Mar 2017 21:44:08 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,234,1486454400"; d="scan'208";a="81673001" From: "Liu, Changpeng" To: Christoph Hellwig CC: "virtio-dev@lists.oasis-open.org" , "virtualization@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "qemu-devel@nongnu.org" Subject: RE: [PATCH] virtio-blk: add DISCARD support to virtio-blk driver Thread-Topic: [PATCH] virtio-blk: add DISCARD support to virtio-blk driver Thread-Index: AQHSpwpcUC495QxZxUSYvBC1Zqhc6KGpedDQ Date: Tue, 28 Mar 2017 01:43:53 +0000 Message-ID: References: <1490690365-21109-1-git-send-email-changpeng.liu@intel.com> <20170327145625.GA24952@lst.de> In-Reply-To: <20170327145625.GA24952@lst.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOWIxNTUwMjAtYjc1YS00N2Y5LWE2YTAtOTQyNjNmZTEzMzI4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6Ilp5OTB2WWkrdTJyeFF4WXFKNTlWd0FQVVozQW16SXQxajdWdGNrTjFlZWM9In0= x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v2S1iHZ5022430 > -----Original Message----- > From: Christoph Hellwig [mailto:hch@lst.de] > Sent: Monday, March 27, 2017 10:56 PM > To: Liu, Changpeng > Cc: virtio-dev@lists.oasis-open.org; virtualization@lists.linux-foundation.org; linux- > kernel@vger.kernel.org; hch@lst.de; qemu-devel@nongnu.org > Subject: Re: [PATCH] virtio-blk: add DISCARD support to virtio-blk driver > > On Tue, Mar 28, 2017 at 04:39:25PM +0800, Changpeng Liu wrote: > > Currently virtio-blk driver does not provide discard feature flag, so the > > filesystems which built on top of the block device will not send discard > > command. This is okay for HDD backend, but it will impact the performance > > for SSD backend. > > > > Add a feature flag VIRTIO_BLK_F_DISCARD and command > VIRTIO_BLK_T_DISCARD > > to extend exist virtio-blk protocol. virtio-blk protocol uses a single > > 8 bytes descriptor containing type,reserved and sector, currently Linux > > uses the reserved field as IO priority, here we also re-use the reserved > > field as number of discard sectors. > > Do you have a link to the specification for this feature? At least > virtio-v1.0 does not seem to specify a discard feature. Not yet, patch goes first, there are uses who don't want to migrate from virtio-blk to virtio-scsi, so this feature seems reasonable, the question is that how we should define the specification to support this feature. > > Note that Linux 4.11 and later have support for multi-range discard > ala ATA TRIM, SCSI UNMAP and NVMe deallocate which might be useful > here, too. For support multi-range discard features, the DISCARD command must have data_in buffer, similar with SCSI UNMAP and NVMe DEALLOCATE commands, maybe 16 bytes aligned descriptors are required for each DISCARD command. > > > + q->limits.discard_zeroes_data = 0; > > No need to clear this. Also hopefully this field goes away for 4.12 > > > + blk_queue_max_discard_segments(q, 1); > > No need to set this.