aboutsummaryrefslogtreecommitdiff
path: root/weed/filer2/filer_buckets.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-04-11 23:37:10 -0700
committerChris Lu <chris.lu@gmail.com>2020-04-11 23:37:10 -0700
commit1c65656fb4a64ae739b9a23a2f97f4032182015c (patch)
tree937f23d794adfcfa0cf1596cbc6825bf68f59360 /weed/filer2/filer_buckets.go
parente4af63a721f62c280596f626302b64729baeaee9 (diff)
downloadseaweedfs-1c65656fb4a64ae739b9a23a2f97f4032182015c.tar.xz
seaweedfs-1c65656fb4a64ae739b9a23a2f97f4032182015c.zip
s3: add option to fsync buckets
Diffstat (limited to 'weed/filer2/filer_buckets.go')
-rw-r--r--weed/filer2/filer_buckets.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/weed/filer2/filer_buckets.go b/weed/filer2/filer_buckets.go
index 3fc4afdab..7a57e7ee1 100644
--- a/weed/filer2/filer_buckets.go
+++ b/weed/filer2/filer_buckets.go
@@ -13,6 +13,7 @@ type BucketName string
type BucketOption struct {
Name BucketName
Replication string
+ fsync bool
}
type FilerBuckets struct {
dirBucketsPath string
@@ -20,36 +21,42 @@ type FilerBuckets struct {
sync.RWMutex
}
-func (f *Filer) LoadBuckets(dirBucketsPath string) {
+func (f *Filer) LoadBuckets() {
f.buckets = &FilerBuckets{
buckets: make(map[BucketName]*BucketOption),
}
- f.DirBucketsPath = dirBucketsPath
limit := math.MaxInt32
- entries, err := f.ListDirectoryEntries(context.Background(), util.FullPath(dirBucketsPath), "", false, limit)
+ entries, err := f.ListDirectoryEntries(context.Background(), util.FullPath(f.DirBucketsPath), "", false, limit)
if err != nil {
glog.V(1).Infof("no buckets found: %v", err)
return
}
+ shouldFsyncMap := make(map[string]bool)
+ for _, bucket := range f.FsyncBuckets {
+ shouldFsyncMap[bucket] = true
+ }
+
glog.V(1).Infof("buckets found: %d", len(entries))
f.buckets.Lock()
for _, entry := range entries {
+ _, shouldFsnyc := shouldFsyncMap[entry.Name()]
f.buckets.buckets[BucketName(entry.Name())] = &BucketOption{
Name: BucketName(entry.Name()),
Replication: entry.Replication,
+ fsync: shouldFsnyc,
}
}
f.buckets.Unlock()
}
-func (f *Filer) ReadBucketOption(buketName string) (replication string) {
+func (f *Filer) ReadBucketOption(buketName string) (replication string, fsync bool) {
f.buckets.RLock()
defer f.buckets.RUnlock()
@@ -57,9 +64,9 @@ func (f *Filer) ReadBucketOption(buketName string) (replication string) {
option, found := f.buckets.buckets[BucketName(buketName)]
if !found {
- return ""
+ return "", false
}
- return option.Replication
+ return option.Replication, option.fsync
}