vfs: embed struct filename inside of names_cache allocation if possible

In the common case where a name is much smaller than PATH_MAX, an extra
allocation for struct filename is unnecessary. Before allocating a
separate one, try to embed the struct filename inside the buffer first. If
it turns out that that's not long enough, then fall back to allocating a
separate struct filename and redoing the copy.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Jeff Layton
2012-10-10 16:43:13 -04:00
committed by Al Viro
parent adb5c2473d
commit 7950e3852a
2 changed files with 50 additions and 20 deletions

View File

@@ -2201,6 +2201,7 @@ struct filename {
const char *name; /* pointer to actual string */
const __user char *uptr; /* original userland pointer */
struct audit_names *aname;
bool separate; /* should "name" be freed? */
};
extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,