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: Yan, Zheng <zyan@redhat.com>
This commit is contained in:
parent
22748f9d61
commit
7627151ea3
|
@ -1937,7 +1937,7 @@ static struct ceph_osd_request *rbd_osd_req_create(
|
||||||
osd_req->r_callback = rbd_osd_req_callback;
|
osd_req->r_callback = rbd_osd_req_callback;
|
||||||
osd_req->r_priv = obj_request;
|
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",
|
if (ceph_oid_aprintf(&osd_req->r_base_oid, GFP_NOIO, "%s",
|
||||||
obj_request->object_name))
|
obj_request->object_name))
|
||||||
goto fail;
|
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_callback = rbd_osd_req_callback;
|
||||||
osd_req->r_priv = obj_request;
|
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",
|
if (ceph_oid_aprintf(&osd_req->r_base_oid, GFP_NOIO, "%s",
|
||||||
obj_request->object_name))
|
obj_request->object_name))
|
||||||
goto fail;
|
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 */
|
/* 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.stripe_unit = 1 << RBD_MAX_OBJ_ORDER;
|
||||||
rbd_dev->layout.fl_stripe_count = cpu_to_le32(1);
|
rbd_dev->layout.stripe_count = 1;
|
||||||
rbd_dev->layout.fl_object_size = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER);
|
rbd_dev->layout.object_size = 1 << RBD_MAX_OBJ_ORDER;
|
||||||
rbd_dev->layout.fl_pg_pool = cpu_to_le32((u32) spec->pool_id);
|
rbd_dev->layout.pool_id = spec->pool_id;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this is a mapping rbd_dev (as opposed to a parent one),
|
* 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_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)
|
if (rbd_dev->image_format == 1)
|
||||||
ret = ceph_oid_aprintf(&rbd_dev->header_oid, GFP_KERNEL, "%s%s",
|
ret = ceph_oid_aprintf(&rbd_dev->header_oid, GFP_KERNEL, "%s%s",
|
||||||
spec->image_name, RBD_SUFFIX);
|
spec->image_name, RBD_SUFFIX);
|
||||||
|
|
|
@ -1730,7 +1730,7 @@ enum {
|
||||||
POOL_WRITE = 2,
|
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_fs_client *fsc = ceph_inode_to_client(&ci->vfs_inode);
|
||||||
struct ceph_mds_client *mdsc = fsc->mdsc;
|
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)
|
if (*p)
|
||||||
goto out;
|
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);
|
down_write(&mdsc->pool_perm_rwsem);
|
||||||
parent = NULL;
|
parent = NULL;
|
||||||
|
@ -1860,13 +1860,13 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci, u32 pool)
|
||||||
out:
|
out:
|
||||||
if (!err)
|
if (!err)
|
||||||
err = have;
|
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;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ceph_pool_perm_check(struct ceph_inode_info *ci, int need)
|
int ceph_pool_perm_check(struct ceph_inode_info *ci, int need)
|
||||||
{
|
{
|
||||||
u32 pool;
|
s64 pool;
|
||||||
int ret, flags;
|
int ret, flags;
|
||||||
|
|
||||||
/* does not support pool namespace yet */
|
/* 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);
|
spin_lock(&ci->i_ceph_lock);
|
||||||
flags = ci->i_ceph_flags;
|
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);
|
spin_unlock(&ci->i_ceph_lock);
|
||||||
check:
|
check:
|
||||||
if (flags & CEPH_I_POOL_PERM) {
|
if (flags & CEPH_I_POOL_PERM) {
|
||||||
if ((need & CEPH_CAP_FILE_RD) && !(flags & CEPH_I_POOL_RD)) {
|
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);
|
pool);
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
if ((need & CEPH_CAP_FILE_WR) && !(flags & CEPH_I_POOL_WR)) {
|
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);
|
pool);
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
@ -1907,10 +1907,10 @@ int ceph_pool_perm_check(struct ceph_inode_info *ci, int need)
|
||||||
flags |= CEPH_I_POOL_WR;
|
flags |= CEPH_I_POOL_WR;
|
||||||
|
|
||||||
spin_lock(&ci->i_ceph_lock);
|
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;
|
ci->i_ceph_flags = flags;
|
||||||
} else {
|
} else {
|
||||||
pool = ceph_file_layout_pg_pool(ci->i_layout);
|
pool = ci->i_layout.pool_id;
|
||||||
flags = ci->i_ceph_flags;
|
flags = ci->i_ceph_flags;
|
||||||
}
|
}
|
||||||
spin_unlock(&ci->i_ceph_lock);
|
spin_unlock(&ci->i_ceph_lock);
|
||||||
|
|
|
@ -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)) {
|
if (newcaps & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR)) {
|
||||||
/* file layout may have changed */
|
/* 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;
|
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? */
|
/* size/truncate_seq? */
|
||||||
queue_trunc = ceph_fill_file_size(inode, issued,
|
queue_trunc = ceph_fill_file_size(inode, issued,
|
||||||
|
|
|
@ -1583,9 +1583,9 @@ static int ceph_zero_objects(struct inode *inode, loff_t offset, loff_t length)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct ceph_inode_info *ci = ceph_inode(inode);
|
struct ceph_inode_info *ci = ceph_inode(inode);
|
||||||
s32 stripe_unit = ceph_file_layout_su(ci->i_layout);
|
s32 stripe_unit = ci->i_layout.stripe_unit;
|
||||||
s32 stripe_count = ceph_file_layout_stripe_count(ci->i_layout);
|
s32 stripe_count = ci->i_layout.stripe_count;
|
||||||
s32 object_size = ceph_file_layout_object_size(ci->i_layout);
|
s32 object_size = ci->i_layout.object_size;
|
||||||
u64 object_set_size = object_size * stripe_count;
|
u64 object_set_size = object_size * stripe_count;
|
||||||
u64 nearly, t;
|
u64 nearly, t;
|
||||||
|
|
||||||
|
|
|
@ -814,10 +814,11 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
|
||||||
|
|
||||||
if (new_version ||
|
if (new_version ||
|
||||||
(new_issued & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR))) {
|
(new_issued & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR))) {
|
||||||
if (ci->i_layout.fl_pg_pool != info->layout.fl_pg_pool)
|
s64 old_pool = ci->i_layout.pool_id;
|
||||||
ci->i_ceph_flags &= ~CEPH_I_POOL_PERM;
|
ceph_file_layout_from_legacy(&ci->i_layout, &info->layout);
|
||||||
ci->i_layout = info->layout;
|
|
||||||
ci->i_pool_ns_len = iinfo->pool_ns_len;
|
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,
|
queue_trunc = ceph_fill_file_size(inode, issued,
|
||||||
le32_to_cpu(info->truncate_seq),
|
le32_to_cpu(info->truncate_seq),
|
||||||
|
|
|
@ -21,10 +21,10 @@ static long ceph_ioctl_get_layout(struct file *file, void __user *arg)
|
||||||
|
|
||||||
err = ceph_do_getattr(file_inode(file), CEPH_STAT_CAP_LAYOUT, false);
|
err = ceph_do_getattr(file_inode(file), CEPH_STAT_CAP_LAYOUT, false);
|
||||||
if (!err) {
|
if (!err) {
|
||||||
l.stripe_unit = ceph_file_layout_su(ci->i_layout);
|
l.stripe_unit = ci->i_layout.stripe_unit;
|
||||||
l.stripe_count = ceph_file_layout_stripe_count(ci->i_layout);
|
l.stripe_count = ci->i_layout.stripe_count;
|
||||||
l.object_size = ceph_file_layout_object_size(ci->i_layout);
|
l.object_size = ci->i_layout.object_size;
|
||||||
l.data_pool = le32_to_cpu(ci->i_layout.fl_pg_pool);
|
l.data_pool = ci->i_layout.pool_id;
|
||||||
l.preferred_osd = (s32)-1;
|
l.preferred_osd = (s32)-1;
|
||||||
if (copy_to_user(arg, &l, sizeof(l)))
|
if (copy_to_user(arg, &l, sizeof(l)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
@ -82,19 +82,19 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
|
||||||
if (l.stripe_count)
|
if (l.stripe_count)
|
||||||
nl.stripe_count = l.stripe_count;
|
nl.stripe_count = l.stripe_count;
|
||||||
else
|
else
|
||||||
nl.stripe_count = ceph_file_layout_stripe_count(ci->i_layout);
|
nl.stripe_count = ci->i_layout.stripe_count;
|
||||||
if (l.stripe_unit)
|
if (l.stripe_unit)
|
||||||
nl.stripe_unit = l.stripe_unit;
|
nl.stripe_unit = l.stripe_unit;
|
||||||
else
|
else
|
||||||
nl.stripe_unit = ceph_file_layout_su(ci->i_layout);
|
nl.stripe_unit = ci->i_layout.stripe_unit;
|
||||||
if (l.object_size)
|
if (l.object_size)
|
||||||
nl.object_size = l.object_size;
|
nl.object_size = l.object_size;
|
||||||
else
|
else
|
||||||
nl.object_size = ceph_file_layout_object_size(ci->i_layout);
|
nl.object_size = ci->i_layout.object_size;
|
||||||
if (l.data_pool)
|
if (l.data_pool)
|
||||||
nl.data_pool = l.data_pool;
|
nl.data_pool = l.data_pool;
|
||||||
else
|
else
|
||||||
nl.data_pool = ceph_file_layout_pg_pool(ci->i_layout);
|
nl.data_pool = ci->i_layout.pool_id;
|
||||||
|
|
||||||
/* this is obsolete, and always -1 */
|
/* this is obsolete, and always -1 */
|
||||||
nl.preferred_osd = le64_to_cpu(-1);
|
nl.preferred_osd = le64_to_cpu(-1);
|
||||||
|
@ -202,8 +202,8 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
dl.file_offset -= dl.object_offset;
|
dl.file_offset -= dl.object_offset;
|
||||||
dl.object_size = ceph_file_layout_object_size(ci->i_layout);
|
dl.object_size = ci->i_layout.object_size;
|
||||||
dl.block_size = ceph_file_layout_su(ci->i_layout);
|
dl.block_size = ci->i_layout.stripe_unit;
|
||||||
|
|
||||||
/* block_offset = object_offset % block_size */
|
/* block_offset = object_offset % block_size */
|
||||||
tmp = dl.object_offset;
|
tmp = dl.object_offset;
|
||||||
|
@ -212,7 +212,7 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
|
||||||
snprintf(dl.object_name, sizeof(dl.object_name), "%llx.%08llx",
|
snprintf(dl.object_name, sizeof(dl.object_name), "%llx.%08llx",
|
||||||
ceph_ino(inode), dl.object_no);
|
ceph_ino(inode), dl.object_no);
|
||||||
|
|
||||||
oloc.pool = ceph_file_layout_pg_pool(ci->i_layout);
|
oloc.pool = ci->i_layout.pool_id;
|
||||||
ceph_oid_printf(&oid, "%s", dl.object_name);
|
ceph_oid_printf(&oid, "%s", dl.object_name);
|
||||||
|
|
||||||
r = ceph_object_locator_to_pg(osdc->osdmap, &oid, &oloc, &pgid);
|
r = ceph_object_locator_to_pg(osdc->osdmap, &oid, &oloc, &pgid);
|
||||||
|
|
|
@ -275,8 +275,8 @@ struct ceph_mds_request {
|
||||||
|
|
||||||
struct ceph_pool_perm {
|
struct ceph_pool_perm {
|
||||||
struct rb_node node;
|
struct rb_node node;
|
||||||
u32 pool;
|
|
||||||
int perm;
|
int perm;
|
||||||
|
s64 pool;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -72,7 +72,7 @@ static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val,
|
||||||
int ret;
|
int ret;
|
||||||
struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb);
|
struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb);
|
||||||
struct ceph_osd_client *osdc = &fsc->client->osdc;
|
struct ceph_osd_client *osdc = &fsc->client->osdc;
|
||||||
s64 pool = ceph_file_layout_pg_pool(ci->i_layout);
|
s64 pool = ci->i_layout.pool_id;
|
||||||
const char *pool_name;
|
const char *pool_name;
|
||||||
char buf[128];
|
char buf[128];
|
||||||
|
|
||||||
|
@ -82,10 +82,9 @@ static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val,
|
||||||
if (pool_name) {
|
if (pool_name) {
|
||||||
size_t len = strlen(pool_name);
|
size_t len = strlen(pool_name);
|
||||||
ret = snprintf(buf, sizeof(buf),
|
ret = snprintf(buf, sizeof(buf),
|
||||||
"stripe_unit=%lld stripe_count=%lld object_size=%lld pool=",
|
"stripe_unit=%u stripe_count=%u object_size=%u pool=",
|
||||||
(unsigned long long)ceph_file_layout_su(ci->i_layout),
|
ci->i_layout.stripe_unit, ci->i_layout.stripe_count,
|
||||||
(unsigned long long)ceph_file_layout_stripe_count(ci->i_layout),
|
ci->i_layout.object_size);
|
||||||
(unsigned long long)ceph_file_layout_object_size(ci->i_layout));
|
|
||||||
if (!size) {
|
if (!size) {
|
||||||
ret += len;
|
ret += len;
|
||||||
} else if (ret + len > size) {
|
} else if (ret + len > size) {
|
||||||
|
@ -97,11 +96,9 @@ static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ret = snprintf(buf, sizeof(buf),
|
ret = snprintf(buf, sizeof(buf),
|
||||||
"stripe_unit=%lld stripe_count=%lld object_size=%lld pool=%lld",
|
"stripe_unit=%u stripe_count=%u object_size=%u pool=%lld",
|
||||||
(unsigned long long)ceph_file_layout_su(ci->i_layout),
|
ci->i_layout.stripe_unit, ci->i_layout.stripe_count,
|
||||||
(unsigned long long)ceph_file_layout_stripe_count(ci->i_layout),
|
ci->i_layout.object_size, (unsigned long long)pool);
|
||||||
(unsigned long long)ceph_file_layout_object_size(ci->i_layout),
|
|
||||||
(unsigned long long)pool);
|
|
||||||
if (size) {
|
if (size) {
|
||||||
if (ret <= size)
|
if (ret <= size)
|
||||||
memcpy(val, buf, ret);
|
memcpy(val, buf, ret);
|
||||||
|
@ -116,22 +113,19 @@ static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val,
|
||||||
static size_t ceph_vxattrcb_layout_stripe_unit(struct ceph_inode_info *ci,
|
static size_t ceph_vxattrcb_layout_stripe_unit(struct ceph_inode_info *ci,
|
||||||
char *val, size_t size)
|
char *val, size_t size)
|
||||||
{
|
{
|
||||||
return snprintf(val, size, "%lld",
|
return snprintf(val, size, "%u", ci->i_layout.stripe_unit);
|
||||||
(unsigned long long)ceph_file_layout_su(ci->i_layout));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t ceph_vxattrcb_layout_stripe_count(struct ceph_inode_info *ci,
|
static size_t ceph_vxattrcb_layout_stripe_count(struct ceph_inode_info *ci,
|
||||||
char *val, size_t size)
|
char *val, size_t size)
|
||||||
{
|
{
|
||||||
return snprintf(val, size, "%lld",
|
return snprintf(val, size, "%u", ci->i_layout.stripe_count);
|
||||||
(unsigned long long)ceph_file_layout_stripe_count(ci->i_layout));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t ceph_vxattrcb_layout_object_size(struct ceph_inode_info *ci,
|
static size_t ceph_vxattrcb_layout_object_size(struct ceph_inode_info *ci,
|
||||||
char *val, size_t size)
|
char *val, size_t size)
|
||||||
{
|
{
|
||||||
return snprintf(val, size, "%lld",
|
return snprintf(val, size, "%u", ci->i_layout.object_size);
|
||||||
(unsigned long long)ceph_file_layout_object_size(ci->i_layout));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t ceph_vxattrcb_layout_pool(struct ceph_inode_info *ci,
|
static size_t ceph_vxattrcb_layout_pool(struct ceph_inode_info *ci,
|
||||||
|
@ -140,7 +134,7 @@ static size_t ceph_vxattrcb_layout_pool(struct ceph_inode_info *ci,
|
||||||
int ret;
|
int ret;
|
||||||
struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb);
|
struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb);
|
||||||
struct ceph_osd_client *osdc = &fsc->client->osdc;
|
struct ceph_osd_client *osdc = &fsc->client->osdc;
|
||||||
s64 pool = ceph_file_layout_pg_pool(ci->i_layout);
|
s64 pool = ci->i_layout.pool_id;
|
||||||
const char *pool_name;
|
const char *pool_name;
|
||||||
|
|
||||||
down_read(&osdc->lock);
|
down_read(&osdc->lock);
|
||||||
|
|
|
@ -34,9 +34,9 @@
|
||||||
#define CEPH_MAX_MON 31
|
#define CEPH_MAX_MON 31
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ceph_file_layout - describe data layout for a file/inode
|
* legacy ceph_file_layoute
|
||||||
*/
|
*/
|
||||||
struct ceph_file_layout {
|
struct ceph_file_layout_legacy {
|
||||||
/* file -> object mapping */
|
/* file -> object mapping */
|
||||||
__le32 fl_stripe_unit; /* stripe unit, in bytes. must be multiple
|
__le32 fl_stripe_unit; /* stripe unit, in bytes. must be multiple
|
||||||
of page size. */
|
of page size. */
|
||||||
|
@ -53,33 +53,25 @@ struct ceph_file_layout {
|
||||||
__le32 fl_pg_pool; /* namespace, crush ruleset, rep level */
|
__le32 fl_pg_pool; /* namespace, crush ruleset, rep level */
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
#define ceph_file_layout_su(l) ((__s32)le32_to_cpu((l).fl_stripe_unit))
|
/*
|
||||||
#define ceph_file_layout_stripe_count(l) \
|
* ceph_file_layout - describe data layout for a file/inode
|
||||||
((__s32)le32_to_cpu((l).fl_stripe_count))
|
*/
|
||||||
#define ceph_file_layout_object_size(l) ((__s32)le32_to_cpu((l).fl_object_size))
|
struct ceph_file_layout {
|
||||||
#define ceph_file_layout_cas_hash(l) ((__s32)le32_to_cpu((l).fl_cas_hash))
|
/* file -> object mapping */
|
||||||
#define ceph_file_layout_object_su(l) \
|
u32 stripe_unit; /* stripe unit, in bytes */
|
||||||
((__s32)le32_to_cpu((l).fl_object_stripe_unit))
|
u32 stripe_count; /* over this many objects */
|
||||||
#define ceph_file_layout_pg_pool(l) \
|
u32 object_size; /* until objects are this big */
|
||||||
((__s32)le32_to_cpu((l).fl_pg_pool))
|
s64 pool_id; /* rados pool id */
|
||||||
|
};
|
||||||
|
|
||||||
static inline unsigned ceph_file_layout_stripe_width(struct ceph_file_layout *l)
|
extern int ceph_file_layout_is_valid(const struct ceph_file_layout *layout);
|
||||||
{
|
extern void ceph_file_layout_from_legacy(struct ceph_file_layout *fl,
|
||||||
return le32_to_cpu(l->fl_stripe_unit) *
|
struct ceph_file_layout_legacy *legacy);
|
||||||
le32_to_cpu(l->fl_stripe_count);
|
extern void ceph_file_layout_to_legacy(struct ceph_file_layout *fl,
|
||||||
}
|
struct ceph_file_layout_legacy *legacy);
|
||||||
|
|
||||||
/* "period" == bytes before i start on a new set of objects */
|
|
||||||
static inline unsigned ceph_file_layout_period(struct ceph_file_layout *l)
|
|
||||||
{
|
|
||||||
return le32_to_cpu(l->fl_object_size) *
|
|
||||||
le32_to_cpu(l->fl_stripe_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define CEPH_MIN_STRIPE_UNIT 65536
|
#define CEPH_MIN_STRIPE_UNIT 65536
|
||||||
|
|
||||||
int ceph_file_layout_is_valid(const struct ceph_file_layout *layout);
|
|
||||||
|
|
||||||
struct ceph_dir_layout {
|
struct ceph_dir_layout {
|
||||||
__u8 dl_dir_hash; /* see ceph_hash.h for ids */
|
__u8 dl_dir_hash; /* see ceph_hash.h for ids */
|
||||||
__u8 dl_unused1;
|
__u8 dl_unused1;
|
||||||
|
@ -399,7 +391,7 @@ union ceph_mds_request_args {
|
||||||
__le32 flags;
|
__le32 flags;
|
||||||
} __attribute__ ((packed)) setxattr;
|
} __attribute__ ((packed)) setxattr;
|
||||||
struct {
|
struct {
|
||||||
struct ceph_file_layout layout;
|
struct ceph_file_layout_legacy layout;
|
||||||
} __attribute__ ((packed)) setlayout;
|
} __attribute__ ((packed)) setlayout;
|
||||||
struct {
|
struct {
|
||||||
__u8 rule; /* currently fcntl or flock */
|
__u8 rule; /* currently fcntl or flock */
|
||||||
|
@ -478,7 +470,7 @@ struct ceph_mds_reply_inode {
|
||||||
__le64 version; /* inode version */
|
__le64 version; /* inode version */
|
||||||
__le64 xattr_version; /* version for xattr blob */
|
__le64 xattr_version; /* version for xattr blob */
|
||||||
struct ceph_mds_reply_cap cap; /* caps issued for this inode */
|
struct ceph_mds_reply_cap cap; /* caps issued for this inode */
|
||||||
struct ceph_file_layout layout;
|
struct ceph_file_layout_legacy layout;
|
||||||
struct ceph_timespec ctime, mtime, atime;
|
struct ceph_timespec ctime, mtime, atime;
|
||||||
__le32 time_warp_seq;
|
__le32 time_warp_seq;
|
||||||
__le64 size, max_size, truncate_size;
|
__le64 size, max_size, truncate_size;
|
||||||
|
@ -673,7 +665,7 @@ struct ceph_mds_caps {
|
||||||
__le64 size, max_size, truncate_size;
|
__le64 size, max_size, truncate_size;
|
||||||
__le32 truncate_seq;
|
__le32 truncate_seq;
|
||||||
struct ceph_timespec mtime, atime, ctime;
|
struct ceph_timespec mtime, atime, ctime;
|
||||||
struct ceph_file_layout layout;
|
struct ceph_file_layout_legacy layout;
|
||||||
__le32 time_warp_seq;
|
__le32 time_warp_seq;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
*/
|
*/
|
||||||
int ceph_file_layout_is_valid(const struct ceph_file_layout *layout)
|
int ceph_file_layout_is_valid(const struct ceph_file_layout *layout)
|
||||||
{
|
{
|
||||||
__u32 su = le32_to_cpu(layout->fl_stripe_unit);
|
__u32 su = layout->stripe_unit;
|
||||||
__u32 sc = le32_to_cpu(layout->fl_stripe_count);
|
__u32 sc = layout->stripe_count;
|
||||||
__u32 os = le32_to_cpu(layout->fl_object_size);
|
__u32 os = layout->object_size;
|
||||||
|
|
||||||
/* stripe unit, object size must be non-zero, 64k increment */
|
/* stripe unit, object size must be non-zero, 64k increment */
|
||||||
if (!su || (su & (CEPH_MIN_STRIPE_UNIT-1)))
|
if (!su || (su & (CEPH_MIN_STRIPE_UNIT-1)))
|
||||||
|
@ -27,6 +27,30 @@ int ceph_file_layout_is_valid(const struct ceph_file_layout *layout)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ceph_file_layout_from_legacy(struct ceph_file_layout *fl,
|
||||||
|
struct ceph_file_layout_legacy *legacy)
|
||||||
|
{
|
||||||
|
fl->stripe_unit = le32_to_cpu(legacy->fl_stripe_unit);
|
||||||
|
fl->stripe_count = le32_to_cpu(legacy->fl_stripe_count);
|
||||||
|
fl->object_size = le32_to_cpu(legacy->fl_object_size);
|
||||||
|
fl->pool_id = le32_to_cpu(legacy->fl_pg_pool);
|
||||||
|
if (fl->pool_id == 0)
|
||||||
|
fl->pool_id = -1;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(ceph_file_layout_from_legacy);
|
||||||
|
|
||||||
|
void ceph_file_layout_to_legacy(struct ceph_file_layout *fl,
|
||||||
|
struct ceph_file_layout_legacy *legacy)
|
||||||
|
{
|
||||||
|
legacy->fl_stripe_unit = cpu_to_le32(fl->stripe_unit);
|
||||||
|
legacy->fl_stripe_count = cpu_to_le32(fl->stripe_count);
|
||||||
|
legacy->fl_object_size = cpu_to_le32(fl->object_size);
|
||||||
|
if (fl->pool_id >= 0)
|
||||||
|
legacy->fl_pg_pool = cpu_to_le32(fl->pool_id);
|
||||||
|
else
|
||||||
|
legacy->fl_pg_pool = 0;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(ceph_file_layout_to_legacy);
|
||||||
|
|
||||||
int ceph_flags_to_mode(int flags)
|
int ceph_flags_to_mode(int flags)
|
||||||
{
|
{
|
||||||
|
|
|
@ -932,7 +932,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
|
||||||
if (opcode == CEPH_OSD_OP_CREATE || opcode == CEPH_OSD_OP_DELETE) {
|
if (opcode == CEPH_OSD_OP_CREATE || opcode == CEPH_OSD_OP_DELETE) {
|
||||||
osd_req_op_init(req, which, opcode, 0);
|
osd_req_op_init(req, which, opcode, 0);
|
||||||
} else {
|
} else {
|
||||||
u32 object_size = le32_to_cpu(layout->fl_object_size);
|
u32 object_size = layout->object_size;
|
||||||
u32 object_base = off - objoff;
|
u32 object_base = off - objoff;
|
||||||
if (!(truncate_seq == 1 && truncate_size == -1ULL)) {
|
if (!(truncate_seq == 1 && truncate_size == -1ULL)) {
|
||||||
if (truncate_size <= object_base) {
|
if (truncate_size <= object_base) {
|
||||||
|
@ -948,7 +948,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
|
||||||
}
|
}
|
||||||
|
|
||||||
req->r_flags = flags;
|
req->r_flags = flags;
|
||||||
req->r_base_oloc.pool = ceph_file_layout_pg_pool(*layout);
|
req->r_base_oloc.pool = layout->pool_id;
|
||||||
ceph_oid_printf(&req->r_base_oid, "%llx.%08llx", vino.ino, objnum);
|
ceph_oid_printf(&req->r_base_oid, "%llx.%08llx", vino.ino, objnum);
|
||||||
|
|
||||||
req->r_snapid = vino.snap;
|
req->r_snapid = vino.snap;
|
||||||
|
|
|
@ -1770,9 +1770,9 @@ int ceph_calc_file_object_mapping(struct ceph_file_layout *layout,
|
||||||
u64 *ono,
|
u64 *ono,
|
||||||
u64 *oxoff, u64 *oxlen)
|
u64 *oxoff, u64 *oxlen)
|
||||||
{
|
{
|
||||||
u32 osize = le32_to_cpu(layout->fl_object_size);
|
u32 osize = layout->object_size;
|
||||||
u32 su = le32_to_cpu(layout->fl_stripe_unit);
|
u32 su = layout->stripe_unit;
|
||||||
u32 sc = le32_to_cpu(layout->fl_stripe_count);
|
u32 sc = layout->stripe_count;
|
||||||
u32 bl, stripeno, stripepos, objsetno;
|
u32 bl, stripeno, stripepos, objsetno;
|
||||||
u32 su_per_object;
|
u32 su_per_object;
|
||||||
u64 t, su_offset;
|
u64 t, su_offset;
|
||||||
|
|
Loading…
Reference in New Issue