summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorgrog <grog@FreeBSD.org>2000-01-05 06:07:26 +0000
committergrog <grog@FreeBSD.org>2000-01-05 06:07:26 +0000
commitf11675cd12cbd85f6623e811cbddc83e541e6e9a (patch)
tree2d1619939a88d193b84a6784fcab9b5a04bc72fa /sys/dev
parenta75e7bd2942ed41e6438a15173fc35f827afa9dd (diff)
downloadFreeBSD-src-f11675cd12cbd85f6623e811cbddc83e541e6e9a.zip
FreeBSD-src-f11675cd12cbd85f6623e811cbddc83e541e6e9a.tar.gz
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>
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/vinum/vinumioctl.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/sys/dev/vinum/vinumioctl.c b/sys/dev/vinum/vinumioctl.c
index 9406668..c71081c 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: */
OpenPOWER on IntegriCloud