Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107590247
D12809.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D12809.diff
View Options
Index: head/sys/geom/geom_slice.c
===================================================================
--- head/sys/geom/geom_slice.c
+++ head/sys/geom/geom_slice.c
@@ -43,7 +43,6 @@
#include <sys/bio.h>
#include <sys/sysctl.h>
#include <sys/proc.h>
-#include <sys/kthread.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/errno.h>
@@ -127,6 +126,15 @@
if ((cp->acr + dr) == 0 && (cp->acw + dw) == 0 && (cp->ace + de) == 1)
de--;
error = g_access(cp, dr, dw, de);
+
+ /*
+ * Free the softc if all providers have been closed and this geom
+ * is being removed.
+ */
+ if (error == 0 && (gp->flags & G_GEOM_WITHER) != 0 &&
+ (cp->acr + cp->acw + cp->ace) == 0)
+ g_slice_free(gsp);
+
return (error);
}
@@ -470,21 +478,32 @@
}
void
-g_slice_spoiled(struct g_consumer *cp)
+g_slice_orphan(struct g_consumer *cp)
{
struct g_geom *gp;
- struct g_slicer *gsp;
g_topology_assert();
gp = cp->geom;
- g_trace(G_T_TOPOLOGY, "g_slice_spoiled(%p/%s)", cp, gp->name);
- cp->flags |= G_CF_ORPHAN;
- gsp = gp->softc;
- gp->softc = NULL;
- g_slice_free(gsp);
+ g_trace(G_T_TOPOLOGY, "%s(%p/%s)", __func__, cp, gp->name);
g_wither_geom(gp, ENXIO);
+
+ /*
+ * We can safely free the softc now if there are no accesses,
+ * otherwise g_slice_access() will do that after the last close.
+ */
+ if ((cp->acr + cp->acw + cp->ace) == 0)
+ g_slice_free(gp->softc);
}
+void
+g_slice_spoiled(struct g_consumer *cp)
+{
+
+ g_trace(G_T_TOPOLOGY, "%s(%p/%s)", __func__, cp, cp->geom->name);
+ cp->flags |= G_CF_ORPHAN;
+ g_slice_orphan(cp);
+}
+
int
g_slice_destroy_geom(struct gctl_req *req, struct g_class *mp, struct g_geom *gp)
{
@@ -507,10 +526,10 @@
gp = g_new_geomf(mp, "%s", pp->name);
gsp = g_slice_alloc(slices, extra);
gsp->start = start;
- gp->access = g_slice_access;
- gp->orphan = g_slice_orphan;
gp->softc = gsp;
gp->start = g_slice_start;
+ gp->access = g_slice_access;
+ gp->orphan = g_slice_orphan;
gp->spoiled = g_slice_spoiled;
if (gp->dumpconf == NULL)
gp->dumpconf = g_slice_dumpconf;
@@ -529,19 +548,4 @@
*vp = gsp->softc;
*cpp = cp;
return (gp);
-}
-
-void
-g_slice_orphan(struct g_consumer *cp)
-{
- struct g_slicer *gsp;
-
- g_trace(G_T_TOPOLOGY, "g_slice_orphan(%p/%s)", cp, cp->provider->name);
- g_topology_assert();
-
- /* XXX: Not good enough we leak the softc and its suballocations */
- gsp = cp->geom->softc;
- cp->geom->softc = NULL;
- g_slice_free(gsp);
- g_wither_geom(cp->geom, ENXIO);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 17, 7:59 AM (21 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15836190
Default Alt Text
D12809.diff (2 KB)
Attached To
Mode
D12809: geom_slice: do not destroy softc until providers are gone
Attached
Detach File
Event Timeline
Log In to Comment