From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Woodhouse Subject: Re: [PATCH 1/5] [BLOCK] Add 'discard' request handling Date: Fri, 08 Aug 2008 11:52:11 +0100 Message-ID: <1218192731.12232.110.camel@pmac.infradead.org> References: <488B7281.4020007@gmail.com> <20080726130200.f541e604.akpm@linux-foundation.org> <1217900716.3454.667.camel@pmac.infradead.org> <20080805114210.GW20055@kernel.dk> <1217953741.3454.784.camel@pmac.infradead.org> <1217957140.3454.800.camel@pmac.infradead.org> <1218014703.5111.35.camel@pmac.infradead.org> <20080807184155.GE20055@kernel.dk> <1218187995.12232.95.camel@pmac.infradead.org> <20080808103041.GM20055@kernel.dk> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: Andrew Morton , Ric Wheeler , linux-fsdevel@vger.kernel.org, gilad@codefidence.com To: Jens Axboe Return-path: Received: from bombadil.infradead.org ([18.85.46.34]:38503 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754059AbYHHKwZ (ORCPT ); Fri, 8 Aug 2008 06:52:25 -0400 In-Reply-To: <20080808103041.GM20055@kernel.dk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, 2008-08-08 at 12:30 +0200, Jens Axboe wrote: > Not at all, please re-read that part. I objected to adding a strategy > hook just for setting cmd type and flags for discard. Ah, now I understand what you were saying. And I vacillated about that too -- I actually suggested to Gilad that we didn't want it, but then went ahead and did it anyway. Adding the ->discard_fn hook provides two features: Firstly, it allows an early 'abort' of discard requests where the device doesn't support them -- there's no point in allocating the request and passing it down to the device to be discarded there, when we can just notice that there's no ->discard_fn and return immediately from blkdev_issue_discard(). Secondly, it allows drivers to insert the appropriate command onto their queue -- I expect that SCSI and ATA drives won't use REQ_TYPE_DISCARD, just as they don't use REQ_TYPE_FLUSH. They'll use REQ_TYPE_BLOCK_PC with whatever opcode is allocated for trim/punch. We _could_ address those two differently -- maybe we could add a QUEUE_FLAG_DISCARDS in q->queue_flags to indicate that discard requests are supported, and we could make the driver 'translate' from REQ_TYPE_DISCARD to whatever it actually wants to do. But that seems strangely different to how we handle flushes, which is what I was basing my implementation on. -- David Woodhouse Open Source Technology Centre David.Woodhouse@intel.com Intel Corporation