From owner-svn-src-all@FreeBSD.ORG Fri Oct 22 22:58:00 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DD265106564A; Fri, 22 Oct 2010 22:58:00 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B18A18FC15; Fri, 22 Oct 2010 22:58:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9MMw0Ws068768; Fri, 22 Oct 2010 22:58:00 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9MMw0kX068766; Fri, 22 Oct 2010 22:58:00 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201010222258.o9MMw0kX068766@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Fri, 22 Oct 2010 22:58:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214229 - head/sys/geom/eli X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Oct 2010 22:58:01 -0000 Author: pjd Date: Fri Oct 22 22:58:00 2010 New Revision: 214229 URL: http://svn.freebsd.org/changeset/base/214229 Log: - 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. Modified: head/sys/geom/eli/g_eli_ctl.c Modified: head/sys/geom/eli/g_eli_ctl.c ============================================================================== --- head/sys/geom/eli/g_eli_ctl.c Fri Oct 22 22:54:26 2010 (r214228) +++ head/sys/geom/eli/g_eli_ctl.c Fri Oct 22 22:58:00 2010 (r214229) @@ -699,22 +699,28 @@ g_eli_ctl_delkey(struct gctl_req *req, s 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_eli_softc *sc; int *all, *nargs; - int error; g_topology_assert(); @@ -775,11 +779,13 @@ g_eli_ctl_suspend(struct gctl_req *req, 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, 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); } } }