summaryrefslogtreecommitdiff
path: root/include/linux/ceph/osdmap.h
diff options
context:
space:
mode:
authorIlya Dryomov <ilya.dryomov@inktank.com>2014-01-27 17:40:18 +0200
committerIlya Dryomov <ilya.dryomov@inktank.com>2014-01-27 23:57:28 +0200
commit4295f2217a5aa8ef2738e3a368db3c1ceab41212 (patch)
tree557b4efd8558bfa71bae87413d0f4d6f0ba0511a /include/linux/ceph/osdmap.h
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/osdmap.h')
-rw-r--r--include/linux/ceph/osdmap.h36
1 files changed, 36 insertions, 0 deletions
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 {
s64 pool;
};
+/*
+ * Maximum supported by kernel client object name length
+ *
+ * (probably outdated: must be >= RBD_MAX_MD_NAME_LEN -- currently 100)
+ */
+#define CEPH_MAX_OID_NAME_LEN 100
+
+struct ceph_object_id {
+ char name[CEPH_MAX_OID_NAME_LEN];
+ int name_len;
+};
+
struct ceph_pg_mapping {
struct rb_node node;
struct ceph_pg pgid;
@@ -72,6 +84,30 @@ struct ceph_osdmap {
struct crush_map *crush;
};
+static inline void ceph_oid_set_name(struct ceph_object_id *oid,
+ const char *name)
+{
+ int len;
+
+ len = strlen(name);
+ if (len > sizeof(oid->name)) {
+ WARN(1, "ceph_oid_set_name '%s' len %d vs %zu, truncating\n",
+ name, len, sizeof(oid->name));
+ len = sizeof(oid->name);
+ }
+
+ memcpy(oid->name, name, len);
+ oid->name_len = len;
+}
+
+static inline void ceph_oid_copy(struct ceph_object_id *dest,
+ struct ceph_object_id *src)
+{
+ BUG_ON(src->name_len > sizeof(dest->name));
+ memcpy(dest->name, src->name, src->name_len);
+ dest->name_len = src->name_len;
+}
+
static inline int ceph_osd_is_up(struct ceph_osdmap *map, int osd)
{
return (osd < map->max_osd) && (map->osd_state[osd] & CEPH_OSD_UP);