FAILED: patch "[PATCH] f2fs: fix false alarm of lockdep on cp_global_sem lock" failed to apply to 5.15-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 6a5e3de9c2bb0b691d16789a5d19e9276a09b308
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026051240-overthrow-lumpiness-9c49@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 6a5e3de9c2bb0b691d16789a5d19e9276a09b308 Mon Sep 17 00:00:00 2001
From: Chao Yu <[email protected]>
Date: Fri, 6 Mar 2026 12:24:20 +0000
Subject: [PATCH] f2fs: fix false alarm of lockdep on cp_global_sem lock
lockdep reported a potential deadlock:
a) TCMU device removal context:
- call del_gendisk() to get q->q_usage_counter
- call start_flush_work() to get work_completion of wb->dwork
b) f2fs writeback context:
- in wb_workfn(), which holds work_completion of wb->dwork
- call f2fs_balance_fs() to get sbi->gc_lock
c) f2fs vfs_write context:
- call f2fs_gc() to get sbi->gc_lock
- call f2fs_write_checkpoint() to get sbi->cp_global_sem
d) f2fs mount context:
- call recover_fsync_data() to get sbi->cp_global_sem
- call f2fs_check_and_fix_write_pointer() to call blkdev_report_zones() that goes down to blk_mq_alloc_request and get q->q_usage_counter
Original callstack is in Closes tag.
However, I think this is a false alarm due to before mount returns successfully (context d), we can not access file therein via vfs_write (context c).
Let's introduce per-sb cp_global_sem_key, and assign the key for cp_global_sem, so that lockdep can recognize cp_global_sem from different super block correctly.
A lot of work are done by Shin'ichiro Kawasaki, thanks a lot for the work.
fs/f2fs/f2fs.h +3 -0
@@ -2042,6 +2042,9 @@ struct f2fs_sb_info {spinlock_t iostat_lat_lock;struct iostat_lat_info *iostat_io_lat;#endif +#ifdef CONFIG_DEBUG_LOCK_ALLOC +struct lock_class_key cp_global_sem_key; +#endif };/* Definitions to access f2fs_sb_info */
fs/f2fs/super.c +11 -0
@@ -4964,6 +4964,11 @@ static int f2fs_fill_super(struct super_block *sb, struct fs_context *fc)init_f2fs_rwsem_trace (&sbi->gc_lock, sbi,LOCK_NAME_GC_LOCK );mutex_init (&sbi->writepages);init_f2fs_rwsem_trace (&sbi->cp_global_sem, sbi,LOCK_NAME_CP_GLOBAL ); +#ifdef CONFIG_DEBUG_LOCK_ALLOC +lockdep_register_key (&sbi->cp_global_sem_key); +lockdep_set_class (&sbi->cp_global_sem.internal_rwsem, + &sbi->cp_global_sem_key); +#endif init_f2fs_rwsem_trace (&sbi->node_write, sbi,LOCK_NAME_NODE_WRITE );init_f2fs_rwsem_trace (&sbi->node_change, sbi,LOCK_NAME_NODE_CHANGE );spin_lock_init (&sbi->stat_lock);
@@ -5435,6 +5440,9 @@ static int f2fs_fill_super(struct super_block *sb, struct fs_context *fc) free_sb_buf:kfree (raw_super); free_sbi: +#ifdef CONFIG_DEBUG_LOCK_ALLOC +lockdep_unregister_key (&sbi->cp_global_sem_key); +#endif kfree (sbi); sb->s_fs_info =NULL ;
@@ -5516,6 +5524,9 @@ static void kill_f2fs_super(struct super_block *sb)/* Release block devices last, after fscrypt_destroy_keyring(). */ if (sbi) {destroy_device_list (sbi); +#ifdef CONFIG_DEBUG_LOCK_ALLOC +lockdep_unregister_key (&sbi->cp_global_sem_key); +#endif kfree (sbi); sb->s_fs_info =NULL ; }
Sasha Levin
maintainerPATCH 1/1 f2fs: fix false alarm of lockdep on cp_global_sem lock
From: Chao Yu <[email protected]>
[ Upstream commit 6a5e3de9c2bb0b691d16789a5d19e9276a09b308 ]
lockdep reported a potential deadlock:
a) TCMU device removal context:
- call del_gendisk() to get q->q_usage_counter
- call start_flush_work() to get work_completion of wb->dwork
b) f2fs writeback context:
- in wb_workfn(), which holds work_completion of wb->dwork
- call f2fs_balance_fs() to get sbi->gc_lock
c) f2fs vfs_write context:
- call f2fs_gc() to get sbi->gc_lock
- call f2fs_write_checkpoint() to get sbi->cp_global_sem
d) f2fs mount context:
- call recover_fsync_data() to get sbi->cp_global_sem
- call f2fs_check_and_fix_write_pointer() to call blkdev_report_zones() that goes down to blk_mq_alloc_request and get q->q_usage_counter
Original callstack is in Closes tag.
However, I think this is a false alarm due to before mount returns successfully (context d), we can not access file therein via vfs_write (context c).
Let's introduce per-sb cp_global_sem_key, and assign the key for cp_global_sem, so that lockdep can recognize cp_global_sem from different super block correctly.
A lot of work are done by Shin'ichiro Kawasaki, thanks a lot for the work.
--- fs/f2fs/f2fs.h | 3 +++ fs/f2fs/super.c | 11 +++++++++++ 2 files changed, 14 insertions(+)
fs/f2fs/f2fs.h +3 -0
@@ -1798,6 +1798,9 @@ struct f2fs_sb_info {spinlock_t iostat_lat_lock;struct iostat_lat_info *iostat_io_lat;#endif +#ifdef CONFIG_DEBUG_LOCK_ALLOC +struct lock_class_key cp_global_sem_key; +#endif };struct f2fs_private_dio {
fs/f2fs/super.c +11 -0
@@ -1667,6 +1667,9 @@ static void f2fs_put_super(struct super_block *sb)kvfree (sbi->write_io[i]);#ifdef CONFIG_UNICODE utf8_unload (sb->s_encoding); +#endif +#ifdef CONFIG_DEBUG_LOCK_ALLOC +lockdep_unregister_key (&sbi->cp_global_sem_key);#endif kfree (sbi); }
@@ -4118,6 +4121,11 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)init_rwsem (&sbi->gc_lock);mutex_init (&sbi->writepages);init_rwsem (&sbi->cp_global_sem); +#ifdef CONFIG_DEBUG_LOCK_ALLOC +lockdep_register_key (&sbi->cp_global_sem_key); +lockdep_set_class (&sbi->cp_global_sem, + &sbi->cp_global_sem_key); +#endif init_rwsem (&sbi->node_write);init_rwsem (&sbi->node_change);
@@ -4519,6 +4527,9 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) free_sbi:if (sbi->s_chksum_driver)crypto_free_shash (sbi->s_chksum_driver); +#ifdef CONFIG_DEBUG_LOCK_ALLOC +lockdep_unregister_key (&sbi->cp_global_sem_key); +#endif kfree (sbi);/* give only one another chance */
Signature · 1 line
2.53.0