From owner-svn-src-all@FreeBSD.ORG Tue Jan 11 17:26:37 2011 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 4F2281065672; Tue, 11 Jan 2011 17:26:37 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3D8368FC0C; Tue, 11 Jan 2011 17:26:37 +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 p0BHQbCB027535; Tue, 11 Jan 2011 17:26:37 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0BHQbwq027532; Tue, 11 Jan 2011 17:26:37 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201101111726.p0BHQbwq027532@svn.freebsd.org> From: Matthew D Fleming Date: Tue, 11 Jan 2011 17:26:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217269 - in stable/8/sys: kern sys 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: Tue, 11 Jan 2011 17:26:37 -0000 Author: mdf Date: Tue Jan 11 17:26:36 2011 New Revision: 217269 URL: http://svn.freebsd.org/changeset/base/217269 Log: Move the fail_point_entry definition from fail.h to kern_fail.c, which allows putting the enumeration constants of fail point types with the text string that matches them. Modified: stable/8/sys/kern/kern_fail.c stable/8/sys/sys/fail.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/kern/kern_fail.c ============================================================================== --- stable/8/sys/kern/kern_fail.c Tue Jan 11 17:16:50 2011 (r217268) +++ stable/8/sys/kern/kern_fail.c Tue Jan 11 17:26:36 2011 (r217269) @@ -76,6 +76,43 @@ MTX_SYSINIT(g_fp_mtx, &g_fp_mtx, "fail p #define FP_LOCK() mtx_lock(&g_fp_mtx) #define FP_UNLOCK() mtx_unlock(&g_fp_mtx) +/** + * Failpoint types. + * Don't change these without changing fail_type_strings in fail.c. + * @ingroup failpoint_private + */ +enum fail_point_t { + FAIL_POINT_OFF, /**< don't fail */ + FAIL_POINT_PANIC, /**< panic */ + FAIL_POINT_RETURN, /**< return an errorcode */ + FAIL_POINT_BREAK, /**< break into the debugger */ + FAIL_POINT_PRINT, /**< print a message */ + FAIL_POINT_SLEEP, /**< sleep for some msecs */ + FAIL_POINT_INVALID, /**< placeholder */ +}; + +static const char *fail_type_strings[] = { + "off", + "panic", + "return", + "break", + "print", + "sleep", +}; + +/** + * Internal structure tracking a single term of a complete failpoint. + * @ingroup failpoint_private + */ +struct fail_point_entry { + enum fail_point_t fe_type; /**< type of entry */ + int fe_arg; /**< argument to type (e.g. return value) */ + int fe_prob; /**< likelihood of firing in millionths */ + int fe_count; /**< number of times to fire, 0 means always */ + + TAILQ_ENTRY(fail_point_entry) fe_entries; /**< next entry in fail point */ +}; + static inline void fail_point_sleep(struct fail_point *fp, struct fail_point_entry *ent, int msecs, enum fail_point_return_code *pret) @@ -102,15 +139,6 @@ enum { PROB_DIGITS = 6, /* number of zero's in above number */ }; -static const char *fail_type_strings[] = { - "off", - "panic", - "return", - "break", - "print", - "sleep", -}; - static char *parse_fail_point(struct fail_point_entries *, char *); static char *parse_term(struct fail_point_entries *, char *); static char *parse_number(int *out_units, int *out_decimal, char *); Modified: stable/8/sys/sys/fail.h ============================================================================== --- stable/8/sys/sys/fail.h Tue Jan 11 17:16:50 2011 (r217268) +++ stable/8/sys/sys/fail.h Tue Jan 11 17:26:36 2011 (r217269) @@ -39,22 +39,6 @@ #include #include - -/** - * Failpoint types. - * Don't change these without changing fail_type_strings in fail.c. - * @ingroup failpoint_private - */ -enum fail_point_t { - FAIL_POINT_OFF, /**< don't fail */ - FAIL_POINT_PANIC, /**< panic */ - FAIL_POINT_RETURN, /**< return an errorcode */ - FAIL_POINT_BREAK, /**< break into the debugger */ - FAIL_POINT_PRINT, /**< print a message */ - FAIL_POINT_SLEEP, /**< sleep for some msecs */ - FAIL_POINT_INVALID, /**< placeholder */ -}; - /** * Failpoint return codes, used internally. * @ingroup failpoint_private @@ -65,6 +49,7 @@ enum fail_point_return_code { FAIL_POINT_RC_QUEUED, /**< sleep_fn will be called */ }; +struct fail_point_entry; TAILQ_HEAD(fail_point_entries, fail_point_entry); /** * Internal failpoint structure, tracking all the current details of the @@ -84,18 +69,7 @@ struct fail_point { #define FAIL_POINT_DYNAMIC_NAME 0x01 /**< Must free name on destroy */ -/** - * Internal structure tracking a single term of a complete failpoint. - * @ingroup failpoint_private - */ -struct fail_point_entry { - enum fail_point_t fe_type; /**< type of entry */ - int fe_arg; /**< argument to type (e.g. return value) */ - int fe_prob; /**< likelihood of firing in millionths */ - int fe_count; /**< number of times to fire, 0 means always */ - - TAILQ_ENTRY(fail_point_entry) fe_entries; /**< next entry in fail point */ -}; +__BEGIN_DECLS /* Private failpoint eval function -- use fail_point_eval() instead. */ enum fail_point_return_code fail_point_eval_nontrivial(struct fail_point *, @@ -152,6 +126,8 @@ fail_point_eval(struct fail_point *fp, i return (fail_point_eval_nontrivial(fp, ret)); } +__END_DECLS + /* Declare a fail_point and its sysctl in a function. */ #define _FAIL_POINT_NAME(name) _fail_point_##name #define _STRINGIFY_HELPER(x) #x @@ -233,7 +209,7 @@ fail_point_eval(struct fail_point *fp, i NULL, NULL, \ }; \ SYSCTL_OID(parent, OID_AUTO, name, \ - CTLTYPE_STRING | CTLFLAG_RW, \ + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, \ &_FAIL_POINT_NAME(name), 0, fail_point_sysctl, \ "A", ""); \ \ @@ -254,7 +230,7 @@ int fail_point_sysctl(SYSCTL_HANDLER_ARG /* The fail point sysctl tree. */ SYSCTL_DECL(_debug_fail_point); +#define DEBUG_FP _debug_fail_point #endif -#define DEBUG_FP _debug_fail_point #endif /* _SYS_FAIL_H_ */