aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ceph
diff options
context:
space:
mode:
authorIlya Dryomov <ilya.dryomov@inktank.com>2014-01-27 10:40:18 -0500
committerIlya Dryomov <ilya.dryomov@inktank.com>2014-01-27 16:57:28 -0500
commit4295f2217a5aa8ef2738e3a368db3c1ceab41212 (patch)
tree557b4efd8558bfa71bae87413d0f4d6f0ba0511a /include/linux/ceph
parent2d0ebc5d591f49131bf8f93b54c5424162c3fb7f (diff)
libceph: introduce and start using oid abstraction
In preparation for tiering support, which would require having two (base and target) object names for each osd request and also copying those names around, introduce struct ceph_object_id (oid) and a couple helpers to facilitate those copies and encapsulate the fact that object name is not necessarily a NUL-terminated string. Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'include/linux/ceph')
-rw-r--r--include/linux/ceph/osd_client.h9
-rw-r--r--include/linux/ceph/osdmap.h36
2 files changed, 37 insertions, 8 deletions
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
index b42f15848cae..8d8bb53994b1 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -12,12 +12,6 @@
12#include <linux/ceph/auth.h> 12#include <linux/ceph/auth.h>
13#include <linux/ceph/pagelist.h> 13#include <linux/ceph/pagelist.h>
14 14
15/*
16 * Maximum object name size
17 * (must be at least as big as RBD_MAX_MD_NAME_LEN -- currently 100)
18 */
19#define CEPH_MAX_OID_NAME_LEN 100
20
21struct ceph_msg; 15struct ceph_msg;
22struct ceph_snap_context; 16struct ceph_snap_context;
23struct ceph_osd_request; 17struct ceph_osd_request;
@@ -160,9 +154,8 @@ struct ceph_osd_request {
160 void *r_priv; /* ditto */ 154 void *r_priv; /* ditto */
161 155
162 struct ceph_object_locator r_oloc; 156 struct ceph_object_locator r_oloc;
157 struct ceph_object_id r_oid;
163 158
164 char r_oid[CEPH_MAX_OID_NAME_LEN]; /* object name */
165 int r_oid_len;
166 u64 r_snapid; 159 u64 r_snapid;
167 unsigned long r_stamp; /* send OR check time */ 160 unsigned long r_stamp; /* send OR check time */
168 161
diff --git a/include/linux/ceph/osdmap.h b/include/linux/ceph/osdmap.h
index f2679c384625..c85f7d43b861 100644
--- a/include/linux/ceph/osdmap.h
+++ b/include/linux/ceph/osdmap.h
@@ -43,6 +43,18 @@ struct ceph_object_locator {
43 s64 pool; 43 s64 pool;
44}; 44};
45 45
46/*
47 * Maximum supported by kernel client object name length
48 *
49 * (probably outdated: must be >= RBD_MAX_MD_NAME_LEN -- currently 100)
50 */
51#define CEPH_MAX_OID_NAME_LEN 100
52
53struct ceph_object_id {
54 char name[CEPH_MAX_OID_NAME_LEN];
55 int name_len;
56};
57
46struct ceph_pg_mapping { 58struct ceph_pg_mapping {
47 struct rb_node node; 59 struct rb_node node;
48 struct ceph_pg pgid; 60 struct ceph_pg pgid;
@@ -72,6 +84,30 @@ struct ceph_osdmap {
72 struct crush_map *crush; 84 struct crush_map *crush;
73}; 85};
74 86
87static inline void ceph_oid_set_name(struct ceph_object_id *oid,
88 const char *name)
89{
90 int len;
91
92 len = strlen(name);
93 if (len > sizeof(oid->name)) {
94 WARN(1, "ceph_oid_set_name '%s' len %d vs %zu, truncating\n",
95 name, len, sizeof(oid->name));
96 len = sizeof(oid->name);
97 }
98
99 memcpy(oid->name, name, len);
100 oid->name_len = len;
101}
102
103static inline void ceph_oid_copy(struct ceph_object_id *dest,
104 struct ceph_object_id *src)
105{
106 BUG_ON(src->name_len > sizeof(dest->name));
107 memcpy(dest->name, src->name, src->name_len);
108 dest->name_len = src->name_len;
109}
110
75static inline int ceph_osd_is_up(struct ceph_osdmap *map, int osd) 111static inline int ceph_osd_is_up(struct ceph_osdmap *map, int osd)
76{ 112{
77 return (osd < map->max_osd) && (map->osd_state[osd] & CEPH_OSD_UP); 113 return (osd < map->max_osd) && (map->osd_state[osd] & CEPH_OSD_UP);