summaryrefslogtreecommitdiffstats
path: root/sys/geom
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2010-10-22 22:58:00 +0000
committerpjd <pjd@FreeBSD.org>2010-10-22 22:58:00 +0000
commit0e4c81027703bc6d197dfa83a76161b7663331ae (patch)
treee085bec3a7eff5a376ba79f661361d099189b62d /sys/geom
parenta4a3ac19b48225c5191901d1e7c8985da69e9d66 (diff)
downloadFreeBSD-src-0e4c81027703bc6d197dfa83a76161b7663331ae.zip
FreeBSD-src-0e4c81027703bc6d197dfa83a76161b7663331ae.tar.gz
- Improve error messages, so instead of 'Not fully done', the user will get
information that device is already suspended or that device is using one-time key and suspend is not supported. - 'geli suspend -a' silently skips devices that use one-time key, this is fine, but because we log which device were suspended on the console, log also which devices were skipped.
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/eli/g_eli_ctl.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/sys/geom/eli/g_eli_ctl.c b/sys/geom/eli/g_eli_ctl.c
index cad962d..2413918 100644
--- a/sys/geom/eli/g_eli_ctl.c
+++ b/sys/geom/eli/g_eli_ctl.c
@@ -699,22 +699,28 @@ g_eli_ctl_delkey(struct gctl_req *req, struct g_class *mp)
G_ELI_DEBUG(1, "Key %d removed from %s.", nkey, pp->name);
}
-static int
-g_eli_suspend_one(struct g_eli_softc *sc)
+static void
+g_eli_suspend_one(struct g_eli_softc *sc, struct gctl_req *req)
{
struct g_eli_worker *wr;
g_topology_assert();
- if (sc == NULL)
- return (ENOENT);
- if (sc->sc_flags & G_ELI_FLAG_ONETIME)
- return (EOPNOTSUPP);
+ KASSERT(sc != NULL, ("NULL sc"));
+
+ if (sc->sc_flags & G_ELI_FLAG_ONETIME) {
+ gctl_error(req,
+ "Device %s is using one-time key, suspend not supported.",
+ sc->sc_name);
+ return;
+ }
mtx_lock(&sc->sc_queue_mtx);
if (sc->sc_flags & G_ELI_FLAG_SUSPEND) {
mtx_unlock(&sc->sc_queue_mtx);
- return (EALREADY);
+ gctl_error(req, "Device %s already suspended.",
+ sc->sc_name);
+ return;
}
sc->sc_flags |= G_ELI_FLAG_SUSPEND;
wakeup(sc);
@@ -742,8 +748,7 @@ g_eli_suspend_one(struct g_eli_softc *sc)
bzero(sc->sc_ivkey, sizeof(sc->sc_ivkey));
bzero(&sc->sc_ivctx, sizeof(sc->sc_ivctx));
mtx_unlock(&sc->sc_queue_mtx);
- G_ELI_DEBUG(0, "%s has been suspended.", sc->sc_name);
- return (0);
+ G_ELI_DEBUG(0, "Device %s has been suspended.", sc->sc_name);
}
static void
@@ -751,7 +756,6 @@ g_eli_ctl_suspend(struct gctl_req *req, struct g_class *mp)
{
struct g_eli_softc *sc;
int *all, *nargs;
- int error;
g_topology_assert();
@@ -775,11 +779,13 @@ g_eli_ctl_suspend(struct gctl_req *req, struct g_class *mp)
LIST_FOREACH_SAFE(gp, &mp->geom, geom, gp2) {
sc = gp->softc;
- if (sc->sc_flags & G_ELI_FLAG_ONETIME)
+ if (sc->sc_flags & G_ELI_FLAG_ONETIME) {
+ G_ELI_DEBUG(0,
+ "Device %s is using one-time key, suspend not supported, skipping.",
+ sc->sc_name);
continue;
- error = g_eli_suspend_one(sc);
- if (error != 0)
- gctl_error(req, "Not fully done.");
+ }
+ g_eli_suspend_one(sc, req);
}
} else {
const char *prov;
@@ -799,9 +805,7 @@ g_eli_ctl_suspend(struct gctl_req *req, struct g_class *mp)
G_ELI_DEBUG(0, "No such provider: %s.", prov);
continue;
}
- error = g_eli_suspend_one(sc);
- if (error != 0)
- gctl_error(req, "Not fully done.");
+ g_eli_suspend_one(sc, req);
}
}
}
OpenPOWER on IntegriCloud