- struct dt_device *dt_dev;
- struct thandle *th;
- int rc;
- ENTRY;
-
- dt_dev = lu2dt_dev(seq->lss_obj->do_lu.lo_dev);
-
- th = seq_store_trans_create(seq, env);
- if (IS_ERR(th))
- RETURN(PTR_ERR(th));
-
- rc = seq_declare_store_write(seq, env, th);
- if (rc)
- GOTO(exit, rc);
-
- if (out != NULL) {
- rc = fld_declare_server_create(seq->lss_site->ms_server_fld,
- env, th);
- if (rc)
- GOTO(exit, rc);
- }
-
- rc = seq_store_trans_start(seq, env, th);
- if (rc)
- GOTO(exit, rc);
-
- rc = seq_store_write(seq, env, th);
- if (rc) {
- CERROR("%s: Can't write space data, rc %d\n",
- seq->lss_name, rc);
- GOTO(exit,rc);
- } else if (out != NULL) {
- rc = fld_server_create(seq->lss_site->ms_server_fld,
- env, out, th);
- if (rc) {
- CERROR("%s: Can't Update fld database, rc %d\n",
- seq->lss_name, rc);
- GOTO(exit,rc);
- }
- }
-
- /* next sequence update will need sync until this update is committed
- * in case of sync operation this is not needed obviously */
- if (!sync)
- /* if callback can't be added then sync always */
- sync = !!seq_update_cb_add(th, seq);
-
- th->th_sync |= sync;
+ struct dt_device *dt_dev = lu2dt_dev(seq->lss_obj->do_lu.lo_dev);
+ struct seq_thread_info *info;
+ struct thandle *th;
+ loff_t pos = 0;
+ int rc;
+
+ if (dt_dev->dd_rdonly)
+ RETURN(0);
+
+ info = lu_context_key_get(&env->le_ctx, &seq_thread_key);
+ LASSERT(info != NULL);
+
+ th = dt_trans_create(env, dt_dev);
+ if (IS_ERR(th))
+ RETURN(PTR_ERR(th));
+
+ /* Store ranges in le format. */
+ range_cpu_to_le(&info->sti_space, &seq->lss_space);
+
+ rc = dt_declare_record_write(env, seq->lss_obj,
+ seq_store_buf(info), 0, th);
+ if (rc)
+ GOTO(exit, rc);
+
+ if (out) {
+ rc = fld_declare_server_create(env,
+ seq->lss_site->ss_server_fld,
+ out, th);
+ if (rc)
+ GOTO(exit, rc);
+ }
+
+ rc = dt_trans_start_local(env, dt_dev, th);
+ if (rc)
+ GOTO(exit, rc);
+
+ rc = dt_record_write(env, seq->lss_obj, seq_store_buf(info), &pos, th);
+ if (rc) {
+ CERROR("%s: Can't write space data, rc %d\n",
+ seq->lss_name, rc);
+ GOTO(exit, rc);
+ } else if (out) {
+ rc = fld_server_create(env, seq->lss_site->ss_server_fld, out,
+ th);
+ if (rc) {
+ CERROR("%s: Can't Update fld database, rc %d\n",
+ seq->lss_name, rc);
+ GOTO(exit, rc);
+ }
+ }
+ /*
+ * next sequence update will need sync until this update is committed
+ * in case of sync operation this is not needed obviously
+ */
+ if (!sync)
+ /* if callback can't be added then sync always */
+ sync = !!seq_update_cb_add(th, seq);
+
+ th->th_sync |= sync;