svn commit: r238216 - head/sys/geom
Edward Tomasz Napierala
trasz at FreeBSD.org
Sat Jul 7 21:28:32 UTC 2012
Author: trasz
Date: Sat Jul 7 21:28:31 2012
New Revision: 238216
URL: http://svn.freebsd.org/changeset/base/238216
Log:
Add disk_resize(), to make it possible for the disk drivers such as da(4)
to notify GEOM about LUN size change.
Reviewed by: mav (earlier version)
Sponsored by: FreeBSD Foundation
Modified:
head/sys/geom/geom_disk.c
head/sys/geom/geom_disk.h
Modified: head/sys/geom/geom_disk.c
==============================================================================
--- head/sys/geom/geom_disk.c Sat Jul 7 20:32:21 2012 (r238215)
+++ head/sys/geom/geom_disk.c Sat Jul 7 21:28:31 2012 (r238216)
@@ -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 c
}
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
(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)
{
Modified: head/sys/geom/geom_disk.h
==============================================================================
--- head/sys/geom/geom_disk.h Sat Jul 7 20:32:21 2012 (r238215)
+++ head/sys/geom/geom_disk.h Sat Jul 7 21:28:31 2012 (r238216)
@@ -109,6 +109,7 @@ void disk_create(struct disk *disk, int
void disk_destroy(struct disk *disk);
void disk_gone(struct disk *disk);
void disk_attr_changed(struct disk *dp, const char *attr, int flag);
+void disk_resize(struct disk *dp);
#define DISK_VERSION_00 0x58561059
#define DISK_VERSION_01 0x5856105a
More information about the svn-src-head
mailing list