Skip to content

Commit

Permalink
lib: chunkio: upgrade to v1.1.3 (#4148)
Browse files Browse the repository at this point in the history
This patch upgrade Chunk I/O to version v1.1.3, some of the changes are:

 - Fix wrong value of zero on fs_size file structure.
 - Use posix_fallocate() if fallocate() is not available (address ext3 and reiser fs)
 - Minor fixes

Signed-off-by: Eduardo Silva <[email protected]>
  • Loading branch information
edsiper committed Oct 5, 2021
1 parent 3d6cfc0 commit 1314fff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 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 1)
set(CIO_VERSION_PATCH 1)
set(CIO_VERSION_PATCH 3)
set(CIO_VERSION_STR "${CIO_VERSION_MAJOR}.${CIO_VERSION_MINOR}.${CIO_VERSION_PATCH}")

# CFLAGS
Expand Down
14 changes: 14 additions & 0 deletions lib/chunkio/src/cio_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ struct cio_file *cio_file_open(struct cio_ctx *ctx,
int ret;
int len;
char *path;
struct stat f_st;
struct cio_file *cf;

len = strlen(ch->name);
Expand Down Expand Up @@ -574,6 +575,12 @@ struct cio_file *cio_file_open(struct cio_ctx *ctx,
/* Should we open and put this file up ? */
ret = open_and_up(ctx);
if (ret == CIO_FALSE) {
/* make sure to set the file size before to return */
ret = stat(cf->path, &f_st);
if (ret == 0) {
cf->fs_size = f_st.st_size;
}

/* we reached our limit, let the file 'down' */
return cf;
}
Expand Down Expand Up @@ -1056,6 +1063,13 @@ int cio_file_fs_size_change(struct cio_file *cf, size_t new_size)
* fallocate() is not portable, Linux only.
*/
ret = fallocate(cf->fd, 0, 0, new_size);
if (ret == EOPNOTSUPP) {
/* If fallocate fails with an EOPNOTSUPP try operation using
* posix_fallocate. Required since some filesystems do not support
* the fallocate operation e.g. ext3 and reiserfs.
*/
ret = posix_fallocate(cf->fd, 0, new_size);
}
}
else
#endif
Expand Down
2 changes: 1 addition & 1 deletion lib/chunkio/src/cio_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ int cio_stream_delete(struct cio_stream *st)
if (!path) {
cio_log_error(ctx,
"content from stream '%s' has been deleted, but the "
"directory might still exists.");
"directory might still exists.", path);
return -1;
}

Expand Down

0 comments on commit 1314fff

Please sign in to comment.