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

add support for tarerofs for TurboOCI #320

Merged
merged 1 commit into from
Mar 27, 2024

Conversation

salvete2022
Copy link

@salvete2022 salvete2022 commented Mar 26, 2024

What this PR does / why we need it:

Currently erofs-utils is integrated into overlaybd by using mkfs.erofs executable file. It's not optimial since raw data needs to be dumped first and output data needs to be write into overlaybd then.

Later API integration may be a better form but it needs more work.

The corresponding accelerated-container-image PR:
containerd/accelerated-container-image#272

The corresponding erofs-utils for test can be found at:
git clone https://gitee.com/anolis/erofs-utils.git -b overlaybd-dev

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Please check the following list:

  • Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • Does this change require a documentation update?
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header?

Copy link
Contributor

@hsiangkao hsiangkao left a comment

Choose a reason for hiding this comment

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

some comments.

#include <photon/fs/fiemap.h>
#include "../lsmt/file.h"
#include "../lsmt/index.h"

Copy link
Contributor

Choose a reason for hiding this comment

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

it might be better to add

#define TAREROFS_BLOCK_SIZE 4096
#define __stringify(s)  #s

Copy link
Author

Choose a reason for hiding this comment

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

Done.

struct stat st;
char buf[128*1024];
char base_path[64] = "/tmp/tarerofs_base_XXXXXX";
char command_line[256] = "mkfs.erofs --tar=0,upper.map,1073741824 --aufs";
Copy link
Contributor

Choose a reason for hiding this comment

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

char command_line[256] = "mkfs.erofs --tar=0,upper.map,1073741824 -b" __stringify(TAREROFS_BLOCK_SIZE) " --aufs";

Copy link
Author

Choose a reason for hiding this comment

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

Done.

}
while (fscanf(fp, "%" PRIx64" %x %" PRIx64 "\n", &blkaddr, &nblocks, &toff) >= 3) {
LSMT::RemoteMapping lba;
lba.offset = blkaddr * 4096;
Copy link
Contributor

Choose a reason for hiding this comment

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

4096 -> TAREROFS_BLOCK_SIZE

Copy link
Author

Choose a reason for hiding this comment

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

Done.

while (fscanf(fp, "%" PRIx64" %x %" PRIx64 "\n", &blkaddr, &nblocks, &toff) >= 3) {
LSMT::RemoteMapping lba;
lba.offset = blkaddr * 4096;
lba.count = nblocks * 4096;
Copy link
Contributor

Choose a reason for hiding this comment

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

4096 -> TAREROFS_BLOCK_SIZE

Copy link
Author

Choose a reason for hiding this comment

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

Done.

char buf[128*1024];
char base_path[64] = "/tmp/tarerofs_base_XXXXXX";
char command_line[256] = "mkfs.erofs --tar=0,upper.map,1073741824 --aufs";
char command_line2[] = " upper.erofs";
Copy link
Contributor

Choose a reason for hiding this comment

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

const char command_line2[] = " upper.erofs";

Copy link
Author

Choose a reason for hiding this comment

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

Done.

}

while ((read = file->read(buf, sizeof(buf))) > 0) {
if (fwrite(buf, read, 1, fp) != 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

better to fix indentation.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

std::strcat(command_line, " --base ");
std::strcat(command_line, base_path);

for (int i = 0; i < 800; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

800 here is quite hard-coded. But I'm not sure how we could detect the real written data in the first segment(extent) since we don't need the following LSMT::IFileRW::RemoteData ranges.

@salvete2022 salvete2022 force-pushed the dev_erofs branch 2 times, most recently from b3e2cfc to 4289d9b Compare March 26, 2024 11:32
Currently erofs-utils is integrated into overlaybd by using `mkfs.erofs`
executable file.  It's not optimial since raw data needs to be dumped
first and output data needs to be write into overlaybd then.

Later API integration may be a better form but it needs more work.

Signed-off-by: Hongzhen Luo <hongzhen.lhz@linux.alibaba.com>
@BigVan
Copy link
Member

BigVan commented Mar 26, 2024

thanks @hsiangkao
Erofs support is an effective enhancement to overlaybd

@liulanzheng liulanzheng merged commit 8fbcd89 into containerd:main Mar 27, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants