Simplify error handling in t4_tom.ko module loading.

- Change t4_ddp_mod_load() to return void instead of always returning
  success.  This avoids having to pretend to have proper support for
  unloading when only part of t4_tom_mod_load() has run.
- If t4_register_uld() fails, don't invoke t4_tom_mod_unload() directly.
  The module handling code in the kernel invokes MOD_UNLOAD on a module
  whose MOD_LOAD fails with an error already.

Reviewed by:	np (part of a larger patch)
MFC after:	1 month
Sponsored by:	Chelsio Communications
This commit is contained in:
John Baldwin 2018-03-13 21:42:38 +00:00
parent c92c85ffeb
commit 9689995d23
3 changed files with 4 additions and 12 deletions

View File

@ -1939,7 +1939,7 @@ t4_aio_queue_ddp(struct socket *so, struct kaiocb *job)
return (0);
}
int
void
t4_ddp_mod_load(void)
{
@ -1948,7 +1948,6 @@ t4_ddp_mod_load(void)
TAILQ_INIT(&ddp_orphan_pagesets);
mtx_init(&ddp_orphan_pagesets_lock, "ddp orphans", NULL, MTX_DEF);
TASK_INIT(&ddp_orphan_task, 0, ddp_free_orphan_pagesets, NULL);
return (0);
}
void

View File

@ -1170,7 +1170,6 @@ t4_aio_queue_tom(struct socket *so, struct kaiocb *job)
static int
t4_tom_mod_load(void)
{
int rc;
struct protosw *tcp_protosw, *tcp6_protosw;
/* CPL handlers */
@ -1178,9 +1177,7 @@ t4_tom_mod_load(void)
t4_init_listen_cpl_handlers();
t4_init_cpl_io_handlers();
rc = t4_ddp_mod_load();
if (rc != 0)
return (rc);
t4_ddp_mod_load();
tcp_protosw = pffindproto(PF_INET, IPPROTO_TCP, SOCK_STREAM);
if (tcp_protosw == NULL)
@ -1202,11 +1199,7 @@ t4_tom_mod_load(void)
ifaddr_evhandler = EVENTHANDLER_REGISTER(ifaddr_event,
t4_tom_ifaddr_event, NULL, EVENTHANDLER_PRI_ANY);
rc = t4_register_uld(&tom_uld_info);
if (rc != 0)
t4_tom_mod_unload();
return (rc);
return (t4_register_uld(&tom_uld_info));
}
static void

View File

@ -389,7 +389,7 @@ void t4_free_page_pods(struct ppod_reservation *);
int t4_soreceive_ddp(struct socket *, struct sockaddr **, struct uio *,
struct mbuf **, struct mbuf **, int *);
int t4_aio_queue_ddp(struct socket *, struct kaiocb *);
int t4_ddp_mod_load(void);
void t4_ddp_mod_load(void);
void t4_ddp_mod_unload(void);
void ddp_assert_empty(struct toepcb *);
void ddp_init_toep(struct toepcb *);