Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
a8823a3b
Q
qemu
项目概览
openeuler
/
qemu
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a8823a3b
编写于
3月 08, 2016
作者:
K
Kevin Wolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
block: Use blk_co_pwritev() for blk_write()
Signed-off-by:
N
Kevin Wolf
<
kwolf@redhat.com
>
上级
1bf1cbc9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
34 addition
and
13 deletion
+34
-13
block/block-backend.c
block/block-backend.c
+30
-9
block/io.c
block/io.c
+1
-4
include/block/block_int.h
include/block/block_int.h
+3
-0
未找到文件。
block/block-backend.c
浏览文件 @
a8823a3b
...
...
@@ -707,6 +707,18 @@ static int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset,
return
bdrv_co_do_preadv
(
blk_bs
(
blk
),
offset
,
bytes
,
qiov
,
flags
);
}
static
int
coroutine_fn
blk_co_pwritev
(
BlockBackend
*
blk
,
int64_t
offset
,
unsigned
int
bytes
,
QEMUIOVector
*
qiov
,
BdrvRequestFlags
flags
)
{
int
ret
=
blk_check_byte_request
(
blk
,
offset
,
bytes
);
if
(
ret
<
0
)
{
return
ret
;
}
return
bdrv_co_do_pwritev
(
blk_bs
(
blk
),
offset
,
bytes
,
qiov
,
flags
);
}
typedef
struct
BlkRwCo
{
BlockBackend
*
blk
;
int64_t
offset
;
...
...
@@ -723,8 +735,16 @@ static void blk_read_entry(void *opaque)
rwco
->
qiov
,
rwco
->
flags
);
}
int
blk_read
(
BlockBackend
*
blk
,
int64_t
sector_num
,
uint8_t
*
buf
,
int
nb_sectors
)
static
void
blk_write_entry
(
void
*
opaque
)
{
BlkRwCo
*
rwco
=
opaque
;
rwco
->
ret
=
blk_co_pwritev
(
rwco
->
blk
,
rwco
->
offset
,
rwco
->
qiov
->
size
,
rwco
->
qiov
,
rwco
->
flags
);
}
static
int
blk_rw
(
BlockBackend
*
blk
,
int64_t
sector_num
,
uint8_t
*
buf
,
int
nb_sectors
,
CoroutineEntry
co_entry
)
{
AioContext
*
aio_context
;
QEMUIOVector
qiov
;
...
...
@@ -749,7 +769,7 @@ int blk_read(BlockBackend *blk, int64_t sector_num, uint8_t *buf,
.
ret
=
NOT_DONE
,
};
co
=
qemu_coroutine_create
(
blk_read
_entry
);
co
=
qemu_coroutine_create
(
co
_entry
);
qemu_coroutine_enter
(
co
,
&
rwco
);
aio_context
=
blk_get_aio_context
(
blk
);
...
...
@@ -760,6 +780,12 @@ int blk_read(BlockBackend *blk, int64_t sector_num, uint8_t *buf,
return
rwco
.
ret
;
}
int
blk_read
(
BlockBackend
*
blk
,
int64_t
sector_num
,
uint8_t
*
buf
,
int
nb_sectors
)
{
return
blk_rw
(
blk
,
sector_num
,
buf
,
nb_sectors
,
blk_read_entry
);
}
int
blk_read_unthrottled
(
BlockBackend
*
blk
,
int64_t
sector_num
,
uint8_t
*
buf
,
int
nb_sectors
)
{
...
...
@@ -774,12 +800,7 @@ int blk_read_unthrottled(BlockBackend *blk, int64_t sector_num, uint8_t *buf,
int
blk_write
(
BlockBackend
*
blk
,
int64_t
sector_num
,
const
uint8_t
*
buf
,
int
nb_sectors
)
{
int
ret
=
blk_check_request
(
blk
,
sector_num
,
nb_sectors
);
if
(
ret
<
0
)
{
return
ret
;
}
return
bdrv_write
(
blk_bs
(
blk
),
sector_num
,
buf
,
nb_sectors
);
return
blk_rw
(
blk
,
sector_num
,
(
uint8_t
*
)
buf
,
nb_sectors
,
blk_write_entry
);
}
int
blk_write_zeroes
(
BlockBackend
*
blk
,
int64_t
sector_num
,
...
...
block/io.c
浏览文件 @
a8823a3b
...
...
@@ -44,9 +44,6 @@ static int coroutine_fn bdrv_co_readv_em(BlockDriverState *bs,
static
int
coroutine_fn
bdrv_co_writev_em
(
BlockDriverState
*
bs
,
int64_t
sector_num
,
int
nb_sectors
,
QEMUIOVector
*
iov
);
static
int
coroutine_fn
bdrv_co_do_pwritev
(
BlockDriverState
*
bs
,
int64_t
offset
,
unsigned
int
bytes
,
QEMUIOVector
*
qiov
,
BdrvRequestFlags
flags
);
static
BlockAIOCB
*
bdrv_co_aio_rw_vector
(
BlockDriverState
*
bs
,
int64_t
sector_num
,
QEMUIOVector
*
qiov
,
...
...
@@ -1281,7 +1278,7 @@ fail:
/*
* Handle a write request in coroutine context
*/
static
int
coroutine_fn
bdrv_co_do_pwritev
(
BlockDriverState
*
bs
,
int
coroutine_fn
bdrv_co_do_pwritev
(
BlockDriverState
*
bs
,
int64_t
offset
,
unsigned
int
bytes
,
QEMUIOVector
*
qiov
,
BdrvRequestFlags
flags
)
{
...
...
include/block/block_int.h
浏览文件 @
a8823a3b
...
...
@@ -511,6 +511,9 @@ void bdrv_setup_io_funcs(BlockDriver *bdrv);
int
coroutine_fn
bdrv_co_do_preadv
(
BlockDriverState
*
bs
,
int64_t
offset
,
unsigned
int
bytes
,
QEMUIOVector
*
qiov
,
BdrvRequestFlags
flags
);
int
coroutine_fn
bdrv_co_do_pwritev
(
BlockDriverState
*
bs
,
int64_t
offset
,
unsigned
int
bytes
,
QEMUIOVector
*
qiov
,
BdrvRequestFlags
flags
);
int
get_tmp_filename
(
char
*
filename
,
int
size
);
BlockDriver
*
bdrv_probe_all
(
const
uint8_t
*
buf
,
int
buf_size
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录