From 1b3f04c26e27fb59a22aaa995b49f58b834e773a Mon Sep 17 00:00:00 2001 From: Jim Rees Date: Thu, 7 Nov 2002 22:55:27 +0000 Subject: [PATCH] openbsd-20021107 fix afs_unmount make osi_NetReceive sleep at shutdown so it won't loop forever --- src/afs/OBSD/osi_vfsops.c | 51 ++++++++++++++++++++++++++----------- src/afs/OBSD/osi_vnodeops.c | 9 ++++--- src/rx/OBSD/rx_knet.c | 4 ++- 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/src/afs/OBSD/osi_vfsops.c b/src/afs/OBSD/osi_vfsops.c index 3b05ab2c4..c16c0c56b 100644 --- a/src/afs/OBSD/osi_vfsops.c +++ b/src/afs/OBSD/osi_vfsops.c @@ -233,7 +233,7 @@ struct proc *p; AFS_GLOCK(); AFS_STATCNT(afs_mount); -#ifdef DISCONN +#ifdef AFS_DISCON_ENV /* initialize the vcache entries before we start using them */ /* XXX find a better place for this if possible */ @@ -263,21 +263,42 @@ struct mount *afsp; int flags; struct proc *p; { - int err; extern int sys_ioctl(), sys_setgroups(); - err = afs_unmount(afsp, flags); - if (err == 0) { - /* give up syscall entries for ioctl & setgroups, which we've stolen */ - sysent[SYS_ioctl].sy_call = sys_ioctl; - sysent[SYS_setgroups].sy_call = sys_setgroups; - /* give up the stolen syscall entry */ - sysent[AFS_SYSCALL].sy_narg = 0; - sysent[AFS_SYSCALL].sy_argsize = 0; - sysent[AFS_SYSCALL].sy_call = afs_badcall; - printf("AFS unmounted--use `/sbin/modunload -i %d' to unload before restarting AFS\n", lkmid); + AFS_STATCNT(afs_unmount); +#ifdef AFS_DISCON_ENV + give_up_cbs(); +#endif + if (!afs_globalVFS) { + printf("afs already unmounted\n"); + return 0; } - return err; + if (afs_globalVp) + AFS_RELE(AFSTOV(afs_globalVp)); + afs_globalVp = NULL; + + vflush(afsp, NULLVP, 0); /* don't support forced */ + afsp->mnt_data = NULL; +#ifdef AFS_GLOBAL_SUNLOCK + mutex_enter(&afs_global_lock); +#endif + afs_globalVFS = 0; + afs_cold_shutdown = 1; + afs_shutdown(); /* XXX */ +#ifdef AFS_GLOBAL_SUNLOCK + mutex_exit(&afs_global_lock); +#endif + + /* give up syscall entries for ioctl & setgroups, which we've stolen */ + sysent[SYS_ioctl].sy_call = sys_ioctl; + sysent[SYS_setgroups].sy_call = sys_setgroups; + + /* give up the stolen syscall entry */ + sysent[AFS_SYSCALL].sy_narg = 0; + sysent[AFS_SYSCALL].sy_argsize = 0; + sysent[AFS_SYSCALL].sy_call = afs_badcall; + printf("AFS unmounted--use `/sbin/modunload -i %d' to unload before restarting AFS\n", lkmid); + return 0; } static int @@ -360,7 +381,7 @@ int afs_sync(struct osi_vfs *afsp) { AFS_STATCNT(afs_sync); -#if defined(DISCONN) && !defined(AFS_OBSD_ENV) +#if defined(AFS_DISCON_ENV) && !defined(AFS_OBSD_ENV) /* Can't do this in OpenBSD 2.7, it faults when called from apm_suspend() */ store_dirty_vcaches(); #endif @@ -431,7 +452,7 @@ afsinit() sysent[AFS_SYSCALL].sy_call = afs3_syscall; sysent[AFS_SYSCALL].sy_narg = 6; - sysent[AFS_SYSCALL].sy_argsize = 6*sizeof(long); + sysent[AFS_SYSCALL].sy_argsize = 6 * sizeof(long); sysent[54].sy_call = afs_xioctl; sysent[80].sy_call = Afs_xsetgroups; diff --git a/src/afs/OBSD/osi_vnodeops.c b/src/afs/OBSD/osi_vnodeops.c index 3ea68b35b..57d88ae8d 100644 --- a/src/afs/OBSD/osi_vnodeops.c +++ b/src/afs/OBSD/osi_vnodeops.c @@ -81,7 +81,7 @@ RCSID("$Header$"); #include "afs/nfsclient.h" #include "afs/afs_osidnlc.h" -#ifdef DISCONN +#ifdef AFS_DISCON_ENV extern int afs_FlushVS(struct vcache *tvc); #endif @@ -817,7 +817,7 @@ afs_nbsd_reclaim(ap) vnode_pager_uncache(vp); #endif -#ifndef DISCONN +#ifndef AFS_DISCON_ENV error = afs_FlushVCache(avc, &slept); /* tosses our stuff from vnode */ #else /* reclaim the vnode and the in-memory vcache, but keep the on-disk vcache */ @@ -878,7 +878,7 @@ afs_nbsd_bmap(ap) AFS_STATCNT(afs_bmap); if (ap->a_bnp) - ap->a_bnp = ap->a_bn * (8192 / DEV_BSIZE); + ap->a_bnp = (daddr_t *) (ap->a_bn * (8192 / DEV_BSIZE)); if (ap->a_vpp) *ap->a_vpp = (vcp) ? AFSTOV(vcp) : NULL; return 0; @@ -981,6 +981,9 @@ afs_nbsd_pathconf(ap) return 0; } +extern int +afs_lockctl(struct vcache *avc, struct AFS_FLOCK *af, int acmd, struct AFS_UCRED *acred, pid_t clid); + /* * Advisory record locking support (fcntl() POSIX style) */ diff --git a/src/rx/OBSD/rx_knet.c b/src/rx/OBSD/rx_knet.c index a9dc37de7..ad9c36793 100644 --- a/src/rx/OBSD/rx_knet.c +++ b/src/rx/OBSD/rx_knet.c @@ -46,8 +46,10 @@ int osi_NetReceive(osi_socket asocket, struct sockaddr_in *addr, struct iovec *d if (haveGlock) AFS_GLOCK(); - if (code) + if (code && afs_termState != AFSOP_STOP_RXK_LISTENER) { + afs_osi_Sleep(&afs_termState); return code; + } *alength -= u.uio_resid; if (addr && nam) { -- 2.39.5