Skip to content

Commit 93c02d0

Browse files
committed
update mergerfs
1 parent 4ba837d commit 93c02d0

File tree

7 files changed

+18
-16
lines changed

7 files changed

+18
-16
lines changed

api/local_storage/openapi.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ components:
486486
example: "/mnt/a:/mnt/b"
487487
options:
488488
type: string
489-
example: "defaults,allow_other,use_ino,category.create=mfs,moveonenospc=true,minfreespace=1M"
489+
example: "defaults,allow_other,category.create=mfs,moveonenospc=true,minfreespace=1M"
490490
extended:
491491
type: object
492492
description: |-

build/sysroot/usr/local/bin/mergerfs.ctl

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def control_file(path):
6666

6767

6868
def add_srcmount(ctrlfile,srcmount):
69-
key = b'user.mergerfs.srcmounts'
69+
key = b'user.mergerfs.branches'
7070
value = b'+' + srcmount.encode()
7171
try:
7272
os.setxattr(ctrlfile,key,value)
@@ -75,7 +75,7 @@ def add_srcmount(ctrlfile,srcmount):
7575

7676

7777
def remove_srcmount(ctrlfile,srcmount):
78-
key = b'user.mergerfs.srcmounts'
78+
key = b'user.mergerfs.branches'
7979
value = b'-' + srcmount.encode()
8080
try:
8181
os.setxattr(ctrlfile,key,value)

pkg/fstab/fstab_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
const fstabContent = `
1111
# UNCONFIGURED FSTAB FOR BASE SYSTEM
1212
LABEL=UEFI /boot/efi vfat umask=0077 0 1
13-
/mnt/sdb:/mnt/sdc /media mergerfs defaults,allow_other,use_ino,category.create=mfs,moveonenospc=true,minfreespace=1M 0 0
13+
/mnt/sdb:/mnt/sdc /media mergerfs defaults,allow_other,category.create=mfs,moveonenospc=true,minfreespace=1M 0 0
1414
LABEL=desktop-rootfs / ext4 defaults 0 1
1515
`
1616

@@ -31,7 +31,7 @@ func TestFSTab(t *testing.T) {
3131
assert.Equal(t, entry.Source, "/mnt/sdb:/mnt/sdc")
3232
assert.Equal(t, entry.MountPoint, "/media")
3333
assert.Equal(t, entry.FSType, "mergerfs")
34-
assert.Equal(t, entry.Options, "defaults,allow_other,use_ino,category.create=mfs,moveonenospc=true,minfreespace=1M")
34+
assert.Equal(t, entry.Options, "defaults,allow_other,category.create=mfs,moveonenospc=true,minfreespace=1M")
3535
assert.Equal(t, entry.Dump, 0)
3636
assert.Equal(t, entry.Pass, PassDoNotCheck)
3737

@@ -51,7 +51,7 @@ func TestFSTab(t *testing.T) {
5151
assert.Equal(t, entry.Source, "/mnt/sdb:/mnt/sdc")
5252
assert.Equal(t, entry.MountPoint, "/media")
5353
assert.Equal(t, entry.FSType, "mergerfs")
54-
assert.Equal(t, entry.Options, "defaults,allow_other,use_ino,category.create=mfs,moveonenospc=true,minfreespace=1M")
54+
assert.Equal(t, entry.Options, "defaults,allow_other,category.create=mfs,moveonenospc=true,minfreespace=1M")
5555
assert.Equal(t, entry.Dump, 0)
5656
assert.Equal(t, entry.Pass, PassDoNotCheck)
5757
}

pkg/mergerfs/mergerfs.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func ListValues(fspath string) (map[string]string, error) {
4646
func SetSource(fspath string, sources []string) error {
4747
ctrlfile := ControlFile(fspath)
4848

49-
key := "user.mergerfs.srcmounts"
49+
key := "user.mergerfs.branches"
5050

5151
sourceMap := make(map[string]interface{})
5252
for _, source := range sources {
@@ -59,8 +59,9 @@ func SetSource(fspath string, sources []string) error {
5959
}
6060

6161
value := []byte(strings.Join(dedupedSources, ":"))
62-
logger.Error("SetSource", zap.String("key", key), zap.String("value", string(value)), zap.String("ctrlfile", ctrlfile))
62+
//str, err := command.ExecResultStr("setfattr -n " + key + " -v " + string(string(value)) + " " + ctrlfile)
6363
err := syscall.Setxattr(ctrlfile, key, value, 0)
64+
//logger.Error("SetSourceStr", zap.String("str", str))
6465
if err != nil {
6566
logger.Error("SetSource", zap.Error(err))
6667
return err
@@ -80,7 +81,7 @@ func GetSource(fspath string) ([]string, error) {
8081
func AddSource(fspath string, source string) error {
8182
ctrlfile := ControlFile(fspath)
8283

83-
key := "user.mergerfs.srcmounts"
84+
key := "user.mergerfs.branches"
8485
value := []byte("+" + source)
8586

8687
return syscall.Setxattr(ctrlfile, key, value, 0)
@@ -89,7 +90,7 @@ func AddSource(fspath string, source string) error {
8990
func RemoveSource(fspath string, source string) error {
9091
ctrlfile := ControlFile(fspath)
9192

92-
key := "user.mergerfs.srcmounts"
93+
key := "user.mergerfs.branches"
9394
value := []byte("-" + source)
9495

9596
return syscall.Setxattr(ctrlfile, key, value, 0)

route/v2/merge.go

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ func (s *LocalStorage) SetMerge(ctx echo.Context) error {
5555
if m.Fstype != nil {
5656
fstype = *m.Fstype
5757
}
58-
logger.Info("fstype", zap.String("fstype", fstype))
5958
// expand source volume paths to source volumes
6059
var sourceVolumes []*model2.Volume
6160
if m.SourceVolumeUuids != nil {

service/disk.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ func (d *diskService) EnsureDefaultMergePoint() bool {
9494
if len(existingMerges) > 1 {
9595
logger.Error("more than one merge point with the same mount point found", zap.String("mount point", mountPoint))
9696
}
97+
config.ServerInfo.EnableMergerFS = "true"
9798
return true
9899
}
99100

@@ -111,6 +112,7 @@ func (d *diskService) EnsureDefaultMergePoint() bool {
111112
isExist := false
112113
for _, v := range mounts {
113114
if v.MountPoint == mountPoint {
115+
config.ServerInfo.EnableMergerFS = "true"
114116
isExist = true
115117
merge.SourceBasePath = v.Source
116118
break
@@ -133,7 +135,7 @@ func (d *diskService) EnsureDefaultMergePoint() bool {
133135
if err := MyService.LocalStorage().CreateMergeInDB(merge); err != nil {
134136
panic(err)
135137
}
136-
138+
config.ServerInfo.EnableMergerFS = "true"
137139
return true
138140
}
139141
func (d *diskService) RemoveLSBLKCache() {
@@ -163,18 +165,18 @@ func (d *diskService) SmartCTL(path string) model.SmartctlA {
163165
buf := command.ExecSmartCTLByPath(path)
164166
if buf == nil {
165167
if err := Cache.Add(key, m, time.Minute*10); err != nil {
166-
logger.Error("failed to add cache", zap.Error(err), zap.String("key", key))
168+
//logger.Error("failed to add cache", zap.Error(err), zap.String("key", key))
167169
}
168170
return m
169171
}
170172

171173
err := json2.Unmarshal(buf, &m)
172174
if err != nil {
173-
logger.Error("failed to unmarshal json", zap.Error(err), zap.String("json", string(buf)))
175+
//logger.Error("failed to unmarshal json", zap.Error(err), zap.String("json", string(buf)))
174176
}
175177
if !reflect.DeepEqual(m, model.SmartctlA{}) {
176178
if err := Cache.Add(key, m, time.Hour*24); err != nil {
177-
logger.Error("failed to add cache", zap.Error(err), zap.String("key", key))
179+
//logger.Error("failed to add cache", zap.Error(err), zap.String("key", key))
178180
}
179181
}
180182
return m

service/v2/fs/mergerfs.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
const (
1010
MergerFS = "mergerfs"
1111
MergerFSFullName = "fuse.mergerfs"
12-
MergerFSDefaultOptions = "defaults,allow_other,use_ino,category.create=mfs,moveonenospc=true,minfreespace=1M"
12+
MergerFSDefaultOptions = "category.create=mfs,moveonenospc=true,minfreespace=1M"
1313

1414
MergerFSExtendedKeySource = "mergerfs.src" // corresponding value could be for example: /var/lib/casaos/files
1515

0 commit comments

Comments
 (0)