* Loan out an arc_buf for read. Return the loaned arc_buf. */
| 1138 | * Loan out an arc_buf for read. Return the loaned arc_buf. |
| 1139 | */ |
| 1140 | arc_buf_t * |
| 1141 | dbuf_loan_arcbuf(dmu_buf_impl_t *db) |
| 1142 | { |
| 1143 | arc_buf_t *abuf; |
| 1144 | |
| 1145 | ASSERT(db->db_blkid != DMU_BONUS_BLKID); |
| 1146 | mutex_enter(&db->db_mtx); |
| 1147 | if (arc_released(db->db_buf) || zfs_refcount_count(&db->db_holds) > 1) { |
| 1148 | int blksz = db->db.db_size; |
| 1149 | spa_t *spa = db->db_objset->os_spa; |
| 1150 | |
| 1151 | mutex_exit(&db->db_mtx); |
| 1152 | abuf = arc_loan_buf(spa, B_FALSE, blksz); |
| 1153 | bcopy(db->db.db_data, abuf->b_data, blksz); |
| 1154 | } else { |
| 1155 | abuf = db->db_buf; |
| 1156 | arc_loan_inuse_buf(abuf, db); |
| 1157 | db->db_buf = NULL; |
| 1158 | dbuf_clear_data(db); |
| 1159 | mutex_exit(&db->db_mtx); |
| 1160 | } |
| 1161 | return (abuf); |
| 1162 | } |
| 1163 | |
| 1164 | /* |
| 1165 | * Calculate which level n block references the data at the level 0 offset |
nothing calls this directly
no test coverage detected