* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2012, 2016, Intel Corporation.
+ * Copyright (c) 2012, 2017, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
{
struct seq_file *m = file->private_data;
struct obd_device *dev = m->private;
+ bool val;
int rc;
- __s64 val;
- rc = lprocfs_str_to_s64(buffer, count, &val);
+ rc = kstrtobool_from_user(buffer, count, &val);
if (rc)
return rc;
- if (val < 0 || val > 1)
- return -ERANGE;
LPROCFS_CLIMP_CHECK(dev);
/* opposite senses */
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 %lld: ignoring repeat request\n",
+ CDEBUG(D_CONFIG, "activate %d: ignoring repeat request\n",
val);
LPROCFS_CLIMP_EXIT(dev);
struct seq_file *m = file->private_data;
struct obd_device *dev = m->private;
struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
+ unsigned int val;
int rc;
- __s64 val;
if (osp == NULL)
return -EINVAL;
- rc = lprocfs_str_to_s64(buffer, count, &val);
+ rc = kstrtouint_from_user(buffer, count, 0, &val);
if (rc)
return rc;
- if (val < 1 || val > INT_MAX)
+ if (val == 0)
return -ERANGE;
osp->opd_sync_max_rpcs_in_flight = val;
struct seq_file *m = file->private_data;
struct obd_device *dev = m->private;
struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
+ unsigned int val;
int rc;
- __s64 val;
if (osp == NULL)
return -EINVAL;
- rc = lprocfs_str_to_s64(buffer, count, &val);
+ rc = kstrtouint_from_user(buffer, count, 0, &val);
if (rc)
return rc;
- if (val < 1 || val > INT_MAX)
+ if (val == 0)
return -ERANGE;
osp->opd_sync_max_rpcs_in_progress = val;
struct seq_file *m = file->private_data;
struct obd_device *obd = m->private;
struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
+ unsigned int val;
int rc, i;
- __s64 val;
if (osp == NULL || osp->opd_pre == NULL)
return 0;
- rc = lprocfs_str_to_s64(buffer, count, &val);
+ rc = kstrtouint_from_user(buffer, count, 0, &val);
if (rc)
return rc;
struct seq_file *m = file->private_data;
struct obd_device *obd = m->private;
struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
+ unsigned int val;
int rc;
- __s64 val;
if (osp == NULL || osp->opd_pre == NULL)
return 0;
- rc = lprocfs_str_to_s64(buffer, count, &val);
+ rc = kstrtouint_from_user(buffer, count, 0, &val);
if (rc)
return rc;
if (osp == NULL)
return -EINVAL;
- seq_printf(m, "%u\n", osp->opd_statfs_maxage);
+ seq_printf(m, "%lld\n", osp->opd_statfs_maxage);
return 0;
}
struct seq_file *m = file->private_data;
struct obd_device *dev = m->private;
struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
+ unsigned int val;
int rc;
- __s64 val;
if (osp == NULL)
return -EINVAL;
- rc = lprocfs_str_to_s64(buffer, count, &val);
+ rc = kstrtouint_from_user(buffer, count, 0, &val);
if (rc)
return rc;
- if (val < 1 || val > INT_MAX)
+ if (val == 0)
return -ERANGE;
osp->opd_statfs_maxage = val;
{
struct seq_file *m = file->private_data;
struct obd_device *dev = m->private;
- __s64 val;
+ unsigned int val;
int rc;
- rc = lprocfs_str_to_s64(buffer, count, &val);
- if (rc == 0) {
- if (val < 0)
- return -ERANGE;
-
+ rc = kstrtouint_from_user(buffer, count, 0, &val);
+ if (!rc)
rc = obd_set_max_rpcs_in_flight(&dev->u.cli, val);
- } else {
+ else
count = rc;
- }
return count;
}
LPROC_SEQ_FOPS(osp_lfsck_max_rpcs_in_flight);
-LPROC_SEQ_FOPS_WO_TYPE(osp, ping);
-LPROC_SEQ_FOPS_RO_TYPE(osp, uuid);
+LPROC_SEQ_FOPS_WR_ONLY(osp, ping);
LPROC_SEQ_FOPS_RO_TYPE(osp, connect_flags);
LPROC_SEQ_FOPS_RO_TYPE(osp, server_uuid);
LPROC_SEQ_FOPS_RO_TYPE(osp, conn_uuid);
}
LPROC_SEQ_FOPS(osp_reserved_mb_low);
+static ssize_t
+lprocfs_force_sync_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 dt_device *dt = lu2dt_dev(dev->obd_lu_dev);
+ struct lu_env env;
+ int rc;
+
+ rc = lu_env_init(&env, LCT_LOCAL);
+ if (rc)
+ return rc;
+ rc = dt_sync(&env, dt);
+ lu_env_fini(&env);
+
+ return rc == 0 ? count : rc;
+}
+LPROC_SEQ_FOPS_WR_ONLY(osp, force_sync);
+
static struct lprocfs_vars lprocfs_osp_obd_vars[] = {
- { .name = "uuid",
- .fops = &osp_uuid_fops },
{ .name = "ping",
.fops = &osp_ping_fops,
.proc_mode = 0222 },
.fops = &osp_reserved_mb_high_fops },
{ .name = "reserved_mb_low",
.fops = &osp_reserved_mb_low_fops },
+ { .name = "force_sync",
+ .fops = &osp_force_sync_fops },
/* for compatibility reasons */
{ .name = "destroys_in_flight",
};
static struct lprocfs_vars lprocfs_osp_md_vars[] = {
- { .name = "uuid",
- .fops = &osp_uuid_fops },
{ .name = "ping",
.fops = &osp_ping_fops,
.proc_mode = 0222 },
{ NULL }
};
+void osp_lprocfs_fini(struct osp_device *osp)
+{
+ struct obd_device *obd = osp->opd_obd;
+ struct kobject *osc;
+
+ osc = kset_find_obj(lustre_kset, "osc");
+ if (osc) {
+ sysfs_remove_link(osc, obd->obd_name);
+ kobject_put(osc);
+ }
+
+ if (!IS_ERR_OR_NULL(osp->opd_debugfs))
+ ldebugfs_remove(&osp->opd_debugfs);
+
+ ptlrpc_lprocfs_unregister_obd(obd);
+ if (osp->opd_symlink)
+ lprocfs_remove(&osp->opd_symlink);
+}
+
/**
* Initialize OSP lprocfs
*
*/
void osp_lprocfs_init(struct osp_device *osp)
{
- struct obd_device *obd = osp->opd_obd;
- struct proc_dir_entry *osc_proc_dir = NULL;
- struct obd_type *type;
- int rc;
+ struct obd_device *obd = osp->opd_obd;
+ struct proc_dir_entry *osc_proc_dir = NULL;
+ struct obd_type *type;
+ struct kobject *osc;
+ int rc;
if (osp->opd_connect_mdt)
obd->obd_vars = lprocfs_osp_md_vars;
else
obd->obd_vars = lprocfs_osp_obd_vars;
- if (lprocfs_obd_setup(obd) != 0)
+ if (lprocfs_obd_setup(obd, true) != 0)
return;
rc = lprocfs_add_vars(obd->obd_proc_entry, lprocfs_osp_osd_vars,
/* If the real OSC is present which is the case for setups
* with both server and clients on the same node then use
+ * the OSC's proc root
+ */
+ osc = kset_find_obj(lustre_kset, "osc");
+ if (osc) {
+ rc = sysfs_create_link(osc, &obd->obd_kset.kobj,
+ obd->obd_name);
+ kobject_put(osc);
+ }
+
+ osp->opd_debugfs = ldebugfs_add_symlink(obd->obd_name, "osc",
+ "../osp/%s", obd->obd_name);
+ if (!osp->opd_debugfs)
+ CERROR("%s: failed to create OSC debugfs symlink\n",
+ obd->obd_name);
+
+ /* If the real OSC is present which is the case for setups
+ * with both server and clients on the same node then use
* the OSC's proc root */
type = class_search_type(LUSTRE_OSC_NAME);
if (type != NULL && type->typ_procroot != NULL)