+int seq_server_alloc_spec(struct lu_server_seq *seq,
+ struct lu_seq_range *spec,
+ const struct lu_env *env)
+{
+ struct lu_seq_range *space = &seq->lss_space;
+ int rc = -ENOSPC;
+ ENTRY;
+
+ /*
+ * In some cases (like recovery after a disaster)
+ * we may need to allocate sequences manually
+ * Notice some sequences can be lost if requested
+ * range doesn't start at the beginning of current
+ * free space. Also notice it's not possible now
+ * to allocate sequences out of natural order.
+ */
+ if (spec->lsr_start >= spec->lsr_end)
+ RETURN(-EINVAL);
+ if (spec->lsr_flags != LU_SEQ_RANGE_MDT &&
+ spec->lsr_flags != LU_SEQ_RANGE_OST)
+ RETURN(-EINVAL);
+
+ mutex_lock(&seq->lss_mutex);
+ if (spec->lsr_start >= space->lsr_start) {
+ space->lsr_start = spec->lsr_end;
+ rc = seq_store_update(env, seq, spec, 1 /* sync */);
+
+ LCONSOLE_INFO("%s: "DRANGE" sequences allocated: rc = %d \n",
+ seq->lss_name, PRANGE(spec), rc);
+ }
+ mutex_unlock(&seq->lss_mutex);
+
+ RETURN(rc);
+}
+