aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ceph/osdmap.h
diff options
context:
space:
mode:
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 {
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);