[PATCH 0/2] slightly cheaper file lookups + an idea

Mateusz Guzik mjguzik at gmail.com
Mon Jul 6 03:07:20 UTC 2015


From: Mateusz Guzik <mjg at freebsd.org>

First, 2 simple patches which imho should go in regardless of whether
the idea below is accepted.

The first one shuffles code around to make the second one easier, which
removes a requirement to hold filedesc lock imposed by auditing.

With that out of the way:

filedesc lock is held so that fd_cdir and fd_rdir vnodes can be obtained
for lookup purposes. In effect namei unnecessarily competes with code
manipulating file descriptor table.

With patches mentioned here at the very least we can decompose the
filedesc lock into 2: one to protect fd_ cdir/jdir/rdir and the other
one for the rest.

However, I believe we should got a step further and split struct
filedesc instead. Specifically, we can move aforementioned vnodes to a
copy-on-write structure managed similarly to thread credentials.

After such an action there is no lock to take during lookups. Further,
since vnodes are guaranteed to be stable we don't have to vref+vrele any
of them, apart from the case where the vnode in question is going to be
returned.

This will make chdir more expensive, but file lookups are way more
frequent so it should be worth it.

Thoughts?

Mateusz Guzik (2):
  vfs: avoid spurious vref+vrele for absolute lookups
  audit: utilize vnode pointer found by namei instead of looking it up
    again

 sys/kern/vfs_lookup.c               | 129 ++++++++++++++++++++----------------
 sys/security/audit/audit.h          |  14 ++++
 sys/security/audit/audit_arg.c      |  36 ++++++++++
 sys/security/audit/audit_bsm_klib.c |  82 +++++++++++++++--------
 sys/security/audit/audit_private.h  |   2 +
 5 files changed, 178 insertions(+), 85 deletions(-)

-- 
2.4.5



More information about the freebsd-fs mailing list