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

Function ztest_dmu_prealloc

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

Source from the content-addressed store, hash-verified

5072}
5073
5074void
5075ztest_dmu_prealloc(ztest_ds_t *zd, uint64_t id)
5076{
5077 ztest_od_t *od;
5078 uint64_t offset = (1ULL << (ztest_random(4) + SPA_MAXBLOCKSHIFT)) +
5079 (ztest_random(ZTEST_RANGE_LOCKS) << SPA_MAXBLOCKSHIFT);
5080 uint64_t count = ztest_random(20) + 1;
5081 uint64_t blocksize = ztest_random_blocksize();
5082 void *data;
5083
5084 od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL);
5085
5086 ztest_od_init(od, id, FTAG, 0, DMU_OT_UINT64_OTHER, blocksize, 0, 0);
5087
5088 if (ztest_object_init(zd, od, sizeof (ztest_od_t),
5089 !ztest_random(2)) != 0) {
5090 umem_free(od, sizeof (ztest_od_t));
5091 return;
5092 }
5093
5094 if (ztest_truncate(zd, od->od_object, offset, count * blocksize) != 0) {
5095 umem_free(od, sizeof (ztest_od_t));
5096 return;
5097 }
5098
5099 ztest_prealloc(zd, od->od_object, offset, count * blocksize);
5100
5101 data = umem_zalloc(blocksize, UMEM_NOFAIL);
5102
5103 while (ztest_random(count) != 0) {
5104 uint64_t randoff = offset + (ztest_random(count) * blocksize);
5105 if (ztest_write(zd, od->od_object, randoff, blocksize,
5106 data) != 0)
5107 break;
5108 while (ztest_random(4) != 0)
5109 ztest_io(zd, od->od_object, randoff);
5110 }
5111
5112 umem_free(data, blocksize);
5113 umem_free(od, sizeof (ztest_od_t));
5114}
5115
5116/*
5117 * Verify that zap_{create,destroy,add,remove,update} work as expected.

Callers

nothing calls this directly

Calls 11

ztest_randomFunction · 0.85
ztest_random_blocksizeFunction · 0.85
umem_allocFunction · 0.85
ztest_od_initFunction · 0.85
ztest_object_initFunction · 0.85
umem_freeFunction · 0.85
ztest_truncateFunction · 0.85
ztest_preallocFunction · 0.85
umem_zallocFunction · 0.85
ztest_writeFunction · 0.85
ztest_ioFunction · 0.85

Tested by

no test coverage detected