Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
57d6a428
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看板
提交
57d6a428
编写于
3月 08, 2016
作者:
K
Kevin Wolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
block: Use blk_aio_prwv() for aio_read/write/write_zeroes
Signed-off-by:
N
Kevin Wolf
<
kwolf@redhat.com
>
上级
a55d3fba
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
92 addition
and
13 deletion
+92
-13
block/block-backend.c
block/block-backend.c
+92
-13
未找到文件。
block/block-backend.c
浏览文件 @
57d6a428
...
...
@@ -855,17 +855,96 @@ BlockAIOCB *blk_abort_aio_request(BlockBackend *blk,
return
&
acb
->
common
;
}
typedef
struct
BlkAioEmAIOCB
{
BlockAIOCB
common
;
BlkRwCo
rwco
;
bool
has_returned
;
QEMUBH
*
bh
;
}
BlkAioEmAIOCB
;
static
const
AIOCBInfo
blk_aio_em_aiocb_info
=
{
.
aiocb_size
=
sizeof
(
BlkAioEmAIOCB
),
};
static
void
blk_aio_complete
(
BlkAioEmAIOCB
*
acb
)
{
if
(
acb
->
bh
)
{
assert
(
acb
->
has_returned
);
qemu_bh_delete
(
acb
->
bh
);
}
if
(
acb
->
has_returned
)
{
acb
->
common
.
cb
(
acb
->
common
.
opaque
,
acb
->
rwco
.
ret
);
qemu_aio_unref
(
acb
);
}
}
static
void
blk_aio_complete_bh
(
void
*
opaque
)
{
blk_aio_complete
(
opaque
);
}
static
BlockAIOCB
*
blk_aio_prwv
(
BlockBackend
*
blk
,
int64_t
offset
,
QEMUIOVector
*
qiov
,
CoroutineEntry
co_entry
,
BdrvRequestFlags
flags
,
BlockCompletionFunc
*
cb
,
void
*
opaque
)
{
BlkAioEmAIOCB
*
acb
;
Coroutine
*
co
;
acb
=
blk_aio_get
(
&
blk_aio_em_aiocb_info
,
blk
,
cb
,
opaque
);
acb
->
rwco
=
(
BlkRwCo
)
{
.
blk
=
blk
,
.
offset
=
offset
,
.
qiov
=
qiov
,
.
flags
=
flags
,
.
ret
=
NOT_DONE
,
};
acb
->
bh
=
NULL
;
acb
->
has_returned
=
false
;
co
=
qemu_coroutine_create
(
co_entry
);
qemu_coroutine_enter
(
co
,
acb
);
acb
->
has_returned
=
true
;
if
(
acb
->
rwco
.
ret
!=
NOT_DONE
)
{
acb
->
bh
=
aio_bh_new
(
blk_get_aio_context
(
blk
),
blk_aio_complete_bh
,
acb
);
qemu_bh_schedule
(
acb
->
bh
);
}
return
&
acb
->
common
;
}
static
void
blk_aio_read_entry
(
void
*
opaque
)
{
BlkAioEmAIOCB
*
acb
=
opaque
;
BlkRwCo
*
rwco
=
&
acb
->
rwco
;
rwco
->
ret
=
blk_co_preadv
(
rwco
->
blk
,
rwco
->
offset
,
rwco
->
qiov
->
size
,
rwco
->
qiov
,
rwco
->
flags
);
blk_aio_complete
(
acb
);
}
static
void
blk_aio_write_entry
(
void
*
opaque
)
{
BlkAioEmAIOCB
*
acb
=
opaque
;
BlkRwCo
*
rwco
=
&
acb
->
rwco
;
rwco
->
ret
=
blk_co_pwritev
(
rwco
->
blk
,
rwco
->
offset
,
rwco
->
qiov
?
rwco
->
qiov
->
size
:
0
,
rwco
->
qiov
,
rwco
->
flags
);
blk_aio_complete
(
acb
);
}
BlockAIOCB
*
blk_aio_write_zeroes
(
BlockBackend
*
blk
,
int64_t
sector_num
,
int
nb_sectors
,
BdrvRequestFlags
flags
,
BlockCompletionFunc
*
cb
,
void
*
opaque
)
{
int
ret
=
blk_check_request
(
blk
,
sector_num
,
nb_sectors
);
if
(
ret
<
0
)
{
return
blk_abort_aio_request
(
blk
,
cb
,
opaque
,
ret
);
if
(
nb_sectors
<
0
||
nb_sectors
>
BDRV_REQUEST_MAX_SECTORS
)
{
return
blk_abort_aio_request
(
blk
,
cb
,
opaque
,
-
EINVAL
);
}
return
b
drv_aio_write_zeroes
(
blk_bs
(
blk
),
sector_num
,
nb_sectors
,
flags
,
cb
,
opaque
);
return
b
lk_aio_prwv
(
blk
,
sector_num
<<
BDRV_SECTOR_BITS
,
NULL
,
blk_aio_write_entry
,
BDRV_REQ_ZERO_WRITE
,
cb
,
opaque
);
}
int
blk_pread
(
BlockBackend
*
blk
,
int64_t
offset
,
void
*
buf
,
int
count
)
...
...
@@ -917,24 +996,24 @@ BlockAIOCB *blk_aio_readv(BlockBackend *blk, int64_t sector_num,
QEMUIOVector
*
iov
,
int
nb_sectors
,
BlockCompletionFunc
*
cb
,
void
*
opaque
)
{
int
ret
=
blk_check_request
(
blk
,
sector_num
,
nb_sectors
);
if
(
ret
<
0
)
{
return
blk_abort_aio_request
(
blk
,
cb
,
opaque
,
ret
);
if
(
nb_sectors
<
0
||
nb_sectors
>
BDRV_REQUEST_MAX_SECTORS
)
{
return
blk_abort_aio_request
(
blk
,
cb
,
opaque
,
-
EINVAL
);
}
return
bdrv_aio_readv
(
blk_bs
(
blk
),
sector_num
,
iov
,
nb_sectors
,
cb
,
opaque
);
return
blk_aio_prwv
(
blk
,
sector_num
<<
BDRV_SECTOR_BITS
,
iov
,
blk_aio_read_entry
,
0
,
cb
,
opaque
);
}
BlockAIOCB
*
blk_aio_writev
(
BlockBackend
*
blk
,
int64_t
sector_num
,
QEMUIOVector
*
iov
,
int
nb_sectors
,
BlockCompletionFunc
*
cb
,
void
*
opaque
)
{
int
ret
=
blk_check_request
(
blk
,
sector_num
,
nb_sectors
);
if
(
ret
<
0
)
{
return
blk_abort_aio_request
(
blk
,
cb
,
opaque
,
ret
);
if
(
nb_sectors
<
0
||
nb_sectors
>
BDRV_REQUEST_MAX_SECTORS
)
{
return
blk_abort_aio_request
(
blk
,
cb
,
opaque
,
-
EINVAL
);
}
return
bdrv_aio_writev
(
blk_bs
(
blk
),
sector_num
,
iov
,
nb_sectors
,
cb
,
opaque
);
return
blk_aio_prwv
(
blk
,
sector_num
<<
BDRV_SECTOR_BITS
,
iov
,
blk_aio_write_entry
,
0
,
cb
,
opaque
);
}
BlockAIOCB
*
blk_aio_flush
(
BlockBackend
*
blk
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录