From: Derrick Brashear Date: Tue, 22 Jan 2008 05:15:15 +0000 (+0000) Subject: vos-volser-enhancements-20080121 X-Git-Tag: BP-openafs-windows-kdfs-ifs~191 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=e1c4e77d13122c2bb66d532ffd9dfc2e75318c04 vos-volser-enhancements-20080121 LICENSE IPL10 add option to addsite to allow adding a site where there is already a release- equivalent volume resident, where thus we don't want to mark unreleased (possible by dumping an existing RO and restoring with -readonly at the new site) add ability to vos clone to a readonly or backup with the correct ID and name add ability when restoring a RW to a new site to leave the volume at the old site intact all changes are internal to vos and can be used with any OpenAFS from 2006 or later (supporting changes in namei to not create volumes with bad parent id went in in December 2005) --- diff --git a/src/volser/volser.p.h b/src/volser/volser.p.h index e0111f0..8053ef7 100644 --- a/src/volser/volser.p.h +++ b/src/volser/volser.p.h @@ -158,18 +158,19 @@ struct partList { /*used by the backup system */ /* Values for the UV_RestoreVolume flags parameter */ /* Also used for UV_CopyVolume and UV_CloneVolume */ -#define RV_FULLRST 0x00001 -#define RV_OFFLINE 0x00002 -#define RV_CRDUMP 0x00010 -#define RV_CRKEEP 0x00020 -#define RV_CRNEW 0x00040 -#define RV_LUDUMP 0x00100 -#define RV_LUKEEP 0x00200 -#define RV_LUNEW 0x00400 -#define RV_RDONLY 0x10000 -#define RV_CPINCR 0x20000 -#define RV_NOVLDB 0x40000 -#define RV_NOCLONE 0x80000 +#define RV_FULLRST 0x000001 +#define RV_OFFLINE 0x000002 +#define RV_CRDUMP 0x000010 +#define RV_CRKEEP 0x000020 +#define RV_CRNEW 0x000040 +#define RV_LUDUMP 0x000100 +#define RV_LUKEEP 0x000200 +#define RV_LUNEW 0x000400 +#define RV_RDONLY 0x010000 +#define RV_CPINCR 0x020000 +#define RV_NOVLDB 0x040000 +#define RV_NOCLONE 0x080000 +#define RV_NODEL 0x100000 struct ubik_client; extern afs_uint32 vsu_GetVolumeID(char *astring, struct ubik_client *acstruct, afs_int32 *errp); diff --git a/src/volser/volser_prototypes.h b/src/volser/volser_prototypes.h index 832f1da..71a65f4 100644 --- a/src/volser/volser_prototypes.h +++ b/src/volser/volser_prototypes.h @@ -52,7 +52,7 @@ extern int UV_RestoreVolume(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid, char tovolname[], int flags, afs_int32(*WriteData) (), char *rock); extern int UV_LockRelease(afs_int32 volid); -extern int UV_AddSite(afs_int32 server, afs_int32 part, afs_int32 volid); +extern int UV_AddSite(afs_int32 server, afs_int32 part, afs_int32 volid, afs_int32 valid); extern int UV_RemoveSite(afs_int32 server, afs_int32 part, afs_int32 volid); extern int UV_ChangeLocation(afs_int32 server, afs_int32 part, afs_int32 volid); diff --git a/src/volser/vos.c b/src/volser/vos.c index a9f69cd..63006d9 100644 --- a/src/volser/vos.c +++ b/src/volser/vos.c @@ -2623,12 +2623,18 @@ CloneVolume(register struct cmd_syndesc *as, void *arock) volname, VOLSER_OLDMAXVOLNAME - 1); return E2BIG; } +#if 0 + /* + * In order that you be able to make clones of RO or BK, this + * check must be omitted. + */ if (!VolNameOK(volname)) { fprintf(STDERR, "Illegal volume name %s, should not end in .readonly or .backup\n", volname); return EINVAL; } +#endif if (IsNumeric(volname)) { fprintf(STDERR, "Illegal volume name %s, should not be a number\n", @@ -2663,7 +2669,7 @@ CloneVolume(register struct cmd_syndesc *as, void *arock) return code; } MapPartIdIntoName(part, partName); - fprintf(STDOUT, "Created clone for volume %lu\n", + fprintf(STDOUT, "Created clone for volume %s\n", as->parms[0].items->data); return 0; @@ -3154,6 +3160,10 @@ RestoreVolume(register struct cmd_syndesc *as, void *arock) default: restoreflags |= RV_LUDUMP; } + if (as->parms[10].items) { + restoreflags |= RV_NODEL; + } + code = UV_RestoreVolume2(aserver, apart, avolid, aparentid, @@ -3201,7 +3211,7 @@ LockReleaseCmd(register struct cmd_syndesc *as, void *arock) static int AddSite(register struct cmd_syndesc *as, void *arock) { - afs_int32 avolid, aserver, apart, code, err; + afs_int32 avolid, aserver, apart, code, err, valid = 0; char apartName[10], avolname[VOLSER_MAXVOLNAME + 1]; vsu_ExtractName(avolname, as->parms[2].items->data);; @@ -3235,7 +3245,10 @@ AddSite(register struct cmd_syndesc *as, void *arock) as->parms[1].items->data); exit(1); } - code = UV_AddSite(aserver, apart, avolid); + if (as->parms[3].items) { + valid = 1; + } + code = UV_AddSite(aserver, apart, avolid, valid); if (code) { PrintDiagnostics("addsite", code); exit(1); @@ -5795,6 +5808,8 @@ main(argc, argv) "dump | keep | new"); cmd_AddParm(ts, "-lastupdate", CMD_SINGLE, CMD_OPTIONAL, "dump | keep | new"); + cmd_AddParm(ts, "-nodelete", CMD_FLAG, CMD_OPTIONAL, + "do not delete old site when restoring to a new site"); COMMONPARMS; ts = cmd_CreateSyntax("unlock", LockReleaseCmd, NULL, @@ -5816,6 +5831,7 @@ main(argc, argv) cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name for new site"); cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID"); + cmd_AddParm(ts, "-valid", CMD_FLAG, CMD_OPTIONAL | CMD_HIDE, "publish as an up-to-date site in VLDB"); COMMONPARMS; ts = cmd_CreateSyntax("remsite", RemoveSite, NULL, diff --git a/src/volser/vsprocs.c b/src/volser/vsprocs.c index 65dc198..c848137 100644 --- a/src/volser/vsprocs.c +++ b/src/volser/vsprocs.c @@ -4079,6 +4079,7 @@ UV_RestoreVolume2(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid, struct volser_status tstatus; struct volintInfo vinfo; char partName[10]; + char tovolreal[VOLSER_OLDMAXVOLNAME]; afs_int32 pvolid, pparentid; afs_int32 temptid; int success; @@ -4150,18 +4151,28 @@ UV_RestoreVolume2(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid, } if (!pparentid) pparentid = pvolid; /* at this point we have a volume id to use/reuse for the volume to be restored */ + strncpy(tovolreal, tovolname, VOLSER_OLDMAXVOLNAME); + if (strlen(tovolname) > (VOLSER_OLDMAXVOLNAME - 1)) { EGOTO1(refail, VOLSERBADOP, "The volume name %s exceeds the maximum limit of (VOLSER_OLDMAXVOLNAME -1 ) bytes\n", tovolname); + } else { + if ((pparentid != pvolid) && (flags & RV_RDONLY)) { + if (strlen(tovolname) > (VOLSER_OLDMAXVOLNAME - 10)) { + EGOTO1(refail, VOLSERBADOP, + "The volume name %s exceeds the maximum limit of (VOLSER_OLDMAXVOLNAME -1 ) bytes\n", tovolname); + } + snprintf(tovolreal, VOLSER_OLDMAXVOLNAME, "%s.readonly", tovolname); + } } MapPartIdIntoName(topart, partName); fprintf(STDOUT, "Restoring volume %s Id %lu on server %s partition %s ..", - tovolname, (unsigned long)pvolid, + tovolreal, (unsigned long)pvolid, hostutil_GetNameByINet(toserver), partName); fflush(STDOUT); code = - AFSVolCreateVolume(toconn, topart, tovolname, volsertype, pparentid, &pvolid, + AFSVolCreateVolume(toconn, topart, tovolreal, volsertype, pparentid, &pvolid, &totid); if (code) { if (flags & RV_FULLRST) { /* full restore: delete then create anew */ @@ -4197,7 +4208,7 @@ UV_RestoreVolume2(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid, VDONE; code = - AFSVolCreateVolume(toconn, topart, tovolname, volsertype, pparentid, + AFSVolCreateVolume(toconn, topart, tovolreal, volsertype, pparentid, &pvolid, &totid); EGOTO1(refail, code, "Could not create new volume %u\n", pvolid); } else { @@ -4221,7 +4232,7 @@ UV_RestoreVolume2(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid, cookie.parent = pparentid; cookie.type = voltype; cookie.clone = 0; - strncpy(cookie.name, tovolname, VOLSER_OLDMAXVOLNAME); + strncpy(cookie.name, tovolreal, VOLSER_OLDMAXVOLNAME); tocall = rx_NewCall(toconn); terror = StartAFSVolRestore(tocall, totid, 1, &cookie); @@ -4251,7 +4262,7 @@ UV_RestoreVolume2(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid, error = code; goto refail; } - code = AFSVolSetIdsTypes(toconn, totid, tovolname, voltype, pparentid, 0, 0); + code = AFSVolSetIdsTypes(toconn, totid, tovolreal, voltype, pparentid, 0, 0); if (code) { fprintf(STDERR, "Could not set the right type and ID on %lu\n", (unsigned long)pvolid); @@ -4405,55 +4416,62 @@ UV_RestoreVolume2(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid, toserver, errcode); if ((!errcode && !same) || (entry.serverPartition[index] != topart)) { - tempconn = - UV_Bind(entry.serverNumber[index], - AFSCONF_VOLUMEPORT); - - MapPartIdIntoName(entry.serverPartition[index], - apartName); - VPRINT3 - ("Deleting the previous volume %u on server %s, partition %s ...", - pvolid, - hostutil_GetNameByINet(entry.serverNumber[index]), - apartName); - code = - AFSVolTransCreate(tempconn, pvolid, - entry.serverPartition[index], - ITOffline, &temptid); - if (!code) { + if (flags & RV_NODEL) { + VPRINT2 + ("Not deleting the previous volume %u on server %s, ...", + pvolid, + hostutil_GetNameByINet(entry.serverNumber[index])); + } else { + tempconn = + UV_Bind(entry.serverNumber[index], + AFSCONF_VOLUMEPORT); + + MapPartIdIntoName(entry.serverPartition[index], + apartName); + VPRINT3 + ("Deleting the previous volume %u on server %s, partition %s ...", + pvolid, + hostutil_GetNameByINet(entry.serverNumber[index]), + apartName); code = - AFSVolSetFlags(tempconn, temptid, - VTDeleteOnSalvage | - VTOutOfService); - if (code) { - fprintf(STDERR, - "Could not set flags on volume %lu on the older site\n", - (unsigned long)pvolid); - error = code; - goto refail; - } - code = AFSVolDeleteVolume(tempconn, temptid); - if (code) { - fprintf(STDERR, - "Could not delete volume %lu on the older site\n", - (unsigned long)pvolid); - error = code; - goto refail; - } - code = AFSVolEndTrans(tempconn, temptid, &rcode); - temptid = 0; - if (!code) - code = rcode; - if (code) { - fprintf(STDERR, - "Could not end transaction on volume %lu on the older site\n", - (unsigned long)pvolid); - error = code; - goto refail; + AFSVolTransCreate(tempconn, pvolid, + entry.serverPartition[index], + ITOffline, &temptid); + if (!code) { + code = + AFSVolSetFlags(tempconn, temptid, + VTDeleteOnSalvage | + VTOutOfService); + if (code) { + fprintf(STDERR, + "Could not set flags on volume %lu on the older site\n", + (unsigned long)pvolid); + error = code; + goto refail; + } + code = AFSVolDeleteVolume(tempconn, temptid); + if (code) { + fprintf(STDERR, + "Could not delete volume %lu on the older site\n", + (unsigned long)pvolid); + error = code; + goto refail; + } + code = AFSVolEndTrans(tempconn, temptid, &rcode); + temptid = 0; + if (!code) + code = rcode; + if (code) { + fprintf(STDERR, + "Could not end transaction on volume %lu on the older site\n", + (unsigned long)pvolid); + error = code; + goto refail; + } + VDONE; + MapPartIdIntoName(entry.serverPartition[index], + partName); } - VDONE; - MapPartIdIntoName(entry.serverPartition[index], - partName); } } entry.serverNumber[index] = toserver; @@ -4565,7 +4583,7 @@ UV_LockRelease(afs_int32 volid) /*adds and as a readonly replication site for *in vldb */ int -UV_AddSite(afs_int32 server, afs_int32 part, afs_int32 volid) +UV_AddSite(afs_int32 server, afs_int32 part, afs_int32 volid, afs_int32 valid) { int j, nro = 0, islocked = 0; struct nvldbentry entry, storeEntry; @@ -4638,7 +4656,11 @@ UV_AddSite(afs_int32 server, afs_int32 part, afs_int32 volid) VPRINT("Adding a new site ..."); entry.serverNumber[entry.nServers] = server; entry.serverPartition[entry.nServers] = part; - entry.serverFlags[entry.nServers] = (ITSROVOL | RO_DONTUSE); + if (!valid) { + entry.serverFlags[entry.nServers] = (ITSROVOL | RO_DONTUSE); + } else { + entry.serverFlags[entry.nServers] = (ITSROVOL); + } entry.nServers++; MapNetworkToHost(&entry, &storeEntry);