Skip to content

Commit

Permalink
[bugfix] workaround if some SegmentMapping refers to end of tar
Browse files Browse the repository at this point in the history
Currently it could happen on EROFS meta indexes.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
  • Loading branch information
hsiangkao committed Oct 18, 2024
1 parent 0911a9b commit 9fb0797
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/overlaybd/lsmt/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,9 +573,14 @@ class LSMTReadOnlyFile : public IFileRW {
// LOG_DEBUG("offset: `, length: `", m.moffset, size);
ssize_t ret = m_files[m.tag]->pread(buf, size, m.moffset * ALIGNMENT);
if (ret < size) {
LOG_ERRNO_RETURN(0, (int)ret,
"failed to read from `-th file ( ` pread return: ` < size: `)",
m.tag, m_files[m.tag], ret, size);
size_t ret2 = m_files[m.tag]->pread((char *)buf + ret, size - ret, m.moffset * ALIGNMENT + ret);
if (ret2) {
LOG_ERRNO_RETURN(0, (int)ret,
"failed to read from `-th file ( ` pread return: ` < size: `)",
m.tag, m_files[m.tag], ret, size);
} else {
memset((char *)buf + ret, 0, size - ret);
}
}
lsmt_io_size += ret;
lsmt_io_cnt++;
Expand Down

0 comments on commit 9fb0797

Please sign in to comment.