Skip to content

Commit cab71f1

Browse files
authored
Merge pull request #243 from liulanzheng/main
only set vsize on first layer for rw scenarios
2 parents 8245172 + 8af3e8e commit cab71f1

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ jobs:
148148
echo "[ init env ]"
149149
sudo apt update && sudo apt install -y containerd.io libnl-3-200 libnl-genl-3-200
150150
sudo modprobe -a target_core_user tcm_loop
151-
wget https://github.com/containerd/overlaybd/releases/download/v1.0.2/overlaybd-1.0.2-0ubuntu1.22.04.x86_64.deb &&
152-
sudo dpkg -i overlaybd-1.0.2-0ubuntu1.22.04.x86_64.deb
151+
wget https://github.com/containerd/overlaybd/releases/download/v1.0.4/overlaybd-1.0.4-0ubuntu1.22.04.x86_64.deb &&
152+
sudo dpkg -i overlaybd-1.0.4-0ubuntu1.22.04.x86_64.deb
153153
sudo systemctl enable /opt/overlaybd/overlaybd-tcmu.service
154154
sudo systemctl start overlaybd-tcmu
155155
sudo systemctl status overlaybd-tcmu

cmd/convertor/builder/overlaybd_builder.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ func (e *overlaybdBuilderEngine) BuildLayer(ctx context.Context, idx int) error
9999
alreadyConverted = true
100100
}
101101
if !alreadyConverted {
102-
if err := e.create(ctx, layerDir, e.mkfs && (idx == 0)); err != nil {
102+
mkfs := e.mkfs && (idx == 0)
103+
vsizeGB := 0
104+
if idx == 0 {
105+
vsizeGB = 64
106+
}
107+
if err := e.create(ctx, layerDir, mkfs, vsizeGB); err != nil {
103108
return err
104109
}
105110
e.overlaybdConfig.Upper = snapshot.OverlayBDBSConfigUpper{
@@ -294,8 +299,8 @@ func (e *overlaybdBuilderEngine) getLayerDir(idx int) string {
294299
return path.Join(e.workDir, fmt.Sprintf("%04d_", idx)+e.manifest.Layers[idx].Digest.String())
295300
}
296301

297-
func (e *overlaybdBuilderEngine) create(ctx context.Context, dir string, mkfs bool) error {
298-
opts := []string{"-s", "64"}
302+
func (e *overlaybdBuilderEngine) create(ctx context.Context, dir string, mkfs bool, vsizeGB int) error {
303+
opts := []string{"-s", fmt.Sprintf("%d", vsizeGB)}
299304
if mkfs {
300305
opts = append(opts, "--mkfs")
301306
logrus.Infof("mkfs for baselayer")

docs/EXAMPLES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ This doc includes:
1717

1818
Check whether the `overlaybd-tcmu` is running.
1919

20+
Overlaybd-snapshotter v1.0.1+ requires overlaybd-tcmu v1.0.4+.
21+
2022
For any problems, please checkout [overlaybd](https://github.com/containerd/overlaybd).
2123

2224
### Proxy overlaybd snapshotter

docs/QUICKSTART.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ sudo systemctl start overlaybd-snapshotter
110110

111111
Users can compile the latest code to install or download the [release](https://github.com/containerd/overlaybd/releases).
112112

113+
There is no strong dependency between the overlaybd-snapshotter and overlaybd-tcmu versions. However, overlaybd-snapshotter v1.0.1+ requires overlaybd-tcmu v1.0.4+ because there have been adjustments made to the parameters for image conversion.
114+
113115
#### Compile from source
114116

115117
Install dependencies:

pkg/snapshot/storage.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,11 @@ func (o *snapshotter) constructOverlayBDSpec(ctx context.Context, key string, wr
552552
return errors.Errorf("unexpect storage %v of snapshot %v during construct overlaybd spec(writable=%v, parent=%s)", stype, key, writable, info.Parent)
553553
}
554554
log.G(ctx).Infof("prepare writable layer. (sn: %s)", id)
555-
if err := o.prepareWritableOverlaybd(ctx, id); err != nil {
555+
vsizeGB := 0
556+
if info.Parent == "" {
557+
vsizeGB = 64
558+
}
559+
if err := o.prepareWritableOverlaybd(ctx, id, vsizeGB); err != nil {
556560
return err
557561
}
558562

@@ -648,9 +652,8 @@ func (o *snapshotter) atomicWriteOverlaybdTargetConfig(snID string, configJSON *
648652
}
649653

650654
// prepareWritableOverlaybd
651-
func (o *snapshotter) prepareWritableOverlaybd(ctx context.Context, snID string) error {
652-
// TODO(fuweid): 256GB can be configurable?
653-
args := []string{"64"}
655+
func (o *snapshotter) prepareWritableOverlaybd(ctx context.Context, snID string, vsizeGB int) error {
656+
args := []string{fmt.Sprintf("%d", vsizeGB)}
654657
if o.writableLayerType == "sparse" {
655658
args = append(args, "-s")
656659
}

0 commit comments

Comments
 (0)