Re: [PATCH 1/2] ext4: introduce EXT4_BG_TRIMMED to optimize fstrim

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux