+LPROC_SEQ_FOPS(lprocfs_nid_stats_clear);
+
+static struct attribute *ofd_attrs[] = {
+ &lustre_attr_seqs_allocated.attr,
+ &lustre_attr_grant_precreate.attr,
+ &lustre_attr_precreate_batch.attr,
+ &lustre_attr_client_cache_count.attr,
+ &lustre_attr_client_cache_seconds.attr,
+ &lustre_attr_degraded.attr,
+ &lustre_attr_fstype.attr,
+ &lustre_attr_syncjournal.attr,
+ &lustre_attr_sync_lock_cancel.attr,
+ &lustre_attr_soft_sync_limit.attr,
+ &lustre_attr_lfsck_speed_limit.attr,
+ &lustre_attr_checksum_t10pi_enforce.attr,
+ NULL,
+};
+
+/**
+ * Initialize all needed procfs entries for OFD device.
+ *
+ * \param[in] ofd OFD device
+ *
+ * \retval 0 if successful
+ * \retval negative value on error
+ */
+int ofd_tunables_init(struct ofd_device *ofd)
+{
+ struct obd_device *obd = ofd_obd(ofd);
+ struct proc_dir_entry *entry;
+ int rc = 0;
+
+ ENTRY;
+ /* lprocfs must be setup before the ofd so state can be safely added
+ * to /proc incrementally as the ofd is setup
+ */
+ obd->obd_ktype.default_attrs = ofd_attrs;
+ obd->obd_vars = lprocfs_ofd_obd_vars;
+ rc = lprocfs_obd_setup(obd, false);
+ if (rc) {
+ CERROR("%s: lprocfs_obd_setup failed: %d.\n",
+ obd->obd_name, rc);
+ RETURN(rc);
+ }
+
+ rc = lprocfs_alloc_obd_stats(obd, LPROC_OFD_STATS_LAST);
+ if (rc) {
+ CERROR("%s: lprocfs_alloc_obd_stats failed: %d.\n",
+ obd->obd_name, rc);
+ GOTO(obd_cleanup, rc);
+ }
+
+ entry = lprocfs_register("exports", obd->obd_proc_entry, NULL, NULL);
+ if (IS_ERR(entry)) {
+ rc = PTR_ERR(entry);
+ CERROR("%s: error %d setting up lprocfs for %s\n",
+ obd->obd_name, rc, "exports");
+ GOTO(obd_free_stats, rc);
+ }
+ obd->obd_proc_exports_entry = entry;
+
+ entry = lprocfs_add_simple(obd->obd_proc_exports_entry, "clear",
+ obd, &lprocfs_nid_stats_clear_fops);
+ if (IS_ERR(entry)) {
+ rc = PTR_ERR(entry);
+ CERROR("%s: add proc entry 'clear' failed: %d.\n",
+ obd->obd_name, rc);
+ GOTO(obd_free_stats, rc);
+ }
+
+ ofd_stats_counter_init(obd->obd_stats);
+
+ rc = lprocfs_job_stats_init(obd, LPROC_OFD_STATS_LAST,
+ ofd_stats_counter_init);
+ if (rc)
+ GOTO(obd_free_stats, rc);
+
+ RETURN(0);
+
+obd_free_stats:
+ lprocfs_free_obd_stats(obd);
+obd_cleanup:
+ lprocfs_obd_cleanup(obd);
+
+ return rc;
+}