PERFORCE change 81706 for review

soc-cjones soc-cjones at FreeBSD.org
Tue Aug 9 06:01:22 GMT 2005


http://perforce.freebsd.org/chv.cgi?CH=81706

Change 81706 by soc-cjones at soc-cjones_ishtar on 2005/08/09 06:00:25

	First cut at moving subdisks.  Let's see whether it works....

Affected files ...

.. //depot/projects/soc2005/gvinum/src/sys/geom/vinum/geom_vinum_move.c#4 edit

Differences ...

==== //depot/projects/soc2005/gvinum/src/sys/geom/vinum/geom_vinum_move.c#4 (text+ko) ====

@@ -70,6 +70,10 @@
 		gctl_error(req, "no destination given");
 		return;
 	}
+	if (GV_TYPE_DRIVE != gv_object_type(sc, destination)) {
+	  gctl_error(req, "destination is not a drive");
+	  return;
+	}
 
 	for (i = 0; i < *argc; i++) {
 		snprintf(buf, sizeof(buf), "argv%d", i);
@@ -84,6 +88,8 @@
 				gctl_error(req, "unknown volume '%s'", object);
 				return;
 			}
+			gctl_error(req, "no touching volumes!");
+			return 1;
 			err = gv_move_vol(sc, req, v, destination, *flags);
 			if (err)
 				return;
@@ -94,6 +100,8 @@
 				gctl_error(req, "unknown plex '%s'", object);
 				return;
 			}
+			gctl_error(req, "no touching plexes!");
+			return 1;
 			err = gv_move_plex(sc, req, p, destination, *flags);
 			if (err)
 				return;
@@ -114,6 +122,8 @@
 				gctl_error(req, "unknown drive '%s'", object);
 				return;
 			}
+			gctl_err(req, "no touching drives!");
+			return 1;
 			err = gv_move_drive(sc, req, d, destination, *flags);
 			if (err)
 				return;
@@ -131,10 +141,11 @@
 static int
 gv_move_vol(struct gv_softc *sc, struct gctl_req *req, struct gv_volume *v, char *destination, int flags) 
 {
-        int err;
-                 
         g_topology_assert();
-        KASSERT(d != NULL, ("gv_move_vol: NULL v")); 
+        KASSERT(v != NULL, ("gv_move_vol: NULL v")); 
+
+	gctl_error(req, "moving a volume makes no sense");
+	return 99;
 }
 
 /* Move a plex. */
@@ -144,7 +155,9 @@
         int err;
                  
         g_topology_assert();
-        KASSERT(d != NULL, ("gv_move_plex: NULL p")); 
+        KASSERT(p != NULL, ("gv_move_plex: NULL p")); 
+
+	/* TODO identify all sds for the plex, then move 'em. */
 
 	return (0);
 }
@@ -154,9 +167,65 @@
 gv_move_sd(struct gv_softc *sc, struct gctl_req *req, struct gv_sd *s, char *destination, int flags)
 {
         int err;
-                 
+	struct gv_drive *d;
+	struct gv_sd *s2;
+	char errstr[ERRBUFSIZ];
+
         g_topology_assert();
-        KASSERT(d != NULL, ("gv_move_sd: NULL s")); 
+        KASSERT(s != NULL, ("gv_move_sd: NULL s")); 
+
+	if (!(flags && GV_FLAG_F)) {
+	  gctl_error(req, "-f flag not passed; move would be destructive");
+	  return 98;
+	}
+
+	d = gv_find_drive(sc, destination);
+	if (NULL == d) {
+	  gctl_error(req, "destination drive '%s' not found", destination);
+	  return 97;
+	}
+
+	if (!strncmp(s->drive, d->name, GV_MAXDRIVENAME)) {
+	  gctl_error(req, "subdisk '%s' already on drive '%s'", s->name, destination);
+	  return 96;
+	}
+
+	/* Create new sd, set vital stats, and try allocating space 
+	   on the new drive. Unfortunately, we can't use gv_new_sd, 
+	   since we don't really want to deal with tokenizing stuff.  
+	   Oh well. */
+	s2 = g_malloc(sizeof(*s2), M_WAITOK | M_ZERO);
+	printf("A\n");
+	snprintf(s2->name, GV_MAXSDNAME, "temp.s0"); /* TODO Come up with temp name. */
+	printf("B (s2->name = %s)\n", s2->name);
+	s2->size = s->size;
+	printf("C\n");
+	s2->drive_sc = d;
+	s2->drive_offset = -1;
+	s2->plex_offset = -1;
+	printf("D\n");
+	s2->plex_sc = (struct gv_plex *) NULL;
+	s2->state = GV_SD_DOWN;
+	s2->vinumconf = sc;
+	printf("E\n");
+	err = gv_sd_to_drive(sc, d, s2, errstr, sizeof(errstr));
+	if (err) {
+	  printf("F errstr = %s\n", errstr);
+	  gctl_error(req, errstr);
+	  g_free(s2);
+	  return err;
+	}
+	printf("G\n");
+	s2->flags |= GV_SD_NEWBORN;
+	printf("H\n");
+	LIST_INSERT_HEAD(&sc->subdisks, s2, sd);
+	printf("I\n");
+	gv_update_sd_state(s);
+	printf("J\n");
+	gv_save_config_all(sc);
+
+	/* TODO -- move data from old sd to new sd. */
+	/* TODO -- delete old sd. */
 
 	return (0);
 }
@@ -170,6 +239,8 @@
         g_topology_assert();
         KASSERT(d != NULL, ("gv_move_drive: NULL d")); 
 
+	/* TODO find all sds on drive, then move them. */
+
 	return (0);
 }
 


More information about the p4-projects mailing list