Commit dd37978c50bc8b354e5c4633f69387f16572fdac

Authored by Al Viro
1 parent 5e608671df

cache the value of file_inode() in struct file

Note that this thing does *not* contribute to inode refcount;
it's pinned down by dentry.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Showing 3 changed files with 6 additions and 2 deletions Side-by-side Diff

... ... @@ -176,6 +176,7 @@
176 176 return file;
177 177  
178 178 file->f_path = *path;
  179 + file->f_inode = path->dentry->d_inode;
179 180 file->f_mapping = path->dentry->d_inode->i_mapping;
180 181 file->f_mode = mode;
181 182 file->f_op = fop;
... ... @@ -258,6 +259,7 @@
258 259 drop_file_write_access(file);
259 260 file->f_path.dentry = NULL;
260 261 file->f_path.mnt = NULL;
  262 + file->f_inode = NULL;
261 263 file_free(file);
262 264 dput(dentry);
263 265 mntput(mnt);
... ... @@ -689,7 +689,7 @@
689 689 f->f_mode = FMODE_PATH;
690 690  
691 691 path_get(&f->f_path);
692   - inode = file_inode(f);
  692 + inode = f->f_inode = f->f_path.dentry->d_inode;
693 693 if (f->f_mode & FMODE_WRITE) {
694 694 error = __get_file_write_access(inode, f->f_path.mnt);
695 695 if (error)
... ... @@ -752,6 +752,7 @@
752 752 path_put(&f->f_path);
753 753 f->f_path.mnt = NULL;
754 754 f->f_path.dentry = NULL;
  755 + f->f_inode = NULL;
755 756 return error;
756 757 }
757 758  
... ... @@ -769,6 +769,7 @@
769 769 } f_u;
770 770 struct path f_path;
771 771 #define f_dentry f_path.dentry
  772 + struct inode *f_inode; /* cached value */
772 773 const struct file_operations *f_op;
773 774  
774 775 /*
... ... @@ -2217,7 +2218,7 @@
2217 2218  
2218 2219 static inline struct inode *file_inode(struct file *f)
2219 2220 {
2220   - return f->f_path.dentry->d_inode;
  2221 + return f->f_inode;
2221 2222 }
2222 2223  
2223 2224 /*