Re: namei() query

From: Jonathan Case Nicklin (nicklin@missioncriticallinux.com)
Date: Tue Apr 18 2000 - 09:06:05 EST


kumon@flab.fujitsu.co.jp wrote:

> I saw most usage of namei() codes are guarded by kernel_lock().
> For example sys_newstat(), sys_stat() ,,,
> Isn't it necessary to guard?
>
> And also I don't understand why these functions need such a giant
> kernel lock.
>
> David S. Miller writes:
> > This would work:
> >
> > mm_segment_t orig_fs;
> >
> > orig_fs = get_fs();
> > set_fs(KERNEL_DS);
> > err = namei("/tmp");
> > set_fs(old_fs);
> >
> > The namei function expects user space pointers, you're sending
> > it a kernel pointer, so you have to adjust your mm segment during
> > the call.
>
> ---
> Computer Systems Laboratory, Fujitsu Labs.
> kumon@flab.fujitsu.co.jp
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.rutgers.edu
> Please read the FAQ at http://www.tux.org/lkml/

Yes, it is necessary to have namei gaurded by the big kernel lock. namei will
call lookup_dentry which can walk lists of dentries. This list access needs
to be guarded by the kernel lock to prevent path/hash entries from slipping
out from under you. In this case the mutual exclusion between the dcache
updates/ modifications and the a dcache accesses via namei is provided by the
kernel lock.

Jonathan Nicklin
http://www.missioncriticallinux.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Apr 23 2000 - 21:00:13 EST