Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EROFS] Align with the block size of overlayBD #351

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 7642e38f12785105262cccb584f724a22c0f9c77
)

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,20 +580,29 @@ 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[blksz];
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 (fgets(line, sizeof(line), fp)) {
LSMT::RemoteMapping lba;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zeroedlen = 0?

cnt = sscanf(line, "%" PRIx64" %x %" PRIx64 "%08u\n", &blkaddr, &nblocks, &toff, &zeroedlen);
if (!(cnt == 3 || cnt == 4))
Copy link
Contributor

@hsiangkao hsiangkao Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should ignore if cnt > 4 (e.g. more hints which we don't care)

LOG_ERRNO_RETURN(0, -1, "fail to read block list");

lba.offset = blkaddr * blksz;
lba.count = nblocks * blksz;
Copy link
Contributor

@hsiangkao hsiangkao Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lba.count = nblocks * blksz - round_down_blk(zeroedlen); ?

Are you sure that is round_up_blk?

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");
Expand Down
Loading