From a1c8cad6ef5d1df47360b5e4edde7b7d0b5c34bf Mon Sep 17 00:00:00 2001 From: Jeffrey Hutzelman Date: Fri, 16 Dec 2005 04:26:40 +0000 Subject: [PATCH] STABLE14-vos-restore-parent-id-patch-20051215 avoid making broken readonlies when when you restore them (cherry picked from commit e5c8042e72a077bfcb05232c918995e9e965b7c2) --- src/volser/vos.c | 9 ++++++--- src/volser/vsprocs.c | 31 ++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/volser/vos.c b/src/volser/vos.c index e7ed31a85..f5ebbb5a7 100644 --- a/src/volser/vos.c +++ b/src/volser/vos.c @@ -2880,7 +2880,7 @@ RestoreVolume(as) register struct cmd_syndesc *as; { - afs_int32 avolid, aserver, apart, code, vcode, err; + afs_int32 avolid, aparentid, aserver, apart, code, vcode, err; afs_int32 aoverwrite = ASK; afs_int32 acreation = 0, alastupdate = 0; int restoreflags, readonly = 0, offline = 0, voltype = RWVOL; @@ -2891,6 +2891,7 @@ RestoreVolume(as) prompt = 'n'; + aparentid = 0; if (as->parms[4].items) { avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err); if (avolid == 0) { @@ -3032,6 +3033,7 @@ RestoreVolume(as) && entry.volumeId[voltype] != avolid) { avolid = entry.volumeId[voltype]; } + aparentid = entry.volumeId[RWVOL]; } else { /* volume exists - do we do a full incremental or abort */ @@ -3045,6 +3047,7 @@ RestoreVolume(as) && entry.volumeId[voltype] != avolid) { avolid = entry.volumeId[voltype]; } + aparentid = entry.volumeId[RWVOL]; /* A file name was specified - check if volume is on another partition */ vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry); @@ -3147,8 +3150,8 @@ RestoreVolume(as) } code = - UV_RestoreVolume(aserver, apart, avolid, avolname, restoreflags, - WriteData, afilename); + UV_RestoreVolume2(aserver, apart, avolid, aparentid, + avolname, restoreflags, WriteData, afilename); if (code) { PrintDiagnostics("restore", code); exit(1); diff --git a/src/volser/vsprocs.c b/src/volser/vsprocs.c index 9dfb88536..d669e4e53 100644 --- a/src/volser/vsprocs.c +++ b/src/volser/vsprocs.c @@ -4047,9 +4047,9 @@ UV_DumpClonedVolume(afs_int32 afromvol, afs_int32 afromserver, * after extracting params from the rock */ int -UV_RestoreVolume(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid, - char tovolname[], int flags, afs_int32(*WriteData) (), - char *rock) +UV_RestoreVolume2(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid, + afs_int32 toparentid, char tovolname[], int flags, + afs_int32(*WriteData) (), char *rock) { struct rx_connection *toconn, *tempconn; struct rx_call *tocall; @@ -4058,7 +4058,7 @@ UV_RestoreVolume(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid, struct volser_status tstatus; struct volintInfo vinfo; char partName[10]; - afs_int32 pvolid; + afs_int32 pvolid, pparentid; afs_int32 temptid; int success; struct nvldbentry entry, storeEntry; @@ -4092,6 +4092,7 @@ UV_RestoreVolume(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid, } pvolid = tovolid; + pparentid = toparentid; toconn = UV_Bind(toserver, AFSCONF_VOLUMEPORT); if (pvolid == 0) { /*alot a new id if needed */ vcode = VLDB_GetEntryByName(tovolname, &entry); @@ -4120,10 +4121,13 @@ UV_RestoreVolume(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid, goto refail; } pvolid = entry.volumeId[ROVOL]; + pparentid = entry.volumeId[RWVOL]; } else { pvolid = entry.volumeId[RWVOL]; + pparentid = entry.volumeId[RWVOL]; } } + if (!pparentid) pparentid = pvolid; /* at this point we have a volume id to use/reuse for the volume to be restored */ if (strlen(tovolname) > (VOLSER_OLDMAXVOLNAME - 1)) { EGOTO1(refail, VOLSERBADOP, @@ -4136,7 +4140,7 @@ UV_RestoreVolume(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid, hostutil_GetNameByINet(toserver), partName); fflush(STDOUT); code = - AFSVolCreateVolume(toconn, topart, tovolname, volsertype, 0, &pvolid, + AFSVolCreateVolume(toconn, topart, tovolname, volsertype, pparentid, &pvolid, &totid); if (code) { if (flags & RV_FULLRST) { /* full restore: delete then create anew */ @@ -4172,7 +4176,7 @@ UV_RestoreVolume(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid, VDONE; code = - AFSVolCreateVolume(toconn, topart, tovolname, volsertype, 0, + AFSVolCreateVolume(toconn, topart, tovolname, volsertype, pparentid, &pvolid, &totid); EGOTO1(refail, code, "Could not create new volume %u\n", pvolid); } else { @@ -4193,7 +4197,7 @@ UV_RestoreVolume(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid, oldUpdateDate = 0; } - cookie.parent = pvolid; + cookie.parent = pparentid; cookie.type = voltype; cookie.clone = 0; strncpy(cookie.name, tovolname, VOLSER_OLDMAXVOLNAME); @@ -4226,7 +4230,7 @@ UV_RestoreVolume(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid, error = code; goto refail; } - code = AFSVolSetIdsTypes(toconn, totid, tovolname, voltype, pvolid, 0, 0); + code = AFSVolSetIdsTypes(toconn, totid, tovolname, voltype, pparentid, 0, 0); if (code) { fprintf(STDERR, "Could not set the right type and ID on %lu\n", (unsigned long)pvolid); @@ -4316,7 +4320,7 @@ UV_RestoreVolume(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid, entry.volumeId[ROVOL] = tstatus.cloneID; /*this should come from status info on the volume if non zero */ } else entry.volumeId[ROVOL] = INVALID_BID; - entry.volumeId[RWVOL] = pvolid; + entry.volumeId[RWVOL] = pparentid; entry.cloneId = 0; if (tstatus.backupID != 0) { entry.volumeId[BACKVOL] = tstatus.backupID; @@ -4502,6 +4506,15 @@ UV_RestoreVolume(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid, return error; } +int +UV_RestoreVolume(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid, + char tovolname[], int flags, afs_int32(*WriteData) (), + char *rock) +{ + return UV_RestoreVolume2(toserver, topart, tovolid, 0, tovolname, flags, + WriteData, rock); +} + /*unlocks the vldb entry associated with */ int -- 2.39.5