Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F163599238
D41409.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D41409.diff
View Options
diff --git a/sys/kern/kern_osd.c b/sys/kern/kern_osd.c
--- a/sys/kern/kern_osd.c
+++ b/sys/kern/kern_osd.c
@@ -112,7 +112,7 @@
for (i = 0; i < osdm[type].osd_ntslots; i++) {
if (osdm[type].osd_destructors[i] == NULL) {
OSD_DEBUG("Unused slot found (type=%u, slot=%u).",
- type, i);
+ type, i + 1);
break;
}
}
@@ -166,32 +166,18 @@
LIST_FOREACH_SAFE(osd, &osdm[type].osd_list, osd_next, tosd)
do_osd_del(type, osd, slot, 1);
mtx_unlock(&osdm[type].osd_list_lock);
+
/*
- * Set destructor to NULL to free the slot.
+ * Set destructor to NULL to free the slot. We don't bother actually
+ * freeing any memory here because we'll gracefully reuse any freed
+ * slots, and reallocating the arrays as a smaller chunk of memory isn't
+ * actually guaranteed to succeed. As such, we'll err on the side of
+ * caution and just leave it be since these are generally modestly sized
+ * allocations.
*/
osdm[type].osd_destructors[slot - 1] = NULL;
- if (slot == osdm[type].osd_ntslots) {
- osdm[type].osd_ntslots--;
- osdm[type].osd_destructors = realloc(osdm[type].osd_destructors,
- sizeof(osd_destructor_t) * osdm[type].osd_ntslots, M_OSD,
- M_NOWAIT | M_ZERO);
- if (osdm[type].osd_nmethods != 0)
- osdm[type].osd_methods = realloc(osdm[type].osd_methods,
- sizeof(osd_method_t) * osdm[type].osd_ntslots *
- osdm[type].osd_nmethods, M_OSD, M_NOWAIT | M_ZERO);
- /*
- * We always reallocate to smaller size, so we assume it will
- * always succeed.
- */
- KASSERT(osdm[type].osd_destructors != NULL &&
- (osdm[type].osd_nmethods == 0 ||
- osdm[type].osd_methods != NULL), ("realloc() failed"));
- OSD_DEBUG("Deregistration of the last slot (type=%u, slot=%u).",
- type, slot);
- } else {
- OSD_DEBUG("Slot deregistration (type=%u, slot=%u).",
- type, slot);
- }
+ OSD_DEBUG("Slot deregistration (type=%u, slot=%u).", type, slot);
+
rm_wunlock(&osdm[type].osd_object_lock);
sx_xunlock(&osdm[type].osd_module_lock);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jul 25, 8:28 PM (9 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35488847
Default Alt Text
D41409.diff (1 KB)
Attached To
Mode
D41409: kern: osd: stop downsizing arrays when the last slot deregisters
Attached
Detach File
Event Timeline
Log In to Comment