提交 30ca43d0 编写于 作者: L lifeng68

image: fix wrong cal image size

use size in tar split process
Signed-off-by: Nlifeng68 <lifeng68@huawei.com>
上级 4f9981db
......@@ -286,8 +286,7 @@ bool devmapper_layer_exists(const char *id, const struct graphdriver *driver)
return has_device(id, driver->devset);
}
int devmapper_apply_diff(const char *id, const struct graphdriver *driver, const struct io_read_wrapper *content,
int64_t *layer_size)
int devmapper_apply_diff(const char *id, const struct graphdriver *driver, const struct io_read_wrapper *content)
{
struct driver_mount_opts *mount_opts = NULL;
char *layer_fs = NULL;
......
......@@ -59,8 +59,7 @@ int devmapper_umount_layer(const char *id, const struct graphdriver *driver);
bool devmapper_layer_exists(const char *id, const struct graphdriver *driver);
int devmapper_apply_diff(const char *id, const struct graphdriver *driver, const struct io_read_wrapper *content,
int64_t *layer_size);
int devmapper_apply_diff(const char *id, const struct graphdriver *driver, const struct io_read_wrapper *content);
int devmapper_get_layer_metadata(const char *id, const struct graphdriver *driver, json_map_string_string *map_info);
......@@ -72,7 +71,6 @@ int devmapper_repair_lowers(const char *id, const char *parent, const struct gra
int devmapper_get_layer_fs_info(const char *id, const struct graphdriver *driver, imagetool_fs_info *fs_info);
#ifdef __cplusplus
}
#endif
......
......@@ -212,19 +212,19 @@ bool graphdriver_layer_exists(const char *id)
return g_graphdriver->ops->exists(id, g_graphdriver);
}
int graphdriver_apply_diff(const char *id, const struct io_read_wrapper *content, int64_t *layer_size)
int graphdriver_apply_diff(const char *id, const struct io_read_wrapper *content)
{
if (g_graphdriver == NULL) {
ERROR("Driver not inited yet");
return -1;
}
if (id == NULL || content == NULL || layer_size == NULL) {
if (id == NULL || content == NULL) {
ERROR("Invalid input arguments for driver umount layer");
return -1;
}
return g_graphdriver->ops->apply_diff(id, g_graphdriver, content, layer_size);
return g_graphdriver->ops->apply_diff(id, g_graphdriver, content);
}
container_inspect_graph_driver *graphdriver_get_metadata(const char *id)
......
......@@ -67,8 +67,7 @@ struct graphdriver_ops {
bool (*exists)(const char *id, const struct graphdriver *driver);
int (*apply_diff)(const char *id, const struct graphdriver *driver, const struct io_read_wrapper *content,
int64_t *layer_size);
int (*apply_diff)(const char *id, const struct graphdriver *driver, const struct io_read_wrapper *content);
int (*get_layer_metadata)(const char *id, const struct graphdriver *driver, json_map_string_string *map_info);
......@@ -113,7 +112,7 @@ int graphdriver_umount_layer(const char *id);
bool graphdriver_layer_exists(const char *id);
int graphdriver_apply_diff(const char *id, const struct io_read_wrapper *content, int64_t *layer_size);
int graphdriver_apply_diff(const char *id, const struct io_read_wrapper *content);
struct graphdriver_status *graphdriver_get_status(void);
......
......@@ -1643,8 +1643,7 @@ out:
return exists;
}
int overlay2_apply_diff(const char *id, const struct graphdriver *driver, const struct io_read_wrapper *content,
int64_t *layer_size)
int overlay2_apply_diff(const char *id, const struct graphdriver *driver, const struct io_read_wrapper *content)
{
int ret = 0;
char *layer_dir = NULL;
......@@ -1680,8 +1679,6 @@ int overlay2_apply_diff(const char *id, const struct graphdriver *driver, const
goto out;
}
utils_calculate_dir_size_without_hardlink(layer_diff, layer_size, NULL);
out:
free(layer_dir);
free(layer_diff);
......
......@@ -52,8 +52,7 @@ int overlay2_umount_layer(const char *id, const struct graphdriver *driver);
bool overlay2_layer_exists(const char *id, const struct graphdriver *driver);
int overlay2_apply_diff(const char *id, const struct graphdriver *driver, const struct io_read_wrapper *content,
int64_t *layer_size);
int overlay2_apply_diff(const char *id, const struct graphdriver *driver, const struct io_read_wrapper *content);
int overlay2_get_layer_metadata(const char *id, const struct graphdriver *driver, json_map_string_string *map_info);
......@@ -74,4 +73,3 @@ int overlay2_get_layer_fs_info(const char *id, const struct graphdriver *driver,
#endif
#endif
......@@ -863,7 +863,8 @@ err_out:
return NULL;
}
typedef int (*archive_entry_cb_t)(struct archive_entry *entry, struct archive *ar, int32_t position, Buffer *json_buf);
typedef int (*archive_entry_cb_t)(struct archive_entry *entry, struct archive *ar, int32_t position, Buffer *json_buf,
int64_t *size);
static void free_storage_entry_data(storage_entry *entry)
{
......@@ -934,7 +935,8 @@ out:
return ret;
}
static int archive_entry_parse(struct archive_entry *entry, struct archive *ar, int32_t position, Buffer *json_buf)
static int archive_entry_parse(struct archive_entry *entry, struct archive *ar, int32_t position, Buffer *json_buf,
int64_t *size)
{
storage_entry sentry = { 0 };
struct parser_context ctx = { OPT_GEN_SIMPLIFY, stderr };
......@@ -965,6 +967,8 @@ static int archive_entry_parse(struct archive_entry *entry, struct archive *ar,
goto out;
}
*size = *size + sentry.size;
ret = 0;
out:
free_storage_entry_data(&sentry);
......@@ -973,7 +977,7 @@ out:
return ret;
}
static int foreach_archive_entry(archive_entry_cb_t cb, int fd, const char *dist)
static int foreach_archive_entry(archive_entry_cb_t cb, int fd, const char *dist, int64_t *size)
{
int ret = -1;
int nret = 0;
......@@ -1008,7 +1012,7 @@ static int foreach_archive_entry(archive_entry_cb_t cb, int fd, const char *dist
ERROR("archive read header failed: %s", archive_error_string(read_a));
goto out;
}
nret = cb(entry, read_a, position, json_buf);
nret = cb(entry, read_a, position, json_buf, size);
if (nret != 0) {
goto out;
}
......@@ -1027,7 +1031,7 @@ out:
return ret;
}
static int make_tar_split_file(const char *lid, const struct io_read_wrapper *diff)
static int make_tar_split_file(const char *lid, const struct io_read_wrapper *diff, int64_t *size)
{
/*
* step 1: read header;
......@@ -1049,7 +1053,7 @@ static int make_tar_split_file(const char *lid, const struct io_read_wrapper *di
goto out;
}
ret = foreach_archive_entry(archive_entry_parse, *pfd, save_fname);
ret = foreach_archive_entry(archive_entry_parse, *pfd, save_fname, size);
if (ret != 0) {
goto out;
}
......@@ -1084,16 +1088,16 @@ static int apply_diff(layer_t *l, const struct io_read_wrapper *diff)
return 0;
}
nret = graphdriver_apply_diff(l->slayer->id, diff, &size);
nret = graphdriver_apply_diff(l->slayer->id, diff);
if (nret != 0) {
goto out;
}
INFO("Apply layer get size: %ld", size);
l->slayer->diff_size = size;
// uncompress digest get from up caller
ret = make_tar_split_file(l->slayer->id, diff, &size);
ret = make_tar_split_file(l->slayer->id, diff);
INFO("Apply layer get size: %ld", size);
l->slayer->diff_size = size;
out:
return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册