From: Joseph Qi <joseph.qi@linux.alibaba.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>,
Heming Zhao <heming.zhao@suse.com>
Cc: ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH v2 3/3] ocfs2: cluster: fix o2hb_dependent_users leak on pin failure
Date: Wed, 22 Jul 2026 20:49:33 +0800 [thread overview]
Message-ID: <20260722124933.430554-4-joseph.qi@linux.alibaba.com> (raw)
In-Reply-To: <20260722124933.430554-1-joseph.qi@linux.alibaba.com>
In o2hb_region_inc_user(), o2hb_dependent_users is incremented
unconditionally before calling o2hb_region_pin(). If the pin fails,
the counter is never decremented and any partially-pinned regions are
never unpinned, since the caller does not call o2hb_region_dec_user()
on error.
The leaked counter causes subsequent o2hb_region_inc_user() calls to
skip pinning entirely (the > 1 check), leaving heartbeat regions
unprotected.
Fix by rolling back on failure: call o2hb_region_unpin(NULL) to release
any partially-pinned regions and decrement o2hb_dependent_users to
restore the pre-increment state.
Fixes: 58a3158a5d17 ("ocfs2/cluster: Pin/unpin o2hb regions")
Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
---
fs/ocfs2/cluster/heartbeat.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index b9395835523e2..c25aa2ff3ebc2 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -2499,8 +2499,13 @@ static int o2hb_region_inc_user(const char *region_uuid)
goto unlock;
if (bitmap_weight(o2hb_quorum_region_bitmap,
- O2NM_MAX_REGIONS) <= O2HB_PIN_CUT_OFF)
+ O2NM_MAX_REGIONS) <= O2HB_PIN_CUT_OFF) {
ret = o2hb_region_pin(NULL, false);
+ if (ret) {
+ o2hb_region_unpin(NULL);
+ o2hb_dependent_users--;
+ }
+ }
unlock:
spin_unlock(&o2hb_live_lock);
--
2.39.3
next prev parent reply other threads:[~2026-07-22 12:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 12:49 [PATCH v2 0/3] ocfs2: cluster: o2hb_region_pin() fixes Joseph Qi
2026-07-22 12:49 ` [PATCH v2 1/3] ocfs2: cluster: don't sleep while holding o2hb_live_lock in o2hb_region_pin() Joseph Qi
2026-07-22 12:49 ` [PATCH v2 2/3] ocfs2: cluster: avoid lock order inversion in o2hb_region_pin() from drop_item Joseph Qi
2026-07-22 12:49 ` Joseph Qi [this message]
2026-07-22 23:43 ` [PATCH v2 0/3] ocfs2: cluster: o2hb_region_pin() fixes Andrew Morton
2026-07-23 1:13 ` Joseph Qi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260722124933.430554-4-joseph.qi@linux.alibaba.com \
--to=joseph.qi@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=heming.zhao@suse.com \
--cc=jlbec@evilplan.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@fasheh.com \
--cc=ocfs2-devel@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®