Handle spoil event in dedicated function: g_mirror_spoiled().

The different between the new function and g_mirror_orphan() (which was
used previously) is that syncid is bumped immediately, instead of on
first write, because when consumer was spoiled, it means, that its
provider was opened for writing, so we can't trust that its data
will be valid when it will be connected again.
This commit is contained in:
Pawel Jakub Dawidek 2004-07-31 21:08:17 +00:00
parent 8fc406a664
commit 4b2e596e38
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=132938

View file

@ -502,6 +502,21 @@ g_mirror_orphan(struct g_consumer *cp)
G_MIRROR_EVENT_DONTWAIT);
}
static void
g_mirror_spoiled(struct g_consumer *cp)
{
struct g_mirror_disk *disk;
g_topology_assert();
disk = cp->private;
if (disk == NULL)
return;
disk->d_softc->sc_bump_syncid = G_MIRROR_BUMP_IMMEDIATELY;
g_mirror_event_send(disk, G_MIRROR_DISK_STATE_DISCONNECTED,
G_MIRROR_EVENT_DONTWAIT);
}
/*
* Function should return the next active disk on the list.
* It is possible that it will be the same disk as given.
@ -2298,7 +2313,7 @@ g_mirror_create(struct g_class *mp, const struct g_mirror_metadata *md)
gp = g_new_geomf(mp, "%s", md->md_name);
sc = malloc(sizeof(*sc), M_MIRROR, M_WAITOK | M_ZERO);
gp->start = g_mirror_start;
gp->spoiled = g_mirror_orphan;
gp->spoiled = g_mirror_spoiled;
gp->orphan = g_mirror_orphan;
gp->access = g_mirror_access;
gp->dumpconf = g_mirror_dumpconf;
@ -2326,7 +2341,7 @@ g_mirror_create(struct g_class *mp, const struct g_mirror_metadata *md)
*/
gp = g_new_geomf(mp, "%s.sync", md->md_name);
gp->softc = sc;
gp->spoiled = g_mirror_orphan;
gp->spoiled = g_mirror_spoiled;
gp->orphan = g_mirror_orphan;
sc->sc_sync.ds_geom = gp;
sc->sc_sync.ds_block = atomic_load_acq_int(&g_mirror_sync_block_size);