Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b191d99 authored by Sage Weil's avatar Sage Weil
Browse files

libceph: decode into cpu-native ceph_pg type



Always decode data into our cpu-native ceph_pg type that has the correct
field widths.  Limit any remaining uses of ceph_pg_v1 to dealing with the
legacy protocol.

Signed-off-by: default avatarSage Weil <sage@inktank.com>
Reviewed-by: default avatarAlex Elder <elder@inktank.com>
parent 12979354
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -186,7 +186,7 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
	u64 len = 1, olen;
	u64 tmp;
	struct ceph_object_layout ol;
	struct ceph_pg_v1 pgid;
	struct ceph_pg pgid;
	int r;

	/* copy and validate */
@@ -212,7 +212,8 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
	ceph_calc_object_layout(&ol, dl.object_name, &ci->i_layout,
				osdc->osdmap);

	pgid = ol.ol_pgid;
	pgid.pool = le32_to_cpu(ol.ol_pgid.pool);
	pgid.seed = le16_to_cpu(ol.ol_pgid.ps);
	dl.osd = ceph_calc_pg_primary(osdc->osdmap, pgid);
	if (dl.osd >= 0) {
		struct ceph_entity_addr *a =
+1 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ struct ceph_osd_request {
	struct list_head r_linger_item;
	struct list_head r_linger_osd;
	struct ceph_osd *r_osd;
	struct ceph_pg_v1 r_pgid;
	struct ceph_pg   r_pgid;
	int              r_pg_osds[CEPH_PG_MAX_SIZE];
	int              r_num_pg_osds;

+8 −3
Original line number Diff line number Diff line
@@ -18,6 +18,11 @@
 * The map can be updated either via an incremental map (diff) describing
 * the change between two successive epochs, or as a fully encoded map.
 */
struct ceph_pg {
	uint64_t pool;
	uint32_t seed;
};

struct ceph_pg_pool_info {
	struct rb_node node;
	int id;
@@ -28,7 +33,7 @@ struct ceph_pg_pool_info {

struct ceph_pg_mapping {
	struct rb_node node;
	struct ceph_pg_v1 pgid;
	struct ceph_pg pgid;
	int len;
	int osds[];
};
@@ -119,10 +124,10 @@ extern int ceph_calc_object_layout(struct ceph_object_layout *ol,
				   struct ceph_file_layout *fl,
				   struct ceph_osdmap *osdmap);
extern int ceph_calc_pg_acting(struct ceph_osdmap *osdmap,
			       struct ceph_pg_v1 pgid,
			       struct ceph_pg pgid,
			       int *acting);
extern int ceph_calc_pg_primary(struct ceph_osdmap *osdmap,
				struct ceph_pg_v1 pgid);
				struct ceph_pg pgid);

extern const char *ceph_pg_pool_name_by_id(struct ceph_osdmap *map, u64 id);
extern int ceph_pg_poolid_by_name(struct ceph_osdmap *map, const char *name);
+2 −3
Original line number Diff line number Diff line
@@ -131,10 +131,9 @@ static int osdc_show(struct seq_file *s, void *pp)

		req = rb_entry(p, struct ceph_osd_request, r_node);

		seq_printf(s, "%lld\tosd%d\t%d.%x\t", req->r_tid,
		seq_printf(s, "%lld\tosd%d\t%lld.%x\t", req->r_tid,
			   req->r_osd ? req->r_osd->o_osd : -1,
			   le32_to_cpu(req->r_pgid.pool),
			   le16_to_cpu(req->r_pgid.ps));
			   req->r_pgid.pool, req->r_pgid.seed);

		head = req->r_request->front.iov_base;
		op = (void *)(head + 1);
+5 −4
Original line number Diff line number Diff line
@@ -914,7 +914,7 @@ static int __map_request(struct ceph_osd_client *osdc,
			 struct ceph_osd_request *req, int force_resend)
{
	struct ceph_osd_request_head *reqhead = req->r_request->front.iov_base;
	struct ceph_pg_v1 pgid;
	struct ceph_pg pgid;
	int acting[CEPH_PG_MAX_SIZE];
	int o = -1, num = 0;
	int err;
@@ -926,7 +926,8 @@ static int __map_request(struct ceph_osd_client *osdc,
		list_move(&req->r_req_lru_item, &osdc->req_notarget);
		return err;
	}
	pgid = reqhead->layout.ol_pgid;
	pgid.pool = le32_to_cpu(reqhead->layout.ol_pgid.pool);
	pgid.seed = le16_to_cpu(reqhead->layout.ol_pgid.ps);
	req->r_pgid = pgid;

	err = ceph_calc_pg_acting(osdc->osdmap, pgid, acting);
@@ -943,8 +944,8 @@ static int __map_request(struct ceph_osd_client *osdc,
	    (req->r_osd == NULL && o == -1))
		return 0;  /* no change */

	dout("map_request tid %llu pgid %d.%x osd%d (was osd%d)\n",
	     req->r_tid, le32_to_cpu(pgid.pool), le16_to_cpu(pgid.ps), o,
	dout("map_request tid %llu pgid %lld.%x osd%d (was osd%d)\n",
	     req->r_tid, pgid.pool, pgid.seed, o,
	     req->r_osd ? req->r_osd->o_osd : -1);

	/* record full pg acting set */
Loading