Skip to content

Commit

Permalink
Address issue of falures on ext3 and reiserfs filesystems
Browse files Browse the repository at this point in the history
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 committed Feb 24, 2021
1 parent 4815fde commit 37d4f5d
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 37d4f5d

Please sign in to comment.