Print this page
4171 clean up spa_feature_*() interfaces
4172 implement extensible_dataset feature for use by other zpool features
Reviewed by: Max Grossman <max.grossman@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>


 555 
 556         for (i = 0; i < nchunks; i++) {
 557                 mzap_ent_phys_t *mze = &mzp->mz_chunk[i];
 558                 zap_name_t *zn;
 559                 if (mze->mze_name[0] == 0)
 560                         continue;
 561                 dprintf("adding %s=%llu\n",
 562                     mze->mze_name, mze->mze_value);
 563                 zn = zap_name_alloc(zap, mze->mze_name, MT_EXACT);
 564                 err = fzap_add_cd(zn, 8, 1, &mze->mze_value, mze->mze_cd, tx);
 565                 zap = zn->zn_zap;    /* fzap_add_cd() may change zap */
 566                 zap_name_free(zn);
 567                 if (err)
 568                         break;
 569         }
 570         kmem_free(mzp, sz);
 571         *zapp = zap;
 572         return (err);
 573 }
 574 
 575 static void
 576 mzap_create_impl(objset_t *os, uint64_t obj, int normflags, zap_flags_t flags,
 577     dmu_tx_t *tx)
 578 {
 579         dmu_buf_t *db;
 580         mzap_phys_t *zp;
 581 
 582         VERIFY(0 == dmu_buf_hold(os, obj, 0, FTAG, &db, DMU_READ_NO_PREFETCH));
 583 
 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;


 845 
 846         err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap);
 847         if (err)
 848                 return (err);
 849         zn = zap_name_alloc_uint64(zap, key, key_numints);
 850         if (zn == NULL) {
 851                 zap_unlockdir(zap);
 852                 return (SET_ERROR(ENOTSUP));
 853         }
 854 
 855         err = fzap_lookup(zn, integer_size, num_integers, buf,
 856             NULL, 0, NULL);
 857         zap_name_free(zn);
 858         zap_unlockdir(zap);
 859         return (err);
 860 }
 861 
 862 int
 863 zap_contains(objset_t *os, uint64_t zapobj, const char *name)
 864 {
 865         int err = (zap_lookup_norm(os, zapobj, name, 0,
 866             0, NULL, MT_EXACT, NULL, 0, NULL));
 867         if (err == EOVERFLOW || err == EINVAL)
 868                 err = 0; /* found, but skipped reading the value */
 869         return (err);
 870 }
 871 
 872 int
 873 zap_length(objset_t *os, uint64_t zapobj, const char *name,
 874     uint64_t *integer_size, uint64_t *num_integers)
 875 {
 876         zap_t *zap;
 877         int err;
 878         mzap_ent_t *mze;
 879         zap_name_t *zn;
 880 
 881         err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap);
 882         if (err)
 883                 return (err);
 884         zn = zap_name_alloc(zap, name, MT_EXACT);
 885         if (zn == NULL) {
 886                 zap_unlockdir(zap);




 555 
 556         for (i = 0; i < nchunks; i++) {
 557                 mzap_ent_phys_t *mze = &mzp->mz_chunk[i];
 558                 zap_name_t *zn;
 559                 if (mze->mze_name[0] == 0)
 560                         continue;
 561                 dprintf("adding %s=%llu\n",
 562                     mze->mze_name, mze->mze_value);
 563                 zn = zap_name_alloc(zap, mze->mze_name, MT_EXACT);
 564                 err = fzap_add_cd(zn, 8, 1, &mze->mze_value, mze->mze_cd, tx);
 565                 zap = zn->zn_zap;    /* fzap_add_cd() may change zap */
 566                 zap_name_free(zn);
 567                 if (err)
 568                         break;
 569         }
 570         kmem_free(mzp, sz);
 571         *zapp = zap;
 572         return (err);
 573 }
 574 
 575 void
 576 mzap_create_impl(objset_t *os, uint64_t obj, int normflags, zap_flags_t flags,
 577     dmu_tx_t *tx)
 578 {
 579         dmu_buf_t *db;
 580         mzap_phys_t *zp;
 581 
 582         VERIFY(0 == dmu_buf_hold(os, obj, 0, FTAG, &db, DMU_READ_NO_PREFETCH));
 583 
 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;


 845 
 846         err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap);
 847         if (err)
 848                 return (err);
 849         zn = zap_name_alloc_uint64(zap, key, key_numints);
 850         if (zn == NULL) {
 851                 zap_unlockdir(zap);
 852                 return (SET_ERROR(ENOTSUP));
 853         }
 854 
 855         err = fzap_lookup(zn, integer_size, num_integers, buf,
 856             NULL, 0, NULL);
 857         zap_name_free(zn);
 858         zap_unlockdir(zap);
 859         return (err);
 860 }
 861 
 862 int
 863 zap_contains(objset_t *os, uint64_t zapobj, const char *name)
 864 {
 865         int err = zap_lookup_norm(os, zapobj, name, 0,
 866             0, NULL, MT_EXACT, NULL, 0, NULL);
 867         if (err == EOVERFLOW || err == EINVAL)
 868                 err = 0; /* found, but skipped reading the value */
 869         return (err);
 870 }
 871 
 872 int
 873 zap_length(objset_t *os, uint64_t zapobj, const char *name,
 874     uint64_t *integer_size, uint64_t *num_integers)
 875 {
 876         zap_t *zap;
 877         int err;
 878         mzap_ent_t *mze;
 879         zap_name_t *zn;
 880 
 881         err = zap_lockdir(os, zapobj, NULL, RW_READER, TRUE, FALSE, &zap);
 882         if (err)
 883                 return (err);
 884         zn = zap_name_alloc(zap, name, MT_EXACT);
 885         if (zn == NULL) {
 886                 zap_unlockdir(zap);