aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-12-17 13:05:20 -0800
committerChris Lu <chris.lu@gmail.com>2020-12-17 13:05:20 -0800
commitdaa8157fc2afc7c4caa1f8c04bc06c1fb32b193f (patch)
tree5b0c367299e31b7db974663f9bed57e0c526b9e8
parentf56e6d231e86ff1ca5fefcda220012ee121c88a5 (diff)
parente2076201d79e84df0407a9e1e535bf966452bba0 (diff)
downloadseaweedfs-daa8157fc2afc7c4caa1f8c04bc06c1fb32b193f.tar.xz
seaweedfs-daa8157fc2afc7c4caa1f8c04bc06c1fb32b193f.zip
Merge branch 'master' into support_ssd_volume
-rw-r--r--docker/Dockerfile.go_build4
-rw-r--r--docker/Dockerfile.go_build_large4
-rw-r--r--weed/storage/disk_location.go27
3 files changed, 27 insertions, 8 deletions
diff --git a/docker/Dockerfile.go_build b/docker/Dockerfile.go_build
index a5f8725e0..726046b56 100644
--- a/docker/Dockerfile.go_build
+++ b/docker/Dockerfile.go_build
@@ -2,8 +2,8 @@ FROM frolvlad/alpine-glibc as builder
RUN apk add git go g++
RUN mkdir -p /go/src/github.com/chrislusf/
RUN git clone https://github.com/chrislusf/seaweedfs /go/src/github.com/chrislusf/seaweedfs
-ARG branch=${branch:-master}
-RUN cd /go/src/github.com/chrislusf/seaweedfs && git checkout $ARG
+ARG BRANCH=${BRANCH:-master}
+RUN cd /go/src/github.com/chrislusf/seaweedfs && git checkout $BRANCH
RUN cd /go/src/github.com/chrislusf/seaweedfs/weed \
&& export LDFLAGS="-X github.com/chrislusf/seaweedfs/weed/util.COMMIT=$(git rev-parse --short HEAD)" \
&& go install -ldflags "${LDFLAGS}"
diff --git a/docker/Dockerfile.go_build_large b/docker/Dockerfile.go_build_large
index c3ea4e606..8fc85e868 100644
--- a/docker/Dockerfile.go_build_large
+++ b/docker/Dockerfile.go_build_large
@@ -2,8 +2,8 @@ FROM frolvlad/alpine-glibc as builder
RUN apk add git go g++
RUN mkdir -p /go/src/github.com/chrislusf/
RUN git clone https://github.com/chrislusf/seaweedfs /go/src/github.com/chrislusf/seaweedfs
-ARG branch=${branch:-master}
-RUN cd /go/src/github.com/chrislusf/seaweedfs && git checkout $ARG
+ARG BRANCH=${BRANCH:-master}
+RUN cd /go/src/github.com/chrislusf/seaweedfs && git checkout $BRANCH
RUN cd /go/src/github.com/chrislusf/seaweedfs/weed \
&& export LDFLAGS="-X github.com/chrislusf/seaweedfs/weed/util.COMMIT=$(git rev-parse --short HEAD)" \
&& go install -tags 5BytesOffset -ldflags "${LDFLAGS}"
diff --git a/weed/storage/disk_location.go b/weed/storage/disk_location.go
index 6623c0111..ce42232a7 100644
--- a/weed/storage/disk_location.go
+++ b/weed/storage/disk_location.go
@@ -55,7 +55,7 @@ func NewDiskLocation(dir string, maxVolumeCount int, minFreeSpacePercent float32
}
func volumeIdFromFileName(filename string) (needle.VolumeId, string, error) {
- if strings.HasSuffix(filename, ".idx") || strings.HasSuffix(filename, ".vif") {
+ if isValidVolume(filename) {
base := filename[:len(filename)-4]
collection, volumeId, err := parseCollectionVolumeId(base)
return volumeId, collection, err
@@ -73,15 +73,26 @@ func parseCollectionVolumeId(base string) (collection string, vid needle.VolumeI
return collection, vol, err
}
+func isValidVolume(basename string) bool {
+ return strings.HasSuffix(basename, ".idx") || strings.HasSuffix(basename, ".vif")
+}
+
+func getValidVolumeName(basename string) string {
+ if isValidVolume(basename) {
+ return basename[:len(basename)-4]
+ }
+ return ""
+}
+
func (l *DiskLocation) loadExistingVolume(fileInfo os.FileInfo, needleMapKind NeedleMapType) bool {
basename := fileInfo.Name()
if fileInfo.IsDir() {
return false
}
- if !strings.HasSuffix(basename, ".idx") && !strings.HasSuffix(basename, ".vif") {
+ volumeName := getValidVolumeName(basename)
+ if volumeName == "" {
return false
}
- volumeName := basename[:len(basename)-4]
// check for incomplete volume
noteFile := l.Directory + "/" + volumeName + ".note"
@@ -128,9 +139,17 @@ func (l *DiskLocation) concurrentLoadingVolumes(needleMapKind NeedleMapType, con
task_queue := make(chan os.FileInfo, 10*concurrency)
go func() {
+ foundVolumeNames := make(map[string]bool)
if fileInfos, err := ioutil.ReadDir(l.Directory); err == nil {
for _, fi := range fileInfos {
- task_queue <- fi
+ volumeName := getValidVolumeName(fi.Name())
+ if volumeName == "" {
+ continue
+ }
+ if _, found := foundVolumeNames[volumeName]; !found {
+ foundVolumeNames[volumeName] = true
+ task_queue <- fi
+ }
}
}
close(task_queue)