[Devel] [PATCH VZ9 v3 3/5] block/blk-cbt: introduce ABI versioning
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Tue Jan 28 11:15:07 MSK 2025
so it will be easier to change anything in the future
https://virtuozzo.atlassian.net/browse/VSTOR-96269
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
block/blk-cbt.c | 10 ++++++++++
include/uapi/linux/fs.h | 4 ++++
2 files changed, 14 insertions(+)
diff --git a/block/blk-cbt.c b/block/blk-cbt.c
index a12d16a1ed39..2543bf1e846c 100644
--- a/block/blk-cbt.c
+++ b/block/blk-cbt.c
@@ -1011,9 +1011,19 @@ static int cbt_ioc_misc(struct block_device *bdev, void __user *arg)
int blk_cbt_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg)
{
struct blk_user_cbt_info __user *ucbt_ioc;
+ __u32 abi_version;
ucbt_ioc = (struct blk_user_cbt_info __user *) arg;
+ if (copy_from_user(&abi_version, arg, sizeof(abi_version)))
+ return -EFAULT;
+
+ if (abi_version != CBT_ABI_VERSION) {
+ WARN_ONCE(1, "blk-cbt ABI mimatch: kernel has %d, userspace uses %d",
+ CBT_ABI_VERSION, abi_version);
+ return -EOPNOTSUPP;
+ }
+
if (cmd == BLKCBTGET)
return cbt_ioc_get(bdev, ucbt_ioc);
diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index 5d7014be0139..2aaee5257477 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -128,10 +128,13 @@ struct blk_user_cbt_extent {
__u64 ce_reserved64[1];
};
+
+#define CBT_ABI_VERSION 2
#define CBT_NAME_LENGTH 128
#define CBT_MAX_ENTRIES 16
struct blk_user_cbt_info {
+ __u32 version; /* ABI version */
__u8 ci_name[CBT_NAME_LENGTH]; /* CBT name */
__u64 ci_start; /* start phisical range of mapping which
userspace wants (in) */
@@ -153,6 +156,7 @@ enum CI_FLAGS
/* Extension of cbt ioctls: */
struct blk_user_cbt_misc_info {
+ __u32 version; /* ABI version */
__u8 name[CBT_NAME_LENGTH]; /* Bitmap name */
/* Allocate and move pending map to CBT snapshot */
#define CBT_SNAP_CREATE 0
--
2.39.3
More information about the Devel
mailing list