summaryrefslogtreecommitdiff
path: root/sys/geom/geom_disk.c
diff options
context:
space:
mode:
authorEdward Tomasz Napierala <trasz@FreeBSD.org>2012-07-07 21:28:31 +0000
committerEdward Tomasz Napierala <trasz@FreeBSD.org>2012-07-07 21:28:31 +0000
commitbc97ce36f7c1164d83ff5e6a135b701e73748fee (patch)
tree2eaefa0b5b44c49d9c47b35c8946b2b59b2b5ea2 /sys/geom/geom_disk.c
parentdc604f0cf62e5e8b9b2f0b2bba1447db443238a6 (diff)
downloadsrc-test-bc97ce36f7c1164d83ff5e6a135b701e73748fee.tar.gz
src-test-bc97ce36f7c1164d83ff5e6a135b701e73748fee.zip
Notes
Diffstat (limited to 'sys/geom/geom_disk.c')
-rw-r--r--sys/geom/geom_disk.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c
index 77065170b85bf..1d6f867ada3dd 100644
--- a/sys/geom/geom_disk.c
+++ b/sys/geom/geom_disk.c
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/sbuf.h>
#include <sys/sysctl.h>
+#include <sys/taskqueue.h>
#include <sys/devicestat.h>
#include <machine/md_var.h>
@@ -65,6 +66,7 @@ struct g_disk_softc {
struct sysctl_oid *sysctl_tree;
char led[64];
uint32_t state;
+ struct task resize_task;
};
static struct mtx g_disk_done_mtx;
@@ -445,6 +447,27 @@ g_disk_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g
}
static void
+g_disk_resize_task(void *context, int pending)
+{
+ struct g_geom *gp;
+ struct g_provider *pp;
+ struct disk *dp;
+ struct g_disk_softc *sc;
+
+ sc = (struct g_disk_softc *)context;
+ dp = sc->dp;
+ gp = dp->d_geom;
+
+ LIST_FOREACH(pp, &gp->provider, provider) {
+ if (pp->sectorsize != 0 &&
+ pp->sectorsize != dp->d_sectorsize)
+ g_wither_provider(pp, ENXIO);
+ else
+ g_resize_provider(pp, dp->d_mediasize);
+ }
+}
+
+static void
g_disk_create(void *arg, int flag)
{
struct g_geom *gp;
@@ -484,6 +507,7 @@ g_disk_create(void *arg, int flag)
CTLFLAG_RW | CTLFLAG_TUN, sc->led, sizeof(sc->led),
"LED name");
}
+ TASK_INIT(&sc->resize_task, 0, g_disk_resize_task, sc);
pp->private = sc;
dp->d_geom = gp;
g_error_provider(pp, 0);
@@ -635,6 +659,24 @@ disk_attr_changed(struct disk *dp, const char *attr, int flag)
(void)g_attr_changed(pp, attr, flag);
}
+void
+disk_resize(struct disk *dp)
+{
+ struct g_geom *gp;
+ struct g_disk_softc *sc;
+ int error;
+
+ gp = dp->d_geom;
+
+ if (gp == NULL)
+ return;
+
+ sc = gp->softc;
+
+ error = taskqueue_enqueue(taskqueue_thread, &sc->resize_task);
+ KASSERT(error == 0, ("taskqueue_enqueue(9) failed."));
+}
+
static void
g_kern_disks(void *p, int flag __unused)
{