dbuf_try_add_ref minor bug fixes

- Don't check db->bb_blkid, but use the blkid argument instead.
  Checking db->db_blkid may be unsafe since we doesn't yet have a
  hold on the dbuf so its validity is unknown.

- Call mutex_exit() on found_db, not db, since it's not certain that
  they point to the same dbuf, and the mutex was taken on found_db.

Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #3443
This commit is contained in:
Ned Bass 2015-05-28 16:14:19 -07:00 committed by Brian Behlendorf
parent 4f38c25910
commit d617648c7f

View File

@ -2251,7 +2251,7 @@ dbuf_try_add_ref(dmu_buf_t *db_fake, objset_t *os, uint64_t obj, uint64_t blkid,
dmu_buf_impl_t *found_db;
boolean_t result = B_FALSE;
if (db->db_blkid == DMU_BONUS_BLKID)
if (blkid == DMU_BONUS_BLKID)
found_db = dbuf_find_bonus(os, obj);
else
found_db = dbuf_find(os, obj, 0, blkid);
@ -2261,7 +2261,7 @@ dbuf_try_add_ref(dmu_buf_t *db_fake, objset_t *os, uint64_t obj, uint64_t blkid,
(void) refcount_add(&db->db_holds, tag);
result = B_TRUE;
}
mutex_exit(&db->db_mtx);
mutex_exit(&found_db->db_mtx);
}
return (result);
}