Skip to content

Commit

Permalink
Revert "Fix ZFS deadlock on db_mtx and dn_holds"
Browse files Browse the repository at this point in the history
This reverts commit 7a32fe7c6b7a86962c5d2db2bf2e58b9b65cb921.
  • Loading branch information
ryao committed Oct 6, 2015
1 parent 387d61b commit 3bb6fd0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
12 changes: 4 additions & 8 deletions include/sys/dbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,6 @@ typedef struct dmu_buf_impl {
*/
uint8_t db_level;

/*
* db_user_mtx protects the two members below it.
* stuff we store for the user (see dmu_buf_set_user)
*/
kmutex_t db_user_mtx;
void *db_user_ptr;
dmu_buf_evict_func_t *db_evict_func;

/* db_mtx protects the members below */
kmutex_t db_mtx;

Expand Down Expand Up @@ -235,6 +227,10 @@ typedef struct dmu_buf_impl {

/* Data which is unique to data (leaf) blocks: */

/* stuff we store for the user (see dmu_buf_set_user) */
void *db_user_ptr;
dmu_buf_evict_func_t *db_evict_func;

uint8_t db_immediate_evict;
uint8_t db_freed_in_flight;

Expand Down
20 changes: 3 additions & 17 deletions module/zfs/dbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ dbuf_cons(void *vdb, void *unused, int kmflag)
dmu_buf_impl_t *db = vdb;
bzero(db, sizeof (dmu_buf_impl_t));

mutex_init(&db->db_user_mtx, NULL, MUTEX_DEFAULT, NULL);
mutex_init(&db->db_mtx, NULL, MUTEX_DEFAULT, NULL);
cv_init(&db->db_changed, NULL, CV_DEFAULT, NULL);
refcount_create(&db->db_holds);
Expand All @@ -104,7 +103,6 @@ static void
dbuf_dest(void *vdb, void *unused)
{
dmu_buf_impl_t *db = vdb;
mutex_destroy(&db->db_user_mtx);
mutex_destroy(&db->db_mtx);
cv_destroy(&db->db_changed);
refcount_destroy(&db->db_holds);
Expand Down Expand Up @@ -270,24 +268,12 @@ dbuf_evict_user(dmu_buf_impl_t *db)
{
ASSERT(MUTEX_HELD(&db->db_mtx));

if (db->db_level != 0)
if (db->db_level != 0 || db->db_evict_func == NULL)
return;

mutex_enter(&db->db_user_mtx);
mutex_exit(&db->db_mtx);

if (db->db_evict_func == NULL) {
mutex_exit(&db->db_user_mtx);
mutex_enter(&db->db_mtx);
return;
}

db->db_evict_func(&db->db, db->db_user_ptr);
db->db_user_ptr = NULL;
db->db_evict_func = NULL;

mutex_exit(&db->db_user_mtx);
mutex_enter(&db->db_mtx);
}

boolean_t
Expand Down Expand Up @@ -2407,7 +2393,7 @@ dmu_buf_update_user(dmu_buf_t *db_fake, void *old_user_ptr, void *user_ptr,

ASSERT((user_ptr == NULL) == (evict_func == NULL));

mutex_enter(&db->db_user_mtx);
mutex_enter(&db->db_mtx);

if (db->db_user_ptr == old_user_ptr) {
db->db_user_ptr = user_ptr;
Expand All @@ -2416,7 +2402,7 @@ dmu_buf_update_user(dmu_buf_t *db_fake, void *old_user_ptr, void *user_ptr,
old_user_ptr = db->db_user_ptr;
}

mutex_exit(&db->db_user_mtx);
mutex_exit(&db->db_mtx);
return (old_user_ptr);
}

Expand Down

0 comments on commit 3bb6fd0

Please sign in to comment.