]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
allow cloning of any volume to any volume with same parent ID
authorJacob Thebault-Spieker <summatusmentis@gmail.com>
Tue, 19 Jul 2011 22:01:26 +0000 (15:01 -0700)
committerDerrick Brashear <shadow@dementix.org>
Mon, 24 Oct 2011 20:15:36 +0000 (13:15 -0700)
remove checks to disallow cloning of ro volumes to rw volumes,
which allows cloning of any volume within the same parent ID
grouping, including allowing destruction of newer version of the
volumes.

Change-Id: I13f600c33934b9af8237f049225d6bacfbbb5690
Reviewed-on: http://gerrit.openafs.org/5049
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
src/volser/volprocs.c
src/volser/volser.p.h
src/volser/vos.c
src/volser/vsprocs.c

index 8083cc2e34d922b8ed1e8e2467e135bc3a065c45..ce14408e2361532ae44815c6b077214170d4fcf6 100644 (file)
@@ -727,8 +727,6 @@ VolClone(struct rx_call *acid, afs_int32 atrans, afs_uint32 purgeId,
     }
     newId = *newNumber;
 
-    if (newType != readonlyVolume && newType != backupVolume)
-       return EINVAL;
     tt = FindTrans(atrans);
     if (!tt)
        return ENOENT;
@@ -778,15 +776,8 @@ VolClone(struct rx_call *acid, afs_int32 atrans, afs_uint32 purgeId,
            error = EINVAL;
            goto fail;
        }
-       if (V_type(originalvp) == readonlyVolume
-           && V_parentId(originalvp) != V_parentId(purgevp)) {
-           Log("1 Volser: Clone: Volume %u and volume %u were not cloned from the same parent volume; aborted\n", tt->volid, purgeId);
-           error = EXDEV;
-           goto fail;
-       }
-       if (V_type(originalvp) == readwriteVolume
-           && tt->volid != V_parentId(purgevp)) {
-           Log("1 Volser: Clone: Volume %u was not originally cloned from volume %u; aborted\n", purgeId, tt->volid);
+       if (V_parentId(originalvp) != V_parentId(purgevp)) {
+           Log("1 Volser: Clone: Volume %u and volume %u were not originally cloned from the same parent; aborted\n", purgeId, tt->volid);
            error = EXDEV;
            goto fail;
        }
@@ -951,19 +942,7 @@ VolReClone(struct rx_call *acid, afs_int32 atrans, afs_int32 cloneId)
        error = EXDEV;
        goto fail;
     }
-    if (V_type(clonevp) != readonlyVolume && V_type(clonevp) != backupVolume) {
-       Log("1 Volser: Clone: The \"recloned\" volume must be a read only volume; aborted\n");
-       error = EINVAL;
-       goto fail;
-    }
-    if (V_type(originalvp) == readonlyVolume
-       && V_parentId(originalvp) != V_parentId(clonevp)) {
-       Log("1 Volser: Clone: Volume %u and volume %u were not cloned from the same parent volume; aborted\n", tt->volid, cloneId);
-       error = EXDEV;
-       goto fail;
-    }
-    if (V_type(originalvp) == readwriteVolume
-       && tt->volid != V_parentId(clonevp)) {
+    if (V_parentId(originalvp) != V_parentId(clonevp)) {
        Log("1 Volser: Clone: Volume %u was not originally cloned from volume %u; aborted\n", cloneId, tt->volid);
        error = EXDEV;
        goto fail;
index ab68f73affad03b03e7cff01068a411683c6366f..4d8ed084bf6069b65c543b364662ace6da254147 100644 (file)
@@ -181,6 +181,7 @@ struct partList {           /*used by the backup system */
 #define RV_NOVLDB      0x040000
 #define RV_NOCLONE     0x080000
 #define RV_NODEL        0x100000
+#define RV_RWONLY      0x200000
 
 struct ubik_client;
 extern afs_uint32 vsu_GetVolumeID(char *astring, struct ubik_client *acstruct, afs_int32 *errp);
index 38c5aa6a1294c963f50d5baa2b0cb713367cf761..2735ac11e5d3d5aa7c48baade68eb2f48bd90dac 100644 (file)
@@ -2733,7 +2733,12 @@ CloneVolume(struct cmd_syndesc *as, void *arock)
 
     flags = 0;
     if (as->parms[5].items) flags |= RV_OFFLINE;
+    if (as->parms[6].items && as->parms[7].items) {
+       fprintf(STDERR, "vos: cannot specify that a volume be -readwrite and -readonly\n");
+       return EINVAL;
+    }
     if (as->parms[6].items) flags |= RV_RDONLY;
+    if (as->parms[7].items) flags |= RV_RWONLY;
 
 
     code =
@@ -5977,6 +5982,8 @@ main(int argc, char **argv)
                "leave clone volume offline");
     cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
                "make clone volume read-only, not readwrite");
+    cmd_AddParm(ts, "-readwrite", CMD_FLAG, CMD_OPTIONAL,
+               "make clone volume readwrite, not read-only");
     COMMONPARMS;
 
     ts = cmd_CreateSyntax("release", ReleaseVolume, NULL, "release a volume");
index b32075985bae6676f2b5fa1a80b61efbfd4a61cb..94df884691484ef5925b981634ba4b1f7a0c1539 100644 (file)
@@ -3000,6 +3000,7 @@ UV_CloneVolume(afs_uint32 aserver, afs_int32 apart, afs_uint32 avolid,
     afs_int32 error = 0;
     int backexists = 1;
     volEntries volumeInfo;
+    int type = 0;
 
     aconn = UV_Bind(aserver, AFSCONF_VOLUMEPORT);
 
@@ -3086,9 +3087,14 @@ UV_CloneVolume(afs_uint32 aserver, afs_int32 apart, afs_uint32 avolid,
     } else {
        VPRINT1("Creating a new clone %u ...", acloneid);
 
-       code = AFSVolClone(aconn, ttid, 0,
-                          (flags & RV_RDONLY) ? readonlyVolume : backupVolume,
-                          aname, &acloneid);
+       if (flags & RV_RWONLY)
+               type = readwriteVolume;
+       else if (flags & RV_RDONLY)
+               type = readonlyVolume;
+       else
+               type = backupVolume;
+
+       code = AFSVolClone(aconn, ttid, 0, type, aname, &acloneid);
        if (code) {
            fprintf(STDERR, "Failed to clone the volume %lu\n",
                    (unsigned long)avolid);