afs: Add AFS_USPC_SHUTDOWN bkg request 81/13281/7
authorAndrew Deason <adeason@sinenomine.net>
Tue, 14 Aug 2018 20:53:20 +0000 (15:53 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 12 Jul 2019 23:55:03 +0000 (19:55 -0400)
When AFS_NEW_BKG was added, the kernel module indicated to the
relevant afsd process that it's time to shutdown by returning -2. This
works on DARWIN, but it's difficult to make this work on all
platforms, because of the different way that platforms handle error
codes from our pioctls and other AFS syscalls.

Specifically, on LINUX, negative error codes are assumed to be
negative errno codes, and so returning -2 from the syscall handler
means we return -1 to userspace, with errno set to 2 (ENOENT).

Getting this to work consistently across platforms is probably more
trouble than its worth, so instead of relying on specific return codes
from the syscall, just add a new background daemon operation called
AFS_USPC_SHUTDOWN, which just tells the background daemon to exit.

Change-Id: I00b245c8f734dc9e49d6b4268cd0f6a4f1896894
Reviewed-on: https://gerrit.openafs.org/13281
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/afs/afs_daemons.c
src/afsd/afsd.c
src/config/afs_args.h

index 861c93f..2223ce8 100644 (file)
@@ -1043,7 +1043,9 @@ afs_BackgroundDaemon(void)
            ReleaseWriteLock(&afs_xbrs);
            afs_osi_Wakeup(&afs_termState);
 #ifdef AFS_NEW_BKG
-           return -2;
+           memset(uspc, 0, sizeof(*uspc));
+           uspc->reqtype = AFS_USPC_SHUTDOWN;
+           return 0;
 #else
            return;
 #endif
index ff08532..2bc6649 100644 (file)
@@ -1553,8 +1553,15 @@ BkgHandler(void)
 
        code = afsd_syscall(AFSOP_BKG_HANDLER, uspc, srcName, dstName);
        if (code) {             /* Something is wrong? */
-           if (code == -2) /* shutting down */
-               break;
+           if (code == -2) {
+               /*
+                * Before AFS_USPC_SHUTDOWN existed, the kernel module used to
+                * indicate it was shutting down by returning -2. Treat this
+                * like a AFS_USPC_SHUTDOWN, in case we're running with an
+                * older kernel module.
+                */
+               return;
+           }
 
            sleep(1);
            uspc->retval = -1;
@@ -1562,6 +1569,10 @@ BkgHandler(void)
        }
 
        switch (uspc->reqtype) {
+       case AFS_USPC_SHUTDOWN:
+           /* Client is shutting down */
+           return;
+
        case AFS_USPC_UMV:
            snprintf(srcpath, BUFSIZ, "/afs/.:mount/%d:%d:%d:%d/%s",
                     uspc->req.umv.sCell, uspc->req.umv.sVolume,
index ae7d2d7..611f857 100644 (file)
@@ -146,6 +146,7 @@ struct afs_umv_param {
 };
 
 #define AFS_USPC_UMV 1
+#define AFS_USPC_SHUTDOWN 2
 
 struct afs_uspc_param {
     afs_int32 retval;