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


 329             tx->tx_txg == TXG_INITIAL));
 330 
 331         spa->spa_feat_for_read_obj = zap_create_link(spa->spa_meta_objset,
 332             DMU_OTN_ZAP_METADATA, DMU_POOL_DIRECTORY_OBJECT,
 333             DMU_POOL_FEATURES_FOR_READ, tx);
 334         spa->spa_feat_for_write_obj = zap_create_link(spa->spa_meta_objset,
 335             DMU_OTN_ZAP_METADATA, DMU_POOL_DIRECTORY_OBJECT,
 336             DMU_POOL_FEATURES_FOR_WRITE, tx);
 337         spa->spa_feat_desc_obj = zap_create_link(spa->spa_meta_objset,
 338             DMU_OTN_ZAP_METADATA, DMU_POOL_DIRECTORY_OBJECT,
 339             DMU_POOL_FEATURE_DESCRIPTIONS, tx);
 340 }
 341 
 342 /*
 343  * Enable any required dependencies, then enable the requested feature.
 344  */
 345 void
 346 spa_feature_enable(spa_t *spa, zfeature_info_t *feature, dmu_tx_t *tx)
 347 {
 348         ASSERT3U(spa_version(spa), >=, SPA_VERSION_FEATURES);
 349         VERIFY3U(0, ==, feature_do_action(spa->spa_meta_objset,
 350             spa->spa_feat_for_read_obj, spa->spa_feat_for_write_obj,
 351             spa->spa_feat_desc_obj, feature, FEATURE_ACTION_ENABLE, tx));
 352 }
 353 
 354 /*
 355  * If the specified feature has not yet been enabled, this function returns
 356  * ENOTSUP; otherwise, this function increments the feature's refcount (or
 357  * returns EOVERFLOW if the refcount cannot be incremented). This function must
 358  * be called from syncing context.
 359  */
 360 void
 361 spa_feature_incr(spa_t *spa, zfeature_info_t *feature, dmu_tx_t *tx)
 362 {
 363         ASSERT3U(spa_version(spa), >=, SPA_VERSION_FEATURES);
 364         VERIFY3U(0, ==, feature_do_action(spa->spa_meta_objset,
 365             spa->spa_feat_for_read_obj, spa->spa_feat_for_write_obj,
 366             spa->spa_feat_desc_obj, feature, FEATURE_ACTION_INCR, tx));
 367 }
 368 
 369 /*
 370  * If the specified feature has not yet been enabled, this function returns
 371  * ENOTSUP; otherwise, this function decrements the feature's refcount (or
 372  * returns EOVERFLOW if the refcount is already 0). This function must
 373  * be called from syncing context.
 374  */
 375 void
 376 spa_feature_decr(spa_t *spa, zfeature_info_t *feature, dmu_tx_t *tx)
 377 {
 378         ASSERT3U(spa_version(spa), >=, SPA_VERSION_FEATURES);
 379         VERIFY3U(0, ==, feature_do_action(spa->spa_meta_objset,
 380             spa->spa_feat_for_read_obj, spa->spa_feat_for_write_obj,
 381             spa->spa_feat_desc_obj, feature, FEATURE_ACTION_DECR, tx));
 382 }
 383 
 384 boolean_t
 385 spa_feature_is_enabled(spa_t *spa, zfeature_info_t *feature)
 386 {
 387         int err;
 388         uint64_t refcount;
 389 
 390         if (spa_version(spa) < SPA_VERSION_FEATURES)
 391                 return (B_FALSE);
 392 
 393         err = feature_get_refcount(spa->spa_meta_objset,
 394             spa->spa_feat_for_read_obj, spa->spa_feat_for_write_obj,
 395             feature, &refcount);
 396         ASSERT(err == 0 || err == ENOTSUP);
 397         return (err == 0);
 398 }
 399 


 329             tx->tx_txg == TXG_INITIAL));
 330 
 331         spa->spa_feat_for_read_obj = zap_create_link(spa->spa_meta_objset,
 332             DMU_OTN_ZAP_METADATA, DMU_POOL_DIRECTORY_OBJECT,
 333             DMU_POOL_FEATURES_FOR_READ, tx);
 334         spa->spa_feat_for_write_obj = zap_create_link(spa->spa_meta_objset,
 335             DMU_OTN_ZAP_METADATA, DMU_POOL_DIRECTORY_OBJECT,
 336             DMU_POOL_FEATURES_FOR_WRITE, tx);
 337         spa->spa_feat_desc_obj = zap_create_link(spa->spa_meta_objset,
 338             DMU_OTN_ZAP_METADATA, DMU_POOL_DIRECTORY_OBJECT,
 339             DMU_POOL_FEATURE_DESCRIPTIONS, tx);
 340 }
 341 
 342 /*
 343  * Enable any required dependencies, then enable the requested feature.
 344  */
 345 void
 346 spa_feature_enable(spa_t *spa, zfeature_info_t *feature, dmu_tx_t *tx)
 347 {
 348         ASSERT3U(spa_version(spa), >=, SPA_VERSION_FEATURES);
 349         VERIFY0(feature_do_action(spa->spa_meta_objset,
 350             spa->spa_feat_for_read_obj, spa->spa_feat_for_write_obj,
 351             spa->spa_feat_desc_obj, feature, FEATURE_ACTION_ENABLE, tx));
 352 }
 353 
 354 /*
 355  * If the specified feature has not yet been enabled, this function returns
 356  * ENOTSUP; otherwise, this function increments the feature's refcount (or
 357  * returns EOVERFLOW if the refcount cannot be incremented). This function must
 358  * be called from syncing context.
 359  */
 360 void
 361 spa_feature_incr(spa_t *spa, zfeature_info_t *feature, dmu_tx_t *tx)
 362 {
 363         ASSERT3U(spa_version(spa), >=, SPA_VERSION_FEATURES);
 364         VERIFY0(feature_do_action(spa->spa_meta_objset,
 365             spa->spa_feat_for_read_obj, spa->spa_feat_for_write_obj,
 366             spa->spa_feat_desc_obj, feature, FEATURE_ACTION_INCR, tx));
 367 }
 368 
 369 /*
 370  * If the specified feature has not yet been enabled, this function returns
 371  * ENOTSUP; otherwise, this function decrements the feature's refcount (or
 372  * returns EOVERFLOW if the refcount is already 0). This function must
 373  * be called from syncing context.
 374  */
 375 void
 376 spa_feature_decr(spa_t *spa, zfeature_info_t *feature, dmu_tx_t *tx)
 377 {
 378         ASSERT3U(spa_version(spa), >=, SPA_VERSION_FEATURES);
 379         VERIFY0(feature_do_action(spa->spa_meta_objset,
 380             spa->spa_feat_for_read_obj, spa->spa_feat_for_write_obj,
 381             spa->spa_feat_desc_obj, feature, FEATURE_ACTION_DECR, tx));
 382 }
 383 
 384 boolean_t
 385 spa_feature_is_enabled(spa_t *spa, zfeature_info_t *feature)
 386 {
 387         int err;
 388         uint64_t refcount;
 389 
 390         if (spa_version(spa) < SPA_VERSION_FEATURES)
 391                 return (B_FALSE);
 392 
 393         err = feature_get_refcount(spa->spa_meta_objset,
 394             spa->spa_feat_for_read_obj, spa->spa_feat_for_write_obj,
 395             feature, &refcount);
 396         ASSERT(err == 0 || err == ENOTSUP);
 397         return (err == 0);
 398 }
 399