Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
166acf54
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,发现更多精彩内容 >>
提交
166acf54
编写于
5月 11, 2012
作者:
K
Kevin Wolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qcow2: Support for fixing refcount inconsistencies
Signed-off-by:
N
Kevin Wolf
<
kwolf@redhat.com
>
上级
ccf34716
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
15 deletion
+37
-15
block/qcow2-refcount.c
block/qcow2-refcount.c
+34
-9
block/qcow2.c
block/qcow2.c
+1
-5
block/qcow2.h
block/qcow2.h
+2
-1
未找到文件。
block/qcow2-refcount.c
浏览文件 @
166acf54
...
...
@@ -1122,11 +1122,12 @@ fail:
* Returns 0 if no errors are found, the number of errors in case the image is
* detected as corrupted, and -errno when an internal error occurred.
*/
int
qcow2_check_refcounts
(
BlockDriverState
*
bs
,
BdrvCheckResult
*
res
)
int
qcow2_check_refcounts
(
BlockDriverState
*
bs
,
BdrvCheckResult
*
res
,
BdrvCheckMode
fix
)
{
BDRVQcowState
*
s
=
bs
->
opaque
;
int64_t
size
;
int
nb_clusters
,
refcount1
,
refcount2
,
i
;
int64_t
size
,
i
;
int
nb_clusters
,
refcount1
,
refcount2
;
QCowSnapshot
*
sn
;
uint16_t
*
refcount_table
;
int
ret
;
...
...
@@ -1170,14 +1171,15 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res)
/* Refcount blocks are cluster aligned */
if
(
offset
&
(
s
->
cluster_size
-
1
))
{
fprintf
(
stderr
,
"ERROR refcount block %
d
is not "
fprintf
(
stderr
,
"ERROR refcount block %
"
PRId64
"
is not "
"cluster aligned; refcount table entry corrupted
\n
"
,
i
);
res
->
corruptions
++
;
continue
;
}
if
(
cluster
>=
nb_clusters
)
{
fprintf
(
stderr
,
"ERROR refcount block %d is outside image
\n
"
,
i
);
fprintf
(
stderr
,
"ERROR refcount block %"
PRId64
" is outside image
\n
"
,
i
);
res
->
corruptions
++
;
continue
;
}
...
...
@@ -1186,7 +1188,8 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res)
inc_refcounts
(
bs
,
res
,
refcount_table
,
nb_clusters
,
offset
,
s
->
cluster_size
);
if
(
refcount_table
[
cluster
]
!=
1
)
{
fprintf
(
stderr
,
"ERROR refcount block %d refcount=%d
\n
"
,
fprintf
(
stderr
,
"ERROR refcount block %"
PRId64
" refcount=%d
\n
"
,
i
,
refcount_table
[
cluster
]);
res
->
corruptions
++
;
}
...
...
@@ -1197,7 +1200,7 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res)
for
(
i
=
0
;
i
<
nb_clusters
;
i
++
)
{
refcount1
=
get_refcount
(
bs
,
i
);
if
(
refcount1
<
0
)
{
fprintf
(
stderr
,
"Can't get refcount for cluster %
d
: %s
\n
"
,
fprintf
(
stderr
,
"Can't get refcount for cluster %
"
PRId64
"
: %s
\n
"
,
i
,
strerror
(
-
refcount1
));
res
->
check_errors
++
;
continue
;
...
...
@@ -1205,9 +1208,31 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res)
refcount2
=
refcount_table
[
i
];
if
(
refcount1
!=
refcount2
)
{
fprintf
(
stderr
,
"%s cluster %d refcount=%d reference=%d
\n
"
,
refcount1
<
refcount2
?
"ERROR"
:
"Leaked"
,
/* Check if we're allowed to fix the mismatch */
int
*
num_fixed
=
NULL
;
if
(
refcount1
>
refcount2
&&
(
fix
&
BDRV_FIX_LEAKS
))
{
num_fixed
=
&
res
->
leaks_fixed
;
}
else
if
(
refcount1
<
refcount2
&&
(
fix
&
BDRV_FIX_ERRORS
))
{
num_fixed
=
&
res
->
corruptions_fixed
;
}
fprintf
(
stderr
,
"%s cluster %"
PRId64
" refcount=%d reference=%d
\n
"
,
num_fixed
!=
NULL
?
"Repairing"
:
refcount1
<
refcount2
?
"ERROR"
:
"Leaked"
,
i
,
refcount1
,
refcount2
);
if
(
num_fixed
)
{
ret
=
update_refcount
(
bs
,
i
<<
s
->
cluster_bits
,
1
,
refcount2
-
refcount1
);
if
(
ret
>=
0
)
{
(
*
num_fixed
)
++
;
continue
;
}
}
/* And if we couldn't, print an error */
if
(
refcount1
<
refcount2
)
{
res
->
corruptions
++
;
}
else
{
...
...
block/qcow2.c
浏览文件 @
166acf54
...
...
@@ -1473,11 +1473,7 @@ static int qcow2_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
static
int
qcow2_check
(
BlockDriverState
*
bs
,
BdrvCheckResult
*
result
,
BdrvCheckMode
fix
)
{
if
(
fix
)
{
return
-
ENOTSUP
;
}
return
qcow2_check_refcounts
(
bs
,
result
);
return
qcow2_check_refcounts
(
bs
,
result
,
fix
);
}
#if 0
...
...
block/qcow2.h
浏览文件 @
166acf54
...
...
@@ -261,7 +261,8 @@ void qcow2_free_any_clusters(BlockDriverState *bs,
int
qcow2_update_snapshot_refcount
(
BlockDriverState
*
bs
,
int64_t
l1_table_offset
,
int
l1_size
,
int
addend
);
int
qcow2_check_refcounts
(
BlockDriverState
*
bs
,
BdrvCheckResult
*
res
);
int
qcow2_check_refcounts
(
BlockDriverState
*
bs
,
BdrvCheckResult
*
res
,
BdrvCheckMode
fix
);
/* qcow2-cluster.c functions */
int
qcow2_grow_l1_table
(
BlockDriverState
*
bs
,
int
min_size
,
bool
exact_size
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录