Skip to content

Commit

Permalink
Fix bug #149 (#148) whereby file_handle::zero() on Linux didn't
Browse files Browse the repository at this point in the history
actually deallocate from the filing system the zeroed range of bytes.
  • Loading branch information
ned14 committed Nov 19, 2024
1 parent 931ad7b commit 27d96a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions include/llfio/revision.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time
#define LLFIO_PREVIOUS_COMMIT_REF 4872b85f61ca15454f852cc8f40092daa483ee5e
#define LLFIO_PREVIOUS_COMMIT_DATE "2024-11-06 09:04:25 +00:00"
#define LLFIO_PREVIOUS_COMMIT_UNIQUE 4872b85f
#define LLFIO_PREVIOUS_COMMIT_REF 931ad7b294ce852e577076630c445e2e930dae17
#define LLFIO_PREVIOUS_COMMIT_DATE "2024-11-18 14:44:33 +00:00"
#define LLFIO_PREVIOUS_COMMIT_UNIQUE 931ad7b2
14 changes: 8 additions & 6 deletions include/llfio/v2.0/detail/impl/posix/file_handle.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -991,13 +991,15 @@ result<file_handle::extent_type> file_handle::zero(file_handle::extent_pair exte
return errc::value_too_large;
}
#if defined(__linux__)
if(-1 == fallocate(_v.fd, 0x02 /*FALLOC_FL_PUNCH_HOLE*/ | 0x01 /*FALLOC_FL_KEEP_SIZE*/, extent.offset, extent.length))
if(-1 != fallocate(_v.fd, 0x02 /*FALLOC_FL_PUNCH_HOLE*/ | 0x01 /*FALLOC_FL_KEEP_SIZE*/, extent.offset, extent.length))
{
// The filing system may not support trim
if(EOPNOTSUPP != errno)
{
return posix_error();
}
// Success
return extent;
}
// The filing system may not support trim
if(EOPNOTSUPP != errno)
{
return posix_error();
}
#endif
// Fall back onto a write of zeros
Expand Down

0 comments on commit 27d96a8

Please sign in to comment.