diff options
author | Tejun Heo <tj@kernel.org> | 2008-09-24 17:22:23 -0400 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@ericvh-desktop.austin.ibm.com> | 2008-09-24 17:22:23 -0400 |
commit | 72029fe85d8d060b3f966f2dbc36b3c75b5a6532 (patch) | |
tree | ef8948240b0aff2a366136a8303afc70e6c84da8 /net/9p/trans_fd.c | |
parent | 72d31053f62c4bc464c2783974926969614a8649 (diff) |
9p: implement proper trans module refcounting and unregistration
9p trans modules aren't refcounted nor were they unregistered
properly. Fix it.
* Add 9p_trans_module->owner and reference the module on each trans
instance creation and put it on destruction.
* Protect v9fs_trans_list with a spinlock. This isn't strictly
necessary as the list is manipulated only during module loading /
unloading but it's a good idea to make the API safe.
* Unregister trans modules when the corresponding module is being
unloaded.
* While at it, kill unnecessary EXPORT_SYMBOL on p9_trans_fd_init().
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'net/9p/trans_fd.c')
-rw-r--r-- | net/9p/trans_fd.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index cdf137af7adc..6a32ffdb9429 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c | |||
@@ -1629,6 +1629,7 @@ static struct p9_trans_module p9_tcp_trans = { | |||
1629 | .maxsize = MAX_SOCK_BUF, | 1629 | .maxsize = MAX_SOCK_BUF, |
1630 | .def = 1, | 1630 | .def = 1, |
1631 | .create = p9_trans_create_tcp, | 1631 | .create = p9_trans_create_tcp, |
1632 | .owner = THIS_MODULE, | ||
1632 | }; | 1633 | }; |
1633 | 1634 | ||
1634 | static struct p9_trans_module p9_unix_trans = { | 1635 | static struct p9_trans_module p9_unix_trans = { |
@@ -1636,6 +1637,7 @@ static struct p9_trans_module p9_unix_trans = { | |||
1636 | .maxsize = MAX_SOCK_BUF, | 1637 | .maxsize = MAX_SOCK_BUF, |
1637 | .def = 0, | 1638 | .def = 0, |
1638 | .create = p9_trans_create_unix, | 1639 | .create = p9_trans_create_unix, |
1640 | .owner = THIS_MODULE, | ||
1639 | }; | 1641 | }; |
1640 | 1642 | ||
1641 | static struct p9_trans_module p9_fd_trans = { | 1643 | static struct p9_trans_module p9_fd_trans = { |
@@ -1643,6 +1645,7 @@ static struct p9_trans_module p9_fd_trans = { | |||
1643 | .maxsize = MAX_SOCK_BUF, | 1645 | .maxsize = MAX_SOCK_BUF, |
1644 | .def = 0, | 1646 | .def = 0, |
1645 | .create = p9_trans_create_fd, | 1647 | .create = p9_trans_create_fd, |
1648 | .owner = THIS_MODULE, | ||
1646 | }; | 1649 | }; |
1647 | 1650 | ||
1648 | int p9_trans_fd_init(void) | 1651 | int p9_trans_fd_init(void) |
@@ -1659,4 +1662,10 @@ int p9_trans_fd_init(void) | |||
1659 | 1662 | ||
1660 | return 0; | 1663 | return 0; |
1661 | } | 1664 | } |
1662 | EXPORT_SYMBOL(p9_trans_fd_init); | 1665 | |
1666 | void p9_trans_fd_exit(void) | ||
1667 | { | ||
1668 | v9fs_unregister_trans(&p9_tcp_trans); | ||
1669 | v9fs_unregister_trans(&p9_unix_trans); | ||
1670 | v9fs_unregister_trans(&p9_fd_trans); | ||
1671 | } | ||