Whamcloud - gitweb
Introduction of lu_env.
[fs/lustre-release.git] / lustre / fid / fid_store.c
index 57bd621..b4d1db1 100644 (file)
@@ -54,7 +54,7 @@ enum {
 
 /* this function implies that caller takes care about locking */
 int seq_store_write(struct lu_server_seq *seq,
-                    const struct lu_context *ctx)
+                    const struct lu_env *env)
 {
         struct dt_object *dt_obj = seq->lss_obj;
         struct seq_thread_info *info;
@@ -65,34 +65,32 @@ int seq_store_write(struct lu_server_seq *seq,
        ENTRY;
 
         dt_dev = lu2dt_dev(seq->lss_obj->do_lu.lo_dev);
-        info = lu_context_key_get(ctx, &seq_thread_key);
+        info = lu_context_key_get(&env->le_ctx, &seq_thread_key);
         LASSERT(info != NULL);
 
         /* 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);
+        th = dt_dev->dd_ops->dt_trans_start(env, 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);
-                rc = dt_obj->do_body_ops->dbo_write(ctx, dt_obj,
+                range_cpu_to_le(&info->sti_record.ssr_space, &seq->lss_space);
+                range_cpu_to_le(&info->sti_record.ssr_super, &seq->lss_super);
+
+                rc = dt_obj->do_body_ops->dbo_write(env, 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"),
+                        CDEBUG(D_INFO|D_WARNING, "%s: Store ranges: Space - "
+                               DRANGE", Super - "DRANGE"\n", seq->lss_name,
                                PRANGE(&seq->lss_space), PRANGE(&seq->lss_super));
-
                         rc = 0;
                 } else if (rc >= 0) {
                         rc = -EIO;
                 }
-                
-                dt_dev->dd_ops->dt_trans_stop(ctx, th);
+
+                dt_dev->dd_ops->dt_trans_stop(env, th);
         } else {
                 rc = PTR_ERR(th);
         }
@@ -103,7 +101,7 @@ int seq_store_write(struct lu_server_seq *seq,
 /* this function implies that caller takes care about locking or locking is not
  * needed (init time). */
 int seq_store_read(struct lu_server_seq *seq,
-                   const struct lu_context *ctx)
+                   const struct lu_env *env)
 {
         struct dt_object *dt_obj = seq->lss_obj;
         struct seq_thread_info *info;
@@ -111,29 +109,25 @@ int seq_store_read(struct lu_server_seq *seq,
        int rc;
        ENTRY;
 
-        info = lu_context_key_get(ctx, &seq_thread_key);
+        info = lu_context_key_get(&env->le_ctx, &seq_thread_key);
         LASSERT(info != NULL);
 
-        rc = dt_obj->do_body_ops->dbo_read(ctx, dt_obj,
+        rc = dt_obj->do_body_ops->dbo_read(env, 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;
-                seq->lss_super = info->sti_record.ssr_super;
 
-                lustre_swab_lu_range(&seq->lss_space);
-                lustre_swab_lu_range(&seq->lss_super);
+        if (rc == sizeof(info->sti_record)) {
+                range_le_to_cpu(&seq->lss_space, &info->sti_record.ssr_space);
+                range_le_to_cpu(&seq->lss_super, &info->sti_record.ssr_super);
 
-                CDEBUG(D_INFO, "read %s ranges: space - "DRANGE", super - "
-                       DRANGE"\n", (seq->lss_type == LUSTRE_SEQ_SERVER ?
-                                    "server" : "controller"),
+                CDEBUG(D_INFO|D_WARNING, "%s: Read ranges: Space - "
+                       DRANGE", Super - "DRANGE"\n", seq->lss_name,
                        PRANGE(&seq->lss_space), PRANGE(&seq->lss_super));
                 rc = 0;
         } else if (rc == 0) {
                 rc = -ENODATA;
         } else if (rc >= 0) {
-                CERROR("read only %d bytes of %d\n",
+                CERROR("%s: Read only %d bytes of %d\n", seq->lss_name,
                        rc, sizeof(info->sti_record));
                 rc = -EIO;
         }
@@ -142,7 +136,7 @@ int seq_store_read(struct lu_server_seq *seq,
 }
 
 int seq_store_init(struct lu_server_seq *seq,
-                   const struct lu_context *ctx,
+                   const struct lu_env *env,
                    struct dt_device *dt)
 {
         struct dt_object *dt_obj;
@@ -152,15 +146,15 @@ int seq_store_init(struct lu_server_seq *seq,
         ENTRY;
 
         name = seq->lss_type == LUSTRE_SEQ_SERVER ?
-                "seq_srv" : "seq_ctl";
-        
-        dt_obj = dt_store_open(ctx, dt, name, &fid);
+                LUSTRE_SEQ_SRV_NAME : LUSTRE_SEQ_CTL_NAME;
+
+        dt_obj = dt_store_open(env, dt, name, &fid);
         if (!IS_ERR(dt_obj)) {
                 seq->lss_obj = dt_obj;
                rc = 0;
         } else {
-                CERROR("cannot find \"seq\" obj %d\n",
-                      (int)PTR_ERR(dt_obj));
+                CERROR("%s: Can't find \"%s\" obj %d\n",
+                      seq->lss_name, name, (int)PTR_ERR(dt_obj));
                 rc = PTR_ERR(dt_obj);
         }
 
@@ -168,16 +162,16 @@ int seq_store_init(struct lu_server_seq *seq,
 }
 
 void seq_store_fini(struct lu_server_seq *seq,
-                    const struct lu_context *ctx)
+                    const struct lu_env *env)
 {
         ENTRY;
 
         if (seq->lss_obj != NULL) {
                 if (!IS_ERR(seq->lss_obj))
-                        lu_object_put(ctx, &seq->lss_obj->do_lu);
+                        lu_object_put(env, &seq->lss_obj->do_lu);
                 seq->lss_obj = NULL;
         }
-        
+
         EXIT;
 }
 #endif