projects/linux·commit 26cf46be

vfs: micro-optimize acl_permission_check()

26cf46be · Linus Torvalds <[email protected]> · 2011-05-13 11:51:01 -07:00

It's a hot function, and we're better off not mixing types in the mask
calculations.  The compiler just ends up mixing 16-bit and 32-bit
operations, for no good reason.

So do everything in 'unsigned int' rather than mixing 'unsigned int'
masking with a 'umode_t' (16-bit) mode variable.

This, together with the parent commit (47a150edc2ae: "Cache user_ns in
struct cred") makes acl_permission_check() much nicer.

Signed-off-by: Linus Torvalds <[email protected]>
Commit
26cf46be954a2dd391d32eeaf7d07c3a953dcc5a
Parents
47a150ed

Changes

1 files changed · +1 −1

FileStatusAddDelContent
fs/namei.cmodified+1−1View file

fs/namei.c

View file
diff --git a/fs/namei.c b/fs/namei.c
index 54fc993..e3c4f11 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -179,7 +179,7 @@ EXPORT_SYMBOL(putname);
static int acl_permission_check(struct inode *inode, int mask, unsigned int flags,
int (*check_acl)(struct inode *inode, int mask, unsigned int flags))
{
- umode_t mode = inode->i_mode;
+ unsigned int mode = inode->i_mode;
mask &= MAY_READ | MAY_WRITE | MAY_EXEC;