Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d7a641e authored by David Howells's avatar David Howells
Browse files

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: default avatarDavid Howells <dhowells@redhat.com>
parent 66b00a7c
Loading
Loading
Loading
Loading
+10 −3
Original line number Original line Diff line number Diff line
@@ -64,9 +64,11 @@ USING SLOW WORK ITEMS
Firstly, a module or subsystem wanting to make use of slow work items must
Firstly, a module or subsystem wanting to make use of slow work items must
register its interest:
register its interest:


	 int ret = slow_work_register_user();
	 int ret = slow_work_register_user(struct module *module);


This will return 0 if successful, or a -ve error upon failure.
This will return 0 if successful, or a -ve error upon failure.  The module
pointer should be the module interested in using this facility (almost
certainly THIS_MODULE).




Slow work items may then be set up by:
Slow work items may then be set up by:
@@ -110,7 +112,12 @@ operation. When all a module's slow work items have been processed, and the
module has no further interest in the facility, it should unregister its
module has no further interest in the facility, it should unregister its
interest:
interest:


	slow_work_unregister_user();
	slow_work_unregister_user(struct module *module);

The module pointer is used to wait for all outstanding work items for that
module before completing the unregistration.  This prevents the put_ref() code
from being taken away before it completes.  module should almost certainly be
THIS_MODULE.




===============
===============
+3 −3
Original line number Original line Diff line number Diff line
@@ -48,7 +48,7 @@ static int __init fscache_init(void)
{
{
	int ret;
	int ret;


	ret = slow_work_register_user();
	ret = slow_work_register_user(THIS_MODULE);
	if (ret < 0)
	if (ret < 0)
		goto error_slow_work;
		goto error_slow_work;


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


+1 −0
Original line number Original line Diff line number Diff line
@@ -45,6 +45,7 @@ static void fscache_enqueue_dependents(struct fscache_object *);
static void fscache_dequeue_object(struct fscache_object *);
static void fscache_dequeue_object(struct fscache_object *);


const struct slow_work_ops fscache_object_slow_work_ops = {
const struct slow_work_ops fscache_object_slow_work_ops = {
	.owner		= THIS_MODULE,
	.get_ref	= fscache_object_slow_work_get_ref,
	.get_ref	= fscache_object_slow_work_get_ref,
	.put_ref	= fscache_object_slow_work_put_ref,
	.put_ref	= fscache_object_slow_work_put_ref,
	.execute	= fscache_object_slow_work_execute,
	.execute	= fscache_object_slow_work_execute,
+1 −0
Original line number Original line Diff line number Diff line
@@ -453,6 +453,7 @@ static void fscache_op_execute(struct slow_work *work)
}
}


const struct slow_work_ops fscache_op_slow_work_ops = {
const struct slow_work_ops fscache_op_slow_work_ops = {
	.owner		= THIS_MODULE,
	.get_ref	= fscache_op_get_ref,
	.get_ref	= fscache_op_get_ref,
	.put_ref	= fscache_op_put_ref,
	.put_ref	= fscache_op_put_ref,
	.execute	= fscache_op_execute,
	.execute	= fscache_op_execute,
+2 −2
Original line number Original line Diff line number Diff line
@@ -114,7 +114,7 @@ static int __init init_gfs2_fs(void)
	if (error)
	if (error)
		goto fail_unregister;
		goto fail_unregister;


	error = slow_work_register_user();
	error = slow_work_register_user(THIS_MODULE);
	if (error)
	if (error)
		goto fail_slow;
		goto fail_slow;


@@ -163,7 +163,7 @@ static void __exit exit_gfs2_fs(void)
	gfs2_unregister_debugfs();
	gfs2_unregister_debugfs();
	unregister_filesystem(&gfs2_fs_type);
	unregister_filesystem(&gfs2_fs_type);
	unregister_filesystem(&gfs2meta_fs_type);
	unregister_filesystem(&gfs2meta_fs_type);
	slow_work_unregister_user();
	slow_work_unregister_user(THIS_MODULE);


	kmem_cache_destroy(gfs2_quotad_cachep);
	kmem_cache_destroy(gfs2_quotad_cachep);
	kmem_cache_destroy(gfs2_rgrpd_cachep);
	kmem_cache_destroy(gfs2_rgrpd_cachep);
Loading