Re: [PATCH 3/3] tcm/fileio: Add UNMAP / Block DISCARD support

From: Boaz Harrosh
Date: Wed Sep 29 2010 - 04:58:08 EST


On 09/29/2010 10:08 AM, Nicholas A. Bellinger wrote:
> On Tue, 2010-09-28 at 08:46 +0200, Boaz Harrosh wrote:
>>> + printk(KERN_WARNING "Ignoring UNMAP for non BD"
>>> + " backend for struct file\n");
>>
>> TODO: Lots of extent based filesystems could enjoy if you punch an hole
>> in the file. (Which will also send a proper discard).
>> So how to punch an hole in a file via vfs?
>
> Good question, as all of the current block discard support assumes a
> struct block_device * pointer currently.
>
> I know that hch has mentioned that accesing a struct block_device from
> struct file is very dangerous, but I am assuming for the TCM/FILEIO case
> that this code will be protected by igrab() and iput().
>
> hch and jaxboe, any comments here..?
>

No you did not understand. FILEIO (working on a filesystem's real file),
should *never* attempt a discard on the blocks even if it was
to read the file's map and figure out these blocks. It should always
call a filesystem specific API that puntches-an-hole in the file.
Fore stupid filesystem that means fill with zero's. For a smart
extent-based file system it means splitting up the extents the range
belongs to and freeing up the block that where allocated for that
range. But it is an heavy meta-data operation that only the filesystem
can do. With really smart FS like xfs the unallocated blocks also
get discarded, for when working with SANs with over provisioning.

> Thanks!
>
> --nab

Boaz
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/