From c967bee755008d70c4d376e2c5fc10773fa40a9f Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Tue, 18 Mar 2003 09:30:31 +0000 Subject: [PATCH] If devstat_new_entry() is passed a unit number of -1 assume that the devstat is for an "interior" GEOM node and register using the name argument as a geom identity pointer. Do not put these devstat structures on the list returned by the sysctl. This gives us the ability to tell the two kinds of nodes apart and leave the current "strictly physical" view of devstat intact without modifications, yet be able to use devstat for both kinds of devices. It also saves us bloating struct devstat with another 48 bytes of space for the name. At least for now. Reviewed by: ken --- sys/kern/subr_devstat.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sys/kern/subr_devstat.c b/sys/kern/subr_devstat.c index 7277dd1ce89..43560203d4e 100644 --- a/sys/kern/subr_devstat.c +++ b/sys/kern/subr_devstat.c @@ -80,8 +80,14 @@ devstat_new_entry(const void *dev_name, ds = devstat_alloc(); mtx_lock(&devstat_mutex); - devstat_add_entry(ds, dev_name, unit_number, block_size, - flags, device_type, priority); + if (unit_number == -1) { + ds->id = dev_name; + binuptime(&ds->creation_time); + devstat_generation++; + } else { + devstat_add_entry(ds, dev_name, unit_number, block_size, + flags, device_type, priority); + } mtx_unlock(&devstat_mutex); return (ds); } @@ -186,8 +192,10 @@ devstat_remove_entry(struct devstat *ds) /* Remove this entry from the devstat queue */ atomic_add_acq_int(&ds->sequence1, 1); - devstat_num_devs--; - STAILQ_REMOVE(devstat_head, ds, devstat, dev_links); + if (ds->id == NULL) { + devstat_num_devs--; + STAILQ_REMOVE(devstat_head, ds, devstat, dev_links); + } devstat_free(ds); devstat_generation++; mtx_unlock(&devstat_mutex);