struct seq_thread_info *info;
struct dt_device *dt_dev;
struct thandle *th;
- loff_t pos;
+ loff_t pos = 0;
int rc;
ENTRY;
info = lu_context_key_get(ctx, &seq_thread_key);
LASSERT(info != NULL);
+ rc = dt_obj->do_body_ops->dbo_read(ctx, dt_obj,
+ (char *)&info->sti_record,
+ sizeof(info->sti_record), &pos);
+ if (rc < 0) {
+ CERROR("can't read seq data from store, rc %d\n", rc);
+ RETURN(rc);
+ }
+
+ if (rc > 0 && rc != sizeof(info->sti_record)) {
+ CWARN("read only %d bytes of %d, old data - zeroing out\n",
+ rc, sizeof(info->sti_record));
+ memset(&info->sti_record, 0, sizeof(info->sti_record));
+ }
+
/* stub here, will fix it later */
info->sti_txn.tp_credits = SEQ_TXN_STORE_CREDITS;
th = dt_dev->dd_ops->dt_trans_start(ctx, dt_dev, &info->sti_txn);
if (!IS_ERR(th)) {
/* store ranges in le format */
- range_to_le(&info->sti_record.ssr_space, &seq->lss_space);
- range_to_le(&info->sti_record.ssr_super, &seq->lss_super);
-
- /*
- * Regular seq server stores its ranges at posision 0 and
- * controller at position of sizeof(info->sti_record).
- */
- pos = (seq->lss_type == LUSTRE_SEQ_SERVER) ? 0 :
- sizeof(info->sti_record);
+ if (seq->lss_type == LUSTRE_SEQ_SERVER) {
+ range_to_le(&info->sti_record.srv_space, &seq->lss_space);
+ range_to_le(&info->sti_record.srv_super, &seq->lss_super);
+ } else {
+ range_to_le(&info->sti_record.ctl_space, &seq->lss_space);
+ range_to_le(&info->sti_record.ctl_super, &seq->lss_super);
+ }
+
rc = dt_obj->do_body_ops->dbo_write(ctx, dt_obj,
(char *)&info->sti_record,
sizeof(info->sti_record),
&pos, th);
if (rc == sizeof(info->sti_record)) {
+ CDEBUG(D_INFO, "store %s ranges: space - "DRANGE", super - "
+ DRANGE"\n", (seq->lss_type == LUSTRE_SEQ_SERVER ?
+ "server" : "controller"),
+ PRANGE(&seq->lss_space), PRANGE(&seq->lss_super));
+
rc = 0;
} else if (rc >= 0) {
rc = -EIO;
{
struct dt_object *dt_obj = seq->lss_obj;
struct seq_thread_info *info;
- loff_t pos;
+ loff_t pos = 0;
int rc;
ENTRY;
info = lu_context_key_get(ctx, &seq_thread_key);
LASSERT(info != NULL);
- /*
- * Regular seq server stores its ranges at posision 0 and controller at
- * position of sizeof(info->sti_record).
- */
- pos = (seq->lss_type == LUSTRE_SEQ_SERVER) ? 0 :
- sizeof(info->sti_record);
-
rc = dt_obj->do_body_ops->dbo_read(ctx, dt_obj,
(char *)&info->sti_record,
sizeof(info->sti_record), &pos);
if (rc == sizeof(info->sti_record)) {
- seq->lss_space = info->sti_record.ssr_space;
+ if (seq->lss_type == LUSTRE_SEQ_SERVER) {
+ seq->lss_space = info->sti_record.srv_space;
+ seq->lss_super = info->sti_record.srv_super;
+ } else {
+ seq->lss_space = info->sti_record.ctl_space;
+ seq->lss_super = info->sti_record.ctl_super;
+ }
lustre_swab_lu_range(&seq->lss_space);
-
- seq->lss_super = info->sti_record.ssr_super;
lustre_swab_lu_range(&seq->lss_super);
+
+ CDEBUG(D_INFO, "read %s ranges: space - "DRANGE", super - "
+ DRANGE"\n", (seq->lss_type == LUSTRE_SEQ_SERVER ?
+ "server" : "controller"),
+ PRANGE(&seq->lss_space), PRANGE(&seq->lss_super));
rc = 0;
} else if (rc == 0) {
rc = -ENODATA;