Repository: minio/minio (language: go)

Issue:
panic: unaligned 64-bit atomic operation [32-bit arm]
## Expected Behavior
Run mc admin update command
MinIO server restarts after performing the update
Stored data can be accessed via mc client

## Current Behavior
mc admin update command installs the update
MinIO Server crashes on Ubuntu latest with settings set
(OS: Ubuntu 20.04.4 LTS armv7l, Dual-core ARM Cortex-A15)

panic: unaligned 64-bit atomic operation

goroutine 91 [running]:
runtime/internal/atomic.panicUnaligned()
        {...}go/src/runtime/internal/atomic/unaligned.go:8 +0x24
runtime/internal/atomic.Xadd64(0x74dd51c, 0x1)
        {...}go/src/runtime/internal/atomic/atomic_arm.s:258 +0x14
github.com/minio/minio/cmd.(*xlStorageDiskIDCheck).updateStorageMetrics.func1(0x7e6cb80)
        {...}go/pkg/mod/github.com/minio/minio@v0.0.0-20220316081900-0bf80b3c89e5/cmd/xl-storage-disk-id-check.go:509 +0xa4
github.com/minio/minio/cmd.(*xlStorageDiskIDCheck).TrackDiskHealth.func1.1()
        {...}go/pkg/mod/github.com/minio/minio@v0.0.0-20220316081900-0bf80b3c89e5/cmd/xl-storage-disk-id-check.go:661 +0xb8
sync.(*Once).doSlow(0x7e8a940, 0x7f53e2c)
        {...}go/src/sync/once.go:68 +0xb8
sync.(*Once).Do(0x7e8a940, 0x7f53e2c)
        {...}go/src/sync/once.go:59 +0x40
github.com/minio/minio/cmd.(*xlStorageDiskIDCheck).TrackDiskHealth.func1(0x7e6cb80)
        {...}go/pkg/mod/github.com/minio/minio@v0.0.0-20220316081900-0bf80b3c89e5/cmd/xl-storage-disk-id-check.go:644 +0x84
github.com/minio/minio/cmd.(*xlStorageDiskIDCheck).ReadAll(0x74dd400, {0x44141a4, 0x70c0004}, {0x1f464cf, 0xa}, {0x1f49dad, 0xb})
        {...}go/pkg/mod/github.com/minio/minio@v0.0.0-20220316081900-0bf80b3c89e5/cmd/xl-storage-disk-id-check.go:476 +0x218
github.com/minio/minio/cmd.loadFormatErasure({0x4420f24, 0x74dd400})
        {...}go/pkg/mod/github.com/minio/minio@v0.0.0-20220316081900-0bf80b3c89e5/cmd/format-erasure.go:387 +0x58
github.com/minio/minio/cmd.loadFormatErasureAll.func1()
        {...}go/pkg/mod/github.com/minio/minio@v0.0.0-20220316081900-0bf80b3c89e5/cmd/format-erasure.go:326 +0x68
github.com/minio/minio/internal/sync/errgroup.(*Group).Go.func1()
        {...}go/pkg/mod/github.com/minio/minio@v0.0.0-20220316081900-0bf80b3c89e5/internal/sync/errgroup/errgroup.go:123 +0x1d0
created by github.com/minio/minio/internal/sync/errgroup.(*Group).Go
        {...}go/pkg/mod/github.com/minio/minio@v0.0.0-20220316081900-0bf80b3c89e5/internal/sync/errgroup/errgroup.go:105 +0xa4

## Possible Solution
Using other hardware, reinstall a previous minio version

However, compiling the source code with go1.18 using GO111MODULE=on go install github.com/minio/minio@latest
results in a finished compiled minio (server) that can run and show the version number, but won't start up the MinIO Server 
due to panic: unaligned 64-bit atomic operation with setting like erasure code set for multiple storage devices and console

## Steps to Reproduce (for bugs)

1. Ubuntu latest (Ubuntu 20.04.4 LTS armv7l)
2. Using a minio version from earlier this month
3. Run mc admin update
4. Looking at the terminal while starting minio on the server side, mc won't be able to connect

## Context
Sounds similar to #12559 

## Regression


## Your Environment
Tested working Environment:
minio version RELEASE.2022-03-05T06-32-39Z
on Linux {...} 4.2.8 #2 SMP Sat Jan 29 05:22:45 CST 2022 armv7l armv7l armv7l GNU/Linux

Tested non-working Environments: (stuck with a panic on MinIO server startup)
minio version RELEASE.2022-03-14T18-25-24Z
and compiled from source minio version DEVELOPMENT.GOGET (using go version go1.18 linux/arm)
on Linux {...} 4.2.8 #2 SMP Sat Jan 29 05:22:45 CST 2022 armv7l armv7l armv7l GNU/Linux


Discussion / hints:
Please test on the latest official release, no home-builds please. Changes has been made to that piece of code since then.

Please report back if latest still experiences the crash.
I just tested the new version of today (https://dl.min.io/server/minio/release/linux-arm/),
and get minio --version: minio version RELEASE.2022-03-17T06-34-49Z
and 
panic: unaligned 64-bit atomic operation

goroutine 101 [running]:
runtime/internal/atomic.panicUnaligned()
        runtime/internal/atomic/unaligned.go:8 +0x24
runtime/internal/atomic.Xadd64(0x6e4075c, 0x1)
        runtime/internal/atomic/atomic_arm.s:256 +0x14
github.com/minio/minio/cmd.(*xlStorageDiskIDCheck).updateStorageMetrics.func1(0x6e73890)
        github.com/minio/minio/cmd/xl-storage-disk-id-check.go:509 +0xa4
github.com/minio/minio/cmd.(*xlStorageDiskIDCheck).TrackDiskHealth.func1.1()
        github.com/minio/minio/cmd/xl-storage-disk-id-check.go:661 +0xb8
sync.(*Once).doSlow(0x6ebd480, 0x64c765c)
        sync/once.go:68 +0x94
sync.(*Once).Do(0x6ebd480, 0x64c765c)
        sync/once.go:59 +0x40
github.com/minio/minio/cmd.(*xlStorageDiskIDCheck).TrackDiskHealth.func1(0x6e73890)
        github.com/minio/minio/cmd/xl-storage-disk-id-check.go:644 +0x84
github.com/minio/minio/cmd.(*xlStorageDiskIDCheck).ReadAll(0x6e40640, {0x42effc8, 0x60440a4}, {0x1e5f2d9, 0xa}, {0x1e62b60, 0xb})
        github.com/minio/minio/cmd/xl-storage-disk-id-check.go:476 +0x200
github.com/minio/minio/cmd.loadFormatErasure({0x43374ec, 0x6e40640})
        github.com/minio/minio/cmd/format-erasure.go:387 +0x58
github.com/minio/minio/cmd.loadFormatErasureAll.func1()
        github.com/minio/minio/cmd/format-erasure.go:326 +0x68
github.com/minio/minio/internal/sync/errgroup.(*Group).Go.func1(0x6e678f0, 0x3, 0x6e679b0)
        github.com/minio/minio/internal/sync/errgroup/errgroup.go:123 +0x18c
created by github.com/minio/minio/internal/sync/errgroup.(*Group).Go
        github.com/minio/minio/internal/sync/errgroup/errgroup.go:105 +0x58

Same system is running with minio version RELEASE.2022-03-05T06-32-39Z
and previos versions from Feb. with no errors, mc connects and shows all stats,
minio server is looking good, no errors

 You are running an older version of MinIO released 1 week ago 
 Update: Run `mc admin update`

running the mc admin update command from mc client runs successfully
Server {...} updated successfully from 2022-03-05T06:32:39Z to 2022-03-17T06-34-49Z 

Restarting the minio server after update:
... Documentation: https://docs.min.io
Restarting on service signal - mc client:  connect: connection refused. 

Starting minio server (2022-03-17T06-34-49Z):
panic: unaligned 64-bit atomic operation

goroutine 77 [running]:
runtime/internal/atomic.panicUnaligned()
        runtime/internal/atomic/unaligned.go:8 +0x24 ...
Strange. Can't really see what would cause it to be unaligned. I will send a PR that moves it to the front.

Fix patch:
diff --git a/cmd/xl-storage-disk-id-check.go b/cmd/xl-storage-disk-id-check.go
index 66b13c6703d5c..ab9e9c1a509c2 100644
--- a/cmd/xl-storage-disk-id-check.go
+++ b/cmd/xl-storage-disk-id-check.go
@@ -71,14 +71,11 @@ const (
 
 // Detects change in underlying disk.
 type xlStorageDiskIDCheck struct {
-	// fields position optimized for memory please
-	// do not re-order them, if you add new fields
-	// please use `fieldalignment ./...` to check
-	// if your changes are not causing any problems.
-	storage      *xlStorage
+	// apiCalls should be placed first so alignment is guaranteed for atomic operations.
+	apiCalls     [storageMetricLast]uint64
 	apiLatencies [storageMetricLast]*lockedLastMinuteLatency
 	diskID       string
-	apiCalls     [storageMetricLast]uint64
+	storage      *xlStorage
 	health       *diskHealthTracker
 }
 


Test patch: