[RFC 00/10] Split up struct nameidata (take 3)

Andreas Gruenbacher
2007-08-08T17:19:44Z

In several places where no nameidata object is available, we are
currently passing NULL instead of constructing a temporary nameidata
object. This is because struct nameidata is big, and constructing
temporary nameidata objects is not efficient. Here is another shot at
splitting up struct nameidata: struct vfs_lookup is similar to struct
nameidata but leaves out the fields required only while walking an
actual pathname. It fits in 24 bytes as opposed to 80 on x86.

This allows to construct temporary vfs_lookup objects where needed
instead of the NULL passing, which gets rid of the associated NULL
checking, and ensures that struct vfsmnt and the lookup intent are
passed down consistently.

In addition, the dentry and vfsmnt in struct vfs_lookup (before: struct
nameidata) are put inside a struct path. This allows to use
path{get,put} instead of mnt{get,put} plus d{get,put}, resulting in more
consistent code. The path{get,put} functions seemingly were suggested by
Erez Zadok / Josef 'Jeff' Sipek; Jan Blunck has been working on this
recently as well.

This proposal consists of the following patches:

nameidata-split.diff

Introduce struct vfs_lookup and change struct nameidata to
embed a struct vfs_lookup. (Requires the next patch to build.)

nameidata-split-2.diff

Update all nameidata users.

permission-args.diff

Switch from struct nameidata to struct vfs_lookup in the
permission inode operation and related functions.

file_permission.diff

Create a temporary vfs_lookup object in file_permission().

sys_fchdir.diff
do_path_lookup.diff

Use vfs_permission() instead of file_permission().

create-args.diff

Switch from struct nameidata to struct vfs_lookup in the
create inode operation and related functions.

vfs_create-nameidata.diff

Fix all users of vfs_create() to never pass it a NULL
vfs_lookup. Get rid of the NULL checks.

d_revalidate-args.diff

Switch from struct nameidata to struct vfs_lookup in the
d_revalidate dentry operation and related functions.

lookup-args.diff

Switch from struct nameidata to struct vfs_lookup in the
lookup inode operation and related functions.

Ultimately, it would be nice to get rid of all the NULL nameidata /
vfs_lookup passing, particularly to the permission inode operation. At
that point, permission() could be replaced entirely by vfs_permission().
Other vfs functions like vfs_create() can be cleaned up in a similar
way.

Andreas