]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - osl.c
afs.cmd: Add documentation for lsatt.
[paraslash.git] / osl.c
diff --git a/osl.c b/osl.c
index b75b3bc3f9516a3645749822d4d7cd96a0c66280..1587b04c5fa06201ce5e32c024c7a8e189a24b8b 100644 (file)
--- a/osl.c
+++ b/osl.c
@@ -526,8 +526,8 @@ int init_table_structure(const struct osl_table_description *desc,
                        break;
                case OSL_MAPPED_STORAGE:
                        t->num_mapped_columns++;
-                       col->index_offset = t->index_entry_size;
-                       t->index_entry_size += 8;
+                       col->index_offset = t->row_index_size;
+                       t->row_index_size += 8;
                        break;
                case OSL_NO_STORAGE:
                        col->volatile_num = t->num_volatile_columns;
@@ -551,7 +551,7 @@ int init_table_structure(const struct osl_table_description *desc,
        if (!t->num_rbtrees)
                goto err;
        /* success */
-       PARA_DEBUG_LOG("OK. Index entry size: %u\n", t->index_entry_size);
+       PARA_DEBUG_LOG("OK. Index entry size: %u\n", t->row_index_size);
        ret = init_column_descriptions(t);
        if (ret < 0)
                goto err;
@@ -955,16 +955,16 @@ int get_mapped_object(const struct osl_table *t, unsigned col_num,
        struct osl_column *col = &t->columns[col_num];
        uint32_t offset;
        char *header;
-       char *index_entry;
+       char *cell_index;
        int ret;
 
        if (t->num_rows <= row_num)
                return -E_BAD_ID;
-       ret = get_index_entry(t, row_num, col_num, &index_entry);
+       ret = get_cell_index(t, row_num, col_num, &cell_index);
        if (ret < 0)
                return ret;
-       offset = read_u32(index_entry);
-       obj->size = read_u32(index_entry + 4) - 1;
+       offset = read_u32(cell_index);
+       obj->size = read_u32(cell_index + 4) - 1;
        header = col->data_map.data + offset;
        obj->data = header + 1;
        if (read_u8(header) == 0xff) {
@@ -1195,13 +1195,13 @@ int osl_close_table(struct osl_table *t, enum osl_close_flags flags)
  */
 int row_is_invalid(struct osl_table *t, uint32_t row_num)
 {
-       char *index_entry;
-       int i, ret = get_index_entry_start(t, row_num, &index_entry);
+       char *row_index;
+       int i, ret = get_row_index(t, row_num, &row_index);
 
        if (ret < 0)
                return ret;
-       for (i = 0; i < t->index_entry_size; i++) {
-               if ((unsigned char)index_entry[i] != 0xff)
+       for (i = 0; i < t->row_index_size; i++) {
+               if ((unsigned char)row_index[i] != 0xff)
                        return 0;
        }
        PARA_INFO_LOG("row %d is invalid\n", row_num);
@@ -1221,14 +1221,13 @@ int row_is_invalid(struct osl_table *t, uint32_t row_num)
  */
 int mark_row_invalid(struct osl_table *t, uint32_t row_num)
 {
-       char *index_entry;
-       int i, ret = get_index_entry_start(t, row_num, &index_entry);
+       char *row_index;
+       int ret = get_row_index(t, row_num, &row_index);
 
-       PARA_INFO_LOG("marking row %d as invalid\n", row_num);
        if (ret < 0)
                return ret;
-       for (i = 0; i < t->index_entry_size; i++)
-               index_entry[i] = 0xff;
+       PARA_INFO_LOG("marking row %d as invalid\n", row_num);
+       memset(row_index, 0xff, t->row_index_size);
        return 1;
 }
 
@@ -1371,7 +1370,7 @@ static int append_map_file(const struct osl_table *t, unsigned col_num,
        return ret;
 }
 
-static int append_index_entry(const struct osl_table *t, char *new_index_entry)
+static int append_row_index(const struct osl_table *t, char *row_index)
 {
        char *filename;
        int ret;
@@ -1379,9 +1378,8 @@ static int append_index_entry(const struct osl_table *t, char *new_index_entry)
        if (!t->num_mapped_columns)
                return 1;
        filename = index_filename(t->desc);
-//     PARA_DEBUG_LOG("appending %u bytes\n", t->index_entry_size);
-       ret = append_file(filename, NULL, 0, new_index_entry,
-               t->index_entry_size, NULL);
+       ret = append_file(filename, NULL, 0, row_index,
+               t->row_index_size, NULL);
        free(filename);
        return ret;
 }
@@ -1479,7 +1477,7 @@ int osl_add_and_get_row(struct osl_table *t, struct osl_object *objects,
        int i, ret;
        char *ds_name = NULL;
        struct rb_node **rb_parents = NULL, ***rb_links = NULL;
-       char *new_index_entry = NULL;
+       char *new_row_index = NULL;
        struct osl_object *volatile_objs = NULL;
        const struct osl_column_description *cd;
 
@@ -1488,7 +1486,7 @@ int osl_add_and_get_row(struct osl_table *t, struct osl_object *objects,
        rb_parents = para_malloc(t->num_rbtrees * sizeof(struct rn_node*));
        rb_links = para_malloc(t->num_rbtrees * sizeof(struct rn_node**));
        if (t->num_mapped_columns)
-               new_index_entry = para_malloc(t->index_entry_size);
+               new_row_index = para_malloc(t->row_index_size);
        /* pass 1: sanity checks */
 //     PARA_DEBUG_LOG("sanity tests: %p:%p\n", objects[0].data,
 //             objects[1].data);
@@ -1539,7 +1537,7 @@ int osl_add_and_get_row(struct osl_table *t, struct osl_object *objects,
                        ret = append_map_file(t, i, objects + i, &new_size);
                        if (ret < 0)
                                goto rollback;
-                       update_index_entry(new_index_entry, col, new_size,
+                       update_cell_index(new_row_index, col, new_size,
                                objects[i].size);
                        continue;
                }
@@ -1548,13 +1546,13 @@ int osl_add_and_get_row(struct osl_table *t, struct osl_object *objects,
                if (ret < 0)
                        goto rollback;
        }
-       ret = append_index_entry(t, new_index_entry);
+       ret = append_row_index(t, new_row_index);
        if (ret < 0)
                goto rollback;
        ret = map_table(t, MAP_TBL_FL_VERIFY_INDEX);
        if (ret < 0) { /* truncate index and rollback changes */
                char *filename = index_filename(t->desc);
-               para_truncate(filename, t->index_entry_size);
+               para_truncate(filename, t->row_index_size);
                free(filename);
                goto rollback;
        }
@@ -1588,7 +1586,7 @@ rollback: /* rollback all changes made, ignore further errors */
        /* ignore error and return previous error value */
        map_table(t, MAP_TBL_FL_VERIFY_INDEX);
 out:
-       free(new_index_entry);
+       free(new_row_index);
        free(ds_name);
        free(rb_parents);
        free(rb_links);
@@ -1971,8 +1969,8 @@ int osl_update_object(struct osl_table *t, const struct osl_row *r,
                        memcpy(old_obj.data, obj->data, cd->data_size);
                else { /* TODO: if the size doesn't change, use old space */
                        uint32_t new_data_map_size;
-                       char *index_entry;
-                       ret = get_index_entry_start(t, r->id, &index_entry);
+                       char *row_index;
+                       ret = get_row_index(t, r->id, &row_index);
                        if (ret < 0)
                                return ret;
                        ret = mark_mapped_object_invalid(t, r->id, col_num);
@@ -1986,7 +1984,7 @@ int osl_update_object(struct osl_table *t, const struct osl_row *r,
                        ret = map_column(t, col_num);
                        if (ret < 0)
                                return ret;
-                       update_index_entry(index_entry, col, new_data_map_size,
+                       update_cell_index(row_index, col, new_data_map_size,
                                obj->size);
                }
        }