Whamcloud - gitweb
- fixes in fid store, by now all ranges should be read from store correctly.
authoryury <yury>
Mon, 4 Sep 2006 07:50:24 +0000 (07:50 +0000)
committeryury <yury>
Mon, 4 Sep 2006 07:50:24 +0000 (07:50 +0000)
lustre/fid/fid_internal.h
lustre/fid/fid_store.c

index a18aa0e..556610f 100644 (file)
 
 #ifdef __KERNEL__
 struct seq_store_record {
-        struct lu_range ssr_space;
-        struct lu_range ssr_super;
+        struct lu_range srv_space;
+        struct lu_range srv_super;
+        struct lu_range ctl_space;
+        struct lu_range ctl_super;
 };
 
 struct seq_thread_info {
index a9273c5..8a27b5f 100644 (file)
@@ -60,7 +60,7 @@ int seq_store_write(struct lu_server_seq *seq,
         struct seq_thread_info *info;
         struct dt_device *dt_dev;
         struct thandle *th;
-        loff_t pos;
+        loff_t pos = 0;
        int rc;
        ENTRY;
 
@@ -68,27 +68,45 @@ int seq_store_write(struct lu_server_seq *seq,
         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;
@@ -109,30 +127,32 @@ int seq_store_read(struct lu_server_seq *seq,
 {
         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;