* [PATCH pve-storage] btrfs: fix swapped filesystem ioctl constants
@ 2026-10-18 14:20 Alchemy Han
0 siblings, 0 replies; only message in thread
From: Alchemy Han @ 2026-10-18 14:20 UTC (permalink / raw)
To: pve-devel; +Cc: Alchemy Han
The FS_IOC_GETFLAGS and FS_IOC_SETFLAGS constants are swapped
in the Btrfs storage plugin.
Consequently, enabling the 'nocow' storage option does not set
the NOCOW attribute on newly allocated RAW disk images.
This can be reproduced by configuring 'nocow 1' on a Btrfs
storage and allocating a new RAW image using 'pvesm alloc'.
The resulting disk.raw does not have the NOCOW attribute.
On x86-64 Linux, the correct ioctl constants are:
FS_IOC_GETFLAGS = 0x80086601
FS_IOC_SETFLAGS = 0x40086602
The original constants were tested using Perl ioctl calls.
Reading the flags after attempting to set FS_NOCOW_FL returned
0x00000000.
With the corrected constants, the same test successfully
returned 0x00800000.
Fix the constants to make the NOCOW storage option work as
intended.
Signed-off-by: Alchemy Han <alchemylinux@gmail.com>
---
src/PVE/Storage/BTRFSPlugin.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/PVE/Storage/BTRFSPlugin.pm b/src/PVE/Storage/BTRFSPlugin.pm
index fa28592..37dd3a6 100644
--- a/src/PVE/Storage/BTRFSPlugin.pm
+++ b/src/PVE/Storage/BTRFSPlugin.pm
@@ -18,8 +18,8 @@ use PVE::Storage::DirPlugin;
use constant {
BTRFS_FIRST_FREE_OBJECTID => 256,
FS_NOCOW_FL => 0x00800000,
- FS_IOC_GETFLAGS => 0x40086602,
- FS_IOC_SETFLAGS => 0x80086601,
+ FS_IOC_GETFLAGS => 0x80086601,
+ FS_IOC_SETFLAGS => 0x40086602,
BTRFS_MAGIC => 0x9123683e,
};
--
2.56.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-18 14:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-18 14:20 [PATCH pve-storage] btrfs: fix swapped filesystem ioctl constants Alchemy Han
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox