Re: Directory semaphore

Benjamin C.R. LaHaise (
Mon, 4 May 1998 15:52:08 -0400 (EDT)

On Mon, 4 May 1998, Richard Gooch wrote:

> Hi, all. I have an inode lookup method that can potentially block
> for a considerable period of time. I've been looking at real_lookup()
> and noticed that it grabs the directory semaphore before calling the
> lookup() method. What I'd like to do is release the semaphore just
> before I block, then grab it again when control returns back.
> I have two questions. Firstly, is this a safe thing to do?
> Secondly, to help me understand, is the directory semaphore rellay
> there to protect the directory inode, or it's dentry?

It's safe under certain conditions... eg a read only filesystem.
Remember, the directory semaphore is there to protect the *contents* of
the directory and make operations like open w/O_EXCL, rename and such
atomic. In 2.3 we should add a blocking version of the SMP reader-writer
to replace this (the mm semaphore comes to mind as being a candidate

Hmmm, is the case you're encountering the auto-loading of modules via


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to