SLOW_WORK: Wait for outstanding work items belonging to a module to clear

Wait for outstanding slow work items belonging to a module to clear when
unregistering that module as a user of the facility.  This prevents the put_ref
code of a work item from being taken away before it returns.

Signed-off-by: David Howells <[email protected]>
This commit is contained in:
David Howells 2009-11-19 18:10:23 +00:00
commit 3d7a641e54
8 changed files with 150 additions and 16 deletions

View file

@ -48,7 +48,7 @@ static int __init fscache_init(void)
{
int ret;
ret = slow_work_register_user();
ret = slow_work_register_user(THIS_MODULE);
if (ret < 0)
goto error_slow_work;
@ -80,7 +80,7 @@ error_kobj:
error_cookie_jar:
fscache_proc_cleanup();
error_proc:
slow_work_unregister_user();
slow_work_unregister_user(THIS_MODULE);
error_slow_work:
return ret;
}
@ -97,7 +97,7 @@ static void __exit fscache_exit(void)
kobject_put(fscache_root);
kmem_cache_destroy(fscache_cookie_jar);
fscache_proc_cleanup();
slow_work_unregister_user();
slow_work_unregister_user(THIS_MODULE);
printk(KERN_NOTICE "FS-Cache: Unloaded\n");
}

View file

@ -45,6 +45,7 @@ static void fscache_enqueue_dependents(struct fscache_object *);
static void fscache_dequeue_object(struct fscache_object *);
const struct slow_work_ops fscache_object_slow_work_ops = {
.owner = THIS_MODULE,
.get_ref = fscache_object_slow_work_get_ref,
.put_ref = fscache_object_slow_work_put_ref,
.execute = fscache_object_slow_work_execute,

View file

@ -453,6 +453,7 @@ static void fscache_op_execute(struct slow_work *work)
}
const struct slow_work_ops fscache_op_slow_work_ops = {
.owner = THIS_MODULE,
.get_ref = fscache_op_get_ref,
.put_ref = fscache_op_put_ref,
.execute = fscache_op_execute,