Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
226c3c26
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
226c3c26
编写于
12月 07, 2012
作者:
K
Kevin Wolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qcow2: Factor out handle_dependencies()
Signed-off-by:
N
Kevin Wolf
<
kwolf@redhat.com
>
上级
4e95314e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
28 deletion
+42
-28
block/qcow2-cluster.c
block/qcow2-cluster.c
+42
-28
未找到文件。
block/qcow2-cluster.c
浏览文件 @
226c3c26
...
...
@@ -753,38 +753,16 @@ out:
}
/*
* Allocates new clusters for the given guest_offset.
*
* At most *nb_clusters are allocated, and on return *nb_clusters is updated to
* contain the number of clusters that have been allocated and are contiguous
* in the image file.
*
* If *host_offset is non-zero, it specifies the offset in the image file at
* which the new clusters must start. *nb_clusters can be 0 on return in this
* case if the cluster at host_offset is already in use. If *host_offset is
* zero, the clusters can be allocated anywhere in the image file.
*
* *host_offset is updated to contain the offset into the image file at which
* the first allocated cluster starts.
*
* Return 0 on success and -errno in error cases. -EAGAIN means that the
* function has been waiting for another request and the allocation must be
* restarted, but the whole request should not be failed.
* Check if there already is an AIO write request in flight which allocates
* the same cluster. In this case we need to wait until the previous
* request has completed and updated the L2 table accordingly.
*/
static
int
do_alloc_cluster_offset
(
BlockDriverState
*
bs
,
uint64_t
guest_offset
,
u
int64_t
*
host_offset
,
u
nsigned
int
*
nb_clusters
)
static
int
handle_dependencies
(
BlockDriverState
*
bs
,
uint64_t
guest_offset
,
unsigned
int
*
nb_clusters
)
{
BDRVQcowState
*
s
=
bs
->
opaque
;
QCowL2Meta
*
old_alloc
;
trace_qcow2_do_alloc_clusters_offset
(
qemu_coroutine_self
(),
guest_offset
,
*
host_offset
,
*
nb_clusters
);
/*
* Check if there already is an AIO write request in flight which allocates
* the same cluster. In this case we need to wait until the previous
* request has completed and updated the L2 table accordingly.
*/
QLIST_FOREACH
(
old_alloc
,
&
s
->
cluster_allocs
,
next_in_flight
)
{
uint64_t
start
=
guest_offset
>>
s
->
cluster_bits
;
...
...
@@ -817,6 +795,42 @@ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset,
abort
();
}
return
0
;
}
/*
* Allocates new clusters for the given guest_offset.
*
* At most *nb_clusters are allocated, and on return *nb_clusters is updated to
* contain the number of clusters that have been allocated and are contiguous
* in the image file.
*
* If *host_offset is non-zero, it specifies the offset in the image file at
* which the new clusters must start. *nb_clusters can be 0 on return in this
* case if the cluster at host_offset is already in use. If *host_offset is
* zero, the clusters can be allocated anywhere in the image file.
*
* *host_offset is updated to contain the offset into the image file at which
* the first allocated cluster starts.
*
* Return 0 on success and -errno in error cases. -EAGAIN means that the
* function has been waiting for another request and the allocation must be
* restarted, but the whole request should not be failed.
*/
static
int
do_alloc_cluster_offset
(
BlockDriverState
*
bs
,
uint64_t
guest_offset
,
uint64_t
*
host_offset
,
unsigned
int
*
nb_clusters
)
{
BDRVQcowState
*
s
=
bs
->
opaque
;
int
ret
;
trace_qcow2_do_alloc_clusters_offset
(
qemu_coroutine_self
(),
guest_offset
,
*
host_offset
,
*
nb_clusters
);
ret
=
handle_dependencies
(
bs
,
guest_offset
,
nb_clusters
);
if
(
ret
<
0
)
{
return
ret
;
}
/* Allocate new clusters */
trace_qcow2_cluster_alloc_phys
(
qemu_coroutine_self
());
if
(
*
host_offset
==
0
)
{
...
...
@@ -828,7 +842,7 @@ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset,
*
host_offset
=
cluster_offset
;
return
0
;
}
else
{
int
ret
=
qcow2_alloc_clusters_at
(
bs
,
*
host_offset
,
*
nb_clusters
);
ret
=
qcow2_alloc_clusters_at
(
bs
,
*
host_offset
,
*
nb_clusters
);
if
(
ret
<
0
)
{
return
ret
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录