Add global and per-module sysctls/tunables to enable/disable metadata taste.

That should help to handle some cases when disk has some RAID metadata that
should be ignored, especially during boot.

MFC after:	3 days
This commit is contained in:
Alexander Motin 2012-09-13 13:27:09 +00:00
parent df3cbc41fa
commit c89d2fbe18
14 changed files with 75 additions and 32 deletions

View File

@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd May 6, 2012
.Dd September 13, 2012
.Dt GRAID 8
.Os
.Sh NAME
@ -293,6 +293,8 @@ Mark volume as clean when idle for the specified number of seconds.
Debug level of the
.Nm RAID
GEOM class.
.It Va kern.geom.raid.enable : No 1
Enable on-disk metadata taste.
.It Va kern.geom.raid.idle_threshold : No 1000000
Time in microseconds to consider a volume idle for rebuild purposes.
.It Va kern.geom.raid.name_format : No 0
@ -302,6 +304,8 @@ Number of read errors equated to disk failure.
Write errors are always considered as disk failures.
.It Va kern.geom.raid.start_timeout : No 30
Time to wait for missing array components on startup.
.It Va kern.geom.raid. Ns Ar X Ns Va .enable : No 1
Enable taste for specific metadata or transformation module.
.El
.Sh EXIT STATUS
Exit status is 0 on success, and non-zero if the command fails.

View File

@ -52,6 +52,10 @@ static MALLOC_DEFINE(M_RAID, "raid_data", "GEOM_RAID Data");
SYSCTL_DECL(_kern_geom);
SYSCTL_NODE(_kern_geom, OID_AUTO, raid, CTLFLAG_RW, 0, "GEOM_RAID stuff");
int g_raid_enable = 1;
TUNABLE_INT("kern.geom.raid.enable", &g_raid_enable);
SYSCTL_INT(_kern_geom_raid, OID_AUTO, enable, CTLFLAG_RW,
&g_raid_enable, 0, "Enable on-disk metadata taste");
u_int g_raid_aggressive_spare = 0;
TUNABLE_INT("kern.geom.raid.aggressive_spare", &g_raid_aggressive_spare);
SYSCTL_UINT(_kern_geom_raid, OID_AUTO, aggressive_spare, CTLFLAG_RW,
@ -1922,6 +1926,8 @@ int g_raid_start_volume(struct g_raid_volume *vol)
G_RAID_DEBUG1(2, vol->v_softc, "Starting volume %s.", vol->v_name);
LIST_FOREACH(class, &g_raid_tr_classes, trc_list) {
if (!class->trc_enable)
continue;
G_RAID_DEBUG1(2, vol->v_softc,
"Tasting volume %s for %s transformation.",
vol->v_name, class->name);
@ -2144,6 +2150,8 @@ g_raid_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_topology_assert();
g_trace(G_T_TOPOLOGY, "%s(%s, %s)", __func__, mp->name, pp->name);
if (!g_raid_enable)
return (NULL);
G_RAID_DEBUG(2, "Tasting provider %s.", pp->name);
gp = g_new_geomf(mp, "raid:taste");
@ -2156,6 +2164,8 @@ g_raid_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
geom = NULL;
LIST_FOREACH(class, &g_raid_md_classes, mdc_list) {
if (!class->mdc_enable)
continue;
G_RAID_DEBUG(2, "Tasting provider %s for %s metadata.",
pp->name, class->name);
obj = (void *)kobj_create((kobj_class_t)class, M_RAID,

View File

@ -33,6 +33,9 @@
#include <sys/kobj.h>
#include <sys/bio.h>
#include <sys/time.h>
#ifdef _KERNEL
#include <sys/sysctl.h>
#endif
#define G_RAID_CLASS_NAME "RAID"
@ -51,6 +54,7 @@ struct g_raid_tr_object;
#ifdef _KERNEL
extern u_int g_raid_aggressive_spare;
extern u_int g_raid_debug;
extern int g_raid_enable;
extern int g_raid_read_err_thresh;
extern u_int g_raid_start_timeout;
extern struct g_class g_raid_class;
@ -322,11 +326,14 @@ struct g_raid_softc {
};
#define sc_name sc_geom->name
SYSCTL_DECL(_kern_geom_raid);
/*
* KOBJ parent class of metadata processing modules.
*/
struct g_raid_md_class {
KOBJ_CLASS_FIELDS;
int mdc_enable;
int mdc_priority;
LIST_ENTRY(g_raid_md_class) mdc_list;
};
@ -342,20 +349,29 @@ struct g_raid_md_object {
int g_raid_md_modevent(module_t, int, void *);
#define G_RAID_MD_DECLARE(name) \
static moduledata_t name##_mod = { \
#name, \
#define G_RAID_MD_DECLARE(name, label) \
static moduledata_t g_raid_md_##name##_mod = { \
"g_raid_md_" __XSTRING(name), \
g_raid_md_modevent, \
&name##_class \
&g_raid_md_##name##_class \
}; \
DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND); \
MODULE_DEPEND(name, geom_raid, 0, 0, 0)
DECLARE_MODULE(g_raid_md_##name, g_raid_md_##name##_mod, \
SI_SUB_DRIVERS, SI_ORDER_SECOND); \
MODULE_DEPEND(g_raid_md_##name, geom_raid, 0, 0, 0); \
SYSCTL_NODE(_kern_geom_raid, OID_AUTO, name, CTLFLAG_RD, \
NULL, label " metadata module"); \
SYSCTL_INT(_kern_geom_raid_##name, OID_AUTO, enable, \
CTLFLAG_RW, &g_raid_md_##name##_class.mdc_enable, 0, \
"Enable " label " metadata format taste"); \
TUNABLE_INT("kern.geom.raid." __XSTRING(name) ".enable", \
&g_raid_md_##name##_class.mdc_enable)
/*
* KOBJ parent class of data transformation modules.
*/
struct g_raid_tr_class {
KOBJ_CLASS_FIELDS;
int trc_enable;
int trc_priority;
LIST_ENTRY(g_raid_tr_class) trc_list;
};
@ -371,14 +387,22 @@ struct g_raid_tr_object {
int g_raid_tr_modevent(module_t, int, void *);
#define G_RAID_TR_DECLARE(name) \
static moduledata_t name##_mod = { \
#name, \
#define G_RAID_TR_DECLARE(name, label) \
static moduledata_t g_raid_tr_##name##_mod = { \
"g_raid_tr_" __XSTRING(name), \
g_raid_tr_modevent, \
&name##_class \
&g_raid_tr_##name##_class \
}; \
DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); \
MODULE_DEPEND(name, geom_raid, 0, 0, 0)
DECLARE_MODULE(g_raid_tr_##name, g_raid_tr_##name##_mod, \
SI_SUB_DRIVERS, SI_ORDER_FIRST); \
MODULE_DEPEND(g_raid_tr_##name, geom_raid, 0, 0, 0); \
SYSCTL_NODE(_kern_geom_raid, OID_AUTO, name, CTLFLAG_RD, \
NULL, label " transformation module"); \
SYSCTL_INT(_kern_geom_raid_##name, OID_AUTO, enable, \
CTLFLAG_RW, &g_raid_tr_##name##_class.trc_enable, 0, \
"Enable " label " transformation module taste"); \
TUNABLE_INT("kern.geom.raid." __XSTRING(name) ".enable", \
&g_raid_tr_##name##_class.trc_enable)
const char * g_raid_volume_level2str(int level, int qual);
int g_raid_volume_str2level(const char *str, int *level, int *qual);

View File

@ -125,6 +125,7 @@ static struct g_raid_md_class g_raid_md_ddf_class = {
"DDF",
g_raid_md_ddf_methods,
sizeof(struct g_raid_md_ddf_object),
.mdc_enable = 1,
.mdc_priority = 100
};
@ -3065,4 +3066,4 @@ g_raid_md_free_ddf(struct g_raid_md_object *md)
return (0);
}
G_RAID_MD_DECLARE(g_raid_md_ddf);
G_RAID_MD_DECLARE(ddf, "DDF");

View File

@ -224,6 +224,7 @@ static struct g_raid_md_class g_raid_md_intel_class = {
"Intel",
g_raid_md_intel_methods,
sizeof(struct g_raid_md_intel_object),
.mdc_enable = 1,
.mdc_priority = 100
};
@ -2432,4 +2433,4 @@ g_raid_md_free_intel(struct g_raid_md_object *md)
return (0);
}
G_RAID_MD_DECLARE(g_raid_md_intel);
G_RAID_MD_DECLARE(intel, "Intel");

View File

@ -132,6 +132,7 @@ static struct g_raid_md_class g_raid_md_jmicron_class = {
"JMicron",
g_raid_md_jmicron_methods,
sizeof(struct g_raid_md_jmicron_object),
.mdc_enable = 1,
.mdc_priority = 100
};
@ -1581,4 +1582,4 @@ g_raid_md_free_jmicron(struct g_raid_md_object *md)
return (0);
}
G_RAID_MD_DECLARE(g_raid_md_jmicron);
G_RAID_MD_DECLARE(jmicron, "JMicron");

View File

@ -143,6 +143,7 @@ static struct g_raid_md_class g_raid_md_nvidia_class = {
"NVIDIA",
g_raid_md_nvidia_methods,
sizeof(struct g_raid_md_nvidia_object),
.mdc_enable = 1,
.mdc_priority = 100
};
@ -1600,4 +1601,4 @@ g_raid_md_free_nvidia(struct g_raid_md_object *md)
return (0);
}
G_RAID_MD_DECLARE(g_raid_md_nvidia);
G_RAID_MD_DECLARE(nvidia, "NVIDIA");

View File

@ -171,6 +171,7 @@ static struct g_raid_md_class g_raid_md_promise_class = {
"Promise",
g_raid_md_promise_methods,
sizeof(struct g_raid_md_object),
.mdc_enable = 1,
.mdc_priority = 100
};
@ -1967,4 +1968,4 @@ g_raid_md_free_promise(struct g_raid_md_object *md)
return (0);
}
G_RAID_MD_DECLARE(g_raid_md_promise);
G_RAID_MD_DECLARE(promise, "Promise");

View File

@ -140,6 +140,7 @@ static struct g_raid_md_class g_raid_md_sii_class = {
"SiI",
g_raid_md_sii_methods,
sizeof(struct g_raid_md_sii_object),
.mdc_enable = 1,
.mdc_priority = 100
};
@ -1688,4 +1689,4 @@ g_raid_md_free_sii(struct g_raid_md_object *md)
return (0);
}
G_RAID_MD_DECLARE(g_raid_md_sii);
G_RAID_MD_DECLARE(sii, "SiI");

View File

@ -73,6 +73,7 @@ static struct g_raid_tr_class g_raid_tr_concat_class = {
"CONCAT",
g_raid_tr_concat_methods,
sizeof(struct g_raid_tr_concat_object),
.trc_enable = 1,
.trc_priority = 50
};
@ -340,4 +341,4 @@ g_raid_tr_free_concat(struct g_raid_tr_object *tr)
return (0);
}
G_RAID_TR_DECLARE(g_raid_tr_concat);
G_RAID_TR_DECLARE(concat, "CONCAT");

View File

@ -73,6 +73,7 @@ static struct g_raid_tr_class g_raid_tr_raid0_class = {
"RAID0",
g_raid_tr_raid0_methods,
sizeof(struct g_raid_tr_raid0_object),
.trc_enable = 1,
.trc_priority = 100
};
@ -323,4 +324,4 @@ g_raid_tr_free_raid0(struct g_raid_tr_object *tr)
return (0);
}
G_RAID_TR_DECLARE(g_raid_tr_raid0);
G_RAID_TR_DECLARE(raid0, "RAID0");

View File

@ -42,9 +42,7 @@ __FBSDID("$FreeBSD$");
#include "geom/raid/g_raid.h"
#include "g_raid_tr_if.h"
SYSCTL_DECL(_kern_geom_raid);
static SYSCTL_NODE(_kern_geom_raid, OID_AUTO, raid1, CTLFLAG_RW, 0,
"RAID1 parameters");
SYSCTL_DECL(_kern_geom_raid_raid1);
#define RAID1_REBUILD_SLAB (1 << 20) /* One transation in a rebuild */
static int g_raid1_rebuild_slab = RAID1_REBUILD_SLAB;
@ -131,6 +129,7 @@ static struct g_raid_tr_class g_raid_tr_raid1_class = {
"RAID1",
g_raid_tr_raid1_methods,
sizeof(struct g_raid_tr_raid1_object),
.trc_enable = 1,
.trc_priority = 100
};
@ -996,4 +995,4 @@ g_raid_tr_free_raid1(struct g_raid_tr_object *tr)
return (0);
}
G_RAID_TR_DECLARE(g_raid_tr_raid1);
G_RAID_TR_DECLARE(raid1, "RAID1");

View File

@ -44,9 +44,7 @@ __FBSDID("$FreeBSD$");
#define N 2
SYSCTL_DECL(_kern_geom_raid);
static SYSCTL_NODE(_kern_geom_raid, OID_AUTO, raid1e, CTLFLAG_RW, 0,
"RAID1E parameters");
SYSCTL_DECL(_kern_geom_raid_raid1e);
#define RAID1E_REBUILD_SLAB (1 << 20) /* One transation in a rebuild */
static int g_raid1e_rebuild_slab = RAID1E_REBUILD_SLAB;
@ -135,6 +133,7 @@ static struct g_raid_tr_class g_raid_tr_raid1e_class = {
"RAID1E",
g_raid_tr_raid1e_methods,
sizeof(struct g_raid_tr_raid1e_object),
.trc_enable = 1,
.trc_priority = 200
};
@ -1236,4 +1235,4 @@ g_raid_tr_free_raid1e(struct g_raid_tr_object *tr)
return (0);
}
G_RAID_TR_DECLARE(g_raid_tr_raid1e);
G_RAID_TR_DECLARE(raid1e, "RAID1E");

View File

@ -42,8 +42,6 @@ __FBSDID("$FreeBSD$");
#include "geom/raid/g_raid.h"
#include "g_raid_tr_if.h"
SYSCTL_DECL(_kern_geom_raid);
static MALLOC_DEFINE(M_TR_RAID5, "tr_raid5_data", "GEOM_RAID RAID5 data");
#define TR_RAID5_NONE 0
@ -95,6 +93,7 @@ static struct g_raid_tr_class g_raid_tr_raid5_class = {
"RAID5",
g_raid_tr_raid5_methods,
sizeof(struct g_raid_tr_raid5_object),
.trc_enable = 1,
.trc_priority = 100
};
@ -419,4 +418,4 @@ g_raid_tr_free_raid5(struct g_raid_tr_object *tr)
return (0);
}
G_RAID_TR_DECLARE(g_raid_tr_raid5);
G_RAID_TR_DECLARE(raid5, "RAID5");