Whamcloud - gitweb
LU-1187 osd: add remote entry insert for ZFS DNE.
[fs/lustre-release.git] / lustre / obdclass / linux / linux-module.c
index 2cfaec7..0648e9a 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, Whamcloud, Inc.
+ * Copyright (c) 2011, 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
  */
 
 #define DEBUG_SUBSYSTEM S_CLASS
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
 
 #ifdef __KERNEL__
-#ifndef AUTOCONF_INCLUDED
-#include <linux/config.h> /* for CONFIG_PROC_FS */
-#endif
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/highmem.h>
 #include <asm/io.h>
 #include <asm/ioctls.h>
-#include <asm/system.h>
 #include <asm/poll.h>
 #include <asm/uaccess.h>
 #include <linux/miscdevice.h>
-#include <linux/smp_lock.h>
 #include <linux/seq_file.h>
 #else
 # include <liblustre.h>
@@ -86,7 +78,6 @@
 #include <lustre_ver.h>
 #include <lustre/lustre_build_version.h>
 #ifdef __KERNEL__
-#include <linux/lustre_version.h>
 
 int proc_version;
 
@@ -167,6 +158,7 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg)
         EXIT;
         return 0;
 }
+EXPORT_SYMBOL(obd_ioctl_getdata);
 
 int obd_ioctl_popdata(void *arg, void *data, int len)
 {
@@ -177,8 +169,6 @@ int obd_ioctl_popdata(void *arg, void *data, int len)
                 err = -EFAULT;
         return err;
 }
-
-EXPORT_SYMBOL(obd_ioctl_getdata);
 EXPORT_SYMBOL(obd_ioctl_popdata);
 
 /*  opening /dev/obd */
@@ -200,13 +190,8 @@ static int obd_class_release(struct inode * inode, struct file * file)
 }
 
 /* to control /dev/obd */
-#ifdef HAVE_UNLOCKED_IOCTL
 static long obd_class_ioctl(struct file *filp, unsigned int cmd,
-                            unsigned long arg)
-#else
-static int obd_class_ioctl(struct inode *inode, struct file *filp,
-                           unsigned int cmd, unsigned long arg)
-#endif
+                           unsigned long arg)
 {
         int err = 0;
         ENTRY;
@@ -224,14 +209,10 @@ static int obd_class_ioctl(struct inode *inode, struct file *filp,
 
 /* declare character device */
 static struct file_operations obd_psdev_fops = {
-        .owner   = THIS_MODULE,
-#if HAVE_UNLOCKED_IOCTL
-        .unlocked_ioctl = obd_class_ioctl, /* unlocked_ioctl */
-#else
-        .ioctl   = obd_class_ioctl,     /* ioctl */
-#endif
-        .open    = obd_class_open,      /* open */
-        .release = obd_class_release,   /* release */
+       .owner          = THIS_MODULE,
+       .unlocked_ioctl = obd_class_ioctl, /* unlocked_ioctl */
+       .open           = obd_class_open,      /* open */
+       .release        = obd_class_release,   /* release */
 };
 
 /* modules setup */
@@ -290,7 +271,7 @@ static int obd_proc_read_health(char *page, char **start, off_t off,
         if (libcfs_catastrophe)
                 rc += snprintf(page + rc, count - rc, "LBUG\n");
 
-        cfs_read_lock(&obd_dev_lock);
+       read_lock(&obd_dev_lock);
         for (i = 0; i < class_devno_max(); i++) {
                 struct obd_device *obd;
 
@@ -303,17 +284,17 @@ static int obd_proc_read_health(char *page, char **start, off_t off,
                         continue;
 
                 class_incref(obd, __FUNCTION__, cfs_current());
-                cfs_read_unlock(&obd_dev_lock);
+               read_unlock(&obd_dev_lock);
 
-                if (obd_health_check(obd)) {
+                if (obd_health_check(NULL, obd)) {
                         rc += snprintf(page + rc, count - rc,
                                        "device %s reported unhealthy\n",
                                        obd->obd_name);
                 }
                 class_decref(obd, __FUNCTION__, cfs_current());
-                cfs_read_lock(&obd_dev_lock);
+               read_lock(&obd_dev_lock);
         }
-        cfs_read_unlock(&obd_dev_lock);
+       read_unlock(&obd_dev_lock);
 
         if (rc == 0)
                 return snprintf(page, count, "healthy\n");
@@ -322,14 +303,35 @@ static int obd_proc_read_health(char *page, char **start, off_t off,
         return rc;
 }
 
+static int obd_proc_rd_jobid_var(char *page, char **start, off_t off,
+                               int count, int *eof, void *data)
+{
+       return snprintf(page, count, "%s\n", obd_jobid_var);
+}
+
+static int obd_proc_wr_jobid_var(struct file *file, const char *buffer,
+                               unsigned long count, void *data)
+{
+       if (!count || count > JOBSTATS_JOBID_VAR_MAX_LEN)
+               return -EINVAL;
+
+       memset(obd_jobid_var, 0, JOBSTATS_JOBID_VAR_MAX_LEN + 1);
+       /* Trim the trailing '\n' if any */
+       memcpy(obd_jobid_var, buffer, count - (buffer[count - 1] == '\n'));
+       return count;
+}
+
 /* Root for /proc/fs/lustre */
 struct proc_dir_entry *proc_lustre_root = NULL;
+EXPORT_SYMBOL(proc_lustre_root);
 
 struct lprocfs_vars lprocfs_base[] = {
-        { "version", obd_proc_read_version, NULL, NULL },
-        { "pinger", obd_proc_read_pinger, NULL, NULL },
-        { "health_check", obd_proc_read_health, NULL, NULL },
-        { 0 }
+       { "version", obd_proc_read_version, NULL, NULL },
+       { "pinger", obd_proc_read_pinger, NULL, NULL },
+       { "health_check", obd_proc_read_health, NULL, NULL },
+       { "jobid_var", obd_proc_rd_jobid_var,
+                      obd_proc_wr_jobid_var, NULL },
+       { 0 }
 };
 #else
 #define lprocfs_base NULL
@@ -443,18 +445,4 @@ int class_procfs_clean(void)
         }
         RETURN(0);
 }
-
-
-/* Check that we're building against the appropriate version of the Lustre
- * kernel patch */
-#include <linux/lustre_version.h>
-#ifdef LUSTRE_KERNEL_VERSION
-#define LUSTRE_MIN_VERSION 45
-#define LUSTRE_MAX_VERSION 47
-#if (LUSTRE_KERNEL_VERSION < LUSTRE_MIN_VERSION)
-# error Cannot continue: Your Lustre kernel patch is older than the sources
-#elif (LUSTRE_KERNEL_VERSION > LUSTRE_MAX_VERSION)
-# error Cannot continue: Your Lustre sources are older than the kernel patch
-#endif
-#endif
 #endif