Whamcloud - gitweb
LU-13437 uapi: add OBD_CONNECT2_GETATTR_PFID
[fs/lustre-release.git] / lustre / obdclass / obd_sysfs.c
index f83c6f3..8e4cae2 100644 (file)
@@ -161,7 +161,7 @@ static ssize_t max_dirty_mb_store(struct kobject *kobj, struct attribute *attr,
 
        val *= 1 << (20 - PAGE_SHIFT); /* convert to pages */
 
-       if (val > ((totalram_pages / 10) * 9)) {
+       if (val > ((cfs_totalram_pages() / 10) * 9)) {
                /* Somebody wants to assign too much memory to dirty pages */
                return -EINVAL;
        }
@@ -177,6 +177,34 @@ static ssize_t max_dirty_mb_store(struct kobject *kobj, struct attribute *attr,
 }
 LUSTRE_RW_ATTR(max_dirty_mb);
 
+#ifdef HAVE_SERVER_SUPPORT
+static ssize_t no_transno_store(struct kobject *kobj,
+                               struct attribute *attr,
+                               const char *buffer, size_t count)
+{
+       struct obd_device *obd;
+       unsigned int idx;
+       int rc;
+
+       rc = kstrtouint(buffer, 10, &idx);
+       if (rc)
+               return rc;
+
+       obd = class_num2obd(idx);
+       if (!obd || !obd->obd_attached) {
+               if (obd)
+                       CERROR("%s: not attached\n", obd->obd_name);
+               return -ENODEV;
+       }
+
+       spin_lock(&obd->obd_dev_lock);
+       obd->obd_no_transno = 1;
+       spin_unlock(&obd->obd_dev_lock);
+       return count;
+}
+LUSTRE_WO_ATTR(no_transno);
+#endif /* HAVE_SERVER_SUPPORT */
+
 static ssize_t version_show(struct kobject *kobj, struct attribute *attr,
                            char *buf)
 {
@@ -186,7 +214,7 @@ static ssize_t version_show(struct kobject *kobj, struct attribute *attr,
 static ssize_t pinger_show(struct kobject *kobj, struct attribute *attr,
                           char *buf)
 {
-#ifdef ENABLE_PINGER
+#ifdef CONFIG_LUSTRE_FS_PINGER
        const char *state = "on";
 #else
        const char *state = "off";
@@ -311,6 +339,44 @@ static ssize_t jobid_name_store(struct kobject *kobj, struct attribute *attr,
        return count;
 }
 
+static ssize_t jobid_this_session_show(struct kobject *kobj,
+                                      struct attribute *attr,
+                                      char *buf)
+{
+       char *jid;
+       int ret = -ENOENT;
+
+       rcu_read_lock();
+       jid = jobid_current();
+       if (jid)
+               ret = snprintf(buf, PAGE_SIZE, "%s\n", jid);
+       rcu_read_unlock();
+       return ret;
+}
+
+static ssize_t jobid_this_session_store(struct kobject *kobj,
+                                       struct attribute *attr,
+                                       const char *buffer,
+                                       size_t count)
+{
+       char *jobid;
+       int len;
+       int ret;
+
+       if (!count || count > LUSTRE_JOBID_SIZE)
+               return -EINVAL;
+
+       jobid = kstrndup(buffer, count, GFP_KERNEL);
+       if (!jobid)
+               return -ENOMEM;
+       len = strcspn(jobid, "\n ");
+       jobid[len] = '\0';
+       ret = jobid_set_current(jobid);
+       kfree(jobid);
+
+       return ret ?: count;
+}
+
 /* Root for /sys/kernel/debug/lustre */
 struct dentry *debugfs_lustre_root;
 EXPORT_SYMBOL_GPL(debugfs_lustre_root);
@@ -328,6 +394,7 @@ LUSTRE_RO_ATTR(pinger);
 LUSTRE_RO_ATTR(health_check);
 LUSTRE_RW_ATTR(jobid_var);
 LUSTRE_RW_ATTR(jobid_name);
+LUSTRE_RW_ATTR(jobid_this_session);
 
 static struct attribute *lustre_attrs[] = {
        &lustre_attr_version.attr,
@@ -335,6 +402,7 @@ static struct attribute *lustre_attrs[] = {
        &lustre_attr_health_check.attr,
        &lustre_attr_jobid_name.attr,
        &lustre_attr_jobid_var.attr,
+       &lustre_attr_jobid_this_session.attr,
        &lustre_sattr_timeout.u.attr,
        &lustre_attr_max_dirty_mb.attr,
        &lustre_sattr_debug_peer_on_timeout.u.attr,
@@ -350,6 +418,7 @@ static struct attribute *lustre_attrs[] = {
 #ifdef HAVE_SERVER_SUPPORT
        &lustre_sattr_ldlm_timeout.u.attr,
        &lustre_sattr_bulk_timeout.u.attr,
+       &lustre_attr_no_transno.attr,
 #endif
        &lustre_sattr_lbug_on_eviction.u.attr,
        NULL,
@@ -517,31 +586,12 @@ int class_procfs_init(void)
        }
 
        debugfs_lustre_root = debugfs_create_dir("lustre", NULL);
-       if (IS_ERR_OR_NULL(debugfs_lustre_root)) {
-               rc = debugfs_lustre_root ? PTR_ERR(debugfs_lustre_root)
-                                        : -ENOMEM;
-               debugfs_lustre_root = NULL;
-               kset_unregister(lustre_kset);
-               goto out;
-       }
 
        file = debugfs_create_file("devices", 0444, debugfs_lustre_root, NULL,
                                   &obd_device_list_fops);
-       if (IS_ERR_OR_NULL(file)) {
-               rc = file ? PTR_ERR(file) : -ENOMEM;
-               debugfs_remove(debugfs_lustre_root);
-               kset_unregister(lustre_kset);
-               goto out;
-       }
 
        file = debugfs_create_file("health_check", 0444, debugfs_lustre_root,
                                   NULL, &health_check_fops);
-       if (IS_ERR_OR_NULL(file)) {
-               rc = file ? PTR_ERR(file) : -ENOMEM;
-               debugfs_remove_recursive(debugfs_lustre_root);
-               kset_unregister(lustre_kset);
-               goto out;
-       }
 
        entry = lprocfs_register("fs/lustre", NULL, NULL, NULL);
        if (IS_ERR(entry)) {