]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ocfs2: switch osb->disable_recovery to enum
authorJan Kara <jack@suse.cz>
Thu, 24 Apr 2025 13:45:11 +0000 (15:45 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 8 May 2025 06:39:40 +0000 (23:39 -0700)
Patch series "ocfs2: Fix deadlocks in quota recovery", v3.

This implements another approach to fixing quota recovery deadlocks.  We
avoid grabbing sb->s_umount semaphore from ocfs2_finish_quota_recovery()
and instead stop quota recovery early in ocfs2_dismount_volume().

This patch (of 3):

We will need more recovery states than just pure enable / disable to fix
deadlocks with quota recovery.  Switch osb->disable_recovery to enum.

Link: https://lkml.kernel.org/r/20250424134301.1392-1-jack@suse.cz
Link: https://lkml.kernel.org/r/20250424134515.18933-4-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: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Jun Piao <piaojun@huawei.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>
fs/ocfs2/journal.c
fs/ocfs2/ocfs2.h

index c7a9729dc9d087816dcb52751c5d2b89159e3ba8..e79f10cc43d91e79668d4a86fc69166ca127c17d 100644 (file)
@@ -174,7 +174,7 @@ int ocfs2_recovery_init(struct ocfs2_super *osb)
        struct ocfs2_recovery_map *rm;
 
        mutex_init(&osb->recovery_lock);
-       osb->disable_recovery = 0;
+       osb->recovery_state = OCFS2_REC_ENABLED;
        osb->recovery_thread_task = NULL;
        init_waitqueue_head(&osb->recovery_event);
 
@@ -206,7 +206,7 @@ void ocfs2_recovery_exit(struct ocfs2_super *osb)
        /* 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->disable_recovery = 1;
+       osb->recovery_state = OCFS2_REC_DISABLED;
        mutex_unlock(&osb->recovery_lock);
        wait_event(osb->recovery_event, !ocfs2_recovery_thread_running(osb));
 
@@ -1582,14 +1582,16 @@ bail:
 
 void ocfs2_recovery_thread(struct ocfs2_super *osb, int node_num)
 {
+       int was_set = -1;
+
        mutex_lock(&osb->recovery_lock);
+       if (osb->recovery_state < OCFS2_REC_DISABLED)
+               was_set = ocfs2_recovery_map_set(osb, node_num);
 
        trace_ocfs2_recovery_thread(node_num, osb->node_num,
-               osb->disable_recovery, osb->recovery_thread_task,
-               osb->disable_recovery ?
-               -1 : ocfs2_recovery_map_set(osb, node_num));
+               osb->recovery_state, osb->recovery_thread_task, was_set);
 
-       if (osb->disable_recovery)
+       if (osb->recovery_state == OCFS2_REC_DISABLED)
                goto out;
 
        if (osb->recovery_thread_task)
index 51c52768132d70289368d06bdfc9c22462044145..e713361939f00a58ba666d9fac18e542d2e00a95 100644 (file)
@@ -308,6 +308,11 @@ enum ocfs2_journal_trigger_type {
 void ocfs2_initialize_journal_triggers(struct super_block *sb,
                                       struct ocfs2_triggers triggers[]);
 
+enum ocfs2_recovery_state {
+       OCFS2_REC_ENABLED = 0,
+       OCFS2_REC_DISABLED,
+};
+
 struct ocfs2_journal;
 struct ocfs2_slot_info;
 struct ocfs2_recovery_map;
@@ -370,7 +375,7 @@ struct ocfs2_super
        struct ocfs2_recovery_map *recovery_map;
        struct ocfs2_replay_map *replay_map;
        struct task_struct *recovery_thread_task;
-       int disable_recovery;
+       enum ocfs2_recovery_state recovery_state;
        wait_queue_head_t checkpoint_event;
        struct ocfs2_journal *journal;
        unsigned long osb_commit_interval;