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

Commit 30c156d9 authored by Yan, Zheng's avatar Yan, Zheng Committed by Ilya Dryomov
Browse files

libceph: rados pool namespace support



Add pool namesapce pointer to struct ceph_file_layout and struct
ceph_object_locator. Pool namespace is used by when mapping object
to PG, it's also used when composing OSD request.

The namespace pointer in struct ceph_file_layout is RCU protected.
So libceph can read namespace without taking lock.

Signed-off-by: default avatarYan, Zheng <zyan@redhat.com>
[idryomov@gmail.com: ceph_oloc_destroy(), misc minor changes]
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent 51e92737
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3999,6 +3999,7 @@ static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc,
	rbd_dev->layout.stripe_count = 1;
	rbd_dev->layout.object_size = 1 << RBD_MAX_OBJ_ORDER;
	rbd_dev->layout.pool_id = spec->pool_id;
	RCU_INIT_POINTER(rbd_dev->layout.pool_ns, NULL);

	/*
	 * If this is a mapping rbd_dev (as opposed to a parent one),
+3 −0
Original line number Diff line number Diff line
@@ -446,6 +446,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb)
	ci->i_symlink = NULL;

	memset(&ci->i_dir_layout, 0, sizeof(ci->i_dir_layout));
	RCU_INIT_POINTER(ci->i_layout.pool_ns, NULL);
	ci->i_pool_ns_len = 0;

	ci->i_fragtree = RB_ROOT;
@@ -570,6 +571,8 @@ void ceph_destroy_inode(struct inode *inode)
	if (ci->i_xattrs.prealloc_blob)
		ceph_buffer_put(ci->i_xattrs.prealloc_blob);

	ceph_put_string(ci->i_layout.pool_ns);

	call_rcu(&inode->i_rcu, ceph_i_callback);
}

+2 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ struct ceph_file_layout_legacy {
	__le32 fl_pg_pool;      /* namespace, crush ruleset, rep level */
} __attribute__ ((packed));

struct ceph_string;
/*
 * ceph_file_layout - describe data layout for a file/inode
 */
@@ -62,6 +63,7 @@ struct ceph_file_layout {
	u32 stripe_count;  /* over this many objects */
	u32 object_size;   /* until objects are this big */
	s64 pool_id;        /* rados pool id */
	struct ceph_string __rcu *pool_ns; /* rados pool namespace */
};

extern int ceph_file_layout_is_valid(const struct ceph_file_layout *layout);
+5 −5
Original line number Diff line number Diff line
@@ -63,11 +63,13 @@ static inline bool ceph_can_shift_osds(struct ceph_pg_pool_info *pool)

struct ceph_object_locator {
	s64 pool;
	struct ceph_string *pool_ns;
};

static inline void ceph_oloc_init(struct ceph_object_locator *oloc)
{
	oloc->pool = -1;
	oloc->pool_ns = NULL;
}

static inline bool ceph_oloc_empty(const struct ceph_object_locator *oloc)
@@ -75,11 +77,9 @@ static inline bool ceph_oloc_empty(const struct ceph_object_locator *oloc)
	return oloc->pool == -1;
}

static inline void ceph_oloc_copy(struct ceph_object_locator *dest,
				  const struct ceph_object_locator *src)
{
	dest->pool = src->pool;
}
void ceph_oloc_copy(struct ceph_object_locator *dest,
		    const struct ceph_object_locator *src);
void ceph_oloc_destroy(struct ceph_object_locator *oloc);

/*
 * Maximum supported by kernel client object name length
+10 −2
Original line number Diff line number Diff line
@@ -156,8 +156,16 @@ static void dump_target(struct seq_file *s, struct ceph_osd_request_target *t)
	seq_printf(s, "]/%d\t[", t->up.primary);
	for (i = 0; i < t->acting.size; i++)
		seq_printf(s, "%s%d", (!i ? "" : ","), t->acting.osds[i]);
	seq_printf(s, "]/%d\t%*pE\t0x%x", t->acting.primary,
	seq_printf(s, "]/%d\t", t->acting.primary);
	if (t->target_oloc.pool_ns) {
		seq_printf(s, "%*pE/%*pE\t0x%x",
			(int)t->target_oloc.pool_ns->len,
			t->target_oloc.pool_ns->str,
			t->target_oid.name_len, t->target_oid.name, t->flags);
	} else {
		seq_printf(s, "%*pE\t0x%x", t->target_oid.name_len,
			t->target_oid.name, t->flags);
	}
	if (t->paused)
		seq_puts(s, "\tP");
}
Loading