Whamcloud - gitweb
LU-5050 libcfs: default CPT matches NUMA topology
[fs/lustre-release.git] / lustre / osp / lproc_osp.c
index 12c91c4..6dc9287 100644 (file)
 static int osp_active_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device       *dev = m->private;
-       int                      rc;
 
        LPROCFS_CLIMP_CHECK(dev);
-       rc = seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive);
+       seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive);
        LPROCFS_CLIMP_EXIT(dev);
-       return rc;
+       return 0;
 }
 
 /**
@@ -74,11 +73,12 @@ static ssize_t
 osp_active_seq_write(struct file *file, const char __user *buffer,
                        size_t count, loff_t *off)
 {
-       struct seq_file   *m = file->private_data;
+       struct seq_file *m = file->private_data;
        struct obd_device *dev = m->private;
-       int                val, rc;
+       int rc;
+       __s64 val;
 
-       rc = lprocfs_write_helper(buffer, count, &val);
+       rc = lprocfs_str_to_s64(buffer, count, &val);
        if (rc)
                return rc;
        if (val < 0 || val > 1)
@@ -89,7 +89,7 @@ osp_active_seq_write(struct file *file, const char __user *buffer,
        if (dev->u.cli.cl_import->imp_deactive == val)
                rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val);
        else
-               CDEBUG(D_CONFIG, "activate %d: ignoring repeat request\n",
+               CDEBUG(D_CONFIG, "activate "LPD64": ignoring repeat request\n",
                       val);
 
        LPROCFS_CLIMP_EXIT(dev);
@@ -113,7 +113,8 @@ static int osp_syn_in_flight_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       return seq_printf(m, "%u\n", osp->opd_syn_rpc_in_flight);
+       seq_printf(m, "%u\n", osp->opd_syn_rpc_in_flight);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osp_syn_in_flight);
 
@@ -133,7 +134,8 @@ static int osp_syn_in_prog_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       return seq_printf(m, "%u\n", osp->opd_syn_rpc_in_progress);
+       seq_printf(m, "%u\n", osp->opd_syn_rpc_in_progress);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osp_syn_in_prog);
 
@@ -153,7 +155,8 @@ static int osp_syn_changes_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       return seq_printf(m, "%lu\n", osp->opd_syn_changes);
+       seq_printf(m, "%lu\n", osp->opd_syn_changes);
+       return 0;
 }
 
 /**
@@ -203,7 +206,8 @@ static int osp_max_rpcs_in_flight_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       return seq_printf(m, "%u\n", osp->opd_syn_max_rpc_in_flight);
+       seq_printf(m, "%u\n", osp->opd_syn_max_rpc_in_flight);
+       return 0;
 }
 
 /**
@@ -220,19 +224,20 @@ static ssize_t
 osp_max_rpcs_in_flight_seq_write(struct file *file, const char __user *buffer,
                                size_t count, loff_t *off)
 {
-       struct seq_file         *m = file->private_data;
-       struct obd_device       *dev = m->private;
-       struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
-       int                      val, rc;
+       struct seq_file *m = file->private_data;
+       struct obd_device *dev = m->private;
+       struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
+       int rc;
+       __s64 val;
 
        if (osp == NULL)
                return -EINVAL;
 
-       rc = lprocfs_write_helper(buffer, count, &val);
+       rc = lprocfs_str_to_s64(buffer, count, &val);
        if (rc)
                return rc;
 
-       if (val < 1)
+       if (val < 1 || val > INT_MAX)
                return -ERANGE;
 
        osp->opd_syn_max_rpc_in_flight = val;
@@ -256,7 +261,8 @@ static int osp_max_rpcs_in_prog_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       return seq_printf(m, "%u\n", osp->opd_syn_max_rpc_in_progress);
+       seq_printf(m, "%u\n", osp->opd_syn_max_rpc_in_progress);
+       return 0;
 }
 
 /**
@@ -273,19 +279,20 @@ static ssize_t
 osp_max_rpcs_in_prog_seq_write(struct file *file, const char __user *buffer,
                                size_t count, loff_t *off)
 {
-       struct seq_file         *m = file->private_data;
-       struct obd_device       *dev = m->private;
-       struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
-       int                      val, rc;
+       struct seq_file *m = file->private_data;
+       struct obd_device *dev = m->private;
+       struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
+       int rc;
+       __s64 val;
 
        if (osp == NULL)
                return -EINVAL;
 
-       rc = lprocfs_write_helper(buffer, count, &val);
+       rc = lprocfs_str_to_s64(buffer, count, &val);
        if (rc)
                return rc;
 
-       if (val < 1)
+       if (val < 1 || val > INT_MAX)
                return -ERANGE;
 
        osp->opd_syn_max_rpc_in_progress = val;
@@ -310,7 +317,8 @@ static int osp_create_count_seq_show(struct seq_file *m, void *data)
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
 
-       return seq_printf(m, "%d\n", osp->opd_pre_grow_count);
+       seq_printf(m, "%d\n", osp->opd_pre_create_count);
+       return 0;
 }
 
 /**
@@ -327,15 +335,16 @@ static ssize_t
 osp_create_count_seq_write(struct file *file, const char __user *buffer,
                                size_t count, loff_t *off)
 {
-       struct seq_file         *m = file->private_data;
-       struct obd_device       *obd = m->private;
-       struct osp_device       *osp = lu2osp_dev(obd->obd_lu_dev);
-       int                      val, rc, i;
+       struct seq_file *m = file->private_data;
+       struct obd_device *obd = m->private;
+       struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
+       int rc, i;
+       __s64 val;
 
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
 
-       rc = lprocfs_write_helper(buffer, count, &val);
+       rc = lprocfs_str_to_s64(buffer, count, &val);
        if (rc)
                return rc;
 
@@ -351,12 +360,12 @@ osp_create_count_seq_write(struct file *file, const char __user *buffer,
         * filesystem as a safety measure. */
        if (val < OST_MIN_PRECREATE || val > OST_MAX_PRECREATE)
                return -ERANGE;
-       if (val > osp->opd_pre_max_grow_count)
+       if (val > osp->opd_pre_max_create_count)
                return -ERANGE;
 
        for (i = 1; (i << 1) <= val; i <<= 1)
                ;
-       osp->opd_pre_grow_count = i;
+       osp->opd_pre_create_count = i;
 
        return count;
 }
@@ -378,7 +387,8 @@ static int osp_max_create_count_seq_show(struct seq_file *m, void *data)
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
 
-       return seq_printf(m, "%d\n", osp->opd_pre_max_grow_count);
+       seq_printf(m, "%d\n", osp->opd_pre_max_create_count);
+       return 0;
 }
 
 /**
@@ -395,27 +405,28 @@ static ssize_t
 osp_max_create_count_seq_write(struct file *file, const char __user *buffer,
                                size_t count, loff_t *off)
 {
-       struct seq_file         *m = file->private_data;
-       struct obd_device       *obd = m->private;
-       struct osp_device       *osp = lu2osp_dev(obd->obd_lu_dev);
-       int                      val, rc;
+       struct seq_file *m = file->private_data;
+       struct obd_device *obd = m->private;
+       struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
+       int rc;
+       __s64 val;
 
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
 
-       rc = lprocfs_write_helper(buffer, count, &val);
+       rc = lprocfs_str_to_s64(buffer, count, &val);
        if (rc)
                return rc;
 
-       if (val < 0)
+       if (val < 0 || val > INT_MAX)
                return -ERANGE;
        if (val > OST_MAX_PRECREATE)
                return -ERANGE;
 
-       if (osp->opd_pre_grow_count > val)
-               osp->opd_pre_grow_count = val;
+       if (osp->opd_pre_create_count > val)
+               osp->opd_pre_create_count = val;
 
-       osp->opd_pre_max_grow_count = val;
+       osp->opd_pre_max_create_count = val;
 
        return count;
 }
@@ -437,7 +448,8 @@ static int osp_prealloc_next_id_seq_show(struct seq_file *m, void *data)
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
 
-       return seq_printf(m, "%u\n", fid_oid(&osp->opd_pre_used_fid) + 1);
+       seq_printf(m, "%u\n", fid_oid(&osp->opd_pre_used_fid) + 1);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osp_prealloc_next_id);
 
@@ -457,7 +469,8 @@ static int osp_prealloc_last_id_seq_show(struct seq_file *m, void *data)
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
 
-       return seq_printf(m, "%u\n", fid_oid(&osp->opd_pre_last_created_fid));
+       seq_printf(m, "%u\n", fid_oid(&osp->opd_pre_last_created_fid));
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osp_prealloc_last_id);
 
@@ -477,7 +490,8 @@ static int osp_prealloc_next_seq_seq_show(struct seq_file *m, void *data)
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
 
-       return seq_printf(m, LPX64"\n", fid_seq(&osp->opd_pre_used_fid));
+       seq_printf(m, LPX64"\n", fid_seq(&osp->opd_pre_used_fid));
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osp_prealloc_next_seq);
 
@@ -497,8 +511,9 @@ static int osp_prealloc_last_seq_seq_show(struct seq_file *m, void *data)
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
 
-       return seq_printf(m, LPX64"\n",
-                       fid_seq(&osp->opd_pre_last_created_fid));
+       seq_printf(m, LPX64"\n",
+                  fid_seq(&osp->opd_pre_last_created_fid));
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osp_prealloc_last_seq);
 
@@ -518,7 +533,8 @@ static int osp_prealloc_reserved_seq_show(struct seq_file *m, void *data)
        if (osp == NULL || osp->opd_pre == NULL)
                return 0;
 
-       return seq_printf(m, LPU64"\n", osp->opd_pre_reserved);
+       seq_printf(m, LPU64"\n", osp->opd_pre_reserved);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osp_prealloc_reserved);
 
@@ -538,7 +554,8 @@ static int osp_maxage_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       return seq_printf(m, "%u\n", osp->opd_statfs_maxage);
+       seq_printf(m, "%u\n", osp->opd_statfs_maxage);
+       return 0;
 }
 
 /**
@@ -555,19 +572,20 @@ static ssize_t
 osp_maxage_seq_write(struct file *file, const char __user *buffer,
                        size_t count, loff_t *off)
 {
-       struct seq_file         *m = file->private_data;
-       struct obd_device       *dev = m->private;
-       struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
-       int                      val, rc;
+       struct seq_file *m = file->private_data;
+       struct obd_device *dev = m->private;
+       struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
+       int rc;
+       __s64 val;
 
        if (osp == NULL)
                return -EINVAL;
 
-       rc = lprocfs_write_helper(buffer, count, &val);
+       rc = lprocfs_str_to_s64(buffer, count, &val);
        if (rc)
                return rc;
 
-       if (val < 1)
+       if (val < 1 || val > INT_MAX)
                return -ERANGE;
 
        osp->opd_statfs_maxage = val;
@@ -593,7 +611,8 @@ static int osp_pre_status_seq_show(struct seq_file *m, void *data)
        if (osp == NULL || osp->opd_pre == NULL)
                return -EINVAL;
 
-       return seq_printf(m, "%d\n", osp->opd_pre_status);
+       seq_printf(m, "%d\n", osp->opd_pre_status);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osp_pre_status);
 
@@ -620,8 +639,9 @@ static int osp_destroys_in_flight_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       return seq_printf(m, "%lu\n",
-                         osp->opd_syn_rpc_in_progress + osp->opd_syn_changes);
+       seq_printf(m, "%lu\n",
+                  osp->opd_syn_rpc_in_progress + osp->opd_syn_changes);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osp_destroys_in_flight);
 
@@ -641,7 +661,8 @@ static int osp_old_sync_processed_seq_show(struct seq_file *m, void *data)
        if (osp == NULL)
                return -EINVAL;
 
-       return seq_printf(m, "%d\n", osp->opd_syn_prev_done);
+       seq_printf(m, "%d\n", osp->opd_syn_prev_done);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osp_old_sync_processed);
 
@@ -660,7 +681,8 @@ osp_lfsck_max_rpcs_in_flight_seq_show(struct seq_file *m, void *data)
        __u32 max;
 
        max = obd_get_max_rpcs_in_flight(&dev->u.cli);
-       return seq_printf(m, "%u\n", max);
+       seq_printf(m, "%u\n", max);
+       return 0;
 }
 
 /**
@@ -680,15 +702,18 @@ osp_lfsck_max_rpcs_in_flight_seq_write(struct file *file,
 {
        struct seq_file   *m = file->private_data;
        struct obd_device *dev = m->private;
-       int val;
+       __s64 val;
        int rc;
 
-       rc = lprocfs_write_helper(buffer, count, &val);
-       if (rc == 0)
-               rc = obd_set_max_rpcs_in_flight(&dev->u.cli, val);
+       rc = lprocfs_str_to_s64(buffer, count, &val);
+       if (rc == 0) {
+               if (val < 0)
+                       return -ERANGE;
 
-       if (rc != 0)
+               rc = obd_set_max_rpcs_in_flight(&dev->u.cli, val);
+       } else {
                count = rc;
+       }
 
        return count;
 }