Add function moveobject, which currently moves subdisks to different

drives.  This function just does the low-level configuration changes;
the resultant subdisk is stale if it previously had any contents,
otherwise it is empty (i.e. in need of initializing if it's RAID-5).
We still need to handle getting the contents moved over, but the
current version will suffice to migrate subdisks from a disk which has
failed.

Submitted-by:  Marius Bendiksen <marius@marius.scancall.no>
This commit is contained in:
Greg Lehey 2000-01-05 06:07:26 +00:00
parent 233fb3be1e
commit 5756902abc

View File

@ -57,6 +57,7 @@ void attachobject(struct vinum_ioctl_msg *);
void detachobject(struct vinum_ioctl_msg *);
void renameobject(struct vinum_rename_msg *);
void replaceobject(struct vinum_ioctl_msg *);
void moveobject(struct vinum_ioctl_msg *);
jmp_buf command_fail; /* return on a failed command */
@ -310,6 +311,11 @@ vinumioctl(dev_t dev,
parityops((struct vinum_ioctl_msg *) data, rebuildparity);
return 0;
/* move an object */
case VINUM_MOVE:
moveobject((struct vinum_ioctl_msg *) data);
return 0;
default:
/* FALLTHROUGH */
}
@ -856,6 +862,44 @@ replaceobject(struct vinum_ioctl_msg *msg)
/* save_config (); */
}
void
moveobject(struct vinum_ioctl_msg *msg)
{
struct _ioctl_reply *reply = (struct _ioctl_reply *) msg;
struct drive *drive;
struct sd *sd;
/* Check that our objects are valid (i.e. they exist) */
drive = validdrive(msg->index, (struct _ioctl_reply *) msg);
if (drive == NULL)
return;
sd = validsd(msg->otherobject, (struct _ioctl_reply *) msg);
if (sd == NULL)
return;
if (sd->driveno == msg->index) /* sd already belongs to drive */
return;
if (sd->state > sd_stale)
set_sd_state(sd->sdno, sd_stale, setstate_force); /* make the subdisk stale */
else
sd->state = sd_empty;
if (sd->plexno >= 0) /* part of a plex, */
update_plex_state(sd->plexno); /* update its state */
/* Return the space on the old drive */
if ((sd->driveno >= 0) /* we have a drive, */
&&(sd->sectors > 0)) /* and some space on it */
return_drive_space(sd->driveno, /* return the space */
sd->driveoffset,
sd->sectors);
/* Reassign the old subdisk */
sd->driveno = msg->index;
sd->driveoffset = -1; /* let the drive decide where to put us */
give_sd_to_drive(sd->sdno);
reply->error = 0;
}
/* Local Variables: */
/* fill-column: 50 */
/* End: */