diff options
-rw-r--r-- | drivers/block/rbd.c | 10 | ||||
-rw-r--r-- | include/linux/ceph/osd_client.h | 9 | ||||
-rw-r--r-- | include/linux/ceph/osdmap.h | 36 | ||||
-rw-r--r-- | net/ceph/debugfs.c | 3 | ||||
-rw-r--r-- | net/ceph/osd_client.c | 17 |
5 files changed, 50 insertions, 25 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 98792b2a7f65..6fdc5fc00447 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -1809,10 +1809,7 @@ static struct ceph_osd_request *rbd_osd_req_create( | |||
1809 | osd_req->r_priv = obj_request; | 1809 | osd_req->r_priv = obj_request; |
1810 | 1810 | ||
1811 | osd_req->r_oloc.pool = ceph_file_layout_pg_pool(rbd_dev->layout); | 1811 | osd_req->r_oloc.pool = ceph_file_layout_pg_pool(rbd_dev->layout); |
1812 | 1812 | ceph_oid_set_name(&osd_req->r_oid, obj_request->object_name); | |
1813 | osd_req->r_oid_len = strlen(obj_request->object_name); | ||
1814 | rbd_assert(osd_req->r_oid_len < sizeof (osd_req->r_oid)); | ||
1815 | memcpy(osd_req->r_oid, obj_request->object_name, osd_req->r_oid_len); | ||
1816 | 1813 | ||
1817 | return osd_req; | 1814 | return osd_req; |
1818 | } | 1815 | } |
@@ -1850,10 +1847,7 @@ rbd_osd_req_create_copyup(struct rbd_obj_request *obj_request) | |||
1850 | osd_req->r_priv = obj_request; | 1847 | osd_req->r_priv = obj_request; |
1851 | 1848 | ||
1852 | osd_req->r_oloc.pool = ceph_file_layout_pg_pool(rbd_dev->layout); | 1849 | osd_req->r_oloc.pool = ceph_file_layout_pg_pool(rbd_dev->layout); |
1853 | 1850 | ceph_oid_set_name(&osd_req->r_oid, obj_request->object_name); | |
1854 | osd_req->r_oid_len = strlen(obj_request->object_name); | ||
1855 | rbd_assert(osd_req->r_oid_len < sizeof (osd_req->r_oid)); | ||
1856 | memcpy(osd_req->r_oid, obj_request->object_name, osd_req->r_oid_len); | ||
1857 | 1851 | ||
1858 | return osd_req; | 1852 | return osd_req; |
1859 | } | 1853 | } |
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 | |||
21 | struct ceph_msg; | 15 | struct ceph_msg; |
22 | struct ceph_snap_context; | 16 | struct ceph_snap_context; |
23 | struct ceph_osd_request; | 17 | struct 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 | |||
53 | struct ceph_object_id { | ||
54 | char name[CEPH_MAX_OID_NAME_LEN]; | ||
55 | int name_len; | ||
56 | }; | ||
57 | |||
46 | struct ceph_pg_mapping { | 58 | struct 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 | ||
87 | static 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 | |||
103 | static 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 | |||
75 | static inline int ceph_osd_is_up(struct ceph_osdmap *map, int osd) | 111 | static 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); |
diff --git a/net/ceph/debugfs.c b/net/ceph/debugfs.c index 83661cdc0766..1f8562706393 100644 --- a/net/ceph/debugfs.c +++ b/net/ceph/debugfs.c | |||
@@ -132,7 +132,8 @@ static int osdc_show(struct seq_file *s, void *pp) | |||
132 | req->r_osd ? req->r_osd->o_osd : -1, | 132 | req->r_osd ? req->r_osd->o_osd : -1, |
133 | req->r_pgid.pool, req->r_pgid.seed); | 133 | req->r_pgid.pool, req->r_pgid.seed); |
134 | 134 | ||
135 | seq_printf(s, "%.*s", req->r_oid_len, req->r_oid); | 135 | seq_printf(s, "%.*s", req->r_oid.name_len, |
136 | req->r_oid.name); | ||
136 | 137 | ||
137 | if (req->r_reassert_version.epoch) | 138 | if (req->r_reassert_version.epoch) |
138 | seq_printf(s, "\t%u'%llu", | 139 | seq_printf(s, "\t%u'%llu", |
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index a053e7e4a780..2988d68b24c6 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
@@ -765,9 +765,9 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, | |||
765 | 765 | ||
766 | req->r_oloc.pool = ceph_file_layout_pg_pool(*layout); | 766 | req->r_oloc.pool = ceph_file_layout_pg_pool(*layout); |
767 | 767 | ||
768 | snprintf(req->r_oid, sizeof(req->r_oid), "%llx.%08llx", | 768 | snprintf(req->r_oid.name, sizeof(req->r_oid.name), |
769 | vino.ino, objnum); | 769 | "%llx.%08llx", vino.ino, objnum); |
770 | req->r_oid_len = strlen(req->r_oid); | 770 | req->r_oid.name_len = strlen(req->r_oid.name); |
771 | 771 | ||
772 | return req; | 772 | return req; |
773 | } | 773 | } |
@@ -1269,7 +1269,7 @@ static int __map_request(struct ceph_osd_client *osdc, | |||
1269 | bool was_paused; | 1269 | bool was_paused; |
1270 | 1270 | ||
1271 | dout("map_request %p tid %lld\n", req, req->r_tid); | 1271 | dout("map_request %p tid %lld\n", req, req->r_tid); |
1272 | err = ceph_calc_ceph_pg(&pgid, req->r_oid, osdc->osdmap, | 1272 | err = ceph_calc_ceph_pg(&pgid, req->r_oid.name, osdc->osdmap, |
1273 | req->r_oloc.pool); | 1273 | req->r_oloc.pool); |
1274 | if (err) { | 1274 | if (err) { |
1275 | list_move(&req->r_req_lru_item, &osdc->req_notarget); | 1275 | list_move(&req->r_req_lru_item, &osdc->req_notarget); |
@@ -2118,10 +2118,11 @@ void ceph_osdc_build_request(struct ceph_osd_request *req, u64 off, | |||
2118 | ceph_encode_32(&p, -1); /* preferred */ | 2118 | ceph_encode_32(&p, -1); /* preferred */ |
2119 | 2119 | ||
2120 | /* oid */ | 2120 | /* oid */ |
2121 | ceph_encode_32(&p, req->r_oid_len); | 2121 | ceph_encode_32(&p, req->r_oid.name_len); |
2122 | memcpy(p, req->r_oid, req->r_oid_len); | 2122 | memcpy(p, req->r_oid.name, req->r_oid.name_len); |
2123 | dout("oid '%.*s' len %d\n", req->r_oid_len, req->r_oid, req->r_oid_len); | 2123 | dout("oid '%.*s' len %d\n", req->r_oid.name_len, |
2124 | p += req->r_oid_len; | 2124 | req->r_oid.name, req->r_oid.name_len); |
2125 | p += req->r_oid.name_len; | ||
2125 | 2126 | ||
2126 | /* ops--can imply data */ | 2127 | /* ops--can imply data */ |
2127 | ceph_encode_16(&p, (u16)req->r_num_ops); | 2128 | ceph_encode_16(&p, (u16)req->r_num_ops); |