From 3e063cca5cf1c9e7c32a8b0f1e820e1c5bd04562 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Mon, 4 May 2020 16:48:03 +0100 Subject: [PATCH] Show the cause error in startup when directio is not supported (#9497) This commit tries to create a file using direct i/o in the startup so the server returns quickly and avoid cryptic other errors. --- cmd/posix.go | 2 +- cmd/storage-rest-server.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/posix.go b/cmd/posix.go index 5353c8440..28e71e806 100644 --- a/cmd/posix.go +++ b/cmd/posix.go @@ -175,7 +175,7 @@ func getValidPath(path string) (string, error) { var rnd [8]byte _, _ = rand.Read(rnd[:]) fn := pathJoin(path, ".writable-check-"+hex.EncodeToString(rnd[:])+".tmp") - file, err := os.Create(fn) + file, err := disk.OpenFileDirectIO(fn, os.O_CREATE, 0600) if err != nil { return path, err } diff --git a/cmd/storage-rest-server.go b/cmd/storage-rest-server.go index 6e90503ee..463412d20 100644 --- a/cmd/storage-rest-server.go +++ b/cmd/storage-rest-server.go @@ -747,7 +747,7 @@ func registerStorageRESTHandlers(router *mux.Router, endpointZones EndpointZones } hint := fmt.Sprintf("Run the following command to add the convenient permissions: `sudo chown %s %s && sudo chmod u+rxw %s`", username, endpoint.Path, endpoint.Path) - logger.Fatal(config.ErrUnableToWriteInBackend(err).Hint(hint), + logger.Fatal(config.ErrUnableToWriteInBackend(err).Msg(err.Error()).Hint(hint), "Unable to initialize posix backend") }