Skip to content

Commit 99ed7a0

Browse files
author
Hongzhen Luo
committed
[EROFS] Align with the block size of overlayBD
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]>
1 parent 35d3980 commit 99ed7a0

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/overlaybd/tar/erofs/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include(FetchContent)
33
FetchContent_Declare(
44
erofs-utils
55
GIT_REPOSITORY https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git
6-
GIT_TAG ac0997ea32a465a6b0db7b782bb8d4d07952365a
6+
GIT_TAG 654e8b8a8f1a87b0746ff47db00dec1afc05fbc9
77
)
88

99
FetchContent_MakeAvailable(erofs-utils)

src/overlaybd/tar/erofs/liberofs.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,25 +580,38 @@ static int erofs_init_tar(struct erofs_tarfile *erofstar,
580580
static int erofs_write_map_file(photon::fs::IFile *fout, uint64_t blksz, FILE *fp)
581581
{
582582
uint64_t blkaddr, toff;
583-
uint32_t nblocks;
583+
uint32_t nblocks, zeroedlen;
584+
char *line = NULL;
585+
size_t len = 0;
586+
int cnt;
584587

585588
if (fp == NULL) {
586589
LOG_ERROR("unable to get upper.map, ignored");
587590
return -1;
588591
}
589592
rewind(fp);
590-
while (fscanf(fp, "%" PRIx64" %x %" PRIx64 "\n", &blkaddr, &nblocks, &toff)
591-
>= 3)
592-
{
593+
594+
while (getline(&line, &len, fp) != -1) {
593595
LSMT::RemoteMapping lba;
596+
597+
cnt = sscanf(line, "%" PRIx64" %x%" PRIx64 "%u", &blkaddr, &nblocks, &toff, &zeroedlen);
598+
if (cnt < 3) {
599+
LOG_ERROR("Bad formatted map file.");
600+
break;
601+
}
602+
594603
lba.offset = blkaddr * blksz;
595604
lba.count = nblocks * blksz;
596605
lba.roffset = toff;
606+
if (cnt > 3)
607+
lba.count = round_up_blk(lba.count - zeroedlen);
608+
597609
int nwrite = fout->ioctl(LSMT::IFileRW::RemoteData, lba);
598610
if ((unsigned) nwrite != lba.count) {
599611
LOG_ERRNO_RETURN(0, -1, "failed to write lba");
600612
}
601613
}
614+
free(line);
602615

603616
return 0;
604617
}

0 commit comments

Comments
 (0)