From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Woodhouse Subject: Re: What's the "prepare_discard_fn" supposed to do? Date: Thu, 02 Oct 2008 14:52:04 +0100 Message-ID: <1222955524.3518.400.camel@macbook.infradead.org> References: Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org To: Chris Worley Return-path: Received: from bombadil.infradead.org ([18.85.46.34]:51770 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753559AbYJBNwH (ORCPT ); Thu, 2 Oct 2008 09:52:07 -0400 In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, 2008-10-02 at 07:45 -0600, Chris Worley wrote: > In perusing the "discard-2.6" kernel at infradead.org (great job... I > have a device I'm testing it on, and it's working), I'm unclear on > what I'm supposed to do in the prepare_discard_fn function. > > It looks like, if it exists, the the discard bio gets passed to the > normal handler. Otherwise, it seems to have no duties. I'm guessing > it's for whatever initialization is needed for the device... but > checking to be sure. It's intended to prepare the command which will be sent to the device, much like the prepare_flush_fn does. See sd_prepare_flush() in drivers/scsi/sd.c for an example (all the devices we've hooked up for discard in Linux so far are virtual ones, so they don't make good examples). I do have a real ATA drive with TRIM protocol support on its way to me though, so I'll be looking at that some time soon. -- David Woodhouse Open Source Technology Centre David.Woodhouse@intel.com Intel Corporation