53 * to the dp_config_rwlock -- the lock will always be held when the callbacks
54 * are called. It will be held for read during the open-context (preliminary)
55 * call to the checkfunc, and then held for write from syncing context during
56 * the calls to the check and sync funcs.
57 *
58 * A dataset or pool name can be passed as the first argument. Typically,
59 * the check func will hold, check the return value of the hold, and then
60 * release the dataset. The sync func will VERIFYO(hold()) the dataset.
61 * This is safe because no changes can be made between the check and sync funcs,
62 * and the sync func will only be called if the check func successfully opened
63 * the dataset.
64 */
65 int
66 dsl_sync_task(const char *pool, dsl_checkfunc_t *checkfunc,
67 dsl_syncfunc_t *syncfunc, void *arg,
68 int blocks_modified, zfs_space_check_t space_check)
69 {
70 spa_t *spa;
71 dmu_tx_t *tx;
72 int err;
73 dsl_sync_task_t dst = { 0 };
74 dsl_pool_t *dp;
75
76 err = spa_open(pool, &spa, FTAG);
77 if (err != 0)
78 return (err);
79 dp = spa_get_dsl(spa);
80
81 top:
82 tx = dmu_tx_create_dd(dp->dp_mos_dir);
83 VERIFY0(dmu_tx_assign(tx, TXG_WAIT));
84
85 dst.dst_pool = dp;
86 dst.dst_txg = dmu_tx_get_txg(tx);
87 dst.dst_space = blocks_modified << DST_AVG_BLKSHIFT;
88 dst.dst_space_check = space_check;
89 dst.dst_checkfunc = checkfunc != NULL ? checkfunc : dsl_null_checkfunc;
90 dst.dst_syncfunc = syncfunc;
91 dst.dst_arg = arg;
92 dst.dst_error = 0;
93 dst.dst_nowaiter = B_FALSE;
|
53 * to the dp_config_rwlock -- the lock will always be held when the callbacks
54 * are called. It will be held for read during the open-context (preliminary)
55 * call to the checkfunc, and then held for write from syncing context during
56 * the calls to the check and sync funcs.
57 *
58 * A dataset or pool name can be passed as the first argument. Typically,
59 * the check func will hold, check the return value of the hold, and then
60 * release the dataset. The sync func will VERIFYO(hold()) the dataset.
61 * This is safe because no changes can be made between the check and sync funcs,
62 * and the sync func will only be called if the check func successfully opened
63 * the dataset.
64 */
65 int
66 dsl_sync_task(const char *pool, dsl_checkfunc_t *checkfunc,
67 dsl_syncfunc_t *syncfunc, void *arg,
68 int blocks_modified, zfs_space_check_t space_check)
69 {
70 spa_t *spa;
71 dmu_tx_t *tx;
72 int err;
73 dsl_sync_task_t dst = { .dst_error = 0 };
74 dsl_pool_t *dp;
75
76 err = spa_open(pool, &spa, FTAG);
77 if (err != 0)
78 return (err);
79 dp = spa_get_dsl(spa);
80
81 top:
82 tx = dmu_tx_create_dd(dp->dp_mos_dir);
83 VERIFY0(dmu_tx_assign(tx, TXG_WAIT));
84
85 dst.dst_pool = dp;
86 dst.dst_txg = dmu_tx_get_txg(tx);
87 dst.dst_space = blocks_modified << DST_AVG_BLKSHIFT;
88 dst.dst_space_check = space_check;
89 dst.dst_checkfunc = checkfunc != NULL ? checkfunc : dsl_null_checkfunc;
90 dst.dst_syncfunc = syncfunc;
91 dst.dst_arg = arg;
92 dst.dst_error = 0;
93 dst.dst_nowaiter = B_FALSE;
|