* [PATCH] ocfs2: fix module_init error handling
@ 2007-03-04 13:34 Akinobu Mita
2007-03-05 19:58 ` Joel Becker
0 siblings, 1 reply; 4+ messages in thread
From: Akinobu Mita @ 2007-03-04 13:34 UTC (permalink / raw)
To: linux-kernel; +Cc: Mark Fasheh, Kurt Hackel
From: Akinobu Mita <akinobu.mita@gmail.com>
Subject: [PATCH] ocfs2: fix module_init error handling
Fix error handling in module_init and make module_init() return
correct error code.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Mark Fasheh <mark.fasheh@oracle.com>
Cc: Kurt Hackel <kurt.hackel@oracle.com>
---
fs/ocfs2/super.c | 42 +++++++++++++++++++++++++++---------------
1 file changed, 27 insertions(+), 15 deletions(-)
Index: 2.6-mm/fs/ocfs2/super.c
===================================================================
--- 2.6-mm.orig/fs/ocfs2/super.c
+++ 2.6-mm/fs/ocfs2/super.c
@@ -806,46 +806,58 @@ static int __init ocfs2_init(void)
ocfs2_print_version();
- if (init_ocfs2_extent_maps())
- return -ENOMEM;
+ status = init_ocfs2_extent_maps();
+ if (status)
+ goto err_extent_maps;
status = init_ocfs2_uptodate_cache();
if (status < 0) {
mlog_errno(status);
- goto leave;
+ goto err_uptodate_cache;
}
status = ocfs2_initialize_mem_caches();
if (status < 0) {
mlog_errno(status);
- goto leave;
+ goto err_mem_caches;
}
ocfs2_wq = create_singlethread_workqueue("ocfs2_wq");
if (!ocfs2_wq) {
status = -ENOMEM;
- goto leave;
+ goto err_workqueue;
}
ocfs2_debugfs_root = debugfs_create_dir("ocfs2", NULL);
if (!ocfs2_debugfs_root) {
status = -EFAULT;
mlog(ML_ERROR, "Unable to create ocfs2 debugfs root.\n");
+ goto err_debugfs;
}
-leave:
- if (status < 0) {
- ocfs2_free_mem_caches();
- exit_ocfs2_uptodate_cache();
- exit_ocfs2_extent_maps();
- }
+ status = register_filesystem(&ocfs2_fs_type);
+ if (status)
+ goto err_filesystem;
mlog_exit(status);
- if (status >= 0) {
- return register_filesystem(&ocfs2_fs_type);
- } else
- return -1;
+ return 0;
+
+err_filesystem:
+ debugfs_remove(ocfs2_debugfs_root);
+err_debugfs:
+ flush_workqueue(ocfs2_wq);
+ destroy_workqueue(ocfs2_wq);
+err_workqueue:
+ ocfs2_free_mem_caches();
+err_mem_caches:
+ exit_ocfs2_uptodate_cache();
+err_uptodate_cache:
+ exit_ocfs2_extent_maps();
+err_extent_maps:
+ mlog_exit(status);
+
+ return status;
}
static void __exit ocfs2_exit(void)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ocfs2: fix module_init error handling
2007-03-04 13:34 [PATCH] ocfs2: fix module_init error handling Akinobu Mita
@ 2007-03-05 19:58 ` Joel Becker
2007-03-06 16:38 ` Akinobu Mita
0 siblings, 1 reply; 4+ messages in thread
From: Joel Becker @ 2007-03-05 19:58 UTC (permalink / raw)
To: Akinobu Mita, linux-kernel, Mark Fasheh, Kurt Hackel
On Sun, Mar 04, 2007 at 10:34:43PM +0900, Akinobu Mita wrote:
> From: Akinobu Mita <akinobu.mita@gmail.com>
> Subject: [PATCH] ocfs2: fix module_init error handling
>
> Fix error handling in module_init and make module_init() return
> correct error code.
What are you fixing specifically? This looks like you are
reorganizing the exit path. While stylistic differences can exist on
the choice of function exit, claiming there is a "fix" means there is an
actual bug. Please clarify the bug so we can evaluate your change.
> -leave:
> - if (status < 0) {
> - ocfs2_free_mem_caches();
> - exit_ocfs2_uptodate_cache();
> - exit_ocfs2_extent_maps();
> - }
> + status = register_filesystem(&ocfs2_fs_type);
> + if (status)
> + goto err_filesystem;
>
> mlog_exit(status);
Also, this change suppresses some paths to mlog_exit(), which
impacts people tracing.
If there is an actual bug you are fixing, please tell us. We'll
work with you to correct it.
Joel
--
Life's Little Instruction Book #451
"Don't be afraid to say, 'I'm sorry.'"
Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker@oracle.com
Phone: (650) 506-8127
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ocfs2: fix module_init error handling
2007-03-05 19:58 ` Joel Becker
@ 2007-03-06 16:38 ` Akinobu Mita
2007-03-06 18:53 ` Mark Fasheh
0 siblings, 1 reply; 4+ messages in thread
From: Akinobu Mita @ 2007-03-06 16:38 UTC (permalink / raw)
To: Akinobu Mita, linux-kernel, Mark Fasheh, Kurt Hackel
2007/3/6, Joel Becker <Joel.Becker@oracle.com>:
> On Sun, Mar 04, 2007 at 10:34:43PM +0900, Akinobu Mita wrote:
> > From: Akinobu Mita <akinobu.mita@gmail.com>
> > Subject: [PATCH] ocfs2: fix module_init error handling
> >
> > Fix error handling in module_init and make module_init() return
> > correct error code.
>
> What are you fixing specifically? This looks like you are
> reorganizing the exit path. While stylistic differences can exist on
> the choice of function exit, claiming there is a "fix" means there is an
> actual bug. Please clarify the bug so we can evaluate your change.
OK. There are three problems (these are not likely to happen)
- There is no error handling when register_filesystem() fails
(several slab caches, debugfs directory, and workqueue will not be cleaned)
- workqueue will not be cleaned if debugfs_create_dir() returns error.
- kmem_cache_destroy() with NULL oops will happen if
ocfs2_free_mem_caches(), exit_ocfs2_uptodate_cache(),
or exit_ocfs2_extent_maps() return error.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ocfs2: fix module_init error handling
2007-03-06 16:38 ` Akinobu Mita
@ 2007-03-06 18:53 ` Mark Fasheh
0 siblings, 0 replies; 4+ messages in thread
From: Mark Fasheh @ 2007-03-06 18:53 UTC (permalink / raw)
To: Akinobu Mita; +Cc: linux-kernel, Kurt Hackel
On Wed, Mar 07, 2007 at 01:38:17AM +0900, Akinobu Mita wrote:
> OK. There are three problems (these are not likely to happen)
>
> - There is no error handling when register_filesystem() fails
> (several slab caches, debugfs directory, and workqueue will not be cleaned)
>
> - workqueue will not be cleaned if debugfs_create_dir() returns error.
>
> - kmem_cache_destroy() with NULL oops will happen if
> ocfs2_free_mem_caches(), exit_ocfs2_uptodate_cache(),
> or exit_ocfs2_extent_maps() return error.
Ok, both those patches are in ocfs2.git now.
--Mark
--
Mark Fasheh
Senior Software Developer, Oracle
mark.fasheh@oracle.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-03-06 18:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-04 13:34 [PATCH] ocfs2: fix module_init error handling Akinobu Mita
2007-03-05 19:58 ` Joel Becker
2007-03-06 16:38 ` Akinobu Mita
2007-03-06 18:53 ` Mark Fasheh
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.