volser: take RO volume offline during convertROtoRW
[openafs.git] / src / volser / volprocs.c
index 832f5d0..90c7778 100644 (file)
@@ -407,7 +407,7 @@ SAFSVolPartitionInfo64(struct rx_call *acid, char *pname, struct diskPartition64
     return code;
 }
 
-afs_int32
+static afs_int32
 VolPartitionInfo(struct rx_call *acid, char *pname, struct diskPartition64
                 *partition)
 {
@@ -3002,11 +3002,33 @@ SAFSVolConvertROtoRWvolume(struct rx_call *acid, afs_int32 partId,
                ret = VOLSERVOLBUSY;
                goto done;
             }
+           ret = FSYNC_VolOp(volumeId, pname, FSYNC_VOL_NEEDVOLUME, V_VOLUPD,
+                             NULL);
+           if (ret != SYNC_OK) {
+               Log("SAFSVolConvertROtoRWvolume: Error %ld trying to check out "
+                   "vol %lu part %s.\n", afs_printable_int32_ld(ret),
+                   afs_printable_uint32_lu(volumeId), pname);
+               ret = VOLSERFAILEDOP;
+               goto done;
+           }
 #ifdef AFS_NAMEI_ENV
            ret = namei_ConvertROtoRWvolume(pname, volumeId);
 #else
            ret = inode_ConvertROtoRWvolume(pname, volumeId);
 #endif
+           if (ret != 0) {
+               Log("SAFSVolConvertROtoRWvolume: Error %ld trying to convert "
+                   "RO vol %lu to RW. The volume may be in an inconsistent or "
+                   "partially converted state; if the volume seems unusable, "
+                   "you can try salvaging it or restoring from another RO "
+                   "copy.\n", afs_printable_int32_ld(ret),
+                   afs_printable_uint32_lu(volumeId));
+               /*
+                * the volume may or may not be usable at this point; let the
+                * fileserver try to attach and decide.
+                */
+               FSYNC_VolOp(volumeId, pname, FSYNC_VOL_ON, 0, NULL);
+           }
            break;
        }
     }