Environment
RAID Model: All SupremeRAID SR-series cards.
Driver: SupremeRAID Linux driver 1.7.x and 2.x. The graid module parameter force_copy_buffer is available in driver 1.7.2 Update 92 and subsequent releases. These releases include the v1 and v2 series.
Operating System: Linux with kernel 7.0 or a subsequent release.
File System: XFS on a SupremeRAID virtual drive (VD). ext4 and raw block devices do not have this problem.
Summary
Read performance decreases when you use XFS on a SupremeRAID virtual drive with stable_writes set to 1. Write performance stays near the value for the same workload without this problem. The Linux block-layer flag stable_writes causes this problem. In the default configuration, SupremeRAID sets this flag to 1 on each virtual drive.
When stable_writes is 1, the XFS read path in the kernel copies the data through a bounce buffer. This copy decreases read performance.
The Linux kernel and XFS cause this problem. It is not a defect in SupremeRAID. The same slow reads occur on one NVMe drive when you set stable_writes to 1 on that drive.
Solution: Set stable_writes to 0 on the virtual drive. Then mount the file system again. For the same data-consistency protection as the default configuration, also set the graid module parameter force_copy_buffer to Y.
This parameter is available in driver 1.7.2 Update 92 and subsequent releases. With this parameter set to Y, the driver makes a copy of each write buffer. The kernel protection is then not necessary. XFS sequential read performance increases to values near those for the raw virtual drive.
Symptoms
- A fio sequential read test on the XFS mount gives a low result. For example, an 8-drive RAID 6 gives 2.4 to 7.8 GB/s on XFS. The raw VD gives 65 to 70 GB/s.
- Sequential and random write results stay near the values for the same workloads without this problem. If write performance also decreases, read performance decreases more.
- A fio test directly on
/dev/gdgXnY(no file system) does not show this problem. - The same fio job on an ext4 file system on the same VD does not show this problem.
- The command
cat /sys/block/gdgXnY/queue/stable_writesshows 1. - Read performance increases after you set
stable_writesto 0 and mount the file system again. A reboot is not necessary.
Background: What stable_writes Does
/sys/block/<device>/queue/stable_writes is a standard Linux block-layer flag. When the value is 1, the application cannot change a memory page while the device writes that page. The application must wait until the write is completed.
This protection is necessary for devices that read the data buffer more than one time. Examples include devices that calculate checksums, T10 data integrity values, or RAID parity. Linux md RAID 5/6 sets the same flag to prevent changes to the data buffer during a write.
SupremeRAID calculates RAID 5 and RAID 6 parity on the GPU from the data buffer that the kernel sends. The application can change the buffer after the driver calculates the parity but before it writes the data. If this occurs, the parity does not agree with the data.
In the default configuration, the SupremeRAID driver sets stable_writes to 1 on each virtual drive to prevent this condition.
Root Cause
When stable_writes is 1 on the block device, the XFS read path copies the data through a bounce buffer. The kernel does not put the data directly into the application pages or the page cache. The CPU does this copy. The copy decreases read performance. ext4 does not use this path and does not have this problem.
Graid did the same test on one NVMe drive without SupremeRAID. With stable_writes set to 1, XFS gives approximately half of the read throughput in the vendor specification. The test also shows that the XFS read path uses a bounce buffer.
These results show that the Linux kernel and XFS cause the problem. SupremeRAID has this problem because the driver sets the flag to 1 in the default configuration.
Lab Measurements
Test system: Ubuntu 26.04, kernel 7.0.0-38-generic, 8 KIOXIA PCIe Gen5 NVMe drives, RAID 6. Sequential read: fio, 64 jobs, queue depth 16. In the table, "sw" is stable_writes and "fcb" is force_copy_buffer.
| Configuration | Sequential Read | Bounce buffer |
|---|---|---|
| RAID 6 + XFS, sw=1 (default) | 2.40 GB/s | yes |
| RAID 6 + XFS, sw=0 | 67.90 GB/s | no |
| RAID 6 + XFS, sw=0, fcb=N | 62.51 GB/s | no |
| RAID 6 + XFS, sw=0, fcb=Y | 65.58 GB/s | no |
| RAID 6 raw VD (no file system) | 69.41 GB/s | no |
| RAID 6 + ext4, sw=1 | 46.72 GB/s | no |
| RAID 6 + ext4, sw=0 | 48.29 GB/s | no |
| One NVMe + XFS, sw=1 | 5.48 GB/s | yes |
| One NVMe + XFS, sw=0 | 12.41 GB/s | no |
| One NVMe raw | 12.41 GB/s | no |
| One NVMe vendor specification | 12.0 GB/s | |
| RAID 6 theoretical maximum (8 drives) | 96 GB/s |
Results:
- With
stable_writesset to 0, XFS sequential read throughput increases from 2.40 GB/s to 67.90 GB/s. Withforce_copy_bufferalso set to Y, the result is 65.58 GB/s. These results are near the raw VD result of 69.41 GB/s. - In the measurements, read performance does not decrease with
force_copy_bufferset to Y. The difference between 62.51 and 65.58 GB/s is usual test variation.
Procedure
Step 1: Show the value of stable_writes
cat /sys/block/gdgXnY/queue/stable_writes
gdgXnY is the device name of your virtual drive. X is the drive group number and Y is the virtual drive number. The command graidctl list vd shows the device path. If you have more than one virtual drive, do this procedure for each virtual drive. A value of 1 means that the flag is set.
Example for virtual drive 1 in drive group 0:
cat /sys/block/gdg0n1/queue/stable_writes
1
Step 2: Set stable_writes to 0 on the virtual drive
Set the value to 0:
echo 0 > /sys/block/gdgXnY/queue/stable_writesExample:
echo 0 > /sys/block/gdg0n1/queue/stable_writesUnmount the XFS file system.
umount /mnt/graidMount the XFS file system again. The file system reads the flag only when you mount it. A reboot or a driver reload is not necessary.
mount /mnt/graidDo the fio sequential read test again with the same job parameters.
Compare the result with the result before the change.
To keep
stable_writesat 0 after a reboot or a driver reload, add this udev rule:cat > /etc/udev/rules.d/99-graid-stable-writes.rules <<'RULE'
ACTION=="add|change", KERNEL=="gdg*n*", ATTR{queue/stable_writes}="0"
RULE
udevadm control --reload-rulesudev uses this rule for the
addandchangeevents of a virtual drive. At boot, udev setsstable_writesto 0 before the system mounts the file system.
Step 3: Set force_copy_buffer to Y
For virtual machines and LVM thin provisioning, Graid recommends this step. Graid also recommends it for applications that change a buffer during a write.
Driver 1.7.2 Update 92 and subsequent releases have the graid module parameter force_copy_buffer. These releases include the v1 and v2 series. When this parameter is Y, the driver copies each write buffer into memory for the driver. The driver then calculates the parity and writes the data from that copy.
The driver uses the same buffer copy for the parity and the data. Changes to application memory after the driver copies the write buffer have no effect on that copy. This parameter gives the same protection as stable_writes set to 1. It does not use the kernel page-cache path that makes XFS reads slow.
Note: With force_copy_buffer set to Y, the driver copies each write buffer one time in host memory. This copy uses host memory bandwidth in proportion to the write throughput of the array. Read performance does not decrease in the measurements in Lab Measurements.
The memory bandwidth of the server has an effect on write performance. On servers with many DDR4 or DDR5 memory channels, memory bandwidth is much higher than array write throughput. On these servers, the effect is small. Write throughput can decrease on servers with a small number of memory channels. It can also decrease if other applications use a large part of the memory bandwidth.
More memory bandwidth is necessary to make a stable copy of the write data. Linux md RAID 5/6 also copies write data into its stripe cache to prevent changes during a write.
Make sure that your driver has the parameter:
cat /sys/module/graid/parameters/force_copy_bufferIf there is no file at this path, make sure that the installed driver has the parameter. The parameter is available in driver 1.7.2 Update 92 and subsequent releases in the v1 and v2 series. If necessary, install a release that has this parameter.
Release notes: https://docs.graidtech.com/sr/release-notes/linux/1.7/1.7.2-92/
Set the parameter to Y. You can change this parameter at run time. The driver uses Y immediately. A remount or a driver reload is not necessary.
echo Y > /sys/module/graid/parameters/force_copy_bufferTo keep
force_copy_bufferset to Y after a driver reload, add the parameter to the module configuration:echo "options graid force_copy_buffer=Y" > /etc/modprobe.d/graid.conf
Step 4: Make sure that the flag and parameter values are correct
cat /sys/block/gdgXnY/queue/stable_writes # value: 0
cat /sys/module/graid/parameters/force_copy_buffer # value: Y (if you set it)
Do the first command for each virtual drive.
Then do the fio sequential read test on the mounted XFS file system again. Use the same fio job parameters for all tests. Compare the result with the result before the change and the raw VD result.
The lab measurements show XFS sequential read throughput near the raw VD result. These measurements do not give a pass/fail limit for other systems.
Optional: Measure the effect on write performance
- Set
force_copy_bufferto N. - Do a fio write test.
- Record the result.
- Set
force_copy_bufferto Y. - Do the same fio write test again.
- Compare the results.
- Keep
force_copy_bufferset to Y for the recommended configuration.
Why the Recommended Configuration Is Safe
The combination of stable_writes set to 0 and force_copy_buffer set to Y prevents this XFS read-performance problem. It also gives the same data-consistency protection as the default configuration.
With force_copy_buffer set to Y, the driver makes a copy of each write buffer in memory for the driver before it calculates the parity. The driver uses the same buffer copy for the parity and the data that it writes to the drives. Changes to application memory after the driver copies the write buffer have no effect on that copy. The kernel protection is then not necessary. You can set stable_writes to 0 with no loss of consistency.
stable_writes set to 0 with force_copy_buffer set to N is safe for most workloads. A write buffer is at risk only if the application changes the buffer while the write is in progress. Correct applications and file systems do not do this. This condition usually occurs with these workloads:
- Virtual machines (KVM / QEMU / Proxmox VE). The system writes the guest memory directly to the array.
- LVM thin provisioning on the virtual drive.
- Applications that use an O_DIRECT buffer again before the write is completed.
With these workloads, a buffer change during the write can cause incorrect parity for that stripe. This condition applies only when stable_writes is 0 and force_copy_buffer is N. When the drive group is in the OPTIMAL state, the system reads data from the data drives. These reads are correct. The SupremeRAID consistency check shows the incorrect parity.
The incorrect parity is a problem only if the system must rebuild that stripe from parity after a drive failure. With force_copy_buffer set to Y, changes to the application buffer cannot cause this parity error. Thus Graid recommends stable_writes set to 0 and force_copy_buffer set to Y for virtualization and LVM thin provisioning.
Frequently Asked Questions
Why does SupremeRAID set stable_writes to 1 in the default configuration?
This value gives correct parity on each Linux kernel and each workload. These workloads include virtual machines and LVM thin provisioning. The graid module parameter force_copy_buffer gives the same protection in the driver. This parameter is available in driver 1.7.2 Update 92 and subsequent releases.
stable_writes gives protection for write data. It tells the kernel to prevent changes to a page while the device writes that page. This protection has no function for reads.
The XFS read path uses a bounce buffer when the flag is 1. This copy decreases read performance. ext4 does not use this read path. Graid thinks that a subsequent XFS or kernel change will prevent this problem.
Until then, use the procedure in this document.
Does this problem occur on ext4? No. ext4 does not have this XFS read-performance problem. In the lab measurements, ext4 sequential read throughput is 46.72 GB/s with stable_writes set to 1. The result is 48.29 GB/s with the flag set to 0.
Does this problem occur on writes? No. stable_writes does not decrease write performance. With force_copy_buffer set to Y, the driver copies each write buffer in host memory. The memory bandwidth of the server then has an effect on write performance. On servers with many memory channels, the difference is small. Refer to Step 3 for the effect on write performance.
Is there an XFS mount option that prevents this problem? No. The stable_writes flag is a property of the block device, not of the file system. XFS reads the flag only when you mount the file system. Thus you must mount the file system again after you change the flag.
Related Documents
- SupremeRAID Linux Driver 1.7.2 Update 92 Release Notes: https://docs.graidtech.com/sr/release-notes/linux/1.7/1.7.2-92/
- Linux kernel documentation,
/sys/block/<disk>/queue/stable_writes: https://www.kernel.org/doc/html/latest/ABI/stable/sysfs-block.html