From: "Theodore Ts'o" <tytso@mit.edu>
To: Li Dongyang <dongyangli@ddn.com>
Cc: linux-ext4@vger.kernel.org, adilger@dilger.ca, sihara@ddn.com,
wangshilong1991@gmail.com
Subject: Re: [PATCH 1/2] ext4: introduce EXT4_BG_TRIMMED to optimize fstrim
Date: Fri, 11 Aug 2023 14:35:58 -0400 [thread overview]
Message-ID: <20230811183558.GA1528742@mit.edu> (raw)
In-Reply-To: <20230811061905.301124-1-dongyangli@ddn.com>
On Fri, Aug 11, 2023 at 04:19:04PM +1000, Li Dongyang wrote:
> Currently the flag indicating block group has done fstrim is not
> persistent, and trim status will be lost after remount, as
> a result fstrim can not skip the already trimmed groups, which
> could be slow on very large devices.
>
> This patch introduces a new block group flag EXT4_BG_TRIMMED,
> we need 1 extra block group descriptor write after trimming each
> block group.
> When clearing the flag, the block group descriptor is journalled
> already so no extra overhead.
If we journalling is enabled (and it normally is enabled) then there
is also writes to the journalling. Updating the block group
descriptor is also a random 4k write, which is not nothing. So if we
are going to do this, then we should not try to set the flag if the
block group is unitialized, and we should actually send the discard in
that case, since presumably the blocks in question were discard when
the file system was mkfs'ed.
> Add a new super block flag EXT2_FLAGS_TRACK_TRIM, to indicate if
> we should honour EXT4_BG_TRIMMED when doing fstrim.
> The new super block flag can be turned on/off via tune2fs.
I don't see the point of having the superblock flag. It seems to me
that either we should either do this via a proper feature flag, which
means that older kernels (and grub bootloaders that get release
updates at a super-lackadasical pace) won't touch file systems that
have the feature flag set --- or we don't have any kind of flag at
all, and kernels and userspace utilities which are EXT4_BG_TRIMMED
enlightened will honor and set/clear the flag.
This risk if we go down that path is that if we have a file system
which is normally used by a kernel that has support for this feature,
and that file system is mounted by an older kernel which doesn't have
this flag, there might be cases where the file system would be trimmed
without setting these flags, or blocks might get released on a block
group without clearing the flag. Fortunately, trim is advisory, so if
we trim a block group that doesn't need it, or we don't trim a block
group where discard might be useful, it's not the end of the world.
And we could always have "e2fsck -E discard" ignore the
EXT4_BG_TRIMMED flag, and just trim all the blocks[1].
[1] https://photos.app.goo.gl/eVL9yHpjdXhjAnq88
- Ted
next prev parent reply other threads:[~2023-08-11 18:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-11 6:19 [PATCH 1/2] ext4: introduce EXT4_BG_TRIMMED to optimize fstrim Li Dongyang
2023-08-11 6:19 ` [PATCH 2/2] e2fsprogs: support EXT2_FLAG_BG_TRIMMED and EXT2_FLAGS_TRACK_TRIM Li Dongyang
2023-08-15 5:08 ` Andreas Dilger
2023-08-11 18:35 ` Theodore Ts'o [this message]
2023-08-15 4:32 ` [PATCH 1/2] ext4: introduce EXT4_BG_TRIMMED to optimize fstrim Andreas Dilger
2023-08-15 5:04 ` Andreas Dilger
2023-08-16 3:47 ` Dongyang Li
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=20230811183558.GA1528742@mit.edu \
--to=tytso@mit.edu \
--cc=adilger@dilger.ca \
--cc=dongyangli@ddn.com \
--cc=linux-ext4@vger.kernel.org \
--cc=sihara@ddn.com \
--cc=wangshilong1991@gmail.com \
/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