ztest.c (243505) | ztest.c (243524) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 190 unchanged lines hidden (view full) --- 199 (MAX(zs->zs_mirrors, 1) * (ztest_opts.zo_raidz_parity + 1) - 1) 200 201enum ztest_io_type { 202 ZTEST_IO_WRITE_TAG, 203 ZTEST_IO_WRITE_PATTERN, 204 ZTEST_IO_WRITE_ZEROES, 205 ZTEST_IO_TRUNCATE, 206 ZTEST_IO_SETATTR, | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 190 unchanged lines hidden (view full) --- 199 (MAX(zs->zs_mirrors, 1) * (ztest_opts.zo_raidz_parity + 1) - 1) 200 201enum ztest_io_type { 202 ZTEST_IO_WRITE_TAG, 203 ZTEST_IO_WRITE_PATTERN, 204 ZTEST_IO_WRITE_ZEROES, 205 ZTEST_IO_TRUNCATE, 206 ZTEST_IO_SETATTR, |
207 ZTEST_IO_REWRITE, |
|
207 ZTEST_IO_TYPES 208}; 209 210typedef struct ztest_block_tag { 211 uint64_t bt_magic; 212 uint64_t bt_objset; 213 uint64_t bt_object; 214 uint64_t bt_offset; --- 1647 unchanged lines hidden (view full) --- 1862 1863 zgd->zgd_rl = ztest_range_lock(zd, object, offset, size, 1864 RL_READER); 1865 1866 error = dmu_buf_hold(os, object, offset, zgd, &db, 1867 DMU_READ_NO_PREFETCH); 1868 1869 if (error == 0) { | 208 ZTEST_IO_TYPES 209}; 210 211typedef struct ztest_block_tag { 212 uint64_t bt_magic; 213 uint64_t bt_objset; 214 uint64_t bt_object; 215 uint64_t bt_offset; --- 1647 unchanged lines hidden (view full) --- 1863 1864 zgd->zgd_rl = ztest_range_lock(zd, object, offset, size, 1865 RL_READER); 1866 1867 error = dmu_buf_hold(os, object, offset, zgd, &db, 1868 DMU_READ_NO_PREFETCH); 1869 1870 if (error == 0) { |
1871 blkptr_t *obp = dmu_buf_get_blkptr(db); 1872 if (obp) { 1873 ASSERT(BP_IS_HOLE(bp)); 1874 *bp = *obp; 1875 } 1876 |
|
1870 zgd->zgd_db = db; 1871 zgd->zgd_bp = bp; 1872 1873 ASSERT(db->db_offset == offset); 1874 ASSERT(db->db_size == size); 1875 1876 error = dmu_sync(zio, lr->lr_common.lrc_txg, 1877 ztest_get_done, zgd); --- 129 unchanged lines hidden (view full) --- 2007 od += count - 1; 2008 2009 for (int i = count - 1; i >= 0; i--, od--) { 2010 if (missing) { 2011 missing++; 2012 continue; 2013 } 2014 | 1877 zgd->zgd_db = db; 1878 zgd->zgd_bp = bp; 1879 1880 ASSERT(db->db_offset == offset); 1881 ASSERT(db->db_size == size); 1882 1883 error = dmu_sync(zio, lr->lr_common.lrc_txg, 1884 ztest_get_done, zgd); --- 129 unchanged lines hidden (view full) --- 2014 od += count - 1; 2015 2016 for (int i = count - 1; i >= 0; i--, od--) { 2017 if (missing) { 2018 missing++; 2019 continue; 2020 } 2021 |
2022 /* 2023 * No object was found. 2024 */ |
|
2015 if (od->od_object == 0) 2016 continue; 2017 2018 lr_remove_t *lr = ztest_lr_alloc(sizeof (*lr), od->od_name); 2019 2020 lr->lr_doid = od->od_dir; 2021 2022 if ((error = ztest_replay_remove(zd, lr, B_FALSE)) != 0) { --- 99 unchanged lines hidden (view full) --- 2122 2123 ztest_range_unlock(rl); 2124 ztest_object_unlock(zd, object); 2125} 2126 2127static void 2128ztest_io(ztest_ds_t *zd, uint64_t object, uint64_t offset) 2129{ | 2025 if (od->od_object == 0) 2026 continue; 2027 2028 lr_remove_t *lr = ztest_lr_alloc(sizeof (*lr), od->od_name); 2029 2030 lr->lr_doid = od->od_dir; 2031 2032 if ((error = ztest_replay_remove(zd, lr, B_FALSE)) != 0) { --- 99 unchanged lines hidden (view full) --- 2132 2133 ztest_range_unlock(rl); 2134 ztest_object_unlock(zd, object); 2135} 2136 2137static void 2138ztest_io(ztest_ds_t *zd, uint64_t object, uint64_t offset) 2139{ |
2140 int err; |
|
2130 ztest_block_tag_t wbt; 2131 dmu_object_info_t doi; 2132 enum ztest_io_type io_type; 2133 uint64_t blocksize; 2134 void *data; 2135 2136 VERIFY(dmu_object_info(zd->zd_os, object, &doi) == 0); 2137 blocksize = doi.doi_data_block_size; --- 36 unchanged lines hidden (view full) --- 2174 2175 case ZTEST_IO_TRUNCATE: 2176 (void) ztest_truncate(zd, object, offset, blocksize); 2177 break; 2178 2179 case ZTEST_IO_SETATTR: 2180 (void) ztest_setattr(zd, object); 2181 break; | 2141 ztest_block_tag_t wbt; 2142 dmu_object_info_t doi; 2143 enum ztest_io_type io_type; 2144 uint64_t blocksize; 2145 void *data; 2146 2147 VERIFY(dmu_object_info(zd->zd_os, object, &doi) == 0); 2148 blocksize = doi.doi_data_block_size; --- 36 unchanged lines hidden (view full) --- 2185 2186 case ZTEST_IO_TRUNCATE: 2187 (void) ztest_truncate(zd, object, offset, blocksize); 2188 break; 2189 2190 case ZTEST_IO_SETATTR: 2191 (void) ztest_setattr(zd, object); 2192 break; |
2193 2194 case ZTEST_IO_REWRITE: 2195 (void) rw_rdlock(&ztest_name_lock); 2196 err = ztest_dsl_prop_set_uint64(zd->zd_name, 2197 ZFS_PROP_CHECKSUM, spa_dedup_checksum(ztest_spa), 2198 B_FALSE); 2199 VERIFY(err == 0 || err == ENOSPC); 2200 err = ztest_dsl_prop_set_uint64(zd->zd_name, 2201 ZFS_PROP_COMPRESSION, 2202 ztest_random_dsl_prop(ZFS_PROP_COMPRESSION), 2203 B_FALSE); 2204 VERIFY(err == 0 || err == ENOSPC); 2205 (void) rw_unlock(&ztest_name_lock); 2206 2207 VERIFY0(dmu_read(zd->zd_os, object, offset, blocksize, data, 2208 DMU_READ_NO_PREFETCH)); 2209 2210 (void) ztest_write(zd, object, offset, blocksize, data); 2211 break; |
|
2182 } 2183 2184 (void) rw_unlock(&zd->zd_zilog_lock); 2185 2186 umem_free(data, blocksize); 2187} 2188 2189/* --- 71 unchanged lines hidden (view full) --- 2261 * attempt to expose any implicit assumptions about ZIL management. 2262 */ 2263/* ARGSUSED */ 2264void 2265ztest_zil_remount(ztest_ds_t *zd, uint64_t id) 2266{ 2267 objset_t *os = zd->zd_os; 2268 | 2212 } 2213 2214 (void) rw_unlock(&zd->zd_zilog_lock); 2215 2216 umem_free(data, blocksize); 2217} 2218 2219/* --- 71 unchanged lines hidden (view full) --- 2291 * attempt to expose any implicit assumptions about ZIL management. 2292 */ 2293/* ARGSUSED */ 2294void 2295ztest_zil_remount(ztest_ds_t *zd, uint64_t id) 2296{ 2297 objset_t *os = zd->zd_os; 2298 |
2269 VERIFY(mutex_lock(&zd->zd_dirobj_lock) == 0); | 2299 /* 2300 * We grab the zd_dirobj_lock to ensure that no other thread is 2301 * updating the zil (i.e. adding in-memory log records) and the 2302 * zd_zilog_lock to block any I/O. 2303 */ 2304 VERIFY0(mutex_lock(&zd->zd_dirobj_lock)); |
2270 (void) rw_wrlock(&zd->zd_zilog_lock); 2271 2272 /* zfsvfs_teardown() */ 2273 zil_close(zd->zd_zilog); 2274 2275 /* zfsvfs_setup() */ 2276 VERIFY(zil_open(os, ztest_get_data) == zd->zd_zilog); 2277 zil_replay(os, zd, ztest_replay_vector); --- 2642 unchanged lines hidden (view full) --- 4920 return; 4921 } 4922 4923 /* 4924 * Write all the copies of our block. 4925 */ 4926 for (int i = 0; i < copies; i++) { 4927 uint64_t offset = i * blocksize; | 2305 (void) rw_wrlock(&zd->zd_zilog_lock); 2306 2307 /* zfsvfs_teardown() */ 2308 zil_close(zd->zd_zilog); 2309 2310 /* zfsvfs_setup() */ 2311 VERIFY(zil_open(os, ztest_get_data) == zd->zd_zilog); 2312 zil_replay(os, zd, ztest_replay_vector); --- 2642 unchanged lines hidden (view full) --- 4955 return; 4956 } 4957 4958 /* 4959 * Write all the copies of our block. 4960 */ 4961 for (int i = 0; i < copies; i++) { 4962 uint64_t offset = i * blocksize; |
4928 VERIFY(dmu_buf_hold(os, object, offset, FTAG, &db, 4929 DMU_READ_NO_PREFETCH) == 0); | 4963 VERIFY0(dmu_buf_hold(os, object, offset, FTAG, &db, 4964 DMU_READ_NO_PREFETCH)); |
4930 ASSERT(db->db_offset == offset); 4931 ASSERT(db->db_size == blocksize); 4932 ASSERT(ztest_pattern_match(db->db_data, db->db_size, pattern) || 4933 ztest_pattern_match(db->db_data, db->db_size, 0ULL)); 4934 dmu_buf_will_fill(db, tx); 4935 ztest_pattern_set(db->db_data, db->db_size, pattern); 4936 dmu_buf_rele(db, FTAG); 4937 } 4938 4939 dmu_tx_commit(tx); 4940 txg_wait_synced(spa_get_dsl(spa), txg); 4941 4942 /* 4943 * Find out what block we got. 4944 */ | 4965 ASSERT(db->db_offset == offset); 4966 ASSERT(db->db_size == blocksize); 4967 ASSERT(ztest_pattern_match(db->db_data, db->db_size, pattern) || 4968 ztest_pattern_match(db->db_data, db->db_size, 0ULL)); 4969 dmu_buf_will_fill(db, tx); 4970 ztest_pattern_set(db->db_data, db->db_size, pattern); 4971 dmu_buf_rele(db, FTAG); 4972 } 4973 4974 dmu_tx_commit(tx); 4975 txg_wait_synced(spa_get_dsl(spa), txg); 4976 4977 /* 4978 * Find out what block we got. 4979 */ |
4945 VERIFY(dmu_buf_hold(os, object, 0, FTAG, &db, 4946 DMU_READ_NO_PREFETCH) == 0); | 4980 VERIFY0(dmu_buf_hold(os, object, 0, FTAG, &db, 4981 DMU_READ_NO_PREFETCH)); |
4947 blk = *((dmu_buf_impl_t *)db)->db_blkptr; 4948 dmu_buf_rele(db, FTAG); 4949 4950 /* 4951 * Damage the block. Dedup-ditto will save us when we read it later. 4952 */ 4953 psize = BP_GET_PSIZE(&blk); 4954 buf = zio_buf_alloc(psize); --- 661 unchanged lines hidden (view full) --- 5616 int numloops = 0; 5617 5618 if (ztest_opts.zo_verbose >= 3) 5619 (void) printf("testing spa_freeze()...\n"); 5620 5621 kernel_init(FREAD | FWRITE); 5622 VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG)); 5623 VERIFY3U(0, ==, ztest_dataset_open(0)); | 4982 blk = *((dmu_buf_impl_t *)db)->db_blkptr; 4983 dmu_buf_rele(db, FTAG); 4984 4985 /* 4986 * Damage the block. Dedup-ditto will save us when we read it later. 4987 */ 4988 psize = BP_GET_PSIZE(&blk); 4989 buf = zio_buf_alloc(psize); --- 661 unchanged lines hidden (view full) --- 5651 int numloops = 0; 5652 5653 if (ztest_opts.zo_verbose >= 3) 5654 (void) printf("testing spa_freeze()...\n"); 5655 5656 kernel_init(FREAD | FWRITE); 5657 VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG)); 5658 VERIFY3U(0, ==, ztest_dataset_open(0)); |
5659 spa->spa_debug = B_TRUE; 5660 ztest_spa = spa; |
|
5624 5625 /* 5626 * Force the first log block to be transactionally allocated. 5627 * We have to do this before we freeze the pool -- otherwise 5628 * the log chain won't be anchored. 5629 */ 5630 while (BP_IS_HOLE(&zd->zd_zilog->zl_header->zh_log)) { 5631 ztest_dmu_object_alloc_free(zd, 0); --- 541 unchanged lines hidden --- | 5661 5662 /* 5663 * Force the first log block to be transactionally allocated. 5664 * We have to do this before we freeze the pool -- otherwise 5665 * the log chain won't be anchored. 5666 */ 5667 while (BP_IS_HOLE(&zd->zd_zilog->zl_header->zh_log)) { 5668 ztest_dmu_object_alloc_free(zd, 0); --- 541 unchanged lines hidden --- |