1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-19 10:53:58 +00:00

- Fix 'rebuild' command - it can no longer relay on retaste event

(we ignore it).
- Remove code used for handling spoil events, as spoiling is not possible
  anymore, because we keep consumers open for writing all the time.

MFC after:	4 days
This commit is contained in:
Pawel Jakub Dawidek 2005-01-04 12:15:21 +00:00
parent da84416791
commit ea973705b3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=139671
3 changed files with 34 additions and 50 deletions

View File

@ -611,22 +611,7 @@ g_raid3_orphan(struct g_consumer *cp)
disk = cp->private; disk = cp->private;
if (disk == NULL) if (disk == NULL)
return; return;
disk->d_softc->sc_bump_id = G_RAID3_BUMP_SYNCID_OFW; disk->d_softc->sc_bump_id = G_RAID3_BUMP_SYNCID;
g_raid3_event_send(disk, G_RAID3_DISK_STATE_DISCONNECTED,
G_RAID3_EVENT_DONTWAIT);
}
static void
g_raid3_spoiled(struct g_consumer *cp)
{
struct g_raid3_disk *disk;
g_topology_assert();
disk = cp->private;
if (disk == NULL)
return;
disk->d_softc->sc_bump_id = G_RAID3_BUMP_SYNCID_IMM;
g_raid3_event_send(disk, G_RAID3_DISK_STATE_DISCONNECTED, g_raid3_event_send(disk, G_RAID3_DISK_STATE_DISCONNECTED,
G_RAID3_EVENT_DONTWAIT); G_RAID3_EVENT_DONTWAIT);
} }
@ -659,7 +644,7 @@ g_raid3_write_metadata(struct g_raid3_disk *disk, struct g_raid3_metadata *md)
g_topology_lock(); g_topology_lock();
free(sector, M_RAID3); free(sector, M_RAID3);
if (error != 0) { if (error != 0) {
disk->d_softc->sc_bump_id = G_RAID3_BUMP_GENID_IMM; disk->d_softc->sc_bump_id = G_RAID3_BUMP_GENID;
g_raid3_event_send(disk, G_RAID3_DISK_STATE_DISCONNECTED, g_raid3_event_send(disk, G_RAID3_DISK_STATE_DISCONNECTED,
G_RAID3_EVENT_DONTWAIT); G_RAID3_EVENT_DONTWAIT);
} }
@ -1093,7 +1078,7 @@ g_raid3_gather(struct bio *pbp)
* Actually this is pointless to bump genid, * Actually this is pointless to bump genid,
* because whole device is fucked up. * because whole device is fucked up.
*/ */
sc->sc_bump_id |= G_RAID3_BUMP_GENID_IMM; sc->sc_bump_id |= G_RAID3_BUMP_GENID;
g_raid3_event_send(disk, g_raid3_event_send(disk,
G_RAID3_DISK_STATE_DISCONNECTED, G_RAID3_DISK_STATE_DISCONNECTED,
G_RAID3_EVENT_DONTWAIT); G_RAID3_EVENT_DONTWAIT);
@ -1256,8 +1241,7 @@ g_raid3_regular_request(struct bio *cbp)
if (cbp->bio_error != 0) { if (cbp->bio_error != 0) {
disk = cbp->bio_caller2; disk = cbp->bio_caller2;
if (disk != NULL) { if (disk != NULL) {
sc->sc_bump_id |= sc->sc_bump_id |= G_RAID3_BUMP_GENID;
G_RAID3_BUMP_GENID_IMM;
g_raid3_event_send(disk, g_raid3_event_send(disk,
G_RAID3_DISK_STATE_DISCONNECTED, G_RAID3_DISK_STATE_DISCONNECTED,
G_RAID3_EVENT_DONTWAIT); G_RAID3_EVENT_DONTWAIT);
@ -1457,7 +1441,7 @@ g_raid3_sync_request(struct bio *bp)
"Synchronization request failed (error=%d).", "Synchronization request failed (error=%d).",
bp->bio_error); bp->bio_error);
g_destroy_bio(bp); g_destroy_bio(bp);
sc->sc_bump_id |= G_RAID3_BUMP_GENID_IMM; sc->sc_bump_id |= G_RAID3_BUMP_GENID;
g_raid3_event_send(disk, g_raid3_event_send(disk,
G_RAID3_DISK_STATE_DISCONNECTED, G_RAID3_DISK_STATE_DISCONNECTED,
G_RAID3_EVENT_DONTWAIT); G_RAID3_EVENT_DONTWAIT);
@ -1657,7 +1641,7 @@ g_raid3_register_request(struct bio *pbp)
/* /*
* Bump syncid on first write. * Bump syncid on first write.
*/ */
if ((sc->sc_bump_id & G_RAID3_BUMP_SYNCID_OFW) != 0) { if ((sc->sc_bump_id & G_RAID3_BUMP_SYNCID) != 0) {
sc->sc_bump_id &= ~G_RAID3_BUMP_SYNCID; sc->sc_bump_id &= ~G_RAID3_BUMP_SYNCID;
g_topology_lock(); g_topology_lock();
g_raid3_bump_syncid(sc); g_raid3_bump_syncid(sc);
@ -2248,7 +2232,7 @@ g_raid3_update_device(struct g_raid3_softc *sc, boolean_t force)
sc->sc_syncid = syncid; sc->sc_syncid = syncid;
if (force) { if (force) {
/* Remember to bump syncid on first write. */ /* Remember to bump syncid on first write. */
sc->sc_bump_id |= G_RAID3_BUMP_SYNCID_OFW; sc->sc_bump_id |= G_RAID3_BUMP_SYNCID;
} }
if (ndisks == sc->sc_ndisks) if (ndisks == sc->sc_ndisks)
state = G_RAID3_DEVICE_STATE_COMPLETE; state = G_RAID3_DEVICE_STATE_COMPLETE;
@ -2265,20 +2249,15 @@ g_raid3_update_device(struct g_raid3_softc *sc, boolean_t force)
state = g_raid3_determine_state(disk); state = g_raid3_determine_state(disk);
g_raid3_event_send(disk, state, G_RAID3_EVENT_DONTWAIT); g_raid3_event_send(disk, state, G_RAID3_EVENT_DONTWAIT);
if (state == G_RAID3_DISK_STATE_STALE) if (state == G_RAID3_DISK_STATE_STALE)
sc->sc_bump_id |= G_RAID3_BUMP_SYNCID_OFW; sc->sc_bump_id |= G_RAID3_BUMP_SYNCID;
} }
break; break;
} }
case G_RAID3_DEVICE_STATE_DEGRADED: case G_RAID3_DEVICE_STATE_DEGRADED:
/* /*
* Bump syncid and/or genid here, if we need to do it * Genid need to be bumped immediately, so do it here.
* immediately.
*/ */
if ((sc->sc_bump_id & G_RAID3_BUMP_SYNCID_IMM) != 0) { if ((sc->sc_bump_id & G_RAID3_BUMP_GENID) != 0) {
sc->sc_bump_id &= ~G_RAID3_BUMP_SYNCID;
g_raid3_bump_syncid(sc);
}
if ((sc->sc_bump_id & G_RAID3_BUMP_GENID_IMM) != 0) {
sc->sc_bump_id &= ~G_RAID3_BUMP_GENID; sc->sc_bump_id &= ~G_RAID3_BUMP_GENID;
g_raid3_bump_genid(sc); g_raid3_bump_genid(sc);
} }
@ -2306,14 +2285,9 @@ g_raid3_update_device(struct g_raid3_softc *sc, boolean_t force)
break; break;
case G_RAID3_DEVICE_STATE_COMPLETE: case G_RAID3_DEVICE_STATE_COMPLETE:
/* /*
* Bump syncid and/or genid here, if we need to do it * Genid need to be bumped immediately, so do it here.
* immediately.
*/ */
if ((sc->sc_bump_id & G_RAID3_BUMP_SYNCID_IMM) != 0) { if ((sc->sc_bump_id & G_RAID3_BUMP_GENID) != 0) {
sc->sc_bump_id &= ~G_RAID3_BUMP_SYNCID;
g_raid3_bump_syncid(sc);
}
if ((sc->sc_bump_id & G_RAID3_BUMP_GENID_IMM) != 0) {
sc->sc_bump_id &= ~G_RAID3_BUMP_GENID; sc->sc_bump_id &= ~G_RAID3_BUMP_GENID;
g_raid3_bump_genid(sc); g_raid3_bump_genid(sc);
} }
@ -2510,7 +2484,7 @@ g_raid3_update_disk(struct g_raid3_disk *disk, u_int state)
* Reset bumping syncid if disk disappeared in STARTING * Reset bumping syncid if disk disappeared in STARTING
* state. * state.
*/ */
if ((sc->sc_bump_id & G_RAID3_BUMP_SYNCID_OFW) != 0) if ((sc->sc_bump_id & G_RAID3_BUMP_SYNCID) != 0)
sc->sc_bump_id &= ~G_RAID3_BUMP_SYNCID; sc->sc_bump_id &= ~G_RAID3_BUMP_SYNCID;
#ifdef INVARIANTS #ifdef INVARIANTS
} else { } else {
@ -2535,7 +2509,7 @@ g_raid3_update_disk(struct g_raid3_disk *disk, u_int state)
} }
#undef DISK_STATE_CHANGED #undef DISK_STATE_CHANGED
static int int
g_raid3_read_metadata(struct g_consumer *cp, struct g_raid3_metadata *md) g_raid3_read_metadata(struct g_consumer *cp, struct g_raid3_metadata *md)
{ {
struct g_provider *pp; struct g_provider *pp;
@ -2663,7 +2637,7 @@ g_raid3_check_metadata(struct g_raid3_softc *sc, struct g_provider *pp,
return (0); return (0);
} }
static int int
g_raid3_add_disk(struct g_raid3_softc *sc, struct g_provider *pp, g_raid3_add_disk(struct g_raid3_softc *sc, struct g_provider *pp,
struct g_raid3_metadata *md) struct g_raid3_metadata *md)
{ {
@ -2766,7 +2740,6 @@ g_raid3_create(struct g_class *mp, const struct g_raid3_metadata *md)
sc->sc_disks = malloc(sizeof(struct g_raid3_disk) * md->md_all, M_RAID3, sc->sc_disks = malloc(sizeof(struct g_raid3_disk) * md->md_all, M_RAID3,
M_WAITOK | M_ZERO); M_WAITOK | M_ZERO);
gp->start = g_raid3_start; gp->start = g_raid3_start;
gp->spoiled = g_raid3_spoiled;
gp->orphan = g_raid3_orphan; gp->orphan = g_raid3_orphan;
gp->access = g_raid3_access; gp->access = g_raid3_access;
gp->dumpconf = g_raid3_dumpconf; gp->dumpconf = g_raid3_dumpconf;

View File

@ -163,14 +163,9 @@ struct g_raid3_event {
#define G_RAID3_DEVICE_STATE_COMPLETE 2 #define G_RAID3_DEVICE_STATE_COMPLETE 2
/* Bump syncid on first write. */ /* Bump syncid on first write. */
#define G_RAID3_BUMP_SYNCID_OFW 0x1 #define G_RAID3_BUMP_SYNCID 0x1
/* Bump syncid immediately. */
#define G_RAID3_BUMP_SYNCID_IMM 0x2
#define G_RAID3_BUMP_SYNCID (G_RAID3_BUMP_SYNCID_OFW | \
G_RAID3_BUMP_SYNCID_IMM)
/* Bump genid immediately. */ /* Bump genid immediately. */
#define G_RAID3_BUMP_GENID_IMM 0x4 #define G_RAID3_BUMP_GENID 0x2
#define G_RAID3_BUMP_GENID (G_RAID3_BUMP_GENID_IMM)
struct g_raid3_softc { struct g_raid3_softc {
u_int sc_state; /* Device state. */ u_int sc_state; /* Device state. */
@ -214,6 +209,9 @@ u_int g_raid3_ndisks(struct g_raid3_softc *sc, int state);
int g_raid3_destroy(struct g_raid3_softc *sc, boolean_t force); int g_raid3_destroy(struct g_raid3_softc *sc, boolean_t force);
int g_raid3_event_send(void *arg, int state, int flags); int g_raid3_event_send(void *arg, int state, int flags);
struct g_raid3_metadata; struct g_raid3_metadata;
int g_raid3_add_disk(struct g_raid3_softc *sc, struct g_provider *pp,
struct g_raid3_metadata *md);
int g_raid3_read_metadata(struct g_consumer *cp, struct g_raid3_metadata *md);
void g_raid3_fill_metadata(struct g_raid3_disk *disk, void g_raid3_fill_metadata(struct g_raid3_disk *disk,
struct g_raid3_metadata *md); struct g_raid3_metadata *md);
int g_raid3_clear_metadata(struct g_raid3_disk *disk); int g_raid3_clear_metadata(struct g_raid3_disk *disk);

View File

@ -220,10 +220,12 @@ g_raid3_ctl_configure(struct gctl_req *req, struct g_class *mp)
static void static void
g_raid3_ctl_rebuild(struct gctl_req *req, struct g_class *mp) g_raid3_ctl_rebuild(struct gctl_req *req, struct g_class *mp)
{ {
struct g_raid3_metadata md;
struct g_raid3_softc *sc; struct g_raid3_softc *sc;
struct g_raid3_disk *disk; struct g_raid3_disk *disk;
struct g_provider *pp;
const char *name; const char *name;
int *nargs; int error, *nargs;
g_topology_assert(); g_topology_assert();
nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs)); nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
@ -268,8 +270,19 @@ g_raid3_ctl_rebuild(struct gctl_req *req, struct g_class *mp)
if ((sc->sc_flags & G_RAID3_DEVICE_FLAG_NOAUTOSYNC) != 0) if ((sc->sc_flags & G_RAID3_DEVICE_FLAG_NOAUTOSYNC) != 0)
disk->d_flags |= G_RAID3_DISK_FLAG_FORCE_SYNC; disk->d_flags |= G_RAID3_DISK_FLAG_FORCE_SYNC;
g_raid3_update_metadata(disk); g_raid3_update_metadata(disk);
pp = disk->d_consumer->provider;
error = g_raid3_read_metadata(disk->d_consumer, &md);
g_raid3_event_send(disk, G_RAID3_DISK_STATE_DISCONNECTED, g_raid3_event_send(disk, G_RAID3_DISK_STATE_DISCONNECTED,
G_RAID3_EVENT_WAIT); G_RAID3_EVENT_WAIT);
if (error != 0) {
gctl_error(req, "Cannot read metadata from %s.", pp->name);
return;
}
error = g_raid3_add_disk(sc, pp, &md);
if (error != 0) {
gctl_error(req, "Cannot reconnect component %s.", pp->name);
return;
}
} }
static void static void