2 * Copyright 2013 GRNET S.A. All rights reserved.
4 * Redistribution and use in source and binary forms, with or
5 * without modification, are permitted provided that the following
8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following
11 * 2. Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following
13 * disclaimer in the documentation and/or other materials
14 * provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
29 * The views and conclusions contained in the software and
30 * documentation are those of the authors and should not be
31 * interpreted as representing official policies, either expressed
32 * or implied, of GRNET S.A.
35 #ifndef MAPPERVERSIONS_H
37 #define MAPPERVERSIONS_H
40 #include <xseg/protocol.h>
41 #include <mapper-version0.h>
42 #include <mapper-version1.h>
43 #include <mapper-version2.h>
45 #define MAP_LATEST_VERSION 2
46 /* These come straight from the struct map fields that need to be kept in
55 #define MAX_MAPHEADER_SIZE (sizeof(uint32_t) \
62 /* should always be the maximum objectlen of all versions */
63 //#define MAX_OBJECT_LEN v2_max_objectlen
65 /* since object names are cacluclated from the volume names, the limit of the
66 * maximum volume len is calculated from the maximum object len, statically for
69 * How the object name is calculated is reflected in this formula:
73 //#define MAX_VOLUME_LEN (MAX_OBJECT_LEN - HEXLIFIED_INDEX - HEXLIFIED_EPOCH - 2)
75 /* Some compile time checks */
76 #if MAX_OBJECT_LEN < v2_max_objectlen
77 #error "MAX_OBJECT_LEN is smaller than v2_max_objectlen"
80 #if MAX_OBJECT_LEN < v1_max_objectlen
81 #error "MAX_OBJECT_LEN is smaller than v1_max_objectlen"
84 #if MAX_OBJECT_LEN < v0_max_objectlen
85 #error "MAX_OBJECT_LEN is smaller than v0_max_objectlen"
90 * map read/write functions
92 * version 0 -> pithos map
93 * version 1 -> archipelago version 1
94 * version 2 -> archipelago version 2
98 struct map_functions {
99 void (*object_to_map)(unsigned char *buf, struct map_node *mn);
100 int (*read_object)(struct map_node *mn, unsigned char *buf);
101 struct xseg_request * (*prepare_write_object)(struct peer_req *pr,
102 struct map *map, struct map_node *mn);
103 // int (*read_map)(struct map *map, unsigned char * data);
104 // int (*write_map)(struct peer_req *pr, struct map *map);
105 int (*read_map_metadata)(struct map *map, unsigned char *metadata,
106 uint32_t metadata_len);
107 int (*load_map_data)(struct peer_req *pr, struct map *map);
108 int (*write_map_metadata)(struct peer_req *pr, struct map *map);
109 int (*write_map_data)(struct peer_req *pr, struct map *map);
112 extern struct map_functions map_functions[];
114 #endif /* end MAPPERVERSIONS_H */