Re: [PATCH v5 06/24] fsverity: pass tree_blocksize to end_enable_verity()

Eric Biggers
2024-03-05T00:52:44Z

On Mon, Mar 04, 2024 at 08:10:29PM +0100, Andrey Albershteyn wrote:
> XFS will need to know tree_blocksize to remove the tree in case of an
> error. The size is needed to calculate offsets of particular Merkle
> tree blocks.
>
> Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
> ---
> fs/btrfs/verity.c | 4 +++-
> fs/ext4/verity.c | 3 ++-
> fs/f2fs/verity.c | 3 ++-
> fs/verity/enable.c | 6 ++++--
> include/linux/fsverity.h | 4 +++-
> 5 files changed, 14 insertions(+), 6 deletions(-)

How will XFS handle dropping a file's incomplete tree if the system crashes
while it's being built?

I think this is why none of the other filesystems have needed the tree_blocksize
in ->end_enable_verity() yet. They need to be able to drop the tree from just
the information the filesystem has on-disk anyway. ext4 and f2fs just truncate
past EOF, while btrfs has some code that finds all the verity metadata items and
deletes them (see btrfs_drop_verity_items() in fs/btrfs/verity.c).

Technically you don't *have* to drop incomplete trees, since it shouldn't cause
a behavior difference. But it seems like something that should be cleaned up.

- Eric