Re: [RFC] preliminary patch for files struct

Bill Hawes (whawes@star.net)
Fri, 30 Jan 1998 13:36:38 -0500


Linus Torvalds wrote:

> What was the problem? The locks should be removed when the last fput(file)
> happens - if that doesn't work then _that_ is the bug rather than any
> interface issues..

Hi Linus,

The problem with locks is that the check is made in close_fp() before calling
fput(). Some of the lock cleanup depends on which task is calling the function,
so you want the call to be last close for the task. But since the fput()
function is just concerned with decrementing the f_count, I thought it would be
better to have a separate wrapper. By passing both the fd and file arguments to
fd_put I can tell whether it's the last close for the task and act
appropriately.

The current fd_get is just an fget(), but if we want to provide for dynamic
expansion of the fd array, we'll need to add some locking, so again I thought it
better to have a wrapper. Also, as much of the fd-related processing is limited
to one task context, it might be possible to drop the kernel lock for some of
the system calls and use a per-task spinlock instead.

Regards,
Bill