Skip to content
Permalink
Browse files

renaming zthr funcs

  • Loading branch information...
shartse committed Apr 3, 2019
1 parent db80cf0 commit 737c2020b9689e11498511d3b5d58ffcd729c031
Showing with 35 additions and 35 deletions.
  1. +2 −2 include/sys/zthr.h
  2. +1 −1 module/zfs/dsl_deadlist.c
  3. +13 −13 module/zfs/dsl_dir.c
  4. +2 −2 module/zfs/spa.c
  5. +17 −17 module/zfs/zthr.c
@@ -33,9 +33,9 @@ extern void zthr_destroy(zthr_t *t);
extern void zthr_wakeup(zthr_t *t);
extern void zthr_cancel(zthr_t *t);
extern void zthr_resume(zthr_t *t);
extern void zthr_finish(zthr_t *t);
extern void zthr_wait_cycle_done(zthr_t *t);

extern boolean_t zthr_iscancelled(zthr_t *t);
extern boolean_t zthr_isfinishing(zthr_t *t);
extern boolean_t zthr_has_waiters(zthr_t *t);

#endif /* _SYS_ZTHR_H */
@@ -822,7 +822,7 @@ dsl_livelist_iterate(void *arg, const blkptr_t *bp, boolean_t free,
zthr_t *t = lia->t;
ASSERT(tx == NULL);

if ((t != NULL) && (zthr_isfinishing(t) || zthr_iscancelled(t)))
if ((t != NULL) && (zthr_has_waiters(t) || zthr_iscancelled(t)))
return (EINTR);
if (free) {
livelist_entry_t *node = kmem_alloc(sizeof (livelist_entry_t),
@@ -2280,22 +2280,22 @@ dsl_dir_remove_livelist(dsl_dir_t *dd, dmu_tx_t *tx, boolean_t total)
if (ll_condense_thread != NULL &&
(to_condense.ds != NULL) && (to_condense.ds->ds_dir == dd)) {
/*
* We use zthr_finish instead of zthr_cancel because we
* don't want to destroy the zthr, just have it skip
* it's current task.
* We use zthr_wait_cycle_done instead of zthr_cancel
* because we don't want to destroy the zthr, just have
* it skip it's current task.
*/
spa->spa_to_condense.cancelled = B_TRUE;
zthr_finish(ll_condense_thread);
zthr_wait_cycle_done(ll_condense_thread);
/*
* If we've returned from zthr_finish without clearing
* the to_condense data structure it's either because
* the no-wait synctask has started (which is indicated
* by 'syncing' field of to_condense) and we can expect
* it to clear to_condense on its own. Otherwise, we
* returned before the zthr ran. The checkfunc will
* now fail as cancelled == B_TRUE so we can safely NULL
* out ds, allowing a different dir's livelist to be
* condensed.
* If we've returned from zthr_wait_cycle_done without
* clearing the to_condense data structure it's either
* because the no-wait synctask has started (which is
* indicated by 'syncing' field of to_condense) and we
* can expect it to clear to_condense on its own.
* Otherwise, we returned before the zthr ran. The
* checkfunc will now fail as cancelled == B_TRUE so we
* can safely NULL out ds, allowing a different dir's
* livelist to be condensed.
*
* We can be sure that the to_condense struct will not
* be repopulated at this stage because both this
@@ -2569,7 +2569,7 @@ void
spa_livelist_condense_cb(void *arg, zthr_t *t)
{
while (zfs_livelist_condense_zthr_pause &&
!(zthr_isfinishing(t) || zthr_iscancelled(t)))
!(zthr_has_waiters(t) || zthr_iscancelled(t)))
delay(1);

int err;
@@ -2587,7 +2587,7 @@ spa_livelist_condense_cb(void *arg, zthr_t *t)

if (err == 0) {
while (zfs_livelist_condense_sync_pause &&
!(zthr_isfinishing(t) || zthr_iscancelled(t)))
!(zthr_has_waiters(t) || zthr_iscancelled(t)))
delay(1);

dmu_tx_t *tx = dmu_tx_create_dd(spa_get_dsl(spa)->dp_mos_dir);
@@ -208,8 +208,8 @@ struct zthr {
boolean_t zthr_cancel;

/* flag set to true if we are waiting for the zthr to finish */
boolean_t zthr_finish;
kcondvar_t zthr_finish_cv;
boolean_t zthr_haswaiters;
kcondvar_t zthr_wait_cv;
/*
* maximum amount of time that the zthr is spent sleeping;
* if this is 0, the thread doesn't wake up until it gets
@@ -246,9 +246,9 @@ zthr_procedure(void *arg)
MSEC2NSEC(1), 0);
}
}
if (t->zthr_finish) {
t->zthr_finish = B_FALSE;
cv_broadcast(&t->zthr_finish_cv);
if (t->zthr_haswaiters) {
t->zthr_haswaiters = B_FALSE;
cv_broadcast(&t->zthr_wait_cv);
}
}

@@ -283,7 +283,7 @@ zthr_create_timer(zthr_checkfunc_t *checkfunc, zthr_func_t *func,
mutex_init(&t->zthr_state_lock, NULL, MUTEX_DEFAULT, NULL);
mutex_init(&t->zthr_request_lock, NULL, MUTEX_DEFAULT, NULL);
cv_init(&t->zthr_cv, NULL, CV_DEFAULT, NULL);
cv_init(&t->zthr_finish_cv, NULL, CV_DEFAULT, NULL);
cv_init(&t->zthr_wait_cv, NULL, CV_DEFAULT, NULL);

mutex_enter(&t->zthr_state_lock);
t->zthr_checkfunc = checkfunc;
@@ -307,7 +307,7 @@ zthr_destroy(zthr_t *t)
mutex_destroy(&t->zthr_request_lock);
mutex_destroy(&t->zthr_state_lock);
cv_destroy(&t->zthr_cv);
cv_destroy(&t->zthr_finish_cv);
cv_destroy(&t->zthr_wait_cv);
kmem_free(t, sizeof (*t));
}

@@ -401,7 +401,7 @@ zthr_resume(zthr_t *t)
ASSERT3P(&t->zthr_checkfunc, !=, NULL);
ASSERT3P(&t->zthr_func, !=, NULL);
ASSERT(!t->zthr_cancel);
ASSERT(!t->zthr_finish);
ASSERT(!t->zthr_haswaiters);

/*
* There are 4 states that we find the zthr in at this point
@@ -459,12 +459,12 @@ zthr_iscancelled(zthr_t *t)

/*
* Wait for the zthr to finish its current function. Similar to
* zthr_iscancelled, you can use zthr_isfinishing to have the zthr_func end
* zthr_iscancelled, you can use zthr_has_waiters to have the zthr_func end
* early. Unlike zthr_cancel, the thread is not destroyed. If the zthr was
* sleeping or cancelled, return immediately.
*/
void
zthr_finish(zthr_t *t)
zthr_wait_cycle_done(zthr_t *t)
{
mutex_enter(&t->zthr_state_lock);

@@ -489,15 +489,15 @@ zthr_finish(zthr_t *t)
* zthr_func.
*/
if (t->zthr_thread != NULL) {
t->zthr_finish = B_TRUE;
t->zthr_haswaiters = B_TRUE;

/* broadcast in case the zthr is sleeping */
cv_broadcast(&t->zthr_cv);

while ((t->zthr_finish) && (t->zthr_thread != NULL))
cv_wait(&t->zthr_finish_cv, &t->zthr_state_lock);
while ((t->zthr_haswaiters) && (t->zthr_thread != NULL))
cv_wait(&t->zthr_wait_cv, &t->zthr_state_lock);

ASSERT(!t->zthr_finish);
ASSERT(!t->zthr_haswaiters);
}

mutex_exit(&t->zthr_state_lock);
@@ -512,7 +512,7 @@ zthr_finish(zthr_t *t)
* returns FALSE otherwise.
*/
boolean_t
zthr_isfinishing(zthr_t *t)
zthr_has_waiters(zthr_t *t)
{
ASSERT3P(t->zthr_thread, ==, curthread);

@@ -523,7 +523,7 @@ zthr_isfinishing(zthr_t *t)
* zthr_state_lock so that the zthr itself can use this
* to check for the request.
*/
boolean_t finish = t->zthr_finish;
boolean_t has_waiters = t->zthr_haswaiters;
mutex_exit(&t->zthr_state_lock);
return (finish);
return (has_waiters);
}

0 comments on commit 737c202

Please sign in to comment.
You can’t perform that action at this time.