+int lprocfs_obd_rd_recovery_status(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_device *obd = data;
+ int len = 0, size;
+
+ LASSERT(obd != NULL);
+ LASSERT(count >= 0);
+
+ /* Set start of user data returned to
+ page + off since the user may have
+ requested to read much smaller than
+ what we need to read */
+ *start = page + off;
+
+ /* We know we are allocated a page here.
+ Also we know that this function will
+ not need to write more than a page
+ so we can truncate at CFS_PAGE_SIZE. */
+ size = min(count + (int)off + 1, (int)CFS_PAGE_SIZE);
+
+ /* Initialize the page */
+ memset(page, 0, size);
+
+ if (lprocfs_obd_snprintf(&page, size, &len, "status: ") <= 0)
+ goto out;
+
+ if (obd->obd_max_recoverable_clients == 0) {
+ lprocfs_obd_snprintf(&page, size, &len, "INACTIVE\n");
+ goto fclose;
+ }
+
+ /* sampled unlocked, but really... */
+ if (obd->obd_recovering == 0) {
+ if (lprocfs_obd_snprintf(&page, size, &len, "COMPLETE\n") <= 0)
+ goto out;
+
+ if (lprocfs_obd_snprintf(&page, size, &len, "recovery_start: %lu\n",
+ obd->obd_recovery_start) <= 0)
+ goto out;
+
+ if (lprocfs_obd_snprintf(&page, size, &len, "recovery_end: %lu\n",
+ obd->obd_recovery_end) <= 0)
+ goto out;
+
+ /* Number of clients have have completed recovery */
+ if (lprocfs_obd_snprintf(&page, size, &len, "recovered_clients: %d\n",
+ obd->obd_max_recoverable_clients - obd->obd_recoverable_clients) <= 0)
+ goto out;
+
+ if (lprocfs_obd_snprintf(&page, size, &len, "unrecovered_clients: %d\n",
+ obd->obd_recoverable_clients) <= 0)
+ goto out;
+
+ if (lprocfs_obd_snprintf(&page, size, &len, "last_transno: "LPD64"\n",
+ obd->obd_next_recovery_transno - 1) <= 0)
+ goto out;
+
+ lprocfs_obd_snprintf(&page, size, &len, "replayed_requests: %d\n", obd->obd_replayed_requests);
+ goto fclose;
+ }
+
+ if (lprocfs_obd_snprintf(&page, size, &len, "RECOVERING\n") <= 0)
+ goto out;
+
+ if (lprocfs_obd_snprintf(&page, size, &len, "recovery_start: %lu\n",
+ obd->obd_recovery_start) <= 0)
+ goto out;
+
+ if (lprocfs_obd_snprintf(&page, size, &len, "time remaining: %lu\n",
+ CURRENT_SECONDS >= obd->obd_recovery_end ? 0 :
+ obd->obd_recovery_end - CURRENT_SECONDS) <= 0)
+ goto out;
+
+ if(lprocfs_obd_snprintf(&page, size, &len, "connected_clients: %d/%d\n",
+ obd->obd_connected_clients,
+ obd->obd_max_recoverable_clients) <= 0)
+ goto out;
+
+ /* Number of clients have have completed recovery */
+ if (lprocfs_obd_snprintf(&page, size, &len, "completed_clients: %d/%d\n",
+ obd->obd_max_recoverable_clients - obd->obd_recoverable_clients,
+ obd->obd_max_recoverable_clients) <= 0)
+ goto out;
+
+ if (lprocfs_obd_snprintf(&page, size, &len, "replayed_requests: %d/??\n",
+ obd->obd_replayed_requests) <= 0)
+ goto out;
+
+ if (lprocfs_obd_snprintf(&page, size, &len, "queued_requests: %d\n",
+ obd->obd_requests_queued_for_recovery) <= 0)
+ goto out;
+
+ lprocfs_obd_snprintf(&page, size, &len, "next_transno: "LPD64"\n", obd->obd_next_recovery_transno);
+
+fclose:
+ *eof = 1;
+out:
+ return min(count, len - (int)off);
+}
+EXPORT_SYMBOL(lprocfs_obd_rd_recovery_status);