svn commit: r238219 - head/sys/geom/nop
Edward Tomasz Napierala
trasz at FreeBSD.org
Sat Jul 7 22:22:14 UTC 2012
Author: trasz
Date: Sat Jul 7 22:22:13 2012
New Revision: 238219
URL: http://svn.freebsd.org/changeset/base/238219
Log:
Add trivial resize handling to gnop(8).
Reviewed by: mav
Sponsored by: FreeBSD Foundation
Modified:
head/sys/geom/nop/g_nop.c
head/sys/geom/nop/g_nop.h
Modified: head/sys/geom/nop/g_nop.c
==============================================================================
--- head/sys/geom/nop/g_nop.c Sat Jul 7 22:20:47 2012 (r238218)
+++ head/sys/geom/nop/g_nop.c Sat Jul 7 22:22:13 2012 (r238219)
@@ -72,6 +72,30 @@ g_nop_orphan(struct g_consumer *cp)
}
static void
+g_nop_resize(struct g_consumer *cp)
+{
+ struct g_nop_softc *sc;
+ struct g_geom *gp;
+ struct g_provider *pp;
+ off_t size;
+
+ g_topology_assert();
+
+ gp = cp->geom;
+ sc = gp->softc;
+
+ if (sc->sc_explicitsize != 0)
+ return;
+ if (cp->provider->mediasize < sc->sc_offset) {
+ g_nop_destroy(gp, 1);
+ return;
+ }
+ size = cp->provider->mediasize - sc->sc_offset;
+ LIST_FOREACH(pp, &gp->provider, provider)
+ g_resize_provider(pp, size);
+}
+
+static void
g_nop_start(struct bio *bp)
{
struct g_nop_softc *sc;
@@ -146,6 +170,7 @@ g_nop_create(struct gctl_req *req, struc
struct g_consumer *cp;
char name[64];
int error;
+ off_t explicitsize;
g_topology_assert();
@@ -165,6 +190,7 @@ g_nop_create(struct gctl_req *req, struc
gctl_error(req, "Invalid offset for provider %s.", pp->name);
return (EINVAL);
}
+ explicitsize = size;
if (size == 0)
size = pp->mediasize - offset;
if (offset + size > pp->mediasize) {
@@ -192,6 +218,7 @@ g_nop_create(struct gctl_req *req, struc
gp = g_new_geomf(mp, name);
sc = g_malloc(sizeof(*sc), M_WAITOK);
sc->sc_offset = offset;
+ sc->sc_explicitsize = explicitsize;
sc->sc_error = ioerror;
sc->sc_rfailprob = rfailprob;
sc->sc_wfailprob = wfailprob;
@@ -202,6 +229,7 @@ g_nop_create(struct gctl_req *req, struc
gp->softc = sc;
gp->start = g_nop_start;
gp->orphan = g_nop_orphan;
+ gp->resize = g_nop_resize;
gp->access = g_nop_access;
gp->dumpconf = g_nop_dumpconf;
Modified: head/sys/geom/nop/g_nop.h
==============================================================================
--- head/sys/geom/nop/g_nop.h Sat Jul 7 22:20:47 2012 (r238218)
+++ head/sys/geom/nop/g_nop.h Sat Jul 7 22:22:13 2012 (r238219)
@@ -57,6 +57,7 @@
struct g_nop_softc {
int sc_error;
off_t sc_offset;
+ off_t sc_explicitsize;
u_int sc_rfailprob;
u_int sc_wfailprob;
uintmax_t sc_reads;
More information about the svn-src-head
mailing list