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.
*
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.
*
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;
}
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,