Skip to contentSkip to conversation

Direct IO for holes and fallocate

RFC PATCH Superseded Mingming 2 participants 3 messages Aug 10, 2009 – Aug 18, 2009 ext4 file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Mingming

author
#0 lore raw

RFC PATCH 2/2 Direct IO for holes and fallocate

handling unwritten extents lookup/map/convert for direct IO request.

For already fallocated extent, at the time DIO get_block() is called, ext4 will split the fallocated extent as necessary, mark the to-write fallocated extent mapped but still remains unwritten. Need to insert the splitted extents, to prevent ENOSPC later.

At the time all IO has completed, end_io call back function will mark the unwritten extent as written.

Patch against ext4 patch queue.

Comments?

---
 fs/ext4/ext4_extents.h |    5 
 fs/ext4/extents.c      |  401 +++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 377 insertions(+), 29 deletions(-)
fs/ext4/ext4_extents.h +5 -0
Index: linux-2.6.31-rc4/fs/ext4/ext4_extents.h
===================================================================
@@ -220,6 +220,11 @@ static inline int ext4_ext_get_actual_le
 		(le16_to_cpu(ext->ee_len) - EXT_INIT_MAX_LEN));
 }
 
+static inline void ext4_ext_mark_initialized(struct ext4_extent *ext)
+{
+	ext->ee_len = ext4_ext_get_actual_len(ext);
+}
+
 extern int ext4_ext_calc_metadata_amount(struct inode *inode, int blocks);
 extern ext4_fsblk_t ext_pblock(struct ext4_extent *ex);
 extern ext4_fsblk_t idx_pblock(struct ext4_extent_idx *);
fs/ext4/extents.c +372 -29

431 lines not on this page · raw message

maintainer
#1 lore raw

Here's my suggest rewrite of the patch description:

ext4: Direct IO for holes and fallocate: unwritten extents spt for DIO

From: Mingming <[email protected]>

When writing into an unitialized extent via direct I/O, and the direct I/O doesn't exactly cover the unitialized extent, split the extent into uninitialized and initialized extents before submitting the I/O. The reason for doing this is to avoid needing to deal with an ENOSPC error in the end_io callback that gets used for direct I/O.

------------------

As mentioned in my comments for the previous patch, ext4_convert_unwritten_extents() needs to be defined in the previous patch. This may requiring dragging in substantial portions of this patch.

The other observation is there seems to be quite a bit of overlap between ext4_split_unwritten_extents() and ext4_ext_convert_to_initialized(). Is there some way we can do some code factorization?

- Ted

author
#2 lore raw
Quoted 9 lines · Theodore Tso

Here's my suggest rewrite of the patch description:

ext4: Direct IO for holes and fallocate: unwritten extents spt for DIO

From: Mingming <[email protected]>

When writing into an unitialized extent via direct I/O, and the direct I/O doesn't exactly cover the unitialized extent, split the extent into uninitialized and initialized extents before submitting the I/O.

                         ~~~~~~~~~~~~

would it better to replace this as to-be-initialized extents? Before submmit the I/O, the extents are splitted but all remains uninitialized. The written part is converted to initialized at the time I/O is complete.

Quoted 14 lines

The reason for doing this is to avoid needing to deal with an ENOSPC error in the end_io callback that gets used for direct I/O.

------------------

As mentioned in my comments for the previous patch, ext4_convert_unwritten_extents() needs to be defined in the previous patch. This may requiring dragging in substantial portions of this patch.

Quoted 5 lines

The other observation is there seems to be quite a bit of overlap between ext4_split_unwritten_extents() and ext4_ext_convert_to_initialized(). Is there some way we can do some code factorization?

I thought about factor the code before... that would require passing a flag and avoid the convertion(as for DIO case we only do split) and zero out( DIO does less agreesive zero out than buffered IO). It makes code actually hard to read. I will give it a try to see if we could reuse the code while still make the code easy to understand.

Thanks,
Mingming

Quoted 5 lines

- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html