Skip to content

Commit

Permalink
file: use posix_fallocate if fallocate() is not supported. Address ex…
Browse files Browse the repository at this point in the history
…t3 and reiserfs fs (#64)

The fallocate operation is failing on e.g. ext3 and reiserf filesystems.
By falling back to use posix_fallocate if the fallocate function call fails
one can keep the performance as is for fallocate supported filesystems but
still support legacy filesystems as ext3 and reiserfs.
  • Loading branch information
sirwio authored Mar 12, 2021
1 parent 5453ee7 commit be3862e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/cio_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,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

0 comments on commit be3862e

Please sign in to comment.