vos: Avoid creating volume with the same RO/BK ids
authorAndrew Deason <adeason@sinenomine.net>
Wed, 20 Jun 2012 21:28:51 +0000 (16:28 -0500)
committerDerrick Brashear <shadow@dementix.org>
Fri, 6 Jul 2012 18:26:45 +0000 (11:26 -0700)
If we specified an RW id of 5, an RO id of 6, and no BK id, this code
would assign the BK id to RW+1, or 6. This gives the RO and BK volumes
the same volume id, which is a mistake. Choose a different id instead.

Change-Id: I7910008dd6147a95d482337f91926e9e0d924b9e
Reviewed-on: http://gerrit.openafs.org/7603
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>

src/volser/vsprocs.c

index 0ac7e1e..f02fe44 100644 (file)
@@ -761,6 +761,12 @@ UV_CreateVolume3(afs_uint32 aserver, afs_int32 apart, char *aname,
     /* rw,ro, bk id are related in the default case */
     /* If caller specified RW id, but not RO/BK ids, have them be RW+1 and RW+2 */
     lastid = *anewid;
+    if (aroid && *aroid != 0) {
+       lastid = MAX(lastid, *aroid);
+    }
+    if (abkid && *abkid != 0) {
+       lastid = MAX(lastid, *abkid);
+    }
     if (aroid && *aroid == 0) {
        *aroid = ++lastid;
     }