VFS: Put a small type field into struct dentry::d_flags
[firefly-linux-kernel-4.4.55.git] / fs / open.c
index d420331ca32a20b20b00c1da468a9af516e6a037..fffbed40dbe9e24dc6129878cf65527e241d4d48 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -685,7 +685,6 @@ static int do_dentry_open(struct file *f,
        }
 
        f->f_mapping = inode->i_mapping;
-       file_sb_list_add(f, inode->i_sb);
 
        if (unlikely(f->f_mode & FMODE_PATH)) {
                f->f_op = &empty_fops;
@@ -693,6 +692,10 @@ static int do_dentry_open(struct file *f,
        }
 
        f->f_op = fops_get(inode->i_fop);
+       if (unlikely(WARN_ON(!f->f_op))) {
+               error = -ENODEV;
+               goto cleanup_all;
+       }
 
        error = security_file_open(f, cred);
        if (error)
@@ -702,7 +705,7 @@ static int do_dentry_open(struct file *f,
        if (error)
                goto cleanup_all;
 
-       if (!open && f->f_op)
+       if (!open)
                open = f->f_op->open;
        if (open) {
                error = open(inode, f);
@@ -720,7 +723,6 @@ static int do_dentry_open(struct file *f,
 
 cleanup_all:
        fops_put(f->f_op);
-       file_sb_list_del(f);
        if (f->f_mode & FMODE_WRITE) {
                put_write_access(inode);
                if (!special_file(inode->i_mode)) {
@@ -1023,7 +1025,7 @@ int filp_close(struct file *filp, fl_owner_t id)
                return 0;
        }
 
-       if (filp->f_op && filp->f_op->flush)
+       if (filp->f_op->flush)
                retval = filp->f_op->flush(filp, id);
 
        if (likely(!(filp->f_mode & FMODE_PATH))) {