svn commit: r368411 - head/sys/net
Mark Johnston
markj at FreeBSD.org
Mon Dec 7 14:52:58 UTC 2020
Author: markj
Date: Mon Dec 7 14:52:57 2020
New Revision: 368411
URL: https://svnweb.freebsd.org/changeset/base/368411
Log:
iflib: Detach tasks upon device registration failure
In some error paths we would fail to detach from the iflib taskqueue
groups. Also move the detach code into its own subroutine instead of
duplicating it.
Submitted by: Sai Rajesh Tallamraju <stallamr at netapp.com>
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D27342
Modified:
head/sys/net/iflib.c
Modified: head/sys/net/iflib.c
==============================================================================
--- head/sys/net/iflib.c Mon Dec 7 11:25:18 2020 (r368410)
+++ head/sys/net/iflib.c Mon Dec 7 14:52:57 2020 (r368411)
@@ -142,6 +142,7 @@ struct iflib_ctx;
static void iru_init(if_rxd_update_t iru, iflib_rxq_t rxq, uint8_t flid);
static void iflib_timer(void *arg);
+static void iflib_tqg_detach(if_ctx_t ctx);
typedef struct iflib_filter_info {
driver_filter_t *ifi_filter;
@@ -4842,7 +4843,7 @@ fail_intr_free:
fail_queues:
iflib_tx_structures_free(ctx);
iflib_rx_structures_free(ctx);
- taskqgroup_detach(qgroup_if_config_tqg, &ctx->ifc_admin_task);
+ iflib_tqg_detach(ctx);
IFDI_DETACH(ctx);
fail_unlock:
CTX_UNLOCK(ctx);
@@ -5042,6 +5043,7 @@ fail_detach:
fail_queues:
iflib_tx_structures_free(ctx);
iflib_rx_structures_free(ctx);
+ iflib_tqg_detach(ctx);
fail_iflib_detach:
IFDI_DETACH(ctx);
fail_unlock:
@@ -5058,11 +5060,6 @@ iflib_pseudo_deregister(if_ctx_t ctx)
{
if_t ifp = ctx->ifc_ifp;
if_shared_ctx_t sctx = ctx->ifc_sctx;
- iflib_txq_t txq;
- iflib_rxq_t rxq;
- int i, j;
- struct taskqgroup *tqg;
- iflib_fl_t fl;
/* Unregister VLAN event handlers early */
iflib_unregister_vlan_handlers(ctx);
@@ -5074,30 +5071,8 @@ iflib_pseudo_deregister(if_ctx_t ctx)
} else {
ether_ifdetach(ifp);
}
- /* XXX drain any dependent tasks */
- tqg = qgroup_if_io_tqg;
- for (txq = ctx->ifc_txqs, i = 0; i < NTXQSETS(ctx); i++, txq++) {
- callout_drain(&txq->ift_timer);
-#ifdef DEV_NETMAP
- callout_drain(&txq->ift_netmap_timer);
-#endif /* DEV_NETMAP */
- if (txq->ift_task.gt_uniq != NULL)
- taskqgroup_detach(tqg, &txq->ift_task);
- }
- for (i = 0, rxq = ctx->ifc_rxqs; i < NRXQSETS(ctx); i++, rxq++) {
- callout_drain(&rxq->ifr_watchdog);
- if (rxq->ifr_task.gt_uniq != NULL)
- taskqgroup_detach(tqg, &rxq->ifr_task);
- for (j = 0, fl = rxq->ifr_fl; j < rxq->ifr_nfl; j++, fl++)
- free(fl->ifl_rx_bitmap, M_IFLIB);
- }
- tqg = qgroup_if_config_tqg;
- if (ctx->ifc_admin_task.gt_uniq != NULL)
- taskqgroup_detach(tqg, &ctx->ifc_admin_task);
- if (ctx->ifc_vflr_task.gt_uniq != NULL)
- taskqgroup_detach(tqg, &ctx->ifc_vflr_task);
-
+ iflib_tqg_detach(ctx);
iflib_tx_structures_free(ctx);
iflib_rx_structures_free(ctx);
@@ -5127,12 +5102,7 @@ int
iflib_device_deregister(if_ctx_t ctx)
{
if_t ifp = ctx->ifc_ifp;
- iflib_txq_t txq;
- iflib_rxq_t rxq;
device_t dev = ctx->ifc_dev;
- int i, j;
- struct taskqgroup *tqg;
- iflib_fl_t fl;
/* Make sure VLANS are not using driver */
if (if_vlantrunkinuse(ifp)) {
@@ -5163,28 +5133,8 @@ iflib_device_deregister(if_ctx_t ctx)
iflib_rem_pfil(ctx);
if (ctx->ifc_led_dev != NULL)
led_destroy(ctx->ifc_led_dev);
- /* XXX drain any dependent tasks */
- tqg = qgroup_if_io_tqg;
- for (txq = ctx->ifc_txqs, i = 0; i < NTXQSETS(ctx); i++, txq++) {
- callout_drain(&txq->ift_timer);
-#ifdef DEV_NETMAP
- callout_drain(&txq->ift_netmap_timer);
-#endif /* DEV_NETMAP */
- if (txq->ift_task.gt_uniq != NULL)
- taskqgroup_detach(tqg, &txq->ift_task);
- }
- for (i = 0, rxq = ctx->ifc_rxqs; i < NRXQSETS(ctx); i++, rxq++) {
- if (rxq->ifr_task.gt_uniq != NULL)
- taskqgroup_detach(tqg, &rxq->ifr_task);
- for (j = 0, fl = rxq->ifr_fl; j < rxq->ifr_nfl; j++, fl++)
- free(fl->ifl_rx_bitmap, M_IFLIB);
- }
- tqg = qgroup_if_config_tqg;
- if (ctx->ifc_admin_task.gt_uniq != NULL)
- taskqgroup_detach(tqg, &ctx->ifc_admin_task);
- if (ctx->ifc_vflr_task.gt_uniq != NULL)
- taskqgroup_detach(tqg, &ctx->ifc_vflr_task);
+ iflib_tqg_detach(ctx);
CTX_LOCK(ctx);
IFDI_DETACH(ctx);
CTX_UNLOCK(ctx);
@@ -5205,6 +5155,35 @@ iflib_device_deregister(if_ctx_t ctx)
unref_ctx_core_offset(ctx);
free(ctx, M_IFLIB);
return (0);
+}
+
+static void
+iflib_tqg_detach(if_ctx_t ctx)
+{
+ iflib_txq_t txq;
+ iflib_rxq_t rxq;
+ int i;
+ struct taskqgroup *tqg;
+
+ /* XXX drain any dependent tasks */
+ tqg = qgroup_if_io_tqg;
+ for (txq = ctx->ifc_txqs, i = 0; i < NTXQSETS(ctx); i++, txq++) {
+ callout_drain(&txq->ift_timer);
+#ifdef DEV_NETMAP
+ callout_drain(&txq->ift_netmap_timer);
+#endif /* DEV_NETMAP */
+ if (txq->ift_task.gt_uniq != NULL)
+ taskqgroup_detach(tqg, &txq->ift_task);
+ }
+ for (i = 0, rxq = ctx->ifc_rxqs; i < NRXQSETS(ctx); i++, rxq++) {
+ if (rxq->ifr_task.gt_uniq != NULL)
+ taskqgroup_detach(tqg, &rxq->ifr_task);
+ }
+ tqg = qgroup_if_config_tqg;
+ if (ctx->ifc_admin_task.gt_uniq != NULL)
+ taskqgroup_detach(tqg, &ctx->ifc_admin_task);
+ if (ctx->ifc_vflr_task.gt_uniq != NULL)
+ taskqgroup_detach(tqg, &ctx->ifc_vflr_task);
}
static void
More information about the svn-src-head
mailing list