diff options
Diffstat (limited to 'fs/file_table.c')
-rw-r--r-- | fs/file_table.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/fs/file_table.c b/fs/file_table.c index 71efc7000226..7a0a9b872251 100644 --- a/fs/file_table.c +++ b/fs/file_table.c | |||
@@ -42,6 +42,7 @@ static inline void file_free_rcu(struct rcu_head *head) | |||
42 | static inline void file_free(struct file *f) | 42 | static inline void file_free(struct file *f) |
43 | { | 43 | { |
44 | percpu_counter_dec(&nr_files); | 44 | percpu_counter_dec(&nr_files); |
45 | file_check_state(f); | ||
45 | call_rcu(&f->f_u.fu_rcuhead, file_free_rcu); | 46 | call_rcu(&f->f_u.fu_rcuhead, file_free_rcu); |
46 | } | 47 | } |
47 | 48 | ||
@@ -207,6 +208,7 @@ int init_file(struct file *file, struct vfsmount *mnt, struct dentry *dentry, | |||
207 | * that we can do debugging checks at __fput() | 208 | * that we can do debugging checks at __fput() |
208 | */ | 209 | */ |
209 | if ((mode & FMODE_WRITE) && !special_file(dentry->d_inode->i_mode)) { | 210 | if ((mode & FMODE_WRITE) && !special_file(dentry->d_inode->i_mode)) { |
211 | file_take_write(file); | ||
210 | error = mnt_want_write(mnt); | 212 | error = mnt_want_write(mnt); |
211 | WARN_ON(error); | 213 | WARN_ON(error); |
212 | } | 214 | } |
@@ -237,8 +239,13 @@ void drop_file_write_access(struct file *file) | |||
237 | struct inode *inode = dentry->d_inode; | 239 | struct inode *inode = dentry->d_inode; |
238 | 240 | ||
239 | put_write_access(inode); | 241 | put_write_access(inode); |
240 | if (!special_file(inode->i_mode)) | 242 | |
241 | mnt_drop_write(mnt); | 243 | if (special_file(inode->i_mode)) |
244 | return; | ||
245 | if (file_check_writeable(file) != 0) | ||
246 | return; | ||
247 | mnt_drop_write(mnt); | ||
248 | file_release_write(file); | ||
242 | } | 249 | } |
243 | EXPORT_SYMBOL_GPL(drop_file_write_access); | 250 | EXPORT_SYMBOL_GPL(drop_file_write_access); |
244 | 251 | ||