Print this page
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero


 489 
 490         zap->zap_objset = os;
 491 
 492         if (lt == RW_WRITER)
 493                 dmu_buf_will_dirty(db, tx);
 494 
 495         ASSERT3P(zap->zap_dbuf, ==, db);
 496 
 497         ASSERT(!zap->zap_ismicro ||
 498             zap->zap_m.zap_num_entries <= zap->zap_m.zap_num_chunks);
 499         if (zap->zap_ismicro && tx && adding &&
 500             zap->zap_m.zap_num_entries == zap->zap_m.zap_num_chunks) {
 501                 uint64_t newsz = db->db_size + SPA_MINBLOCKSIZE;
 502                 if (newsz > MZAP_MAX_BLKSZ) {
 503                         dprintf("upgrading obj %llu: num_entries=%u\n",
 504                             obj, zap->zap_m.zap_num_entries);
 505                         *zapp = zap;
 506                         return (mzap_upgrade(zapp, tx, 0));
 507                 }
 508                 err = dmu_object_set_blocksize(os, obj, newsz, 0, tx);
 509                 ASSERT3U(err, ==, 0);
 510                 zap->zap_m.zap_num_chunks =
 511                     db->db_size / MZAP_ENT_LEN - 1;
 512         }
 513 
 514         *zapp = zap;
 515         return (0);
 516 }
 517 
 518 void
 519 zap_unlockdir(zap_t *zap)
 520 {
 521         rw_exit(&zap->zap_rwlock);
 522         dmu_buf_rele(zap->zap_dbuf, NULL);
 523 }
 524 
 525 static int
 526 mzap_upgrade(zap_t **zapp, dmu_tx_t *tx, zap_flags_t flags)
 527 {
 528         mzap_phys_t *mzp;
 529         int i, sz, nchunks;


 584 #ifdef ZFS_DEBUG
 585         {
 586                 dmu_object_info_t doi;
 587                 dmu_object_info_from_db(db, &doi);
 588                 ASSERT3U(DMU_OT_BYTESWAP(doi.doi_type), ==, DMU_BSWAP_ZAP);
 589         }
 590 #endif
 591 
 592         dmu_buf_will_dirty(db, tx);
 593         zp = db->db_data;
 594         zp->mz_block_type = ZBT_MICRO;
 595         zp->mz_salt = ((uintptr_t)db ^ (uintptr_t)tx ^ (obj << 1)) | 1ULL;
 596         zp->mz_normflags = normflags;
 597         dmu_buf_rele(db, FTAG);
 598 
 599         if (flags != 0) {
 600                 zap_t *zap;
 601                 /* Only fat zap supports flags; upgrade immediately. */
 602                 VERIFY(0 == zap_lockdir(os, obj, tx, RW_WRITER,
 603                     B_FALSE, B_FALSE, &zap));
 604                 VERIFY3U(0, ==, mzap_upgrade(&zap, tx, flags));
 605                 zap_unlockdir(zap);
 606         }
 607 }
 608 
 609 int
 610 zap_create_claim(objset_t *os, uint64_t obj, dmu_object_type_t ot,
 611     dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx)
 612 {
 613         return (zap_create_claim_norm(os, obj,
 614             0, ot, bonustype, bonuslen, tx));
 615 }
 616 
 617 int
 618 zap_create_claim_norm(objset_t *os, uint64_t obj, int normflags,
 619     dmu_object_type_t ot,
 620     dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx)
 621 {
 622         int err;
 623 
 624         err = dmu_object_claim(os, obj, ot, 0, bonustype, bonuslen, tx);




 489 
 490         zap->zap_objset = os;
 491 
 492         if (lt == RW_WRITER)
 493                 dmu_buf_will_dirty(db, tx);
 494 
 495         ASSERT3P(zap->zap_dbuf, ==, db);
 496 
 497         ASSERT(!zap->zap_ismicro ||
 498             zap->zap_m.zap_num_entries <= zap->zap_m.zap_num_chunks);
 499         if (zap->zap_ismicro && tx && adding &&
 500             zap->zap_m.zap_num_entries == zap->zap_m.zap_num_chunks) {
 501                 uint64_t newsz = db->db_size + SPA_MINBLOCKSIZE;
 502                 if (newsz > MZAP_MAX_BLKSZ) {
 503                         dprintf("upgrading obj %llu: num_entries=%u\n",
 504                             obj, zap->zap_m.zap_num_entries);
 505                         *zapp = zap;
 506                         return (mzap_upgrade(zapp, tx, 0));
 507                 }
 508                 err = dmu_object_set_blocksize(os, obj, newsz, 0, tx);
 509                 ASSERT0(err);
 510                 zap->zap_m.zap_num_chunks =
 511                     db->db_size / MZAP_ENT_LEN - 1;
 512         }
 513 
 514         *zapp = zap;
 515         return (0);
 516 }
 517 
 518 void
 519 zap_unlockdir(zap_t *zap)
 520 {
 521         rw_exit(&zap->zap_rwlock);
 522         dmu_buf_rele(zap->zap_dbuf, NULL);
 523 }
 524 
 525 static int
 526 mzap_upgrade(zap_t **zapp, dmu_tx_t *tx, zap_flags_t flags)
 527 {
 528         mzap_phys_t *mzp;
 529         int i, sz, nchunks;


 584 #ifdef ZFS_DEBUG
 585         {
 586                 dmu_object_info_t doi;
 587                 dmu_object_info_from_db(db, &doi);
 588                 ASSERT3U(DMU_OT_BYTESWAP(doi.doi_type), ==, DMU_BSWAP_ZAP);
 589         }
 590 #endif
 591 
 592         dmu_buf_will_dirty(db, tx);
 593         zp = db->db_data;
 594         zp->mz_block_type = ZBT_MICRO;
 595         zp->mz_salt = ((uintptr_t)db ^ (uintptr_t)tx ^ (obj << 1)) | 1ULL;
 596         zp->mz_normflags = normflags;
 597         dmu_buf_rele(db, FTAG);
 598 
 599         if (flags != 0) {
 600                 zap_t *zap;
 601                 /* Only fat zap supports flags; upgrade immediately. */
 602                 VERIFY(0 == zap_lockdir(os, obj, tx, RW_WRITER,
 603                     B_FALSE, B_FALSE, &zap));
 604                 VERIFY0(mzap_upgrade(&zap, tx, flags));
 605                 zap_unlockdir(zap);
 606         }
 607 }
 608 
 609 int
 610 zap_create_claim(objset_t *os, uint64_t obj, dmu_object_type_t ot,
 611     dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx)
 612 {
 613         return (zap_create_claim_norm(os, obj,
 614             0, ot, bonustype, bonuslen, tx));
 615 }
 616 
 617 int
 618 zap_create_claim_norm(objset_t *os, uint64_t obj, int normflags,
 619     dmu_object_type_t ot,
 620     dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx)
 621 {
 622         int err;
 623 
 624         err = dmu_object_claim(os, obj, ot, 0, bonustype, bonuslen, tx);