#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)
{
}
LPROC_SEQ_FOPS_RO(lprocfs_exp_replydata);
+int lprocfs_exp_print_fmd_count_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
+ struct hlist_node *hnode, void *cb_data)
+
+{
+ struct obd_export *exp = cfs_hash_object(hs, hnode);
+ struct seq_file *m = cb_data;
+ struct tg_export_data *ted = &exp->exp_target_data;
+
+ seq_printf(m, "%d\n", ted->ted_fmd_count);
+
+ return 0;
+}
+
+int lprocfs_exp_fmd_count_seq_show(struct seq_file *m, void *data)
+{
+ struct nid_stat *stats = m->private;
+ struct obd_device *obd = stats->nid_obd;
+
+ cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
+ lprocfs_exp_print_fmd_count_seq, m);
+ return 0;
+}
+LPROC_SEQ_FOPS_RO(lprocfs_exp_fmd_count);
+
int lprocfs_nid_stats_clear_seq_show(struct seq_file *m, void *data)
{
seq_puts(m, "Write into this file to clear all nid stats and stale nid entries\n");
GOTO(destroy_new_ns, rc);
}
+ entry = lprocfs_add_simple(new_stat->nid_proc, "fmd_count", new_stat,
+ &lprocfs_exp_fmd_count_fops);
+ if (IS_ERR(entry)) {
+ rc = PTR_ERR(entry);
+ CWARN("%s: error adding the fmd_count file: rc = %d\n",
+ obd->obd_name, rc);
+ GOTO(destroy_new_ns, rc);
+ }
+
spin_lock(&exp->exp_lock);
exp->exp_nid_stats = new_stat;
spin_unlock(&exp->exp_lock);
return 0;
}
-#define LPROCFS_OBD_OP_INIT(base, stats, op) \
-do { \
- unsigned int coffset = base + OBD_COUNTER_OFFSET(op); \
- LASSERT(coffset < stats->ls_num); \
- lprocfs_counter_init(stats, coffset, 0, #op, "reqs"); \
-} while (0)
-
-void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats)
-{
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, iocontrol);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, get_info);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, set_info_async);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, setup);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, precleanup);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, cleanup);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, process_config);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, postrecov);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, add_conn);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, del_conn);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, connect);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, reconnect);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, disconnect);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, fid_init);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, fid_fini);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, fid_alloc);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, statfs);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, statfs_async);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, create);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, destroy);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, setattr);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, getattr);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, preprw);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, commitrw);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, init_export);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, destroy_export);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, import_event);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, notify);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, health_check);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, get_uuid);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, quotactl);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, ping);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_new);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_rem);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_add);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_del);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, getref);
- LPROCFS_OBD_OP_INIT(num_private_stats, stats, putref);
-
- CLASSERT(NUM_OBD_STATS == OBD_COUNTER_OFFSET(putref) + 1);
-}
-EXPORT_SYMBOL(lprocfs_init_ops_stats);
-
-int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned num_private_stats)
+int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned int num_stats)
{
struct lprocfs_stats *stats;
- unsigned int num_stats;
- int rc, i;
+ int rc;
LASSERT(obd->obd_stats == NULL);
LASSERT(obd->obd_proc_entry != NULL);
- LASSERT(obd->obd_cntr_base == 0);
- num_stats = NUM_OBD_STATS + num_private_stats;
stats = lprocfs_alloc_stats(num_stats, 0);
if (stats == NULL)
return -ENOMEM;
- lprocfs_init_ops_stats(num_private_stats, stats);
-
- for (i = num_private_stats; i < num_stats; i++) {
- /* If this LBUGs, it is likely that an obd
- * operation was added to struct obd_ops in
- * <obd.h>, and that the corresponding line item
- * LPROCFS_OBD_OP_INIT(.., .., opname)
- * is missing from the list above. */
- LASSERTF(stats->ls_cnt_header[i].lc_name != NULL,
- "Missing obd_stat initializer obd_op "
- "operation at offset %d.\n", i - num_private_stats);
- }
rc = lprocfs_register_stats(obd->obd_proc_entry, "stats", stats);
- if (rc < 0) {
+ if (rc < 0)
lprocfs_free_stats(&stats);
- } else {
- obd->obd_stats = stats;
- obd->obd_cntr_base = num_private_stats;
- }
+ else
+ obd->obd_stats = stats;
+
return rc;
}
EXPORT_SYMBOL(lprocfs_alloc_obd_stats);
}
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*/