Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Commit

Permalink
Properly destroy work items in spl_kmem_cache_destroy()
Browse files Browse the repository at this point in the history
In a non-debug build the ASSERT() would be optimized away
which could cause pending work items to not be cancelled.

We must also use cancel_delayed_work_sync() rather than just
cancel_delayed_work() to actually wait until work items have
completed.  Otherwise they might accidentally access free'd
memory.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes ZFS bugs #279, #62, #363, #418
  • Loading branch information
gunnarbeutner authored and behlendorf committed Oct 11, 2011
1 parent 763b2f3 commit 64c075c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions module/spl/spl-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1491,10 +1491,10 @@ spl_kmem_cache_destroy(spl_kmem_cache_t *skc)
up_write(&spl_kmem_cache_sem);

/* Cancel any and wait for any pending delayed work */
ASSERT(!test_and_set_bit(KMC_BIT_DESTROY, &skc->skc_flags));
cancel_delayed_work(&skc->skc_work);
VERIFY(!test_and_set_bit(KMC_BIT_DESTROY, &skc->skc_flags));
cancel_delayed_work_sync(&skc->skc_work);
for_each_online_cpu(i)
cancel_delayed_work(&skc->skc_mag[i]->skm_work);
cancel_delayed_work_sync(&skc->skc_mag[i]->skm_work);

flush_scheduled_work();

Expand Down

0 comments on commit 64c075c

Please sign in to comment.