- spin_lock(&mdd->mdd_cl.mc_lock);
- cur = mdd->mdd_cl.mc_index;
- spin_unlock(&mdd->mdd_cl.mc_lock);
-
- cucb.count = count;
- cucb.page = page;
- cucb.idx = 0;
-
- cucb.idx += snprintf(cucb.page + cucb.idx, cucb.count - cucb.idx,
- "current index: "LPU64"\n", cur);
-
- cucb.idx += snprintf(cucb.page + cucb.idx, cucb.count - cucb.idx,
- "%-5s %s\n", "ID", "index");
-
- llog_cat_process(ctxt->loc_handle, lprocfs_changelog_users_cb,
- &cucb, 0, 0);
-
- llog_ctxt_put(ctxt);
- return cucb.idx;
-}
-
-/* non-seq version for direct calling by class_process_proc_param */
-static int mdd_changelog_write(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- struct mdd_device *mdd = (struct mdd_device *)data;
- char kernbuf[32];
- char *end;
- int rc;
-
- if (count > (sizeof(kernbuf) - 1))
- goto out_usage;
-
- count = min_t(unsigned long, count, sizeof(kernbuf));
- if (copy_from_user(kernbuf, buffer, count))
- return -EFAULT;
-
- kernbuf[count] = '\0';
- /* strip trailing newline from "echo blah" */
- if (kernbuf[count - 1] == '\n')
- kernbuf[count - 1] = '\0';
-
- if (strcmp(kernbuf, "on") == 0) {
- LCONSOLE_INFO("changelog on\n");
- if (mdd->mdd_cl.mc_flags & CLM_ERR) {
- CERROR("Changelogs cannot be enabled due to error "
- "condition.\n");
- } else {
- spin_lock(&mdd->mdd_cl.mc_lock);
- mdd->mdd_cl.mc_flags |= CLM_ON;
- spin_unlock(&mdd->mdd_cl.mc_lock);
- rc = mdd_changelog_write_header(mdd, CLM_START);
- if (rc)
- return rc;
- }
- } else if (strcmp(kernbuf, "off") == 0) {
- LCONSOLE_INFO("changelog off\n");
- rc = mdd_changelog_write_header(mdd, CLM_FINI);
- if (rc)
- return rc;
- spin_lock(&mdd->mdd_cl.mc_lock);
- mdd->mdd_cl.mc_flags &= ~CLM_ON;
- spin_unlock(&mdd->mdd_cl.mc_lock);
- } else {
- /* purge to an index */
- long long unsigned endrec;
-
- endrec = (long long)simple_strtoull(kernbuf, &end, 0);
- if (end == kernbuf)
- goto out_usage;
-
- LCONSOLE_INFO("changelog purge to %llu\n", endrec);
-
- rc = mdd_changelog_llog_cancel(mdd, endrec);
- if (rc < 0)
- return rc;
- }