Whamcloud - gitweb
LU-9859 libcfs: initialize bit_wait_table
[fs/lustre-release.git] / libcfs / libcfs / module.c
index 882b177..b0e9c94 100644 (file)
@@ -53,6 +53,7 @@
 
 #include <libcfs/libcfs.h>
 #include <libcfs/libcfs_crypto.h>
+#include <libcfs/linux/linux-fs.h>
 #include <lnet/lib-lnet.h>
 #include "tracefile.h"
 
@@ -109,9 +110,8 @@ int libcfs_ioctl(unsigned long cmd, void __user *uparam)
                        err = -EINVAL;
                else
                        err = notifier_to_errno(err);
-               if (!err)
-                       if (copy_to_user(uparam, hdr, hdr->ioc_len))
-                               err = -EFAULT;
+               if (copy_to_user(uparam, hdr, hdr->ioc_len) && !err)
+                       err = -EFAULT;
                break;
        }
 out:
@@ -575,6 +575,31 @@ static void lnet_insert_debugfs_links(
                                       symlinks->target);
 }
 
+#ifndef HAVE_D_HASH_AND_LOOKUP
+/**
+ * d_hash_and_lookup - hash the qstr then search for a dentry
+ * @dir: Directory to search in
+ * @name: qstr of name we wish to find
+ *
+ * On lookup failure NULL is returned; on bad name - ERR_PTR(-error)
+ */
+struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name)
+{
+       /*
+        * Check for a fs-specific hash function. Note that we must
+        * calculate the standard hash first, as the d_op->d_hash()
+        * routine may choose to leave the hash value unchanged.
+        */
+       name->hash = full_name_hash(name->name, name->len);
+       if (dir->d_op && dir->d_op->d_hash) {
+               int err = dir->d_op->d_hash(dir, name);
+               if (unlikely(err < 0))
+                       return ERR_PTR(err);
+       }
+       return d_lookup(dir, name);
+}
+#endif
+
 void lnet_remove_debugfs(struct ctl_table *table)
 {
        for (; table && table->procname; table++) {
@@ -592,6 +617,9 @@ static int __init libcfs_init(void)
 {
        int rc;
 
+#ifndef HAVE_WAIT_VAR_EVENT
+       wait_bit_init();
+#endif
        rc = libcfs_debug_init(5 * 1024 * 1024);
        if (rc < 0) {
                printk(KERN_ERR "LustreError: libcfs_debug_init: %d\n", rc);