Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ned14/llfio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2021-10-22 17:00:44 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2021-10-22 17:00:44 +0300
commit857baa15e1f71cd2445ad7dae11b23767202a071 (patch)
tree8905ff843d72b77f6b34bb0682806985aead6009
parent5091315a17d2d5af0aa51cd61efd1749ec9cd127 (diff)
Fix previous commit generating resource_unavailable_try_again errors.
-rw-r--r--include/llfio/v2.0/detail/impl/posix/file_handle.ipp13
-rw-r--r--include/llfio/v2.0/detail/impl/windows/file_handle.ipp13
2 files changed, 14 insertions, 12 deletions
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 b6b60662..ab476e25 100644
--- a/include/llfio/v2.0/detail/impl/posix/file_handle.ipp
+++ b/include/llfio/v2.0/detail/impl/posix/file_handle.ipp
@@ -1,5 +1,5 @@
/* A handle to something
-(C) 2015-2020 Niall Douglas <http://www.nedproductions.biz/> (8 commits)
+(C) 2015-2021 Niall Douglas <http://www.nedproductions.biz/> (8 commits)
File Created: Dec 2015
@@ -536,10 +536,11 @@ result<file_handle::extent_pair> file_handle::clone_extents_to(file_handle::exte
while(extent.length > 0)
{
deadline nd;
- buffer_type b(buffer, blocksize /* to allow aligned i/o files */);
+ const auto towrite = (extent.length < blocksize) ? (size_t) extent.length : blocksize;
+ buffer_type b(buffer, utils::round_up_to_page_size(towrite, 4096) /* to allow aligned i/o files */);
LLFIO_DEADLINE_TO_PARTIAL_DEADLINE(nd, d);
OUTCOME_TRY(auto &&readed, read({{&b, 1}, extent.offset}, nd));
- const_buffer_type cb(readed.front());
+ const_buffer_type cb(readed.front().data(), std::min(readed.front().size(), towrite));
if(cb.size() == 0)
{
return ret;
@@ -836,16 +837,16 @@ result<file_handle::extent_pair> file_handle::clone_extents_to(file_handle::exte
buffer = utils::page_allocator<byte>().allocate(blocksize);
}
deadline nd;
- buffer_type b(buffer, blocksize /* to allow aligned i/o files */);
+ buffer_type b(buffer, utils::round_up_to_page_size(thisblock, 4096) /* to allow aligned i/o files */);
LLFIO_DEADLINE_TO_PARTIAL_DEADLINE(nd, d);
OUTCOME_TRY(auto &&readed, read({{&b, 1}, item.src.offset + thisoffset}, nd));
buffer_dirty = true;
- if(readed.front().size() != thisblock)
+ if(readed.front().size() < thisblock)
{
return errc::resource_unavailable_try_again; // something is wrong
}
LLFIO_DEADLINE_TO_PARTIAL_DEADLINE(nd, d);
- const_buffer_type cb(readed.front());
+ const_buffer_type cb(readed.front().data(), thisblock);
if(item.destination_extents_are_new)
{
// If we don't need to reset the bytes in the destination, try to elide
diff --git a/include/llfio/v2.0/detail/impl/windows/file_handle.ipp b/include/llfio/v2.0/detail/impl/windows/file_handle.ipp
index 82ab8c39..c758f3e5 100644
--- a/include/llfio/v2.0/detail/impl/windows/file_handle.ipp
+++ b/include/llfio/v2.0/detail/impl/windows/file_handle.ipp
@@ -1,5 +1,5 @@
/* A handle to a file
-(C) 2015-2020 Niall Douglas <http://www.nedproductions.biz/> (16 commits)
+(C) 2015-2021 Niall Douglas <http://www.nedproductions.biz/> (16 commits)
File Created: Dec 2015
@@ -461,10 +461,11 @@ result<file_handle::extent_pair> file_handle::clone_extents_to(file_handle::exte
while(extent.length > 0)
{
deadline nd;
- buffer_type b(buffer, blocksize /* to allow aligned i/o files */);
+ const auto towrite = (extent.length < blocksize) ? (size_t) extent.length : blocksize;
+ buffer_type b(buffer, utils::round_up_to_page_size(towrite, 4096) /* to allow aligned i/o files */);
LLFIO_DEADLINE_TO_PARTIAL_DEADLINE(nd, d);
OUTCOME_TRY(auto &&readed, read({{&b, 1}, extent.offset}, nd));
- const_buffer_type cb(readed.front());
+ const_buffer_type cb(readed.front().data(), std::min(readed.front().size(), towrite));
if(cb.size() == 0)
{
return ret;
@@ -717,16 +718,16 @@ result<file_handle::extent_pair> file_handle::clone_extents_to(file_handle::exte
buffer = utils::page_allocator<byte>().allocate(blocksize);
}
deadline nd;
- buffer_type b(buffer, blocksize /* to allow aligned i/o files */);
+ buffer_type b(buffer, utils::round_up_to_page_size(thisblock, 4096) /* to allow aligned i/o files */);
LLFIO_DEADLINE_TO_PARTIAL_DEADLINE(nd, d);
OUTCOME_TRY(auto &&readed, read({{&b, 1}, item.src.offset + thisoffset}, nd));
buffer_dirty = true;
- if(readed.front().size() != thisblock)
+ if(readed.front().size() < thisblock)
{
return errc::resource_unavailable_try_again; // something is wrong
}
LLFIO_DEADLINE_TO_PARTIAL_DEADLINE(nd, d);
- const_buffer_type cb(readed.front());
+ const_buffer_type cb(readed.front().data(), thisblock);
if(item.destination_extents_are_new)
{
// If we don't need to reset the bytes in the destination, try to elide