Commit e518ddb7ba44a3d852c0e41961365844c76eb2bf
Committed by
Linus Torvalds
1 parent
c16a02d6f5
Exists in
master
and in
4 other branches
[PATCH] fs/namei.c: replace multiple current->fs by shortcut variable
Replace current->fs by fs helper variable to reduce some indirection overhead and (at least at the moment, before the current_thread_info() %gs PDA improvement is available) get rid of more costly current references. Reduces fs/namei.o from 37786 to 37082 Bytes (704 Bytes saved). [akpm@osdl.org: cleanup] Signed-off-by: Andreas Mohr <andi@lisas.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 1 changed file with 47 additions and 39 deletions Side-by-side Diff
fs/namei.c
... | ... | @@ -518,18 +518,20 @@ |
518 | 518 | static __always_inline int |
519 | 519 | walk_init_root(const char *name, struct nameidata *nd) |
520 | 520 | { |
521 | - read_lock(¤t->fs->lock); | |
522 | - if (current->fs->altroot && !(nd->flags & LOOKUP_NOALT)) { | |
523 | - nd->mnt = mntget(current->fs->altrootmnt); | |
524 | - nd->dentry = dget(current->fs->altroot); | |
525 | - read_unlock(¤t->fs->lock); | |
521 | + struct fs_struct *fs = current->fs; | |
522 | + | |
523 | + read_lock(&fs->lock); | |
524 | + if (fs->altroot && !(nd->flags & LOOKUP_NOALT)) { | |
525 | + nd->mnt = mntget(fs->altrootmnt); | |
526 | + nd->dentry = dget(fs->altroot); | |
527 | + read_unlock(&fs->lock); | |
526 | 528 | if (__emul_lookup_dentry(name,nd)) |
527 | 529 | return 0; |
528 | - read_lock(¤t->fs->lock); | |
530 | + read_lock(&fs->lock); | |
529 | 531 | } |
530 | - nd->mnt = mntget(current->fs->rootmnt); | |
531 | - nd->dentry = dget(current->fs->root); | |
532 | - read_unlock(¤t->fs->lock); | |
532 | + nd->mnt = mntget(fs->rootmnt); | |
533 | + nd->dentry = dget(fs->root); | |
534 | + read_unlock(&fs->lock); | |
533 | 535 | return 1; |
534 | 536 | } |
535 | 537 | |
536 | 538 | |
537 | 539 | |
... | ... | @@ -724,17 +726,19 @@ |
724 | 726 | |
725 | 727 | static __always_inline void follow_dotdot(struct nameidata *nd) |
726 | 728 | { |
729 | + struct fs_struct *fs = current->fs; | |
730 | + | |
727 | 731 | while(1) { |
728 | 732 | struct vfsmount *parent; |
729 | 733 | struct dentry *old = nd->dentry; |
730 | 734 | |
731 | - read_lock(¤t->fs->lock); | |
732 | - if (nd->dentry == current->fs->root && | |
733 | - nd->mnt == current->fs->rootmnt) { | |
734 | - read_unlock(¤t->fs->lock); | |
735 | + read_lock(&fs->lock); | |
736 | + if (nd->dentry == fs->root && | |
737 | + nd->mnt == fs->rootmnt) { | |
738 | + read_unlock(&fs->lock); | |
735 | 739 | break; |
736 | 740 | } |
737 | - read_unlock(¤t->fs->lock); | |
741 | + read_unlock(&fs->lock); | |
738 | 742 | spin_lock(&dcache_lock); |
739 | 743 | if (nd->dentry != nd->mnt->mnt_root) { |
740 | 744 | nd->dentry = dget(nd->dentry->d_parent); |
741 | 745 | |
742 | 746 | |
... | ... | @@ -1042,15 +1046,17 @@ |
1042 | 1046 | struct vfsmount *old_mnt = nd->mnt; |
1043 | 1047 | struct qstr last = nd->last; |
1044 | 1048 | int last_type = nd->last_type; |
1049 | + struct fs_struct *fs = current->fs; | |
1050 | + | |
1045 | 1051 | /* |
1046 | - * NAME was not found in alternate root or it's a directory. Try to find | |
1047 | - * it in the normal root: | |
1052 | + * NAME was not found in alternate root or it's a directory. | |
1053 | + * Try to find it in the normal root: | |
1048 | 1054 | */ |
1049 | 1055 | nd->last_type = LAST_ROOT; |
1050 | - read_lock(¤t->fs->lock); | |
1051 | - nd->mnt = mntget(current->fs->rootmnt); | |
1052 | - nd->dentry = dget(current->fs->root); | |
1053 | - read_unlock(¤t->fs->lock); | |
1056 | + read_lock(&fs->lock); | |
1057 | + nd->mnt = mntget(fs->rootmnt); | |
1058 | + nd->dentry = dget(fs->root); | |
1059 | + read_unlock(&fs->lock); | |
1054 | 1060 | if (path_walk(name, nd) == 0) { |
1055 | 1061 | if (nd->dentry->d_inode) { |
1056 | 1062 | dput(old_dentry); |
... | ... | @@ -1074,6 +1080,7 @@ |
1074 | 1080 | struct vfsmount *mnt = NULL, *oldmnt; |
1075 | 1081 | struct dentry *dentry = NULL, *olddentry; |
1076 | 1082 | int err; |
1083 | + struct fs_struct *fs = current->fs; | |
1077 | 1084 | |
1078 | 1085 | if (!emul) |
1079 | 1086 | goto set_it; |
... | ... | @@ -1083,12 +1090,12 @@ |
1083 | 1090 | dentry = nd.dentry; |
1084 | 1091 | } |
1085 | 1092 | set_it: |
1086 | - write_lock(¤t->fs->lock); | |
1087 | - oldmnt = current->fs->altrootmnt; | |
1088 | - olddentry = current->fs->altroot; | |
1089 | - current->fs->altrootmnt = mnt; | |
1090 | - current->fs->altroot = dentry; | |
1091 | - write_unlock(¤t->fs->lock); | |
1093 | + write_lock(&fs->lock); | |
1094 | + oldmnt = fs->altrootmnt; | |
1095 | + olddentry = fs->altroot; | |
1096 | + fs->altrootmnt = mnt; | |
1097 | + fs->altroot = dentry; | |
1098 | + write_unlock(&fs->lock); | |
1092 | 1099 | if (olddentry) { |
1093 | 1100 | dput(olddentry); |
1094 | 1101 | mntput(oldmnt); |
1095 | 1102 | |
1096 | 1103 | |
1097 | 1104 | |
1098 | 1105 | |
... | ... | @@ -1102,29 +1109,30 @@ |
1102 | 1109 | int retval = 0; |
1103 | 1110 | int fput_needed; |
1104 | 1111 | struct file *file; |
1112 | + struct fs_struct *fs = current->fs; | |
1105 | 1113 | |
1106 | 1114 | nd->last_type = LAST_ROOT; /* if there are only slashes... */ |
1107 | 1115 | nd->flags = flags; |
1108 | 1116 | nd->depth = 0; |
1109 | 1117 | |
1110 | 1118 | if (*name=='/') { |
1111 | - read_lock(¤t->fs->lock); | |
1112 | - if (current->fs->altroot && !(nd->flags & LOOKUP_NOALT)) { | |
1113 | - nd->mnt = mntget(current->fs->altrootmnt); | |
1114 | - nd->dentry = dget(current->fs->altroot); | |
1115 | - read_unlock(¤t->fs->lock); | |
1119 | + read_lock(&fs->lock); | |
1120 | + if (fs->altroot && !(nd->flags & LOOKUP_NOALT)) { | |
1121 | + nd->mnt = mntget(fs->altrootmnt); | |
1122 | + nd->dentry = dget(fs->altroot); | |
1123 | + read_unlock(&fs->lock); | |
1116 | 1124 | if (__emul_lookup_dentry(name,nd)) |
1117 | 1125 | goto out; /* found in altroot */ |
1118 | - read_lock(¤t->fs->lock); | |
1126 | + read_lock(&fs->lock); | |
1119 | 1127 | } |
1120 | - nd->mnt = mntget(current->fs->rootmnt); | |
1121 | - nd->dentry = dget(current->fs->root); | |
1122 | - read_unlock(¤t->fs->lock); | |
1128 | + nd->mnt = mntget(fs->rootmnt); | |
1129 | + nd->dentry = dget(fs->root); | |
1130 | + read_unlock(&fs->lock); | |
1123 | 1131 | } else if (dfd == AT_FDCWD) { |
1124 | - read_lock(¤t->fs->lock); | |
1125 | - nd->mnt = mntget(current->fs->pwdmnt); | |
1126 | - nd->dentry = dget(current->fs->pwd); | |
1127 | - read_unlock(¤t->fs->lock); | |
1132 | + read_lock(&fs->lock); | |
1133 | + nd->mnt = mntget(fs->pwdmnt); | |
1134 | + nd->dentry = dget(fs->pwd); | |
1135 | + read_unlock(&fs->lock); | |
1128 | 1136 | } else { |
1129 | 1137 | struct dentry *dentry; |
1130 | 1138 |