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
This commit is contained in:
parent
dc604f0cf6
commit
bc97ce36f7
@ -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;
|
||||
@ -444,6 +446,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)
|
||||
{
|
||||
@ -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)
|
||||
{
|
||||
|
@ -109,6 +109,7 @@ void disk_create(struct disk *disk, int version);
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user