diff options
author | jdike <[email protected]> | 2019-07-31 17:53:39 -0400 |
---|---|---|
committer | Matthew Ahrens <[email protected]> | 2019-07-31 14:53:39 -0700 |
commit | 48be0dfba19f35637877ab63f58d52b6d51e759c (patch) | |
tree | 04832c59c2461daf175ad09047dc8f8ac982bb7d | |
parent | cae97c88c4ed2d99b523b84c713993d26034a23b (diff) |
lockdep false positive - move txg_kick() outside of ->dp_lock
This fixes a lockdep warning by breaking a link between ->tx_sync_lock
and ->dp_lock.
The deadlock envisioned by lockdep is this:
thread 1 holds db->db_mtx and tries to get dp->dp_lock:
dsl_pool_dirty_space+0x70/0x2d0 [zfs]
dbuf_dirty+0x778/0x31d0 [zfs]
thread 2 holds bpo->bpo_lock and tries to get db->db_mtx:
dmu_buf_will_dirty_impl
dmu_buf_will_dirty+0x6b/0x6c0 [zfs]
bpobj_iterate_impl+0xbe6/0x1410 [zfs]
thread 3 holds tx->tx_sync_lock and tries to get bpo->bpo_lock:
bpobj_space+0x63/0x470 [zfs]
dsl_scan_active+0x340/0x3d0 [zfs]
txg_sync_thread+0x3f2/0x1370 [zfs]
thread 4 holds dp->dp_lock and tries to get tx->tx_sync_lock
txg_kick+0x61/0x420 [zfs]
dsl_pool_need_dirty_delay+0x1c7/0x3f0 [zfs]
This patch is orginally from Brian Behlendorf and slightly simplified
by me.
It breaks this cycle in thread 4 by moving the call from
dsl_pool_need_dirty_delay to txg_kick outside the section controlled
by dp->dp_lock.
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Matt Ahrens <[email protected]>
Signed-off-by: Jeff Dike <[email protected]>
Closes #9094
-rw-r--r-- | module/zfs/dsl_pool.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/module/zfs/dsl_pool.c b/module/zfs/dsl_pool.c index c342f0c51..9fb3a061d 100644 --- a/module/zfs/dsl_pool.c +++ b/module/zfs/dsl_pool.c @@ -889,14 +889,14 @@ dsl_pool_need_dirty_delay(dsl_pool_t *dp) zfs_dirty_data_max * zfs_delay_min_dirty_percent / 100; uint64_t dirty_min_bytes = zfs_dirty_data_max * zfs_dirty_data_sync_percent / 100; - boolean_t rv; + uint64_t dirty; mutex_enter(&dp->dp_lock); - if (dp->dp_dirty_total > dirty_min_bytes) - txg_kick(dp); - rv = (dp->dp_dirty_total > delay_min_bytes); + dirty = dp->dp_dirty_total; mutex_exit(&dp->dp_lock); - return (rv); + if (dirty > dirty_min_bytes) + txg_kick(dp); + return (dirty > delay_min_bytes); } void |