Re: [PATCH 1/2] fs: Do not dispatch FITRIM through separate super_operation

Christoph Hellwig
2010-11-19T15:34:41Z

On Fri, Nov 19, 2010 at 10:24:52AM -0500, Mark Lord wrote:
> I wonder if this can be treated more like how SG_IO does things?
> The SG_IO mechanism seems to have no issues passing through stuff
> like this, so perhaps we could implement something in a similar fashion?

We actually sent discards down as BLOCK_PC commands, which basically
is SG_IO style I/O from kernelspace. But that caused a lot of problems
with scsi error handling so we moved away from it. But even when
you do a BLOCK_PC UNMAP command that later gets translated to a TRIM
by libata you have a few issues:

- you need to get partion offsets in the I/O sumitter to include them
in every range. That's doable but a quite nasty layering violation,
and it also prevents us from ever adding DM/MD support to that
scheme.
- you'll have to allocate new memory for the TRIM payload in libata,
and switch the libata command to use it, instead of the current
hack to reuse the zeroed page sent down with the WRITE SAME command.
I tried to get the payload switching in libata to work a few times,
but never managed to get it right.