Add basic BIO_DELETE support to GEOM RAID class for all RAID levels.

If at least one subdisk in the volume supports it, BIO_DELETE requests
will be propagated down.  Unfortunatelly, for RAID levels with redundancy
unmapped blocks will be mapped back during first rebuild/resync process.

Sponsored by:	iXsystems, Inc.
MFC after:	1 month
This commit is contained in:
Alexander Motin 2012-10-29 18:04:38 +00:00
parent 1af2d09b49
commit 609a74746a
12 changed files with 91 additions and 173 deletions

View File

@ -498,6 +498,34 @@ g_raid_get_diskname(struct g_raid_disk *disk)
return (disk->d_consumer->provider->name);
}
void
g_raid_get_disk_info(struct g_raid_disk *disk)
{
struct g_consumer *cp = disk->d_consumer;
int error, len;
/* Read kernel dumping information. */
disk->d_kd.offset = 0;
disk->d_kd.length = OFF_MAX;
len = sizeof(disk->d_kd);
error = g_io_getattr("GEOM::kerneldump", cp, &len, &disk->d_kd);
if (error)
disk->d_kd.di.dumper = NULL;
if (disk->d_kd.di.dumper == NULL)
G_RAID_DEBUG1(2, disk->d_softc,
"Dumping not supported by %s: %d.",
cp->provider->name, error);
/* Read BIO_DELETE support. */
error = g_getattr("GEOM::candelete", cp, &disk->d_candelete);
if (error)
disk->d_candelete = 0;
if (!disk->d_candelete)
G_RAID_DEBUG1(2, disk->d_softc,
"BIO_DELETE not supported by %s: %d.",
cp->provider->name, error);
}
void
g_raid_report_disk_state(struct g_raid_disk *disk)
{
@ -1051,6 +1079,31 @@ g_raid_kerneldump(struct g_raid_softc *sc, struct bio *bp)
g_io_deliver(bp, 0);
}
static void
g_raid_candelete(struct g_raid_softc *sc, struct bio *bp)
{
struct g_provider *pp;
struct g_raid_volume *vol;
struct g_raid_subdisk *sd;
int *val;
int i;
val = (int *)bp->bio_data;
pp = bp->bio_to;
vol = pp->private;
*val = 0;
for (i = 0; i < vol->v_disks_count; i++) {
sd = &vol->v_subdisks[i];
if (sd->sd_state == G_RAID_SUBDISK_S_NONE)
continue;
if (sd->sd_disk->d_candelete) {
*val = 1;
break;
}
}
g_io_deliver(bp, 0);
}
static void
g_raid_start(struct bio *bp)
{
@ -1073,7 +1126,9 @@ g_raid_start(struct bio *bp)
case BIO_FLUSH:
break;
case BIO_GETATTR:
if (!strcmp(bp->bio_attribute, "GEOM::kerneldump"))
if (!strcmp(bp->bio_attribute, "GEOM::candelete"))
g_raid_candelete(sc, bp);
else if (!strcmp(bp->bio_attribute, "GEOM::kerneldump"))
g_raid_kerneldump(sc, bp);
else
g_io_deliver(bp, EOPNOTSUPP);

View File

@ -153,6 +153,7 @@ struct g_raid_disk {
struct g_consumer *d_consumer; /* GEOM disk consumer. */
void *d_md_data; /* Disk's metadata storage. */
struct g_kerneldump d_kd; /* Kernel dumping method/args. */
int d_candelete; /* BIO_DELETE supported. */
uint64_t d_flags; /* Additional flags. */
u_int d_state; /* Disk state. */
u_int d_load; /* Disk average load. */
@ -418,6 +419,7 @@ struct g_raid_volume * g_raid_create_volume(struct g_raid_softc *sc,
const char *name, int id);
struct g_raid_disk * g_raid_create_disk(struct g_raid_softc *sc);
const char * g_raid_get_diskname(struct g_raid_disk *disk);
void g_raid_get_disk_info(struct g_raid_disk *disk);
int g_raid_start_volume(struct g_raid_volume *vol);

View File

@ -2087,7 +2087,7 @@ g_raid_md_taste_ddf(struct g_raid_md_object *md, struct g_class *mp,
struct g_raid_md_ddf_perdisk *pd;
struct g_raid_md_ddf_object *mdi;
struct g_geom *geom;
int error, result, len, be;
int error, result, be;
char name[16];
G_RAID_DEBUG(1, "Tasting DDF on %s", cp->provider->name);
@ -2154,14 +2154,7 @@ g_raid_md_taste_ddf(struct g_raid_md_object *md, struct g_class *mp,
disk->d_consumer = rcp;
rcp->private = disk;
/* Read kernel dumping information. */
disk->d_kd.offset = 0;
disk->d_kd.length = OFF_MAX;
len = sizeof(disk->d_kd);
error = g_io_getattr("GEOM::kerneldump", rcp, &len, &disk->d_kd);
if (disk->d_kd.di.dumper == NULL)
G_RAID_DEBUG1(2, sc, "Dumping not supported by %s: %d.",
rcp->provider->name, error);
g_raid_get_disk_info(disk);
g_raid_md_ddf_new_disk(disk);
@ -2348,15 +2341,7 @@ g_raid_md_ctl_ddf(struct g_raid_md_object *md,
ddf_meta_update(&mdi->mdio_meta, &pd->pd_meta);
g_topology_unlock();
/* Read kernel dumping information. */
disk->d_kd.offset = 0;
disk->d_kd.length = OFF_MAX;
len = sizeof(disk->d_kd);
g_io_getattr("GEOM::kerneldump", cp, &len, &disk->d_kd);
if (disk->d_kd.di.dumper == NULL)
G_RAID_DEBUG1(2, sc,
"Dumping not supported by %s.",
cp->provider->name);
g_raid_get_disk_info(disk);
/* Reserve some space for metadata. */
size = MIN(size, GET64(&pd->pd_meta,
@ -2675,15 +2660,7 @@ g_raid_md_ctl_ddf(struct g_raid_md_object *md,
disk->d_md_data = (void *)pd;
cp->private = disk;
/* Read kernel dumping information. */
disk->d_kd.offset = 0;
disk->d_kd.length = OFF_MAX;
len = sizeof(disk->d_kd);
g_io_getattr("GEOM::kerneldump", cp, &len, &disk->d_kd);
if (disk->d_kd.di.dumper == NULL)
G_RAID_DEBUG1(2, sc,
"Dumping not supported by %s.",
cp->provider->name);
g_raid_get_disk_info(disk);
/* Welcome the "new" disk. */
g_raid_change_disk_state(disk, G_RAID_DISK_S_SPARE);

View File

@ -1369,14 +1369,7 @@ g_raid_md_taste_intel(struct g_raid_md_object *md, struct g_class *mp,
disk->d_consumer = rcp;
rcp->private = disk;
/* Read kernel dumping information. */
disk->d_kd.offset = 0;
disk->d_kd.length = OFF_MAX;
len = sizeof(disk->d_kd);
error = g_io_getattr("GEOM::kerneldump", rcp, &len, &disk->d_kd);
if (disk->d_kd.di.dumper == NULL)
G_RAID_DEBUG1(2, sc, "Dumping not supported by %s: %d.",
rcp->provider->name, error);
g_raid_get_disk_info(disk);
g_raid_md_intel_new_disk(disk);
@ -1556,15 +1549,7 @@ g_raid_md_ctl_intel(struct g_raid_md_object *md,
break;
}
/* Read kernel dumping information. */
disk->d_kd.offset = 0;
disk->d_kd.length = OFF_MAX;
len = sizeof(disk->d_kd);
g_io_getattr("GEOM::kerneldump", cp, &len, &disk->d_kd);
if (disk->d_kd.di.dumper == NULL)
G_RAID_DEBUG1(2, sc,
"Dumping not supported by %s.",
cp->provider->name);
g_raid_get_disk_info(disk);
intel_set_disk_sectors(&pd->pd_disk_meta,
pp->mediasize / pp->sectorsize);
@ -2080,15 +2065,7 @@ g_raid_md_ctl_intel(struct g_raid_md_object *md,
disk->d_md_data = (void *)pd;
cp->private = disk;
/* Read kernel dumping information. */
disk->d_kd.offset = 0;
disk->d_kd.length = OFF_MAX;
len = sizeof(disk->d_kd);
g_io_getattr("GEOM::kerneldump", cp, &len, &disk->d_kd);
if (disk->d_kd.di.dumper == NULL)
G_RAID_DEBUG1(2, sc,
"Dumping not supported by %s.",
cp->provider->name);
g_raid_get_disk_info(disk);
memcpy(&pd->pd_disk_meta.serial[0], &serial[0],
INTEL_SERIAL_LEN);

View File

@ -826,7 +826,7 @@ g_raid_md_taste_jmicron(struct g_raid_md_object *md, struct g_class *mp,
struct jmicron_raid_conf *meta;
struct g_raid_md_jmicron_perdisk *pd;
struct g_geom *geom;
int error, disk_pos, result, spare, len;
int disk_pos, result, spare, len;
char name[16];
uint16_t vendor;
@ -945,14 +945,7 @@ g_raid_md_taste_jmicron(struct g_raid_md_object *md, struct g_class *mp,
disk->d_consumer = rcp;
rcp->private = disk;
/* Read kernel dumping information. */
disk->d_kd.offset = 0;
disk->d_kd.length = OFF_MAX;
len = sizeof(disk->d_kd);
error = g_io_getattr("GEOM::kerneldump", rcp, &len, &disk->d_kd);
if (disk->d_kd.di.dumper == NULL)
G_RAID_DEBUG1(2, sc, "Dumping not supported by %s: %d.",
rcp->provider->name, error);
g_raid_get_disk_info(disk);
g_raid_md_jmicron_new_disk(disk);
@ -1115,15 +1108,7 @@ g_raid_md_ctl_jmicron(struct g_raid_md_object *md,
cp->private = disk;
g_topology_unlock();
/* Read kernel dumping information. */
disk->d_kd.offset = 0;
disk->d_kd.length = OFF_MAX;
len = sizeof(disk->d_kd);
g_io_getattr("GEOM::kerneldump", cp, &len, &disk->d_kd);
if (disk->d_kd.di.dumper == NULL)
G_RAID_DEBUG1(2, sc,
"Dumping not supported by %s.",
cp->provider->name);
g_raid_get_disk_info(disk);
pd->pd_disk_size = pp->mediasize;
if (size > pp->mediasize)
@ -1374,15 +1359,7 @@ g_raid_md_ctl_jmicron(struct g_raid_md_object *md,
cp->private = disk;
g_topology_unlock();
/* Read kernel dumping information. */
disk->d_kd.offset = 0;
disk->d_kd.length = OFF_MAX;
len = sizeof(disk->d_kd);
g_io_getattr("GEOM::kerneldump", cp, &len, &disk->d_kd);
if (disk->d_kd.di.dumper == NULL)
G_RAID_DEBUG1(2, sc,
"Dumping not supported by %s.",
cp->provider->name);
g_raid_get_disk_info(disk);
/* Welcome the "new" disk. */
update += g_raid_md_jmicron_start_disk(disk);

View File

@ -830,7 +830,7 @@ g_raid_md_taste_nvidia(struct g_raid_md_object *md, struct g_class *mp,
struct nvidia_raid_conf *meta;
struct g_raid_md_nvidia_perdisk *pd;
struct g_geom *geom;
int error, result, spare, len;
int result, spare, len;
char name[32];
uint16_t vendor;
@ -939,14 +939,7 @@ g_raid_md_taste_nvidia(struct g_raid_md_object *md, struct g_class *mp,
disk->d_consumer = rcp;
rcp->private = disk;
/* Read kernel dumping information. */
disk->d_kd.offset = 0;
disk->d_kd.length = OFF_MAX;
len = sizeof(disk->d_kd);
error = g_io_getattr("GEOM::kerneldump", rcp, &len, &disk->d_kd);
if (disk->d_kd.di.dumper == NULL)
G_RAID_DEBUG1(2, sc, "Dumping not supported by %s: %d.",
rcp->provider->name, error);
g_raid_get_disk_info(disk);
g_raid_md_nvidia_new_disk(disk);
@ -1117,15 +1110,7 @@ g_raid_md_ctl_nvidia(struct g_raid_md_object *md,
cp->private = disk;
g_topology_unlock();
/* Read kernel dumping information. */
disk->d_kd.offset = 0;
disk->d_kd.length = OFF_MAX;
len = sizeof(disk->d_kd);
g_io_getattr("GEOM::kerneldump", cp, &len, &disk->d_kd);
if (disk->d_kd.di.dumper == NULL)
G_RAID_DEBUG1(2, sc,
"Dumping not supported by %s.",
cp->provider->name);
g_raid_get_disk_info(disk);
pd->pd_disk_size = pp->mediasize;
if (size > pp->mediasize)
@ -1377,15 +1362,7 @@ g_raid_md_ctl_nvidia(struct g_raid_md_object *md,
cp->private = disk;
g_topology_unlock();
/* Read kernel dumping information. */
disk->d_kd.offset = 0;
disk->d_kd.length = OFF_MAX;
len = sizeof(disk->d_kd);
g_io_getattr("GEOM::kerneldump", cp, &len, &disk->d_kd);
if (disk->d_kd.di.dumper == NULL)
G_RAID_DEBUG1(2, sc,
"Dumping not supported by %s.",
cp->provider->name);
g_raid_get_disk_info(disk);
/* Welcome the "new" disk. */
update += g_raid_md_nvidia_start_disk(disk);

View File

@ -1046,7 +1046,7 @@ g_raid_md_taste_promise(struct g_raid_md_object *md, struct g_class *mp,
struct promise_raid_conf *meta, *metaarr[4];
struct g_raid_md_promise_perdisk *pd;
struct g_geom *geom;
int error, i, j, result, len, subdisks;
int i, j, result, len, subdisks;
char name[16];
uint16_t vendor;
@ -1142,14 +1142,7 @@ g_raid_md_taste_promise(struct g_raid_md_object *md, struct g_class *mp,
disk->d_consumer = rcp;
rcp->private = disk;
/* Read kernel dumping information. */
disk->d_kd.offset = 0;
disk->d_kd.length = OFF_MAX;
len = sizeof(disk->d_kd);
error = g_io_getattr("GEOM::kerneldump", rcp, &len, &disk->d_kd);
if (disk->d_kd.di.dumper == NULL)
G_RAID_DEBUG1(2, sc, "Dumping not supported by %s: %d.",
rcp->provider->name, error);
g_raid_get_disk_info(disk);
g_raid_md_promise_new_disk(disk);
@ -1337,15 +1330,7 @@ g_raid_md_ctl_promise(struct g_raid_md_object *md,
break;
}
/* Read kernel dumping information. */
disk->d_kd.offset = 0;
disk->d_kd.length = OFF_MAX;
len = sizeof(disk->d_kd);
g_io_getattr("GEOM::kerneldump", cp, &len, &disk->d_kd);
if (disk->d_kd.di.dumper == NULL)
G_RAID_DEBUG1(2, sc,
"Dumping not supported by %s.",
cp->provider->name);
g_raid_get_disk_info(disk);
/* Reserve some space for metadata. */
size = MIN(size, pp->mediasize - 131072llu * pp->sectorsize);
@ -1659,15 +1644,7 @@ g_raid_md_ctl_promise(struct g_raid_md_object *md,
disk->d_md_data = (void *)pd;
cp->private = disk;
/* Read kernel dumping information. */
disk->d_kd.offset = 0;
disk->d_kd.length = OFF_MAX;
len = sizeof(disk->d_kd);
g_io_getattr("GEOM::kerneldump", cp, &len, &disk->d_kd);
if (disk->d_kd.di.dumper == NULL)
G_RAID_DEBUG1(2, sc,
"Dumping not supported by %s.",
cp->provider->name);
g_raid_get_disk_info(disk);
/* Welcome the "new" disk. */
g_raid_change_disk_state(disk, G_RAID_DISK_S_SPARE);

View File

@ -912,7 +912,7 @@ g_raid_md_taste_sii(struct g_raid_md_object *md, struct g_class *mp,
struct sii_raid_conf *meta;
struct g_raid_md_sii_perdisk *pd;
struct g_geom *geom;
int error, disk_pos, result, spare, len;
int disk_pos, result, spare, len;
char name[32];
uint16_t vendor;
@ -1032,14 +1032,7 @@ g_raid_md_taste_sii(struct g_raid_md_object *md, struct g_class *mp,
disk->d_consumer = rcp;
rcp->private = disk;
/* Read kernel dumping information. */
disk->d_kd.offset = 0;
disk->d_kd.length = OFF_MAX;
len = sizeof(disk->d_kd);
error = g_io_getattr("GEOM::kerneldump", rcp, &len, &disk->d_kd);
if (disk->d_kd.di.dumper == NULL)
G_RAID_DEBUG1(2, sc, "Dumping not supported by %s: %d.",
rcp->provider->name, error);
g_raid_get_disk_info(disk);
g_raid_md_sii_new_disk(disk);
@ -1201,15 +1194,7 @@ g_raid_md_ctl_sii(struct g_raid_md_object *md,
cp->private = disk;
g_topology_unlock();
/* Read kernel dumping information. */
disk->d_kd.offset = 0;
disk->d_kd.length = OFF_MAX;
len = sizeof(disk->d_kd);
g_io_getattr("GEOM::kerneldump", cp, &len, &disk->d_kd);
if (disk->d_kd.di.dumper == NULL)
G_RAID_DEBUG1(2, sc,
"Dumping not supported by %s.",
cp->provider->name);
g_raid_get_disk_info(disk);
pd->pd_disk_size = pp->mediasize;
if (size > pp->mediasize)
@ -1459,15 +1444,7 @@ g_raid_md_ctl_sii(struct g_raid_md_object *md,
cp->private = disk;
g_topology_unlock();
/* Read kernel dumping information. */
disk->d_kd.offset = 0;
disk->d_kd.length = OFF_MAX;
len = sizeof(disk->d_kd);
g_io_getattr("GEOM::kerneldump", cp, &len, &disk->d_kd);
if (disk->d_kd.di.dumper == NULL)
G_RAID_DEBUG1(2, sc,
"Dumping not supported by %s.",
cp->provider->name);
g_raid_get_disk_info(disk);
/* Welcome the "new" disk. */
update += g_raid_md_sii_start_disk(disk);

View File

@ -248,7 +248,8 @@ g_raid_tr_iostart_concat(struct g_raid_tr_object *tr, struct bio *bp)
cbp->bio_caller1 = sd;
bioq_insert_tail(&queue, cbp);
remain -= length;
addr += length;
if (bp->bio_cmd != BIO_DELETE)
addr += length;
offset = 0;
no++;
KASSERT(no < vol->v_disks_count || remain == 0,

View File

@ -234,7 +234,8 @@ g_raid_tr_iostart_raid0(struct g_raid_tr_object *tr, struct bio *bp)
offset += strip_size;
}
remain -= length;
addr += length;
if (bp->bio_cmd != BIO_DELETE)
addr += length;
start = 0;
} while (remain > 0);
for (cbp = bioq_first(&queue); cbp != NULL;

View File

@ -647,10 +647,8 @@ g_raid_tr_iostart_raid1(struct g_raid_tr_object *tr, struct bio *bp)
g_raid_tr_iostart_raid1_read(tr, bp);
break;
case BIO_WRITE:
g_raid_tr_iostart_raid1_write(tr, bp);
break;
case BIO_DELETE:
g_raid_iodone(bp, EIO);
g_raid_tr_iostart_raid1_write(tr, bp);
break;
case BIO_FLUSH:
g_raid_tr_flush_common(tr, bp);
@ -893,7 +891,7 @@ g_raid_tr_iodone_raid1(struct g_raid_tr_object *tr,
g_raid_unlock_range(sd->sd_volume, bp->bio_offset,
bp->bio_length);
}
if (pbp->bio_cmd != BIO_READ) {
if (pbp->bio_cmd == BIO_WRITE) {
if (pbp->bio_inbed == 1 || pbp->bio_error != 0)
pbp->bio_error = bp->bio_error;
if (bp->bio_error != 0) {

View File

@ -802,7 +802,8 @@ g_raid_tr_iostart_raid1e_write(struct g_raid_tr_object *tr, struct bio *bp)
}
}
remain -= length;
addr += length;
if (bp->bio_cmd != BIO_DELETE)
addr += length;
start = 0;
}
for (cbp = bioq_first(&queue); cbp != NULL;
@ -858,10 +859,8 @@ g_raid_tr_iostart_raid1e(struct g_raid_tr_object *tr, struct bio *bp)
g_raid_tr_iostart_raid1e_read(tr, bp);
break;
case BIO_WRITE:
g_raid_tr_iostart_raid1e_write(tr, bp);
break;
case BIO_DELETE:
g_raid_iodone(bp, EIO);
g_raid_tr_iostart_raid1e_write(tr, bp);
break;
case BIO_FLUSH:
g_raid_tr_flush_common(tr, bp);
@ -1119,7 +1118,7 @@ g_raid_tr_iodone_raid1e(struct g_raid_tr_object *tr,
G_RAID_LOGREQ(2, bp, "REMAP done %d.", bp->bio_error);
g_raid_unlock_range(sd->sd_volume, virtual, bp->bio_length);
}
if (pbp->bio_cmd != BIO_READ) {
if (pbp->bio_cmd == BIO_WRITE) {
if (pbp->bio_inbed == 1 || pbp->bio_error != 0)
pbp->bio_error = bp->bio_error;
if (bp->bio_error != 0) {