Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
a303bb0e
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
a303bb0e
编写于
6月 21, 2017
作者:
I
Ilya Dryomov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libceph: introduce and switch to decode_pg_mapping()
Signed-off-by:
N
Ilya Dryomov
<
idryomov@gmail.com
>
上级
33333d10
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
83 addition
and
67 deletion
+83
-67
net/ceph/osdmap.c
net/ceph/osdmap.c
+83
-67
未找到文件。
net/ceph/osdmap.c
浏览文件 @
a303bb0e
...
...
@@ -434,6 +434,25 @@ int ceph_spg_compare(const struct ceph_spg *lhs, const struct ceph_spg *rhs)
return
0
;
}
static
struct
ceph_pg_mapping
*
alloc_pg_mapping
(
size_t
payload_len
)
{
struct
ceph_pg_mapping
*
pg
;
pg
=
kmalloc
(
sizeof
(
*
pg
)
+
payload_len
,
GFP_NOIO
);
if
(
!
pg
)
return
NULL
;
RB_CLEAR_NODE
(
&
pg
->
node
);
return
pg
;
}
static
void
free_pg_mapping
(
struct
ceph_pg_mapping
*
pg
)
{
WARN_ON
(
!
RB_EMPTY_NODE
(
&
pg
->
node
));
kfree
(
pg
);
}
/*
* rbtree of pg_mapping for handling pg_temp (explicit mapping of pgid
* to a set of osds) and primary_temp (explicit primary setting)
...
...
@@ -1017,47 +1036,36 @@ static int decode_new_pools(void **p, void *end, struct ceph_osdmap *map)
return
__decode_pools
(
p
,
end
,
map
,
true
);
}
static
int
__decode_pg_temp
(
void
**
p
,
void
*
end
,
struct
ceph_osdmap
*
map
,
bool
incremental
)
typedef
struct
ceph_pg_mapping
*
(
*
decode_mapping_fn_t
)(
void
**
,
void
*
,
bool
);
static
int
decode_pg_mapping
(
void
**
p
,
void
*
end
,
struct
rb_root
*
mapping_root
,
decode_mapping_fn_t
fn
,
bool
incremental
)
{
u32
n
;
WARN_ON
(
!
incremental
&&
!
fn
);
ceph_decode_32_safe
(
p
,
end
,
n
,
e_inval
);
while
(
n
--
)
{
struct
ceph_pg_mapping
*
pg
;
struct
ceph_pg
pgid
;
u32
len
,
i
;
int
ret
;
ret
=
ceph_decode_pgid
(
p
,
end
,
&
pgid
);
if
(
ret
)
return
ret
;
ceph_decode_32_safe
(
p
,
end
,
len
,
e_inval
);
ret
=
__remove_pg_mapping
(
&
map
->
pg_temp
,
&
pgid
);
BUG_ON
(
!
incremental
&&
ret
!=
-
ENOENT
);
if
(
!
incremental
||
len
>
0
)
{
struct
ceph_pg_mapping
*
pg
;
ret
=
__remove_pg_mapping
(
mapping_root
,
&
pgid
);
WARN_ON
(
!
incremental
&&
ret
!=
-
ENOENT
);
ceph_decode_need
(
p
,
end
,
len
*
sizeof
(
u32
),
e_inval
);
if
(
fn
)
{
pg
=
fn
(
p
,
end
,
incremental
);
if
(
IS_ERR
(
pg
))
return
PTR_ERR
(
pg
);
if
(
len
>
(
UINT_MAX
-
sizeof
(
*
pg
))
/
sizeof
(
u32
))
return
-
EINVAL
;
pg
=
kzalloc
(
sizeof
(
*
pg
)
+
len
*
sizeof
(
u32
),
GFP_NOFS
);
if
(
!
pg
)
return
-
ENOMEM
;
pg
->
pgid
=
pgid
;
pg
->
pg_temp
.
len
=
len
;
for
(
i
=
0
;
i
<
len
;
i
++
)
pg
->
pg_temp
.
osds
[
i
]
=
ceph_decode_32
(
p
);
ret
=
__insert_pg_mapping
(
pg
,
&
map
->
pg_temp
);
if
(
ret
)
{
kfree
(
pg
);
return
ret
;
if
(
pg
)
{
pg
->
pgid
=
pgid
;
/* struct */
__insert_pg_mapping
(
pg
,
mapping_root
);
}
}
}
...
...
@@ -1068,69 +1076,77 @@ static int __decode_pg_temp(void **p, void *end, struct ceph_osdmap *map,
return
-
EINVAL
;
}
static
struct
ceph_pg_mapping
*
__decode_pg_temp
(
void
**
p
,
void
*
end
,
bool
incremental
)
{
struct
ceph_pg_mapping
*
pg
;
u32
len
,
i
;
ceph_decode_32_safe
(
p
,
end
,
len
,
e_inval
);
if
(
len
==
0
&&
incremental
)
return
NULL
;
/* new_pg_temp: [] to remove */
if
(
len
>
(
SIZE_MAX
-
sizeof
(
*
pg
))
/
sizeof
(
u32
))
return
ERR_PTR
(
-
EINVAL
);
ceph_decode_need
(
p
,
end
,
len
*
sizeof
(
u32
),
e_inval
);
pg
=
alloc_pg_mapping
(
len
*
sizeof
(
u32
));
if
(
!
pg
)
return
ERR_PTR
(
-
ENOMEM
);
pg
->
pg_temp
.
len
=
len
;
for
(
i
=
0
;
i
<
len
;
i
++
)
pg
->
pg_temp
.
osds
[
i
]
=
ceph_decode_32
(
p
);
return
pg
;
e_inval:
return
ERR_PTR
(
-
EINVAL
);
}
static
int
decode_pg_temp
(
void
**
p
,
void
*
end
,
struct
ceph_osdmap
*
map
)
{
return
__decode_pg_temp
(
p
,
end
,
map
,
false
);
return
decode_pg_mapping
(
p
,
end
,
&
map
->
pg_temp
,
__decode_pg_temp
,
false
);
}
static
int
decode_new_pg_temp
(
void
**
p
,
void
*
end
,
struct
ceph_osdmap
*
map
)
{
return
__decode_pg_temp
(
p
,
end
,
map
,
true
);
return
decode_pg_mapping
(
p
,
end
,
&
map
->
pg_temp
,
__decode_pg_temp
,
true
);
}
static
int
__decode_primary_temp
(
void
**
p
,
void
*
end
,
struct
ceph_osdmap
*
map
,
bool
incremental
)
static
struct
ceph_pg_mapping
*
__decode_primary_temp
(
void
**
p
,
void
*
end
,
bool
incremental
)
{
u32
n
;
ceph_decode_32_safe
(
p
,
end
,
n
,
e_inval
);
while
(
n
--
)
{
struct
ceph_pg
pgid
;
u32
osd
;
int
ret
;
ret
=
ceph_decode_pgid
(
p
,
end
,
&
pgid
);
if
(
ret
)
return
ret
;
ceph_decode_32_safe
(
p
,
end
,
osd
,
e_inval
);
ret
=
__remove_pg_mapping
(
&
map
->
primary_temp
,
&
pgid
);
BUG_ON
(
!
incremental
&&
ret
!=
-
ENOENT
);
if
(
!
incremental
||
osd
!=
(
u32
)
-
1
)
{
struct
ceph_pg_mapping
*
pg
;
pg
=
kzalloc
(
sizeof
(
*
pg
),
GFP_NOFS
);
if
(
!
pg
)
return
-
ENOMEM
;
struct
ceph_pg_mapping
*
pg
;
u32
osd
;
pg
->
pgid
=
pgid
;
pg
->
primary_temp
.
osd
=
osd
;
ceph_decode_32_safe
(
p
,
end
,
osd
,
e_inval
);
if
(
osd
==
(
u32
)
-
1
&&
incremental
)
return
NULL
;
/* new_primary_temp: -1 to remove */
ret
=
__insert_pg_mapping
(
pg
,
&
map
->
primary_temp
);
if
(
ret
)
{
kfree
(
pg
);
return
ret
;
}
}
}
pg
=
alloc_pg_mapping
(
0
);
if
(
!
pg
)
return
ERR_PTR
(
-
ENOMEM
);
return
0
;
pg
->
primary_temp
.
osd
=
osd
;
return
pg
;
e_inval:
return
-
EINVAL
;
return
ERR_PTR
(
-
EINVAL
)
;
}
static
int
decode_primary_temp
(
void
**
p
,
void
*
end
,
struct
ceph_osdmap
*
map
)
{
return
__decode_primary_temp
(
p
,
end
,
map
,
false
);
return
decode_pg_mapping
(
p
,
end
,
&
map
->
primary_temp
,
__decode_primary_temp
,
false
);
}
static
int
decode_new_primary_temp
(
void
**
p
,
void
*
end
,
struct
ceph_osdmap
*
map
)
{
return
__decode_primary_temp
(
p
,
end
,
map
,
true
);
return
decode_pg_mapping
(
p
,
end
,
&
map
->
primary_temp
,
__decode_primary_temp
,
true
);
}
u32
ceph_get_primary_affinity
(
struct
ceph_osdmap
*
map
,
int
osd
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录