[PATCH 0/3] ocfs2: fix metadata reservation for xattr value trees

From: Joseph Qi

Date: Sat Oct 10 2026 - 07:35:34 EST


ocfs2_calc_xattr_set_need() reserves too little metadata for a new xattr
value's extent tree on three paths. The reservation cannot be topped up
once the transaction has started, so ocfs2_add_clusters_in_btree() gives
up with RESTART_META when the value root fills and nothing is left.
ocfs2_xattr_extend_allocation() turns that into -ENOSPC, after
ocfs2_xa_cleanup_value_truncate() has dropped the entry and leaked the
clusters already handed out; before commit 0cdc7dde00ec ("ocfs2: fix
missing metadata reservation for large xattrs") it was a BUG_ON()
instead. It takes a fragmented cluster allocator to get there, since
the first extent always fits in the root.

Patch 1 fixes the create side of meta_guess: commit 3ed2be719eb9 ("ocfs2:
allow for more than one data extent when creating xattr") replaced the
block reserved for the new xattr block with the two the value tree needs
instead of adding them together.

Patch 2 fixes the arm that moves an xattr back into the inode, which
charges credits for a value tree but no metadata for one.

Patch 3 drops a second copy of the same reservation on the path that
falls through to meta_guess. That one is cleanup rather than a fix and
is not for stable, and it must not be backported without patch 1: the
duplicate it removes is what currently covers the shortfall patch 1
fixes.

Based on linux-next-20261008.

Joseph Qi (3):
ocfs2: reserve metadata for a new xattr block and its value tree
ocfs2: reserve value tree metadata when moving an xattr into the inode
ocfs2: reserve xattr value tree metadata only once

fs/ocfs2/xattr.c | 33 ++++++++++++++++++++++++++++++---
1 file changed, 30 insertions(+), 3 deletions(-)

--
2.39.3