Skip to content

Commit 72a123c

Browse files
committed
Optimization critical area & rename 'mode' to 'rwMode'
Signed-off-by: Yifan Yuan <tuji.yyf@alibaba-inc.com>
1 parent e504a69 commit 72a123c

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

docs/QUICKSTART.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ The config file is `/etc/overlaybd-snapshotter/config.json`. Please create the f
6060
"root": "/var/lib/containerd/io.containerd.snapshotter.v1.overlaybd",
6161
"address": "/run/overlaybd-snapshotter/overlaybd.sock",
6262
"verbose": "info",
63-
"mode": "overlayfs",
63+
"rwMode": "overlayfs",
6464
"logReportCaller": false,
6565
"autoRemoveDev": false
6666
}
@@ -70,7 +70,7 @@ The config file is `/etc/overlaybd-snapshotter/config.json`. Please create the f
7070
| `root` | the root directory to store snapshots |
7171
| `address` | the socket address used to connect withcontainerd. |
7272
| `verbose` | log level, `info` or `debug` |
73-
| `mode` | rootfs mode about wether to use native writable layer. See [Native Support for Writable](docs/WRITABLE.md) for detail. |
73+
| `rwMode` | rootfs mode about wether to use native writable layer. See [Native Support for Writable](docs/WRITABLE.md) for detail. |
7474
| `logReportCaller` | enable/disable the calling method |
7575
| `autoRemoveDev` | enable/disable auto clean-up overlaybd device after container removed |
7676

pkg/snapshot/overlay.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,14 @@ type BootConfig struct {
147147
Root string `json:"root"`
148148
LogLevel string `json:"verbose"`
149149
LogReportCaller bool `json:"logReportCaller"`
150-
Mode string `json:"mode"` // fs, dir or dev
150+
RwMode string `json:"rwMode"` // overlayfs, dir or dev
151151
AutoRemoveDev bool `json:"autoRemoveDev"`
152152
}
153153

154154
func DefaultBootConfig() *BootConfig {
155155
return &BootConfig{
156156
LogLevel: "info",
157-
Mode: "overlayfs",
157+
RwMode: "overlayfs",
158158
LogReportCaller: false,
159159
AutoRemoveDev: false,
160160
}
@@ -209,7 +209,7 @@ type Opt func(config *SnapshotterConfig) error
209209
// - metadata.db
210210
type snapshotter struct {
211211
root string
212-
mode string
212+
rwMode string
213213
config SnapshotterConfig
214214
metacopyOption string
215215
ms *storage.MetaStore
@@ -254,7 +254,7 @@ func NewSnapshotter(bootConfig *BootConfig, opts ...Opt) (snapshots.Snapshotter,
254254

255255
return &snapshotter{
256256
root: bootConfig.Root,
257-
mode: bootConfig.Mode,
257+
rwMode: bootConfig.RwMode,
258258
ms: ms,
259259
indexOff: indexOff,
260260
config: config,
@@ -357,7 +357,7 @@ func (o *snapshotter) getWritableType(ctx context.Context, id string, info snaps
357357
}
358358
m, ok := info.Labels[LabelSupportReadWriteMode]
359359
if !ok {
360-
return rwMode(o.mode)
360+
return rwMode(o.rwMode)
361361
}
362362

363363
return rwMode(m)
@@ -593,10 +593,12 @@ func (o *snapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, er
593593
log.G(ctx).Debugf("Mounts (key: %s, id: %s, parentID: %s, kind: %d)", key, s.ID, s.ParentIDs, s.Kind)
594594

595595
if len(s.ParentIDs) > 0 {
596-
o.locker.Lock(s.ID)
597-
defer o.locker.Unlock(s.ID)
598-
o.locker.Lock(s.ParentIDs[0])
599-
defer o.locker.Unlock(s.ParentIDs[0])
596+
if o.autoRemoveDev {
597+
o.locker.Lock(s.ID)
598+
defer o.locker.Unlock(s.ID)
599+
o.locker.Lock(s.ParentIDs[0])
600+
defer o.locker.Unlock(s.ParentIDs[0])
601+
}
600602

601603
_, info, _, err := storage.GetInfo(ctx, key)
602604
if err != nil {

script/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"root": "/var/lib/containerd/io.containerd.snapshotter.v1.overlaybd",
33
"address": "/run/overlaybd-snapshotter/overlaybd.sock",
44
"verbose": "info",
5-
"mode": "overlayfs",
5+
"rwMode": "overlayfs",
66
"logReportCaller": false,
77
"autoRemoveDev": false
88
}

0 commit comments

Comments
 (0)