]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-vos-volser-enhancements-20080121
authorDerrick Brashear <shadow@dementia.org>
Tue, 22 Jan 2008 05:15:42 +0000 (05:15 +0000)
committerDerrick Brashear <shadow@dementia.org>
Tue, 22 Jan 2008 05:15:42 +0000 (05:15 +0000)
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)

(cherry picked from commit e1c4e77d13122c2bb66d532ffd9dfc2e75318c04)

src/volser/volser.p.h
src/volser/volser_prototypes.h
src/volser/vos.c
src/volser/vsprocs.c

index 9e5b015c7cff4b79ed66e575b0cd2d9e7052abe6..95c59654cc416567461925968b609d497ce3f102 100644 (file)
@@ -157,18 +157,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);
index 832f1da334a326e8bfbe8995c25b563fbd8ce16b..71a65f473d1678b300ea46acd84a3ef96b079d3b 100644 (file)
@@ -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);
index 83710cb533b3a1338d9103ce2f703c38a56919fb..6c75d1d5389eb37db7b12b97997c70aaa6b167e0 100644 (file)
@@ -2621,12 +2621,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",
@@ -2661,7 +2667,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;
@@ -3152,6 +3158,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,
@@ -3199,7 +3209,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);;
@@ -3233,7 +3243,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);
@@ -5793,6 +5806,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,
@@ -5814,6 +5829,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,
index 296db83424cf8904c1d76216750c2739d284f97f..7df0ab2eef1567691405242160ac4be824e6e382 100644 (file)
@@ -4075,6 +4075,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;
@@ -4146,18 +4147,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 */
@@ -4193,7 +4204,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 {
@@ -4217,7 +4228,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);
@@ -4247,7 +4258,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);
@@ -4401,55 +4412,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;
@@ -4561,7 +4579,7 @@ UV_LockRelease(afs_int32 volid)
 /*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;
@@ -4634,7 +4652,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);