Question: correctly detecting erased blocks in ext2/ext3

From: Alon Ziv
Date: Fri Apr 23 2004 - 16:45:16 EST


Hi,

I'm trying to correct the integration of ext2/ext3 and the various flash-based
block devices (e.g. INFTL); these currently assume that any block that's
written containing all-zeros can just be deleted from the block maps, and a
read of a non-existent block just returns all zeros. This scheme is a bit
hackish, as well as highly sub-optimal since "real" file systems just erase
the blocks' bits in the blocks bitmap and don't bother to overwrite the old
contents.

So, I'd like to have a go at solving the real problem: detect when blocks are
_really_ erased, and transmit this information to the block device.

My first intuition was to add a new address_space_operations method, and call
it from (a helper of) truncate_inode_pages. However, this works only for in-
core pages, and completely fails to handle pages that are just on disk and
metadata pages. So I have to strike this one off.

So my current idea is to just define a new kind of request (DELETE), and
provide a function that takes a bh and submits a DELETE operation for its
associated blocks. I'll also probably want a wrapper that does the same
given a super_block structure. The new operation will be ignored by existing
(non-flash) block devices, and will DTRT on flash block devices.

I'll also want to change the file-system code to correctly produce this new
request -- in ext2, I believe it's a simple change to ext2_free_blocks(); in
ext3, I'm far less certain of the correct place, as I should probably wait for
a checkpoint to occur, so the DELETE requests will have to be buffered for
jbd... Sigh, it gets _so_ complicated :-(

Not to mention that some file systems (e.g. JFS) are completely pagecache
based, and if more file systems move in this direction, I'll need a completely
new method for sending this request (and I haven't got a clue of where to put
it).

So, my question(s) to the gurus: does my idea sound right, or am I thoroughly
out? And -- anyone got some smart idea on how to integrate this beast with
ext3?

Thanks in advance,
-Alon Ziv
-
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/