Add support for kernel 5.11

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga
2021-05-21 00:04:53 +02:00
parent 2d7b94fa21
commit e5e0697da4
13 changed files with 333 additions and 117 deletions

View File

@@ -0,0 +1,74 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. $(dirname $3)/conf_framework
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "struct block_device *bd; bd->bd_partno;" "linux/blk_types.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "struct hd_struct *hd; hd->partno;" "linux/genhd.h"
then
echo $cur_name "2" >> $config_file_path
else
echo $cur_name "X" >> $config_file_path
fi
}
apply() {
case "$1" in
"1")
add_function "
static inline int cas_bd_get_next_part(struct block_device *bd)
{
int part_no = 0;
struct gendisk *disk = bd->bd_disk;
struct disk_part_iter piter;
struct block_device *part;
mutex_lock(&bd->bd_mutex);
disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY);
while ((part = disk_part_iter_next(&piter))) {
part_no = part->bd_partno;
break;
}
disk_part_iter_exit(&piter);
mutex_unlock(&bd->bd_mutex);
return part_no;
}" ;;
"2")
add_function "
static inline int cas_bd_get_next_part(struct block_device *bd)
{
int part_no = 0;
struct gendisk *disk = bd->bd_disk;
struct disk_part_iter piter;
struct hd_struct *part;
mutex_lock(&bd->bd_mutex);
disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY);
while ((part = disk_part_iter_next(&piter))) {
part_no = part->partno;
break;
}
disk_part_iter_exit(&piter);
mutex_unlock(&bd->bd_mutex);
return part_no;
}" ;;
*)
exit 1
esac
}
conf_run $@

View File

@@ -9,12 +9,15 @@
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "lookup_bdev(\"some_path\")" "linux/fs.h" "linux/blkdev.h"
if compile_module $cur_name "dev_t dev; lookup_bdev(\"some_path\", &dev)" "linux/blkdev.h"
then
echo $cur_name "1" >> $config_file_path
elif compile_module $cur_name "lookup_bdev(\"some_path\", 0)" "linux/fs.h" "linux/blkdev.h"
elif compile_module $cur_name "lookup_bdev(\"some_path\")" "linux/fs.h" "linux/blkdev.h"
then
echo $cur_name "2" >> $config_file_path
elif compile_module $cur_name "lookup_bdev(\"some_path\", 0)" "linux/fs.h" "linux/blkdev.h"
then
echo $cur_name "3" >> $config_file_path
else
echo $cur_name "X" >> $config_file_path
fi
@@ -23,11 +26,77 @@ check() {
apply() {
case "$1" in
"1")
add_define "CAS_LOOKUP_BDEV(PATH) \\
lookup_bdev(PATH)" ;;
add_function "
static inline bool cas_bdev_exist(const char *path)
{
dev_t dev;
int result;
result = lookup_bdev(path, &dev);
return !result;
}"
add_function "
static inline bool cas_bdev_match(const char *path, struct block_device *bd)
{
dev_t dev;
int result;
result = lookup_bdev(path, &dev);
if (result)
return false;
return (bd->bd_dev == dev);
}" ;;
"2")
add_define "CAS_LOOKUP_BDEV(PATH) \\
lookup_bdev(PATH, 0)" ;;
add_function "
static inline bool cas_bdev_exist(const char *path)
{
struct block_device *bdev;
bdev = lookup_bdev(path);
if (IS_ERR(bdev))
return false;
bdput(bdev);
return true;
}"
add_function "
static inline bool cas_bdev_match(const char *path, struct block_device *bd)
{
struct block_device *bdev;
bool match = false;
bdev = lookup_bdev(path);
if (IS_ERR(bdev))
return false;
match = (bdev == bd);
bdput(bdev);
return match;
}" ;;
"3")
add_function "
static inline bool cas_bdev_exist(const char *path)
{
struct block_device *bdev;
bdev = lookup_bdev(path, 0);
if (IS_ERR(bdev))
return false;
bdput(bdev);
return true;
}"
add_function "
static inline bool cas_bdev_match(const char *path, struct block_device *bd)
{
struct block_device *bdev;
bool match = false;
bdev = lookup_bdev(path, 0);
if (IS_ERR(bdev))
return false;
match = (bdev == bd);
bdput(bdev);
return match;
}" ;;
*)
exit 1
esac

View File

@@ -0,0 +1,37 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. $(dirname $3)/conf_framework
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "bdev_nr_sectors(NULL);" "linux/genhd.h"
then
echo $cur_name 1 >> $config_file_path
elif compile_module $cur_name "struct block_device *bd; bd->bd_part->nr_sects;" "linux/blk_types.h"
then
echo $cur_name 2 >> $config_file_path
else
echo $cur_name X >> $config_file_path
fi
}
apply() {
case "$1" in
"1")
add_define "cas_bdev_nr_sectors(bd) \\
bdev_nr_sectors(bd)" ;;
"2")
add_define "cas_bdev_nr_sectors(bd) \\
(bd->bd_part->nr_sects)" ;;
*)
exit 1
esac
}
conf_run $@

View File

@@ -0,0 +1,37 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. $(dirname $3)/conf_framework
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "struct block_device *bd; bdev_whole(bd);" "linux/blk_types.h" "linux/genhd.h"
then
echo $cur_name 1 >> $config_file_path
elif compile_module $cur_name "struct block_device *bd; bd->bd_contains;" "linux/blk_types.h"
then
echo $cur_name 2 >> $config_file_path
else
echo $cur_name X >> $config_file_path
fi
}
apply() {
case "$1" in
"1")
add_define "cas_bdev_whole(bd) \\
bdev_whole(bd)" ;;
"2")
add_define "cas_bdev_whole(bd) \\
(bd->bd_contains)" ;;
*)
exit 1
esac
}
conf_run $@

View File

@@ -0,0 +1,43 @@
#!/bin/bash
#
# Copyright(c) 2012-2021 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. $(dirname $3)/conf_framework
check() {
cur_name=$(basename $2)
config_file_path=$1
if compile_module $cur_name "bdget_disk(NULL, 0);" "linux/genhd.h"
then
echo $cur_name 1 >> $config_file_path
elif compile_module $cur_name "bdgrab(NULL);" "linux/blkdev.h"
then
echo $cur_name 2 >> $config_file_path
else
echo $cur_name X >> $config_file_path
fi
}
apply() {
case "$1" in
"1")
add_function "
static inline struct block_device *cas_bdget_disk(struct gendisk *gd)
{
return bdget_disk(gd, 0);
}" ;;
"2")
add_function "
static inline struct block_device *cas_bdget_disk(struct gendisk *gd)
{
return bdgrab(gd->part0);
}" ;;
*)
exit 1
esac
}
conf_run $@

View File

@@ -34,56 +34,62 @@ apply() {
"1")
add_function "
static inline unsigned long long cas_generic_start_io_acct(
struct request_queue *q, struct bio *bio,
struct hd_struct *part)
struct bio *bio)
{
return bio_start_io_acct(bio);
}"
add_function "
static inline void cas_generic_end_io_acct(struct request_queue *q,
struct bio *bio, struct hd_struct *part,
unsigned long start_time)
static inline void cas_generic_end_io_acct(
struct bio *bio, unsigned long start_time)
{
bio_end_io_acct(bio, start_time);
}" ;;
"2")
add_function "
static inline unsigned long long cas_generic_start_io_acct(
struct request_queue *q, struct bio *bio,
struct hd_struct *part)
struct bio *bio)
{
generic_start_io_acct(q, bio_data_dir(bio), bio_sectors(bio), part);
struct gendisk *gd = CAS_BIO_GET_DEV(bio);
generic_start_io_acct(gd->queue, bio_data_dir(bio),
bio_sectors(bio), &gd->part0);
return jiffies;
}"
add_function "
static inline void cas_generic_end_io_acct(struct request_queue *q,
struct bio *bio, struct hd_struct *part,
unsigned long start_time)
static inline void cas_generic_end_io_acct(
struct bio *bio, unsigned long start_time)
{
generic_end_io_acct(q, bio_data_dir(bio), part, start_time);
struct gendisk *gd = CAS_BIO_GET_DEV(bio);
generic_end_io_acct(gd->queue, bio_data_dir(bio),
&gd->part0, start_time);
}" ;;
"3")
add_function "
static inline unsigned long long cas_generic_start_io_acct(
struct request_queue *q, struct bio *bio,
struct hd_struct *part)
struct bio *bio)
{
generic_start_io_acct(bio_data_dir(bio), bio_sectors(bio), part);
struct gendisk *gd = CAS_BIO_GET_DEV(bio);
generic_start_io_acct(bio_data_dir(bio), bio_sectors(bio),
&gd->part0);
return jiffies;
}"
add_function "
static inline void cas_generic_end_io_acct(struct request_queue *q,
struct bio *bio, struct hd_struct *part,
unsigned long start_time)
static inline void cas_generic_end_io_acct(
struct bio *bio, unsigned long start_time)
{
generic_end_io_acct(bio_data_dir(bio), part, start_time);
struct gendisk *gd = CAS_BIO_GET_DEV(bio);
generic_end_io_acct(bio_data_dir(bio), &gd->part0, start_time);
}" ;;
"4")
add_function "
static inline unsigned long long cas_generic_start_io_acct(
struct request_queue *q, struct bio *bio,
struct hd_struct *part)
struct bio *bio)
{
struct gendisk *gd = CAS_BIO_GET_DEV(bio);
int rw = bio_data_dir(bio);
int cpu = part_stat_lock();
part_round_stats(cpu, part);
@@ -94,44 +100,47 @@ apply() {
return jiffies;
}"
add_function "
static inline void cas_generic_end_io_acct(struct request_queue *q,
struct bio *bio, struct hd_struct *part,
unsigned long start_time)
static inline void cas_generic_end_io_acct(
struct bio *bio, unsigned long start_time)
{
struct gendisk *gd = CAS_BIO_GET_DEV(bio);
int rw = bio_data_dir(bio);
unsigned long duration = jiffies - start_time;
int cpu = part_stat_lock();
part_stat_add(cpu, part, ticks[rw], duration);
part_round_stats(cpu, part);
part_dec_in_flight(part, rw);
part_stat_add(cpu, &gd->part0, ticks[rw], duration);
part_round_stats(cpu, &gd->part0);
part_dec_in_flight(&gd->part0, rw);
part_stat_unlock();
}" ;;
"5")
add_function "
static inline unsigned long long cas_generic_start_io_acct(
struct request_queue *q, struct bio *bio,
struct hd_struct *part)
struct bio *bio)
{
struct gendisk *gd = CAS_BIO_GET_DEV(bio);
int rw = bio_data_dir(bio);
int cpu = part_stat_lock();
part_round_stats(NULL, cpu, part);
part_stat_inc(cpu, part, ios[rw]);
part_stat_add(cpu, part, sectors[rw], bio_sectors(bio));
part_inc_in_flight(NULL, part, rw);
part_round_stats(NULL, cpu, &gd->part0);
part_stat_inc(cpu, &gd->part0, ios[rw]);
part_stat_add(cpu, &gd->part0, sectors[rw], bio_sectors(bio));
part_inc_in_flight(NULL, &gd->part0, rw);
part_stat_unlock();
return jiffies;
}"
add_function "
static inline void cas_generic_end_io_acct(struct request_queue *q,
struct bio *bio, struct hd_struct *part,
unsigned long start_time)
static inline void cas_generic_end_io_acct(
struct bio *bio, unsigned long start_time)
{
struct gendisk *gd = CAS_BIO_GET_DEV(bio);
int rw = bio_data_dir(bio);
unsigned long duration = jiffies - start_time;
int cpu = part_stat_lock();
part_stat_add(cpu, part, ticks[rw], duration);
part_round_stats(NULL, cpu, part);
part_dec_in_flight(NULL, part, rw);
part_stat_add(cpu, &gd->part0, ticks[rw], duration);
part_round_stats(NULL, cpu, &gd->part0);
part_dec_in_flight(NULL, &gd->part0, rw);
part_stat_unlock();
}" ;;
*)

View File

@@ -52,6 +52,7 @@ compile_module(){
return 0;
}
void cleanup_module(void) {};
MODULE_LICENSE("GPL");
EOF
#######################################