Whamcloud - gitweb
- using dt_body_ops in server sequence manager to store seq mgr state and read it...
authoryury <yury>
Sat, 29 Jul 2006 08:56:16 +0000 (08:56 +0000)
committeryury <yury>
Sat, 29 Jul 2006 08:56:16 +0000 (08:56 +0000)
lustre/fid/fid_handler.c
lustre/fid/fid_store.c
lustre/fld/fld_handler.c
lustre/fld/fld_index.c

index 8482cb3..d96d89e 100644 (file)
@@ -537,8 +537,6 @@ seq_server_fini(struct lu_server_seq *seq,
                 seq->seq_dev = NULL;
         }
 
-        CDEBUG(D_INFO|D_WARNING, "Server Sequence "
-               "Manager\n");
         EXIT;
 }
 EXPORT_SYMBOL(seq_server_fini);
index ad40838..c2bfb82 100644 (file)
 #include "fid_internal.h"
 
 #ifdef __KERNEL__
+struct seq_store_capsule {
+        struct lu_range ssc_space;
+        struct lu_range ssc_super;
+};
+
+enum {
+        SEQ_TXN_STORE_CREDITS = 20
+};
+
+/* this function implies that caller takes about locking */
 int
 seq_store_write(struct lu_server_seq *seq,
                const struct lu_context *ctx)
 {
-       int rc = 0;
+        struct dt_object *dt_obj = seq->seq_obj;
+        struct dt_device *dt_dev = seq->seq_dev;
+        struct seq_store_capsule capsule;
+        loff_t pos = 0;
+        struct txn_param txn;
+        struct thandle *th;
+       int rc;
        ENTRY;
 
+        /* stub here, will fix it later */
+        txn.tp_credits = SEQ_TXN_STORE_CREDITS;
+
+        th = dt_dev->dd_ops->dt_trans_start(ctx, dt_dev, &txn);
+        if (!IS_ERR(th)) {
+                rc = dt_obj->do_body_ops->dbo_write(ctx, dt_obj,
+                                                    (char *)&capsule,
+                                                    sizeof(capsule),
+                                                    &pos, th);
+                if (rc == sizeof(capsule)) {
+                        rc = 0;
+                } else if (rc >= 0) {
+                        rc = -EIO;
+                }
+                
+                dt_dev->dd_ops->dt_trans_stop(ctx, th);
+        } else {
+                rc = PTR_ERR(th);
+        }
+       
        RETURN(rc);
 }
 
+/* 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)
 {
-       int rc = -ENODATA;
+        struct dt_object *dt_obj = seq->seq_obj;
+        struct seq_store_capsule capsule;
+        loff_t pos = 0;
+       int rc;
        ENTRY;
+
+        rc = dt_obj->do_body_ops->dbo_read(ctx, dt_obj,
+                                           (char *)&capsule,
+                                           sizeof(capsule), &pos);
+        if (rc == sizeof(capsule)) {
+                seq->seq_space = capsule.ssc_space;
+                seq->seq_super = capsule.ssc_super;
+                rc = 0;
+        } else if (rc == 0) {
+                rc = -ENODATA;
+        } else if (rc >= 0) {
+                CERROR("read only %d bytes of %d\n",
+                       rc, sizeof(capsule));
+                rc = -EIO;
+        }
        
        RETURN(rc);
 }
index 106a867..e4b3d70 100644 (file)
@@ -367,7 +367,6 @@ fld_server_fini(struct lu_server_fld *fld,
                 fld_index_fini(fld, ctx);
                 fld->fld_dt = NULL;
         }
-        CDEBUG(D_INFO|D_WARNING, "Server FLD\n");
         EXIT;
 }
 EXPORT_SYMBOL(fld_server_fini);
index de2023e..4378781 100644 (file)
@@ -66,7 +66,7 @@ static const struct dt_index_features fld_index_features = {
  */
 enum {
         FLD_TXN_INDEX_INSERT_CREDITS  = 20,
-        FLD_TXN_INDEX_DELETE_CREDITS  = 20
+        FLD_TXN_INDEX_DELETE_CREDITS  = 20,
 };
 
 struct fld_thread_info {
@@ -140,7 +140,7 @@ int fld_index_create(struct lu_server_fld *fld,
         int rc;
         ENTRY;
 
-        /*stub here, will fix it later*/
+        /* stub here, will fix it later */
         txn.tp_credits = FLD_TXN_INDEX_INSERT_CREDITS;
 
         th = dt->dd_ops->dt_trans_start(ctx, dt, &txn);