/* 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);
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",
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;
default:
restoreflags |= RV_LUDUMP;
}
+ if (as->parms[10].items) {
+ restoreflags |= RV_NODEL;
+ }
+
code =
UV_RestoreVolume2(aserver, apart, avolid, aparentid,
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);;
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);
"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,
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,
struct volser_status tstatus;
struct volintInfo vinfo;
char partName[10];
+ char tovolreal[VOLSER_OLDMAXVOLNAME];
afs_int32 pvolid, pparentid;
afs_int32 temptid;
int success;
}
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 */
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 {
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);
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);
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;
/*adds <server> and <part> as a readonly replication site for <volid>
*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;
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);