Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
kernel_linux
提交
a5ae4300
K
kernel_linux
项目概览
OpenHarmony
/
kernel_linux
上一次同步 4 年多
通知
15
Star
8
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kernel_linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
a5ae4300
编写于
9月 10, 2013
作者:
K
Kent Overstreet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bcache: Zero less memory
Another minor performance optimization Signed-off-by:
N
Kent Overstreet
<
kmo@daterainc.com
>
上级
d56d000a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
41 addition
and
40 deletion
+41
-40
drivers/md/bcache/closure.h
drivers/md/bcache/closure.h
+1
-12
drivers/md/bcache/request.c
drivers/md/bcache/request.c
+27
-20
drivers/md/bcache/request.h
drivers/md/bcache/request.h
+13
-8
未找到文件。
drivers/md/bcache/closure.h
浏览文件 @
a5ae4300
...
@@ -347,14 +347,6 @@ do { \
...
@@ -347,14 +347,6 @@ do { \
do_closure_init(_cl, parent, running); \
do_closure_init(_cl, parent, running); \
} while (0)
} while (0)
/**
* __closure_init() - Initialize a closure, skipping the memset()
*
* May be used instead of closure_init() when memory has already been zeroed.
*/
#define __closure_init(cl, parent) \
closure_init_type(cl, parent, true)
/**
/**
* closure_init() - Initialize a closure, setting the refcount to 1
* closure_init() - Initialize a closure, setting the refcount to 1
* @cl: closure to initialize
* @cl: closure to initialize
...
@@ -362,10 +354,7 @@ do { \
...
@@ -362,10 +354,7 @@ do { \
* lifetime; may be NULL.
* lifetime; may be NULL.
*/
*/
#define closure_init(cl, parent) \
#define closure_init(cl, parent) \
do { \
closure_init_type(cl, parent, true)
memset((cl), 0, sizeof(*(cl))); \
__closure_init(cl, parent); \
} while (0)
static
inline
void
closure_init_stack
(
struct
closure
*
cl
)
static
inline
void
closure_init_stack
(
struct
closure
*
cl
)
{
{
...
...
drivers/md/bcache/request.c
浏览文件 @
a5ae4300
...
@@ -597,14 +597,12 @@ struct search {
...
@@ -597,14 +597,12 @@ struct search {
/* Stack frame for bio_complete */
/* Stack frame for bio_complete */
struct
closure
cl
;
struct
closure
cl
;
struct
bcache_device
*
d
;
struct
bbio
bio
;
struct
bbio
bio
;
struct
bio
*
orig_bio
;
struct
bio
*
orig_bio
;
struct
bio
*
cache_miss
;
struct
bio
*
cache_miss
;
struct
bcache_device
*
d
;
unsigned
insert_bio_sectors
;
unsigned
insert_bio_sectors
;
unsigned
recoverable
:
1
;
unsigned
recoverable
:
1
;
unsigned
write
:
1
;
unsigned
write
:
1
;
unsigned
read_dirty_data
:
1
;
unsigned
read_dirty_data
:
1
;
...
@@ -712,10 +710,13 @@ static void cache_lookup(struct closure *cl)
...
@@ -712,10 +710,13 @@ static void cache_lookup(struct closure *cl)
{
{
struct
search
*
s
=
container_of
(
cl
,
struct
search
,
iop
.
cl
);
struct
search
*
s
=
container_of
(
cl
,
struct
search
,
iop
.
cl
);
struct
bio
*
bio
=
&
s
->
bio
.
bio
;
struct
bio
*
bio
=
&
s
->
bio
.
bio
;
int
ret
;
int
ret
=
bch_btree_map_keys
(
&
s
->
op
,
s
->
iop
.
c
,
bch_btree_op_init
(
&
s
->
op
,
-
1
);
&
KEY
(
s
->
iop
.
inode
,
bio
->
bi_iter
.
bi_sector
,
0
),
cache_lookup_fn
,
MAP_END_KEY
);
ret
=
bch_btree_map_keys
(
&
s
->
op
,
s
->
iop
.
c
,
&
KEY
(
s
->
iop
.
inode
,
bio
->
bi_iter
.
bi_sector
,
0
),
cache_lookup_fn
,
MAP_END_KEY
);
if
(
ret
==
-
EAGAIN
)
if
(
ret
==
-
EAGAIN
)
continue_at
(
cl
,
cache_lookup
,
bcache_wq
);
continue_at
(
cl
,
cache_lookup
,
bcache_wq
);
...
@@ -756,12 +757,12 @@ static void bio_complete(struct search *s)
...
@@ -756,12 +757,12 @@ static void bio_complete(struct search *s)
}
}
}
}
static
void
do_bio_hook
(
struct
search
*
s
)
static
void
do_bio_hook
(
struct
search
*
s
,
struct
bio
*
orig_bio
)
{
{
struct
bio
*
bio
=
&
s
->
bio
.
bio
;
struct
bio
*
bio
=
&
s
->
bio
.
bio
;
bio_init
(
bio
);
bio_init
(
bio
);
__bio_clone_fast
(
bio
,
s
->
orig_bio
);
__bio_clone_fast
(
bio
,
orig_bio
);
bio
->
bi_end_io
=
request_endio
;
bio
->
bi_end_io
=
request_endio
;
bio
->
bi_private
=
&
s
->
cl
;
bio
->
bi_private
=
&
s
->
cl
;
...
@@ -780,26 +781,32 @@ static void search_free(struct closure *cl)
...
@@ -780,26 +781,32 @@ static void search_free(struct closure *cl)
mempool_free
(
s
,
s
->
d
->
c
->
search
);
mempool_free
(
s
,
s
->
d
->
c
->
search
);
}
}
static
struct
search
*
search_alloc
(
struct
bio
*
bio
,
struct
bcache_device
*
d
)
static
inline
struct
search
*
search_alloc
(
struct
bio
*
bio
,
struct
bcache_device
*
d
)
{
{
struct
search
*
s
;
struct
search
*
s
;
s
=
mempool_alloc
(
d
->
c
->
search
,
GFP_NOIO
);
s
=
mempool_alloc
(
d
->
c
->
search
,
GFP_NOIO
);
memset
(
s
,
0
,
offsetof
(
struct
search
,
iop
.
insert_keys
));
__closure_init
(
&
s
->
cl
,
NULL
);
closure_init
(
&
s
->
cl
,
NULL
);
do_bio_hook
(
s
,
bio
);
s
->
iop
.
inode
=
d
->
id
;
s
->
iop
.
c
=
d
->
c
;
s
->
d
=
d
;
s
->
op
.
lock
=
-
1
;
s
->
iop
.
write_point
=
hash_long
((
unsigned
long
)
current
,
16
);
s
->
orig_bio
=
bio
;
s
->
orig_bio
=
bio
;
s
->
write
=
(
bio
->
bi_rw
&
REQ_WRITE
)
!=
0
;
s
->
cache_miss
=
NULL
;
s
->
iop
.
flush_journal
=
(
bio
->
bi_rw
&
(
REQ_FLUSH
|
REQ_FUA
))
!=
0
;
s
->
d
=
d
;
s
->
recoverable
=
1
;
s
->
recoverable
=
1
;
s
->
write
=
(
bio
->
bi_rw
&
REQ_WRITE
)
!=
0
;
s
->
read_dirty_data
=
0
;
s
->
start_time
=
jiffies
;
s
->
start_time
=
jiffies
;
do_bio_hook
(
s
);
s
->
iop
.
c
=
d
->
c
;
s
->
iop
.
bio
=
NULL
;
s
->
iop
.
inode
=
d
->
id
;
s
->
iop
.
write_point
=
hash_long
((
unsigned
long
)
current
,
16
);
s
->
iop
.
write_prio
=
0
;
s
->
iop
.
error
=
0
;
s
->
iop
.
flags
=
0
;
s
->
iop
.
flush_journal
=
(
bio
->
bi_rw
&
(
REQ_FLUSH
|
REQ_FUA
))
!=
0
;
return
s
;
return
s
;
}
}
...
@@ -845,7 +852,7 @@ static void cached_dev_read_error(struct closure *cl)
...
@@ -845,7 +852,7 @@ static void cached_dev_read_error(struct closure *cl)
trace_bcache_read_retry
(
s
->
orig_bio
);
trace_bcache_read_retry
(
s
->
orig_bio
);
s
->
iop
.
error
=
0
;
s
->
iop
.
error
=
0
;
do_bio_hook
(
s
);
do_bio_hook
(
s
,
s
->
orig_bio
);
/* XXX: invalidate cache */
/* XXX: invalidate cache */
...
...
drivers/md/bcache/request.h
浏览文件 @
a5ae4300
...
@@ -13,17 +13,22 @@ struct data_insert_op {
...
@@ -13,17 +13,22 @@ struct data_insert_op {
uint16_t
write_prio
;
uint16_t
write_prio
;
short
error
;
short
error
;
unsigned
bypass
:
1
;
union
{
unsigned
writeback
:
1
;
uint16_t
flags
;
unsigned
flush_journal
:
1
;
unsigned
csum
:
1
;
unsigned
replace
:
1
;
struct
{
unsigned
replace_collision
:
1
;
unsigned
bypass
:
1
;
unsigned
writeback
:
1
;
unsigned
flush_journal
:
1
;
unsigned
csum
:
1
;
unsigned
insert_data_done
:
1
;
unsigned
replace
:
1
;
unsigned
replace_collision
:
1
;
unsigned
insert_data_done
:
1
;
};
};
/* Anything past this point won't get zeroed in search_alloc() */
struct
keylist
insert_keys
;
struct
keylist
insert_keys
;
BKEY_PADDED
(
replace_key
);
BKEY_PADDED
(
replace_key
);
};
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录