public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Jan Kara <jack@suse.cz>,
	Heming Zhao <heming.zhao@suse.com>,
	Joseph Qi <joseph.qi@linux.alibaba.com>,
	Changwei Ge <gechangwei@live.cn>,
	Joel Becker <jlbec@evilplan.org>, Jun Piao <piaojun@huawei.com>,
	Junxiao Bi <junxiao.bi@oracle.com>, Mark Fasheh <mark@fasheh.com>,
	Murad Masimov <m.masimov@mt-integration.ru>,
	Shichangkuo <shi.changkuo@h3c.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 6.1 48/92] ocfs2: implement handshaking with ocfs2 recovery thread
Date: Mon, 12 May 2025 19:45:23 +0200	[thread overview]
Message-ID: <20250512172025.075860483@linuxfoundation.org> (raw)
In-Reply-To: <20250512172023.126467649@linuxfoundation.org>

6.1-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jan Kara <jack@suse.cz>

commit 8f947e0fd595951460f5a6e1ac29baa82fa02eab upstream.

We will need ocfs2 recovery thread to acknowledge transitions of
recovery_state when disabling particular types of recovery.  This is
similar to what currently happens when disabling recovery completely, just
more general.  Implement the handshake and use it for exit from recovery.

Link: https://lkml.kernel.org/r/20250424134515.18933-5-jack@suse.cz
Fixes: 5f530de63cfc ("ocfs2: Use s_umount for quota recovery protection")
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Heming Zhao <heming.zhao@suse.com>
Tested-by: Heming Zhao <heming.zhao@suse.com>
Acked-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Jun Piao <piaojun@huawei.com>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Murad Masimov <m.masimov@mt-integration.ru>
Cc: Shichangkuo <shi.changkuo@h3c.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/ocfs2/journal.c |   52 +++++++++++++++++++++++++++++++++++-----------------
 fs/ocfs2/ocfs2.h   |    4 ++++
 2 files changed, 39 insertions(+), 17 deletions(-)

--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -192,31 +192,48 @@ int ocfs2_recovery_init(struct ocfs2_sup
 	return 0;
 }
 
-/* we can't grab the goofy sem lock from inside wait_event, so we use
- * memory barriers to make sure that we'll see the null task before
- * being woken up */
 static int ocfs2_recovery_thread_running(struct ocfs2_super *osb)
 {
-	mb();
 	return osb->recovery_thread_task != NULL;
 }
 
-void ocfs2_recovery_exit(struct ocfs2_super *osb)
+static void ocfs2_recovery_disable(struct ocfs2_super *osb,
+				   enum ocfs2_recovery_state state)
 {
-	struct ocfs2_recovery_map *rm;
-
-	/* disable any new recovery threads and wait for any currently
-	 * running ones to exit. Do this before setting the vol_state. */
 	mutex_lock(&osb->recovery_lock);
-	osb->recovery_state = OCFS2_REC_DISABLED;
+	/*
+	 * If recovery thread is not running, we can directly transition to
+	 * final state.
+	 */
+	if (!ocfs2_recovery_thread_running(osb)) {
+		osb->recovery_state = state + 1;
+		goto out_lock;
+	}
+	osb->recovery_state = state;
+	/* Wait for recovery thread to acknowledge state transition */
+	wait_event_cmd(osb->recovery_event,
+		       !ocfs2_recovery_thread_running(osb) ||
+				osb->recovery_state >= state + 1,
+		       mutex_unlock(&osb->recovery_lock),
+		       mutex_lock(&osb->recovery_lock));
+out_lock:
 	mutex_unlock(&osb->recovery_lock);
-	wait_event(osb->recovery_event, !ocfs2_recovery_thread_running(osb));
 
-	/* At this point, we know that no more recovery threads can be
-	 * launched, so wait for any recovery completion work to
-	 * complete. */
+	/*
+	 * At this point we know that no more recovery work can be queued so
+	 * wait for any recovery completion work to complete.
+	 */
 	if (osb->ocfs2_wq)
 		flush_workqueue(osb->ocfs2_wq);
+}
+
+void ocfs2_recovery_exit(struct ocfs2_super *osb)
+{
+	struct ocfs2_recovery_map *rm;
+
+	/* disable any new recovery threads and wait for any currently
+	 * running ones to exit. Do this before setting the vol_state. */
+	ocfs2_recovery_disable(osb, OCFS2_REC_WANT_DISABLE);
 
 	/*
 	 * Now that recovery is shut down, and the osb is about to be
@@ -1536,7 +1553,8 @@ bail:
 
 	ocfs2_free_replay_slots(osb);
 	osb->recovery_thread_task = NULL;
-	mb(); /* sync with ocfs2_recovery_thread_running */
+	if (osb->recovery_state == OCFS2_REC_WANT_DISABLE)
+		osb->recovery_state = OCFS2_REC_DISABLED;
 	wake_up(&osb->recovery_event);
 
 	mutex_unlock(&osb->recovery_lock);
@@ -1552,13 +1570,13 @@ void ocfs2_recovery_thread(struct ocfs2_
 	int was_set = -1;
 
 	mutex_lock(&osb->recovery_lock);
-	if (osb->recovery_state < OCFS2_REC_DISABLED)
+	if (osb->recovery_state < OCFS2_REC_WANT_DISABLE)
 		was_set = ocfs2_recovery_map_set(osb, node_num);
 
 	trace_ocfs2_recovery_thread(node_num, osb->node_num,
 		osb->recovery_state, osb->recovery_thread_task, was_set);
 
-	if (osb->recovery_state == OCFS2_REC_DISABLED)
+	if (osb->recovery_state >= OCFS2_REC_WANT_DISABLE)
 		goto out;
 
 	if (osb->recovery_thread_task)
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -286,6 +286,10 @@ enum ocfs2_mount_options
 
 enum ocfs2_recovery_state {
 	OCFS2_REC_ENABLED = 0,
+	OCFS2_REC_WANT_DISABLE,
+	/*
+	 * Must be OCFS2_REC_WANT_DISABLE + 1 for ocfs2_recovery_exit() to work
+	 */
 	OCFS2_REC_DISABLED,
 };
 



  parent reply	other threads:[~2025-05-12 17:54 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-12 17:44 [PATCH 6.1 00/92] 6.1.139-rc1 review Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 01/92] dm: add missing unlock on in dm_keyslot_evict() Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 02/92] arm64: dts: imx8mm-verdin: Link reg_usdhc2_vqmmc to usdhc2 Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 03/92] can: mcan: m_can_class_unregister(): fix order of unregistration calls Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 04/92] can: mcp251xfd: mcp251xfd_remove(): " Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 05/92] ksmbd: prevent out-of-bounds stream writes by validating *pos Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 06/92] openvswitch: Fix unsafe attribute parsing in output_userspace() Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 07/92] ksmbd: fix memory leak in parse_lease_state() Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 08/92] sch_htb: make htb_deactivate() idempotent Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 09/92] gre: Fix again IPv6 link-local address generation Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 10/92] can: mcp251xfd: fix TDC setting for low data bit rates Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 11/92] rcu/kvfree: Add kvfree_rcu_mightsleep() and kfree_rcu_mightsleep() Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 12/92] can: gw: fix RCU/BH usage in cgw_create_job() Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 13/92] ipv4: Drop tos parameter from flowi4_update_output() Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 14/92] ipvs: fix uninit-value for saddr in do_output_route4 Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 15/92] netfilter: ipset: fix region locking in hash types Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 16/92] bpf: Scrub packet on bpf_redirect_peer Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 17/92] net: dsa: b53: allow leaky reserved multicast Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 18/92] net: dsa: b53: fix clearing PVID of a port Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 19/92] net: dsa: b53: fix flushing old pvid VLAN on pvid change Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 20/92] net: dsa: b53: fix VLAN ID for untagged vlan on bridge leave Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 21/92] net: dsa: b53: always rejoin default untagged VLAN " Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 22/92] net: dsa: b53: fix learning on VLAN unaware bridges Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 23/92] Input: mtk-pmic-keys - fix possible null pointer dereference Greg Kroah-Hartman
2025-05-12 17:44 ` [PATCH 6.1 24/92] Input: synaptics - enable InterTouch on Dynabook Portege X30-D Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 25/92] Input: synaptics - enable InterTouch on Dynabook Portege X30L-G Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 26/92] Input: synaptics - enable InterTouch on Dell Precision M3800 Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 27/92] Input: synaptics - enable SMBus for HP Elitebook 850 G1 Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 28/92] Input: synaptics - enable InterTouch on TUXEDO InfinityBook Pro 14 v5 Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 29/92] staging: iio: adc: ad7816: Correct conditional logic for store mode Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 30/92] staging: axis-fifo: Remove hardware resets for user errors Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 31/92] staging: axis-fifo: Correct handling of tx_fifo_depth for size validation Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 32/92] x86/mm: Eliminate window where TLB flushes may be inadvertently skipped Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 33/92] drm/amd/display: Shift DMUB AUX reply command if necessary Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 34/92] iio: adc: ad7606: fix serial register access Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 35/92] iio: adis16201: Correct inclinometer channel resolution Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 36/92] iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_fifo Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 37/92] iio: imu: st_lsm6dsx: fix possible lockup in st_lsm6dsx_read_tagged_fifo Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 38/92] drm/v3d: Add job to pending list if the reset was skipped Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 39/92] drm/amd/display: Fix the checking condition in dmub aux handling Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 40/92] drm/amd/display: Remove incorrect checking in dmub aux handler Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 41/92] drm/amd/display: Fix wrong handling for AUX_DEFER case Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 42/92] drm/amd/display: Copy AUX read reply data whenever length > 0 Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 43/92] drm/amdgpu/hdp5.2: use memcfg register to post the write for HDP flush Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 44/92] usb: uhci-platform: Make the clock really optional Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 45/92] xenbus: Use kref to track req lifetime Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 46/92] module: ensure that kobject_put() is safe for module type kobjects Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 47/92] ocfs2: switch osb->disable_recovery to enum Greg Kroah-Hartman
2025-05-12 17:45 ` Greg Kroah-Hartman [this message]
2025-05-12 17:45 ` [PATCH 6.1 49/92] ocfs2: stop quota recovery before disabling quotas Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 50/92] usb: cdnsp: Fix issue with resuming from L1 Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 51/92] usb: cdnsp: fix L1 resume issue for RTL_REVISION_NEW_LPM version Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 52/92] usb: gadget: tegra-xudc: ACK ST_RC after clearing CTRL_RUN Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 53/92] usb: host: tegra: Prevent host controller crash when OTG port is used Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 54/92] usb: typec: tcpm: delay SNK_TRY_WAIT_DEBOUNCE to SRC_TRYWAIT transition Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 55/92] usb: typec: ucsi: displayport: Fix NULL pointer access Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 56/92] USB: usbtmc: use interruptible sleep in usbtmc_read Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 57/92] usb: usbtmc: Fix erroneous get_stb ioctl error returns Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 58/92] usb: usbtmc: Fix erroneous wait_srq ioctl return Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 59/92] usb: usbtmc: Fix erroneous generic_read " Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 60/92] iio: accel: adxl367: fix setting odr for activity time update Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 61/92] iio: temp: maxim-thermocouple: Fix potential lack of DMA safe buffer Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 62/92] types: Complement the aligned types with signed 64-bit one Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 63/92] iio: accel: adxl355: Make timestamp 64-bit aligned using aligned_s64 Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 64/92] iio: adc: dln2: Use aligned_s64 for timestamp Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 65/92] MIPS: Fix MAX_REG_OFFSET Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 66/92] drm/panel: simple: Update timings for AUO G101EVN010 Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 67/92] nvme: unblock ctrl state transition for firmware update Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 68/92] do_umount(): add missing barrier before refcount checks in sync case Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 69/92] io_uring: always arm linked timeouts prior to issue Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 70/92] io_uring: ensure deferred completions are posted for multishot Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 71/92] Revert "net: phy: microchip: force IRQ polling mode for lan88xx" Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 72/92] arm64: insn: Add support for encoding DSB Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 73/92] arm64: proton-pack: Expose whether the platform is mitigated by firmware Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 74/92] arm64: proton-pack: Expose whether the branchy loop k value Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 75/92] arm64: bpf: Add BHB mitigation to the epilogue for cBPF programs Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 76/92] arm64: bpf: Only mitigate cBPF programs loaded by unprivileged users Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 77/92] arm64: proton-pack: Add new CPUs k values for branch mitigation Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 78/92] x86/bpf: Call branch history clearing sequence on exit Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 79/92] x86/bpf: Add IBHF call at end of classic BPF Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 80/92] x86/bhi: Do not set BHI_DIS_S in 32-bit mode Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 81/92] x86/speculation: Simplify and make CALL_NOSPEC consistent Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 82/92] x86/speculation: Add a conditional CS prefix to CALL_NOSPEC Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 83/92] x86/speculation: Remove the extra #ifdef around CALL_NOSPEC Greg Kroah-Hartman
2025-05-12 17:45 ` [PATCH 6.1 84/92] Documentation: x86/bugs/its: Add ITS documentation Greg Kroah-Hartman
2025-05-12 17:46 ` [PATCH 6.1 85/92] x86/its: Enumerate Indirect Target Selection (ITS) bug Greg Kroah-Hartman
2025-05-12 17:46 ` [PATCH 6.1 86/92] x86/its: Add support for ITS-safe indirect thunk Greg Kroah-Hartman
2025-05-12 17:46 ` [PATCH 6.1 87/92] x86/its: Add support for ITS-safe return thunk Greg Kroah-Hartman
2025-05-12 17:46 ` [PATCH 6.1 88/92] x86/its: Enable Indirect Target Selection mitigation Greg Kroah-Hartman
2025-05-12 17:46 ` [PATCH 6.1 89/92] x86/its: Add "vmexit" option to skip mitigation on some CPUs Greg Kroah-Hartman
2025-05-12 17:46 ` [PATCH 6.1 90/92] x86/its: Align RETs in BHB clear sequence to avoid thunking Greg Kroah-Hartman
2025-05-12 17:46 ` [PATCH 6.1 91/92] x86/ibt: Keep IBT disabled during alternative patching Greg Kroah-Hartman
2025-05-12 17:46 ` [PATCH 6.1 92/92] x86/its: Use dynamic thunks for indirect branches Greg Kroah-Hartman
2025-05-12 20:56 ` [PATCH 6.1 00/92] 6.1.139-rc1 review Jon Hunter
2025-05-13  6:45 ` Pavel Machek
2025-05-13  9:43 ` Florian Fainelli
2025-05-13  9:48 ` Mark Brown
2025-05-13 10:04 ` Ron Economos
2025-05-13 11:39 ` Peter Schneider
2025-05-13 17:19 ` Naresh Kamboju
2025-05-13 17:32 ` Shuah Khan
2025-05-14 17:11 ` Hardik Garg

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=20250512172025.075860483@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=gechangwei@live.cn \
    --cc=heming.zhao@suse.com \
    --cc=jack@suse.cz \
    --cc=jlbec@evilplan.org \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=junxiao.bi@oracle.com \
    --cc=m.masimov@mt-integration.ru \
    --cc=mark@fasheh.com \
    --cc=patches@lists.linux.dev \
    --cc=piaojun@huawei.com \
    --cc=shi.changkuo@h3c.com \
    --cc=stable@vger.kernel.org \
    /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