tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

File handling changes



I have some changes to file descriptor handling:

- A few stylistic changes: KNF, remove unused casts now that caddr_t is
  gone. Replace dumb gotos with loop control in a few places.

- Don't do redundant pointer passing (struct proc, lwp, filedesc *)
  unless the routine is likely to be inlined. 99% of the time it's about
  the current process.

- Redo reference counting to be sane. Right now it looks like the product of
  ~30 years worth of incremental changes. With the patch, LWPs accessing
  files take a short term reference on the local file descriptor. This is
  the most common case. While a file is in a process descriptor table, a
  reference is held to the file. The file reference count only changes
  during control operations like open() or close(). Code that comes at files
  from an unusual direction (i.e. foreign to the process) like procfs or
  sysctl takes a reference on the file (f_count), and not on a descriptor.

- Remove knowledge of refrence counting and locking from most code that
  deals with files. With the changes most file users look something like
  this:

        file_t *fp;
        if ((fp = fd_getfile(fd)) == NULL)
                return EBADF;
        (*fp->f_ops->f_foo)(...);
        fd_putfile(fd);
        return 0;

http://www.netbsd.org/~ad/fd1.diff
http://www.netbsd.org/~ad/fd2.diff

There are still problems with the patched code, which I am working on it at
the moment. Comments?

Thanks,
Andrew


Home | Main Index | Thread Index | Old Index