* Drops db_mtx and the parent lock specified by dblt and tag before * returning. */
| 1435 | * returning. |
| 1436 | */ |
| 1437 | static int |
| 1438 | dbuf_read_impl(dmu_buf_impl_t *db, zio_t *zio, uint32_t flags, |
| 1439 | db_lock_type_t dblt, void *tag) |
| 1440 | { |
| 1441 | dnode_t *dn; |
| 1442 | zbookmark_phys_t zb; |
| 1443 | uint32_t aflags = ARC_FLAG_NOWAIT; |
| 1444 | int err, zio_flags; |
| 1445 | boolean_t bonus_read; |
| 1446 | |
| 1447 | err = zio_flags = 0; |
| 1448 | bonus_read = B_FALSE; |
| 1449 | DB_DNODE_ENTER(db); |
| 1450 | dn = DB_DNODE(db); |
| 1451 | ASSERT(!zfs_refcount_is_zero(&db->db_holds)); |
| 1452 | ASSERT(MUTEX_HELD(&db->db_mtx)); |
| 1453 | ASSERT(db->db_state == DB_UNCACHED); |
| 1454 | ASSERT(db->db_buf == NULL); |
| 1455 | ASSERT(db->db_parent == NULL || |
| 1456 | RW_LOCK_HELD(&db->db_parent->db_rwlock)); |
| 1457 | |
| 1458 | if (db->db_blkid == DMU_BONUS_BLKID) { |
| 1459 | err = dbuf_read_bonus(db, dn, flags); |
| 1460 | goto early_unlock; |
| 1461 | } |
| 1462 | |
| 1463 | err = dbuf_read_hole(db, dn, flags); |
| 1464 | if (err == 0) |
| 1465 | goto early_unlock; |
| 1466 | |
| 1467 | /* |
| 1468 | * Any attempt to read a redacted block should result in an error. This |
| 1469 | * will never happen under normal conditions, but can be useful for |
| 1470 | * debugging purposes. |
| 1471 | */ |
| 1472 | if (BP_IS_REDACTED(db->db_blkptr)) { |
| 1473 | ASSERT(dsl_dataset_feature_is_active( |
| 1474 | db->db_objset->os_dsl_dataset, |
| 1475 | SPA_FEATURE_REDACTED_DATASETS)); |
| 1476 | err = SET_ERROR(EIO); |
| 1477 | goto early_unlock; |
| 1478 | } |
| 1479 | |
| 1480 | SET_BOOKMARK(&zb, dmu_objset_id(db->db_objset), |
| 1481 | db->db.db_object, db->db_level, db->db_blkid); |
| 1482 | |
| 1483 | /* |
| 1484 | * All bps of an encrypted os should have the encryption bit set. |
| 1485 | * If this is not true it indicates tampering and we report an error. |
| 1486 | */ |
| 1487 | if (db->db_objset->os_encrypted && !BP_USES_CRYPT(db->db_blkptr)) { |
| 1488 | spa_log_error(db->db_objset->os_spa, &zb); |
| 1489 | zfs_panic_recover("unencrypted block in encrypted " |
| 1490 | "object set %llu", dmu_objset_id(db->db_objset)); |
| 1491 | err = SET_ERROR(EIO); |
| 1492 | goto early_unlock; |
| 1493 | } |
| 1494 |
no test coverage detected