[OpenAFS] tasklist_lock undefined Linux 2.6.18, OpenAFS 1.4.2

Peter N. Schweitzer pschweitzer@usgs.gov
Mon, 30 Oct 2006 10:46:02 -0500

Jeffrey Hutzelman wrote:
> On Friday, October 27, 2006 03:53:23 PM -0400 "Peter N. Schweitzer" 
> <pschweitzer@usgs.gov> wrote:
>> #  nm afs_osi.o | grep tasklist_lock
>>          U tasklist_lock
> OK; this is the one we're looking for.  That, combined with Stefaan's 
> comment about not having the problem if keyring support is enabled, 
> makes me think the compiler is doing something bogus here, like not 
> correctly handling the 'weak' attribute on an extern symbol not declared 
> in global scope.
> Try the following patch:
> --- src/afs/afs_osi.c.orig    2006-10-27 18:45:35.000000000 -0400
> +++ src/afs/afs_osi.c    2006-10-27 18:45:43.000000000 -0400
> @@ -805,11 +805,11 @@
> #endif
> #if defined(AFS_LINUX22_ENV)
> +extern rwlock_t tasklist_lock __attribute__((weak));
> void
> afs_osi_TraverseProcTable()
> {
> -    extern rwlock_t tasklist_lock __attribute__((weak));
>     struct task_struct *p;
>     if (&tasklist_lock)


That did the trick.  The symbol is no longer unresolved, the kernel
module loads without complaint, and the AFS client software (which is
the only part I use) seems to work fine.

Thanks very much for your help!

>> I'm still thinking there's some kernel feature that I should have enabled
>> but didn't know I needed.
> No; the symbol really isn't exported in recent kernels; this is not 
> about kernel configuration.

Not to belabor the point, but for my understanding, the tasklist_lock 
variable within the AFS module and the variable by the same name within
some parts of the kernel code (sched.c, for example) are not related,
it's just a different use of the same name, maybe for the same sort of
thing.  Hence it was only necessary to persuade the compiler to actually
allocate space for the symbol within the AFS module's data section
rather than assume that the symbol would be instantiated elsewhere?

Peter N. Schweitzer (MS 954, U.S. Geological Survey, Reston, VA 20192)
(703) 648-6533  FAX: (703) 648-6252  email: pschweitzer@usgs.gov