[OpenAFS-devel] backup volrestore crash with > 20 dump levels
Rainer Toebbicke
rtb@pclella.cern.ch
Fri, 23 Mar 2007 12:20:51 +0100
This is a multi-part message in MIME format.
--------------000401080203070509030005
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
backup volrestore silently continues to override memory past the
dlevels array when there are more than 20 incremental dumps.
With the attached patch it mallocs a bigger array instead whenever
that happens.
bcc'ed openafs-bugs.
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Rainer Toebbicke
European Laboratory for Particle Physics(CERN) - Geneva, Switzerland
Phone: +41 22 767 8985 Fax: +41 22 767 7155
--------------000401080203070509030005
Content-Type: text/plain;
name="p_dump_levels"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="p_dump_levels"
Index: openafs/src/bucoord/restore.c
===================================================================
RCS file: /cvs/openafs/src/bucoord/restore.c,v
retrieving revision 1.8.2.3
diff -u -r1.8.2.3 restore.c
--- openafs/src/bucoord/restore.c 5 Jan 2007 03:34:09 -0000 1.8.2.3
+++ openafs/src/bucoord/restore.c 22 Mar 2007 15:37:19 -0000
@@ -40,7 +40,6 @@
extern struct bc_dumpTask bc_dumpTasks[BC_MAXSIMDUMPS];
extern char *whoami;
-#define BC_MAXLEVELS 20
#define MAXTAPESATONCE 10
#define HOSTADDR(sockaddr) (sockaddr)->sin_addr.s_addr
@@ -182,9 +181,10 @@
statusP statusPtr, newStatusPtr;
struct dumpinfo *dumpinfolist = NULL;
- struct dumpinfo *pdi, *ndi, *di, dlevels[BC_MAXLEVELS];
+ struct dumpinfo *pdi, *ndi, *di, *dlevels;
struct volinfo *pvi, *nvi, *vi;
afs_int32 lvl, lv;
+ int num_dlevels = 20;
afs_int32 serverAll; /* The server to which all volumes are to be restore to */
afs_int32 partitionAll; /* Likewise for partition */
@@ -196,6 +196,8 @@
extern statusP createStatusNode();
extern statusP findStatus();
+ dlevels = (struct dumpinfo *) malloc(num_dlevels * sizeof(*dlevels));
+
dumpTaskPtr = &bc_dumpTasks[aindex];
serverAll = HOSTADDR(&dumpTaskPtr->destServer);
partitionAll = dumpTaskPtr->destPartition;
@@ -314,6 +316,14 @@
memcpy(&dlevels[0], di, sizeof(struct dumpinfo));
for (lvl = 1, parent = dlevels[0].parentDumpId; parent;
parent = dlevels[lvl].parentDumpId, lvl++) {
+ if (lvl >= num_dlevels) { /* running out of dump levels */
+ struct dumpinfo *tdl = dlevels;
+
+ num_dlevels += num_dlevels; /* double */
+ dlevels = (struct dumpinfo *) malloc(num_dlevels * sizeof(*dlevels));
+ memcpy(dlevels, tdl, (num_dlevels/2) * sizeof(*dlevels));
+ free(tdl);
+ }
code = bcdb_FindDumpByID(parent, &dumpDescr1);
if (code) {
for (vi = di->volinfolist; vi; vi = vi->next) {
@@ -768,5 +778,7 @@
if (volumeEntries)
free(volumeEntries);
+ free(dlevels);
+
return code;
}
--------------000401080203070509030005--