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

Commit 7627151e authored by Yan, Zheng's avatar Yan, Zheng Committed by Ilya Dryomov
Browse files

libceph: define new ceph_file_layout structure



Define new ceph_file_layout structure and rename old ceph_file_layout
to ceph_file_layout_legacy. This is preparation for adding namespace
to ceph_file_layout structure.

Signed-off-by: default avatarYan, Zheng <zyan@redhat.com>
parent 22748f9d
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -1937,7 +1937,7 @@ static struct ceph_osd_request *rbd_osd_req_create(
	osd_req->r_callback = rbd_osd_req_callback;
	osd_req->r_priv = obj_request;

	osd_req->r_base_oloc.pool = ceph_file_layout_pg_pool(rbd_dev->layout);
	osd_req->r_base_oloc.pool = rbd_dev->layout.pool_id;
	if (ceph_oid_aprintf(&osd_req->r_base_oid, GFP_NOIO, "%s",
			     obj_request->object_name))
		goto fail;
@@ -1991,7 +1991,7 @@ rbd_osd_req_create_copyup(struct rbd_obj_request *obj_request)
	osd_req->r_callback = rbd_osd_req_callback;
	osd_req->r_priv = obj_request;

	osd_req->r_base_oloc.pool = ceph_file_layout_pg_pool(rbd_dev->layout);
	osd_req->r_base_oloc.pool = rbd_dev->layout.pool_id;
	if (ceph_oid_aprintf(&osd_req->r_base_oid, GFP_NOIO, "%s",
			     obj_request->object_name))
		goto fail;
@@ -3995,10 +3995,10 @@ static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc,

	/* Initialize the layout used for all rbd requests */

	rbd_dev->layout.fl_stripe_unit = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER);
	rbd_dev->layout.fl_stripe_count = cpu_to_le32(1);
	rbd_dev->layout.fl_object_size = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER);
	rbd_dev->layout.fl_pg_pool = cpu_to_le32((u32) spec->pool_id);
	rbd_dev->layout.stripe_unit = 1 << RBD_MAX_OBJ_ORDER;
	rbd_dev->layout.stripe_count = 1;
	rbd_dev->layout.object_size = 1 << RBD_MAX_OBJ_ORDER;
	rbd_dev->layout.pool_id = spec->pool_id;

	/*
	 * If this is a mapping rbd_dev (as opposed to a parent one),
@@ -5187,7 +5187,7 @@ static int rbd_dev_header_name(struct rbd_device *rbd_dev)

	rbd_assert(rbd_image_format_valid(rbd_dev->image_format));

	rbd_dev->header_oloc.pool = ceph_file_layout_pg_pool(rbd_dev->layout);
	rbd_dev->header_oloc.pool = rbd_dev->layout.pool_id;
	if (rbd_dev->image_format == 1)
		ret = ceph_oid_aprintf(&rbd_dev->header_oid, GFP_KERNEL, "%s%s",
				       spec->image_name, RBD_SUFFIX);
+9 −9
Original line number Diff line number Diff line
@@ -1730,7 +1730,7 @@ enum {
	POOL_WRITE	= 2,
};

static int __ceph_pool_perm_get(struct ceph_inode_info *ci, u32 pool)
static int __ceph_pool_perm_get(struct ceph_inode_info *ci, s64 pool)
{
	struct ceph_fs_client *fsc = ceph_inode_to_client(&ci->vfs_inode);
	struct ceph_mds_client *mdsc = fsc->mdsc;
@@ -1757,7 +1757,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci, u32 pool)
	if (*p)
		goto out;

	dout("__ceph_pool_perm_get pool %u no perm cached\n", pool);
	dout("__ceph_pool_perm_get pool %lld no perm cached\n", pool);

	down_write(&mdsc->pool_perm_rwsem);
	parent = NULL;
@@ -1860,13 +1860,13 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci, u32 pool)
out:
	if (!err)
		err = have;
	dout("__ceph_pool_perm_get pool %u result = %d\n", pool, err);
	dout("__ceph_pool_perm_get pool %lld result = %d\n", pool, err);
	return err;
}

int ceph_pool_perm_check(struct ceph_inode_info *ci, int need)
{
	u32 pool;
	s64 pool;
	int ret, flags;

	/* does not support pool namespace yet */
@@ -1879,17 +1879,17 @@ int ceph_pool_perm_check(struct ceph_inode_info *ci, int need)

	spin_lock(&ci->i_ceph_lock);
	flags = ci->i_ceph_flags;
	pool = ceph_file_layout_pg_pool(ci->i_layout);
	pool = ci->i_layout.pool_id;
	spin_unlock(&ci->i_ceph_lock);
check:
	if (flags & CEPH_I_POOL_PERM) {
		if ((need & CEPH_CAP_FILE_RD) && !(flags & CEPH_I_POOL_RD)) {
			dout("ceph_pool_perm_check pool %u no read perm\n",
			dout("ceph_pool_perm_check pool %lld no read perm\n",
			     pool);
			return -EPERM;
		}
		if ((need & CEPH_CAP_FILE_WR) && !(flags & CEPH_I_POOL_WR)) {
			dout("ceph_pool_perm_check pool %u no write perm\n",
			dout("ceph_pool_perm_check pool %lld no write perm\n",
			     pool);
			return -EPERM;
		}
@@ -1907,10 +1907,10 @@ int ceph_pool_perm_check(struct ceph_inode_info *ci, int need)
		flags |= CEPH_I_POOL_WR;

	spin_lock(&ci->i_ceph_lock);
	if (pool == ceph_file_layout_pg_pool(ci->i_layout)) {
	if (pool == ci->i_layout.pool_id) {
		ci->i_ceph_flags = flags;
        } else {
		pool = ceph_file_layout_pg_pool(ci->i_layout);
		pool = ci->i_layout.pool_id;
		flags = ci->i_ceph_flags;
	}
	spin_unlock(&ci->i_ceph_lock);
+4 −1
Original line number Diff line number Diff line
@@ -2895,8 +2895,11 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,

	if (newcaps & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR)) {
		/* file layout may have changed */
		ci->i_layout = grant->layout;
		s64 old_pool = ci->i_layout.pool_id;
		ceph_file_layout_from_legacy(&ci->i_layout, &grant->layout);
		ci->i_pool_ns_len = pool_ns_len;
		if (ci->i_layout.pool_id != old_pool)
			ci->i_ceph_flags &= ~CEPH_I_POOL_PERM;

		/* size/truncate_seq? */
		queue_trunc = ceph_fill_file_size(inode, issued,
+3 −3
Original line number Diff line number Diff line
@@ -1583,9 +1583,9 @@ static int ceph_zero_objects(struct inode *inode, loff_t offset, loff_t length)
{
	int ret = 0;
	struct ceph_inode_info *ci = ceph_inode(inode);
	s32 stripe_unit = ceph_file_layout_su(ci->i_layout);
	s32 stripe_count = ceph_file_layout_stripe_count(ci->i_layout);
	s32 object_size = ceph_file_layout_object_size(ci->i_layout);
	s32 stripe_unit = ci->i_layout.stripe_unit;
	s32 stripe_count = ci->i_layout.stripe_count;
	s32 object_size = ci->i_layout.object_size;
	u64 object_set_size = object_size * stripe_count;
	u64 nearly, t;

+4 −3
Original line number Diff line number Diff line
@@ -814,10 +814,11 @@ static int fill_inode(struct inode *inode, struct page *locked_page,

	if (new_version ||
	    (new_issued & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR))) {
		if (ci->i_layout.fl_pg_pool != info->layout.fl_pg_pool)
			ci->i_ceph_flags &= ~CEPH_I_POOL_PERM;
		ci->i_layout = info->layout;
		s64 old_pool = ci->i_layout.pool_id;
		ceph_file_layout_from_legacy(&ci->i_layout, &info->layout);
		ci->i_pool_ns_len = iinfo->pool_ns_len;
		if (ci->i_layout.pool_id != old_pool)
			ci->i_ceph_flags &= ~CEPH_I_POOL_PERM;

		queue_trunc = ceph_fill_file_size(inode, issued,
					le32_to_cpu(info->truncate_seq),
Loading