Whamcloud - gitweb
LU-506 dcache: check lookup_instantiate_filp() return value
[fs/lustre-release.git] / lustre / llite / namei.c
index 64bbd87..d5c9fbe 100644 (file)
@@ -669,25 +669,17 @@ static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry,
                                                        (struct ptlrpc_request *)
                                                           it->d.lustre.it_data);
                                 } else {
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17))
-/* 2.6.1[456] have a bug in open_namei() that forgets to check
- * nd->intent.open.file for error, so we need to return it as lookup's result
- * instead */
-                                        struct file *filp;
-                                        nd->intent.open.file->private_data = it;
-                                        filp =lookup_instantiate_filp(nd,dentry,
-                                                                      NULL);
-                                        if (IS_ERR(filp)) {
-                                                if (de)
-                                                        dput(de);
-                                                de = (struct dentry *) filp;
-                                        }
-#else
-                                        nd->intent.open.file->private_data = it;
-                                        (void)lookup_instantiate_filp(nd,dentry,
-                                                                      NULL);
-#endif
-
+                                       struct file *filp;
+
+                                       nd->intent.open.file->private_data = it;
+                                       filp = lookup_instantiate_filp(nd,
+                                                                      dentry,
+                                                                      NULL);
+                                       if (IS_ERR(filp)) {
+                                               if (de)
+                                                       dput(de);
+                                               de = (struct dentry *)filp;
+                                       }
                                 }
                         } else if (it_disposition(it, DISP_OPEN_CREATE)) {
                                 // XXX This can only reliably work on assumption
@@ -908,8 +900,12 @@ static int ll_create_nd(struct inode *dir, struct dentry *dentry,
 
         rc = ll_create_it(dir, dentry, mode, it);
         if (nd && (nd->flags & LOOKUP_OPEN) && dentry->d_inode) { /* Open */
-                nd->intent.open.file->private_data = it;
-                lookup_instantiate_filp(nd, dentry, NULL);
+               struct file *filp;
+
+               nd->intent.open.file->private_data = it;
+               filp = lookup_instantiate_filp(nd, dentry, NULL);
+               if (IS_ERR(filp))
+                       rc = PTR_ERR(filp);
         }
 
 out: