From nobody Sun Dec 14 11:17:15 2025 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6232E30F540 for ; Fri, 12 Dec 2025 07:45:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765525523; cv=none; b=HECZ/9Fn1raHM4DjFPG5Vj1F+U4S5aAhsoM59AYJ9o5rRqznAbMyIBXrFDaN0Da7HO+2XplwEG1pIiNg6Pk/snEo5YTMLc3WidzQbn+GPXNt4daPKP+tUx0yZ/h57IRQDk1hrQ6qcUFNjmFp1CO6xl+n2WT4Fz9dG5egxqwRDQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765525523; c=relaxed/simple; bh=k0Da8MpybI0CYQLClcHeD9cgrvdH2g3rxNuqSdol5Zo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lLvi3jShU01wzvgiC8Ca95zpzGn3ZqqVxSYbnA4kJ5V8mLOElg02arXjiIsgdYNYH4EKjkNgARbv41qYTgfFxqrzpN2rtCQx+q0VEcRh74kZi60ybDMXSAI3ilKu0oz+1t88PgmhKMie76L5YXTnnJEX0TUmq2WyNKQd7hSIbgM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=KEDbxiJJ; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="KEDbxiJJ" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-47928022b93so1959615e9.0 for ; Thu, 11 Dec 2025 23:45:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1765525519; x=1766130319; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MjqsA3Rk0Xp0l1r6js0wRRyT/FYUpiPjVmpKyrwUjoc=; b=KEDbxiJJvK9/muEdEcSpD5y8SBRf8vGC5aY50PWytROhBo5RxcXwwAtAD9VsM9wLs3 hH5bcvh8keBEUe1jwRn1pn+ykhM9lMy7YPa3fE7Lcd/jB6eTcQ4U+Kp+nfi5MV8q2aNG FcUuYRF5sPhnI7omNrRvOZgmFpDDwp3r5kiLpa5N+QWrODSbpS8v67TnU2nMxtss+9zH Q6045NenaJI7YN2oN+jzMnbZXmeFGkUfJVwqCt1on381RP/1QmDBpqDbEy2XQZH1fusk 7teJRqYVWL0jLXdODQDO8BOWE81TpopyEyH0/g6Aw/vB4mYFkIxRe7s13h92XGK5SuK4 I42A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765525519; x=1766130319; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=MjqsA3Rk0Xp0l1r6js0wRRyT/FYUpiPjVmpKyrwUjoc=; b=YlpIgJrLzhnILTOKNEAJI8x5O6PP9jHnZQStU7dqWUgnjUzUvADGY/R2Q1e1tLt35T ijCcQyMZkUnwz4r+3neSCCj0dLHHiFr1pct87DXuLiBw4zmVAYFsdi9yh9D3XKXL19uG W6Xpbz6fYQ4poyjAFo2JW/UqDFgWfkoVwuREJlhGeTcNzdOFhDr/LSxwpyuY7wlLvqw3 ZAmNpydOIYbLIoGtE6yvFI5ZhwSok21Ntx/fKiUf30MPk2I0h82z7DAZ/GwA7ye/cCU9 Y570Icd84B3ftoSxspb6TZnmmsyQ89ombAsHMzeQihm5jKu+BFzyVMbUjLoetESd9z6/ Apbw== X-Forwarded-Encrypted: i=1; AJvYcCVB5Kx37swHxELIqThQDvL20EUzAc+yBhea9evw6iVNNVjSQd908irMY6ttQKN4R5qe7PKpjmHLyo+nDrE=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/IO6IMMeLGlgaIsztAieJfc5Dwl1/avygdVTlomCxsKzh2NAR f1hJqfgQ5P3YMCTryqiAwSVQwYrmaCr1UE8CGB+ZNmuN9Qjs51CHI+nrGY0ncfLkzMA= X-Gm-Gg: AY/fxX4cGiBFZXQSrAV+q7haD4UVtczM7xtH08eX7nL4TVJuj3PkviLhHCuJvVT5c59 5oll5WdsnOITXcWkVmotMok0rQwTzbQGA9ASu2oisJuK/gp+fiz4rx0FqqVO3flViZHmhZ1kAPs p4KJE93f/EAuWECp/KK7KImSvxKcNdF/SbRClZMjiStIhP6+6TMozvNppPw+i1YUieWr64svnQU C3Tx/tCqj6afp1dRZqziwIEhE+x+lFhr4Ifz57MD7RhZZ7XLmmluLlaMoPLWhK3eyXiTFSnhzrq IB4tULfeJQ1znb5YKlDv9oJaCSIqgnpOICgCTFRk/E3dgP5jIjMphoyxtu+326YczDfQ/O6Lkjk QpRubgP8+D+4gChFSQppQObpkJh78GuWkAVMRrRo3+sY1ewImSG9awXmdXVCDueeJcNhH+naev4 n2lDKykRuqsG4= X-Google-Smtp-Source: AGHT+IEjuwAfIHrDjNbY3jvvOm9cGk1SelVLWKi9CsNogqTqb7sT5nmS5zEZUcqgR+NfnkAOy6BG1A== X-Received: by 2002:a05:600c:4f84:b0:477:a6f1:499d with SMTP id 5b1f17b1804b1-47a8f9187c7mr6616485e9.3.1765525518589; Thu, 11 Dec 2025 23:45:18 -0800 (PST) Received: from p15.suse.cz ([202.127.77.110]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29ee9d38adcsm45916975ad.30.2025.12.11.23.45.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 23:45:17 -0800 (PST) From: Heming Zhao To: joseph.qi@linux.alibaba.com, mark@fasheh.com, jlbec@evilplan.org Cc: Heming Zhao , ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org, glass.su@suse.com Subject: [PATCH v6 2/2] ocfs2: detect released suballocator BG for fh_to_[dentry|parent] Date: Fri, 12 Dec 2025 15:45:04 +0800 Message-ID: <20251212074505.25962-3-heming.zhao@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251212074505.25962-1-heming.zhao@suse.com> References: <20251212074505.25962-1-heming.zhao@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" After ocfs2 gained the ability to reclaim suballocator free block group (BGs), a suballocator block group may be released. This change causes the xfstest case generic/426 to fail. generic/426 expects return value -ENOENT or -ESTALE, but the current code triggers -EROFS. Call stack before ocfs2 gained the ability to reclaim bg: ocfs2_fh_to_dentry //or ocfs2_fh_to_parent ocfs2_get_dentry + ocfs2_test_inode_bit | ocfs2_test_suballoc_bit | + ocfs2_read_group_descriptor //Since ocfs2 never releases the bg, | | //the bg block was always found. | + *res =3D ocfs2_test_bit //unlink was called, and the bit is zero | + if (!set) //because the above *res is 0 status =3D -ESTALE //the generic/426 expected return value Current call stack that triggers -EROFS: ocfs2_get_dentry ocfs2_test_inode_bit ocfs2_test_suballoc_bit ocfs2_read_group_descriptor + if reading a released bg, validation fails and triggers -EROFS How to fix: Since the read BG is already released, we must avoid triggering -EROFS. With this commit, we use ocfs2_read_hint_group_descriptor() to detect the released BG block. This approach quietly handles this type of error and returns -EINVAL, which triggers the caller's existing conversion path to -ESTALE. Signed-off-by: Heming Zhao Reviewed-by: Su Yue Reviewed-by: Joseph Qi --- fs/ocfs2/export.c | 6 ++++-- fs/ocfs2/suballoc.c | 26 +++++++++++++++++--------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/fs/ocfs2/export.c b/fs/ocfs2/export.c index b95724b767e1..9c2665dd24e2 100644 --- a/fs/ocfs2/export.c +++ b/fs/ocfs2/export.c @@ -74,8 +74,9 @@ static struct dentry *ocfs2_get_dentry(struct super_block= *sb, * nice */ status =3D -ESTALE; - } else + } else if (status !=3D -ESTALE) { mlog(ML_ERROR, "test inode bit failed %d\n", status); + } goto unlock_nfs_sync; } =20 @@ -162,8 +163,9 @@ static struct dentry *ocfs2_get_parent(struct dentry *c= hild) if (status < 0) { if (status =3D=3D -EINVAL) { status =3D -ESTALE; - } else + } else if (status !=3D -ESTALE) { mlog(ML_ERROR, "test inode bit failed %d\n", status); + } parent =3D ERR_PTR(status); goto bail_unlock; } diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index 9a19f5230c8c..9b0ae1bc445b 100644 --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c @@ -3152,7 +3152,7 @@ static int ocfs2_test_suballoc_bit(struct ocfs2_super= *osb, struct ocfs2_group_desc *group; struct buffer_head *group_bh =3D NULL; u64 bg_blkno; - int status; + int status, quiet =3D 0, released; =20 trace_ocfs2_test_suballoc_bit((unsigned long long)blkno, (unsigned int)bit); @@ -3168,9 +3168,13 @@ static int ocfs2_test_suballoc_bit(struct ocfs2_supe= r *osb, =20 bg_blkno =3D group_blkno ? group_blkno : ocfs2_which_suballoc_group(blkno, bit); - status =3D ocfs2_read_group_descriptor(suballoc, alloc_di, bg_blkno, - &group_bh); - if (status < 0) { + status =3D ocfs2_read_hint_group_descriptor(suballoc, alloc_di, bg_blkno, + &group_bh, &released); + if (released) { + quiet =3D 1; + status =3D -ESTALE; + goto bail; + } else if (status < 0) { mlog(ML_ERROR, "read group %llu failed %d\n", (unsigned long long)bg_blkno, status); goto bail; @@ -3182,7 +3186,7 @@ static int ocfs2_test_suballoc_bit(struct ocfs2_super= *osb, bail: brelse(group_bh); =20 - if (status) + if (status && !quiet) mlog_errno(status); return status; } @@ -3202,7 +3206,7 @@ static int ocfs2_test_suballoc_bit(struct ocfs2_super= *osb, */ int ocfs2_test_inode_bit(struct ocfs2_super *osb, u64 blkno, int *res) { - int status; + int status, quiet =3D 0; u64 group_blkno =3D 0; u16 suballoc_bit =3D 0, suballoc_slot =3D 0; struct inode *inode_alloc_inode; @@ -3244,8 +3248,12 @@ int ocfs2_test_inode_bit(struct ocfs2_super *osb, u6= 4 blkno, int *res) =20 status =3D ocfs2_test_suballoc_bit(osb, inode_alloc_inode, alloc_bh, group_blkno, blkno, suballoc_bit, res); - if (status < 0) - mlog(ML_ERROR, "test suballoc bit failed %d\n", status); + if (status < 0) { + if (status =3D=3D -ESTALE) + quiet =3D 1; + else + mlog(ML_ERROR, "test suballoc bit failed %d\n", status); + } =20 ocfs2_inode_unlock(inode_alloc_inode, 0); inode_unlock(inode_alloc_inode); @@ -3253,7 +3261,7 @@ int ocfs2_test_inode_bit(struct ocfs2_super *osb, u64= blkno, int *res) iput(inode_alloc_inode); brelse(alloc_bh); bail: - if (status) + if (status && !quiet) mlog_errno(status); return status; } --=20 2.43.0