aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-03-01 19:48:30 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2013-03-01 19:48:30 -0500
commitdd37978c50bc8b354e5c4633f69387f16572fdac (patch)
treed233c7027f26869485f96556cc9cddacbb3a8f2d
parent5e608671dfbfd6a9556c31df65a4f147439eed59 (diff)
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>
-rw-r--r--fs/file_table.c2
-rw-r--r--fs/open.c3
-rw-r--r--include/linux/fs.h3
3 files changed, 6 insertions, 2 deletions
diff --git a/fs/file_table.c b/fs/file_table.c
index aa07d3684a2e..cd4d87a82951 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -176,6 +176,7 @@ struct file *alloc_file(struct path *path, fmode_t mode,
176 return file; 176 return file;
177 177
178 file->f_path = *path; 178 file->f_path = *path;
179 file->f_inode = path->dentry->d_inode;
179 file->f_mapping = path->dentry->d_inode->i_mapping; 180 file->f_mapping = path->dentry->d_inode->i_mapping;
180 file->f_mode = mode; 181 file->f_mode = mode;
181 file->f_op = fop; 182 file->f_op = fop;
@@ -258,6 +259,7 @@ static void __fput(struct file *file)
258 drop_file_write_access(file); 259 drop_file_write_access(file);
259 file->f_path.dentry = NULL; 260 file->f_path.dentry = NULL;
260 file->f_path.mnt = NULL; 261 file->f_path.mnt = NULL;
262 file->f_inode = NULL;
261 file_free(file); 263 file_free(file);
262 dput(dentry); 264 dput(dentry);
263 mntput(mnt); 265 mntput(mnt);
diff --git a/fs/open.c b/fs/open.c
index 62f907e3bc36..806d4589559f 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -689,7 +689,7 @@ static int do_dentry_open(struct file *f,
689 f->f_mode = FMODE_PATH; 689 f->f_mode = FMODE_PATH;
690 690
691 path_get(&f->f_path); 691 path_get(&f->f_path);
692 inode = file_inode(f); 692 inode = f->f_inode = f->f_path.dentry->d_inode;
693 if (f->f_mode & FMODE_WRITE) { 693 if (f->f_mode & FMODE_WRITE) {
694 error = __get_file_write_access(inode, f->f_path.mnt); 694 error = __get_file_write_access(inode, f->f_path.mnt);
695 if (error) 695 if (error)
@@ -752,6 +752,7 @@ cleanup_file:
752 path_put(&f->f_path); 752 path_put(&f->f_path);
753 f->f_path.mnt = NULL; 753 f->f_path.mnt = NULL;
754 f->f_path.dentry = NULL; 754 f->f_path.dentry = NULL;
755 f->f_inode = NULL;
755 return error; 756 return error;
756} 757}
757 758
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 4e686a099465..74a907b8b950 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -769,6 +769,7 @@ struct file {
769 } f_u; 769 } f_u;
770 struct path f_path; 770 struct path f_path;
771#define f_dentry f_path.dentry 771#define f_dentry f_path.dentry
772 struct inode *f_inode; /* cached value */
772 const struct file_operations *f_op; 773 const struct file_operations *f_op;
773 774
774 /* 775 /*
@@ -2217,7 +2218,7 @@ static inline bool execute_ok(struct inode *inode)
2217 2218
2218static inline struct inode *file_inode(struct file *f) 2219static 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/*