From nobody Tue Dec 2 02:04:31 2025 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 1ECC6283683 for ; Fri, 21 Nov 2025 07:40:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763710849; cv=none; b=C4fQjPFFHDkNXU/lewV+q6z/7x5mG734lf2bFKC2EgOOcZC0LrE39b/3tD/Xq0OH5UNKsuO6QPH7MITBuojALoqwy9cygSofTM+M1xs4TFR5UaenVk1dAw90znKaneTvi/uaiLeQHIw5VG4UHLdwJByXurQ2OKZWYzYHBJtV/DY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763710849; c=relaxed/simple; bh=u3tF8zKd7NcYJDtduBDGjGpk5WLn+y3aUQFW19+tjRo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TPO6bo+PEVcItoPYpXRKoMXJUjgTyX5vFseON4wB22Nw63eX0JM/xPFsGoSQdnR4JY0wN9THm7Kb3i9MG4gl1iqTWdL2oxoRfMbZPIALLqhwng5m+nSwVGf5BrnPz849Wxo29qNDxVJbkDGhN81S6rmcxIzD1aoEZMZ5Kg1OIAg= 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=VRIfdh4C; arc=none smtp.client-ip=209.85.128.51 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="VRIfdh4C" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4779c9109ceso1008745e9.1 for ; Thu, 20 Nov 2025 23:40:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1763710845; x=1764315645; 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=W9MWQEkUmssQH7h8+ZJJJrAiWh1kVuLIvHyNZDUo2Ps=; b=VRIfdh4CenBxkaCubmOCsHKjpISA4E6bFZnX9DLf/Nn4l0EbiBcdFd3LOFQ1MoDy+z RtFd94gokTXlfN4gOgLdLWjhAweTo/gGhtFbv1SlryAja1dRwFlI7fgjCKhhlEfGxgCA mao/+Mg7N+O3wNjnxWCuZI9C+HVnAn1Sfc6GiCzBzByjVV46SQy5Jqvl26SVZ5Nt80Q1 1g3YuNUWHGYBt/+FR6HCRbR1uVnqlL1QC/lnnHspl3D2kw5KNsV9sKK8+fmRxpzxMoNZ VtaTa6hO7RvuDvXctOraL2zow5B6nglUaawy72VkZx4QFMTHyn19t/aRUtQPkFAPwdxw SRwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763710845; x=1764315645; 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=W9MWQEkUmssQH7h8+ZJJJrAiWh1kVuLIvHyNZDUo2Ps=; b=USuS5kLu2KvMwAxHC7YPwkBGKZoYNw9TCMOjyCFsxHCHKnxHF93n6KW6c6Z3uzloN2 Du089usF4FH81PpesW0x2pkZP5f+2rsuieBQfLbIRm2OoO/PMpPzIys+11fZmnfBFm0O uL3WsCbOwQ1+Z6dnfpo3+LU9hJq72o5BOlp6do7ONIK2huAd/9VSbzIvUNx2hqlJVGlB t2CfcmDTTNlJJajmJn3P3ODdDuQmMJGzkI/Ug/RcnoTtIzJaeIuuDN5ytcKWXvRpR400 IqTyrui12u1lCXZweIopWzfvMD99py4JaSctVt/Up7h7km4ul/5WLhpt9ZUlhLi/m0mN +dHw== X-Forwarded-Encrypted: i=1; AJvYcCUoMKhhEwg+UmzkMN0/3QCpfyO0kxlM8k06lMyBBqiuOp7faPjt20yaNJyhNueFkofZmIPVxJtUgRM4hek=@vger.kernel.org X-Gm-Message-State: AOJu0YwFDnLB0XCibHxkHFh/EprZ5F/sBvaF/vG8yp74rlm+MUem62hc GRkKz5Qjz8s9aEzcPNKDfSulhhzRPyINCIckcBwmmltL/fOoOytppz37O6LKAXzYUq4= X-Gm-Gg: ASbGncu6NZIBWRdzhgnuwPL4vQUsDVJOAlRQ6sXdO9rIXnwwzQban/GQ7LJ6NiRsuTW 0500rgBQp6RPPDs8nicXG2DnudZ02NyMYH4EhoaMzm7DKq5xpozpiw6dyKwYmwYCpstpWiBzhBa Hr5LzzVg7wBz8uUEBfXhVBWNVHhfgSM88O56qywyQ9MYbwN2Q7CJCXJAZZ0/qJ8HsRUFMQqQlgR 48QaAEVIZQtFiwmo2uV77EXwz7N1al73XljL/apuiWhef7AQRFE61Z8AfBMWTfo8R61fw2OKBXo O3FRCOLk0vG1WNuRF7oYBIHRCzoKnRhlIRV6IiJ0iUlZMUupwZBFdBwPorRtQAdJgb1ZcoIiQTF +LqSLoNsxIpRuVnIIKei5vDVRntQUnMNRT+fQnBQBRbICRzci6YiC6teA8e++1Bx/shBOZhqK7U HE2kbeSgO/DYMSOAMuoDcQRQXv X-Google-Smtp-Source: AGHT+IGPfilu/kbgZV9dVq6wCfMGv8hTMKmEAShf3TykDi7bNAfE5BRENmfv20DM+MDzIz2SzorcxA== X-Received: by 2002:a05:600c:46c4:b0:477:5ca6:4d51 with SMTP id 5b1f17b1804b1-477c01bdd6cmr8525255e9.3.1763710845317; Thu, 20 Nov 2025 23:40:45 -0800 (PST) Received: from localhost.localdomain ([202.127.77.110]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7c3f023fba8sm5081295b3a.41.2025.11.20.23.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Nov 2025 23:40:44 -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 v4 2/2] ocfs2: detect released suballocator BG for fh_to_[dentry|parent] Date: Fri, 21 Nov 2025 15:40:25 +0800 Message-ID: <20251121074030.12014-3-heming.zhao@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251121074030.12014-1-heming.zhao@suse.com> References: <20251121074030.12014-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 --- fs/ocfs2/suballoc.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index de2f09217142..a126d83ddb1c 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,11 +3168,15 @@ static int ocfs2_test_suballoc_bit(struct ocfs2_sup= er *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 -EINVAL; + goto bail; + } else if (status < 0) { mlog(ML_ERROR, "read group %llu failed %d\n", - (unsigned long long)bg_blkno, status); + (unsigned long long)bg_blkno, status); goto bail; } =20 @@ -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 -EINVAL) + 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