zap.c (307287) | zap.c (307292) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 256 unchanged lines hidden (view full) --- 265} 266 267static int 268zap_table_load(zap_t *zap, zap_table_phys_t *tbl, uint64_t idx, uint64_t *valp) 269{ 270 uint64_t blk, off; 271 int err; 272 dmu_buf_t *db; | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 256 unchanged lines hidden (view full) --- 265} 266 267static int 268zap_table_load(zap_t *zap, zap_table_phys_t *tbl, uint64_t idx, uint64_t *valp) 269{ 270 uint64_t blk, off; 271 int err; 272 dmu_buf_t *db; |
273 dnode_t *dn; |
|
273 int bs = FZAP_BLOCK_SHIFT(zap); 274 275 ASSERT(RW_LOCK_HELD(&zap->zap_rwlock)); 276 277 blk = idx >> (bs-3); 278 off = idx & ((1<<(bs-3))-1); 279 | 274 int bs = FZAP_BLOCK_SHIFT(zap); 275 276 ASSERT(RW_LOCK_HELD(&zap->zap_rwlock)); 277 278 blk = idx >> (bs-3); 279 off = idx & ((1<<(bs-3))-1); 280 |
280 err = dmu_buf_hold(zap->zap_objset, zap->zap_object, | 281 /* 282 * Note: this is equivalent to dmu_buf_hold(), but we use 283 * _dnode_enter / _by_dnode because it's faster because we don't 284 * have to hold the dnode. 285 */ 286 dn = dmu_buf_dnode_enter(zap->zap_dbuf); 287 err = dmu_buf_hold_by_dnode(dn, |
281 (tbl->zt_blk + blk) << bs, FTAG, &db, DMU_READ_NO_PREFETCH); | 288 (tbl->zt_blk + blk) << bs, FTAG, &db, DMU_READ_NO_PREFETCH); |
289 dmu_buf_dnode_exit(zap->zap_dbuf); |
|
282 if (err) 283 return (err); 284 *valp = ((uint64_t *)db->db_data)[off]; 285 dmu_buf_rele(db, FTAG); 286 287 if (tbl->zt_nextblk != 0) { 288 /* 289 * read the nextblk for the sake of i/o error checking, 290 * so that zap_table_load() will catch errors for 291 * zap_table_store. 292 */ 293 blk = (idx*2) >> (bs-3); 294 | 290 if (err) 291 return (err); 292 *valp = ((uint64_t *)db->db_data)[off]; 293 dmu_buf_rele(db, FTAG); 294 295 if (tbl->zt_nextblk != 0) { 296 /* 297 * read the nextblk for the sake of i/o error checking, 298 * so that zap_table_load() will catch errors for 299 * zap_table_store. 300 */ 301 blk = (idx*2) >> (bs-3); 302 |
295 err = dmu_buf_hold(zap->zap_objset, zap->zap_object, | 303 dn = dmu_buf_dnode_enter(zap->zap_dbuf); 304 err = dmu_buf_hold_by_dnode(dn, |
296 (tbl->zt_nextblk + blk) << bs, FTAG, &db, 297 DMU_READ_NO_PREFETCH); | 305 (tbl->zt_nextblk + blk) << bs, FTAG, &db, 306 DMU_READ_NO_PREFETCH); |
307 dmu_buf_dnode_exit(zap->zap_dbuf); |
|
298 if (err == 0) 299 dmu_buf_rele(db, FTAG); 300 } 301 return (err); 302} 303 304/* 305 * Routines for growing the ptrtbl. --- 194 unchanged lines hidden (view full) --- 500{ 501 dmu_buf_t *db; 502 zap_leaf_t *l; 503 int bs = FZAP_BLOCK_SHIFT(zap); 504 int err; 505 506 ASSERT(RW_LOCK_HELD(&zap->zap_rwlock)); 507 | 308 if (err == 0) 309 dmu_buf_rele(db, FTAG); 310 } 311 return (err); 312} 313 314/* 315 * Routines for growing the ptrtbl. --- 194 unchanged lines hidden (view full) --- 510{ 511 dmu_buf_t *db; 512 zap_leaf_t *l; 513 int bs = FZAP_BLOCK_SHIFT(zap); 514 int err; 515 516 ASSERT(RW_LOCK_HELD(&zap->zap_rwlock)); 517 |
508 err = dmu_buf_hold(zap->zap_objset, zap->zap_object, | 518 dnode_t *dn = dmu_buf_dnode_enter(zap->zap_dbuf); 519 err = dmu_buf_hold_by_dnode(dn, |
509 blkid << bs, NULL, &db, DMU_READ_NO_PREFETCH); | 520 blkid << bs, NULL, &db, DMU_READ_NO_PREFETCH); |
521 dmu_buf_dnode_exit(zap->zap_dbuf); |
|
510 if (err) 511 return (err); 512 513 ASSERT3U(db->db_object, ==, zap->zap_object); 514 ASSERT3U(db->db_offset, ==, blkid << bs); 515 ASSERT3U(db->db_size, ==, 1 << bs); 516 ASSERT(blkid != 0); 517 --- 882 unchanged lines hidden --- | 522 if (err) 523 return (err); 524 525 ASSERT3U(db->db_object, ==, zap->zap_object); 526 ASSERT3U(db->db_offset, ==, blkid << bs); 527 ASSERT3U(db->db_size, ==, 1 << bs); 528 ASSERT(blkid != 0); 529 --- 882 unchanged lines hidden --- |