Direct IO for holes and fallocate
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
@@ -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
Theodore Tso
maintainerHere'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
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_iocallback that gets used for direct I/O.Singed-Off-By Mingming Cao <[email protected]>Signed-off-by "Theodore Ts'o" <[email protected]>------------------
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()andext4_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