Skip to content

Commit

Permalink
lib: chunkio: upgrade from v1.0.1 to v1.0.2
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <[email protected]>
  • Loading branch information
edsiper committed Mar 5, 2020
1 parent 2a82db5 commit ed8ffe3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/chunkio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project(chunk-io)

set(CIO_VERSION_MAJOR 1)
set(CIO_VERSION_MINOR 0)
set(CIO_VERSION_PATCH 1)
set(CIO_VERSION_PATCH 2)
set(CIO_VERSION_STR "${CIO_VERSION_MAJOR}.${CIO_VERSION_MINOR}.${CIO_VERSION_PATCH}")

# CFLAGS
Expand Down
2 changes: 1 addition & 1 deletion lib/chunkio/include/chunkio/chunkio.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct cio_ctx {
* memory. For short, it restrict the open number of files and
* the amount of memory mapped.
*/
int max_chunks_up;
size_t max_chunks_up;

/* streams */
struct mk_list streams;
Expand Down
20 changes: 15 additions & 5 deletions lib/chunkio/src/cio_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ static int mmap_file(struct cio_ctx *ctx, struct cio_chunk *ch, size_t size)
content_size = cio_file_st_get_content_size(cf->map, fs_size);
if (content_size == -1) {
cio_log_error(ctx, "invalid content size %s", cf->path);
munmap(cf->map, cf->alloc_size);
cf->map = NULL;
cf->data_size = 0;
cf->alloc_size = 0;
return CIO_CORRUPTED;
}
cf->data_size = content_size;
Expand All @@ -344,6 +348,10 @@ static int mmap_file(struct cio_ctx *ctx, struct cio_chunk *ch, size_t size)
if (ret == -1) {
cio_log_error(ctx, "format check failed: %s/%s",
ch->st->name, ch->name);
munmap(cf->map, cf->alloc_size);
cf->map = NULL;
cf->data_size = 0;
cf->alloc_size = 0;
return CIO_CORRUPTED;
}

Expand Down Expand Up @@ -551,16 +559,18 @@ static int _cio_file_up(struct cio_chunk *ch, int enforced)
return CIO_ERROR;
}

/* Map content */
/*
* Map content:
*
* return values = CIO_OK, CIO_ERROR, CIO_CORRUPTED or CIO_RETRY
*/
ret = mmap_file(ch->ctx, ch, cf->fs_size);
if (ret == -1) {
if (ret == CIO_ERROR) {
cio_log_error(ch->ctx, "[cio file] cannot map chunk: %s/%s",
ch->st->name, ch->name);
/* ret = CIO_OK, CIO_ERROR, CIO_CORRUPTED or CIO_RETRY */
return ret;
}

return 0;
return ret;
}

/*
Expand Down
4 changes: 2 additions & 2 deletions lib/chunkio/tests/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ static void test_context()
ctx = cio_create("/tmp/", NULL, -1, flags);
TEST_CHECK(ctx == NULL);

/* Invalid debug level 5 */
ctx = cio_create("/tmp/", NULL, 5, flags);
/* Invalid debug level 6 */
ctx = cio_create("/tmp/", NULL, 6, flags);
TEST_CHECK(ctx == NULL);

/* Valid context without callback */
Expand Down

0 comments on commit ed8ffe3

Please sign in to comment.