Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Dec 2010 08:46:34 -0800
From:      mdf@FreeBSD.org
To:        src-committers@freebsd.org, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r216616 - in head/sys: kern sys
Message-ID:  <AANLkTimBbcg8GnoAj0h-gJhU9MbnwHKnovhx-d7fP7n7@mail.gmail.com>
In-Reply-To: <201012211629.oBLGTwh4069669@svn.freebsd.org>
References:  <201012211629.oBLGTwh4069669@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Dec 21, 2010 at 8:29 AM, Matthew D Fleming <mdf@freebsd.org> wrote:
> Author: mdf
> Date: Tue Dec 21 16:29:58 2010
> New Revision: 216616
> URL: http://svn.freebsd.org/changeset/base/216616
>
> Log:
> =A0Move the fail_point_entry definition from fail.h to kern_fail.c, which
> =A0allows putting the enumeration constants of fail point types with the
> =A0text string that matches them.

Forgot the other part of the change.  Mark the oid as MPSAFE since it
runs using an internal lock, add __BEGIN_DECLS/__END_DECLS tag around
the function declarations, and move a #define under the guard, since
using the define makes no sense if the sysctl node is not declared.

Thanks,
matthew

>
> =A0MFC after: =A0 =A01 week
>
> Modified:
> =A0head/sys/kern/kern_fail.c
> =A0head/sys/sys/fail.h
>
> Modified: head/sys/kern/kern_fail.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/kern/kern_fail.c =A0 Tue Dec 21 13:45:29 2010 =A0 =A0 =A0 =
=A0(r216615)
> +++ head/sys/kern/kern_fail.c =A0 Tue Dec 21 16:29:58 2010 =A0 =A0 =A0 =
=A0(r216616)
> @@ -76,6 +76,43 @@ MTX_SYSINIT(g_fp_mtx, &g_fp_mtx, "fail p
> =A0#define FP_LOCK() =A0 =A0 =A0mtx_lock(&g_fp_mtx)
> =A0#define FP_UNLOCK() =A0 =A0mtx_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 {
> + =A0 =A0 =A0 FAIL_POINT_OFF, =A0 =A0 =A0 =A0 /**< don't fail */
> + =A0 =A0 =A0 FAIL_POINT_PANIC, =A0 =A0 =A0 /**< panic */
> + =A0 =A0 =A0 FAIL_POINT_RETURN, =A0 =A0 =A0/**< return an errorcode */
> + =A0 =A0 =A0 FAIL_POINT_BREAK, =A0 =A0 =A0 /**< break into the debugger =
*/
> + =A0 =A0 =A0 FAIL_POINT_PRINT, =A0 =A0 =A0 /**< print a message */
> + =A0 =A0 =A0 FAIL_POINT_SLEEP, =A0 =A0 =A0 /**< sleep for some msecs */
> + =A0 =A0 =A0 FAIL_POINT_INVALID, =A0 =A0 /**< placeholder */
> +};
> +
> +static const char *fail_type_strings[] =3D {
> + =A0 =A0 =A0 "off",
> + =A0 =A0 =A0 "panic",
> + =A0 =A0 =A0 "return",
> + =A0 =A0 =A0 "break",
> + =A0 =A0 =A0 "print",
> + =A0 =A0 =A0 "sleep",
> +};
> +
> +/**
> + * Internal structure tracking a single term of a complete failpoint.
> + * @ingroup failpoint_private
> + */
> +struct fail_point_entry {
> + =A0 =A0 =A0 enum fail_point_t fe_type; =A0 =A0 =A0/**< type of entry */
> + =A0 =A0 =A0 int =A0 =A0 =A0 =A0 =A0 =A0 fe_arg; =A0 =A0 =A0 =A0 /**< ar=
gument to type (e.g. return value) */
> + =A0 =A0 =A0 int =A0 =A0 =A0 =A0 =A0 =A0 fe_prob; =A0 =A0 =A0 =A0/**< li=
kelihood of firing in millionths */
> + =A0 =A0 =A0 int =A0 =A0 =A0 =A0 =A0 =A0 fe_count; =A0 =A0 =A0 /**< numb=
er of times to fire, 0 means always */
> +
> + =A0 =A0 =A0 TAILQ_ENTRY(fail_point_entry) fe_entries; /**< next entry i=
n fail point */
> +};
> +
> =A0static inline void
> =A0fail_point_sleep(struct fail_point *fp, struct fail_point_entry *ent,
> =A0 =A0 int msecs, enum fail_point_return_code *pret)
> @@ -102,15 +139,6 @@ enum {
> =A0 =A0 =A0 =A0PROB_DIGITS =3D 6, =A0 =A0 =A0 =A0/* number of zero's in a=
bove number */
> =A0};
>
> -static const char *fail_type_strings[] =3D {
> - =A0 =A0 =A0 "off",
> - =A0 =A0 =A0 "panic",
> - =A0 =A0 =A0 "return",
> - =A0 =A0 =A0 "break",
> - =A0 =A0 =A0 "print",
> - =A0 =A0 =A0 "sleep",
> -};
> -
> =A0static char *parse_fail_point(struct fail_point_entries *, char *);
> =A0static char *parse_term(struct fail_point_entries *, char *);
> =A0static char *parse_number(int *out_units, int *out_decimal, char *);
>
> Modified: head/sys/sys/fail.h
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/sys/sys/fail.h Tue Dec 21 13:45:29 2010 =A0 =A0 =A0 =A0(r216615)
> +++ head/sys/sys/fail.h Tue Dec 21 16:29:58 2010 =A0 =A0 =A0 =A0(r216616)
> @@ -39,22 +39,6 @@
> =A0#include <sys/queue.h>
> =A0#include <sys/sysctl.h>
>
> -
> -/**
> - * Failpoint types.
> - * Don't change these without changing fail_type_strings in fail.c.
> - * @ingroup failpoint_private
> - */
> -enum fail_point_t {
> - =A0 =A0 =A0 FAIL_POINT_OFF, =A0 =A0 =A0 =A0 /**< don't fail */
> - =A0 =A0 =A0 FAIL_POINT_PANIC, =A0 =A0 =A0 /**< panic */
> - =A0 =A0 =A0 FAIL_POINT_RETURN, =A0 =A0 =A0/**< return an errorcode */
> - =A0 =A0 =A0 FAIL_POINT_BREAK, =A0 =A0 =A0 /**< break into the debugger =
*/
> - =A0 =A0 =A0 FAIL_POINT_PRINT, =A0 =A0 =A0 /**< print a message */
> - =A0 =A0 =A0 FAIL_POINT_SLEEP, =A0 =A0 =A0 /**< sleep for some msecs */
> - =A0 =A0 =A0 FAIL_POINT_INVALID, =A0 =A0 /**< placeholder */
> -};
> -
> =A0/**
> =A0* Failpoint return codes, used internally.
> =A0* @ingroup failpoint_private
> @@ -65,6 +49,7 @@ enum fail_point_return_code {
> =A0 =A0 =A0 =A0FAIL_POINT_RC_QUEUED, =A0 =A0 =A0 =A0 =A0 /**< sleep_fn wi=
ll be called */
> =A0};
>
> +struct fail_point_entry;
> =A0TAILQ_HEAD(fail_point_entries, fail_point_entry);
> =A0/**
> =A0* Internal failpoint structure, tracking all the current details of th=
e
> @@ -84,18 +69,7 @@ struct fail_point {
>
> =A0#define =A0 =A0 =A0 =A0FAIL_POINT_DYNAMIC_NAME 0x01 =A0 =A0/**< Must f=
ree name on destroy */
>
> -/**
> - * Internal structure tracking a single term of a complete failpoint.
> - * @ingroup failpoint_private
> - */
> -struct fail_point_entry {
> - =A0 =A0 =A0 enum fail_point_t fe_type; =A0 =A0 =A0/**< type of entry */
> - =A0 =A0 =A0 int =A0 =A0 =A0 =A0 =A0 =A0 fe_arg; =A0 =A0 =A0 =A0 /**< ar=
gument to type (e.g. return value) */
> - =A0 =A0 =A0 int =A0 =A0 =A0 =A0 =A0 =A0 fe_prob; =A0 =A0 =A0 =A0/**< li=
kelihood of firing in millionths */
> - =A0 =A0 =A0 int =A0 =A0 =A0 =A0 =A0 =A0 fe_count; =A0 =A0 =A0 /**< numb=
er of times to fire, 0 means always */
> -
> - =A0 =A0 =A0 TAILQ_ENTRY(fail_point_entry) fe_entries; /**< next entry i=
n fail point */
> -};
> +__BEGIN_DECLS
>
> =A0/* Private failpoint eval function -- use fail_point_eval() instead. *=
/
> =A0enum fail_point_return_code fail_point_eval_nontrivial(struct fail_poi=
nt *,
> @@ -152,6 +126,8 @@ fail_point_eval(struct fail_point *fp, i
> =A0 =A0 =A0 =A0return (fail_point_eval_nontrivial(fp, ret));
> =A0}
>
> +__END_DECLS
> +
> =A0/* Declare a fail_point and its sysctl in a function. */
> =A0#define _FAIL_POINT_NAME(name) _fail_point_##name
> =A0#define _STRINGIFY_HELPER(x) #x
> @@ -233,7 +209,7 @@ fail_point_eval(struct fail_point *fp, i
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0NULL, NULL, =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0SYSCTL_OID(parent, OID_AUTO, name, =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 CTLTYPE_STRING | CTLFLAG_RW=
, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 CTLTYPE_STRING | CTLFLAG_RW=
 | CTLFLAG_MPSAFE, =A0 \
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&_FAIL_POINT_NAME(name), 0=
, fail_point_sysctl, =A0\
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"A", ""); =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\
> @@ -254,7 +230,7 @@ int fail_point_sysctl(SYSCTL_HANDLER_ARG
>
> =A0/* The fail point sysctl tree. */
> =A0SYSCTL_DECL(_debug_fail_point);
> +#define =A0 =A0 =A0 =A0DEBUG_FP =A0 =A0 =A0 =A0_debug_fail_point
> =A0#endif
> -#define DEBUG_FP _debug_fail_point
>
> =A0#endif /* _SYS_FAIL_H_ */
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTimBbcg8GnoAj0h-gJhU9MbnwHKnovhx-d7fP7n7>