Re: [PATCH V2 1/1] loop: introduce LO_FLAGS_NO_DEALLOC
From: Zhang Boyang
Date: Wed Aug 10 2022 - 07:00:22 EST
Hi,
On 2022/8/10 06:19, Darrick J. Wong wrote:
Considering that discard isn't required to do anything, why not
echo 0 | sudo tee /sys/block/loopX/queue/discard_max_bytes ?
Thanks for reviewing! This will disable discard completely (>=5.19),
thus the filesystem of backing file has no knowledge about what can be
freed. In contrast, my patch convert REQ_OP_DISCARD to
FALLOC_FL_ZERO_RANGE, the discarded parts of backing file is flagged
zeroed. So there is possibility for the filesystem of backing file to
discard (trim) the zeroed range, improving the write performance on, for
example, SSDs.
However, it seems only XFS with realtime discard enabled can do trim on
FALLOC_FL_ZERO_RANGE. All other filesystems (and XFS without realtime
discard) can't do trim on extents flagged zeroed. Batch discard like
FITRIM (used by `fstirm' tool) also can't help here, because no
filesystem track `allocated but flagged zeroed' extents at filesystem
level. I will probably write another patch to add the ability to trim
zeroed extents in single file to FITRIM. (Currently, FITRIM work on
filesystem level, not file level)
Best Regards,
Zhang Boyang