]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - osl.c
loglevel adjustments.
[paraslash.git] / osl.c
diff --git a/osl.c b/osl.c
index a71f93c3243153d20504eae0fed91a88141145ff..b75b3bc3f9516a3645749822d4d7cd96a0c66280 100644 (file)
--- a/osl.c
+++ b/osl.c
@@ -806,6 +806,17 @@ static void mark_table_clean(struct osl_table *t)
        write_u8(buf, read_u8(buf) & 0xfe);
 }
 
+static void unmap_column(struct osl_table *t, unsigned col_num)
+{
+       struct osl_object map = t->columns[col_num].data_map;
+       int ret;
+       if (!map.data)
+               return;
+       ret = para_munmap(map.data, map.size);
+       assert(ret > 0);
+       map.data = NULL;
+}
+
 /**
  * Unmap all mapped files of an osl table.
  *
@@ -836,18 +847,30 @@ int unmap_table(struct osl_table *t, enum osl_close_flags flags)
        t->index_map.data = NULL;
        if (!t->num_rows)
                return 1;
-       FOR_EACH_MAPPED_COLUMN(i, t, cd) {
-               struct osl_object map = t->columns[i].data_map;
-               if (!map.data)
-                       continue;
-               ret = para_munmap(map.data, map.size);
-               if (ret < 0)
-                       return ret;
-               map.data = NULL;
-       }
+       FOR_EACH_MAPPED_COLUMN(i, t, cd)
+               unmap_column(t, i);
        return 1;
 }
 
+static int map_column(struct osl_table *t, unsigned col_num)
+{
+       struct stat statbuf;
+       char *filename = column_filename(t, col_num);
+       int ret = -E_STAT;
+       if (stat(filename, &statbuf) < 0) {
+               free(filename);
+               return ret;
+       }
+       if (!(S_IFREG & statbuf.st_mode)) {
+               free(filename);
+               return ret;
+       }
+       ret = mmap_full_file(filename, O_RDWR,
+               &t->columns[col_num].data_map);
+       free(filename);
+       return ret;
+}
+
 /**
  * Map the index file and all columns of type \p OSL_MAPPED_STORAGE into memory.
  *
@@ -894,20 +917,7 @@ int map_table(struct osl_table *t, enum map_table_flags flags)
                return num_rows;
        /* map data files */
        FOR_EACH_MAPPED_COLUMN(i, t, cd) {
-               struct stat statbuf;
-               filename = column_filename(t, i);
-               ret = -E_STAT;
-               if (stat(filename, &statbuf) < 0) {
-                       free(filename);
-                       goto err;
-               }
-               if (!(S_IFREG & statbuf.st_mode)) {
-                       free(filename);
-                       goto err;
-               }
-               ret = mmap_full_file(filename, O_RDWR,
-                       &t->columns[i].data_map);
-               free(filename);
+               ret = map_column(t, i);
                if (ret < 0)
                        goto err;
        }
@@ -1423,7 +1433,7 @@ static int delete_disk_storage_file(const struct osl_table *t, unsigned col_num,
        char *dirname, *filename = disk_storage_path(t, col_num, ds_name);
        int ret = unlink(filename);
 
-       PARA_INFO_LOG("deleted %s\n", filename);
+       PARA_DEBUG_LOG("deleted %s\n", filename);
        free(filename);
        if (ret < 0) {
                if (errno == ENOENT)
@@ -1915,6 +1925,7 @@ int osl_update_object(struct osl_table *t, const struct osl_row *r,
                return -E_BAD_TABLE;
        col = &t->columns[col_num];
        cd = get_column_description(t->desc, col_num);
+       PARA_DEBUG_LOG("updating column %u of %s\n", col_num, t->desc->name);
        if (cd->storage_flags & OSL_RBTREE) {
                if (search_rbtree(obj, t, col_num, NULL, NULL) > 0)
                        return -E_RB_KEY_EXISTS;
@@ -1967,8 +1978,12 @@ int osl_update_object(struct osl_table *t, const struct osl_row *r,
                        ret = mark_mapped_object_invalid(t, r->id, col_num);
                        if (ret < 0)
                                return ret;
+                       unmap_column(t, col_num);
                        ret = append_map_file(t, col_num, obj,
                                &new_data_map_size);
+                       if (ret < 0)
+                               return ret;
+                       ret = map_column(t, col_num);
                        if (ret < 0)
                                return ret;
                        update_index_entry(index_entry, col, new_data_map_size,