Skip to contentSkip to conversation

xfs: pass proper leaf argument from xfs_rtrefcountbt_broot_realloc()

PATCH Applied Eric Sandeen 4 participants 4 messages Nov 24 – Nov 26 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: pass proper leaf argument from xfs_rtrefcountbt_broot_realloc()

xfs_rtrefcountbt_maxrecs() takes a third boolean "leaf" argument, but the caller in xfs_rtrefcountbt_broot_realloc() passes level directly, rather than "level == 0" as is done correctly in xfs_rtrefcountbt_get_minrecs and xfs_rtrefcountbt_get_maxrecs.

Fix that.

Fixes f0415af60f48 ("xfs: wire up a new metafile type for the realtime refcount")
---
 fs/xfs/libxfs/xfs_rtrefcount_btree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/xfs/libxfs/xfs_rtrefcount_btree.c +2 -1
index 697f5e622685..18bc30897189 100644
@@ -237,7 +237,8 @@ xfs_rtrefcountbt_broot_realloc(
 		 * realloc it and possibly move the node block pointers because
 		 * those are not butted up against the btree block header.
 		 */
-		old_numrecs = xfs_rtrefcountbt_maxrecs(mp, old_size, level);
+		old_numrecs = xfs_rtrefcountbt_maxrecs(mp, old_size,
+					level == 0);
 		broot = xfs_broot_realloc(ifp, new_size);
 		if (level > 0)
 			xfs_rtrefcountbt_move_ptrs(mp, broot, old_size,
Signature · 1 line
2.56.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Eric Sandeen

xfs_rtrefcountbt_maxrecs() takes a third boolean "leaf" argument, but the caller in xfs_rtrefcountbt_broot_realloc() passes level directly, rather than "level == 0" as is done correctly in xfs_rtrefcountbt_get_minrecs and xfs_rtrefcountbt_get_maxrecs.

So we basically get the wrong maxrecs here. I assume you found this by code inspection and not by testing?

#2 lore raw
Quoted 10 lines · Christoph Hellwig
Quoted 4 lines · Eric Sandeen

xfs_rtrefcountbt_maxrecs() takes a third boolean "leaf" argument, but the caller in xfs_rtrefcountbt_broot_realloc() passes level directly, rather than "level == 0" as is done correctly in xfs_rtrefcountbt_get_minrecs and xfs_rtrefcountbt_get_maxrecs.

So we basically get the wrong maxrecs here. I assume you found this by code inspection and not by testing?

Yes. (with the help of an LLM doing other review)

There are actually other cases where we got a factor of two wrong in this code when it was copied in, and some of it affects disk format. I need to grok that a bit better and can send a patch, but the patch will probably just be "document it in a comment" because trying to change the disk format now is probably not worth it.

(tl;dr, the problem splits root nodes too soon due to the error, IIRC.)

-Eric

maintainer Applied
#3 lore raw
In reply to Eric Sandeen
Quoted 8 lines · Eric Sandeen

xfs_rtrefcountbt_maxrecs() takes a third boolean "leaf" argument, but the caller in xfs_rtrefcountbt_broot_realloc() passes level directly, rather than "level == 0" as is done correctly in xfs_rtrefcountbt_get_minrecs and xfs_rtrefcountbt_get_maxrecs.

Fix that.

[...]

Applied to for-next, thanks!

[1/1] xfs: pass proper leaf argument from xfs_rtrefcountbt_broot_realloc()

      commit: ba7d05f4078051e9b68a08c213eefae0edbc8a0a

Best regards,

Signature · 1 line
Carlos Maiolino <[email protected]>