support make_ext4fs
[firefly-linux-kernel-4.4.55.git] / fs / file_table.c
index 334ce39881f8fea36897196a262f4164cccde1f8..464248f25f4b6d747f985dcccdef6821f35122cf 100644 (file)
@@ -74,14 +74,14 @@ EXPORT_SYMBOL_GPL(get_max_files);
  * Handle nr_files sysctl
  */
 #if defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS)
-int proc_nr_files(ctl_table *table, int write, struct file *filp,
+int proc_nr_files(ctl_table *table, int write,
                      void __user *buffer, size_t *lenp, loff_t *ppos)
 {
        files_stat.nr_files = get_nr_files();
-       return proc_dointvec(table, write, filp, buffer, lenp, ppos);
+       return proc_dointvec(table, write, buffer, lenp, ppos);
 }
 #else
-int proc_nr_files(ctl_table *table, int write, struct file *filp,
+int proc_nr_files(ctl_table *table, int write,
                      void __user *buffer, size_t *lenp, loff_t *ppos)
 {
        return -ENOSYS;
@@ -121,13 +121,13 @@ struct file *get_empty_filp(void)
                goto fail;
 
        percpu_counter_inc(&nr_files);
+       f->f_cred = get_cred(cred);
        if (security_file_alloc(f))
                goto fail_sec;
 
        INIT_LIST_HEAD(&f->f_u.fu_list);
        atomic_long_set(&f->f_count, 1);
        rwlock_init(&f->f_owner.lock);
-       f->f_cred = get_cred(cred);
        spin_lock_init(&f->f_lock);
        eventpoll_init_file(f);
        /* f->f_version: 0 */
@@ -420,7 +420,9 @@ retry:
                        continue;
                if (!(f->f_mode & FMODE_WRITE))
                        continue;
+               spin_lock(&f->f_lock);
                f->f_mode &= ~FMODE_WRITE;
+               spin_unlock(&f->f_lock);
                if (file_check_writeable(f) != 0)
                        continue;
                file_release_write(f);