Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Aug 2005 06:48:54 GMT
From:      soc-cjones <soc-cjones@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 81632 for review
Message-ID:  <200508080648.j786msem088892@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=81632

Change 81632 by soc-cjones@soc-cjones_ishtar on 2005/08/08 06:48:06

	Renaming volumes now works, both recursively and non-.  Next up, drives, subdisks, and plexes.

Affected files ...

.. //depot/projects/soc2005/gvinum/src/sys/geom/vinum/geom_vinum_rename.c#3 edit

Differences ...

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

@@ -180,11 +180,58 @@
 	int err;
 	struct gv_plex *p;
 	struct gv_sd *s;
+	char oldvolname[GV_MAXVOLNAME];
+	char oldplexname[GV_MAXPLEXNAME];
 
 	g_topology_assert();
 	KASSERT(d != NULL, ("gv_rename_vol: NULL v"));
 
-	printf("gv_rename_vol:\n");
+	printf("gv_rename_vol: flags = %x\n", flags);
+
+	/* Rename the volume. We need to hold on to the old volume name. */
+	strncpy(oldvolname, v->name, GV_MAXVOLNAME);
+	printf("Renaming volume %s to %s\n", v->name, newname);
+	strncpy(v->name, newname, GV_MAXVOLNAME);
+
+	/* Rename the associated plexes. For each plex, iterate across 
+	   list of all subdisks and check to see if its plex is the one 
+	   we're renaming.  Yes, this is icky and O(N_{plexes} x N_{sds}), 
+	   but it works. */
+
+	LIST_FOREACH(p, &sc->plexes, plex) {
+	  if (!strncmp(p->volume, oldvolname, GV_MAXVOLNAME)) {
+	    strncpy(p->volume, v->name, GV_MAXVOLNAME);
+	    if (flags && GV_FLAG_R) {
+	      char plexnumber[GV_MAXPLEXNAME];
+	      char *pplexnumber = plexnumber;
+	      printf("Modifying plex %s, p->volume = %s\n", p->name, p->volume);
+	      strncpy(oldplexname, p->name, GV_MAXPLEXNAME);
+	      strncpy(plexnumber, p->name, GV_MAXPLEXNAME);
+	      strsep(&pplexnumber, ".");
+	      printf("Renaming plex %s to %s.%s\n", p->name, v->name, pplexnumber);
+	      snprintf(p->name, GV_MAXPLEXNAME, "%s.%s", v->name, pplexnumber);
+	      LIST_FOREACH(s, &sc->subdisks, sd) {
+		if (!strncmp(s->plex, oldplexname, GV_MAXPLEXNAME)) {
+		  char sdnumber[GV_MAXSDNAME];
+		  char *psdnumber = sdnumber;
+		  printf("Modifying subdisk %s, s->plex = %s\n", s->name, s->plex);
+		  strncpy(sdnumber, s->name, GV_MAXSDNAME);
+		  strsep(&psdnumber, ".");
+		  strsep(&psdnumber, ".");
+		  printf("Renaming subdisk %s to %s.%s\n", s->name, p->name, psdnumber);
+		  snprintf(s->name, GV_MAXSDNAME, "%s.%s", p->name, psdnumber);
+		  strncpy(s->plex, p->name, GV_MAXPLEXNAME);
+		} else {
+		  printf("Ignoring subdisk %s, s->plex = %s\n", s->name, s->plex);
+		}
+	      }
+	    }
+	  } else {
+	    printf("Ignoring plex %s, p->volume = %s\n", p->name, p->volume);
+	  }
+	}
+
+	printf("Debugging output:\n");
 	printf("\tsc = %p\n", sc);
 	printf("\treq = %p\n", req);
 	printf("\tv = %p\n", v);
@@ -193,23 +240,25 @@
 	printf("\t\tv->plexcount = %d\n", v->plexcount);
 	printf("\tnewname = \"%s\"\n", newname);
 	printf("\tflags = %x\n", flags);
-
-	printf("iterating across plexes list...\n");
-	LIST_FOREACH(p, &v->plexes, plex) {
-	  if (strcmp(p->volume, v->name)) {
-		continue; /* Not a plex we're looking for. */
+	
+	LIST_FOREACH(p, &sc->plexes, plex) {
+	  if (!strncmp(p->volume, v->name, GV_MAXVOLNAME)) {
+	    printf("\tp->name = %s\n", p->name);
+	    printf("\tp->size = %d\n", (int) p->size);
+	    printf("\tp->volume = %s\n", p->volume);
+	    printf("\tp->sdcount = %d\n", p->sdcount);
+	    printf("\tp->sddown = %d\n", p->sddown);
+	    LIST_FOREACH(s, &sc->subdisks, sd) {
+	      if (!strncmp(s->plex, p->name, GV_MAXPLEXNAME)) {
+		printf("\t\ts->name = %s\n", s->name);
+		printf("\t\ts->size = %d\n", (int) s->size);
+		printf("\t\ts->drive = %s\n", s->drive);
+		printf("\t\ts->plex = %s\n", s->plex);		
+	      }
+	    }
 	  }
-	  printf("\tp->name = %s\n", p->name);
-	  printf("\tp->size = %d\n", (int) p->size);
-	  printf("\tp->volume = %s\n", p->volume);
-/*	  LIST_FOREACH(s, &p->subdisks, sd) {
-	    printf("\t\ts->name = %s\n", s->name);
-	    printf("\t\ts->size = %d\n", (int) s->size);
-	    printf("\t\ts->drive = %s\n", s->drive);
-	    printf("\t\ts->plex = %s\n", s->plex);
-	  } */
 	}
+	printf("\n\n");
 
 	return (0);
-
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508080648.j786msem088892>