mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Julian Sun <sunjunchao2870@gmail.com>
To: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz,
	boyu.mt@taobao.com, tm@tao.ma,
	Julian Sun <sunjunchao2870@gmail.com>
Subject: [PATCH 0/7] ext4: Convert truncated extent data to inline data.
Date: Fri, 20 Dec 2024 23:16:18 +0800	[thread overview]
Message-ID: <20241220151625.19769-1-sunjunchao2870@gmail.com> (raw)

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(-)

-- 
2.39.5


             reply	other threads:[~2024-12-20 15:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-20 15:16 Julian Sun [this message]
2024-12-20 15:16 ` [PATCH 1/7] ext4: Modify ei->i_flags before calling ext4_mark_iloc_dirty() Julian Sun
2025-01-06 15:25   ` Jan Kara
2025-01-07  2:53     ` Julian Sun
2024-12-20 15:16 ` [PATCH 2/7] ext4: Remove a redundant return statement Julian Sun
2025-01-06 15:23   ` Jan Kara
2024-12-20 15:16 ` [PATCH 3/7] ext4: Don't set EXT4_STATE_MAY_INLINE_DATA for ea inodes Julian Sun
2025-01-06 15:23   ` Jan Kara
2024-12-20 15:16 ` [PATCH 4/7] ext4: Introduce a new helper function ext4_generic_write_inline_data() Julian Sun
2025-01-06 15:35   ` Jan Kara
2025-01-07  2:57     ` Julian Sun
2024-12-20 15:16 ` [PATCH 5/7] ext4: Refactor out ext4_da_write_inline_data_begin() Julian Sun
2025-01-06 15:39   ` Jan Kara
2025-01-07  2:58     ` Julian Sun
2024-12-20 15:16 ` [PATCH 6/7] ext4: Refactor out ext4_try_to_write_inline_data() Julian Sun
2025-01-06 15:40   ` Jan Kara
2024-12-20 15:16 ` [PATCH 7/7] ext4: Store truncated large files as inline data Julian Sun
2025-01-06 15:51 ` [PATCH 0/7] ext4: Convert truncated extent data to " Jan Kara
2025-01-07  6:03   ` Julian Sun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241220151625.19769-1-sunjunchao2870@gmail.com \
    --to=sunjunchao2870@gmail.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=boyu.mt@taobao.com \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tm@tao.ma \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®