From fea397b0433ae3cc1155a3f826b0776eee23a497 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Wed, 28 Nov 2012 17:22:21 -0600 Subject: [PATCH] vol: Let non-usable volumes attach for non-DAFS Before DAFS, volumes that were not inService/blessed were not accessible by normal clients, but were still allowed to attach. That is, access to clients was prevented at VGetVolume-time, rather than at attach-time. Commit 939382c5 tried to short-circuit this by detecting this volume state at attach-time. However, volume utilities (e.g. volserver) can give us back a volume over FSSYNC when they are done with the volume, and for non-DAFS, we then try to attach the volume. So, with 939382c5 that attachment will fail when volserver gives us back a volume that is not inService/blessed (which can happen for some normal volume operations). This situation is not terrible, since either way the volume is not usable by clients (since the volume didn't attach), and the volume is still usable by volserver (since volserver is allowed to check out nonexistent volumes). But it is a deviation from pre-DAFS behavior and it can result in confusing error messages, so revert the 939382c5 behavior for non-DAFS. For DAFS, this behavior is fine, since the fileserver does not attach a volume unless it is trying to service a client request. So, leave it for DAFS. FIXES 131505 Reviewed-on: http://gerrit.openafs.org/8557 Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit 988f66c5c3bd4c4f23bfa53e69a52ed52c4e3ab9) Change-Id: I08b55b30047fc19788e2c83ada1ecd80456f1f74 Reviewed-on: http://gerrit.openafs.org/9499 Tested-by: BuildBot Reviewed-by: Mark Vitale Reviewed-by: Andrew Deason Reviewed-by: Stephan Wiesand --- src/vol/volume.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/vol/volume.c b/src/vol/volume.c index 19e20d1e1..a7ad5b808 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -3442,15 +3442,21 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp, V_inUse(vp) = fileServer; V_offlineMessage(vp)[0] = '\0'; } +#ifdef AFS_DEMAND_ATTACH_FS + /* check if the volume is actually usable. only do this for DAFS; for + * non-DAFS, volumes that are not inService/blessed can still be + * attached, even if clients cannot access them. this is relevant + * because for non-DAFS, we try to attach the volume when e.g. + * volserver gives us back then vol when its done with it, but + * volserver may give us back a volume that is not inService/blessed. */ + if (!V_inUse(vp)) { *ec = VNOVOL; -#ifdef AFS_DEMAND_ATTACH_FS /* Put the vol into PREATTACHED state, so if someone tries to * access it again, we try to attach, see that we're not blessed, * and give a VNOVOL error again. Putting it into UNATTACHED state * would result in a VOFFLINE error instead. */ error_state = VOL_STATE_PREATTACHED; -#endif /* AFS_DEMAND_ATTACH_FS */ /* mimic e.g. GetVolume errors */ if (!V_blessed(vp)) { @@ -3462,17 +3468,14 @@ attach2(Error * ec, VolId volumeId, char *path, struct DiskPartition64 *partp, } else { Log("Volume %lu offline: needs salvage\n", afs_printable_uint32_lu(V_id(vp))); *ec = VSALVAGE; -#ifdef AFS_DEMAND_ATTACH_FS error_state = VOL_STATE_ERROR; /* see if we can recover */ VRequestSalvage_r(ec, vp, SALVSYNC_NEEDED, VOL_SALVAGE_NO_OFFLINE); -#endif } -#ifdef AFS_DEMAND_ATTACH_FS vp->nUsers = 0; -#endif goto locked_error; } +#endif /* AFS_DEMAND_ATTACH_FS */ } else { #ifdef AFS_DEMAND_ATTACH_FS if ((mode != V_PEEK) && (mode != V_SECRETLY) && (mode != V_READONLY)) -- 2.39.5