replace kernel obsolete api
This commit is contained in:
parent
1d559a7c5a
commit
8af451068a
131
0002-replace-kernel-obsolete-api.patch
Normal file
131
0002-replace-kernel-obsolete-api.patch
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
From 1af6a3f5a848237f5ea045499f33d29b6a8b8fd3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: wang--ge <wang__ge@126.com>
|
||||||
|
Date: Tue, 26 Mar 2024 15:06:39 +0800
|
||||||
|
Subject: [PATCH] init pakcage
|
||||||
|
|
||||||
|
---
|
||||||
|
vdo/io-factory.c | 55 +++++++++++++++++++++++++++++++-----------------
|
||||||
|
1 file changed, 36 insertions(+), 19 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/vdo/io-factory.c b/vdo/io-factory.c
|
||||||
|
index 1313da2..d0d189b 100644
|
||||||
|
--- a/vdo/io-factory.c
|
||||||
|
+++ b/vdo/io-factory.c
|
||||||
|
@@ -11,7 +11,7 @@
|
||||||
|
#include "logger.h"
|
||||||
|
#include "memory-alloc.h"
|
||||||
|
|
||||||
|
-enum { BLK_FMODE = FMODE_READ | FMODE_WRITE };
|
||||||
|
+enum { BLK_FMODE = BLK_OPEN_READ | BLK_OPEN_WRITE };
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A kernel mode IO Factory object controls access to an index stored
|
||||||
|
@@ -19,6 +19,7 @@ enum { BLK_FMODE = FMODE_READ | FMODE_WRITE };
|
||||||
|
*/
|
||||||
|
struct io_factory {
|
||||||
|
struct block_device *bdev;
|
||||||
|
+ struct bdev_handle *bdev_h;
|
||||||
|
atomic_t ref_count;
|
||||||
|
};
|
||||||
|
|
||||||
|
@@ -28,18 +29,30 @@ void get_uds_io_factory(struct io_factory *factory)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int get_block_device_from_name(const char *name,
|
||||||
|
- struct block_device **bdev)
|
||||||
|
+ struct bdev_handle **bdev_h)
|
||||||
|
{
|
||||||
|
- dev_t device = name_to_dev_t(name);
|
||||||
|
-
|
||||||
|
- if (device != 0) {
|
||||||
|
- *bdev = blkdev_get_by_dev(device, BLK_FMODE, NULL);
|
||||||
|
+ dev_t device;
|
||||||
|
+ unsigned int major, minor;
|
||||||
|
+ char dummy;
|
||||||
|
+ const struct blk_holder_ops hops = { NULL };
|
||||||
|
+
|
||||||
|
+ /* Extract the major/minor numbers */
|
||||||
|
+ if (sscanf(name, "%u:%u%c", &major, &minor, &dummy) == 2) {
|
||||||
|
+ device = MKDEV(major, minor);
|
||||||
|
+ if (MAJOR(device) != major || MINOR(device) != minor) {
|
||||||
|
+ *bdev_h = NULL;
|
||||||
|
+ return uds_log_error_strerror(UDS_INVALID_ARGUMENT,
|
||||||
|
+ "%s is not a valid block device",
|
||||||
|
+ name);
|
||||||
|
+ }
|
||||||
|
+ *bdev_h = bdev_open_by_dev(device, BLK_FMODE, NULL, &hops);
|
||||||
|
} else {
|
||||||
|
- *bdev = blkdev_get_by_path(name, BLK_FMODE, NULL);
|
||||||
|
+ *bdev_h = bdev_open_by_path(name, BLK_FMODE, NULL, &hops);
|
||||||
|
}
|
||||||
|
- if (IS_ERR(*bdev)) {
|
||||||
|
- uds_log_error_strerror(-PTR_ERR(*bdev),
|
||||||
|
- "%s is not a block device", name);
|
||||||
|
+
|
||||||
|
+ if (IS_ERR(*bdev_h)) {
|
||||||
|
+ uds_log_error_strerror(-PTR_ERR(*bdev_h), "%s is not a block device", name);
|
||||||
|
+ *bdev_h = NULL;
|
||||||
|
return UDS_INVALID_ARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -49,21 +62,22 @@ static int get_block_device_from_name(const char *name,
|
||||||
|
int make_uds_io_factory(const char *path, struct io_factory **factory_ptr)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
- struct block_device *bdev;
|
||||||
|
+ struct bdev_handle *bdev_h;
|
||||||
|
struct io_factory *factory;
|
||||||
|
|
||||||
|
- result = get_block_device_from_name(path, &bdev);
|
||||||
|
+ result = get_block_device_from_name(path, &bdev_h);
|
||||||
|
if (result != UDS_SUCCESS) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = UDS_ALLOCATE(1, struct io_factory, __func__, &factory);
|
||||||
|
if (result != UDS_SUCCESS) {
|
||||||
|
- blkdev_put(bdev, BLK_FMODE);
|
||||||
|
+ bdev_release(bdev_h);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
- factory->bdev = bdev;
|
||||||
|
+ factory->bdev_h = bdev_h;
|
||||||
|
+ factory->bdev = bdev_h->bdev;
|
||||||
|
atomic_set_release(&factory->ref_count, 1);
|
||||||
|
|
||||||
|
*factory_ptr = factory;
|
||||||
|
@@ -73,22 +87,25 @@ int make_uds_io_factory(const char *path, struct io_factory **factory_ptr)
|
||||||
|
int replace_uds_storage(struct io_factory *factory, const char *path)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
- struct block_device *bdev;
|
||||||
|
+ struct bdev_handle *bdev_h;
|
||||||
|
|
||||||
|
- result = get_block_device_from_name(path, &bdev);
|
||||||
|
+ result = get_block_device_from_name(path, &bdev_h);
|
||||||
|
if (result != UDS_SUCCESS) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
- blkdev_put(factory->bdev, BLK_FMODE);
|
||||||
|
- factory->bdev = bdev;
|
||||||
|
+ factory->bdev = NULL;
|
||||||
|
+ bdev_release(factory->bdev_h);
|
||||||
|
+ factory->bdev_h = bdev_h;
|
||||||
|
+ factory->bdev = bdev_h->bdev;
|
||||||
|
return UDS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void put_uds_io_factory(struct io_factory *factory)
|
||||||
|
{
|
||||||
|
if (atomic_add_return(-1, &factory->ref_count) <= 0) {
|
||||||
|
- blkdev_put(factory->bdev, BLK_FMODE);
|
||||||
|
+ factory->bdev=NULL;
|
||||||
|
+ bdev_release(factory->bdev_h);
|
||||||
|
UDS_FREE(factory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
#This spec is obtained from source code(kvdo-6.2.2.24.tar.gz)
|
#This spec is obtained from source code(kvdo-6.2.2.24.tar.gz)
|
||||||
%define spec_release 3
|
%define spec_release 4
|
||||||
%define kmod_name kmod-kvdo
|
%define kmod_name kmod-kvdo
|
||||||
%define kmod_driver_version 8.2.1.2
|
%define kmod_driver_version 8.2.1.2
|
||||||
%define kmod_rpm_release %{spec_release}
|
%define kmod_rpm_release %{spec_release}
|
||||||
@ -15,7 +15,8 @@ Summary: Kernel Modules for Virtual Data Optimizer
|
|||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
URL: http://github.com/dm-vdo/kvdo
|
URL: http://github.com/dm-vdo/kvdo
|
||||||
Source0: https://github.com/dm-vdo/kvdo/archive/refs/tags/%{kmod_driver_version}.tar.gz
|
Source0: https://github.com/dm-vdo/kvdo/archive/refs/tags/%{kmod_driver_version}.tar.gz
|
||||||
Patch1: 01-add-riscv64-support.patch
|
Patch1: 01-add-riscv64-support.patch
|
||||||
|
Patch2: 0002-replace-kernel-obsolete-api.patch
|
||||||
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
|
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
|
||||||
|
|
||||||
Requires: dkms
|
Requires: dkms
|
||||||
@ -78,6 +79,9 @@ rm -rf $RPM_BUILD_ROOT
|
|||||||
%{_usr}/src/%{kmod_name}-%{version}-%{kmod_rpm_release}/*
|
%{_usr}/src/%{kmod_name}-%{version}-%{kmod_rpm_release}/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Mar 26 2024 Ge Wang <wang__ge@126.com> - 8.2.1.2-4
|
||||||
|
- Replace kernel obsolete api
|
||||||
|
|
||||||
* Wed Apr 12 2023 laokz <zhangkai@iscas.ac.cn> - 8.2.1.2-3
|
* Wed Apr 12 2023 laokz <zhangkai@iscas.ac.cn> - 8.2.1.2-3
|
||||||
- Add riscv64 support
|
- Add riscv64 support
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user