Skip to content

ext4: Convert truncated extent data to inline data.

Julian Sun linux-ext4 lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7ext4: Modify ei->i_flags before calling ext4_mark_iloc_dirty()fs/ext4/inline.c+1 -22 replies
2/7ext4: Remove a redundant return statementfs/ext4/extents_status.c+0 -11 reply
3/7ext4: Don't set EXT4_STATE_MAY_INLINE_DATA for ea inodesfs/ext4/ialloc.c+1 -11 reply
4/7ext4: Introduce a new helper function ext4_generic_write_inline_data()fs/ext4/inline.c+85 -02 replies
5/7ext4: Refactor out ext4_da_write_inline_data_begin()fs/ext4/inline.c+2 -722 replies
6/7ext4: Refactor out ext4_try_to_write_inline_data()fs/ext4/inline.c+3 -741 reply
7/7ext4: Store truncated large files as inline data.fs/ext4/inline.c fs/ext4/inode.c+28 -10 replies

Reviews trailers per patch

4 of 7 patches have a Reviewed-by or Acked-by.

PatchJan Kara
1/7
2/7R-b
3/7R-b
4/7R-b
5/7
6/7R-b
7/7

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/7] ext4: Convert truncated extent data to inline data.

Ext4 provides the feature of storing data inline and automatically converts it to extent data when appropriate. However, files stored as extents cannot be converted back to inline data after truncation, even if the file size allows for inline data storage.
This patch set implements the feature to store large truncated files as inline data when suitable, improving disk utilization. Patches 1-3 include some cleanups and fixes.
Patches 4-6 refactor the functions responsible for writing inline data, consolidating their logic for better code organization. Patch 7 implements the feature of storing truncated files as inline data on the next write operation.

Below is a comparison of results before and after applying the patch set.

Before:

root@q:linux# dd if=/dev/urandom bs=1M count=10 of=/mnt/ext4/test
10+0 records in
10+0 records out
10485760 bytes (10 MB, 10 MiB) copied, 0.0770325 s, 136 MB/s
root@q:linux# filefrag -v /mnt/ext4/test
Filesystem type is: ef53
File size of /mnt/ext4/test is 10485760 (2560 blocks of 4096 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..    2559:          0..         0:      0:             last,unknown_loc,delalloc,eof
/mnt/ext4/test: 1 extent found
root@q:linux# echo a > /mnt/ext4/test
root@q:linux# filefrag -v /mnt/ext4/test
Filesystem type is: ef53
File size of /mnt/ext4/test is 2 (1 block of 4096 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..       0:      34304..     34304:      1:             last,eof
/mnt/ext4/test: 1 extent found

After:

root@q:linux# dd if=/dev/urandom bs=1M count=10 of=/mnt/ext4/test
10+0 records in
10+0 records out
10485760 bytes (10 MB, 10 MiB) copied, 0.0883107 s, 119 MB/s
root@q:linux# filefrag -v /mnt/ext4/test
Filesystem type is: ef53
File size of /mnt/ext4/test is 10485760 (2560 blocks of 4096 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..    2559:      38912..     41471:   2560:             last,unknown_loc,delalloc,eof
/mnt/ext4/test: 1 extent found
root@q:linux# echo a > /mnt/ext4/test
root@q:linux# filefrag -v /mnt/ext4/test
Filesystem type is: ef53
Filesystem cylinder groups approximately 78
File size of /mnt/ext4/test is 2 (1 block of 4096 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..       1:    4340520..   4340521:      2:             last,not_aligned,inline,eof
/mnt/ext4/test: 1 extent found

Using filefrag, we can see that after applying this patch, large truncated files also utilize the inline data feature. This patch set has been tested with xfstests' check -g and has not introduced any additional failures.

Julian Sun (7):
ext4: Modify ei->i_flags before calling ext4_mark_iloc_dirty()
ext4: Remove a redundant return statement
ext4: Don't set EXT4_STATE_MAY_INLINE_DATA for ea inodes
ext4: Introduce a new helper function ext4_generic_write_inline_data()
ext4: Refactor out ext4_da_write_inline_data_begin()
ext4: Refactor out ext4_try_to_write_inline_data()
ext4: Store truncated large files as inline data.

 fs/ext4/extents_status.c |   1 -
 fs/ext4/ialloc.c         |   2 +-
 fs/ext4/inline.c         | 205 ++++++++++++++++-----------------------
 fs/ext4/inode.c          |   5 +
 4 files changed, 91 insertions(+), 122 deletions(-)
Signature · 1 line
2.39.5