Whamcloud - gitweb
LU-6032 ldlm: don't disable softirq for exp_rpc_lock
[fs/lustre-release.git] / lustre / obdclass / lprocfs_status_server.c
index 08f3f18..bbd81a9 100644 (file)
 #include <lprocfs_status.h>
 #include <lustre_nodemap.h>
 
+#define MAX_STRING_SIZE 128
+
+struct dentry *ldebugfs_add_symlink(const char *name, const char *target,
+                                   const char *format, ...)
+{
+       struct dentry *entry = NULL;
+       struct dentry *parent;
+       struct qstr dname;
+       va_list ap;
+       char *dest;
+
+       if (!target || !format)
+               return NULL;
+
+       dname.name = target;
+       dname.len = strlen(dname.name);
+       dname.hash = ll_full_name_hash(parent, dname.name, dname.len);
+       parent = d_lookup(debugfs_lustre_root, &dname);
+       if (!parent)
+               return NULL;
+
+       OBD_ALLOC_WAIT(dest, MAX_STRING_SIZE + 1);
+       if (!dest)
+               goto no_entry;
+
+       va_start(ap, format);
+       vsnprintf(dest, MAX_STRING_SIZE, format, ap);
+       va_end(ap);
+
+       entry = debugfs_create_symlink(name, parent, dest);
+       if (IS_ERR_OR_NULL(entry)) {
+               CERROR("LdebugFS: Could not create symbolic link from %s to %s\n",
+                      name, dest);
+               entry = NULL;
+       }
+
+       OBD_FREE(dest, MAX_STRING_SIZE + 1);
+no_entry:
+       dput(parent);
+       return entry;
+}
+EXPORT_SYMBOL(ldebugfs_add_symlink);
+
 #ifdef CONFIG_PROC_FS
 
 int lprocfs_evict_client_open(struct inode *inode, struct file *f)
@@ -772,11 +815,11 @@ lprocfs_ir_factor_seq_write(struct file *file, const char __user *buffer,
 {
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
+       int val;
        int rc;
-       __s64 val;
 
        LASSERT(obd != NULL);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtoint_from_user(buffer, count, 10, &val);
        if (rc)
                return rc;
 
@@ -804,15 +847,15 @@ lprocfs_checksum_dump_seq_write(struct file *file, const char __user *buffer,
 {
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
+       bool val;
        int rc;
-       __s64 val;
 
        LASSERT(obd != NULL);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
-       obd->obd_checksum_dump = !!val;
+       obd->obd_checksum_dump = val;
        return count;
 }
 EXPORT_SYMBOL(lprocfs_checksum_dump_seq_write);
@@ -834,15 +877,13 @@ lprocfs_recovery_time_soft_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
+       unsigned int val;
        int rc;
-       __s64 val;
 
        LASSERT(obd != NULL);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
-       if (val < 0 || val > INT_MAX)
-               return -ERANGE;
 
        obd->obd_recovery_timeout = val;
        return count;
@@ -866,15 +907,13 @@ lprocfs_recovery_time_hard_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
+       unsigned int val;
        int rc;
-       __s64 val;
 
        LASSERT(obd != NULL);
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtouint_from_user(buffer, count, 0, &val);
        if (rc)
                return rc;
-       if (val < 0 || val > INT_MAX)
-               return -ERANGE;
 
        obd->obd_recovery_time_hard = val;
        return count;