From ed9991dc0484b6a05f6a803f9a4aad2715fc32be Mon Sep 17 00:00:00 2001 From: Sam Hartman Date: Sun, 13 Apr 2003 19:32:25 +0000 Subject: [PATCH] Merge conflicts from 1.2.8 to 1.2.9 --- Makefile.in | 18 ++-- NEWS | 14 ++- src/afs/LINUX/osi_machdep.h | 22 +++- src/afs/LINUX/osi_misc.c | 16 +-- src/afs/LINUX/osi_module.c | 175 +++++++++++++++++--------------- src/afs/LINUX/osi_vnodeops.c | 8 +- src/afs/VNOPS/afs_vnop_lookup.c | 36 +++---- src/afs/afs.h | 41 +++++--- src/afs/afs_call.c | 127 ++++++++++++----------- src/afs/afs_daemons.c | 88 +++++++++------- src/afs/afs_pioctl.c | 152 +++++++++++---------------- src/config/param.i386_linux22.h | 2 +- src/config/param.i386_linux24.h | 2 +- src/config/param.s390_linux24.h | 2 +- src/lwp/Makefile.in | 6 +- src/pam/Makefile.in | 3 +- src/ptserver/pt_util.c | 5 +- src/rx/rx.c | 140 +++++++++++-------------- src/rx/rx_packet.c | 44 +++++--- src/rxkad/ticket5.c | 2 +- src/sys/Makefile.in | 2 +- src/sys/rmtsyss.c | 3 +- src/util/Makefile.in | 12 +++ src/venus/fstrace.c | 11 +- src/venus/kdump.c | 82 ++++++++++++++- src/viced/afsfileprocs.c | 19 ++-- 26 files changed, 575 insertions(+), 457 deletions(-) diff --git a/Makefile.in b/Makefile.in index 3d8492f70..421520cdd 100644 --- a/Makefile.in +++ b/Makefile.in @@ -261,7 +261,7 @@ null: project gtx: project null auth # kauth rxkad ? case ${SYS_NAME} in \ - rs_aix* | sun4x_5? | sgi_6? | *linux* | ppc_darwin* | *fbsd*) \ + rs_aix* | sun*_5? | sgi_6? | *linux* | ppc_darwin* | *fbsd*) \ $(RM) -f ${TOP_LIBDIR}/libtermlib.a; \ ln -s libnull.a ${TOP_LIBDIR}/libtermlib.a; \ ${COMPILE_PART1} gtx ${COMPILE_PART2};; \ @@ -311,7 +311,7 @@ login: project kauth rxkad ${COMPILE_PART1} login ${COMPILE_PART2} ;; \ parisc_linux24) \ echo Skipping pam/login for parisc_linux24 ;; \ - sun4x_* | hp_ux11* | *linux* | *fbsd* ) \ + sun*_* | hp_ux11* | *linux* | *fbsd* ) \ ${COMPILE_PART1} pam ${COMPILE_PART2} ;; \ ppc_darwin* | *_obsd* ) \ echo Skipping login for ${SYS_NAME} ;; \ @@ -411,7 +411,7 @@ butc: project bubasics butm budb bucoord cmd tbutc: project bubasics butm budb bucoord cmd butc case ${SYS_NAME} in \ - alpha_dux*|sgi_*|sun4x_*|rs_aix4*|*linux*|hp_ux110) \ + alpha_dux*|sgi_*|sun*_*|rs_aix4*|*linux*|hp_ux110) \ ${COMPILE_PART1} tbutc ${COMPILE_PART2} ;; \ *) \ echo Not building MT butc for ${SYS_NAME} ;; \ @@ -434,7 +434,7 @@ tests: rxtests ubiktests # pthread based user space RX library libafsrpc: rx rxkad des case ${SYS_NAME} in \ - alpha_dux*|sgi_*|sun4x_*|rs_aix*|*linux*|hp_ux110|*fbsd*) \ + alpha_dux*|sgi_*|sun*_*|rs_aix*|*linux*|hp_ux110|*fbsd*) \ ${COMPILE_PART1} libafsrpc ${COMPILE_PART2} ;; \ *) \ echo Not building MT libafsrpc for ${SYS_NAME} ;; \ @@ -442,7 +442,7 @@ libafsrpc: rx rxkad des libafsauthent: ubik auth kauth libafsrpc case ${SYS_NAME} in \ - alpha_dux*|sgi_*|sun4x_*|rs_aix*|*linux*|hp_ux110|*fbsd*) \ + alpha_dux*|sgi_*|sun*_*|rs_aix*|*linux*|hp_ux110|*fbsd*) \ ${COMPILE_PART1} libafsauthent ${COMPILE_PART2} ;; \ *) \ echo Not building MT libafsrpc for ${SYS_NAME} ;; \ @@ -450,7 +450,7 @@ libafsauthent: ubik auth kauth libafsrpc shlibafsrpc: rx rxkad des case ${SYS_NAME} in \ - alpha_dux*|sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux110) \ + alpha_dux*|sgi_*|sun*_*|rs_aix*|*linux*|hp_ux110) \ ${COMPILE_PART1} shlibafsrpc ${COMPILE_PART2} ;; \ *) \ echo Not building shared libafsrpc for ${SYS_NAME} ;; \ @@ -458,7 +458,7 @@ shlibafsrpc: rx rxkad des shlibafsauthent: ubik auth kauth shlibafsrpc case ${SYS_NAME} in \ - alpha_dux*|sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux110) \ + alpha_dux*|sgi_*|sun*_*|rs_aix*|*linux*|hp_ux110) \ ${COMPILE_PART1} shlibafsauthent ${COMPILE_PART2} ;; \ *) \ echo Not building shared libafsrpc for ${SYS_NAME} ;; \ @@ -478,7 +478,7 @@ libadmin_real: libadmin: libafsauthent bozo case ${SYS_NAME} in \ - alpha_dux*|sgi_*|sun4x_*|rs_aix*|*linux*|hp_ux110) \ + alpha_dux*|sgi_*|sun*_*|rs_aix*|*linux*|hp_ux110) \ $(MAKE) libadmin_real ;; \ *) \ echo Not building MT libadmin for ${SYS_NAME} ;; \ @@ -762,7 +762,7 @@ package.files: package ntp: project volser @case ${WITH_OBSOLETE} in \ YES) case ${SYS_NAME} in \ - sun4x_58 | sunx86_* | *linux* | *fbsd* | ppc_darwin* ) echo skipping ntp for ${SYS_NAME} ;; \ + sun*_5[89] | *linux* | *fbsd* | ppc_darwin* ) echo skipping ntp for ${SYS_NAME} ;; \ * ) ${COMPILE_PART1} ntp ${COMPILE_PART2} ;; \ esac ;; \ *) echo skipping deprecated target: ntp ;; \ diff --git a/NEWS b/NEWS index 4246519ee..b95a74976 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,16 @@ -OpenAFS News -- history of user-visible changes. December 9, 2002. +OpenAFS News -- history of user-visible changes. April 10, 2003. + +* Changes incorporated in OpenAFS 1.2.9 + +** The kaserver now defaults to not allowing interrealm authentication, + due to security vulnerabilities in the krb4 protocol. The new + "-crossrealm" flag to the kaserver is provided to reenable interrealm + authentication if desired. + +** RedHat Linux 9.0 is now supported. + +** Solaris 9 12/02 is now supported. Solaris 7 and 8 x86 should now + work again. * Changes incorporated in OpenAFS 1.2.8 diff --git a/src/afs/LINUX/osi_machdep.h b/src/afs/LINUX/osi_machdep.h index 9c14afef4..c402a2388 100644 --- a/src/afs/LINUX/osi_machdep.h +++ b/src/afs/LINUX/osi_machdep.h @@ -24,11 +24,30 @@ #undef getuerror #define getpid() current->pid +#ifdef STRUCT_TASK_STRUCT_HAS_REAL_PARENT +#define getppid() current->real_parent->pid +#else #define getppid() current->p_opptr->pid +#endif +#ifdef RECALC_SIGPENDING_TAKES_VOID +#define RECALC_SIGPENDING(X) recalc_sigpending() +#else +#define RECALC_SIGPENDING(X) recalc_sigpending(X) +#endif + +#if defined (STRUCT_TASK_STRUCT_HAS_SIGMASK_LOCK) +#define SIG_LOCK(X) spin_lock_irq(&X->sigmask_lock) +#define SIG_UNLOCK(X) spin_unlock_irq(&X->sigmask_lock) +#elif defined (STRUCT_TASK_STRUCT_HAS_SIGHAND) +#define SIG_LOCK(X) spin_lock_irq(&X->sighand->siglock) +#define SIG_UNLOCK(X) spin_unlock_irq(&X->sighand->siglock) +#else +#define SIG_LOCK(X) spin_lock_irq(&X->sig->siglock) +#define SIG_UNLOCK(X) spin_unlock_irq(&X->sig->siglock) +#endif #define afs_hz HZ -#include "../h/sched.h" #define osi_Time() (xtime.tv_sec) #if (CPU == sparc64) #define osi_GetTime(V) do { (*(V)).tv_sec = xtime.tv_sec; (*(V)).tv_usec = xtime.tv_usec; } while (0) @@ -146,6 +165,7 @@ extern unsigned long afs_linux_page_offset; #define afs_linux_page_address(page) (afs_linux_page_offset + PAGE_SIZE * (page - mem_map)) #if defined(__KERNEL__) && defined(CONFIG_SMP) +#include "../h/sched.h" #include "linux/wait.h" extern struct semaphore afs_global_lock; diff --git a/src/afs/LINUX/osi_misc.c b/src/afs/LINUX/osi_misc.c index 2f426235b..dff15511f 100644 --- a/src/afs/LINUX/osi_misc.c +++ b/src/afs/LINUX/osi_misc.c @@ -14,7 +14,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/LINUX/osi_misc.c,v 1.12 2002/09/26 19:18:06 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/LINUX/osi_misc.c,v 1.13 2003/04/13 19:32:22 hartmans Exp $"); #include "../afs/sysincludes.h" #include "../afs/afsincludes.h" @@ -444,18 +444,10 @@ void check_bad_parent(struct dentry *dp) struct task_struct *rxk_ListenerTask; void osi_linux_mask() { - spin_lock_irq(¤t->sigmask_lock); + SIG_LOCK(current); sigfillset(¤t->blocked); - recalc_sigpending(current); - spin_unlock_irq(¤t->sigmask_lock); -} - -void osi_linux_unmask() { - spin_lock_irq(&rxk_ListenerTask->sigmask_lock); - sigemptyset(&rxk_ListenerTask->blocked); - flush_signals(rxk_ListenerTask); - recalc_sigpending(rxk_ListenerTask); - spin_unlock_irq(&rxk_ListenerTask->sigmask_lock); + RECALC_SIGPENDING(current); + SIG_UNLOCK(current); } void osi_linux_rxkreg() { diff --git a/src/afs/LINUX/osi_module.c b/src/afs/LINUX/osi_module.c index 2dbf0c9f8..093363beb 100644 --- a/src/afs/LINUX/osi_module.c +++ b/src/afs/LINUX/osi_module.c @@ -14,7 +14,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/LINUX/osi_module.c,v 1.10 2002/12/11 03:00:39 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/LINUX/osi_module.c,v 1.11 2003/04/13 19:32:22 hartmans Exp $"); #include "../afs/sysincludes.h" #include "../afs/afsincludes.h" @@ -25,9 +25,9 @@ RCSID("$Header: /tmp/cvstemp/openafs/src/afs/LINUX/osi_module.c,v 1.10 2002/12/1 #include #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) #include +#include #endif #ifndef EXPORTED_SYS_CALL_TABLE -#include #include #endif @@ -41,7 +41,6 @@ asmlinkage int (*sys_settimeofdayp)(struct timeval *tv, struct timezone *tz); #if !defined(AFS_ALPHA_LINUX20_ENV) asmlinkage int (*sys_socketcallp)(int call, long *args); #endif /* no socketcall on alpha */ -asmlinkage int (*sys_killp)(int pid, int signal); asmlinkage long (*sys_setgroupsp)(int gidsetsize, gid_t *grouplist); #ifdef EXPORTED_SYS_CALL_TABLE @@ -93,14 +92,12 @@ static unsigned int *sys_call_table32; asmlinkage int afs_syscall32(long syscall, long parm1, long parm2, long parm3, long parm4, long parm5) { -__asm__ __volatile__ (" - srl %o4, 0, %o4 - mov %o7, %i7 - call afs_syscall - srl %o5, 0, %o5 - ret - nop -"); +__asm__ __volatile__ ("srl %o4, 0, %o4\n\t" + "mov %o7, %i7\n\t" + "call afs_syscall\n\t" + "srl %o5, 0, %o5\n\t" + "ret\n\t" + "nop"); } #endif @@ -109,69 +106,65 @@ __asm__ __volatile__ (" asmlinkage long afs_syscall_stub(int r0, int r1, long r2, long r3, long r4, long gp) { -__asm__ __volatile__ (" - alloc r42 = ar.pfs, 8, 3, 6, 0 - mov r41 = b0 /* save rp */ - mov out0 = in0 - mov out1 = in1 - mov out2 = in2 - mov out3 = in3 - mov out4 = in4 - mov out5 = gp /* save gp */ - ;; -.L1: mov r3 = ip - ;; - addl r15=.fptr_afs_syscall-.L1,r3 - ;; - ld8 r15=[r15] - ;; - ld8 r16=[r15],8 - ;; - ld8 gp=[r15] - mov b6=r16 - br.call.sptk.many b0 = b6 - ;; - mov ar.pfs = r42 - mov b0 = r41 - mov gp = r48 /* restore gp */ - br.ret.sptk.many b0 -.fptr_afs_syscall: - data8 @fptr(afs_syscall) -"); +__asm__ __volatile__ ("alloc r42 = ar.pfs, 8, 3, 6, 0\n\t" + "mov r41 = b0\n\t" /* save rp */ + "mov out0 = in0\n\t" + "mov out1 = in1\n\t" + "mov out2 = in2\n\t" + "mov out3 = in3\n\t" + "mov out4 = in4\n\t" + "mov out5 = gp\n\t" /* save gp */ + ";;\n" + ".L1: mov r3 = ip\n\t" + ";;\n\t" + "addl r15=.fptr_afs_syscall-.L1,r3\n\t" + ";;\n\t" + "ld8 r15=[r15]\n\t" + ";;\n\t" + "ld8 r16=[r15],8\n\t" + ";;\n\t" + "ld8 gp=[r15]\n\t" + "mov b6=r16\n\t" + "br.call.sptk.many b0 = b6\n\t" + ";;\n\t" + "mov ar.pfs = r42\n\t" + "mov b0 = r41\n\t" + "mov gp = r48\n\t" /* restore gp */ + "br.ret.sptk.many b0\n" + ".fptr_afs_syscall:\n\t" + "data8 @fptr(afs_syscall)"); } asmlinkage long afs_xsetgroups_stub(int r0, int r1, long r2, long r3, long r4, long gp) { -__asm__ __volatile__ (" - alloc r42 = ar.pfs, 8, 3, 6, 0 - mov r41 = b0 /* save rp */ - mov out0 = in0 - mov out1 = in1 - mov out2 = in2 - mov out3 = in3 - mov out4 = in4 - mov out5 = gp /* save gp */ - ;; -.L2: mov r3 = ip - ;; - addl r15=.fptr_afs_xsetgroups - .L2,r3 - ;; - ld8 r15=[r15] - ;; - ld8 r16=[r15],8 - ;; - ld8 gp=[r15] - mov b6=r16 - br.call.sptk.many b0 = b6 - ;; - mov ar.pfs = r42 - mov b0 = r41 - mov gp = r48 /* restore gp */ - br.ret.sptk.many b0 -.fptr_afs_xsetgroups: - data8 @fptr(afs_xsetgroups) -"); +__asm__ __volatile__ ("alloc r42 = ar.pfs, 8, 3, 6, 0\n\t" + "mov r41 = b0\n\t" /* save rp */ + "mov out0 = in0\n\t" + "mov out1 = in1\n\t" + "mov out2 = in2\n\t" + "mov out3 = in3\n\t" + "mov out4 = in4\n\t" + "mov out5 = gp\n\t" /* save gp */ + ";;\n" + ".L2: mov r3 = ip\n\t" + ";;\n\t" + "addl r15=.fptr_afs_xsetgroups - .L2,r3\n\t" + ";;\n\t" + "ld8 r15=[r15]\n\t" + ";;\n\t" + "ld8 r16=[r15],8\n\t" + ";;\n\t" + "ld8 gp=[r15]\n\t" + "mov b6=r16\n\t" + "br.call.sptk.many b0 = b6\n\t" + ";;\n\t" + "mov ar.pfs = r42\n\t" + "mov b0 = r41\n\t" + "mov gp = r48\n\t" /* restore gp */ + "br.ret.sptk.many b0\n" + ".fptr_afs_xsetgroups:\n\t" + "data8 @fptr(afs_xsetgroups)"); } struct fptr @@ -202,7 +195,7 @@ int init_module(void) { #if defined(AFS_IA64_LINUX20_ENV) unsigned long kernel_gp; - static struct fptr sys_kill, sys_settimeofday, sys_setgroups; + static struct fptr sys_settimeofday, sys_setgroups; #endif extern int afs_syscall(); extern long afs_xsetgroups(); @@ -289,12 +282,20 @@ int init_module(void) sys_call_table=(void *) &(ptr[ -1 * (__NR_close-1024)]); break; } +#else +#if defined(EXPORTED_SYS_CHDIR) && defined(EXPORTED_SYS_CLOSE) + if (ptr[0] == (unsigned long)&sys_close && + ptr[__NR_chdir - __NR_close] == (unsigned long)&sys_chdir) { + sys_call_table=ptr - __NR_close; + break; + } #else if (ptr[0] == (unsigned long)&sys_exit && ptr[__NR_open - __NR_exit] == (unsigned long)&sys_open) { sys_call_table=ptr - __NR_exit; break; } +#endif #endif } #ifdef EXPORTED_KALLSYMS_ADDRESS @@ -309,6 +310,7 @@ int init_module(void) printf("Failed to find address of sys_call_table\n"); return -EIO; } + printf("Found sys_call_table at %x\n", sys_call_table); # ifdef AFS_SPARC64_LINUX20_ENV error cant support this yet. #endif @@ -319,21 +321,16 @@ error cant support this yet. kernel_gp = ((struct fptr *)printk)->gp; sys_settimeofdayp = (void *) &sys_settimeofday; - sys_killp = (void *) &sys_kill; ((struct fptr *)sys_settimeofdayp)->ip = SYSCALL2POINTER sys_call_table[__NR_settimeofday - 1024]; ((struct fptr *)sys_settimeofdayp)->gp = kernel_gp; - ((struct fptr *)sys_killp)->ip = - SYSCALL2POINTER sys_call_table[__NR_kill - 1024]; - ((struct fptr *)sys_killp)->gp = kernel_gp; #else /* !AFS_IA64_LINUX20_ENV */ sys_settimeofdayp = SYSCALL2POINTER sys_call_table[__NR_settimeofday]; #ifdef __NR_socketcall sys_socketcallp = SYSCALL2POINTER sys_call_table[__NR_socketcall]; #endif /* no socketcall on alpha */ - sys_killp = SYSCALL2POINTER sys_call_table[__NR_kill]; #endif /* AFS_IA64_LINUX20_ENV */ /* setup AFS entry point. */ @@ -440,13 +437,29 @@ static long get_page_offset(void) #if defined(AFS_PPC_LINUX22_ENV) || defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_SPARC_LINUX20_ENV) || defined(AFS_ALPHA_LINUX20_ENV) || defined(AFS_S390_LINUX22_ENV) || defined(AFS_IA64_LINUX20_ENV) || defined(AFS_PARISC_LINUX24_ENV) return PAGE_OFFSET; #else - struct task_struct *p; + struct task_struct *p, *q; /* search backward thru the circular list */ - for(p = current; p; p = p->prev_task) - if (p->pid == 1) - return p->addr_limit.seg; - - return 0; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) + read_lock(&tasklist_lock); +#endif + /* search backward thru the circular list */ +#ifdef DEFINED_PREV_TASK + for(q = current; p = q; q = prev_task(p)) { +#else + for(p = current; p; p = p->prev_task) { +#endif + if (p->pid == 1) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) + read_unlock(&tasklist_lock); +#endif + return p->addr_limit.seg; + } + } + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) + read_unlock(&tasklist_lock); +#endif + return 0; #endif } diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index d75e8cc71..aaf21c552 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -23,7 +23,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/LINUX/osi_vnodeops.c,v 1.14 2002/12/11 03:00:39 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/LINUX/osi_vnodeops.c,v 1.15 2003/04/13 19:32:22 hartmans Exp $"); #include "../afs/sysincludes.h" #include "../afs/afsincludes.h" @@ -542,11 +542,11 @@ static int afs_linux_lock(struct file *fp, int cmd, struct file_lock *flp) /* Safe because there are no large files, yet */ #if defined(F_GETLK64) && (F_GETLK != F_GETLK64) - if (cmd = F_GETLK64) + if (cmd == F_GETLK64) cmd = F_GETLK; - else if (cmd = F_SETLK64) + else if (cmd == F_SETLK64) cmd = F_SETLK; - else if (cmd = F_SETLKW64) + else if (cmd == F_SETLKW64) cmd = F_SETLKW; #endif /* F_GETLK64 && F_GETLK != F_GETLK64 */ diff --git a/src/afs/VNOPS/afs_vnop_lookup.c b/src/afs/VNOPS/afs_vnop_lookup.c index 6e32ee702..8f40009e6 100644 --- a/src/afs/VNOPS/afs_vnop_lookup.c +++ b/src/afs/VNOPS/afs_vnop_lookup.c @@ -22,7 +22,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/VNOPS/afs_vnop_lookup.c,v 1.13 2002/12/11 03:00:39 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/VNOPS/afs_vnop_lookup.c,v 1.14 2003/04/13 19:32:23 hartmans Exp $"); #include "../afs/sysincludes.h" /* Standard vendor system headers */ #include "../afs/afsincludes.h" /* Afs-based standard headers */ @@ -137,10 +137,10 @@ EvalMountPoint(avc, advc, avolpp, areq) } if (!tcell) return ENODEV; - mtptCell = tcell->cell; /* The cell for the mountpoint */ + mtptCell = tcell->cellNum; /* The cell for the mountpoint */ if (tcell->lcellp) { - hac = 1; /* has associated cell */ - assocCell = tcell->lcellp->cell; /* The associated cell */ + hac = 1; /* has associated cell */ + assocCell = tcell->lcellp->cellNum; /* The associated cell */ } afs_PutCell(tcell, READ_LOCK); @@ -255,6 +255,9 @@ void afs_InitFakeStat(state) struct afs_fakestat_state *state; { + if (!afs_fakestat_enable) + return; + state->valid = 1; state->did_eval = 0; state->need_release = 0; @@ -275,11 +278,13 @@ int afs_EvalFakeStat_int(struct vcache **avcp, struct afs_fakestat_state *state, struct volume *tvolp = NULL; int code = 0; + if (!afs_fakestat_enable) + return 0; + osi_Assert(state->valid == 1); osi_Assert(state->did_eval == 0); state->did_eval = 1; - if (!afs_fakestat_enable) - return 0; + tvc = *avcp; if (tvc->mvstat != 1) return 0; @@ -396,6 +401,9 @@ void afs_PutFakeStat(state) struct afs_fakestat_state *state; { + if (!afs_fakestat_enable) + return; + osi_Assert(state->valid == 1); if (state->need_release) afs_PutVCache(state->root_vp, 0); @@ -1313,20 +1321,14 @@ afs_lookup(adp, aname, avcp, acred) afs_PutDCache(tdc); if (code == ENOENT && afs_IsDynroot(adp) && dynrootRetry) { - struct cell *tcell; - ReleaseReadLock(&adp->lock); dynrootRetry = 0; - if (*tname == '.') - tcell = afs_GetCellByName(tname + 1, READ_LOCK); + if (tname[0] == '.') + afs_LookupAFSDB(tname + 1); else - tcell = afs_GetCellByName(tname, READ_LOCK); - if (tcell) { - afs_PutCell(tcell, READ_LOCK); - afs_RefreshDynroot(); - if (tname != aname && tname) osi_FreeLargeSpace(tname); - goto redo; - } + afs_LookupAFSDB(tname); + if (tname && tname != aname) osi_FreeLargeSpace(tname); + goto redo; } else { ReleaseReadLock(&adp->lock); } diff --git a/src/afs/afs.h b/src/afs/afs.h index d3ff50343..8f93de5c4 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -181,29 +181,43 @@ struct afs_cbr { struct AFSFid fid; }; - -#define LOCALCELL 1 /* local cell's number is always 1 */ +/* cellinfo file magic number */ +#define AFS_CELLINFO_MAGIC 0xf32817cd /* cell flags */ -#define CPrimary 1 /* on if this is the primary cell */ -#define CNoSUID 2 /* 1 if no suid progs can run from this cell */ -#define CHasVolRef 16 /* Volumes were referenced in this cell*/ -#define CLinkedCell 32 -#define CAlias 64 /* This cell entry is an alias */ +#define CNoSUID 0x02 /* disable suid bit for this cell */ +#define CLinkedCell4 0x04 /* reserved for ADDCELL2 pioctl */ +#define CNoAFSDB 0x08 /* never bother trying AFSDB */ +#define CHasVolRef 0x10 /* volumes were referenced */ +#define CLinkedCell 0x20 /* has a linked cell in lcellp */ struct cell { - struct afs_q lruq; /* lru q next and prev */ - afs_int32 cell; /* unique id assigned by venus */ + struct afs_q lruq; /* lru q next and prev */ char *cellName; /* char string name of cell */ - struct server *cellHosts[MAXCELLHOSTS]; /* volume *location* hosts for this cell */ + afs_int32 cellIndex; /* sequence number */ + afs_int32 cellNum; /* semi-permanent cell number */ + struct server *cellHosts[MAXCELLHOSTS]; /* volume *location* hosts */ struct cell *lcellp; /* Associated linked cell */ u_short fsport; /* file server port */ u_short vlport; /* volume server port */ short states; /* state flags */ - short cellIndex; /* relative index number per cell */ - short realcellIndex; /* as above but ignoring aliases */ time_t timeout; /* data expire time, if non-zero */ - char *realName; /* who this cell is an alias for */ + struct cell_name *cnamep; /* pointer to our cell_name */ + afs_rwlock_t lock; /* protects cell data */ +}; + +struct cell_name { + struct cell_name *next; + afs_int32 cellnum; + char *cellname; + char used; +}; + +struct cell_alias { + struct cell_alias *next; + afs_int32 index; + char *alias; + char *cell; }; #define afs_PutCell(cellp, locktype) @@ -992,7 +1006,6 @@ extern struct volume *afs_GetVolumeByName(); extern struct conn *afs_Conn(); extern struct conn *afs_ConnByHost(); extern struct conn *afs_ConnByMHosts(); -extern afs_int32 afs_NewCell(); extern struct dcache *afs_GetDCache(); extern struct dcache *afs_FindDCache(); extern struct dcache *afs_NewDCache(); diff --git a/src/afs/afs_call.c b/src/afs/afs_call.c index 81f760104..4280a570f 100644 --- a/src/afs/afs_call.c +++ b/src/afs/afs_call.c @@ -10,7 +10,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_call.c,v 1.14 2002/09/26 19:18:06 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_call.c,v 1.15 2003/04/13 19:32:22 hartmans Exp $"); #include "../afs/sysincludes.h" /* Standard vendor system headers */ #include "../afs/afsincludes.h" /* Afs-based standard headers */ @@ -83,6 +83,7 @@ static int afs_CacheInit_Done = 0; static int afs_Go_Done = 0; extern struct interfaceAddr afs_cb_interface; static int afs_RX_Running = 0; +static int afs_InitSetup_done = 0; static int Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval); @@ -99,6 +100,9 @@ static int afs_InitSetup(int preallocs) extern void afs_InitStats(); int code; + if (afs_InitSetup_done) + return; + #ifndef AFS_NOSTATS /* * Set up all the AFS statistics variables. This should be done @@ -121,6 +125,9 @@ static int afs_InitSetup(int preallocs) /* resource init creates the services */ afs_ResourceInit(preallocs); + afs_InitSetup_done = 1; + afs_osi_Wakeup(&afs_InitSetup_done); + return code; } #if defined(AFS_LINUX24_ENV) && defined(COMPLETION_H_EXISTS) @@ -138,6 +145,7 @@ static int afsd_thread(void *rock) { daemonize(); /* doesn't do much, since we were forked from keventd, but does call mm_release, which wakes up our parent (since it used CLONE_VFORK) */ + reparent_to_init(); afs_osi_MaskSignals(); switch (parm) { case AFSOP_START_RXCALLBACK: @@ -294,6 +302,11 @@ afs_syscall_call(parm, parm2, parm3, parm4, parm5, parm6) long parm, parm2, parm3, parm4, parm5, parm6; { afs_int32 code = 0; +#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) + size_t bufferSize; +#else /* AFS_SGI61_ENV */ + u_int bufferSize; +#endif /* AFS_SGI61_ENV */ AFS_STATCNT(afs_syscall_call); #ifdef AFS_SUN5_ENV @@ -377,21 +390,11 @@ long parm, parm2, parm3, parm4, parm5, parm6; #endif else if (parm == AFSOP_START_AFS) { /* afs daemon */ - afs_int32 temp; - if (AFS_Running) goto out; AFS_Running = 1; while (afs_initState < AFSOP_START_AFS) afs_osi_Sleep(&afs_initState); -#if defined(AFS_SUN_ENV) || defined(AFS_SGI_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) - temp = AFS_MINBUFFERS; /* Should fix this soon */ -#else - temp = ((afs_bufferpages * NBPG)>>11); /* number of 2k buffers we could get from all of the buffer space */ - temp = temp>>2; /* don't take more than 25% (our magic parameter) */ - if (temp < AFS_MINBUFFERS) temp = AFS_MINBUFFERS; /* although we really should have this many */ -#endif - DInit(temp); afs_initState = AFSOP_START_BKG; afs_osi_Wakeup(&afs_initState); afs_osi_Invisible(); @@ -452,13 +455,31 @@ long parm, parm2, parm3, parm4, parm5, parm6; } #endif #endif + else if (parm == AFSOP_BASIC_INIT) { + afs_int32 temp; + + while (!afs_InitSetup_done) + afs_osi_Sleep(&afs_InitSetup_done); + +#if defined(AFS_SUN_ENV) || defined(AFS_SGI_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) + temp = AFS_MINBUFFERS; /* Should fix this soon */ +#else + /* number of 2k buffers we could get from all of the buffer space */ + temp = ((afs_bufferpages * NBPG)>>11); + temp = temp>>2; /* don't take more than 25% (our magic parameter) */ + if (temp < AFS_MINBUFFERS) + temp = AFS_MINBUFFERS; /* though we really should have this many */ +#endif + DInit(temp); + afs_rootFid.Fid.Volume = 0; + code = 0; + } else if (parm == AFSOP_ADDCELL) { /* add a cell. Parameter 2 is 8 hosts (in net order), parm 3 is the null-terminated name. Parameter 4 is the length of the name, including the null. Parm 5 is the home cell flag (0x1 bit) and the nosuid flag (0x2 bit) */ struct afsop_cell tcell; - while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState); AFS_COPYIN((char *)parm2, (char *)tcell.hosts, sizeof(tcell.hosts), code); if (!code) { if (parm4 > sizeof(tcell.cellName)) @@ -467,22 +488,19 @@ long parm, parm2, parm3, parm4, parm5, parm6; AFS_COPYIN((char *)parm3, tcell.cellName, parm4, code); if (!code) afs_NewCell(tcell.cellName, tcell.hosts, parm5, - (char *)0, (u_short)0, (u_short)0, (int)0); + NULL, 0, 0, 0); } } } else if (parm == AFSOP_ADDCELL2) { struct afsop_cell tcell; char *tbuffer = osi_AllocSmallSpace(AFS_SMALLOCSIZ), *lcnamep = 0; char *tbuffer1 = osi_AllocSmallSpace(AFS_SMALLOCSIZ), *cnamep = 0; -#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) - size_t bufferSize; -#else /* AFS_SGI61_ENV */ - u_int bufferSize; -#endif /* AFS_SGI61_ENV */ int cflags = parm4; - /* wait for basic init */ +#if 0 + /* wait for basic init - XXX can't find any reason we need this? */ while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState); +#endif AFS_COPYIN((char *)parm2, (char *)tcell.hosts, sizeof(tcell.hosts), code); if (!code) { @@ -497,7 +515,7 @@ long parm, parm2, parm3, parm4, parm5, parm6; } if (!code) afs_NewCell(tbuffer1, tcell.hosts, cflags, - lcnamep, (u_short)0, (u_short)0, (int)0); + lcnamep, 0, 0, 0); } } osi_FreeSmallSpace(tbuffer); @@ -509,34 +527,33 @@ long parm, parm2, parm3, parm4, parm5, parm6; * parm2 is the alias name * parm3 is the real cell name */ -#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) - size_t bufferSize; -#else /* AFS_SGI61_ENV */ - u_int bufferSize; -#endif /* AFS_SGI61_ENV */ char *aliasName = osi_AllocSmallSpace(AFS_SMALLOCSIZ); char *cellName = osi_AllocSmallSpace(AFS_SMALLOCSIZ); AFS_COPYINSTR((char *)parm2, aliasName, AFS_SMALLOCSIZ, &bufferSize, code); if (!code) AFS_COPYINSTR((char *)parm3, cellName, AFS_SMALLOCSIZ, &bufferSize, code); - if (!code) afs_NewCell(aliasName, /* new entry name */ - 0, /* host list */ - CAlias, /* flags */ - (char *) 0, /* linked cell */ - 0, 0, /* fs & vl ports */ - 0, /* timeout */ - cellName); /* real cell name */ + if (!code) afs_NewCellAlias(aliasName, cellName); osi_FreeSmallSpace(aliasName); osi_FreeSmallSpace(cellName); } + else if (parm == AFSOP_SET_THISCELL) { + /* + * Call arguments: + * parm2 is the primary cell name + */ + char *cell = osi_AllocSmallSpace(AFS_SMALLOCSIZ); + + AFS_COPYINSTR((char *) parm2, cell, AFS_SMALLOCSIZ, &bufferSize, code); + if (!code) + afs_SetPrimaryCell(cell); + osi_FreeSmallSpace(cell); + } else if (parm == AFSOP_CACHEINIT) { struct afs_cacheParams cparms; if (afs_CacheInit_Done) goto out; - /* wait for basic init */ - while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState); AFS_COPYIN((char *)parm2, (caddr_t) &cparms, sizeof(cparms), code); if (code) { #if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined (AFS_SGI64_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) @@ -585,12 +602,6 @@ long parm, parm2, parm3, parm4, parm5, parm6; code = afs_InitCacheFile((char *) 0, ainode); } else if (parm == AFSOP_ROOTVOLUME) { -#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) - size_t bufferSize; -#else /* AFS_SGI61_ENV */ - u_int bufferSize; -#endif /* AFS_SGI61_ENV */ - /* wait for basic init */ while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState); @@ -600,29 +611,31 @@ long parm, parm2, parm3, parm4, parm5, parm6; } else code = 0; } - else if (parm == AFSOP_CACHEFILE || parm == AFSOP_CACHEINFO || - parm == AFSOP_VOLUMEINFO || parm == AFSOP_AFSLOG) { + else if (parm == AFSOP_CACHEFILE || + parm == AFSOP_CACHEINFO || + parm == AFSOP_VOLUMEINFO || + parm == AFSOP_AFSLOG || + parm == AFSOP_CELLINFO) { char *tbuffer = osi_AllocSmallSpace(AFS_SMALLOCSIZ); -#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) - size_t bufferSize; -#else /* AFS_SGI61_ENV */ - u_int bufferSize; -#endif /* AFS_SGI61_ENV */ - /* wait for basic init */ - while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState); code = 0; - AFS_COPYINSTR((char *)parm2, tbuffer, AFS_SMALLOCSIZ, &bufferSize, code); + AFS_COPYINSTR((char *) parm2, tbuffer, AFS_SMALLOCSIZ, + &bufferSize, code); if (code) { osi_FreeSmallSpace(tbuffer); goto out; } if (!code) { - tbuffer[AFS_SMALLOCSIZ-1] = 0; /* null-terminate the name */ - /* we now have the cache dir copied in. Call the cache init routines */ - if (parm == AFSOP_CACHEFILE) code = afs_InitCacheFile(tbuffer, 0); - else if (parm == AFSOP_CACHEINFO) code = afs_InitCacheInfo(tbuffer); - else if (parm == AFSOP_VOLUMEINFO) code = afs_InitVolumeInfo(tbuffer); + tbuffer[AFS_SMALLOCSIZ-1] = '\0'; /* null-terminate the name */ + /* We have the cache dir copied in. Call the cache init routine */ + if (parm == AFSOP_CACHEFILE) + code = afs_InitCacheFile(tbuffer, 0); + else if (parm == AFSOP_CACHEINFO) + code = afs_InitCacheInfo(tbuffer); + else if (parm == AFSOP_VOLUMEINFO) + code = afs_InitVolumeInfo(tbuffer); + else if (parm == AFSOP_CELLINFO) + code = afs_InitCellInfo(tbuffer); } osi_FreeSmallSpace(tbuffer); } @@ -827,7 +840,7 @@ long parm, parm2, parm3, parm4, parm5, parm6; AFS_COPYIN((afs_int32 *)parm2, cellname, cellLen, code); AFS_COPYIN((afs_int32 *)parm3, kmsg, kmsgLen, code); if (!code) { - code = afs_AfsdbHandler(cellname, cellLen, kmsg); + code = afs_AFSDBHandler(cellname, cellLen, kmsg); if (*cellname == 1) *cellname = 0; if (code == -2) { /* Shutting down? */ *cellname = 1; @@ -1451,7 +1464,7 @@ afs_shutdown() } #ifdef AFS_AFSDB_ENV afs_warn("AFSDB... "); - afs_StopAfsdb(); + afs_StopAFSDB(); while (afs_termState == AFSOP_STOP_AFSDB) afs_osi_Sleep(&afs_termState); #endif diff --git a/src/afs/afs_daemons.c b/src/afs/afs_daemons.c index a73e1e829..fad44353f 100644 --- a/src/afs/afs_daemons.c +++ b/src/afs/afs_daemons.c @@ -10,7 +10,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_daemons.c,v 1.7 2002/05/12 05:50:42 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_daemons.c,v 1.8 2003/04/13 19:32:22 hartmans Exp $"); #include "../afs/sysincludes.h" /* Standard vendor system headers */ #include "../afs/afsincludes.h" /* Afs-based standard headers */ @@ -265,57 +265,67 @@ void afs_Daemon() { } } -afs_CheckRootVolume () { +int afs_CheckRootVolume (void) { char rootVolName[32]; - register struct volume *tvp; + struct volume *tvp; int usingDynroot = afs_GetDynrootEnable(); + int localcell; AFS_STATCNT(afs_CheckRootVolume); if (*afs_rootVolumeName == 0) { strcpy(rootVolName, "root.afs"); - } - else { + } else { strcpy(rootVolName, afs_rootVolumeName); } + + if (!usingDynroot) { + struct cell *lc = afs_GetPrimaryCell(READ_LOCK); + + if (!lc) + return ENOENT; + localcell = lc->cellNum; + afs_PutCell(lc, READ_LOCK); + } + if (usingDynroot) { - afs_GetDynrootFid(&afs_rootFid); - tvp = afs_GetVolume(&afs_rootFid, (struct vrequest *) 0, READ_LOCK); + afs_GetDynrootFid(&afs_rootFid); + tvp = afs_GetVolume(&afs_rootFid, NULL, READ_LOCK); } else { - tvp = afs_GetVolumeByName(rootVolName, LOCALCELL, 1, (struct vrequest *) 0, READ_LOCK); + tvp = afs_GetVolumeByName(rootVolName, localcell, 1, NULL, READ_LOCK); } - if (!tvp) { - char buf[128]; - int len = strlen(rootVolName); - - if ((len < 9) || strcmp(&rootVolName[len - 9], ".readonly")) { - strcpy(buf, rootVolName); - afs_strcat(buf, ".readonly"); - tvp = afs_GetVolumeByName(buf, LOCALCELL, 1, (struct vrequest *) 0, READ_LOCK); - } + if (!tvp && !usingDynroot) { + char buf[128]; + int len = strlen(rootVolName); + + if ((len < 9) || strcmp(&rootVolName[len - 9], ".readonly")) { + strcpy(buf, rootVolName); + afs_strcat(buf, ".readonly"); + tvp = afs_GetVolumeByName(buf, localcell, 1, NULL, READ_LOCK); + } } if (tvp) { - if (!usingDynroot) { - int volid = (tvp->roVol? tvp->roVol : tvp->volume); - afs_rootFid.Cell = LOCALCELL; - if (afs_rootFid.Fid.Volume && afs_rootFid.Fid.Volume != volid - && afs_globalVp) { - /* If we had a root fid before and it changed location we reset - * the afs_globalVp so that it will be reevaluated. - * Just decrement the reference count. This only occurs during - * initial cell setup and can panic the machine if we set the - * count to zero and fs checkv is executed when the current - * directory is /afs. - */ - AFS_FAST_RELE(afs_globalVp); - afs_globalVp = 0; - } - afs_rootFid.Fid.Volume = volid; - afs_rootFid.Fid.Vnode = 1; - afs_rootFid.Fid.Unique = 1; - } - afs_initState = 300; /* won */ - afs_osi_Wakeup(&afs_initState); - afs_PutVolume(tvp, READ_LOCK); + if (!usingDynroot) { + int volid = (tvp->roVol? tvp->roVol : tvp->volume); + afs_rootFid.Cell = localcell; + if (afs_rootFid.Fid.Volume && afs_rootFid.Fid.Volume != volid + && afs_globalVp) { + /* If we had a root fid before and it changed location we reset + * the afs_globalVp so that it will be reevaluated. + * Just decrement the reference count. This only occurs during + * initial cell setup and can panic the machine if we set the + * count to zero and fs checkv is executed when the current + * directory is /afs. + */ + AFS_FAST_RELE(afs_globalVp); + afs_globalVp = 0; + } + afs_rootFid.Fid.Volume = volid; + afs_rootFid.Fid.Vnode = 1; + afs_rootFid.Fid.Unique = 1; + } + afs_initState = 300; /* won */ + afs_osi_Wakeup(&afs_initState); + afs_PutVolume(tvp, READ_LOCK); } #ifdef AFS_DEC_ENV /* This is to make sure that we update the root gnode */ diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c index 0df96f120..b314112ca 100644 --- a/src/afs/afs_pioctl.c +++ b/src/afs/afs_pioctl.c @@ -10,7 +10,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_pioctl.c,v 1.15 2002/09/26 19:18:06 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_pioctl.c,v 1.16 2003/04/13 19:32:22 hartmans Exp $"); #include "../afs/sysincludes.h" /* Standard vendor system headers */ #include "../afs/afsincludes.h" /* Afs-based standard headers */ @@ -1327,39 +1327,29 @@ static PGCPAGs(avc, afun, areq, ain, aout, ainSize, aoutSize, acred) return 0; } - static PGetWSCell(avc, afun, areq, ain, aout, ainSize, aoutSize) - struct vcache *avc; - int afun; - struct vrequest *areq; - register char *ain; - char *aout; - afs_int32 ainSize; - afs_int32 *aoutSize; /* set this */ { - register struct cell *tcell=0, *cellOne=0; - register struct afs_q *cq, *tq; +static PGetWSCell(avc, afun, areq, ain, aout, ainSize, aoutSize) + struct vcache *avc; + int afun; + struct vrequest *areq; + register char *ain; + char *aout; + afs_int32 ainSize; + afs_int32 *aoutSize; /* set this */ +{ + struct cell *tcell = NULL; AFS_STATCNT(PGetWSCell); if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */ return EIO; /* Inappropriate ioctl for device */ - ObtainReadLock(&afs_xcell); - cellOne = (struct cell *) 0; - - for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { - tcell = QTOC(cq); tq = QNext(cq); - if (tcell->states & CPrimary) break; - if (tcell->cell == 1) cellOne = tcell; - tcell = 0; - } - ReleaseReadLock(&afs_xcell); - if (!tcell) { /* no primary cell, use cell #1 */ - if (!cellOne) return ESRCH; - tcell = cellOne; - } + tcell = afs_GetPrimaryCell(READ_LOCK); + if (!tcell) /* no primary cell? */ + return ESRCH; strcpy(aout, tcell->cellName); *aoutSize = strlen(aout) + 1; + afs_PutCell(tcell, READ_LOCK); return 0; - } +} static PGetUserCell(avc, afun, areq, ain, aout, ainSize, aoutSize) struct vcache *avc; @@ -1454,20 +1444,15 @@ static PGCPAGs(avc, afun, areq, ain, aout, ainSize, aoutSize, acred) set_parent_pag = 1; } tcell = afs_GetCellByName(ain, READ_LOCK); - if (tcell) { - i = tcell->cell; - } - else { - goto nocell; - } + if (!tcell) goto nocell; } else { - /* default to cell 1, primary id */ + /* default to primary cell, primary id */ flag = 1; /* primary id */ - i = 1; /* cell number */ - tcell = afs_GetCell(1, READ_LOCK); + tcell = afs_GetPrimaryCell(READ_LOCK); if (!tcell) goto nocell; } + i = tcell->cellNum; afs_PutCell(tcell, READ_LOCK); if (set_parent_pag) { int pag; @@ -1818,7 +1803,7 @@ static PGetTokens(avc, afun, areq, ain, aout, ainSize, aoutSize) } } else { - if (tu->uid == areq->uid && tu->cell == 1) break; + if (tu->uid == areq->uid && afs_IsPrimaryCellNum(tu->cell)) break; } } if (tu) { @@ -2003,7 +1988,7 @@ static PCheckServers(avc, afun, areq, ain, aout, ainSize, aoutSize, acred) else cellp = (struct cell *) 0; if (!cellp && (temp & 2)) { /* use local cell */ - cellp = afs_GetCell(1, READ_LOCK); + cellp = afs_GetPrimaryCell(READ_LOCK); } if (!(temp & 1)) { /* if not fast, call server checker routine */ afs_CheckServers(1, cellp); /* check down servers */ @@ -2342,7 +2327,7 @@ static PNewCell(avc, afun, areq, ain, aout, ainSize, aoutSize, acred) } linkedstate |= CNoSUID; /* setuid is disabled by default for fs newcell */ - code = afs_NewCell(newcell, cellHosts, linkedstate, linkedcell, fsport, vlport, (int)0, (char *) 0); + code = afs_NewCell(newcell, cellHosts, linkedstate, linkedcell, fsport, vlport, (int)0); return code; } @@ -2357,11 +2342,9 @@ static PNewAlias(avc, afun, areq, ain, aout, ainSize, aoutSize, acred) afs_int32 *aoutSize; /* set this */ { /* create a new cell alias */ - register struct cell *tcell; char *tp = ain; register afs_int32 code; char *realName, *aliasName; - register struct afs_q *cq, *tq; if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */ return EIO; /* Inappropriate ioctl for device */ @@ -2373,22 +2356,7 @@ static PNewAlias(avc, afun, areq, ain, aout, ainSize, aoutSize, acred) tp += strlen(aliasName) + 1; realName = tp; - /* - * Prevent user from shooting themselves in the foot -- don't allow - * creation of aliases when a real cell already exists with that name. - */ - ObtainReadLock(&afs_xcell); - for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { - tcell = QTOC(cq); tq = QNext(cq); - if ((afs_strcasecmp(tcell->cellName, aliasName) == 0) && - !(tcell->states & CAlias)) { - ReleaseReadLock(&afs_xcell); - return EEXIST; - } - } - ReleaseReadLock(&afs_xcell); - - code = afs_NewCell(aliasName, 0, CAlias, 0, 0, 0, 0, realName); + code = afs_NewCellAlias(aliasName, realName); *aoutSize = 0; return code; } @@ -2404,7 +2372,6 @@ static PListCells(avc, afun, areq, ain, aout, ainSize, aoutSize) register struct cell *tcell=0; register afs_int32 i; register char *cp, *tp = ain; - register struct afs_q *cq, *tq; AFS_STATCNT(PListCells); if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */ @@ -2412,7 +2379,7 @@ static PListCells(avc, afun, areq, ain, aout, ainSize, aoutSize) memcpy((char *)&whichCell, tp, sizeof(afs_int32)); tp += sizeof(afs_int32); - tcell = afs_GetRealCellByIndex(whichCell, READ_LOCK, 0); + tcell = afs_GetCellByIndex(whichCell, READ_LOCK); if (tcell) { cp = aout; memset(cp, 0, MAXCELLHOSTS * sizeof(afs_int32)); @@ -2425,6 +2392,7 @@ static PListCells(avc, afun, areq, ain, aout, ainSize, aoutSize) strcpy(cp, tcell->cellName); cp += strlen(tcell->cellName)+1; *aoutSize = cp - aout; + afs_PutCell(tcell, READ_LOCK); } if (tcell) return 0; else return EDOM; @@ -2439,9 +2407,8 @@ static PListAliases(avc, afun, areq, ain, aout, ainSize, aoutSize) afs_int32 *aoutSize; /* set this */ { afs_int32 whichAlias; - register struct cell *tcell=0; + register struct cell_alias *tcalias=0; register char *cp, *tp = ain; - register struct afs_q *cq, *tq; if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */ return EIO; /* Inappropriate ioctl for device */ @@ -2451,27 +2418,17 @@ static PListAliases(avc, afun, areq, ain, aout, ainSize, aoutSize) memcpy((char *)&whichAlias, tp, sizeof(afs_int32)); tp += sizeof(afs_int32); - ObtainReadLock(&afs_xcell); - for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { - tcell = QTOC(cq); tq = QNext(cq); - if (!(tcell->states & CAlias)) { - tcell = 0; - continue; - } - if (whichAlias == 0) break; - tcell = 0; - whichAlias--; - } - if (tcell) { + tcalias = afs_GetCellAlias(whichAlias); + if (tcalias) { cp = aout; - strcpy(cp, tcell->cellName); - cp += strlen(tcell->cellName)+1; - strcpy(cp, tcell->realName); - cp += strlen(tcell->realName)+1; + strcpy(cp, tcalias->alias); + cp += strlen(tcalias->alias)+1; + strcpy(cp, tcalias->cell); + cp += strlen(tcalias->cell)+1; *aoutSize = cp - aout; + afs_PutCellAlias(tcalias); } - ReleaseReadLock(&afs_xcell); - if (tcell) return 0; + if (tcalias) return 0; else return EDOM; } @@ -2956,10 +2913,22 @@ register struct AFS_UCRED *acred; * fine. Should consider special-casing the local cell for large n. * Likewise for PSetSPrefs. */ -static void ReSortCells(s,l, vlonly) - int s; /* number of ids in array l[] -- NOT index of last id */ - afs_int32 l[]; /* array of cell ids which have volumes that need to be sorted */ - int vlonly; /* sort vl servers or file servers?*/ +static void *ReSortCells_cb(struct cell *cell, void *arg) +{ + afs_int32 *p = (afs_int32 *) arg; + afs_int32 *l = p + 1; + int i, s = p[0]; + + for (i=0; icellNum) { + ObtainWriteLock(&cell->lock, 690); + afs_SortServers(cell->cellHosts, MAXCELLHOSTS); + ReleaseWriteLock(&cell->lock); + } + } +} + +static void ReSortCells(int s, afs_int32 *l, int vlonly) { extern struct volume *afs_volumes[NVOLS]; /* volume hash table */ @@ -2968,15 +2937,12 @@ static void ReSortCells(s,l, vlonly) register int k; if (vlonly) { - struct cell *tcell; - ObtainWriteLock(&afs_xcell,300); - for(k=0;kcellHosts, MAXCELLHOSTS); - afs_PutCell(tcell, WRITE_LOCK); - } - ReleaseWriteLock(&afs_xcell); + afs_int32 *p; + p = (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * (s+1)); + p[0] = s; + memcpy(p+1, l, s * sizeof(afs_int32)); + afs_TraverseCells(&ReSortCells_cb, p); + afs_osi_Free(p, sizeof(afs_int32) * (s+1)); return; } @@ -3038,10 +3004,10 @@ static int afs_setsprefs(sp, num, vlonly) if (srvr->cell) { /* if we don't know yet what cell it's in, this is moot */ - for (j=touchedSize-1; j>=0 && touched[j] != srvr->cell->cell; j--) + for (j=touchedSize-1; j>=0 && touched[j] != srvr->cell->cellNum; j--) /* is it in our list of touched cells ? */ ; if (j < 0) { /* no, it's not */ - touched[touchedSize++] = srvr->cell->cell; + touched[touchedSize++] = srvr->cell->cellNum; if (touchedSize >= 32) { /* watch for ovrflow */ ReleaseReadLock(&afs_xserver); ReSortCells(touchedSize, touched, vlonly); diff --git a/src/config/param.i386_linux22.h b/src/config/param.i386_linux22.h index 0a845bcf2..1501236eb 100644 --- a/src/config/param.i386_linux22.h +++ b/src/config/param.i386_linux22.h @@ -39,7 +39,7 @@ #ifdef AFS_SMP #define CONFIG_SMP 1 #ifndef CONFIG_X86_LOCAL_APIC -#define CONFIG_X86_LOCAL_APIC +#define CONFIG_X86_LOCAL_APIC 1 #endif #ifndef __SMP__ #define __SMP__ diff --git a/src/config/param.i386_linux24.h b/src/config/param.i386_linux24.h index 049d461ee..b6018605e 100644 --- a/src/config/param.i386_linux24.h +++ b/src/config/param.i386_linux24.h @@ -34,7 +34,7 @@ #ifdef AFS_SMP #define CONFIG_SMP 1 #ifndef CONFIG_X86_LOCAL_APIC -#define CONFIG_X86_LOCAL_APIC +#define CONFIG_X86_LOCAL_APIC 1 #endif #ifndef __SMP__ #define __SMP__ diff --git a/src/config/param.s390_linux24.h b/src/config/param.s390_linux24.h index 6a7189f9d..8c2fa46c8 100644 --- a/src/config/param.s390_linux24.h +++ b/src/config/param.s390_linux24.h @@ -37,7 +37,7 @@ #ifdef AFS_SMP #define CONFIG_SMP 1 #ifndef CONFIG_S390_LOCAL_APIC -#define CONFIG_S390_LOCAL_APIC +#define CONFIG_S390_LOCAL_APIC 1 #endif #ifndef __SMP__ #define __SMP__ diff --git a/src/lwp/Makefile.in b/src/lwp/Makefile.in index ffb0679ff..f1779c577 100644 --- a/src/lwp/Makefile.in +++ b/src/lwp/Makefile.in @@ -55,7 +55,7 @@ process.o : process.s process.c @case "$(SYS_NAME)" in \ pmax_he1) \ $(CC) -c -I${TOP_INCDIR} process.s;; \ - sun4c_51 | sun4c_52 | sun4m_51 | sun4m_52 | sun4c_53 | sun4m_53 | sun4_53 | sun4_52 | sun4_54 | sun4c_54 | sun4m_54 | sun4x_5? | sunx86_54) \ + sun4c_51 | sun4c_52 | sun4m_51 | sun4m_52 | sun4c_53 | sun4m_53 | sun4_53 | sun4_52 | sun4_54 | sun4c_54 | sun4m_54 | sun4x_5? | sunx86_5? | ncrx86_*) \ /usr/ccs/lib/cpp -P -I${TOP_INCDIR} process.s process.ss; \ ${AS} process.ss -o process.o; \ $(RM) process.ss ;; \ @@ -75,10 +75,6 @@ process.o : process.s process.c $(RM) process.ss ;; \ hp* | *_linux* | sgi_64 | sgi_65 ) \ ${CC} ${CFLAGS} -c process.c;; \ - ncrx86_*) \ - /usr/ccs/lib/cpp -P -I${TOP_INCDIR} process.s process.ss; \ - ${AS} -o process.o process.ss; \ - $(RM) process.ss ;; \ alpha_osf1 | alpha_osf20 | alpha_osf30 | alpha_osf32 | alpha_osf32c | alpha_dux?? ) \ ${AS} -v -P -DOSF -I${TOP_INCDIR} -DASSEMBLER process.s; \ ${AS} -v process.i -o process.o;; \ diff --git a/src/pam/Makefile.in b/src/pam/Makefile.in index ba61bb8bd..6f932735c 100644 --- a/src/pam/Makefile.in +++ b/src/pam/Makefile.in @@ -43,8 +43,7 @@ LDFLAGS = ${SHLIB_LDFLAGS} SHOBJS = afs_account.o afs_session.o afs_password.o \ afs_pam_msg.o afs_message.o AFS_component_version_number.o OBJS = $(SHOBJS) test_pam.o -INCLUDES=-I${TOP_SRCDIR}/config -I${TOP_INCDIR} \ - -I/usr/include -I/usr/include/sys +INCLUDES=-I${TOP_SRCDIR}/config -I${TOP_INCDIR} CFLAGS = ${DEBUG} ${INCLUDES} ${PAM_CFLAGS} all: test_pam ${TOP_LIBDIR}/pam_afs.so.1 ${TOP_LIBDIR}/pam_afs.krb.so.1 diff --git a/src/ptserver/pt_util.c b/src/ptserver/pt_util.c index 942a5dce2..e53230004 100644 --- a/src/ptserver/pt_util.c +++ b/src/ptserver/pt_util.c @@ -1,4 +1,4 @@ -/* $Id: pt_util.c,v 1.6 2003/01/02 03:55:51 hartmans Exp $ */ +/* $Id: pt_util.c,v 1.7 2003/04/13 19:32:23 hartmans Exp $ */ /* * @@ -16,12 +16,13 @@ #include #include #include +#include #include #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/ptserver/pt_util.c,v 1.6 2003/01/02 03:55:51 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/ptserver/pt_util.c,v 1.7 2003/04/13 19:32:23 hartmans Exp $"); #include #include diff --git a/src/rx/rx.c b/src/rx/rx.c index 718af16c7..9b216b20d 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -16,7 +16,7 @@ #include #endif -RCSID("$Header: /tmp/cvstemp/openafs/src/rx/rx.c,v 1.13 2002/12/11 03:00:40 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/rx/rx.c,v 1.14 2003/04/13 19:32:24 hartmans Exp $"); #ifdef KERNEL #include "../afs/sysincludes.h" @@ -79,7 +79,7 @@ extern afs_int32 afs_termState; #ifdef AFS_NT40_ENV # include # include -# include +# include #else # include # include @@ -143,6 +143,7 @@ static unsigned int rxi_rpc_process_stat_cnt; * to ease NT porting */ +extern pthread_mutex_t rx_stats_mutex; extern pthread_mutex_t rxkad_stats_mutex; extern pthread_mutex_t des_init_mutex; extern pthread_mutex_t des_random_mutex; @@ -167,6 +168,8 @@ static pthread_mutex_t rx_debug_mutex; static void rxi_InitPthread(void) { assert(pthread_mutex_init(&rx_clock_mutex, (const pthread_mutexattr_t*)0)==0); + assert(pthread_mutex_init(&rx_stats_mutex, + (const pthread_mutexattr_t*)0)==0); assert(pthread_mutex_init(&rxi_connCacheMutex, (const pthread_mutexattr_t*)0)==0); assert(pthread_mutex_init(&rx_init_mutex, @@ -251,7 +254,6 @@ assert(pthread_once(&rx_once_init, rxi_InitPthread)==0); */ #ifdef RX_ENABLE_LOCKS -static int rxi_ServerThreadSelectingCall; static afs_kmutex_t rx_rpc_stats; void rxi_StartUnlocked(); #endif @@ -425,7 +427,6 @@ int rx_Init(u_int port) #ifndef KERNEL MUTEX_INIT(&rxi_keyCreate_lock, "rxi_keyCreate_lock", MUTEX_DEFAULT, 0); #endif /* !KERNEL */ - CV_INIT(&rx_serverPool_cv, "rx_serverPool_cv",CV_DEFAULT, 0); #if defined(KERNEL) && defined(AFS_HPUX110_ENV) if ( !uniprocessor ) rx_sleepLock = alloc_spinlock(LAST_HELD_ORDER-10, "rx_sleepLock"); @@ -1421,7 +1422,7 @@ struct rx_service *cur_service; osi_socket *socketp; { struct rx_serverQueueEntry *sq; - register struct rx_call *call = (struct rx_call *) 0, *choice2; + register struct rx_call *call = (struct rx_call *) 0; struct rx_service *service = NULL; SPLVAR; @@ -1443,8 +1444,8 @@ osi_socket *socketp; } while (1) { if (queue_IsNotEmpty(&rx_incomingCallQueue)) { - register struct rx_call *tcall, *ncall; - choice2 = (struct rx_call *) 0; + register struct rx_call *tcall, *ncall, *choice2 = NULL; + /* Scan for eligible incoming calls. A call is not eligible * if the maximum number of calls for its service type are * already executing */ @@ -1453,66 +1454,61 @@ osi_socket *socketp; * have all their input data available immediately. This helps * keep threads from blocking, waiting for data from the client. */ for (queue_Scan(&rx_incomingCallQueue, tcall, ncall, rx_call)) { - service = tcall->conn->service; - if (!QuotaOK(service)) { - continue; - } - if (!tno || !tcall->queue_item_header.next ) { - /* If we're thread 0, then we'll just use - * this call. If we haven't been able to find an optimal - * choice, and we're at the end of the list, then use a - * 2d choice if one has been identified. Otherwise... */ - call = (choice2 ? choice2 : tcall); - service = call->conn->service; - } else if (!queue_IsEmpty(&tcall->rq)) { - struct rx_packet *rp; - rp = queue_First(&tcall->rq, rx_packet); - if (rp->header.seq == 1) { - if (!meltdown_1pkt || - (rp->header.flags & RX_LAST_PACKET)) { - call = tcall; - } else if (rxi_2dchoice && !choice2 && - !(tcall->flags & RX_CALL_CLEARED) && - (tcall->rprev > rxi_HardAckRate)) { - choice2 = tcall; - } else rxi_md2cnt++; + service = tcall->conn->service; + if (!QuotaOK(service)) { + continue; + } + if (tno==rxi_fcfs_thread_num || !tcall->queue_item_header.next ) { + /* If we're the fcfs thread , then we'll just use + * this call. If we haven't been able to find an optimal + * choice, and we're at the end of the list, then use a + * 2d choice if one has been identified. Otherwise... */ + call = (choice2 ? choice2 : tcall); + service = call->conn->service; + } else if (!queue_IsEmpty(&tcall->rq)) { + struct rx_packet *rp; + rp = queue_First(&tcall->rq, rx_packet); + if (rp->header.seq == 1) { + if (!meltdown_1pkt || + (rp->header.flags & RX_LAST_PACKET)) { + call = tcall; + } else if (rxi_2dchoice && !choice2 && + !(tcall->flags & RX_CALL_CLEARED) && + (tcall->rprev > rxi_HardAckRate)) { + choice2 = tcall; + } else rxi_md2cnt++; + } + } + if (call) { + break; + } else { + ReturnToServerPool(service); } - } - if (call) { - break; - } else { - ReturnToServerPool(service); - } } - } + } if (call) { queue_Remove(call); - rxi_ServerThreadSelectingCall = 1; MUTEX_EXIT(&rx_serverPool_lock); MUTEX_ENTER(&call->lock); - MUTEX_ENTER(&rx_serverPool_lock); - - if (queue_IsEmpty(&call->rq) || - queue_First(&call->rq, rx_packet)->header.seq != 1) - rxi_SendAck(call, 0, 0, 0, 0, RX_ACK_DELAY, 0); - CLEAR_CALL_QUEUE_LOCK(call); - if (call->error) { + if (call->state != RX_STATE_PRECALL || call->error) { MUTEX_EXIT(&call->lock); + MUTEX_ENTER(&rx_serverPool_lock); ReturnToServerPool(service); - rxi_ServerThreadSelectingCall = 0; - CV_SIGNAL(&rx_serverPool_cv); - call = (struct rx_call*)0; + call = NULL; continue; } - call->flags &= (~RX_CALL_WAIT_PROC); + + if (queue_IsEmpty(&call->rq) || + queue_First(&call->rq, rx_packet)->header.seq != 1) + rxi_SendAck(call, 0, 0, 0, 0, RX_ACK_DELAY, 0); + + CLEAR_CALL_QUEUE_LOCK(call); + call->flags &= ~RX_CALL_WAIT_PROC; MUTEX_ENTER(&rx_stats_mutex); rx_nWaiting--; MUTEX_EXIT(&rx_stats_mutex); - rxi_ServerThreadSelectingCall = 0; - CV_SIGNAL(&rx_serverPool_cv); - MUTEX_EXIT(&rx_serverPool_lock); break; } else { @@ -1615,8 +1611,8 @@ rx_GetCall(tno, cur_service, socketp) for (queue_Scan(&rx_incomingCallQueue, tcall, ncall, rx_call)) { service = tcall->conn->service; if (QuotaOK(service)) { - if (!tno || !tcall->queue_item_header.next ) { - /* If we're thread 0, then we'll just use + if (tno==rxi_fcfs_thread_num || !tcall->queue_item_header.next ) { + /* If we're the fcfs thread, then we'll just use * this call. If we haven't been able to find an optimal * choice, and we're at the end of the list, then use a * 2d choice if one has been identified. Otherwise... */ @@ -3926,23 +3922,12 @@ rxi_AttachServerProc(call, socket, tnop, newcallp) { register struct rx_serverQueueEntry *sq; register struct rx_service *service = call->conn->service; -#ifdef RX_ENABLE_LOCKS register int haveQuota = 0; -#endif /* RX_ENABLE_LOCKS */ + /* May already be attached */ if (call->state == RX_STATE_ACTIVE) return; MUTEX_ENTER(&rx_serverPool_lock); -#ifdef RX_ENABLE_LOCKS - while(rxi_ServerThreadSelectingCall) { - MUTEX_EXIT(&call->lock); - CV_WAIT(&rx_serverPool_cv, &rx_serverPool_lock); - MUTEX_EXIT(&rx_serverPool_lock); - MUTEX_ENTER(&call->lock); - MUTEX_ENTER(&rx_serverPool_lock); - /* Call may have been attached */ - if (call->state == RX_STATE_ACTIVE) return; - } haveQuota = QuotaOK(service); if ((!haveQuota) || queue_IsEmpty(&rx_idleServerQueue)) { @@ -3950,8 +3935,11 @@ rxi_AttachServerProc(call, socket, tnop, newcallp) * put the call on the incoming call queue (unless it's * already on the queue). */ +#ifdef RX_ENABLE_LOCKS if (haveQuota) ReturnToServerPool(service); +#endif /* RX_ENABLE_LOCKS */ + if (!(call->flags & RX_CALL_WAIT_PROC)) { call->flags |= RX_CALL_WAIT_PROC; MUTEX_ENTER(&rx_stats_mutex); @@ -3962,20 +3950,6 @@ rxi_AttachServerProc(call, socket, tnop, newcallp) queue_Append(&rx_incomingCallQueue, call); } } -#else /* RX_ENABLE_LOCKS */ - if (!QuotaOK(service) || queue_IsEmpty(&rx_idleServerQueue)) { - /* If there are no processes available to service this call, - * put the call on the incoming call queue (unless it's - * already on the queue). - */ - if (!(call->flags & RX_CALL_WAIT_PROC)) { - call->flags |= RX_CALL_WAIT_PROC; - rx_nWaiting++; - rxi_calltrace(RX_CALL_ARRIVAL, call); - queue_Append(&rx_incomingCallQueue, call); - } - } -#endif /* RX_ENABLE_LOCKS */ else { sq = queue_First(&rx_idleServerQueue, rx_serverQueueEntry); @@ -4741,9 +4715,9 @@ static void rxi_SendList(call, list, len, istack, moreFlag, now, retryTime, rese CALL_HOLD(call, RX_CALL_REFCOUNT_SEND); MUTEX_EXIT(&call->lock); if (len > 1) { - rxi_SendPacketList(conn, list, len, istack); + rxi_SendPacketList(call, conn, list, len, istack); } else { - rxi_SendPacket(conn, list[0], istack); + rxi_SendPacket(call, conn, list[0], istack); } MUTEX_ENTER(&call->lock); CALL_RELE(call, RX_CALL_REFCOUNT_SEND); @@ -5200,7 +5174,7 @@ void rxi_Send(call, p, istack) /* Actually send the packet, filling in more connection-specific fields */ CALL_HOLD(call, RX_CALL_REFCOUNT_SEND); MUTEX_EXIT(&call->lock); - rxi_SendPacket(conn, p, istack); + rxi_SendPacket(call, conn, p, istack); MUTEX_ENTER(&call->lock); CALL_RELE(call, RX_CALL_REFCOUNT_SEND); diff --git a/src/rx/rx_packet.c b/src/rx/rx_packet.c index 8c98956ca..3b332ff54 100644 --- a/src/rx/rx_packet.c +++ b/src/rx/rx_packet.c @@ -14,7 +14,7 @@ #include #endif -RCSID("$Header: /tmp/cvstemp/openafs/src/rx/rx_packet.c,v 1.7 2002/09/26 19:18:09 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/rx/rx_packet.c,v 1.8 2003/04/13 19:32:24 hartmans Exp $"); #ifdef KERNEL #if defined(UKERNEL) @@ -1471,14 +1471,15 @@ static void rxi_SendDebugPacket(struct rx_packet *apacket, osi_socket asocket, } /* Send the packet to appropriate destination for the specified - * connection. The header is first encoded and placed in the packet. + * call. The header is first encoded and placed in the packet. */ -void rxi_SendPacket(struct rx_connection * conn, struct rx_packet *p, - int istack) +void rxi_SendPacket(struct rx_call * call, struct rx_connection * conn, + struct rx_packet *p, int istack) { #if defined(KERNEL) int waslocked; #endif + int code; struct sockaddr_in addr; register struct rx_peer *peer = conn->peer; osi_socket socket; @@ -1550,14 +1551,24 @@ void rxi_SendPacket(struct rx_connection * conn, struct rx_packet *p, waslocked = ISAFS_GLOCK(); if (waslocked) AFS_GUNLOCK(); #endif - if (osi_NetSend(socket, &addr, p->wirevec, p->niovecs, - p->length+RX_HEADER_SIZE, istack)){ + if ((code = osi_NetSend(socket, &addr, p->wirevec, p->niovecs, + p->length+RX_HEADER_SIZE, istack)) != 0) { /* send failed, so let's hurry up the resend, eh? */ MUTEX_ENTER(&rx_stats_mutex); rx_stats.netSendFailures++; MUTEX_EXIT(&rx_stats_mutex); p->retryTime = p->timeSent; /* resend it very soon */ clock_Addmsec(&(p->retryTime), 10 + (((afs_uint32) p->backoff) << 8)); + +#if defined(KERNEL) && defined(AFS_LINUX20_ENV) + /* Linux is nice -- it can tell us right away that we cannot + * reach this recipient by returning an ENETUNREACH error + * code. So, when this happens let's "down" the host NOW so + * we don't sit around waiting for this host to timeout later. + */ + if (call && code == -ENETUNREACH) + call->lastReceiveTime = 0; +#endif } #ifdef KERNEL if (waslocked) AFS_GLOCK(); @@ -1582,10 +1593,8 @@ void rxi_SendPacket(struct rx_connection * conn, struct rx_packet *p, /* Send a list of packets to appropriate destination for the specified * connection. The headers are first encoded and placed in the packets. */ -void rxi_SendPacketList(struct rx_connection * conn, - struct rx_packet **list, - int len, - int istack) +void rxi_SendPacketList(struct rx_call * call, struct rx_connection * conn, + struct rx_packet **list, int len, int istack) { #if defined(AFS_SUN5_ENV) && defined(KERNEL) int waslocked; @@ -1595,7 +1604,7 @@ void rxi_SendPacketList(struct rx_connection * conn, osi_socket socket; struct rx_packet *p = NULL; struct iovec wirevec[RX_MAXIOVECS]; - int i, length; + int i, length, code; afs_uint32 serial; afs_uint32 temp; struct rx_jumboHeader *jp; @@ -1715,7 +1724,7 @@ void rxi_SendPacketList(struct rx_connection * conn, waslocked = ISAFS_GLOCK(); if (!istack && waslocked) AFS_GUNLOCK(); #endif - if (osi_NetSend(socket, &addr, &wirevec[0], len+1, length, istack)){ + if ((code = osi_NetSend(socket, &addr, &wirevec[0], len+1, length, istack)) != 0){ /* send failed, so let's hurry up the resend, eh? */ MUTEX_ENTER(&rx_stats_mutex); rx_stats.netSendFailures++; @@ -1725,6 +1734,15 @@ void rxi_SendPacketList(struct rx_connection * conn, p->retryTime = p->timeSent; /* resend it very soon */ clock_Addmsec(&(p->retryTime), 10 + (((afs_uint32) p->backoff) << 8)); } +#if defined(KERNEL) && defined(AFS_LINUX20_ENV) + /* Linux is nice -- it can tell us right away that we cannot + * reach this recipient by returning an ENETUNREACH error + * code. So, when this happens let's "down" the host NOW so + * we don't sit around waiting for this host to timeout later. + */ + if (call && code == -ENETUNREACH) + call->lastReceiveTime = 0; +#endif } #if defined(AFS_SUN5_ENV) && defined(KERNEL) if (!istack && waslocked) AFS_GLOCK(); @@ -1816,7 +1834,7 @@ rxi_SendSpecial(call, conn, optionalPacket, type, data, nbytes, istack) } if (call) rxi_Send(call, p, istack); - else rxi_SendPacket(conn, p, istack); + else rxi_SendPacket((struct rx_call *)0, conn, p, istack); if (saven) { /* means we truncated the packet above. We probably don't */ /* really need to do this, but it seems safer this way, given that */ /* sneaky optionalPacket... */ diff --git a/src/rxkad/ticket5.c b/src/rxkad/ticket5.c index 931477fe8..a48488006 100644 --- a/src/rxkad/ticket5.c +++ b/src/rxkad/ticket5.c @@ -61,7 +61,7 @@ #include #endif -RCSID("$Header: /tmp/cvstemp/openafs/src/rxkad/ticket5.c,v 1.1.1.2 2003/04/13 19:07:35 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/rxkad/ticket5.c,v 1.3 2003/04/13 19:32:24 hartmans Exp $"); #if defined(UKERNEL) #include "../afs/sysincludes.h" diff --git a/src/sys/Makefile.in b/src/sys/Makefile.in index 30f3af868..4082ae845 100644 --- a/src/sys/Makefile.in +++ b/src/sys/Makefile.in @@ -98,7 +98,7 @@ tests: pagsh pagsh.krb fixit iinc idec icreate iopen istat rmtsysd syscall.o: syscall.s case "$(SYS_NAME)" in \ - sun4c_51 | sun4c_52 | sun4m_51 | sun4m_52 | sun4c_53 | sun4m_53 | sun4_53 | sun4_52 | sun4_54 | sun4c_54 | sun4m_54 | sun4x_5? | sunx86_54) \ + sun*_5? ) \ /usr/ccs/lib/cpp ${SFLAGS} syscall.s syscall.ss; \ as -o syscall.o syscall.ss; \ $(RM) syscall.ss;; \ diff --git a/src/sys/rmtsyss.c b/src/sys/rmtsyss.c index 19ad7b25e..ede1a77e7 100644 --- a/src/sys/rmtsyss.c +++ b/src/sys/rmtsyss.c @@ -15,7 +15,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/sys/rmtsyss.c,v 1.2 2003/01/02 03:55:51 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/sys/rmtsyss.c,v 1.3 2003/04/13 19:32:24 hartmans Exp $"); #include #include @@ -27,6 +27,7 @@ RCSID("$Header: /tmp/cvstemp/openafs/src/sys/rmtsyss.c,v 1.2 2003/01/02 03:55:51 #include #include #include +#include #include #ifdef HAVE_STRING_H #include diff --git a/src/util/Makefile.in b/src/util/Makefile.in index 6d4474f6d..6182bc21b 100644 --- a/src/util/Makefile.in +++ b/src/util/Makefile.in @@ -60,6 +60,7 @@ all: ukinstall kinstall \ ${TOP_INCDIR}/afs/pthread_glock.h \ ${TOP_INCDIR}/afs/afs_atomlist.h \ ${TOP_INCDIR}/afs/afs_lhash.h \ + ${TOP_INCDIR}/afs/softsig.h \ ${TOP_INCDIR}/potpourri.h \ ${TOP_LIBDIR}/util.a \ ${TOP_LIBDIR}/libafsutil.a \ @@ -157,6 +158,7 @@ install: \ ${DESTDIR}${includedir}/afs/pthread_glock.h \ ${DESTDIR}${includedir}/afs/afs_atomlist.h \ ${DESTDIR}${includedir}/afs/afs_lhash.h \ + ${DESTDIR}${includedir}/afs/softsig.h \ ${DESTDIR}${includedir}/potpourri.h \ ${DESTDIR}${libdir}/afs/util.a \ ${DESTDIR}${libdir}/afs/libafsutil.a \ @@ -204,6 +206,9 @@ ${TOP_INCDIR}/afs/afs_atomlist.h: afs_atomlist.h ${TOP_INCDIR}/afs/afs_lhash.h: afs_lhash.h ${INSTALL} $? $@ +${TOP_INCDIR}/afs/softsig.h: softsig.h + ${INSTALL} $? $@ + ${TOP_INCDIR}/potpourri.h: potpourri.h ${INSTALL} $? $@ @@ -257,6 +262,9 @@ ${DESTDIR}${includedir}/afs/afs_atomlist.h: afs_atomlist.h ${DESTDIR}${includedir}/afs/afs_lhash.h: afs_lhash.h ${INSTALL} $? $@ +${DESTDIR}${includedir}/afs/softsig.h: softsig.h + ${INSTALL} $? $@ + ${DESTDIR}${includedir}/potpourri.h: potpourri.h ${INSTALL} $? $@ @@ -314,6 +322,9 @@ ${DEST}/include/afs/afs_atomlist.h: afs_atomlist.h ${DEST}/include/afs/afs_lhash.h: afs_lhash.h ${INSTALL} $? $@ +${DEST}/include/afs/softsig.h: softsig.h + ${INSTALL} $? $@ + ${DEST}/include/potpourri.h: potpourri.h ${INSTALL} $? $@ @@ -456,6 +467,7 @@ dest: \ ${DEST}/include/afs/pthread_glock.h \ ${DEST}/include/afs/afs_atomlist.h \ ${DEST}/include/afs/afs_lhash.h \ + ${DEST}/include/afs/softsig.h \ ${DEST}/include/potpourri.h \ ${DEST}/lib/afs/util.a \ ${DEST}/lib/afs/libafsutil.a \ diff --git a/src/venus/fstrace.c b/src/venus/fstrace.c index 1c54b9a6c..38842176e 100644 --- a/src/venus/fstrace.c +++ b/src/venus/fstrace.c @@ -13,7 +13,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/venus/fstrace.c,v 1.7 2002/05/12 05:50:43 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/venus/fstrace.c,v 1.8 2003/04/13 19:32:24 hartmans Exp $"); #include #include @@ -2104,11 +2104,10 @@ long call, parm0, parm1, parm2, parm3, parm4, parm5, parm6; } #if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_SPARC_LINUX20_ENV) /* on sparc this function returns none value, so do it myself */ - __asm__ __volatile__ (" - mov %o0, %i0 - ret - restore -"); + __asm__ __volatile__ ( + "mov %o0, %i0\n\t" + "ret\n\t" + "restore"); #endif #else #if !defined(AFS_SGI_ENV) && !defined(AFS_AIX32_ENV) diff --git a/src/venus/kdump.c b/src/venus/kdump.c index 83c3f3e0c..9f67133a8 100644 --- a/src/venus/kdump.c +++ b/src/venus/kdump.c @@ -10,7 +10,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/venus/kdump.c,v 1.6 2003/01/02 03:55:52 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/venus/kdump.c,v 1.7 2003/04/13 19:32:24 hartmans Exp $"); #include #include @@ -1053,6 +1053,8 @@ kdump() if (Dcells || Dall) { print_cells(1); /* Handle the afs_cells structures */ + print_cellaliases(1); + print_cellnames(1); } if (Dusers || Dall) { @@ -1170,6 +1172,7 @@ kdump() #if !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_ENV) int Sum_cellnames=0, Sum_userstp=0, Sum_volnames=0, Sum_exps=0, Sum_nfssysnames=0; int Sum_vcachemvids=0, Sum_vcachelinkData=0, Sum_vcacheacc=0, Sum_vcachelocks=0; +int Sum_cellaliases=0, Sum_cellname_names=0; int print_cells(pnt) int pnt; @@ -1193,6 +1196,64 @@ int pnt; j++; } if (pnt) printf("... found %d 'afs_cells' entries\n", j); + + return j; +} + +int print_cellaliases(int pnt) +{ + off_t symoff; + struct cell_alias *ca, cae; + long j = 0; + + if (pnt) printf("\n\nPrinting cell_alias list...\n"); + findsym( "afs_cellalias_head", &symoff); + kread(kmem, symoff, (char *) &ca, sizeof ca); + while (ca) { + char alias[100], cell[100]; + + kread(kmem, (off_t) ca, (char *) &cae, sizeof cae); + kread(kmem, (off_t) cae.alias, alias, (KDUMP_SIZE_T)40); + alias[40] = '\0'; + Sum_cellaliases += strlen(alias) + 1; + kread(kmem, (off_t) cae.cell, cell, (KDUMP_SIZE_T)40); + cell[40] = '\0'; + Sum_cellaliases += strlen(cell) + 1; + if (pnt) + printf("%x: alias=%s cell=%s index=%d\n", + ca, alias, cell, cae.index); + ca = cae.next; + j++; + } + if (pnt) printf("... found %d 'cell_alias' entries\n", j); + + return j; +} + +int print_cellnames(int pnt) +{ + off_t symoff; + struct cell_name *cn, cne; + long j = 0; + + if (pnt) printf("\n\nPrinting cell_name list...\n"); + findsym( "afs_cellname_head", &symoff); + kread(kmem, symoff, (char *) &cn, sizeof cn); + while (cn) { + char cellname[100]; + + kread(kmem, (off_t) cn, (char *) &cne, sizeof cne); + kread(kmem, (off_t) cne.cellname, cellname, (KDUMP_SIZE_T)40); + cellname[40] = '\0'; + Sum_cellname_names += strlen(cellname) + 1; + if (pnt) + printf("%x: cellnum=%d cellname=%s used=%d\n", + cn, cne.cellnum, cellname, cne.used); + cn = cne.next; + j++; + } + if (pnt) printf("... found %d 'cell_name' entries\n", j); + return j; } @@ -1761,6 +1822,18 @@ int pnt; T += j; printf("%20s:\t%8d bytes\t[%d cells/%d bytes each + %d bytes for cell names]\n", "Cell package", j, i, sizeof(struct cell), Sum_cellnames); + Sum_cellaliases=0; + i = print_cellaliases(0); + j = (i * sizeof(struct cell_alias)) + Sum_cellaliases; + T += j; + printf("%20s:\t%8d bytes\t[%d cell_aliases/%d bytes each + %d bytes for cell names]\n", "Cell package", j, i, sizeof(struct cell_alias), Sum_cellaliases); + + Sum_cellname_names=0; + i = print_cellnames(0); + j = (i * sizeof(struct cell_name)) + Sum_cellname_names; + T += j; + printf("%20s:\t%8d bytes\t[%d cell_names/%d bytes each + %d bytes for cell name strings]\n", "Cell package", j, i, sizeof(struct cell_name), Sum_cellname_names); + Sum_userstp=0; i = print_users(0); j = (i * sizeof(struct unixuser)) + Sum_userstp; @@ -2268,9 +2341,10 @@ void print_cell(kmem, clep, ptr, pnt) cellName[40] = 0; Sum_cellnames += strlen(cellName)+1; if (pnt) { - printf("%lx: cell=%s, cellname=%s, states=%x, cindex=%d fsport=%d vlport=%d\n", ptr, - PrintIPAddr(clep->cell), cellName, clep->states, clep->cellIndex, - clep->fsport, clep->vlport); + printf("%lx: cellname=%s, states=%x, cnum=%d, cindex=%d fsport=%d vlport=%d timeout=%d cnamep=%x\n", ptr, + cellName, clep->states, clep->cellNum, clep->cellIndex, + clep->fsport, clep->vlport, clep->timeout, clep->cnamep); + #ifdef AFS33 if (clep->lcellp) printf("\tlinked cellp %lx\n", clep->lcellp); diff --git a/src/viced/afsfileprocs.c b/src/viced/afsfileprocs.c index 1e7de7f03..78e3594ab 100644 --- a/src/viced/afsfileprocs.c +++ b/src/viced/afsfileprocs.c @@ -28,7 +28,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/viced/afsfileprocs.c,v 1.11 2002/12/11 03:00:40 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/viced/afsfileprocs.c,v 1.12 2003/04/13 19:32:25 hartmans Exp $"); #include #include @@ -266,13 +266,14 @@ static SetVolumeSync(async, avol) static CallPreamble(acall, activecall) register struct rx_call **acall; int activecall; - { struct host *thost; struct rx_connection *tconn; struct client *tclient; int retry_flag=1; int code = 0; + char hoststr[16]; + tconn = rx_ConnectionOf(*acall); *acall = (struct rx_call *)tconn; /* change it! */ @@ -320,11 +321,13 @@ retry: ViceLog(0,("BreakDelayedCallbacks FAILED for host %08x which IS UP. Possible network or routing failure.\n",thost->host)); if ( MultiProbeAlternateAddress_r (thost) ) { ViceLog(0, ("MultiProbe failed to find new address for host %x.%d\n", - thost->host, thost->port)); - code = -1; + afs_inet_ntoa_r(thost->host, hoststr), + ntohs(thost->port))); + code = -1; } else { - ViceLog(0, ("MultiProbe found new address for host %x.%d\n", - thost->host, thost->port)); + ViceLog(0, ("MultiProbe found new address for host %s:%d\n", + afs_inet_ntoa_r(thost->host, hoststr), + ntohs(thost->port))); if (BreakDelayedCallBacks_r(thost)) { ViceLog(0,("BreakDelayedCallbacks FAILED AGAIN for host %08x which IS UP. Possible network or routing failure.\n",thost->host)); code = -1; @@ -6143,13 +6146,13 @@ CheckVnode(fid, volptr, vptr, lock) /* I'm not really worried about when we restarted, I'm */ /* just worried about when the first VBUSY was returned. */ TM_GetTimeOfDay(&restartedat, 0); - return(VBUSY); + return(busyonrst?VBUSY:VRESTARTING); } else { struct timeval now; TM_GetTimeOfDay(&now, 0); if ((now.tv_sec - restartedat.tv_sec) < (11*60)) { - return(VBUSY); + return(busyonrst?VBUSY:VRESTARTING); } else { return (VRESTARTING); -- 2.39.5