From 5756902abc0c9115f073504e4e86ffdd259d89e9 Mon Sep 17 00:00:00 2001 From: Greg Lehey Date: Wed, 5 Jan 2000 06:07:26 +0000 Subject: [PATCH] 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 --- sys/dev/vinum/vinumioctl.c | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/sys/dev/vinum/vinumioctl.c b/sys/dev/vinum/vinumioctl.c index 94066680261..c71081cdc7d 100644 --- a/sys/dev/vinum/vinumioctl.c +++ b/sys/dev/vinum/vinumioctl.c @@ -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: */