add additional fdatasync before close() on writes (#9947)

This commit is contained in:
Harshavardhana
2020-07-01 10:57:23 -07:00
committed by GitHub
parent 5388ae4acb
commit 174f428571
9 changed files with 134 additions and 42 deletions

View File

@@ -27,7 +27,6 @@ import (
"github.com/minio/minio/pkg/disk"
"github.com/minio/minio/pkg/madmin"
cpuhw "github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/host"
memhw "github.com/shirou/gopsutil/mem"
"github.com/shirou/gopsutil/process"
)
@@ -369,36 +368,3 @@ func getLocalProcOBD(ctx context.Context, r *http.Request) madmin.ServerProcOBDI
Processes: sysProcs,
}
}
func getLocalOsInfoOBD(ctx context.Context, r *http.Request) madmin.ServerOsOBDInfo {
addr := r.Host
if globalIsDistErasure {
addr = GetLocalPeer(globalEndpoints)
}
info, err := host.InfoWithContext(ctx)
if err != nil {
return madmin.ServerOsOBDInfo{
Addr: addr,
Error: err.Error(),
}
}
sensors, err := host.SensorsTemperaturesWithContext(ctx)
if err != nil {
return madmin.ServerOsOBDInfo{
Addr: addr,
Error: err.Error(),
}
}
// ignore user err, as it cannot be obtained reliably inside containers
users, _ := host.UsersWithContext(ctx)
return madmin.ServerOsOBDInfo{
Addr: addr,
Info: info,
Sensors: sensors,
Users: users,
}
}

View File

@@ -1,4 +1,4 @@
// +build !freebsd
// +build !freebsd,!netbsd,!openbsd,!solaris
/*
* MinIO Cloud Storage, (C) 2020 MinIO, Inc.
@@ -26,8 +26,42 @@ import (
"github.com/minio/minio/pkg/madmin"
diskhw "github.com/shirou/gopsutil/disk"
"github.com/shirou/gopsutil/host"
)
func getLocalOsInfoOBD(ctx context.Context, r *http.Request) madmin.ServerOsOBDInfo {
addr := r.Host
if globalIsDistErasure {
addr = GetLocalPeer(globalEndpoints)
}
info, err := host.InfoWithContext(ctx)
if err != nil {
return madmin.ServerOsOBDInfo{
Addr: addr,
Error: err.Error(),
}
}
sensors, err := host.SensorsTemperaturesWithContext(ctx)
if err != nil {
return madmin.ServerOsOBDInfo{
Addr: addr,
Error: err.Error(),
}
}
// ignore user err, as it cannot be obtained reliably inside containers
users, _ := host.UsersWithContext(ctx)
return madmin.ServerOsOBDInfo{
Addr: addr,
Info: info,
Sensors: sensors,
Users: users,
}
}
func getLocalDiskHwOBD(ctx context.Context, r *http.Request) madmin.ServerDiskHwOBDInfo {
addr := r.Host
if globalIsDistErasure {

View File

@@ -1,3 +1,5 @@
// +build freebsd netbsd openbsd solaris
/*
* MinIO Cloud Storage, (C) 2020 MinIO, Inc.
*
@@ -20,6 +22,7 @@ package cmd
import (
"context"
"net/http"
"runtime"
"github.com/minio/minio/pkg/madmin"
)
@@ -32,6 +35,18 @@ func getLocalDiskHwOBD(ctx context.Context, r *http.Request) madmin.ServerDiskHw
return madmin.ServerDiskHwOBDInfo{
Addr: addr,
Error: "unsupported platform",
Error: "unsupported platform: " + runtime.GOOS,
}
}
func getLocalOsInfoOBD(ctx context.Context, r *http.Request) madmin.ServerOsOBDInfo {
addr := r.Host
if globalIsDistErasure {
addr = GetLocalPeer(globalEndpoints)
}
return madmin.ServerOsOBDInfo{
Addr: addr,
Error: "unsupported platform: " + runtime.GOOS,
}
}

View File

@@ -1694,7 +1694,10 @@ func (s *xlStorage) CreateFile(volume, path string, fileSize int64, r io.Reader)
return err
}
defer w.Close()
defer func() {
disk.Fdatasync(w) // Only interested in flushing the size_t not mtime/atime
w.Close()
}()
bufp := s.pool.Get().(*[]byte)
defer s.pool.Put(bufp)