Project

General

Profile

Bug #2905

zfs: deadlock of dp_config_rwlock due to nested READ lock

Added by Vitaliy Gusev over 7 years ago.

Status:
New
Priority:
High
Assignee:
-
Category:
-
Start date:
2012-06-21
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

dsl_pool->dp_config_rwlock is krwlock_t. Writer has priority over readers and is barrier for readers.

So nested READ lock can bring deadlock if between nested readlock writer tries to get that lock.

thread 1: thread2

read_lock
...                                   write_lock   << goes to sleep
read_lock  << deadlock

Stacks of real deadlock:

::pgrep zfs|::walk thread|::findstack
stack pointer for thread ffffff00d239bc00: ffffff00028873e0
ffffff00028874c0 turnstile_block+0x760()
ffffff0002887530 rw_enter_sleep+0x205()
ffffff00028875b0 dsl_prop_register+0x5b()
ffffff0002887640 dmu_objset_open_impl+0x220()
ffffff0002887690 dmu_objset_from_ds+0x68()
ffffff00028876c0 dsl_dataset_modified_since_lastsnap+0x5e()
ffffff0002887720 recv_existing_check+0x36()
ffffff0002887760 dsl_sync_task_group_wait+0x8b()
ffffff00028877e0 dsl_sync_task_do+0x65()
ffffff00028879c0 dmu_recv_begin+0x50e()
ffffff0002887bb0 zfs_ioc_recv+0x2a8()
ffffff0002887c30 zfsdev_ioctl+0x15e()
ffffff0002887c70 cdev_ioctl+0x45()
ffffff0002887cb0 spec_ioctl+0x5a()
ffffff0002887d30 fop_ioctl+0x7b()
ffffff0002887e30 ioctl+0x18e()

::threadlist!grep txg_sync_thread
ffffff00027f3c60 fffffffffbc2dbf0 0 txg_sync_thread()
ffffff00037bbc60 fffffffffbc2dbf0 0 txg_sync_thread()

ffffff00037bbc60::findstack

stack pointer for thread ffffff00037bbc60: ffffff00037bb8d0
[ ffffff00037bb8d0 _resume_from_idle+0xf1() ]
ffffff00037bb900 swtch+0x145()
ffffff00037bb9b0 turnstile_block+0x760()
ffffff00037bba20 rw_enter_sleep+0x1a3()
ffffff00037bba70 dsl_sync_task_group_sync+0x87()
ffffff00037bbaf0 dsl_pool_sync+0x1ec()
ffffff00037bbba0 spa_sync+0x38d()
ffffff00037bbc40 txg_sync_thread+0x247()
ffffff00037bbc50 thread_start+8()

So dp_config_rwlock is taken twice for READ (nested):

1-st      -  dsl_sync_task_group_wait
2-nd - dsl_prop_register

Also available in: Atom PDF