From a6af886fd0b4ff036a3e9fcc4b9cb0b8db41a36c Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sun, 4 Aug 2024 11:51:16 +0200 Subject: [PATCH] xfs: return -ENOENT when trying to scrub non-existing rtgroup Provide a fallback for scrub code trying to scrub RTG 0 when it doesn't actually exist for a file system with the RTGROUPS feature bit, but without any RT extents. Signed-off-by: Christoph Hellwig --- fs/xfs/scrub/scrub.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c index f942141c6539..51f155c5596d 100644 --- a/fs/xfs/scrub/scrub.c +++ b/fs/xfs/scrub/scrub.c @@ -510,10 +510,16 @@ xchk_validate_inputs( case ST_RTGROUP: if (sm->sm_ino || sm->sm_gen) goto out; - if (!xfs_has_rtgroups(mp) && sm->sm_agno != 0) - goto out; - if (xfs_has_rtgroups(mp) && sm->sm_agno >= mp->m_sb.sb_rgcount) - goto out; + if (xfs_has_rtgroups(mp)) { + if (sm->sm_agno >= mp->m_sb.sb_rgcount) { + if (sm->sm_agno == 0) + error = -ENOENT; + goto out; + } + } else { + if (sm->sm_agno != 0) + goto out; + } break; default: goto out; -- 2.50.1