extern int lprocfs_state_seq_show(struct seq_file *m, void *data);
extern int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data);
#ifdef HAVE_SERVER_SUPPORT
-extern int lprocfs_num_exports_seq_show(struct seq_file *m, void *data);
+ssize_t num_exports_show(struct kobject *kobj, struct attribute *attr,
+ char *buf);
#endif
struct adaptive_timeout;
extern int lprocfs_at_hist_helper(struct seq_file *m,
int lprocfs_hash_seq_show(struct seq_file *m, void *data);
/* lprocfs_status.c: IR factor */
-int lprocfs_ir_factor_seq_show(struct seq_file *m, void *data);
-ssize_t
-lprocfs_ir_factor_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off);
+ssize_t ir_factor_show(struct kobject *kobj, struct attribute *attr,
+ char *buf);
+ssize_t ir_factor_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count);
#endif
/* lprocfs_status.c: dump pages on cksum error */
void lprocfs_job_stats_fini(struct obd_device *obd);
int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
cntr_init_callback fn);
-int lprocfs_job_interval_seq_show(struct seq_file *m, void *data);
-ssize_t
-lprocfs_job_interval_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off);
-/* lproc_status.c */
-int lprocfs_recovery_time_soft_seq_show(struct seq_file *m, void *data);
-ssize_t lprocfs_recovery_time_soft_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off);
-int lprocfs_recovery_time_hard_seq_show(struct seq_file *m, void *data);
-ssize_t
-lprocfs_recovery_time_hard_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off);
-int lprocfs_target_instance_seq_show(struct seq_file *m, void *data);
+ssize_t job_cleanup_interval_show(struct kobject *kobj, struct attribute *attr,
+ char *buf);
+ssize_t job_cleanup_interval_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count);
+/* lproc_status_server.c */
+ssize_t recovery_time_soft_show(struct kobject *kobj, struct attribute *attr,
+ char *buf);
+ssize_t recovery_time_soft_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count);
+ssize_t recovery_time_hard_show(struct kobject *kobj, struct attribute *attr,
+ char *buf);
+ssize_t recovery_time_hard_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count);
+ssize_t instance_show(struct kobject *kobj, struct attribute *attr,
+ char *buf);
#endif
+/* lproc_status.c */
int lprocfs_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *data);
ssize_t lprocfs_obd_max_pages_per_rpc_seq_write(struct file *file,
const char __user *buffer,
int tgt_statfs_internal(const struct lu_env *env, struct lu_target *lut,
struct obd_statfs *osfs, time64_t max_age,
int *from_cache);
-int tgt_tot_dirty_seq_show(struct seq_file *m, void *data);
-int tgt_tot_granted_seq_show(struct seq_file *m, void *data);
-int tgt_tot_pending_seq_show(struct seq_file *m, void *data);
-int tgt_grant_compat_disable_seq_show(struct seq_file *m, void *data);
-ssize_t tgt_grant_compat_disable_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off);
+ssize_t tot_dirty_show(struct kobject *kobj, struct attribute *attr,
+ char *buf);
+ssize_t tot_granted_show(struct kobject *kobj, struct attribute *attr,
+ char *buf);
+ssize_t tot_pending_show(struct kobject *kobj, struct attribute *attr,
+ char *buf);
+ssize_t grant_compat_disable_show(struct kobject *kobj, struct attribute *attr,
+ char *buf);
+ssize_t grant_compat_disable_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count);
/* FMD */
void tgt_fmd_update(struct obd_export *exp, const struct lu_fid *fid,
time64_t obd_recovery_start;
/* seconds, for lprocfs_status */
time64_t obd_recovery_end;
- time64_t obd_recovery_time_hard;
- time64_t obd_recovery_timeout;
+ /* To tell timeouts from time stamps Lustre uses time_t
+ * instead of time64_t.
+ */
+ time_t obd_recovery_time_hard;
+ time_t obd_recovery_timeout;
int obd_recovery_ir_factor;
/* new recovery stuff from CMD2 */
ssize_t class_set_global(const char *param);
ssize_t class_modify_config(struct lustre_cfg *lcfg, const char *prefix,
struct kobject *kobj);
-int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
- struct lustre_cfg *lcfg, void *data);
int class_attach(struct lustre_cfg *lcfg);
int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg);
int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg);
obd->obd_recovery_start = ktime_get_real_seconds();
spin_unlock(&obd->obd_dev_lock);
- LCONSOLE_WARN("%s: Will be in recovery for at least %llu:%02llu, or until %d client%s reconnect%s\n",
+ LCONSOLE_WARN("%s: Will be in recovery for at least %lu:%02lu, or until %d client%s reconnect%s\n",
obd->obd_name,
obd->obd_recovery_timeout / 60,
obd->obd_recovery_timeout % 60,
extend_recovery_timer(obd, obd->obd_recovery_timeout,
true);
CDEBUG(D_HA,
- "%s update recovery is not ready, extend recovery %llu\n",
+ "%s update recovery is not ready, extend recovery %lu\n",
obd->obd_name, obd->obd_recovery_timeout);
return 0;
}
}
}
-/**
- * create /proc entries for coordinator
- * \param mdt [IN]
- * \retval 0 success
- * \retval -ve failure
- */
-int hsm_cdt_procfs_init(struct mdt_device *mdt)
-{
- struct coordinator *cdt = &mdt->mdt_coordinator;
- int rc = 0;
- ENTRY;
-
- /* init /proc entries, failure is not critical */
- cdt->cdt_proc_dir = lprocfs_register("hsm",
- mdt2obd_dev(mdt)->obd_proc_entry,
- lprocfs_mdt_hsm_vars, mdt);
- if (IS_ERR(cdt->cdt_proc_dir)) {
- rc = PTR_ERR(cdt->cdt_proc_dir);
- CERROR("%s: Cannot create 'hsm' directory in mdt proc dir,"
- " rc=%d\n", mdt_obd_name(mdt), rc);
- cdt->cdt_proc_dir = NULL;
- RETURN(rc);
- }
-
- RETURN(0);
-}
-
-/**
- * remove /proc entries for coordinator
- * \param mdt [IN]
- */
-void hsm_cdt_procfs_fini(struct mdt_device *mdt)
-{
- struct coordinator *cdt = &mdt->mdt_coordinator;
-
- if (cdt->cdt_proc_dir != NULL)
- lprocfs_remove(&cdt->cdt_proc_dir);
-}
-
-/**
- * get vector of hsm cdt /proc vars
- * \param none
- * \retval var vector
- */
-struct lprocfs_vars *hsm_cdt_get_proc_vars(void)
-{
- return lprocfs_mdt_hsm_vars;
-}
-
/* Release the ressource used by the coordinator. Called when the
* coordinator is stopping. */
static void mdt_hsm_cdt_cleanup(struct mdt_device *mdt)
hsm_init_ucred(mdt_ucred(cdt_mti));
- /* default values for /proc tunnables
+ /* default values for sysfs tunnables
* can be override by MGS conf */
cdt->cdt_default_archive_id = 1;
cdt->cdt_grace_delay = 60;
cdt->cdt_group_request_mask = (1UL << HSMA_RESTORE);
cdt->cdt_other_request_mask = (1UL << HSMA_RESTORE);
- /* to avoid deadlock when start is made through /proc
- * /proc entries are created by the coordinator thread */
-
+ /* to avoid deadlock when start is made through sysfs
+ * sysfs entries are created by the coordinator thread
+ */
/* set up list of started restore requests */
cdt_mti = lu_context_key_get(&cdt->cdt_env.le_ctx, &mdt_thread_key);
rc = mdt_hsm_pending_restore(cdt_mti);
}
/*
- * /proc interface used to get/set HSM behaviour (cdt->cdt_policy)
+ * sysfs interface used to get/set HSM behaviour (cdt->cdt_policy)
*/
static const struct {
__u64 bit;
OBD_FREE(buf, count + 1);
RETURN(rc);
}
-LPROC_SEQ_FOPS(mdt_hsm_policy);
-
-#define GENERATE_PROC_METHOD(VAR) \
-static int mdt_hsm_##VAR##_seq_show(struct seq_file *m, void *data) \
-{ \
- struct mdt_device *mdt = m->private; \
- struct coordinator *cdt = &mdt->mdt_coordinator; \
- ENTRY; \
- \
- seq_printf(m, "%llu\n", (__u64)cdt->VAR); \
- RETURN(0); \
-} \
-static ssize_t \
-mdt_hsm_##VAR##_seq_write(struct file *file, const char __user *buffer, \
- size_t count, loff_t *off) \
- \
-{ \
- struct seq_file *m = file->private_data; \
- struct mdt_device *mdt = m->private; \
- struct coordinator *cdt = &mdt->mdt_coordinator; \
- unsigned int val; \
- int rc; \
- \
- ENTRY; \
- rc = kstrtouint_from_user(buffer, count, 0, &val); \
- if (rc) \
- RETURN(rc); \
- \
- if (val != 0) { \
- cdt->VAR = val; \
- RETURN(count); \
- } \
- RETURN(-EINVAL); \
-} \
-
-GENERATE_PROC_METHOD(cdt_loop_period)
-GENERATE_PROC_METHOD(cdt_grace_delay)
-GENERATE_PROC_METHOD(cdt_active_req_timeout)
-GENERATE_PROC_METHOD(cdt_max_requests)
-GENERATE_PROC_METHOD(cdt_default_archive_id)
+LDEBUGFS_SEQ_FOPS(mdt_hsm_policy);
+
+ssize_t loop_period_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
+{
+ struct coordinator *cdt = container_of(kobj, struct coordinator,
+ cdt_hsm_kobj);
+
+ return scnprintf(buf, PAGE_SIZE, "%lu\n", cdt->cdt_loop_period);
+}
+
+ssize_t loop_period_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
+{
+ struct coordinator *cdt = container_of(kobj, struct coordinator,
+ cdt_hsm_kobj);
+ unsigned int val;
+ int rc;
+
+ rc = kstrtouint(buffer, 0, &val);
+ if (rc)
+ return rc;
+
+ if (val != 0)
+ cdt->cdt_loop_period = val;
+
+ return val ? count : -EINVAL;
+}
+LUSTRE_RW_ATTR(loop_period);
+
+ssize_t grace_delay_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
+{
+ struct coordinator *cdt = container_of(kobj, struct coordinator,
+ cdt_hsm_kobj);
+
+ return scnprintf(buf, PAGE_SIZE, "%lu\n", cdt->cdt_grace_delay);
+}
+
+ssize_t grace_delay_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
+{
+ struct coordinator *cdt = container_of(kobj, struct coordinator,
+ cdt_hsm_kobj);
+ unsigned int val;
+ int rc;
+
+ rc = kstrtouint(buffer, 0, &val);
+ if (rc)
+ return rc;
+
+ if (val != 0)
+ cdt->cdt_grace_delay = val;
+
+ return val ? count : -EINVAL;
+}
+LUSTRE_RW_ATTR(grace_delay);
+
+ssize_t active_request_timeout_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
+{
+ struct coordinator *cdt = container_of(kobj, struct coordinator,
+ cdt_hsm_kobj);
+
+ return scnprintf(buf, PAGE_SIZE, "%lu\n", cdt->cdt_active_req_timeout);
+}
+
+ssize_t active_request_timeout_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count)
+{
+ struct coordinator *cdt = container_of(kobj, struct coordinator,
+ cdt_hsm_kobj);
+ unsigned int val;
+ int rc;
+
+ rc = kstrtouint(buffer, 0, &val);
+ if (rc)
+ return rc;
+
+ if (val != 0)
+ cdt->cdt_active_req_timeout = val;
+
+ return val ? count : -EINVAL;
+}
+LUSTRE_RW_ATTR(active_request_timeout);
+
+ssize_t max_requests_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
+{
+ struct coordinator *cdt = container_of(kobj, struct coordinator,
+ cdt_hsm_kobj);
+
+ return scnprintf(buf, PAGE_SIZE, "%llu\n", cdt->cdt_max_requests);
+}
+
+ssize_t max_requests_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
+{
+ struct coordinator *cdt = container_of(kobj, struct coordinator,
+ cdt_hsm_kobj);
+ unsigned long long val;
+ int rc;
+
+ rc = kstrtoull(buffer, 0, &val);
+ if (rc)
+ return rc;
+
+ if (val != 0)
+ cdt->cdt_max_requests = val;
+
+ return val ? count : -EINVAL;
+}
+LUSTRE_RW_ATTR(max_requests);
+
+ssize_t default_archive_id_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
+{
+ struct coordinator *cdt = container_of(kobj, struct coordinator,
+ cdt_hsm_kobj);
+
+ return scnprintf(buf, PAGE_SIZE, "%u\n", cdt->cdt_default_archive_id);
+}
+
+ssize_t default_archive_id_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
+{
+ struct coordinator *cdt = container_of(kobj, struct coordinator,
+ cdt_hsm_kobj);
+ unsigned int val;
+ int rc;
+
+ rc = kstrtouint(buffer, 0, &val);
+ if (rc)
+ return rc;
+
+ if (val != 0)
+ cdt->cdt_default_archive_id = val;
+
+ return val ? count : -EINVAL;
+}
+LUSTRE_RW_ATTR(default_archive_id);
/*
* procfs write method for MDT/hsm_control
#define CDT_HELP_CMD "help"
#define CDT_MAX_CMD_LEN 10
-ssize_t
-mdt_hsm_cdt_control_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+ssize_t hsm_control_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
- struct coordinator *cdt = &(mdt->mdt_coordinator);
- int rc, usage = 0;
- char kernbuf[CDT_MAX_CMD_LEN];
- ENTRY;
-
- if (count == 0 || count >= sizeof(kernbuf))
- RETURN(-EINVAL);
-
- if (copy_from_user(kernbuf, buffer, count))
- RETURN(-EFAULT);
- kernbuf[count] = 0;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
+ struct coordinator *cdt = &(mdt->mdt_coordinator);
+ int usage = 0;
+ int rc = 0;
- if (kernbuf[count - 1] == '\n')
- kernbuf[count - 1] = 0;
+ if (count == 0 || count >= CDT_MAX_CMD_LEN)
+ return -EINVAL;
- rc = 0;
- if (strcmp(kernbuf, CDT_ENABLE_CMD) == 0) {
+ if (strncmp(buffer, CDT_ENABLE_CMD, strlen(CDT_ENABLE_CMD)) == 0) {
if (cdt->cdt_state == CDT_DISABLE) {
rc = set_cdt_state(cdt, CDT_RUNNING);
mdt_hsm_cdt_event(cdt);
} else {
rc = mdt_hsm_cdt_start(mdt);
}
- } else if (strcmp(kernbuf, CDT_STOP_CMD) == 0) {
+ } else if (strncmp(buffer, CDT_STOP_CMD, strlen(CDT_STOP_CMD)) == 0) {
if ((cdt->cdt_state == CDT_STOPPING) ||
(cdt->cdt_state == CDT_STOPPED)) {
CERROR("%s: Coordinator already stopped\n",
} else {
rc = mdt_hsm_cdt_stop(mdt);
}
- } else if (strcmp(kernbuf, CDT_DISABLE_CMD) == 0) {
+ } else if (strncmp(buffer, CDT_DISABLE_CMD,
+ strlen(CDT_DISABLE_CMD)) == 0) {
if ((cdt->cdt_state == CDT_STOPPING) ||
(cdt->cdt_state == CDT_STOPPED)) {
CERROR("%s: Coordinator is stopped\n",
} else {
rc = set_cdt_state(cdt, CDT_DISABLE);
}
- } else if (strcmp(kernbuf, CDT_PURGE_CMD) == 0) {
+ } else if (strncmp(buffer, CDT_PURGE_CMD,
+ strlen(CDT_PURGE_CMD)) == 0) {
rc = hsm_cancel_all_actions(mdt);
- } else if (strcmp(kernbuf, CDT_HELP_CMD) == 0) {
+ } else if (strncmp(buffer, CDT_HELP_CMD,
+ strlen(CDT_HELP_CMD)) == 0) {
usage = 1;
} else {
usage = 1;
RETURN(count);
}
-int mdt_hsm_cdt_control_seq_show(struct seq_file *m, void *data)
+ssize_t hsm_control_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
- struct coordinator *cdt;
- ENTRY;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
+ struct coordinator *cdt;
cdt = &(mdt_dev(obd->obd_lu_dev)->mdt_coordinator);
- seq_printf(m, "%s\n", cdt_mdt_state2str(cdt->cdt_state));
-
- RETURN(0);
+ return scnprintf(buf, PAGE_SIZE, "%s\n",
+ cdt_mdt_state2str(cdt->cdt_state));
}
static int
&cdt->cdt_other_request_mask);
}
-static int mdt_hsm_cdt_raolu_seq_show(struct seq_file *m, void *data)
+static ssize_t remove_archive_on_last_unlink_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct mdt_device *mdt = m->private;
- struct coordinator *cdt = &mdt->mdt_coordinator;
- ENTRY;
+ struct coordinator *cdt = container_of(kobj, struct coordinator,
+ cdt_hsm_kobj);
- seq_printf(m, "%d\n", (int)cdt->cdt_remove_archive_on_last_unlink);
- RETURN(0);
+ return scnprintf(buf, PAGE_SIZE, "%u\n",
+ cdt->cdt_remove_archive_on_last_unlink);
}
-static ssize_t
-mdt_hsm_cdt_raolu_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
-
+static ssize_t remove_archive_on_last_unlink_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct seq_file *m = file->private_data;
- struct mdt_device *mdt = m->private;
- struct coordinator *cdt = &mdt->mdt_coordinator;
+ struct coordinator *cdt = container_of(kobj, struct coordinator,
+ cdt_hsm_kobj);
bool val;
int rc;
- ENTRY;
- rc = kstrtobool_from_user(buffer, count, &val);
+ rc = kstrtobool(buffer, &val);
if (rc < 0)
- RETURN(rc);
+ return rc;
cdt->cdt_remove_archive_on_last_unlink = val;
- RETURN(count);
+ return count;
}
+LUSTRE_RW_ATTR(remove_archive_on_last_unlink);
+
+LDEBUGFS_SEQ_FOPS(mdt_hsm_user_request_mask);
+LDEBUGFS_SEQ_FOPS(mdt_hsm_group_request_mask);
+LDEBUGFS_SEQ_FOPS(mdt_hsm_other_request_mask);
-LPROC_SEQ_FOPS(mdt_hsm_cdt_loop_period);
-LPROC_SEQ_FOPS(mdt_hsm_cdt_grace_delay);
-LPROC_SEQ_FOPS(mdt_hsm_cdt_active_req_timeout);
-LPROC_SEQ_FOPS(mdt_hsm_cdt_max_requests);
-LPROC_SEQ_FOPS(mdt_hsm_cdt_default_archive_id);
-LPROC_SEQ_FOPS(mdt_hsm_user_request_mask);
-LPROC_SEQ_FOPS(mdt_hsm_group_request_mask);
-LPROC_SEQ_FOPS(mdt_hsm_other_request_mask);
-LPROC_SEQ_FOPS(mdt_hsm_cdt_raolu);
-
-/* Read-only proc files for request counters */
-static int mdt_hsm_cdt_archive_count_seq_show(struct seq_file *m, void *data)
+/* Read-only sysfs files for request counters */
+static ssize_t archive_count_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct mdt_device *mdt = m->private;
- struct coordinator *cdt = &mdt->mdt_coordinator;
- ENTRY;
+ struct coordinator *cdt = container_of(kobj, struct coordinator,
+ cdt_hsm_kobj);
- seq_printf(m, "%d\n", atomic_read(&cdt->cdt_archive_count));
- RETURN(0);
+ return scnprintf(buf, PAGE_SIZE, "%d\n",
+ atomic_read(&cdt->cdt_archive_count));
}
+LUSTRE_RO_ATTR(archive_count);
-static int mdt_hsm_cdt_restore_count_seq_show(struct seq_file *m, void *data)
+static ssize_t restore_count_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct mdt_device *mdt = m->private;
- struct coordinator *cdt = &mdt->mdt_coordinator;
- ENTRY;
+ struct coordinator *cdt = container_of(kobj, struct coordinator,
+ cdt_hsm_kobj);
- seq_printf(m, "%d\n", atomic_read(&cdt->cdt_restore_count));
- RETURN(0);
+ return scnprintf(buf, PAGE_SIZE, "%d\n",
+ atomic_read(&cdt->cdt_restore_count));
}
+LUSTRE_RO_ATTR(restore_count);
-static int mdt_hsm_cdt_remove_count_seq_show(struct seq_file *m, void *data)
+static ssize_t remove_count_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct mdt_device *mdt = m->private;
- struct coordinator *cdt = &mdt->mdt_coordinator;
- ENTRY;
+ struct coordinator *cdt = container_of(kobj, struct coordinator,
+ cdt_hsm_kobj);
- seq_printf(m, "%d\n", atomic_read(&cdt->cdt_remove_count));
- RETURN(0);
+ return scnprintf(buf, PAGE_SIZE, "%d\n",
+ atomic_read(&cdt->cdt_remove_count));
}
-
-LPROC_SEQ_FOPS_RO(mdt_hsm_cdt_archive_count);
-LPROC_SEQ_FOPS_RO(mdt_hsm_cdt_restore_count);
-LPROC_SEQ_FOPS_RO(mdt_hsm_cdt_remove_count);
+LUSTRE_RO_ATTR(remove_count);
static struct lprocfs_vars lprocfs_mdt_hsm_vars[] = {
{ .name = "agents",
{ .name = "actions",
.fops = &mdt_hsm_actions_fops,
.proc_mode = 0444 },
- { .name = "default_archive_id",
- .fops = &mdt_hsm_cdt_default_archive_id_fops },
- { .name = "grace_delay",
- .fops = &mdt_hsm_cdt_grace_delay_fops },
- { .name = "loop_period",
- .fops = &mdt_hsm_cdt_loop_period_fops },
- { .name = "max_requests",
- .fops = &mdt_hsm_cdt_max_requests_fops },
{ .name = "policy",
.fops = &mdt_hsm_policy_fops },
- { .name = "active_request_timeout",
- .fops = &mdt_hsm_cdt_active_req_timeout_fops },
{ .name = "active_requests",
.fops = &mdt_hsm_active_requests_fops },
{ .name = "user_request_mask",
.fops = &mdt_hsm_group_request_mask_fops, },
{ .name = "other_request_mask",
.fops = &mdt_hsm_other_request_mask_fops, },
- { .name = "remove_archive_on_last_unlink",
- .fops = &mdt_hsm_cdt_raolu_fops, },
- { .name = "archive_count",
- .fops = &mdt_hsm_cdt_archive_count_fops, },
- { .name = "restore_count",
- .fops = &mdt_hsm_cdt_restore_count_fops, },
- { .name = "remove_count",
- .fops = &mdt_hsm_cdt_remove_count_fops, },
{ 0 }
};
+
+static struct attribute *hsm_attrs[] = {
+ &lustre_attr_loop_period.attr,
+ &lustre_attr_grace_delay.attr,
+ &lustre_attr_active_request_timeout.attr,
+ &lustre_attr_max_requests.attr,
+ &lustre_attr_default_archive_id.attr,
+ &lustre_attr_remove_archive_on_last_unlink.attr,
+ &lustre_attr_archive_count.attr,
+ &lustre_attr_restore_count.attr,
+ &lustre_attr_remove_count.attr,
+ NULL,
+};
+
+static void hsm_kobj_release(struct kobject *kobj)
+{
+ struct coordinator *cdt = container_of(kobj, struct coordinator,
+ cdt_hsm_kobj);
+
+ debugfs_remove_recursive(cdt->cdt_debugfs_dir);
+ cdt->cdt_debugfs_dir = NULL;
+
+ complete(&cdt->cdt_kobj_unregister);
+}
+
+static struct kobj_type hsm_ktype = {
+ .default_attrs = hsm_attrs,
+ .sysfs_ops = &lustre_sysfs_ops,
+ .release = hsm_kobj_release,
+};
+
+/**
+ * create sysfs entries for coordinator
+ * \param mdt [IN]
+ * \retval 0 success
+ * \retval -ve failure
+ */
+int hsm_cdt_tunables_init(struct mdt_device *mdt)
+{
+ struct coordinator *cdt = &mdt->mdt_coordinator;
+ struct obd_device *obd = mdt2obd_dev(mdt);
+ int rc;
+
+ init_completion(&cdt->cdt_kobj_unregister);
+ rc = kobject_init_and_add(&cdt->cdt_hsm_kobj, &hsm_ktype,
+ &obd->obd_kset.kobj, "%s", "hsm");
+ if (rc) {
+ kobject_put(&cdt->cdt_hsm_kobj);
+ return rc;
+ }
+
+ /* init debugfs entries, failure is not critical */
+ cdt->cdt_debugfs_dir = ldebugfs_register("hsm",
+ obd->obd_debugfs_entry,
+ lprocfs_mdt_hsm_vars, mdt);
+ if (IS_ERR_OR_NULL(cdt->cdt_debugfs_dir)) {
+ rc = cdt->cdt_debugfs_dir ? PTR_ERR(cdt->cdt_debugfs_dir) :
+ -ENOMEM;
+ CERROR("%s: Cannot create 'hsm' directory in mdt proc dir, rc = %d\n",
+ mdt_obd_name(mdt), rc);
+ cdt->cdt_debugfs_dir = NULL;
+ kobject_put(&cdt->cdt_hsm_kobj);
+ return rc;
+ }
+
+ return 0;
+}
+
+/**
+ * remove sysfs entries for coordinator
+ *
+ * @mdt
+ */
+void hsm_cdt_tunables_fini(struct mdt_device *mdt)
+{
+ struct coordinator *cdt = &mdt->mdt_coordinator;
+
+ kobject_put(&cdt->cdt_hsm_kobj);
+ wait_for_completion(&cdt->cdt_kobj_unregister);
+}
ping_evictor_stop();
/* Remove the HSM /proc entry so the coordinator cannot be
- * restarted by a user while it's shutting down. */
- hsm_cdt_procfs_fini(m);
+ * restarted by a user while it's shutting down.
+ */
mdt_hsm_cdt_stop(m);
mdt_llog_ctxt_unclone(env, m, LLOG_AGENT_ORIG_CTXT);
/* Calling the cleanup functions in the same order as in the mdt_init0
* error path
*/
- mdt_procfs_fini(m);
+ mdt_tunables_fini(m);
target_recovery_fini(obd);
upcall_cache_cleanup(m->mdt_identity_cache);
GOTO(err_free_hsm, rc);
}
- rc = mdt_procfs_init(m, dev);
+ rc = mdt_tunables_init(m, dev);
if (rc) {
CERROR("Can't init MDT lprocfs, rc %d\n", rc);
GOTO(err_recovery, rc);
RETURN(0);
err_procfs:
- mdt_procfs_fini(m);
+ mdt_tunables_fini(m);
err_recovery:
upcall_cache_cleanup(m->mdt_identity_cache);
m->mdt_identity_cache = NULL;
switch (cfg->lcfg_command) {
case LCFG_PARAM: {
- struct obd_device *obd = d->ld_obd;
-
+ struct obd_device *obd = d->ld_obd;
/* For interoperability */
- struct cfg_interop_param *ptr = NULL;
- struct lustre_cfg *old_cfg = NULL;
- char *param = NULL;
+ struct cfg_interop_param *ptr = NULL;
+ struct lustre_cfg *old_cfg = NULL;
+ char *param = NULL;
+ ssize_t count;
param = lustre_cfg_string(cfg, 1);
if (param == NULL) {
}
}
- rc = class_process_proc_param(PARAM_MDT, obd->obd_vars,
- cfg, obd);
- if (rc > 0 || rc == -ENOSYS) {
+ count = class_modify_config(cfg, PARAM_MDT,
+ &obd->obd_kset.kobj);
+ if (count < 0) {
+ struct coordinator *cdt = &m->mdt_coordinator;
+
/* is it an HSM var ? */
- rc = class_process_proc_param(PARAM_HSM,
- hsm_cdt_get_proc_vars(),
- cfg, obd);
- if (rc > 0 || rc == -ENOSYS)
+ count = class_modify_config(cfg, PARAM_HSM,
+ &cdt->cdt_hsm_kobj);
+ if (count < 0)
/* we don't understand; pass it on */
rc = next->ld_ops->ldo_process_config(env, next,
cfg);
+ else
+ rc = count > 0 ? 0 : count;
+ } else {
+ rc = count > 0 ? 0 : count;
}
if (old_cfg)
* seq_file method called to start access to /proc file
* get llog context + llog handle
*/
-static void *mdt_hsm_actions_proc_start(struct seq_file *s, loff_t *pos)
+static void *mdt_hsm_actions_debugfs_start(struct seq_file *s, loff_t *pos)
{
struct agent_action_iterator *aai = s->private;
ENTRY;
RETURN(aai);
}
-static void *mdt_hsm_actions_proc_next(struct seq_file *s, void *v,
+static void *mdt_hsm_actions_debugfs_next(struct seq_file *s, void *v,
loff_t *pos)
{
RETURN(NULL);
}
/**
- * mdt_hsm_actions_proc_show() is called at for each seq record
+ * mdt_hsm_actions_debugfs_show() is called at for each seq record
* process the llog, with a cb which fill the file_seq buffer
* to be faster, one show will fill multiple records
*/
-static int mdt_hsm_actions_proc_show(struct seq_file *s, void *v)
+static int mdt_hsm_actions_debugfs_show(struct seq_file *s, void *v)
{
struct agent_action_iterator *aai = s->private;
struct coordinator *cdt = &aai->aai_mdt->mdt_coordinator;
* seq_file method called to stop access to /proc file
* clean + put llog context
*/
-static void mdt_hsm_actions_proc_stop(struct seq_file *s, void *v)
+static void mdt_hsm_actions_debugfs_stop(struct seq_file *s, void *v)
{
struct agent_action_iterator *aai = s->private;
ENTRY;
return;
}
-static const struct seq_operations mdt_hsm_actions_proc_ops = {
- .start = mdt_hsm_actions_proc_start,
- .next = mdt_hsm_actions_proc_next,
- .show = mdt_hsm_actions_proc_show,
- .stop = mdt_hsm_actions_proc_stop,
+static const struct seq_operations mdt_hsm_actions_debugfs_ops = {
+ .start = mdt_hsm_actions_debugfs_start,
+ .next = mdt_hsm_actions_debugfs_next,
+ .show = mdt_hsm_actions_debugfs_show,
+ .stop = mdt_hsm_actions_debugfs_stop,
};
-static int lprocfs_open_hsm_actions(struct inode *inode, struct file *file)
+static int ldebugfs_open_hsm_actions(struct inode *inode, struct file *file)
{
struct agent_action_iterator *aai;
struct seq_file *s;
struct mdt_device *mdt;
ENTRY;
- rc = seq_open(file, &mdt_hsm_actions_proc_ops);
+ rc = seq_open(file, &mdt_hsm_actions_debugfs_ops);
if (rc)
RETURN(rc);
if (rc)
GOTO(err, rc);
- /* mdt is saved in proc_dir_entry->data by
- * mdt_coordinator_procfs_init() calling lprocfs_register()
+ /* mdt is saved in seq_file->data by
+ * mdt_coordinator_tunables_init() calling
+ * debugfs_register()
*/
- mdt = (struct mdt_device *)PDE_DATA(inode);
+ mdt = inode->i_private;
aai->aai_mdt = mdt;
s = file->private_data;
s->private = aai;
GOTO(out, rc = 0);
err:
- lprocfs_seq_release(inode, file);
+ seq_release(inode, file);
if (aai && aai->aai_env.le_ses)
OBD_FREE_PTR(aai->aai_env.le_ses);
if (aai)
}
/**
- * lprocfs_release_hsm_actions() is called at end of /proc access.
+ * ldebugfs_release_hsm_actions() is called at end of /proc access.
* It frees allocated resources and calls cleanup lprocfs methods.
*/
-static int lprocfs_release_hsm_actions(struct inode *inode, struct file *file)
+static int ldebugfs_release_hsm_actions(struct inode *inode, struct file *file)
{
struct seq_file *seq = file->private_data;
struct agent_action_iterator *aai = seq->private;
OBD_FREE_PTR(aai);
}
- return lprocfs_seq_release(inode, file);
+ return seq_release(inode, file);
}
/* Methods to access HSM action list LLOG through /proc */
const struct file_operations mdt_hsm_actions_fops = {
.owner = THIS_MODULE,
- .open = lprocfs_open_hsm_actions,
+ .open = ldebugfs_open_hsm_actions,
.read = seq_read,
.llseek = seq_lseek,
- .release = lprocfs_release_hsm_actions,
+ .release = ldebugfs_release_hsm_actions,
};
}
/**
- * seq_file method called to start access to /proc file
+ * seq_file method called to start access to debugfs file
*/
-static void *mdt_hsm_agent_proc_start(struct seq_file *s, loff_t *off)
+static void *mdt_hsm_agent_debugfs_start(struct seq_file *s, loff_t *off)
{
struct mdt_device *mdt = s->private;
struct coordinator *cdt = &mdt->mdt_coordinator;
* seq_file method called to get next item
* just returns NULL at eof
*/
-static void *mdt_hsm_agent_proc_next(struct seq_file *s, void *v, loff_t *p)
+static void *mdt_hsm_agent_debugfs_next(struct seq_file *s, void *v, loff_t *p)
{
struct mdt_device *mdt = s->private;
struct coordinator *cdt = &mdt->mdt_coordinator;
/**
*/
-static int mdt_hsm_agent_proc_show(struct seq_file *s, void *v)
+static int mdt_hsm_agent_debugfs_show(struct seq_file *s, void *v)
{
struct list_head *pos = v;
struct hsm_agent *ha;
}
/**
- * seq_file method called to stop access to /proc file
+ * seq_file method called to stop access to debugfs file
*/
-static void mdt_hsm_agent_proc_stop(struct seq_file *s, void *v)
+static void mdt_hsm_agent_debugfs_stop(struct seq_file *s, void *v)
{
struct mdt_device *mdt = s->private;
struct coordinator *cdt = &mdt->mdt_coordinator;
up_read(&cdt->cdt_agent_lock);
}
-/* hsm agent list proc functions */
-static const struct seq_operations mdt_hsm_agent_proc_ops = {
- .start = mdt_hsm_agent_proc_start,
- .next = mdt_hsm_agent_proc_next,
- .show = mdt_hsm_agent_proc_show,
- .stop = mdt_hsm_agent_proc_stop,
+/* hsm agent list debugfs functions */
+static const struct seq_operations mdt_hsm_agent_debugfs_ops = {
+ .start = mdt_hsm_agent_debugfs_start,
+ .next = mdt_hsm_agent_debugfs_next,
+ .show = mdt_hsm_agent_debugfs_show,
+ .stop = mdt_hsm_agent_debugfs_stop,
};
/**
- * public function called at open of /proc file to get
+ * public function called at open of debugfs file to get
* list of agents
*/
-static int lprocfs_open_hsm_agent(struct inode *inode, struct file *file)
+static int ldebugfs_open_hsm_agent(struct inode *inode, struct file *file)
{
struct seq_file *s;
int rc;
ENTRY;
- rc = seq_open(file, &mdt_hsm_agent_proc_ops);
+ rc = seq_open(file, &mdt_hsm_agent_debugfs_ops);
if (rc)
RETURN(rc);
s = file->private_data;
- s->private = PDE_DATA(inode);
+ s->private = inode->i_private;
RETURN(rc);
}
/* methods to access hsm agent list */
const struct file_operations mdt_hsm_agent_fops = {
.owner = THIS_MODULE,
- .open = lprocfs_open_hsm_agent,
+ .open = ldebugfs_open_hsm_agent,
.read = seq_read,
.llseek = seq_lseek,
- .release = lprocfs_seq_release,
+ .release = seq_release,
};
* public function called at open of /proc file to get
* list of agents
*/
-static int lprocfs_open_hsm_active_requests(struct inode *inode,
- struct file *file)
+static int ldebugfs_open_hsm_active_requests(struct inode *inode,
+ struct file *file)
{
struct seq_file *s;
int rc;
RETURN(rc);
}
s = file->private_data;
- s->private = PDE_DATA(inode);
+ s->private = inode->i_private;
RETURN(rc);
}
/* methods to access hsm request list */
const struct file_operations mdt_hsm_active_requests_fops = {
.owner = THIS_MODULE,
- .open = lprocfs_open_hsm_active_requests,
+ .open = ldebugfs_open_hsm_active_requests,
.read = seq_read,
.llseek = seq_lseek,
- .release = lprocfs_seq_release,
+ .release = seq_release,
};
struct lu_env cdt_env; /**< coordinator lustre
* env */
struct lu_context cdt_session; /** session for lu_ucred */
- struct proc_dir_entry *cdt_proc_dir; /**< cdt /proc directory */
+ struct dentry *cdt_debugfs_dir; /**< cdt debugfs directory */
+ struct completion cdt_kobj_unregister;
+ struct kobject cdt_hsm_kobj; /* hsm sysfs object */
__u64 cdt_policy; /**< policy flags */
enum cdt_states cdt_state; /**< state */
struct mutex cdt_state_lock; /**< cdt_state lock */
* list */
struct mutex cdt_restore_lock; /**< protect restore
* list */
- time64_t cdt_loop_period; /**< llog scan period */
- time64_t cdt_grace_delay; /**< request grace
+ time_t cdt_loop_period; /**< llog scan period */
+ time_t cdt_grace_delay; /**< request grace
* delay */
- time64_t cdt_active_req_timeout; /**< request timeout */
+ time_t cdt_active_req_timeout; /**< request timeout */
__u32 cdt_default_archive_id; /**< archive id used
* when none are
* specified */
- __u64 cdt_max_requests; /**< max count of started
+ u64 cdt_max_requests; /**< max count of started
* requests */
/** Current count of active requests */
atomic_t cdt_request_count; /** total */
cdt->cdt_event = true;
}
-/* coordinator control /proc interface */
-ssize_t mdt_hsm_cdt_control_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off);
-int mdt_hsm_cdt_control_seq_show(struct seq_file *m, void *data);
-int hsm_cdt_procfs_init(struct mdt_device *mdt);
-void hsm_cdt_procfs_fini(struct mdt_device *mdt);
-struct lprocfs_vars *hsm_cdt_get_proc_vars(void);
+/* coordinator control sysfs interface */
+ssize_t hsm_control_show(struct kobject *kobj, struct attribute *attr,
+ char *buf);
+ssize_t hsm_control_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count);
+int hsm_cdt_tunables_init(struct mdt_device *mdt);
+void hsm_cdt_tunables_fini(struct mdt_device *mdt);
/* md_hsm helpers */
struct mdt_object *mdt_hsm_get_md_hsm(struct mdt_thread_info *mti,
const struct lu_fid *fid,
void mdt_counter_incr(struct ptlrpc_request *req, int opcode);
void mdt_stats_counter_init(struct lprocfs_stats *stats);
-int mdt_procfs_init(struct mdt_device *mdt, const char *name);
-void mdt_procfs_fini(struct mdt_device *mdt);
+int mdt_tunables_init(struct mdt_device *mdt, const char *name);
+void mdt_tunables_fini(struct mdt_device *mdt);
/* lustre/mdt_mdt_lproc.c */
int lprocfs_mdt_open_files_seq_open(struct inode *inode,
(unsigned int)ma->ma_attr.la_size);
}
-static int mdt_identity_expire_seq_show(struct seq_file *m, void *data)
+static ssize_t identity_expire_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
- seq_printf(m, "%lld\n", mdt->mdt_identity_cache->uc_entry_expire);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%lld\n",
+ mdt->mdt_identity_cache->uc_entry_expire);
}
-static ssize_t
-mdt_identity_expire_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t identity_expire_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
time64_t val;
int rc;
- rc = kstrtoll_from_user(buffer, count, 0, &val);
+ rc = kstrtoll(buffer, 10, &val);
if (rc)
return rc;
return count;
}
-LPROC_SEQ_FOPS(mdt_identity_expire);
+LUSTRE_RW_ATTR(identity_expire);
-static int mdt_identity_acquire_expire_seq_show(struct seq_file *m, void *data)
+static ssize_t identity_acquire_expire_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
- seq_printf(m, "%lld\n", mdt->mdt_identity_cache->uc_acquire_expire);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%lld\n",
+ mdt->mdt_identity_cache->uc_acquire_expire);
}
-static ssize_t
-mdt_identity_acquire_expire_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t identity_acquire_expire_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
time64_t val;
int rc;
- rc = kstrtoll_from_user(buffer, count, 0, &val);
+ rc = kstrtoll(buffer, 0, &val);
if (rc)
return rc;
return count;
}
-LPROC_SEQ_FOPS(mdt_identity_acquire_expire);
+LUSTRE_RW_ATTR(identity_acquire_expire);
-static int mdt_identity_upcall_seq_show(struct seq_file *m, void *data)
+static ssize_t identity_upcall_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
struct upcall_cache *hash = mdt->mdt_identity_cache;
+ int rc;
down_read(&hash->uc_upcall_rwsem);
- seq_printf(m, "%s\n", hash->uc_upcall);
+ rc = scnprintf(buf, PAGE_SIZE, "%s\n", hash->uc_upcall);
up_read(&hash->uc_upcall_rwsem);
- return 0;
+ return rc;
}
-static ssize_t
-mdt_identity_upcall_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t identity_upcall_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
- struct upcall_cache *hash = mdt->mdt_identity_cache;
- int rc;
- char *kernbuf;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
+ struct upcall_cache *hash = mdt->mdt_identity_cache;
if (count >= UC_CACHE_UPCALL_MAXPATH) {
CERROR("%s: identity upcall too long\n", mdt_obd_name(mdt));
return -EINVAL;
}
- OBD_ALLOC(kernbuf, count + 1);
- if (kernbuf == NULL)
- GOTO(failed, rc = -ENOMEM);
- if (copy_from_user(kernbuf, buffer, count))
- GOTO(failed, rc = -EFAULT);
/* Remove any extraneous bits from the upcall (e.g. linefeeds) */
down_write(&hash->uc_upcall_rwsem);
- sscanf(kernbuf, "%s", hash->uc_upcall);
+ count = sscanf(buffer, "%s", hash->uc_upcall);
up_write(&hash->uc_upcall_rwsem);
if (strcmp(hash->uc_name, mdt_obd_name(mdt)) != 0)
CDEBUG(D_CONFIG, "%s: identity upcall set to %s\n", mdt_obd_name(mdt),
hash->uc_upcall);
- OBD_FREE(kernbuf, count + 1);
RETURN(count);
-
- failed:
- if (kernbuf)
- OBD_FREE(kernbuf, count + 1);
- RETURN(rc);
}
-LPROC_SEQ_FOPS(mdt_identity_upcall);
+LUSTRE_RW_ATTR(identity_upcall);
-static ssize_t
-lprocfs_identity_flush_seq_write(struct file *file, const char __user *buffer,
- size_t count, void *data)
+static ssize_t identity_flush_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
int uid;
int rc;
- rc = kstrtoint_from_user(buffer, count, 0, &uid);
+ rc = kstrtoint(buffer, 0, &uid);
if (rc)
return rc;
mdt_flush_identity(mdt->mdt_identity_cache, uid);
return count;
}
-LPROC_SEQ_FOPS_WR_ONLY(mdt, identity_flush);
+LUSTRE_WO_ATTR(identity_flush);
static ssize_t
lprocfs_identity_info_seq_write(struct file *file, const char __user *buffer,
#undef BUFLEN
-static int mdt_evict_tgt_nids_seq_show(struct seq_file *m, void *data)
+static ssize_t evict_tgt_nids_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
- seq_printf(m, "%u\n", mdt->mdt_opts.mo_evict_tgt_nids);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%u\n",
+ mdt->mdt_opts.mo_evict_tgt_nids);
}
-static ssize_t
-mdt_evict_tgt_nids_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t evict_tgt_nids_store(struct kobject *kobj,
+ struct attribute *attr, const char *buffer,
+ size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
bool val;
int rc;
- rc = kstrtobool_from_user(buffer, count, &val);
+ rc = kstrtobool(buffer, &val);
if (rc)
return rc;
mdt->mdt_opts.mo_evict_tgt_nids = val;
return count;
}
-LPROC_SEQ_FOPS(mdt_evict_tgt_nids);
+LUSTRE_RW_ATTR(evict_tgt_nids);
-static int mdt_cos_seq_show(struct seq_file *m, void *data)
+static ssize_t commit_on_sharing_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
- seq_printf(m, "%u\n", mdt_cos_is_enabled(mdt));
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%u\n", mdt_cos_is_enabled(mdt));
}
-static ssize_t
-mdt_cos_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t commit_on_sharing_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
bool val;
int rc;
- rc = kstrtobool_from_user(buffer, count, &val);
+ rc = kstrtobool(buffer, &val);
if (rc)
return rc;
mdt_enable_cos(mdt, val);
return count;
}
-LPROC_SEQ_FOPS(mdt_cos);
+LUSTRE_RW_ATTR(commit_on_sharing);
static int mdt_root_squash_seq_show(struct seq_file *m, void *data)
{
}
LPROC_SEQ_FOPS(mdt_nosquash_nids);
-static int mdt_enable_remote_dir_seq_show(struct seq_file *m, void *data)
+static ssize_t enable_remote_dir_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
- seq_printf(m, "%u\n", mdt->mdt_enable_remote_dir);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%u\n", mdt->mdt_enable_remote_dir);
}
-static ssize_t
-mdt_enable_remote_dir_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t enable_remote_dir_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
bool val;
int rc;
- rc = kstrtobool_from_user(buffer, count, &val);
+ rc = kstrtobool(buffer, &val);
if (rc)
return rc;
mdt->mdt_enable_remote_dir = val;
return count;
}
-LPROC_SEQ_FOPS(mdt_enable_remote_dir);
+LUSTRE_RW_ATTR(enable_remote_dir);
-static int mdt_enable_remote_dir_gid_seq_show(struct seq_file *m, void *data)
+static ssize_t enable_remote_dir_gid_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
- seq_printf(m, "%d\n",
- (int)mdt->mdt_enable_remote_dir_gid);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%d\n",
+ (int)mdt->mdt_enable_remote_dir_gid);
}
-static ssize_t
-mdt_enable_remote_dir_gid_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t enable_remote_dir_gid_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
int val;
int rc;
- rc = kstrtoint_from_user(buffer, count, 0, &val);
+ rc = kstrtoint(buffer, 0, &val);
if (rc)
return rc;
mdt->mdt_enable_remote_dir_gid = val;
return count;
}
-LPROC_SEQ_FOPS(mdt_enable_remote_dir_gid);
+LUSTRE_RW_ATTR(enable_remote_dir_gid);
-static int mdt_enable_striped_dir_seq_show(struct seq_file *m, void *data)
+static ssize_t enable_striped_dir_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
- seq_printf(m, "%u\n", mdt->mdt_enable_striped_dir);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%u\n", mdt->mdt_enable_striped_dir);
}
-static ssize_t
-mdt_enable_striped_dir_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t enable_striped_dir_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
bool val;
int rc;
- rc = kstrtobool_from_user(buffer, count, &val);
+ rc = kstrtobool(buffer, &val);
if (rc)
return rc;
mdt->mdt_enable_striped_dir = val;
return count;
}
-LPROC_SEQ_FOPS(mdt_enable_striped_dir);
+LUSTRE_RW_ATTR(enable_striped_dir);
-static int mdt_enable_dir_migration_seq_show(struct seq_file *m, void *data)
+static ssize_t enable_dir_migration_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
- seq_printf(m, "%u\n", mdt->mdt_enable_dir_migration);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%u\n", mdt->mdt_enable_dir_migration);
}
-static ssize_t
-mdt_enable_dir_migration_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t enable_dir_migration_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
bool val;
int rc;
- rc = kstrtobool_from_user(buffer, count, &val);
+ rc = kstrtobool(buffer, &val);
if (rc)
return rc;
mdt->mdt_enable_dir_migration = val;
return count;
}
-LPROC_SEQ_FOPS(mdt_enable_dir_migration);
+LUSTRE_RW_ATTR(enable_dir_migration);
/**
* Show MDT async commit count.
*
- * \param[in] m seq_file handle
- * \param[in] data unused for single entry
+ * @m seq_file handle
+ * @data unused for single entry
*
- * \retval 0 on success
- * \retval negative value on error
+ * Return: 0 on success
+ * negative value on error
*/
-static int mdt_async_commit_count_seq_show(struct seq_file *m, void *data)
+static ssize_t async_commit_count_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
- seq_printf(m, "%d\n", atomic_read(&mdt->mdt_async_commit_count));
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%d\n",
+ atomic_read(&mdt->mdt_async_commit_count));
}
-static ssize_t
-mdt_async_commit_count_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t async_commit_count_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
int val;
int rc;
- rc = kstrtoint_from_user(buffer, count, 0, &val);
+ rc = kstrtoint(buffer, 10, &val);
if (rc)
return rc;
return count;
}
-LPROC_SEQ_FOPS(mdt_async_commit_count);
+LUSTRE_RW_ATTR(async_commit_count);
/**
* Show MDT sync count.
* \retval 0 on success
* \retval negative value on error
*/
-static int mdt_sync_count_seq_show(struct seq_file *m, void *data)
+static ssize_t sync_count_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct lu_target *tgt = obd->u.obt.obt_lut;
- seq_printf(m, "%d\n", atomic_read(&tgt->lut_sync_count));
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%d\n",
+ atomic_read(&tgt->lut_sync_count));
}
-static ssize_t
-mdt_sync_count_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t sync_count_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct lu_target *tgt = obd->u.obt.obt_lut;
int val;
int rc;
- rc = kstrtoint_from_user(buffer, count, 0, &val);
+ rc = kstrtoint(buffer, 0, &val);
if (rc)
return rc;
return count;
}
-LPROC_SEQ_FOPS(mdt_sync_count);
+LUSTRE_RW_ATTR(sync_count);
static char *dom_open_lock_modes[NUM_DOM_LOCK_ON_OPEN_MODES] = {
[NO_DOM_LOCK_ON_OPEN] = "never",
* \retval 0 on success
* \retval negative value on error
*/
-static int mdt_dom_lock_seq_show(struct seq_file *m, void *data)
+static ssize_t dom_lock_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
- seq_printf(m, "%s\n", dom_open_lock_modes[mdt->mdt_opts.mo_dom_lock]);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%s\n",
+ dom_open_lock_modes[mdt->mdt_opts.mo_dom_lock]);
}
/**
* \retval \a count on success
* \retval negative number on error
*/
-static ssize_t
-mdt_dom_lock_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t dom_lock_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
- char kernbuf[DOM_LOCK_MODES_MAXLEN];
int val = -1;
int i, rc;
- if (count == 0 || count >= sizeof(kernbuf))
+ if (count == 0 || count >= DOM_LOCK_MODES_MAXLEN)
return -EINVAL;
- if (copy_from_user(kernbuf, buffer, count))
- return -EFAULT;
-
- kernbuf[count] = 0;
- if (kernbuf[count - 1] == '\n')
- kernbuf[count - 1] = 0;
-
for (i = 0 ; i < NUM_DOM_LOCK_ON_OPEN_MODES; i++) {
- if (strcmp(kernbuf, dom_open_lock_modes[i]) == 0) {
+ /* buffer might have '\n' but using strlen() avoids it */
+ if (strncmp(buffer, dom_open_lock_modes[i],
+ strlen(dom_open_lock_modes[i])) == 0) {
val = i;
break;
}
/* Legacy numeric codes */
if (val == -1) {
- rc = kstrtoint_from_user(buffer, count, 0, &val);
+ rc = kstrtoint(buffer, 0, &val);
if (rc)
return rc;
}
mdt->mdt_opts.mo_dom_lock = val;
return count;
}
-LPROC_SEQ_FOPS(mdt_dom_lock);
+LUSTRE_RW_ATTR(dom_lock);
/**
* Show MDT policy for data prefetch on open for DoM files..
* \retval 0 on success
* \retval negative value on error
*/
-static int mdt_dom_read_open_seq_show(struct seq_file *m, void *data)
+static ssize_t dom_read_open_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
- seq_printf(m, "%u\n", !!mdt->mdt_opts.mo_dom_read_open);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%u\n",
+ !!mdt->mdt_opts.mo_dom_read_open);
}
/**
* \retval \a count on success
* \retval negative number on error
*/
-static ssize_t
-mdt_dom_read_open_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t dom_read_open_store(struct kobject *kobj,
+ struct attribute *attr, const char *buffer,
+ size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
bool val;
int rc;
- rc = kstrtobool_from_user(buffer, count, &val);
+ rc = kstrtobool(buffer, &val);
if (rc)
return rc;
mdt->mdt_opts.mo_dom_read_open = !!val;
return count;
}
-LPROC_SEQ_FOPS(mdt_dom_read_open);
+LUSTRE_RW_ATTR(dom_read_open);
-static int mdt_migrate_hsm_allowed_seq_show(struct seq_file *m, void *data)
+static ssize_t migrate_hsm_allowed_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
- seq_printf(m, "%u\n", (mdt->mdt_opts.mo_migrate_hsm_allowed != 0));
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%u\n",
+ mdt->mdt_opts.mo_migrate_hsm_allowed);
}
-static ssize_t
-mdt_migrate_hsm_allowed_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t migrate_hsm_allowed_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
bool val;
int rc;
- rc = kstrtobool_from_user(buffer, count, &val);
+ rc = kstrtobool(buffer, &val);
if (rc)
return rc;
mdt->mdt_opts.mo_migrate_hsm_allowed = val;
return count;
}
-LPROC_SEQ_FOPS(mdt_migrate_hsm_allowed);
+LUSTRE_RW_ATTR(migrate_hsm_allowed);
-static int mdt_readonly_seq_show(struct seq_file *m, void *data)
+static ssize_t readonly_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
- seq_printf(m, "%u\n", mdt->mdt_readonly);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%u\n", mdt->mdt_readonly);
}
-static ssize_t
-mdt_readonly_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t readonly_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
bool val;
int rc;
- rc = kstrtobool_from_user(buffer, count, &val);
+ rc = kstrtobool(buffer, &val);
if (rc)
return rc;
mdt->mdt_readonly = val;
return count;
}
-LPROC_SEQ_FOPS(mdt_readonly);
+LUSTRE_RW_ATTR(readonly);
-static int mdt_enable_remote_rename_seq_show(struct seq_file *m, void *data)
+static ssize_t enable_remote_rename_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
- seq_printf(m, "%u\n", mdt->mdt_enable_remote_rename);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%u\n",
+ mdt->mdt_enable_remote_rename);
}
-static ssize_t
-mdt_enable_remote_rename_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t enable_remote_rename_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
bool val;
int rc;
- rc = kstrtobool_from_user(buffer, count, &val);
+ rc = kstrtobool(buffer, &val);
if (rc)
return rc;
mdt->mdt_enable_remote_rename = val;
return count;
}
-LPROC_SEQ_FOPS(mdt_enable_remote_rename);
+LUSTRE_RW_ATTR(enable_remote_rename);
-LPROC_SEQ_FOPS_RO_TYPE(mdt, recovery_status);
-LPROC_SEQ_FOPS_RO_TYPE(mdt, num_exports);
-LPROC_SEQ_FOPS_RO_TYPE(mdt, target_instance);
LPROC_SEQ_FOPS_RO_TYPE(mdt, hash);
LPROC_SEQ_FOPS_WR_ONLY(mdt, mds_evict_client);
-LPROC_SEQ_FOPS_RW_TYPE(mdt, job_interval);
-LPROC_SEQ_FOPS_RW_TYPE(mdt, ir_factor);
+LUSTRE_RW_ATTR(job_cleanup_interval);
LPROC_SEQ_FOPS_RW_TYPE(mdt, nid_stats_clear);
-LPROC_SEQ_FOPS(mdt_hsm_cdt_control);
-
-LPROC_SEQ_FOPS_RW_TYPE(mdt, recovery_time_hard);
-LPROC_SEQ_FOPS_RW_TYPE(mdt, recovery_time_soft);
+LUSTRE_RW_ATTR(hsm_control);
-LPROC_SEQ_FOPS_RO(tgt_tot_dirty);
-LPROC_SEQ_FOPS_RO(tgt_tot_granted);
-LPROC_SEQ_FOPS_RO(tgt_tot_pending);
-LPROC_SEQ_FOPS(tgt_grant_compat_disable);
+LPROC_SEQ_FOPS_RO_TYPE(mdt, recovery_status);
+LUSTRE_RW_ATTR(recovery_time_hard);
+LUSTRE_RW_ATTR(recovery_time_soft);
+LUSTRE_RW_ATTR(ir_factor);
+
+LUSTRE_RO_ATTR(tot_dirty);
+LUSTRE_RO_ATTR(tot_granted);
+LUSTRE_RO_ATTR(tot_pending);
+LUSTRE_RW_ATTR(grant_compat_disable);
+LUSTRE_RO_ATTR(instance);
+
+LUSTRE_RO_ATTR(num_exports);
+
+static struct attribute *mdt_attrs[] = {
+ &lustre_attr_tot_dirty.attr,
+ &lustre_attr_tot_granted.attr,
+ &lustre_attr_tot_pending.attr,
+ &lustre_attr_grant_compat_disable.attr,
+ &lustre_attr_instance.attr,
+ &lustre_attr_recovery_time_hard.attr,
+ &lustre_attr_recovery_time_soft.attr,
+ &lustre_attr_ir_factor.attr,
+ &lustre_attr_num_exports.attr,
+ &lustre_attr_identity_expire.attr,
+ &lustre_attr_identity_acquire_expire.attr,
+ &lustre_attr_identity_upcall.attr,
+ &lustre_attr_identity_flush.attr,
+ &lustre_attr_evict_tgt_nids.attr,
+ &lustre_attr_enable_remote_dir.attr,
+ &lustre_attr_enable_remote_dir_gid.attr,
+ &lustre_attr_enable_striped_dir.attr,
+ &lustre_attr_enable_dir_migration.attr,
+ &lustre_attr_enable_remote_rename.attr,
+ &lustre_attr_commit_on_sharing.attr,
+ &lustre_attr_async_commit_count.attr,
+ &lustre_attr_sync_count.attr,
+ &lustre_attr_dom_lock.attr,
+ &lustre_attr_dom_read_open.attr,
+ &lustre_attr_migrate_hsm_allowed.attr,
+ &lustre_attr_hsm_control.attr,
+ &lustre_attr_job_cleanup_interval.attr,
+ &lustre_attr_readonly.attr,
+ NULL,
+};
static struct lprocfs_vars lprocfs_mdt_obd_vars[] = {
- { .name = "tot_dirty",
- .fops = &tgt_tot_dirty_fops },
- { .name = "tot_pending",
- .fops = &tgt_tot_pending_fops },
- { .name = "tot_granted",
- .fops = &tgt_tot_granted_fops },
- { .name = "grant_compat_disable",
- .fops = &tgt_grant_compat_disable_fops },
{ .name = "recovery_status",
.fops = &mdt_recovery_status_fops },
- { .name = "num_exports",
- .fops = &mdt_num_exports_fops },
- { .name = "identity_expire",
- .fops = &mdt_identity_expire_fops },
- { .name = "identity_acquire_expire",
- .fops = &mdt_identity_acquire_expire_fops },
- { .name = "identity_upcall",
- .fops = &mdt_identity_upcall_fops },
- { .name = "identity_flush",
- .fops = &mdt_identity_flush_fops },
{ .name = "identity_info",
.fops = &mdt_identity_info_fops },
{ .name = "site_stats",
.fops = &mdt_site_stats_fops },
{ .name = "evict_client",
.fops = &mdt_mds_evict_client_fops },
- { .name = "evict_tgt_nids",
- .fops = &mdt_evict_tgt_nids_fops },
{ .name = "hash_stats",
.fops = &mdt_hash_fops },
- { .name = "commit_on_sharing",
- .fops = &mdt_cos_fops },
{ .name = "root_squash",
.fops = &mdt_root_squash_fops },
{ .name = "nosquash_nids",
.fops = &mdt_nosquash_nids_fops },
- { .name = "instance",
- .fops = &mdt_target_instance_fops },
- { .name = "ir_factor",
- .fops = &mdt_ir_factor_fops },
- { .name = "job_cleanup_interval",
- .fops = &mdt_job_interval_fops },
- { .name = "enable_remote_dir",
- .fops = &mdt_enable_remote_dir_fops },
- { .name = "enable_remote_dir_gid",
- .fops = &mdt_enable_remote_dir_gid_fops },
- { .name = "enable_striped_dir",
- .fops = &mdt_enable_striped_dir_fops },
- { .name = "enable_dir_migration",
- .fops = &mdt_enable_dir_migration_fops },
- { .name = "enable_remote_rename",
- .fops = &mdt_enable_remote_rename_fops },
- { .name = "hsm_control",
- .fops = &mdt_hsm_cdt_control_fops },
- { .name = "recovery_time_hard",
- .fops = &mdt_recovery_time_hard_fops },
- { .name = "recovery_time_soft",
- .fops = &mdt_recovery_time_soft_fops },
- { .name = "async_commit_count",
- .fops = &mdt_async_commit_count_fops },
- { .name = "sync_count",
- .fops = &mdt_sync_count_fops },
- { .name = "dom_lock",
- .fops = &mdt_dom_lock_fops },
- { .name = "dom_read_open",
- .fops = &mdt_dom_read_open_fops },
- { .name = "migrate_hsm_allowed",
- .fops = &mdt_migrate_hsm_allowed_fops },
- { .name = "readonly",
- .fops = &mdt_readonly_fops },
{ NULL }
};
}
}
-int mdt_procfs_init(struct mdt_device *mdt, const char *name)
+int mdt_tunables_init(struct mdt_device *mdt, const char *name)
{
struct obd_device *obd = mdt2obd_dev(mdt);
int rc;
ENTRY;
LASSERT(name != NULL);
+ obd->obd_ktype.default_attrs = mdt_attrs;
obd->obd_vars = lprocfs_mdt_obd_vars;
rc = lprocfs_obd_setup(obd, true);
if (rc) {
return rc;
}
- rc = hsm_cdt_procfs_init(mdt);
+ rc = hsm_cdt_tunables_init(mdt);
if (rc) {
CERROR("%s: cannot create hsm proc entries: rc = %d\n",
mdt_obd_name(mdt), rc);
RETURN(rc);
}
-void mdt_procfs_fini(struct mdt_device *mdt)
+void mdt_tunables_fini(struct mdt_device *mdt)
{
struct obd_device *obd = mdt2obd_dev(mdt);
}
lprocfs_free_per_client_stats(obd);
- hsm_cdt_procfs_fini(mdt);
+ /* hsm_cdt_tunables is disabled earlier than this to avoid
+ * coordinator restart.
+ */
+ hsm_cdt_tunables_fini(mdt);
tgt_tunables_fini(&mdt->mdt_lut);
lprocfs_obd_cleanup(obd);
lprocfs_free_md_stats(obd);
return 0;
}
-LPROC_SEQ_FOPS_RO_TYPE(mgs, num_exports);
LPROC_SEQ_FOPS_RO_TYPE(mgs, hash);
LPROC_SEQ_FOPS_WR_ONLY(mgs, evict_client);
LPROC_SEQ_FOPS_RW_TYPE(mgs, ir_timeout);
static struct lprocfs_vars lprocfs_mgs_obd_vars[] = {
- { .name = "num_exports",
- .fops = &mgs_num_exports_fops },
{ .name = "hash_stats",
.fops = &mgs_hash_fops },
{ .name = "evict_client",
{ NULL }
};
+LUSTRE_RO_ATTR(num_exports);
+
static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr,
char *buf)
{
static struct attribute *mgs_attrs[] = {
&lustre_attr_fstype.attr,
&lustre_attr_mntdev.attr,
+ &lustre_attr_num_exports.attr,
NULL,
};
RETURN(0);
}
EXPORT_SYMBOL(lprocfs_job_stats_init);
+#endif /* CONFIG_PROC_FS*/
-int lprocfs_job_interval_seq_show(struct seq_file *m, void *data)
+ssize_t job_cleanup_interval_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct obd_job_stats *stats;
- if (obd == NULL)
- return -ENODEV;
-
stats = &obd->u.obt.obt_jobstats;
- seq_printf(m, "%d\n", stats->ojs_cleanup_interval);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%d\n", stats->ojs_cleanup_interval);
}
-EXPORT_SYMBOL(lprocfs_job_interval_seq_show);
+EXPORT_SYMBOL(job_cleanup_interval_show);
-ssize_t
-lprocfs_job_interval_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+ssize_t job_cleanup_interval_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct obd_device *obd;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct obd_job_stats *stats;
unsigned int val;
int rc;
- obd = ((struct seq_file *)file->private_data)->private;
- if (obd == NULL)
- return -ENODEV;
-
stats = &obd->u.obt.obt_jobstats;
- rc = kstrtouint_from_user(buffer, count, 0, &val);
+ rc = kstrtouint(buffer, 0, &val);
if (rc)
return rc;
lprocfs_job_cleanup(stats, stats->ojs_cleanup_interval);
return count;
}
-EXPORT_SYMBOL(lprocfs_job_interval_seq_write);
-#endif /* CONFIG_PROC_FS*/
+EXPORT_SYMBOL(job_cleanup_interval_store);
#undef BUFLEN
-int lprocfs_num_exports_seq_show(struct seq_file *m, void *data)
+ssize_t num_exports_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = data;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
- LASSERT(obd != NULL);
- seq_printf(m, "%u\n", obd->obd_num_exports);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%u\n", obd->obd_num_exports);
}
-EXPORT_SYMBOL(lprocfs_num_exports_seq_show);
+EXPORT_SYMBOL(num_exports_show);
static int obd_export_flags2str(struct obd_export *exp, struct seq_file *m)
{
}
EXPORT_SYMBOL(lprocfs_recovery_status_seq_show);
-int lprocfs_ir_factor_seq_show(struct seq_file *m, void *data)
+ssize_t ir_factor_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
- LASSERT(obd != NULL);
- seq_printf(m, "%d\n", obd->obd_recovery_ir_factor);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%d\n", obd->obd_recovery_ir_factor);
}
-EXPORT_SYMBOL(lprocfs_ir_factor_seq_show);
+EXPORT_SYMBOL(ir_factor_show);
-ssize_t
-lprocfs_ir_factor_seq_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+ssize_t ir_factor_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
int val;
int rc;
- LASSERT(obd != NULL);
- rc = kstrtoint_from_user(buffer, count, 10, &val);
+ rc = kstrtoint(buffer, 10, &val);
if (rc)
return rc;
obd->obd_recovery_ir_factor = val;
return count;
}
-EXPORT_SYMBOL(lprocfs_ir_factor_seq_write);
+EXPORT_SYMBOL(ir_factor_store);
int lprocfs_checksum_dump_seq_show(struct seq_file *m, void *data)
{
}
EXPORT_SYMBOL(lprocfs_checksum_dump_seq_write);
-int lprocfs_recovery_time_soft_seq_show(struct seq_file *m, void *data)
+ssize_t recovery_time_soft_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
- LASSERT(obd != NULL);
- seq_printf(m, "%llu\n", obd->obd_recovery_timeout);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%ld\n", obd->obd_recovery_timeout);
}
-EXPORT_SYMBOL(lprocfs_recovery_time_soft_seq_show);
+EXPORT_SYMBOL(recovery_time_soft_show);
-ssize_t
-lprocfs_recovery_time_soft_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+ssize_t recovery_time_soft_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
unsigned int val;
int rc;
- LASSERT(obd != NULL);
- rc = kstrtouint_from_user(buffer, count, 0, &val);
+ rc = kstrtouint(buffer, 0, &val);
if (rc)
return rc;
obd->obd_recovery_timeout = val;
return count;
}
-EXPORT_SYMBOL(lprocfs_recovery_time_soft_seq_write);
+EXPORT_SYMBOL(recovery_time_soft_store);
-int lprocfs_recovery_time_hard_seq_show(struct seq_file *m, void *data)
+ssize_t recovery_time_hard_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
- LASSERT(obd != NULL);
- seq_printf(m, "%lld\n", obd->obd_recovery_time_hard);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%ld\n", obd->obd_recovery_time_hard);
}
-EXPORT_SYMBOL(lprocfs_recovery_time_hard_seq_show);
+EXPORT_SYMBOL(recovery_time_hard_show);
-ssize_t
-lprocfs_recovery_time_hard_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+ssize_t recovery_time_hard_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
unsigned int val;
int rc;
- LASSERT(obd != NULL);
- rc = kstrtouint_from_user(buffer, count, 0, &val);
+ rc = kstrtouint(buffer, 0, &val);
if (rc)
return rc;
obd->obd_recovery_time_hard = val;
return count;
}
-EXPORT_SYMBOL(lprocfs_recovery_time_hard_seq_write);
+EXPORT_SYMBOL(recovery_time_hard_store);
-int lprocfs_target_instance_seq_show(struct seq_file *m, void *data)
+ssize_t instance_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct obd_device_target *target = &obd->u.obt;
- LASSERT(obd != NULL);
LASSERT(target->obt_magic == OBT_MAGIC);
- seq_printf(m, "%u\n", obd->u.obt.obt_instance);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%u\n", obd->u.obt.obt_instance);
}
-EXPORT_SYMBOL(lprocfs_target_instance_seq_show);
+EXPORT_SYMBOL(instance_show);
#endif /* CONFIG_PROC_FS*/
}
EXPORT_SYMBOL(class_modify_config);
-int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
- struct lustre_cfg *lcfg, void *data)
-{
- struct lprocfs_vars *var;
- struct file fakefile;
- struct seq_file fake_seqfile;
- char *key, *sval;
- int i, keylen, vallen;
- int matched = 0, j = 0;
- int rc = 0;
- int skip = 0;
-
- ENTRY;
-
- if (lcfg->lcfg_command != LCFG_PARAM) {
- CERROR("Unknown command: %d\n", lcfg->lcfg_command);
- RETURN(-EINVAL);
- }
-
- /* fake a seq file so that var->fops->write can work... */
- fakefile.private_data = &fake_seqfile;
- fake_seqfile.private = data;
- /*
- * e.g. tunefs.lustre --param mdt.group_upcall=foo /r/tmp/lustre-mdt
- * or lctl conf_param lustre-MDT0000.mdt.group_upcall=bar
- * or lctl conf_param lustre-OST0000.osc.max_dirty_mb=36
- */
- for (i = 1; i < lcfg->lcfg_bufcount; i++) {
- key = lustre_cfg_buf(lcfg, i);
- /* Strip off prefix */
- if (class_match_param(key, prefix, &key))
- /*
- * If the prefix doesn't match, return error so we
- * can pass it down the stack
- */
- RETURN(-ENOSYS);
- sval = strchr(key, '=');
- if (!sval || *(sval + 1) == 0) {
- CERROR("%s: can't parse param '%s' (missing '=')\n",
- lustre_cfg_string(lcfg, 0),
- lustre_cfg_string(lcfg, i));
- /* rc = -EINVAL; continue parsing other params */
- continue;
- }
- keylen = sval - key;
- sval++;
- vallen = strlen(sval);
- matched = 0;
- j = 0;
- /* Search proc entries */
- while (lvars[j].name) {
- var = &lvars[j];
- if (class_match_param(key, var->name, NULL) == 0 &&
- keylen == strlen(var->name)) {
- matched++;
- rc = -EROFS;
-
- if (var->fops && var->fops->write) {
- mm_segment_t oldfs;
- oldfs = get_fs();
- set_fs(KERNEL_DS);
- rc = (var->fops->write)(&fakefile, sval,
- vallen, NULL);
- set_fs(oldfs);
- }
- break;
- }
- j++;
- }
- if (!matched) {
- /*
- * It was upgraded from old MDT/OST device,
- * ignore the obsolete "sec_level" parameter.
- */
- if (strncmp("sec_level", key, keylen) == 0)
- continue;
-
- CERROR("%s: unknown config parameter '%s'\n",
- lustre_cfg_string(lcfg, 0),
- lustre_cfg_string(lcfg, i));
- /* rc = -EINVAL; continue parsing other params */
- skip++;
- } else if (rc < 0) {
- CERROR("%s: error writing parameter '%s': rc = %d\n",
- lustre_cfg_string(lcfg, 0), key, rc);
- rc = 0;
- } else {
- CDEBUG(D_CONFIG, "%s: set parameter '%s'\n",
- lustre_cfg_string(lcfg, 0), key);
- }
- }
-
- if (rc > 0)
- rc = 0;
- if (!rc && skip)
- rc = skip;
- RETURN(rc);
-}
-EXPORT_SYMBOL(class_process_proc_param);
-
/*
* Supplemental functions for config logs, it allocates lustre_cfg
* buffers plus initialized llog record header at the beginning.
#endif
LPROC_SEQ_FOPS_RO_TYPE(ofd, recovery_status);
-LPROC_SEQ_FOPS_RW_TYPE(ofd, recovery_time_soft);
-LPROC_SEQ_FOPS_RW_TYPE(ofd, recovery_time_hard);
+LUSTRE_RW_ATTR(recovery_time_hard);
+LUSTRE_RW_ATTR(recovery_time_soft);
+LUSTRE_RW_ATTR(ir_factor);
+
LPROC_SEQ_FOPS_WR_ONLY(ofd, evict_client);
-LPROC_SEQ_FOPS_RO_TYPE(ofd, num_exports);
-LPROC_SEQ_FOPS_RO_TYPE(ofd, target_instance);
-LPROC_SEQ_FOPS_RW_TYPE(ofd, ir_factor);
LPROC_SEQ_FOPS_RW_TYPE(ofd, checksum_dump);
-LPROC_SEQ_FOPS_RW_TYPE(ofd, job_interval);
+LUSTRE_RW_ATTR(job_cleanup_interval);
+
+LUSTRE_RO_ATTR(tot_dirty);
+LUSTRE_RO_ATTR(tot_granted);
+LUSTRE_RO_ATTR(tot_pending);
+LUSTRE_RW_ATTR(grant_compat_disable);
+LUSTRE_RO_ATTR(instance);
-LPROC_SEQ_FOPS_RO(tgt_tot_dirty);
-LPROC_SEQ_FOPS_RO(tgt_tot_granted);
-LPROC_SEQ_FOPS_RO(tgt_tot_pending);
-LPROC_SEQ_FOPS(tgt_grant_compat_disable);
+LUSTRE_RO_ATTR(num_exports);
struct lprocfs_vars lprocfs_ofd_obd_vars[] = {
{ .name = "last_id",
.fops = &ofd_last_id_fops },
- { .name = "tot_dirty",
- .fops = &tgt_tot_dirty_fops },
- { .name = "tot_pending",
- .fops = &tgt_tot_pending_fops },
- { .name = "tot_granted",
- .fops = &tgt_tot_granted_fops },
{ .name = "recovery_status",
.fops = &ofd_recovery_status_fops },
- { .name = "recovery_time_soft",
- .fops = &ofd_recovery_time_soft_fops },
- { .name = "recovery_time_hard",
- .fops = &ofd_recovery_time_hard_fops },
{ .name = "evict_client",
.fops = &ofd_evict_client_fops },
- { .name = "num_exports",
- .fops = &ofd_num_exports_fops },
{ .name = "brw_size",
.fops = &ofd_brw_size_fops },
- { .name = "instance",
- .fops = &ofd_target_instance_fops },
- { .name = "ir_factor",
- .fops = &ofd_ir_factor_fops },
{ .name = "checksum_dump",
.fops = &ofd_checksum_dump_fops },
- { .name = "grant_compat_disable",
- .fops = &tgt_grant_compat_disable_fops },
- { .name = "job_cleanup_interval",
- .fops = &ofd_job_interval_fops },
{ .name = "lfsck_layout",
.fops = &ofd_lfsck_layout_fops },
{ .name = "lfsck_verify_pfid",
LPROC_SEQ_FOPS(lprocfs_nid_stats_clear);
static struct attribute *ofd_attrs[] = {
+ &lustre_attr_tot_dirty.attr,
+ &lustre_attr_tot_granted.attr,
+ &lustre_attr_tot_pending.attr,
+ &lustre_attr_grant_compat_disable.attr,
+ &lustre_attr_instance.attr,
+ &lustre_attr_recovery_time_hard.attr,
+ &lustre_attr_recovery_time_soft.attr,
+ &lustre_attr_ir_factor.attr,
+ &lustre_attr_num_exports.attr,
&lustre_attr_seqs_allocated.attr,
&lustre_attr_grant_precreate.attr,
&lustre_attr_precreate_batch.attr,
&lustre_attr_sync_journal.attr,
&lustre_attr_soft_sync_limit.attr,
&lustre_attr_lfsck_speed_limit.attr,
+ &lustre_attr_job_cleanup_interval.attr,
&lustre_attr_checksum_t10pi_enforce.attr,
#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 14, 53, 0)
&lustre_attr_read_cache_enable.attr,
/**
* Show estimate of total amount of dirty data on clients.
*
- * \param[in] m seq_file handle
- * \param[in] data unused for single entry
+ * @kobj kobject embedded in obd_device
+ * @attr unused
+ * @buf buf used by sysfs to print out data
*
- * \retval 0 on success
- * \retval negative value on error
+ * Return: 0 on success
+ * negative value on error
*/
-int tgt_tot_dirty_seq_show(struct seq_file *m, void *data)
+ssize_t tot_dirty_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct tg_grants_data *tgd;
- LASSERT(obd != NULL);
tgd = &obd->u.obt.obt_lut->lut_tgd;
- seq_printf(m, "%llu\n", tgd->tgd_tot_dirty);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%llu\n", tgd->tgd_tot_dirty);
}
-EXPORT_SYMBOL(tgt_tot_dirty_seq_show);
+EXPORT_SYMBOL(tot_dirty_show);
/**
* Show total amount of space granted to clients.
*
- * \param[in] m seq_file handle
- * \param[in] data unused for single entry
+ * @kobj kobject embedded in obd_device
+ * @attr unused
+ * @buf buf used by sysfs to print out data
*
- * \retval 0 on success
- * \retval negative value on error
+ * Return: 0 on success
+ * negative value on error
*/
-int tgt_tot_granted_seq_show(struct seq_file *m, void *data)
+ssize_t tot_granted_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct tg_grants_data *tgd;
- LASSERT(obd != NULL);
tgd = &obd->u.obt.obt_lut->lut_tgd;
- seq_printf(m, "%llu\n", tgd->tgd_tot_granted);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%llu\n", tgd->tgd_tot_granted);
}
-EXPORT_SYMBOL(tgt_tot_granted_seq_show);
+EXPORT_SYMBOL(tot_granted_show);
/**
* Show total amount of space used by IO in progress.
*
- * \param[in] m seq_file handle
- * \param[in] data unused for single entry
+ * @kobj kobject embedded in obd_device
+ * @attr unused
+ * @buf buf used by sysfs to print out data
*
- * \retval 0 on success
- * \retval negative value on error
+ * Return: 0 on success
+ * negative value on error
*/
-int tgt_tot_pending_seq_show(struct seq_file *m, void *data)
+ssize_t tot_pending_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct tg_grants_data *tgd;
- LASSERT(obd != NULL);
tgd = &obd->u.obt.obt_lut->lut_tgd;
- seq_printf(m, "%llu\n", tgd->tgd_tot_pending);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%llu\n", tgd->tgd_tot_pending);
}
-EXPORT_SYMBOL(tgt_tot_pending_seq_show);
+EXPORT_SYMBOL(tot_pending_show);
/**
* Show if grants compatibility mode is disabled.
* block, (i.e. typically 4kB units), but underlaying file system might have
* block size bigger than page size, e.g. ZFS. See LU-2049 for details.
*
- * \param[in] m seq_file handle
- * \param[in] data unused for single entry
+ * @kobj kobject embedded in obd_device
+ * @attr unused
+ * @buf buf used by sysfs to print out data
*
- * \retval 0 on success
- * \retval negative value on error
+ * Return: string length of @buf output on success
*/
-int tgt_grant_compat_disable_seq_show(struct seq_file *m, void *data)
+ssize_t grant_compat_disable_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct tg_grants_data *tgd = &obd->u.obt.obt_lut->lut_tgd;
- seq_printf(m, "%u\n", tgd->tgd_grant_compat_disable);
- return 0;
+ return scnprintf(buf, PAGE_SIZE, "%u\n", tgd->tgd_grant_compat_disable);
}
-EXPORT_SYMBOL(tgt_grant_compat_disable_seq_show);
+EXPORT_SYMBOL(grant_compat_disable_show);
/**
* Change grant compatibility mode.
* Setting tgd_grant_compat_disable prohibit any space granting to clients
* not supporting OBD_CONNECT_GRANT_PARAM. See details above.
*
- * \param[in] file proc file
- * \param[in] buffer string which represents mode
- * 1: disable compatibility mode
- * 0: enable compatibility mode
- * \param[in] count \a buffer length
- * \param[in] off unused for single entry
+ * @kobj kobject embedded in obd_device
+ * @attr unused
+ * @buffer string which represents mode
+ * 1: disable compatibility mode
+ * 0: enable compatibility mode
+ * @count @buffer length
*
- * \retval \a count on success
- * \retval negative number on error
+ * Return: @count on success
+ * negative number on error
*/
-ssize_t tgt_grant_compat_disable_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+ssize_t grant_compat_disable_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct seq_file *m = file->private_data;
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
struct tg_grants_data *tgd = &obd->u.obt.obt_lut->lut_tgd;
bool val;
int rc;
- rc = kstrtobool_from_user(buffer, count, &val);
+ rc = kstrtobool(buffer, &val);
if (rc)
return rc;
return count;
}
-EXPORT_SYMBOL(tgt_grant_compat_disable_seq_write);
+EXPORT_SYMBOL(grant_compat_disable_store);