-
Notifications
You must be signed in to change notification settings - Fork 91
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
Support shared domain #162
Conversation
501a681
to
cbf30cd
Compare
Codecov ReportBase: 28.87% // Head: 29.13% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #162 +/- ##
==========================================
+ Coverage 28.87% 29.13% +0.26%
==========================================
Files 27 27
Lines 2293 2296 +3
==========================================
+ Hits 662 669 +7
+ Misses 1537 1533 -4
Partials 94 94
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
cbf30cd
to
102aec8
Compare
|
102aec8
to
a308b73
Compare
config/daemonconfig.go
Outdated
@@ -161,7 +161,7 @@ func NewDaemonConfig(fsDriver string, cfg DaemonConfig, imageID, snapshotID stri | |||
backendConfig = &cfg.Config.BackendConfig | |||
fscacheID := erofs.FscacheID(snapshotID) | |||
cfg.ID = fscacheID | |||
cfg.DomainID = fscacheID | |||
cfg.DomainID = "global-domain" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is domain ID specific to kernel/erofs? In other words, is it a predefined keyword in the Kernel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, @domain_id is a mount option of EROFS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I mean "global-domain" :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'global-domain' is not a keyword in the kernel. This is just a name(id) specified by us. In future work, 'domain_id' will be specified by the user.
pkg/utils/erofs/erofs_linux.go
Outdated
logrus.Infof("Mount erofs to %s with options %s", mountPoint, opts) | ||
if err := mount("erofs", mountPoint, "erofs", 0, opts); err != nil { | ||
return errors.Wrapf(err, "failed to mount erofs") | ||
if err := mount("erofs", mountPoint, "erofs", 0, "fsid="+fsID); err != nil { | ||
return errors.Wrapf(err, "failed to mount erofs") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you retry another mount if the L20 mount operation fails? It's better to add a comment to tell necessity and intention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a mount with the option "domain_id" fails, this indicates that the kernel may not support EROFS shared domain, and will fall back to normal mount. I'll add a comment about that. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Can it check return error code like unsupported or invalid ?
pkg/utils/erofs/erofs_linux.go
Outdated
@@ -15,10 +15,12 @@ import ( | |||
func Mount(bootstrapPath, fsID, mountPoint string) error { | |||
mount := unix.Mount | |||
|
|||
opts := "fsid=" + fsID | |||
opts := fmt.Sprintf("domain_id=%s,fsid=%s", "global-domain", fsID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to make "global-domain" as a global constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll revise it.
5ba09a4
to
c304447
Compare
pkg/utils/erofs/erofs_linux.go
Outdated
@@ -12,15 +12,24 @@ import ( | |||
"golang.org/x/sys/unix" | |||
) | |||
|
|||
const globalDomainName = "global-domain" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Um. erofs package should import the constant from daemonconfig.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, will fix it.
pkg/utils/erofs/erofs_linux.go
Outdated
logrus.Infof("Mount erofs to %s with options %s", mountPoint, opts) | ||
if err := mount("erofs", mountPoint, "erofs", 0, opts); err != nil { | ||
err = mount("erofs", mountPoint, "erofs", 0, opts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still can improve the code like:
if err := mount("erofs", mountPoint, "erofs", 0, opts); err!=nil {
if errors.Is(err, unix.EINVAL) {
err = mount("erofs", mountPoint, "erofs", 0, "fsid="+fsID)
if err != nil {
return errr
}
}
return errors.Wrapf(err, "failed to mount erofs")
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
14621e2
to
b685756
Compare
Use a global domain for all mountpoints. If kernel doesn't support shared domain, will fallback to the mount without 'domain_id' option. Signed-off-by: Jia Zhu <zhujia.zj@bytedance.com>
b685756
to
f2f36e9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
https://lore.kernel.org/linux-erofs/20220902105305.79687-1-zhujia.zj@bytedance.com/T/#t
Signed-off-by: Jia Zhu zhujia.zj@bytedance.com