fs: Add safe locking semantics for format.json (#4523)

This patch also reverts previous changes which were
merged for migration to the newer disk format. We will
be bringing these changes in subsequent releases. But
we wish to add protection in this release such that
future release migrations are protected.

Revert "fs: Migration should handle bucketConfigs as regular objects. (#4482)"
This reverts commit 976870a391.

Revert "fs: Migrate object metadata to objects directory. (#4195)"
This reverts commit 76f4f20609.
This commit is contained in:
Harshavardhana
2017-06-12 17:40:28 -07:00
committed by GitHub
parent b8463a738c
commit 075b8903d7
20 changed files with 509 additions and 933 deletions

View File

@@ -134,6 +134,7 @@ func fsStat(statLoc string) (os.FileInfo, error) {
if err != nil {
return nil, traceError(err)
}
return fi, nil
}
@@ -142,12 +143,13 @@ func fsStat(statLoc string) (os.FileInfo, error) {
func fsStatDir(statDir string) (os.FileInfo, error) {
fi, err := fsStat(statDir)
if err != nil {
if os.IsNotExist(errorCause(err)) {
err = errorCause(err)
if os.IsNotExist(err) {
return nil, traceError(errVolumeNotFound)
} else if os.IsPermission(errorCause(err)) {
} else if os.IsPermission(err) {
return nil, traceError(errVolumeAccessDenied)
}
return nil, err
return nil, traceError(err)
}
if !fi.IsDir() {
@@ -161,16 +163,17 @@ func fsStatDir(statDir string) (os.FileInfo, error) {
func fsStatFile(statFile string) (os.FileInfo, error) {
fi, err := fsStat(statFile)
if err != nil {
if os.IsNotExist(errorCause(err)) {
err = errorCause(err)
if os.IsNotExist(err) {
return nil, traceError(errFileNotFound)
} else if os.IsPermission(errorCause(err)) {
} else if os.IsPermission(err) {
return nil, traceError(errFileAccessDenied)
} else if isSysErrNotDir(errorCause(err)) {
} else if isSysErrNotDir(err) {
return nil, traceError(errFileAccessDenied)
} else if isSysErrPathNotFound(errorCause(err)) {
} else if isSysErrPathNotFound(err) {
return nil, traceError(errFileNotFound)
}
return nil, err
return nil, traceError(err)
}
if fi.IsDir() {
return nil, traceError(errFileAccessDenied)