MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ztest_fzap

Function ztest_fzap

freebsd/contrib/openzfs/cmd/ztest/ztest.c:5267–5309  ·  view source on GitHub ↗

* Test case to test the upgrading of a microzap to fatzap. */

Source from the content-addressed store, hash-verified

5265 * Test case to test the upgrading of a microzap to fatzap.
5266 */
5267void
5268ztest_fzap(ztest_ds_t *zd, uint64_t id)
5269{
5270 objset_t *os = zd->zd_os;
5271 ztest_od_t *od;
5272 uint64_t object, txg;
5273 int i;
5274
5275 od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL);
5276 ztest_od_init(od, id, FTAG, 0, DMU_OT_ZAP_OTHER, 0, 0, 0);
5277
5278 if (ztest_object_init(zd, od, sizeof (ztest_od_t),
5279 !ztest_random(2)) != 0)
5280 goto out;
5281 object = od->od_object;
5282
5283 /*
5284 * Add entries to this ZAP and make sure it spills over
5285 * and gets upgraded to a fatzap. Also, since we are adding
5286 * 2050 entries we should see ptrtbl growth and leaf-block split.
5287 */
5288 for (i = 0; i < 2050; i++) {
5289 char name[ZFS_MAX_DATASET_NAME_LEN];
5290 uint64_t value = i;
5291 dmu_tx_t *tx;
5292 int error;
5293
5294 (void) snprintf(name, sizeof (name), "fzap-%llu-%llu",
5295 (u_longlong_t)id, (u_longlong_t)value);
5296
5297 tx = dmu_tx_create(os);
5298 dmu_tx_hold_zap(tx, object, B_TRUE, name);
5299 txg = ztest_tx_assign(tx, TXG_MIGHTWAIT, FTAG);
5300 if (txg == 0)
5301 goto out;
5302 error = zap_add(os, object, name, sizeof (uint64_t), 1,
5303 &value, tx);
5304 ASSERT(error == 0 || error == EEXIST);
5305 dmu_tx_commit(tx);
5306 }
5307out:
5308 umem_free(od, sizeof (ztest_od_t));
5309}
5310
5311/* ARGSUSED */
5312void

Callers

nothing calls this directly

Calls 11

umem_allocFunction · 0.85
ztest_od_initFunction · 0.85
ztest_object_initFunction · 0.85
ztest_randomFunction · 0.85
snprintfFunction · 0.85
dmu_tx_createFunction · 0.85
dmu_tx_hold_zapFunction · 0.85
ztest_tx_assignFunction · 0.85
zap_addFunction · 0.85
dmu_tx_commitFunction · 0.85
umem_freeFunction · 0.85

Tested by

no test coverage detected