Print this page
4045 zfs write throttle & i/o scheduler performance work
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>


 167         .zo_alt_libpath = { '\0' },
 168         .zo_vdevs = 5,
 169         .zo_ashift = SPA_MINBLOCKSHIFT,
 170         .zo_mirrors = 2,
 171         .zo_raidz = 4,
 172         .zo_raidz_parity = 1,
 173         .zo_vdev_size = SPA_MINDEVSIZE,
 174         .zo_datasets = 7,
 175         .zo_threads = 23,
 176         .zo_passtime = 60,              /* 60 seconds */
 177         .zo_killrate = 70,              /* 70% kill rate */
 178         .zo_verbose = 0,
 179         .zo_init = 1,
 180         .zo_time = 300,                 /* 5 minutes */
 181         .zo_maxloops = 50,              /* max loops during spa_freeze() */
 182         .zo_metaslab_gang_bang = 32 << 10
 183 };
 184 
 185 extern uint64_t metaslab_gang_bang;
 186 extern uint64_t metaslab_df_alloc_threshold;
 187 extern uint64_t zfs_deadman_synctime;
 188 
 189 static ztest_shared_opts_t *ztest_shared_opts;
 190 static ztest_shared_opts_t ztest_opts;
 191 
 192 typedef struct ztest_shared_ds {
 193         uint64_t        zd_seq;
 194 } ztest_shared_ds_t;
 195 
 196 static ztest_shared_ds_t *ztest_shared_ds;
 197 #define ZTEST_GET_SHARED_DS(d) (&ztest_shared_ds[d])
 198 
 199 #define BT_MAGIC        0x123456789abcdefULL
 200 #define MAXFAULTS() \
 201         (MAX(zs->zs_mirrors, 1) * (ztest_opts.zo_raidz_parity + 1) - 1)
 202 
 203 enum ztest_io_type {
 204         ZTEST_IO_WRITE_TAG,
 205         ZTEST_IO_WRITE_PATTERN,
 206         ZTEST_IO_WRITE_ZEROES,
 207         ZTEST_IO_TRUNCATE,


5308 ztest_resume_thread(void *arg)
5309 {
5310         spa_t *spa = arg;
5311 
5312         while (!ztest_exiting) {
5313                 if (spa_suspended(spa))
5314                         ztest_resume(spa);
5315                 (void) poll(NULL, 0, 100);
5316         }
5317         return (NULL);
5318 }
5319 
5320 static void *
5321 ztest_deadman_thread(void *arg)
5322 {
5323         ztest_shared_t *zs = arg;
5324         spa_t *spa = ztest_spa;
5325         hrtime_t delta, total = 0;
5326 
5327         for (;;) {
5328                 delta = (zs->zs_thread_stop - zs->zs_thread_start) /
5329                     NANOSEC + zfs_deadman_synctime;
5330 
5331                 (void) poll(NULL, 0, (int)(1000 * delta));
5332 
5333                 /*
5334                  * If the pool is suspended then fail immediately. Otherwise,
5335                  * check to see if the pool is making any progress. If
5336                  * vdev_deadman() discovers that there hasn't been any recent
5337                  * I/Os then it will end up aborting the tests.
5338                  */
5339                 if (spa_suspended(spa)) {
5340                         fatal(0, "aborting test after %llu seconds because "
5341                             "pool has transitioned to a suspended state.",
5342                             zfs_deadman_synctime);
5343                         return (NULL);
5344                 }
5345                 vdev_deadman(spa->spa_root_vdev);
5346 
5347                 total += zfs_deadman_synctime;
5348                 (void) printf("ztest has been running for %lld seconds\n",
5349                     total);
5350         }
5351 }
5352 
5353 static void
5354 ztest_execute(int test, ztest_info_t *zi, uint64_t id)
5355 {
5356         ztest_ds_t *zd = &ztest_ds[id % ztest_opts.zo_datasets];
5357         ztest_shared_callstate_t *zc = ZTEST_GET_SHARED_CALLSTATE(test);
5358         hrtime_t functime = gethrtime();
5359 
5360         for (int i = 0; i < zi->zi_iters; i++)
5361                 zi->zi_func(zd, id);
5362 
5363         functime = gethrtime() - functime;
5364 
5365         atomic_add_64(&zc->zc_count, 1);
5366         atomic_add_64(&zc->zc_time, functime);
5367 


6056 int
6057 main(int argc, char **argv)
6058 {
6059         int kills = 0;
6060         int iters = 0;
6061         int older = 0;
6062         int newer = 0;
6063         ztest_shared_t *zs;
6064         ztest_info_t *zi;
6065         ztest_shared_callstate_t *zc;
6066         char timebuf[100];
6067         char numbuf[6];
6068         spa_t *spa;
6069         char *cmd;
6070         boolean_t hasalt;
6071         char *fd_data_str = getenv("ZTEST_FD_DATA");
6072 
6073         (void) setvbuf(stdout, NULL, _IOLBF, 0);
6074 
6075         dprintf_setup(&argc, argv);
6076         zfs_deadman_synctime = 300;
6077 
6078         ztest_fd_rand = open("/dev/urandom", O_RDONLY);
6079         ASSERT3S(ztest_fd_rand, >=, 0);
6080 
6081         if (!fd_data_str) {
6082                 process_options(argc, argv);
6083 
6084                 setup_data_fd();
6085                 setup_hdr();
6086                 setup_data();
6087                 bcopy(&ztest_opts, ztest_shared_opts,
6088                     sizeof (*ztest_shared_opts));
6089         } else {
6090                 ztest_fd_data = atoi(fd_data_str);
6091                 setup_data();
6092                 bcopy(ztest_shared_opts, &ztest_opts, sizeof (ztest_opts));
6093         }
6094         ASSERT3U(ztest_opts.zo_datasets, ==, ztest_shared_hdr->zh_ds_count);
6095 
6096         /* Override location of zpool.cache */




 167         .zo_alt_libpath = { '\0' },
 168         .zo_vdevs = 5,
 169         .zo_ashift = SPA_MINBLOCKSHIFT,
 170         .zo_mirrors = 2,
 171         .zo_raidz = 4,
 172         .zo_raidz_parity = 1,
 173         .zo_vdev_size = SPA_MINDEVSIZE,
 174         .zo_datasets = 7,
 175         .zo_threads = 23,
 176         .zo_passtime = 60,              /* 60 seconds */
 177         .zo_killrate = 70,              /* 70% kill rate */
 178         .zo_verbose = 0,
 179         .zo_init = 1,
 180         .zo_time = 300,                 /* 5 minutes */
 181         .zo_maxloops = 50,              /* max loops during spa_freeze() */
 182         .zo_metaslab_gang_bang = 32 << 10
 183 };
 184 
 185 extern uint64_t metaslab_gang_bang;
 186 extern uint64_t metaslab_df_alloc_threshold;
 187 extern uint64_t zfs_deadman_synctime_ms;
 188 
 189 static ztest_shared_opts_t *ztest_shared_opts;
 190 static ztest_shared_opts_t ztest_opts;
 191 
 192 typedef struct ztest_shared_ds {
 193         uint64_t        zd_seq;
 194 } ztest_shared_ds_t;
 195 
 196 static ztest_shared_ds_t *ztest_shared_ds;
 197 #define ZTEST_GET_SHARED_DS(d) (&ztest_shared_ds[d])
 198 
 199 #define BT_MAGIC        0x123456789abcdefULL
 200 #define MAXFAULTS() \
 201         (MAX(zs->zs_mirrors, 1) * (ztest_opts.zo_raidz_parity + 1) - 1)
 202 
 203 enum ztest_io_type {
 204         ZTEST_IO_WRITE_TAG,
 205         ZTEST_IO_WRITE_PATTERN,
 206         ZTEST_IO_WRITE_ZEROES,
 207         ZTEST_IO_TRUNCATE,


5308 ztest_resume_thread(void *arg)
5309 {
5310         spa_t *spa = arg;
5311 
5312         while (!ztest_exiting) {
5313                 if (spa_suspended(spa))
5314                         ztest_resume(spa);
5315                 (void) poll(NULL, 0, 100);
5316         }
5317         return (NULL);
5318 }
5319 
5320 static void *
5321 ztest_deadman_thread(void *arg)
5322 {
5323         ztest_shared_t *zs = arg;
5324         spa_t *spa = ztest_spa;
5325         hrtime_t delta, total = 0;
5326 
5327         for (;;) {
5328                 delta = zs->zs_thread_stop - zs->zs_thread_start +
5329                     MSEC2NSEC(zfs_deadman_synctime_ms);
5330 
5331                 (void) poll(NULL, 0, (int)NSEC2MSEC(delta));
5332 
5333                 /*
5334                  * If the pool is suspended then fail immediately. Otherwise,
5335                  * check to see if the pool is making any progress. If
5336                  * vdev_deadman() discovers that there hasn't been any recent
5337                  * I/Os then it will end up aborting the tests.
5338                  */
5339                 if (spa_suspended(spa)) {
5340                         fatal(0, "aborting test after %llu seconds because "
5341                             "pool has transitioned to a suspended state.",
5342                             zfs_deadman_synctime_ms / 1000);
5343                         return (NULL);
5344                 }
5345                 vdev_deadman(spa->spa_root_vdev);
5346 
5347                 total += zfs_deadman_synctime_ms/1000;
5348                 (void) printf("ztest has been running for %lld seconds\n",
5349                     total);
5350         }
5351 }
5352 
5353 static void
5354 ztest_execute(int test, ztest_info_t *zi, uint64_t id)
5355 {
5356         ztest_ds_t *zd = &ztest_ds[id % ztest_opts.zo_datasets];
5357         ztest_shared_callstate_t *zc = ZTEST_GET_SHARED_CALLSTATE(test);
5358         hrtime_t functime = gethrtime();
5359 
5360         for (int i = 0; i < zi->zi_iters; i++)
5361                 zi->zi_func(zd, id);
5362 
5363         functime = gethrtime() - functime;
5364 
5365         atomic_add_64(&zc->zc_count, 1);
5366         atomic_add_64(&zc->zc_time, functime);
5367 


6056 int
6057 main(int argc, char **argv)
6058 {
6059         int kills = 0;
6060         int iters = 0;
6061         int older = 0;
6062         int newer = 0;
6063         ztest_shared_t *zs;
6064         ztest_info_t *zi;
6065         ztest_shared_callstate_t *zc;
6066         char timebuf[100];
6067         char numbuf[6];
6068         spa_t *spa;
6069         char *cmd;
6070         boolean_t hasalt;
6071         char *fd_data_str = getenv("ZTEST_FD_DATA");
6072 
6073         (void) setvbuf(stdout, NULL, _IOLBF, 0);
6074 
6075         dprintf_setup(&argc, argv);
6076         zfs_deadman_synctime_ms = 300000;
6077 
6078         ztest_fd_rand = open("/dev/urandom", O_RDONLY);
6079         ASSERT3S(ztest_fd_rand, >=, 0);
6080 
6081         if (!fd_data_str) {
6082                 process_options(argc, argv);
6083 
6084                 setup_data_fd();
6085                 setup_hdr();
6086                 setup_data();
6087                 bcopy(&ztest_opts, ztest_shared_opts,
6088                     sizeof (*ztest_shared_opts));
6089         } else {
6090                 ztest_fd_data = atoi(fd_data_str);
6091                 setup_data();
6092                 bcopy(ztest_shared_opts, &ztest_opts, sizeof (ztest_opts));
6093         }
6094         ASSERT3U(ztest_opts.zo_datasets, ==, ztest_shared_hdr->zh_ds_count);
6095 
6096         /* Override location of zpool.cache */