| 5072 | } |
| 5073 | |
| 5074 | void |
| 5075 | ztest_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. |
nothing calls this directly
no test coverage detected