CFanのBlog

A good day for snow-viewing

Synology VM on ESXi with a passed-through SATA controller now and then loses the whole pool: irqbalance moved the controller’s MSI interrupt

No comments on Synology VM on ESXi with a passed-through SATA controller now and then loses the whole pool: irqbalance moved the controller’s MSI interrupt
230 views

Translated from the Chinese original by Claude.

My NAS at home is a Synology virtual machine (Xpenology) running on ESXi, with the motherboard’s Intel SATA controller passed through to it and four drives attached. Over the past year it has inexplicably lost its drives six times: the four drives on the passed-through controller all dropped out in the same second, the storage pool went straight to Crashed, and a reboot made everything fine again. Sometimes 3 days apart, sometimes more than six months, with no pattern whatsoever.

Every previous time I’d just rebooted and left it at that; this time I resisted, logged in and read the kernel log. The drives and cables turned out to be fine: it was DSM’s own irqbalance trying to move the passed-through controller’s interrupt to another CPU. On bare metal the device would go along with that, but with ESXi passthrough the change is simply ignored and the interrupt keeps going wherever it went at boot. That did no harm as long as the kernel kept the old slot, until one day it freed it (do_IRQ: 0.145 No irq handler for vector): the driver never received another interrupt, every command to the four drives timed out, and in the end the kernel disabled them one by one.

The fix is to start irqbalance with --banirq so that it leaves this interrupt alone. After the change I rebooted, the NAS was back two minutes later and the storage pool reassembled itself. Below is a record of how I got there.

MSI interrupt path of the passed-through SATA controller: normally the interrupt goes to CPU0; after irqbalance moves it, ESXi still delivers it to vector 145 on CPU0, which the kernel has freed, and the AHCI driver never receives the completion interrupt
Left: normal operation; right: when it goes wrong. The CPU and vector numbers are the ones from this incident’s logs.

Setup

PartConfiguration
HostESXi 8.0 U3 (8.0.3 build 24859861), Xeon Silver 4210R, motherboard with the Intel C620 chipset
Virtual machineDSM 7.4.1-90080 Update 1, set up as model RS1221+, kernel 4.4.302+, 8 vCPUs
Drives 1 and 2VMware virtual disks on a virtual SATA controller. Storage Pool 1 (RAID 1), holding Docker and the packages
Drives 3–6On the motherboard’s Intel C620 SATA controller (AHCI, 8086:a182), passed through. Three 12 TB drives make up Storage Pool 2 (SHR), plus one 1 TB drive not in any pool

DSM keeps a copy of its system partition on every drive, so even with all the passed-through drives gone the system was still alive: the web interface opened and /var/log was still there.

Symptoms

  • In Storage Manager, Storage Pool 2 showed as Crashed, and HDD/SSD listed only the two virtual disks.
  • One of the notifications read Drive slot has been disabled.
  • The Docker containers on Storage Pool 1 were unaffected; every shared folder on Storage Pool 2 was gone.

DSM’s logs (the system log and the drive log merged in time order, all verbatim):

All four drives dropped out in the same second.

Scrolling back through the logs, I found the same dropout six times in all:

Dropout (UTC)Since the previous oneHow it was recovered
2025-11-06 12:16—Reboot
2025-12-27 23:0551 daysReboot
2026-03-02 04:1665 daysReboot
2026-03-29 21:0927 daysReboot
2026-04-01 17:133 daysReboot
2026-11-10 19:46223 daysThis time

The four drives are two brands and four models, so they can’t all have failed in the same second, and the two virtual disks had never had a problem. It definitely wasn’t the drives themselves: the cause had to be in the controller, the passthrough or the power supply.

SSH wouldn’t let me in either

I wanted to log in and read the logs, but key login was refused outright:

The key was fine: ssh -v showed the public key being offered, the server just wouldn’t accept it. It took me a moment to realise: the homes shared folder lives on Storage Pool 2, so authorized_keys had gone down with it. Sigh.

root’s home directory is on the system partition, so it was unaffected. Log in with the password, sudo -i, add the public key under root, and you can then log in as root with the key:

Don’t reboot just yet. A reboot does bring the storage pool back, but it also wipes the evidence, /proc/interrupts and the like, and that evidence is the only reason I could track this down. Also, once the storage pool has gone, btrfs floods kern.log with errors: mine logged over 200,000 lines in an hour, and only 9 log files are kept, so the records from the few minutes when it happened get pushed out within a few hours. Best save a copy first.

Background

A few things to explain before the logs; if you know them already, feel free to skip ahead.

An interrupt (IRQ) is how hardware tells the CPU that something has happened. For example, when the disk controller finishes a read or write command it raises an interrupt, and only when the driver in the kernel (here the AHCI driver) receives it does it know the command has completed. Having issued a command, the driver waits for this interrupt; if it never comes, all it can do is time out.

Each line of /proc/interrupts is one interrupt number, followed by how many times each CPU has handled it, and finally which device it belongs to.

PCI devices used to signal interrupts over dedicated interrupt lines (INTx), with several devices possibly sharing one line, routed to the CPU through the IOAPIC. Today’s PCI devices have nearly all switched to MSI (Message Signaled Interrupts): there is no interrupt line; when the device wants to raise an interrupt it writes a value to a particular address, and that write is itself the interrupt.

That address and value are stored in the device’s configuration space, set by the kernel when the driver loads. On x86 the address looks like 0xfeeXXXXX and contains the APIC ID of the target CPU, and the data holds the vector number. Each CPU has a vector table in which the kernel records which vector belongs to which interrupt handler. So which vector on which CPU an MSI interrupt goes to is decided by those two values in the device, and lspci -vv shows them. The 0.145 in the logs further down means vector 145 on CPU 0.

Which CPU handles an interrupt is called its affinity, and it can be changed. irqbalance is a daemon that looks at the interrupt load on each CPU every so often and moves interrupts between CPUs to even the load out. To move an MSI interrupt, the kernel allocates a new vector on the new CPU, then rewrites the address and data in the device.

The address and data are two separate registers, so changing them takes two writes. Some devices support MSI masking (with MSI-X every interrupt has its own mask bit), so the interrupt can be held off before the change and let through again afterwards. Those that don’t (lspci shows Maskable-) can only be changed directly, and if the device happens to raise an interrupt halfway through, it can end up in the wrong place.

Passthrough means ESXi hands a physical device straight to a virtual machine, and the driver inside the VM operates the device directly. How interrupts get into the VM, though, is ESXi’s business: it delivers them to the target (which CPU, which vector) that the VM has set for the device. So when the VM changes the MSI target, ESXi has to follow suit.

The kernel log

For four drives dropping out together I could think of roughly three explanations, and each looks different in the logs:

Possible causeWhat you’d see in the kernel log
The passed-through controller’s interrupts are being lostCommands time out; after a reset the link comes up normally, but the IDENTIFY that follows times out again
The controller has dropped off the PCI bus (a problem on the ESXi side)controller reset failed, registers read back as all ones
The power, cabling or backplane the four drives shareSATA link down on every port at once

Then I looked at the few minutes around the incident in /var/log/kern.log. I’ve removed the host name and the kernel timestamps; the notes after the arrows are mine, and ata35–ata38 are drives 3–6 on the passed-through controller:

What this shows:

  • SErr is 0 and after every reset the link comes straight back up at 6.0 Gbps, so it isn’t the power or the cables. When I checked SMART later, UDMA_CRC_Error_Count was 0 on all four drives as well.
  • There’s no controller reset failed: the controller was there the whole time.
  • Commands go out fine; it’s the interrupts saying they’ve completed that never arrive. In those few minutes there were 36 No irq handler for vector lines, every one of them 0.145, with two appearing after each reset.

0.145 is vector 145 on CPU 0: an interrupt was delivered there, but the kernel had no handler registered at that slot.

Where did the interrupts go?

As I hadn’t rebooted, all the evidence was still there. First, which interrupt does the passed-through controller use? lspci shows two SATA controllers; 13:00.0 is the passed-through Intel controller (DeviceName pciPassthru0), and its interrupt number is in sysfs:

So it’s IRQ 25. Interrupt numbers are assigned at boot rather than fixed, which is why the script further down looks it up each time too.

Next, /proc/interrupts (some of the middle columns left out); the last column of line 25 is that same PCI address:

In 20 days of uptime the passed-through controller (IRQ 25) had had over a hundred million interrupts, all on CPU0, bar a single one on CPU2; every other CPU shows 0. A few more places to look:

  • The MSI Address is fee04000, so the target APIC ID is 4, which is CPU2 in this VM; the Data is 0x4054, so the vector is 0x54, i.e. 84. In other words, the kernel had already changed this device’s MSI to deliver to vector 84 on CPU2.
  • CPU2 did receive one interrupt, but every one after that went to vector 145 on CPU0, which doesn’t match what’s written in the device.
  • The affinity is 6: irqbalance later wanted to move it again, to CPU6. For this kind of MSI, an affinity change is only actually carried out when the next interrupt arrives, and the next interrupt never came.
  • Maskable-: this controller’s MSI doesn’t support masking.
  • The thing changing the affinity is irqbalance, which comes with DSM and runs from boot.

At this point one thing was certain: the target written in the device is CPU2 / 84, the interrupts were actually being delivered to CPU0 / 145, and the kernel no longer recognised vector 145 on CPU0. Two things still didn’t add up, though. irqbalance moves interrupts around like this every day on real Synology hardware, so why is that fine? And IRQ 25 had run happily on CPU0 for 20 days, so when did it go wrong?

Why it’s fine on bare metal but not on ESXi

First I looked at the ESXi side. Around 19:42, neither the VM’s vmware.log nor the host’s vmkernel.log had a single line about this device; there were only a few passthrough entries from when the VM rebooted. In other words, ESXi took no notice at all of the VM changing the MSI.

Next, how ESXi delivers this interrupt:

ESXi has posted interrupts turned on: interrupts from passed-through devices don’t go through ESXi’s software at all; the hardware delivers them straight to a particular CPU and vector in the VM according to a table, and that table is filled in by ESXi. So the question is whether ESXi updates the table when the VM rewrites the MSI.

I simply tried it (by now I had rebooted, and IRQ 25 was on vector 145 on CPU0): while dd read from a drive to generate interrupts, I changed the passed-through controller’s MSI data register inside the VM from vector 145 to 231, held it there for 50 ms and changed it back, to see whether interrupts still reached CPU0 during those 50 ms. The script’s output:

The register really had changed (it read back as e7, i.e. 231), yet all 1489 interrupts in those 50 ms still went to CPU0, without losing a single one. Changing the address register (the target CPU) from CPU0 to CPU7 made no difference either (only the relevant lines kept):

So ESXi ignores the VM’s rewrites of the MSI completely and keeps delivering interrupts to the CPU and vector that were set when the VM enabled MSI (that is, at boot). On bare metal there’s no such layer: a change to the device’s own registers takes effect immediately, and irqbalance can move things around as much as it likes.

This experiment is risky. Had ESXi honoured the rewrite, every interrupt in those 50 ms would have been lost: at best a hang of some tens of seconds, at worst the drives dropping out again. Don’t try it casually on a machine with data on it.

So how did it last 20 days?

When the 4.4 kernel moves an interrupt, it doesn’t drop the old vector straight away: only once the first interrupt arrives at the new location does it consider the move complete and free the old vector. ESXi kept delivering to the old location, the old vector stayed valid, and so everything worked; the only oddity was that the CPU shown in smp_affinity didn’t match the CPU actually receiving the interrupts. That state can carry on indefinitely.

Until an interrupt really does turn up at the new location: that lonely single count on CPU2 in /proc/interrupts is the one. That interrupt most likely didn’t come from the passed-through controller but from the virtual SATA controller (IRQ 24): its MSI can’t be masked either, and irqbalance moves it about every 30 seconds. When it does, the kernel writes the address first and the data second, and if an interrupt happens to come in between the two, it goes to the new CPU but the old vector. That’s where the odd stray No irq handler line in the logs normally comes from.

I wrote a script to record the time (in seconds since boot) of every change to IRQ 24’s MSI registers, and two of them lined up with the kernel log:

When a misdirected interrupt like this lands on a vector nobody is using, it’s just one No irq handler line and does no harm. But if it happens to land on the new slot reserved for IRQ 25 (vector 84 on CPU2), the kernel concludes that IRQ 25 has finished moving and frees the old vector on CPU0, while ESXi is still delivering to the old slot, so every real interrupt from then on is lost.

An interrupt from the virtual SATA controller, misdirected while irqbalance was moving it, lands on vector 84 on CPU2, which is reserved for the passed-through controller; the kernel frees the old vector and the passed-through controller's drives drop out
One of the virtual controller’s interrupts goes astray and lands exactly on the slot reserved for the passed-through controller. This step is inferred.

I didn’t catch this last step in the act; it’s an inference. The numbers do fit, though: in the 20 days of the previous boot there were 502 such lines in all, spread over 182 different vectors. That works out at roughly one hit in a thousand, and at about 25 a day that’s once every 40 days or so, the same order of magnitude as the actual intervals (3 to 223 days, 74 on average).

So the full sequence of events should be:

  1. After boot, irqbalance moves IRQ 25 from CPU0 to CPU2, and the kernel changes the device’s MSI address and data. Exactly when it moved I don’t know; possibly not long after boot.
  2. ESXi ignores the change and keeps delivering the interrupts to vector 145 on CPU0. The kernel’s old vector is still in place, so everything carries on working.
  3. 20 days later, a misdirected interrupt happens to land on vector 84 on CPU2; the kernel decides the move is complete and frees the old vector on CPU0.
  4. The real interrupts still go to vector 145 on CPU0, where there’s no longer a handler, and all of them are lost.
  5. The AHCI driver waits in vain for interrupts: commands time out, the port is reset, they time out again, and finally the port is disabled. The four drives sit on the same controller and share this one interrupt, so they all drop out together.

The intervals are so random because it has to wait for a misdirected interrupt to land on exactly that spot.

I also looked at how DSM starts irqbalance. The start script /usr/syno/etc/rc.sysv/irqbalance.sh looks in synoinfo.conf for two values, syno_10g_irq_bind_cpus and syno_ahci_irq_bind_cpus, and if they’re set it adds Synology’s own CPU-pinning options. My model’s configuration has neither, so it’s a plain irqbalance with no options at all, and it moves every single interrupt around.

Normally there are a few dozen No irq handler lines a day, each with a different CPU and vector, appearing once and never again; when things went wrong, it was the same 0.145 over and over. So don’t just count the lines; look at whether the same vector keeps repeating:

The fix

Since ESXi doesn’t honour the rewrite, just don’t let irqbalance move this interrupt: then the kernel and ESXi always agree on the same location from boot, and every other interrupt is handled as usual. The irqbalance that comes with DSM is 1.6.0, which supports --banirq.

Hard-coding the interrupt number isn’t very safe, so I wrote a script that looks it up at start-up: it finds every AHCI controller that isn’t a VMware virtual device and bans all their interrupts. Save it as /usr/local/bin/irqbalance-passthrough-ban.sh, and remember to chmod 755 it:

Then replace the original start command with a systemd drop-in, /etc/systemd/system/irqbalance.service.d/10-passthrough-ban.conf:

To confirm that irqbalance really honours the option, you can do a single run in debug mode:

A DSM update might wipe the drop-in, so I added a check at boot as well. At boot DSM runs /usr/local/etc/rc.d/*.sh start, so put an irqbalance-passthrough-ban.sh in there (also chmod 755) that puts the drop-in back if it has gone:

Other approaches I didn’t use:

  • --banmod=ahci looks less fiddly, but this kernel names the interrupt after the PCI address (0000:13:00.0) rather than ahci, so I doubt it would match. I didn’t try it.
  • Synology’s own --synoahciirq pins the AHCI interrupt to a given CPU, which amounts to deliberately moving it once: even worse.
  • Stopping irqbalance altogether would also work, but then nothing would look after the interrupts of the network card’s 8 queues; banning just the one has the least impact.

Reboot

That’s DSM’s own command, the same as clicking Restart in the web interface. I ran it at 22:15 and could log in at 22:18; it was unreachable for less than two minutes. Once it was up, Storage Pool 2 had reassembled itself:

Presumably that’s because the three drives dropped out together: by the time md tried to record on the drives which of them had failed, none of them was responding any more (that’s what the write errors in the DSM log are). So the metadata on all three drives stopped just before the incident and is consistent, which is why the array assembled straight away on reboot without a rebuild.

While I was at it, I checked:

  • btrfs device stats /volume2: all zeros
  • SMART: PASSED on all four drives, with zero reallocated sectors, pending sectors and CRC errors
  • My usual account could log in with the key again
  • The containers had all started by themselves

One more thing: the three passed-through drives had been offline for over two hours, so at boot the mirror of DSM’s system partition kicked them out as stale (md: kicking non-fresh sata3p1 from array!), and Storage Manager reports that the system partition has failed. Your data isn’t affected: click Repair in Storage Manager and it finishes syncing in a few minutes.

Looking at the interrupts again 17 minutes after boot:

irqbalance had already moved the virtual controller’s interrupt across several CPUs, while the passed-through controller stayed on CPU0 throughout. There’s still the occasional No irq handler (one in these 17 minutes, 3.120), of the kind described above, but IRQ 25 has kept working and there are no ATA errors.

What’s still uncertain

  • Only 9 copies of kern.log are kept, so the kernel logs from the first five incidents are long gone. All I can say is that DSM showed the same symptoms; I can’t promise it was the same cause.
  • I didn’t catch the one interrupt that landed on the reserved slot; that part is inferred from the numbers.
  • The longest gap was 7 months, so only time will tell whether it’s really fixed.
  • There’s one more approach I haven’t tried: on the ESXi side, add a line to the VM’s .vmx, pciPassthru0.msiEnabled = "FALSE", so that the passed-through device doesn’t use MSI and falls back to INTx. With the ban in place it shouldn’t be needed.
  • After a DSM update, check that --banirq is still on irqbalance’s command line.

If it happens to you

If you have a Linux VM on ESXi with a SATA controller passed through, and every so often all the drives on that controller drop out at once and a reboot puts it right, here’s how to check:

  1. Don’t reboot yet. If key login fails, add your public key to root as described above.
  2. Check the kernel log for links that come up while commands time out, and for No irq handler for vector repeating with the same vector:
  3. Check whether /proc/interrupts shows all of the passed-through controller’s interrupts on one CPU while /proc/irq/N/smp_affinity_list points to another, and whether irqbalance is running.
  4. Use lspci -vv to see whether the controller’s MSI is Maskable-.
  5. If it all matches, ban this interrupt from irqbalance, then reboot.

If the log shows SATA link down on every port at once, that’s another matter altogether: check the power and the cables.

References

  • x86/apic/msi: Plug non-maskable MSI affinity race (Linux commit 6f1a4891a592, 2020): when the affinity of a non-maskable MSI changes, the address and data aren’t written in one go, and an interrupt arriving in between goes to the wrong place. The stray No irq handler lines above are exactly this.
  • genirq/msi: Make sure PCI MSIs are activated early (Linux commit f3b0946d629c, 2016): the commit message says a device may latch the contents of its MSI registers at the moment MSI is enabled, and mentions that the change incidentally fixed a problem with VMware passthrough, which matches the ESXi behaviour seen here.
  • irqbalance: documentation for options such as --banirq.

Leave a comment

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.