+static int lprocfs_ofd_rd_groups(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_device *obd = (struct obd_device *)data;
+ struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+
+ *eof = 1;
+ return snprintf(page, count, "%u\n", ofd->ofd_max_group);
+}
+
+static int lprocfs_ofd_rd_last_id(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_device *obd = data;
+ struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+ int retval = 0, rc, i;
+
+ if (obd == NULL)
+ return 0;
+
+ for (i = FID_SEQ_OST_MDT0; i <= ofd->ofd_max_group; i++) {
+ rc = snprintf(page, count, LPU64"\n", ofd_last_id(ofd, i));
+ if (rc < 0) {
+ retval = rc;
+ break;
+ }
+ page += rc;
+ count -= rc;
+ retval += rc;
+ }
+ return retval;
+}
+
+static int lprocfs_ofd_rd_capa(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_device *obd = data;
+ int rc;
+
+ rc = snprintf(page, count, "capability on: %s\n",
+ obd->u.filter.fo_fl_oss_capa ? "oss" : "");
+ return rc;
+}
+
+static int lprocfs_ofd_wr_capa(struct file *file, const char *buffer,
+ unsigned long count, void *data)
+{
+ struct obd_device *obd = data;
+ int val, rc;
+
+ rc = lprocfs_write_helper(buffer, count, &val);
+ if (rc)
+ return rc;
+
+ if (val & ~0x1) {
+ CERROR("invalid capability mode, only 0/1 are accepted.\n"
+ " 1: enable oss fid capability\n"
+ " 0: disable oss fid capability\n");
+ return -EINVAL;
+ }
+
+ obd->u.filter.fo_fl_oss_capa = val;
+ LCONSOLE_INFO("OSS %s %s fid capability.\n", obd->obd_name,
+ val ? "enabled" : "disabled");
+ return count;
+}
+
+static int lprocfs_ofd_rd_capa_count(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ return snprintf(page, count, "%d %d\n",
+ capa_count[CAPA_SITE_CLIENT],
+ capa_count[CAPA_SITE_SERVER]);
+}
+
+int lprocfs_ofd_rd_degraded(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_device *obd = data;
+ struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+
+ return snprintf(page, count, "%u\n", ofd->ofd_raid_degraded);
+}
+
+int lprocfs_ofd_wr_degraded(struct file *file, const char *buffer,
+ unsigned long count, void *data)
+{
+ struct obd_device *obd = data;
+ struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+ int val, rc;
+
+ rc = lprocfs_write_helper(buffer, count, &val);
+ if (rc)
+ return rc;
+
+ cfs_spin_lock(&ofd->ofd_flags_lock);
+ ofd->ofd_raid_degraded = !!val;
+ cfs_spin_unlock(&ofd->ofd_flags_lock);
+
+ return count;
+}
+
+int lprocfs_ofd_rd_fstype(char *page, char **start, off_t off, int count,
+ int *eof, void *data)
+{
+ struct obd_device *obd = data;
+ struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+ struct lu_device *d;
+
+ LASSERT(ofd->ofd_osd);
+ d = &ofd->ofd_osd->dd_lu_dev;
+ LASSERT(d->ld_type);
+ return snprintf(page, count, "%s\n", d->ld_type->ldt_name);
+}
+
+int lprocfs_ofd_rd_syncjournal(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_device *obd = data;
+ struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+ int rc;
+
+ rc = snprintf(page, count, "%u\n", ofd->ofd_syncjournal);
+ return rc;
+}
+
+int lprocfs_ofd_wr_syncjournal(struct file *file, const char *buffer,
+ unsigned long count, void *data)
+{
+ struct obd_device *obd = data;
+ struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+ int val;
+ int rc;
+
+ rc = lprocfs_write_helper(buffer, count, &val);
+ if (rc)
+ return rc;
+
+ if (val < 0)
+ return -EINVAL;
+
+ cfs_spin_lock(&ofd->ofd_flags_lock);
+ ofd->ofd_syncjournal = !!val;
+ ofd_slc_set(ofd);
+ cfs_spin_unlock(&ofd->ofd_flags_lock);
+
+ return count;
+}
+
+static char *sync_on_cancel_states[] = {"never",
+ "blocking",
+ "always" };
+
+int lprocfs_ofd_rd_sync_lock_cancel(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_device *obd = data;
+ struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+ int rc;
+
+ rc = snprintf(page, count, "%s\n",
+ sync_on_cancel_states[ofd->ofd_sync_lock_cancel]);
+ return rc;
+}
+
+int lprocfs_ofd_wr_sync_lock_cancel(struct file *file, const char *buffer,
+ unsigned long count, void *data)
+{
+ struct obd_device *obd = data;
+ struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+ int val = -1;
+ int i;
+
+ for (i = 0 ; i < NUM_SYNC_ON_CANCEL_STATES; i++) {
+ if (memcmp(buffer, sync_on_cancel_states[i],
+ strlen(sync_on_cancel_states[i])) == 0) {
+ val = i;
+ break;
+ }
+ }
+ if (val == -1) {
+ int rc;
+
+ rc = lprocfs_write_helper(buffer, count, &val);
+ if (rc)
+ return rc;
+ }
+
+ if (val < 0 || val > 2)
+ return -EINVAL;
+
+ cfs_spin_lock(&ofd->ofd_flags_lock);
+ ofd->ofd_sync_lock_cancel = val;
+ cfs_spin_unlock(&ofd->ofd_flags_lock);
+ return count;
+}
+