From nobody Sun Dec 14 11:15:29 2025 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 4DCCB3C38 for ; Fri, 12 Dec 2025 07:00:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765522837; cv=none; b=a8zTcExzV0TARDDyfVwdde+s/7oWIMf9tE2XfqPVinZSMVhy8EBJEiRQXonJjdnDm+RdkvJHg598GzCRqG5hmJsXjk67vG3gBkS9pe5zhY42s6BxNhqnTBEKzHO+nbby3eT54HPEgFT6g/ePcksiVm5XhDe0mvvoH1jYH09gKck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765522837; c=relaxed/simple; bh=Evs5QQATIk0sNsyehuiCaQOTsbxa/fjc0hXZd7wTlXw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oxFjltH8PUyPVGVgA0d/6nDjfp9/2lpooXjWwuzTU07bHJa9FKz9gbDj9WP3VcxOFhHjs3iMCPiIllzOT8famnqk4SUHzt+y8WSNqsczEAU0du+v53OFj1r4EJuxnaYPRBxOACyNSKJk/VEYLFuv1EUpZz2H/SGJsSaMFMGAti8= 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=HdUIaQTB; arc=none smtp.client-ip=209.85.221.41 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="HdUIaQTB" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-42b5dfa4e9eso99606f8f.0 for ; Thu, 11 Dec 2025 23:00:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1765522833; x=1766127633; 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=GxXUWWraavNZv54vBuFyK/VfBOztE6hI+jfRRJkFQFs=; b=HdUIaQTBq7DgefDTtyISaHxSSSQp4iuyZXGKhTH7vBYWaZLVfUy+blZmMm07LMj+wp 504yZFF6AknRwM/SJTwos/+tz1/zK75A/0qjtING1Z4UwNzQtyzvbs+laDua38NQBdOU jqul8mfcC8Zi9fiL323KB4qteGvqpdSro2UOc4zPnSlPJxIKjLi9ANrJVBwLOA6xDT4o eHlVHwaSJjDgQw9KUVqM+x4eOk37i/yFzNF0ia+vmeoawVeUcgQZWlUPnCBJCTEi8YWj 9tf4iuaKstbA4EvBro4kBWOU+fofPg3l3MvjM2g6hLCiMGlQEOtYeZmYmlKJsFpydxyj bfLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765522833; x=1766127633; 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=GxXUWWraavNZv54vBuFyK/VfBOztE6hI+jfRRJkFQFs=; b=gh9f98mAaK4/r1UYoS8imWi49dA2eaXFIWSsrwIjg4CsFe7V/HkcCJfcxxDNeECUbh S63CjFc1vZVTBVwH6uqE9F5nlnoWhX3CrhU85+sObTu/7J+0c5W+NjHZSGku9qjjBcnt 4v8cdkQifcjwVF/3Vb1BCtC4g2HjzfFc0foja2XfejFgofvkRuuQHHpxnUCOIz5kse2s 36ZeM8FSCZr7YjVPfWLyQiFNVzSX4G24KimrR37/RH5YZp64MpRV4yeDm78/qZP8/cZs b+3h38/7uaAKSm964bFsd/xogSV+XIgmpO+EAuHkTwrroKsokkq2gv8/MFuKZf10sqm7 RlJg== X-Forwarded-Encrypted: i=1; AJvYcCVaiM7jWs/9Sxge2EizhEChgzkhG6IhssQXp8wJfkVTmAU1h3HU1eNz19fvnSjIqN9FltG9Pfc8PjS6PAg=@vger.kernel.org X-Gm-Message-State: AOJu0YymlC/XdtdBWSt4fPLZsz5byBoNNTNMG0ksmMmNnJ/XBGsVYkgr NmWf71ywBrkAW5zG2mXCH1+BohLfkIasYK+P706szEclsdi+LM0gng+w47TgfF0wGTLT9SdT8Ib a9u3M X-Gm-Gg: AY/fxX66g5kvR7a2DqrXUX032F78cEQmijugFfnMdqZbRLB6Ox95aaDLUZ78PPzBMOL fTvhrjem2ht1s42hIq/q3yySELzYcar7Z0Kw7NhhcqVlvALV6wOAG+hsbthKHBu0Q8Ao1NxtxTR /RnZvqxVHU+DnfVkzNxq+wrxv+edYaSM3kYKwe1cnbEwsEsbgVTMDMLw64hcWQbVFgxOzFSldzd YGqfP7cr3JbvUEEdfr6GxzNI67+mDxm5bCAW/ne4IOHH96ihhKmvE+d0kQ+1UnhsH4SOpEhoaqV FgyZTt57RgxYYe7EI9gImwoBvB25IkWBn4MrWOKClNPQ0t3GXD6ads83H36o+ZNS9Ya5if6llKO JMztYryEsZCzDYSVy+u0bumJkpnGUqcYFret40rf2fuPOwqau8wnKceysX5EgYqJsjtYif5+chS DacOyOw051QG8dXg+EeiiS1w== X-Google-Smtp-Source: AGHT+IFA53IyEiFb68nHZUn7/d0cwMWOehrqr8ylyNpy+E7MrSw8ju0jqjgEBSkU/GZW8iSGd9yb7A== X-Received: by 2002:a05:600c:1992:b0:477:c5a9:33ce with SMTP id 5b1f17b1804b1-47a8f904696mr5013075e9.4.1765522833258; Thu, 11 Dec 2025 23:00:33 -0800 (PST) Received: from p15.suse.cz ([202.127.77.110]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29ee9d38c74sm44479145ad.31.2025.12.11.23.00.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 23:00:32 -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 v5 2/2] ocfs2: detect released suballocator BG for fh_to_[dentry|parent] Date: Fri, 12 Dec 2025 15:00:14 +0800 Message-ID: <20251212070016.24235-3-heming.zhao@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251212070016.24235-1-heming.zhao@suse.com> References: <20251212070016.24235-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/export.c | 6 ++++-- fs/ocfs2/suballoc.c | 28 ++++++++++++++++++---------- 2 files changed, 22 insertions(+), 12 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..ddcfa6e001e8 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 -ESTALE; + 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 -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