Make namei convertROtoRW'd volumes usable

Right now, if you convertROtoRW a volume on namei, the converted volume
appears to need a salvage before it is usable, and the header of the old
(now empty) RO volume is kept around. Fix this:

 -- Set inUse = 0 on the converted volume, so the fileserver will be
    able to attach the volume when we give it back

 -- Unlink the RO header file, instead of trying to unlink the
    VI_VOLINFO file twice

 -- Log the actual error code (errno) in the error message for the last
    unlink

Reviewed-on: http://gerrit.openafs.org/591
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
Andrew Deason 2009-10-07 12:14:11 -05:00 committed by Derrick Brashear
parent e3d1eaf0ca
commit 906403c6d7

View File

@ -1581,6 +1581,7 @@ convertVolumeInfo(int fdr, int fdw, afs_uint32 vid)
vd.id = vd.parentId;
vd.type = RWVOL;
vd.dontSalvage = 0;
vd.inUse = 0;
vd.uniquifier += 5000; /* just in case there are still file copies from
* the old RW volume around */
p = strrchr(vd.name, '.');
@ -1807,8 +1808,10 @@ namei_ConvertROtoRWvolume(char *pname, afs_uint32 volumeId)
return EIO;
}
close(fd);
(void)afs_snprintf(headername, sizeof headername, VFORMAT, afs_printable_uint32_lu(volumeId));
(void)afs_snprintf(oldpath, sizeof oldpath, "%s/%s", pname, headername);
if (unlink(oldpath) < 0) {
Log("1 namei_ConvertROtoRWvolume: Couldn't unlink RO header, error = %d\n", error);
Log("1 namei_ConvertROtoRWvolume: Couldn't unlink RO header, error = %d\n", errno);
}
FSYNC_VolOp(volumeId, pname, FSYNC_VOL_DONE, 0, NULL);
FSYNC_VolOp(h.id, pname, FSYNC_VOL_ON, 0, NULL);