afs: afsd -shutdown sets afs_cold_shutdown too soon 80/12180/6
authorMark Vitale <mvitale@sinenomine.net>
Thu, 28 Jan 2016 15:01:13 +0000 (10:01 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Thu, 6 May 2021 16:31:17 +0000 (12:31 -0400)
'afsd -shutdown' always invokes syscall(AFSOP_SHUTDOWN)
with parm2 set to 1 to indicate a "cold" shutdown.
(There are no other callers to AFSOP_SHUTDOWN).

AFSOP_SHUTDOWN sets global variable afs_cold_shutdown
based on the value of parm2.  Then it checks to see if
AFS is still mounted; if so, we return early with EACCES.
However, global afs_cold_shutdown remains set.

Therefore, the next successful 'umount' after a "failed"
'afsd -shutdown' will always trigger a "cold" shutdown.
This is contrary to the intent of the current implementation,
which is to perform a "warm" shutdown upon 'umount' for
most platforms.  (Exceptions:  AIX, OBSD, NBSD always
specify a cold shutdown upon 'umount').

This bug would never be noticed on the "cold" exception
platforms, but on the "warm" platforms the inconsistency
of seeing an unexpected "COLD" shutdown may be confusing
and surprising.

Make shutdown operation more self-consistent by modifying
AFSOP_SHUTDOWN to defer setting of afs_cold_shutdown until
after the mount test.

Change-Id: If4ddb592d0b8fc8098f7ef96cec82f9f545b9099
Reviewed-on: https://gerrit.openafs.org/12180
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/afs/afs_call.c

index 6785667..ed40804 100644 (file)
@@ -1464,14 +1464,16 @@ afs_syscall_call(long parm, long parm2, long parm3,
        }
     }
     else if (parm == AFSOP_SHUTDOWN) {
-       afs_cold_shutdown = 0;
-       if (parm2 == 1)
-           afs_cold_shutdown = 1;
        if (afs_globalVFS != 0) {
            afs_warn("AFS isn't unmounted yet! Call aborted\n");
            code = EACCES;
-       } else
+       } else {
+           afs_cold_shutdown = 0;
+           if (parm2 == 1) {
+               afs_cold_shutdown = 1;
+           }
            afs_shutdown();
+       }
     } else if (parm == AFSOP_AFS_VFSMOUNT) {
 #ifdef AFS_HPUX_ENV
        vfsmount(parm2, parm3, parm4, parm5);