From 27d96a8af49cb169c7cd03638b2e0365dc1c1014 Mon Sep 17 00:00:00 2001 From: "Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)" Date: Tue, 19 Nov 2024 16:11:02 +0100 Subject: [PATCH] Fix bug #149 (#148) whereby `file_handle::zero()` on Linux didn't actually deallocate from the filing system the zeroed range of bytes. --- include/llfio/revision.hpp | 6 +++--- .../llfio/v2.0/detail/impl/posix/file_handle.ipp | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/llfio/revision.hpp b/include/llfio/revision.hpp index 591abcd2..da470105 100644 --- a/include/llfio/revision.hpp +++ b/include/llfio/revision.hpp @@ -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 diff --git a/include/llfio/v2.0/detail/impl/posix/file_handle.ipp b/include/llfio/v2.0/detail/impl/posix/file_handle.ipp index 91e3bf29..c3e7044b 100644 --- a/include/llfio/v2.0/detail/impl/posix/file_handle.ipp +++ b/include/llfio/v2.0/detail/impl/posix/file_handle.ipp @@ -991,13 +991,15 @@ result 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