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

Function ztest_io

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

Source from the content-addressed store, hash-verified

2603}
2604
2605static void
2606ztest_io(ztest_ds_t *zd, uint64_t object, uint64_t offset)
2607{
2608 int err;
2609 ztest_block_tag_t wbt;
2610 dmu_object_info_t doi;
2611 enum ztest_io_type io_type;
2612 uint64_t blocksize;
2613 void *data;
2614
2615 VERIFY(dmu_object_info(zd->zd_os, object, &doi) == 0);
2616 blocksize = doi.doi_data_block_size;
2617 data = umem_alloc(blocksize, UMEM_NOFAIL);
2618
2619 /*
2620 * Pick an i/o type at random, biased toward writing block tags.
2621 */
2622 io_type = ztest_random(ZTEST_IO_TYPES);
2623 if (ztest_random(2) == 0)
2624 io_type = ZTEST_IO_WRITE_TAG;
2625
2626 (void) pthread_rwlock_rdlock(&zd->zd_zilog_lock);
2627
2628 switch (io_type) {
2629
2630 case ZTEST_IO_WRITE_TAG:
2631 ztest_bt_generate(&wbt, zd->zd_os, object, doi.doi_dnodesize,
2632 offset, 0, 0, 0);
2633 (void) ztest_write(zd, object, offset, sizeof (wbt), &wbt);
2634 break;
2635
2636 case ZTEST_IO_WRITE_PATTERN:
2637 (void) memset(data, 'a' + (object + offset) % 5, blocksize);
2638 if (ztest_random(2) == 0) {
2639 /*
2640 * Induce fletcher2 collisions to ensure that
2641 * zio_ddt_collision() detects and resolves them
2642 * when using fletcher2-verify for deduplication.
2643 */
2644 ((uint64_t *)data)[0] ^= 1ULL << 63;
2645 ((uint64_t *)data)[4] ^= 1ULL << 63;
2646 }
2647 (void) ztest_write(zd, object, offset, blocksize, data);
2648 break;
2649
2650 case ZTEST_IO_WRITE_ZEROES:
2651 bzero(data, blocksize);
2652 (void) ztest_write(zd, object, offset, blocksize, data);
2653 break;
2654
2655 case ZTEST_IO_TRUNCATE:
2656 (void) ztest_truncate(zd, object, offset, blocksize);
2657 break;
2658
2659 case ZTEST_IO_SETATTR:
2660 (void) ztest_setattr(zd, object);
2661 break;
2662 default:

Callers 4

ztest_dmu_write_parallelFunction · 0.85
ztest_dmu_preallocFunction · 0.85
ztest_freezeFunction · 0.85

Calls 14

umem_allocFunction · 0.85
ztest_randomFunction · 0.85
ztest_bt_generateFunction · 0.85
ztest_writeFunction · 0.85
memsetFunction · 0.85
bzeroFunction · 0.85
ztest_truncateFunction · 0.85
ztest_setattrFunction · 0.85
spa_dedup_checksumFunction · 0.85
ztest_random_dsl_propFunction · 0.85
dmu_readFunction · 0.85

Tested by

no test coverage detected