Skip to content

Commit 515b269

Browse files
Alexander AringAndreas Gruenbacher
authored andcommitted
gfs2: set lockdep subclass for iopen glocks
This patch introduce a new globs attribute to define the subclass of the glock lockref spinlock. This avoid the following lockdep warning, which occurs when we lock an inode lock while an iopen lock is held: ============================================ WARNING: possible recursive locking detected 5.10.0-rc3+ #4990 Not tainted -------------------------------------------- kworker/0:1/12 is trying to acquire lock: ffff9067d45672d8 (&gl->gl_lockref.lock){+.+.}-{3:3}, at: lockref_get+0x9/0x20 but task is already holding lock: ffff9067da308588 (&gl->gl_lockref.lock){+.+.}-{3:3}, at: delete_work_func+0x164/0x260 other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(&gl->gl_lockref.lock); lock(&gl->gl_lockref.lock); *** DEADLOCK *** May be due to missing lock nesting notation 3 locks held by kworker/0:1/12: #0: ffff9067c1bfdd38 ((wq_completion)delete_workqueue){+.+.}-{0:0}, at: process_one_work+0x1b7/0x540 #1: ffffac594006be70 ((work_completion)(&(&gl->gl_delete)->work)){+.+.}-{0:0}, at: process_one_work+0x1b7/0x540 #2: ffff9067da308588 (&gl->gl_lockref.lock){+.+.}-{3:3}, at: delete_work_func+0x164/0x260 stack backtrace: CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.10.0-rc3+ #4990 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-2.fc32 04/01/2014 Workqueue: delete_workqueue delete_work_func Call Trace: dump_stack+0x8b/0xb0 __lock_acquire.cold+0x19e/0x2e3 lock_acquire+0x150/0x410 ? lockref_get+0x9/0x20 _raw_spin_lock+0x27/0x40 ? lockref_get+0x9/0x20 lockref_get+0x9/0x20 delete_work_func+0x188/0x260 process_one_work+0x237/0x540 worker_thread+0x4d/0x3b0 ? process_one_work+0x540/0x540 kthread+0x127/0x140 ? __kthread_bind_mask+0x60/0x60 ret_from_fork+0x22/0x30 Suggested-by: Andreas Gruenbacher <agruenba@redhat.com> Signed-off-by: Alexander Aring <aahringo@redhat.com> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent 16e6281 commit 515b269

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

fs/gfs2/glock.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
10351035
gl->gl_node.next = NULL;
10361036
gl->gl_flags = 0;
10371037
gl->gl_name = name;
1038+
lockdep_set_subclass(&gl->gl_lockref.lock, glops->go_subclass);
10381039
gl->gl_lockref.count = 1;
10391040
gl->gl_state = LM_ST_UNLOCKED;
10401041
gl->gl_target = LM_ST_UNLOCKED;

fs/gfs2/glops.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ const struct gfs2_glock_operations gfs2_iopen_glops = {
781781
.go_callback = iopen_go_callback,
782782
.go_demote_ok = iopen_go_demote_ok,
783783
.go_flags = GLOF_LRU | GLOF_NONDISK,
784+
.go_subclass = 1,
784785
};
785786

786787
const struct gfs2_glock_operations gfs2_flock_glops = {

fs/gfs2/incore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ struct gfs2_glock_operations {
247247
const char *fs_id_buf);
248248
void (*go_callback)(struct gfs2_glock *gl, bool remote);
249249
void (*go_free)(struct gfs2_glock *gl);
250+
const int go_subclass;
250251
const int go_type;
251252
const unsigned long go_flags;
252253
#define GLOF_ASPACE 1 /* address space attached */

0 commit comments

Comments
 (0)