]> 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>
Wed, 26 Oct 2011 22:57:35 +0000 (15:57 -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.

Reviewed-on: http://gerrit.openafs.org/5049
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
(cherry picked from commit 83c41c69411ece7ac1dd0a7b15d4ee9746edcf23)

Change-Id: Idc2575538811d278fb65be46cfc0cd4d24d90f5d
Reviewed-on: http://gerrit.openafs.org/5725
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: Derrick Brashear <shadow@dementix.org>
src/volser/volprocs.c
src/volser/volser.p.h
src/volser/vos.c
src/volser/vsprocs.c

index 46f1e8aecc9471c29f8001785a4a0dddf8b0f5e1..b86501fed944d0e98a2b81e596f9d3cc4353a4c4 100644 (file)
@@ -703,8 +703,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;
@@ -754,15 +752,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;
        }
@@ -925,19 +916,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 e174f9f478530aa10657a9e34bccc8362ae7edcb..5907fcb00623e375ef23d3f24ac3d9c7afae7905 100644 (file)
@@ -184,6 +184,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 50e2c00851ca0e26af9a7c33c77ce4695dcc3915..f9f14b11b588ac05abf8185df6084d285a69b6ca 100644 (file)
@@ -2752,7 +2752,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 =
@@ -5988,6 +5993,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 ac65ca140b90d6a1a68660e4b47e0928e8553ab4..38d17490cd89965139c4e5a6804537503a2ed3e7 100644 (file)
@@ -3018,6 +3018,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);
 
@@ -3104,9 +3105,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);