Skip to content

Commit

Permalink
[EROFS] Align with the block size of overlayBD
Browse files Browse the repository at this point in the history
The inconsistency in the default block sizes between OverlayBD
and EROFS can lead to issues during segment mapping. This patch
aligns with the block size of overlaybd for mapping (i.e.,
OverlayBD's 512-byte size) to overcome this inconsistency.

Signed-off-by: Hongzhen Luo <[email protected]>
  • Loading branch information
salvete committed Nov 13, 2024
1 parent 35d3980 commit 7777d6f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/overlaybd/tar/erofs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include(FetchContent)
FetchContent_Declare(
erofs-utils
GIT_REPOSITORY https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git
GIT_TAG ac0997ea32a465a6b0db7b782bb8d4d07952365a
GIT_TAG 654e8b8a8f1a87b0746ff47db00dec1afc05fbc9
)

FetchContent_MakeAvailable(erofs-utils)
Expand Down
17 changes: 13 additions & 4 deletions src/overlaybd/tar/erofs/liberofs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,25 +580,34 @@ static int erofs_init_tar(struct erofs_tarfile *erofstar,
static int erofs_write_map_file(photon::fs::IFile *fout, uint64_t blksz, FILE *fp)
{
uint64_t blkaddr, toff;
uint32_t nblocks;
uint32_t nblocks, zeroedlen;
char *line = NULL;
size_t len = 0;
int cnt;

if (fp == NULL) {
LOG_ERROR("unable to get upper.map, ignored");
return -1;
}
rewind(fp);
while (fscanf(fp, "%" PRIx64" %x %" PRIx64 "\n", &blkaddr, &nblocks, &toff)
>= 3)
{

while (getline(&line, &len, fp) != -1) {
LSMT::RemoteMapping lba;

cnt = sscanf(line, "%" PRIx64" %x%" PRIx64 "%u", &blkaddr, &nblocks, &toff, &zeroedlen);

lba.offset = blkaddr * blksz;
lba.count = nblocks * blksz;
lba.roffset = toff;
if (cnt > 3)
lba.count = round_up_blk(lba.count - zeroedlen);

int nwrite = fout->ioctl(LSMT::IFileRW::RemoteData, lba);
if ((unsigned) nwrite != lba.count) {
LOG_ERRNO_RETURN(0, -1, "failed to write lba");
}
}
free(line);

return 0;
}
Expand Down

0 comments on commit 7777d6f

Please sign in to comment.