Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
c2e552e7
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看板
提交
c2e552e7
编写于
12月 07, 2009
作者:
S
Sage Weil
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ceph: use kref for ceph_msg
Signed-off-by:
N
Sage Weil
<
sage@newdream.net
>
上级
415e49a9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
35 deletion
+27
-35
fs/ceph/messenger.c
fs/ceph/messenger.c
+18
-29
fs/ceph/messenger.h
fs/ceph/messenger.h
+8
-5
fs/ceph/msgpool.c
fs/ceph/msgpool.c
+1
-1
未找到文件。
fs/ceph/messenger.c
浏览文件 @
c2e552e7
...
@@ -1958,7 +1958,7 @@ struct ceph_msg *ceph_msg_new(int type, int front_len,
...
@@ -1958,7 +1958,7 @@ struct ceph_msg *ceph_msg_new(int type, int front_len,
m
=
kmalloc
(
sizeof
(
*
m
),
GFP_NOFS
);
m
=
kmalloc
(
sizeof
(
*
m
),
GFP_NOFS
);
if
(
m
==
NULL
)
if
(
m
==
NULL
)
goto
out
;
goto
out
;
atomic_set
(
&
m
->
nref
,
1
);
kref_init
(
&
m
->
kref
);
INIT_LIST_HEAD
(
&
m
->
list_head
);
INIT_LIST_HEAD
(
&
m
->
list_head
);
m
->
hdr
.
type
=
cpu_to_le16
(
type
);
m
->
hdr
.
type
=
cpu_to_le16
(
type
);
...
@@ -2070,34 +2070,23 @@ void ceph_msg_kfree(struct ceph_msg *m)
...
@@ -2070,34 +2070,23 @@ void ceph_msg_kfree(struct ceph_msg *m)
/*
/*
* Drop a msg ref. Destroy as needed.
* Drop a msg ref. Destroy as needed.
*/
*/
void
ceph_msg_put
(
struct
ceph_msg
*
m
)
void
ceph_msg_last_put
(
struct
kref
*
kref
)
{
{
dout
(
"ceph_msg_put %p %d -> %d
\n
"
,
m
,
atomic_read
(
&
m
->
nref
),
struct
ceph_msg
*
m
=
container_of
(
kref
,
struct
ceph_msg
,
kref
);
atomic_read
(
&
m
->
nref
)
-
1
);
if
(
atomic_read
(
&
m
->
nref
)
<=
0
)
{
pr_err
(
"bad ceph_msg_put on %p %llu %d=%s %d+%d
\n
"
,
m
,
le64_to_cpu
(
m
->
hdr
.
seq
),
le16_to_cpu
(
m
->
hdr
.
type
),
ceph_msg_type_name
(
le16_to_cpu
(
m
->
hdr
.
type
)),
le32_to_cpu
(
m
->
hdr
.
front_len
),
le32_to_cpu
(
m
->
hdr
.
data_len
));
WARN_ON
(
1
);
}
if
(
atomic_dec_and_test
(
&
m
->
nref
))
{
dout
(
"ceph_msg_put last one on %p
\n
"
,
m
);
WARN_ON
(
!
list_empty
(
&
m
->
list_head
));
/* drop middle, data, if any */
if
(
m
->
middle
)
{
ceph_buffer_put
(
m
->
middle
);
m
->
middle
=
NULL
;
}
m
->
nr_pages
=
0
;
m
->
pages
=
NULL
;
if
(
m
->
pool
)
dout
(
"ceph_msg_put last one on %p
\n
"
,
m
);
ceph_msgpool_put
(
m
->
pool
,
m
);
WARN_ON
(
!
list_empty
(
&
m
->
list_head
));
else
ceph_msg_kfree
(
m
);
/* drop middle, data, if any */
if
(
m
->
middle
)
{
ceph_buffer_put
(
m
->
middle
);
m
->
middle
=
NULL
;
}
}
m
->
nr_pages
=
0
;
m
->
pages
=
NULL
;
if
(
m
->
pool
)
ceph_msgpool_put
(
m
->
pool
,
m
);
else
ceph_msg_kfree
(
m
);
}
}
fs/ceph/messenger.h
浏览文件 @
c2e552e7
#ifndef __FS_CEPH_MESSENGER_H
#ifndef __FS_CEPH_MESSENGER_H
#define __FS_CEPH_MESSENGER_H
#define __FS_CEPH_MESSENGER_H
#include <linux/kref.h>
#include <linux/mutex.h>
#include <linux/mutex.h>
#include <linux/net.h>
#include <linux/net.h>
#include <linux/radix-tree.h>
#include <linux/radix-tree.h>
...
@@ -85,7 +86,7 @@ struct ceph_msg {
...
@@ -85,7 +86,7 @@ struct ceph_msg {
struct
page
**
pages
;
/* data payload. NOT OWNER. */
struct
page
**
pages
;
/* data payload. NOT OWNER. */
unsigned
nr_pages
;
/* size of page array */
unsigned
nr_pages
;
/* size of page array */
struct
list_head
list_head
;
struct
list_head
list_head
;
atomic_t
n
ref
;
struct
kref
k
ref
;
bool
front_is_vmalloc
;
bool
front_is_vmalloc
;
bool
more_to_follow
;
bool
more_to_follow
;
int
front_max
;
int
front_max
;
...
@@ -243,11 +244,13 @@ extern int ceph_alloc_middle(struct ceph_connection *con, struct ceph_msg *msg);
...
@@ -243,11 +244,13 @@ extern int ceph_alloc_middle(struct ceph_connection *con, struct ceph_msg *msg);
static
inline
struct
ceph_msg
*
ceph_msg_get
(
struct
ceph_msg
*
msg
)
static
inline
struct
ceph_msg
*
ceph_msg_get
(
struct
ceph_msg
*
msg
)
{
{
dout
(
"ceph_msg_get %p %d -> %d
\n
"
,
msg
,
atomic_read
(
&
msg
->
nref
),
kref_get
(
&
msg
->
kref
);
atomic_read
(
&
msg
->
nref
)
+
1
);
atomic_inc
(
&
msg
->
nref
);
return
msg
;
return
msg
;
}
}
extern
void
ceph_msg_put
(
struct
ceph_msg
*
msg
);
extern
void
ceph_msg_last_put
(
struct
kref
*
kref
);
static
inline
void
ceph_msg_put
(
struct
ceph_msg
*
msg
)
{
kref_put
(
&
msg
->
kref
,
ceph_msg_last_put
);
}
#endif
#endif
fs/ceph/msgpool.c
浏览文件 @
c2e552e7
...
@@ -165,7 +165,7 @@ void ceph_msgpool_put(struct ceph_msgpool *pool, struct ceph_msg *msg)
...
@@ -165,7 +165,7 @@ void ceph_msgpool_put(struct ceph_msgpool *pool, struct ceph_msg *msg)
{
{
spin_lock
(
&
pool
->
lock
);
spin_lock
(
&
pool
->
lock
);
if
(
pool
->
num
<
pool
->
min
)
{
if
(
pool
->
num
<
pool
->
min
)
{
ceph_msg_get
(
msg
);
/* retake a single ref */
kref_set
(
&
msg
->
kref
,
1
);
/* retake a single ref */
list_add
(
&
msg
->
list_head
,
&
pool
->
msgs
);
list_add
(
&
msg
->
list_head
,
&
pool
->
msgs
);
pool
->
num
++
;
pool
->
num
++
;
dout
(
"msgpool_put %p reclaim %p, now %d/%d
\n
"
,
pool
,
msg
,
dout
(
"msgpool_put %p reclaim %p, now %d/%d
\n
"
,
pool
,
msg
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录