Fix dbuf_stats_hash_table_data race

Dropping DBUF_HASH_MUTEX when walking the hash list is unsafe. The dbuf
can be freed at any time.

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4846
This commit is contained in:
Chunwei Chen 2016-07-12 12:23:43 -07:00 committed by Brian Behlendorf
parent 8887c7d778
commit 02de3e3c5d

View File

@ -148,7 +148,6 @@ dbuf_stats_hash_table_data(char *buf, size_t size, void *data)
} }
mutex_enter(&db->db_mtx); mutex_enter(&db->db_mtx);
mutex_exit(DBUF_HASH_MUTEX(h, dsh->idx));
if (db->db_state != DB_EVICTING) { if (db->db_state != DB_EVICTING) {
length = __dbuf_stats_hash_table_data(buf, size, db); length = __dbuf_stats_hash_table_data(buf, size, db);
@ -157,7 +156,6 @@ dbuf_stats_hash_table_data(char *buf, size_t size, void *data)
} }
mutex_exit(&db->db_mtx); mutex_exit(&db->db_mtx);
mutex_enter(DBUF_HASH_MUTEX(h, dsh->idx));
} }
mutex_exit(DBUF_HASH_MUTEX(h, dsh->idx)); mutex_exit(DBUF_HASH_MUTEX(h, dsh->idx));