Add support for kernel 5.11
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
parent
2d7b94fa21
commit
e5e0697da4
74
configure.d/1_bd_first_part.conf
Normal file
74
configure.d/1_bd_first_part.conf
Normal 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 $@
|
@ -9,12 +9,15 @@
|
|||||||
check() {
|
check() {
|
||||||
cur_name=$(basename $2)
|
cur_name=$(basename $2)
|
||||||
config_file_path=$1
|
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
|
then
|
||||||
echo $cur_name "1" >> $config_file_path
|
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
|
then
|
||||||
echo $cur_name "2" >> $config_file_path
|
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
|
else
|
||||||
echo $cur_name "X" >> $config_file_path
|
echo $cur_name "X" >> $config_file_path
|
||||||
fi
|
fi
|
||||||
@ -23,11 +26,77 @@ check() {
|
|||||||
apply() {
|
apply() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"1")
|
"1")
|
||||||
add_define "CAS_LOOKUP_BDEV(PATH) \\
|
add_function "
|
||||||
lookup_bdev(PATH)" ;;
|
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")
|
"2")
|
||||||
add_define "CAS_LOOKUP_BDEV(PATH) \\
|
add_function "
|
||||||
lookup_bdev(PATH, 0)" ;;
|
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
|
exit 1
|
||||||
esac
|
esac
|
||||||
|
37
configure.d/1_bdev_nr_sectors.conf
Normal file
37
configure.d/1_bdev_nr_sectors.conf
Normal 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 $@
|
37
configure.d/1_bdev_whole.conf
Normal file
37
configure.d/1_bdev_whole.conf
Normal 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 $@
|
43
configure.d/1_bdget_disk.conf
Normal file
43
configure.d/1_bdget_disk.conf
Normal 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 $@
|
@ -34,56 +34,62 @@ apply() {
|
|||||||
"1")
|
"1")
|
||||||
add_function "
|
add_function "
|
||||||
static inline unsigned long long cas_generic_start_io_acct(
|
static inline unsigned long long cas_generic_start_io_acct(
|
||||||
struct request_queue *q, struct bio *bio,
|
struct bio *bio)
|
||||||
struct hd_struct *part)
|
|
||||||
{
|
{
|
||||||
return bio_start_io_acct(bio);
|
return bio_start_io_acct(bio);
|
||||||
}"
|
}"
|
||||||
add_function "
|
add_function "
|
||||||
static inline void cas_generic_end_io_acct(struct request_queue *q,
|
static inline void cas_generic_end_io_acct(
|
||||||
struct bio *bio, struct hd_struct *part,
|
struct bio *bio, unsigned long start_time)
|
||||||
unsigned long start_time)
|
|
||||||
{
|
{
|
||||||
bio_end_io_acct(bio, start_time);
|
bio_end_io_acct(bio, start_time);
|
||||||
}" ;;
|
}" ;;
|
||||||
"2")
|
"2")
|
||||||
add_function "
|
add_function "
|
||||||
static inline unsigned long long cas_generic_start_io_acct(
|
static inline unsigned long long cas_generic_start_io_acct(
|
||||||
struct request_queue *q, struct bio *bio,
|
struct bio *bio)
|
||||||
struct hd_struct *part)
|
|
||||||
{
|
{
|
||||||
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;
|
return jiffies;
|
||||||
}"
|
}"
|
||||||
add_function "
|
add_function "
|
||||||
static inline void cas_generic_end_io_acct(struct request_queue *q,
|
static inline void cas_generic_end_io_acct(
|
||||||
struct bio *bio, struct hd_struct *part,
|
struct bio *bio, unsigned long start_time)
|
||||||
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")
|
"3")
|
||||||
add_function "
|
add_function "
|
||||||
static inline unsigned long long cas_generic_start_io_acct(
|
static inline unsigned long long cas_generic_start_io_acct(
|
||||||
struct request_queue *q, struct bio *bio,
|
struct bio *bio)
|
||||||
struct hd_struct *part)
|
|
||||||
{
|
{
|
||||||
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;
|
return jiffies;
|
||||||
}"
|
}"
|
||||||
add_function "
|
add_function "
|
||||||
static inline void cas_generic_end_io_acct(struct request_queue *q,
|
static inline void cas_generic_end_io_acct(
|
||||||
struct bio *bio, struct hd_struct *part,
|
struct bio *bio, unsigned long start_time)
|
||||||
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")
|
"4")
|
||||||
add_function "
|
add_function "
|
||||||
static inline unsigned long long cas_generic_start_io_acct(
|
static inline unsigned long long cas_generic_start_io_acct(
|
||||||
struct request_queue *q, struct bio *bio,
|
struct bio *bio)
|
||||||
struct hd_struct *part)
|
|
||||||
{
|
{
|
||||||
|
struct gendisk *gd = CAS_BIO_GET_DEV(bio);
|
||||||
|
|
||||||
int rw = bio_data_dir(bio);
|
int rw = bio_data_dir(bio);
|
||||||
int cpu = part_stat_lock();
|
int cpu = part_stat_lock();
|
||||||
part_round_stats(cpu, part);
|
part_round_stats(cpu, part);
|
||||||
@ -94,44 +100,47 @@ apply() {
|
|||||||
return jiffies;
|
return jiffies;
|
||||||
}"
|
}"
|
||||||
add_function "
|
add_function "
|
||||||
static inline void cas_generic_end_io_acct(struct request_queue *q,
|
static inline void cas_generic_end_io_acct(
|
||||||
struct bio *bio, struct hd_struct *part,
|
struct bio *bio, unsigned long start_time)
|
||||||
unsigned long start_time)
|
|
||||||
{
|
{
|
||||||
|
struct gendisk *gd = CAS_BIO_GET_DEV(bio);
|
||||||
|
|
||||||
int rw = bio_data_dir(bio);
|
int rw = bio_data_dir(bio);
|
||||||
unsigned long duration = jiffies - start_time;
|
unsigned long duration = jiffies - start_time;
|
||||||
int cpu = part_stat_lock();
|
int cpu = part_stat_lock();
|
||||||
part_stat_add(cpu, part, ticks[rw], duration);
|
part_stat_add(cpu, &gd->part0, ticks[rw], duration);
|
||||||
part_round_stats(cpu, part);
|
part_round_stats(cpu, &gd->part0);
|
||||||
part_dec_in_flight(part, rw);
|
part_dec_in_flight(&gd->part0, rw);
|
||||||
part_stat_unlock();
|
part_stat_unlock();
|
||||||
}" ;;
|
}" ;;
|
||||||
"5")
|
"5")
|
||||||
add_function "
|
add_function "
|
||||||
static inline unsigned long long cas_generic_start_io_acct(
|
static inline unsigned long long cas_generic_start_io_acct(
|
||||||
struct request_queue *q, struct bio *bio,
|
struct bio *bio)
|
||||||
struct hd_struct *part)
|
|
||||||
{
|
{
|
||||||
|
struct gendisk *gd = CAS_BIO_GET_DEV(bio);
|
||||||
|
|
||||||
int rw = bio_data_dir(bio);
|
int rw = bio_data_dir(bio);
|
||||||
int cpu = part_stat_lock();
|
int cpu = part_stat_lock();
|
||||||
part_round_stats(NULL, cpu, part);
|
part_round_stats(NULL, cpu, &gd->part0);
|
||||||
part_stat_inc(cpu, part, ios[rw]);
|
part_stat_inc(cpu, &gd->part0, ios[rw]);
|
||||||
part_stat_add(cpu, part, sectors[rw], bio_sectors(bio));
|
part_stat_add(cpu, &gd->part0, sectors[rw], bio_sectors(bio));
|
||||||
part_inc_in_flight(NULL, part, rw);
|
part_inc_in_flight(NULL, &gd->part0, rw);
|
||||||
part_stat_unlock();
|
part_stat_unlock();
|
||||||
return jiffies;
|
return jiffies;
|
||||||
}"
|
}"
|
||||||
add_function "
|
add_function "
|
||||||
static inline void cas_generic_end_io_acct(struct request_queue *q,
|
static inline void cas_generic_end_io_acct(
|
||||||
struct bio *bio, struct hd_struct *part,
|
struct bio *bio, unsigned long start_time)
|
||||||
unsigned long start_time)
|
|
||||||
{
|
{
|
||||||
|
struct gendisk *gd = CAS_BIO_GET_DEV(bio);
|
||||||
|
|
||||||
int rw = bio_data_dir(bio);
|
int rw = bio_data_dir(bio);
|
||||||
unsigned long duration = jiffies - start_time;
|
unsigned long duration = jiffies - start_time;
|
||||||
int cpu = part_stat_lock();
|
int cpu = part_stat_lock();
|
||||||
part_stat_add(cpu, part, ticks[rw], duration);
|
part_stat_add(cpu, &gd->part0, ticks[rw], duration);
|
||||||
part_round_stats(NULL, cpu, part);
|
part_round_stats(NULL, cpu, &gd->part0);
|
||||||
part_dec_in_flight(NULL, part, rw);
|
part_dec_in_flight(NULL, &gd->part0, rw);
|
||||||
part_stat_unlock();
|
part_stat_unlock();
|
||||||
}" ;;
|
}" ;;
|
||||||
*)
|
*)
|
@ -52,6 +52,7 @@ compile_module(){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
void cleanup_module(void) {};
|
void cleanup_module(void) {};
|
||||||
|
MODULE_LICENSE("GPL");
|
||||||
EOF
|
EOF
|
||||||
#######################################
|
#######################################
|
||||||
|
|
||||||
|
@ -1068,7 +1068,6 @@ out_bdev:
|
|||||||
int cache_mngt_prepare_core_cfg(struct ocf_mngt_core_config *cfg,
|
int cache_mngt_prepare_core_cfg(struct ocf_mngt_core_config *cfg,
|
||||||
struct kcas_insert_core *cmd_info)
|
struct kcas_insert_core *cmd_info)
|
||||||
{
|
{
|
||||||
struct block_device *bdev;
|
|
||||||
char core_name[OCF_CORE_NAME_SIZE] = {};
|
char core_name[OCF_CORE_NAME_SIZE] = {};
|
||||||
ocf_cache_t cache;
|
ocf_cache_t cache;
|
||||||
uint16_t core_id;
|
uint16_t core_id;
|
||||||
@ -1109,10 +1108,8 @@ int cache_mngt_prepare_core_cfg(struct ocf_mngt_core_config *cfg,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bdev = CAS_LOOKUP_BDEV(cfg->uuid.data);
|
if (!cas_bdev_exist(cfg->uuid.data))
|
||||||
if (IS_ERR(bdev))
|
|
||||||
return -OCF_ERR_INVAL_VOLUME_TYPE;
|
return -OCF_ERR_INVAL_VOLUME_TYPE;
|
||||||
bdput(bdev);
|
|
||||||
|
|
||||||
if (cmd_info->update_path)
|
if (cmd_info->update_path)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1135,9 +1132,7 @@ static int cache_mngt_update_core_uuid(ocf_cache_t cache, const char *core_name,
|
|||||||
{
|
{
|
||||||
ocf_core_t core;
|
ocf_core_t core;
|
||||||
ocf_volume_t vol;
|
ocf_volume_t vol;
|
||||||
struct block_device *bdev;
|
|
||||||
struct bd_object *bdvol;
|
struct bd_object *bdvol;
|
||||||
bool match;
|
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
if (ocf_core_get_by_name(cache, core_name, name_len, &core)) {
|
if (ocf_core_get_by_name(cache, core_name, name_len, &core)) {
|
||||||
@ -1154,19 +1149,7 @@ static int cache_mngt_update_core_uuid(ocf_cache_t cache, const char *core_name,
|
|||||||
vol = ocf_core_get_volume(core);
|
vol = ocf_core_get_volume(core);
|
||||||
bdvol = bd_object(vol);
|
bdvol = bd_object(vol);
|
||||||
|
|
||||||
/* lookup block device object for device pointed by uuid */
|
if (!cas_bdev_match(uuid->data, bdvol->btm_bd)) {
|
||||||
bdev = CAS_LOOKUP_BDEV(uuid->data);
|
|
||||||
if (IS_ERR(bdev)) {
|
|
||||||
printk(KERN_ERR "failed to lookup bdev%s\n", (char*)uuid->data);
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check whether both core id and uuid point to the same block device */
|
|
||||||
match = (bdvol->btm_bd == bdev);
|
|
||||||
|
|
||||||
bdput(bdev);
|
|
||||||
|
|
||||||
if (!match) {
|
|
||||||
printk(KERN_ERR "UUID provided does not match target core device\n");
|
printk(KERN_ERR "UUID provided does not match target core device\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
@ -1766,7 +1749,7 @@ int cache_mngt_prepare_cache_cfg(struct ocf_mngt_cache_config *cfg,
|
|||||||
-OCF_ERR_INVAL_VOLUME_TYPE;
|
-OCF_ERR_INVAL_VOLUME_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
is_part = (bdev->bd_contains != bdev);
|
is_part = (cas_bdev_whole(bdev) != bdev);
|
||||||
part_count = cas_blk_get_part_count(bdev);
|
part_count = cas_blk_get_part_count(bdev);
|
||||||
blkdev_put(bdev, (FMODE_EXCL|FMODE_READ));
|
blkdev_put(bdev, (FMODE_EXCL|FMODE_READ));
|
||||||
|
|
||||||
@ -1872,7 +1855,7 @@ static void init_instance_complete(struct _cache_mngt_attach_context *ctx,
|
|||||||
bdev = bd_cache_obj->btm_bd;
|
bdev = bd_cache_obj->btm_bd;
|
||||||
|
|
||||||
/* If we deal with whole device, reread partitions */
|
/* If we deal with whole device, reread partitions */
|
||||||
if (bdev->bd_contains == bdev)
|
if (cas_bdev_whole(bdev) == bdev)
|
||||||
cas_reread_partitions(bdev);
|
cas_reread_partitions(bdev);
|
||||||
|
|
||||||
/* Set other back information */
|
/* Set other back information */
|
||||||
|
@ -303,7 +303,7 @@ int cas_blk_identify_type_by_bdev(struct block_device *bdev,
|
|||||||
atomic_params_int.is_mode_optimal = 1;
|
atomic_params_int.is_mode_optimal = 1;
|
||||||
break;
|
break;
|
||||||
#else
|
#else
|
||||||
if (bdev == bdev->bd_contains) {
|
if (bdev == cas_bdev_whole(bdev)) {
|
||||||
/*
|
/*
|
||||||
* Entire device - format isn't optimal
|
* Entire device - format isn't optimal
|
||||||
*/
|
*/
|
||||||
|
@ -84,9 +84,9 @@ uint64_t block_dev_get_byte_length(ocf_volume_t vol)
|
|||||||
struct block_device *bd = bdobj->btm_bd;
|
struct block_device *bd = bdobj->btm_bd;
|
||||||
uint64_t sector_length;
|
uint64_t sector_length;
|
||||||
|
|
||||||
sector_length = (bd->bd_contains == bd) ?
|
sector_length = (cas_bdev_whole(bd) == bd) ?
|
||||||
get_capacity(bd->bd_disk) :
|
get_capacity(bd->bd_disk) :
|
||||||
bd->bd_part->nr_sects;
|
cas_bdev_nr_sectors(bd);
|
||||||
|
|
||||||
return sector_length << SECTOR_SHIFT;
|
return sector_length << SECTOR_SHIFT;
|
||||||
}
|
}
|
||||||
|
@ -30,21 +30,6 @@ static void _blockdev_set_bio_data(struct blk_data *data, struct bio *bio)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned long long _blockdev_start_io_acct(struct bio *bio)
|
|
||||||
{
|
|
||||||
struct gendisk *gd = CAS_BIO_GET_DEV(bio);
|
|
||||||
|
|
||||||
return cas_generic_start_io_acct(gd->queue, bio, &gd->part0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void _blockdev_end_io_acct(struct bio *bio,
|
|
||||||
unsigned long start_time)
|
|
||||||
{
|
|
||||||
struct gendisk *gd = CAS_BIO_GET_DEV(bio);
|
|
||||||
|
|
||||||
cas_generic_end_io_acct(gd->queue, bio, &gd->part0, start_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int _blkdev_can_hndl_bio(struct bio *bio)
|
static inline int _blkdev_can_hndl_bio(struct bio *bio)
|
||||||
{
|
{
|
||||||
if (CAS_CHECK_BARRIER(bio)) {
|
if (CAS_CHECK_BARRIER(bio)) {
|
||||||
@ -140,7 +125,7 @@ static int _blockdev_set_geometry(struct casdsk_disk *dsk, void *private)
|
|||||||
cache_bd = casdisk_functions.casdsk_disk_get_blkdev(bd_cache_vol->dsk);
|
cache_bd = casdisk_functions.casdsk_disk_get_blkdev(bd_cache_vol->dsk);
|
||||||
BUG_ON(!cache_bd);
|
BUG_ON(!cache_bd);
|
||||||
|
|
||||||
core_q = core_bd->bd_contains->bd_disk->queue;
|
core_q = cas_bdev_whole(core_bd)->bd_disk->queue;
|
||||||
cache_q = cache_bd->bd_disk->queue;
|
cache_q = cache_bd->bd_disk->queue;
|
||||||
exp_q = casdisk_functions.casdsk_exp_obj_get_queue(dsk);
|
exp_q = casdisk_functions.casdsk_exp_obj_get_queue(dsk);
|
||||||
|
|
||||||
@ -215,7 +200,7 @@ static void block_dev_complete_data(struct ocf_io *io, int error)
|
|||||||
struct blk_data *data = ocf_io_get_data(io);
|
struct blk_data *data = ocf_io_get_data(io);
|
||||||
struct bio *bio = data->master_io_req;
|
struct bio *bio = data->master_io_req;
|
||||||
|
|
||||||
_blockdev_end_io_acct(bio, data->start_time);
|
cas_generic_end_io_acct(bio, data->start_time);
|
||||||
|
|
||||||
CAS_BIO_ENDIO(bio, CAS_BIO_BISIZE(bio), CAS_ERRNO_TO_BLK_STS(error));
|
CAS_BIO_ENDIO(bio, CAS_BIO_BISIZE(bio), CAS_ERRNO_TO_BLK_STS(error));
|
||||||
ocf_io_put(io);
|
ocf_io_put(io);
|
||||||
@ -275,7 +260,7 @@ static void _blockdev_handle_data(ocf_core_t core, struct bio *bio)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ocf_io_set_cmpl(io, NULL, NULL, block_dev_complete_data);
|
ocf_io_set_cmpl(io, NULL, NULL, block_dev_complete_data);
|
||||||
data->start_time = _blockdev_start_io_acct(bio);
|
data->start_time = cas_generic_start_io_acct(bio);
|
||||||
|
|
||||||
ocf_core_submit_io(io);
|
ocf_core_submit_io(io);
|
||||||
}
|
}
|
||||||
@ -296,7 +281,8 @@ static void _blockdev_handle_discard(ocf_core_t core, struct bio *bio)
|
|||||||
|
|
||||||
io = ocf_core_new_io(core, cache_priv->io_queues[smp_processor_id()],
|
io = ocf_core_new_io(core, cache_priv->io_queues[smp_processor_id()],
|
||||||
CAS_BIO_BISECTOR(bio) << SECTOR_SHIFT,
|
CAS_BIO_BISECTOR(bio) << SECTOR_SHIFT,
|
||||||
CAS_BIO_BISIZE(bio), OCF_WRITE, 0, 0);
|
CAS_BIO_BISIZE(bio), OCF_WRITE, 0,
|
||||||
|
CAS_CLEAR_FLUSH(CAS_BIO_OP_FLAGS(bio)));
|
||||||
|
|
||||||
if (!io) {
|
if (!io) {
|
||||||
CAS_PRINT_RL(KERN_CRIT
|
CAS_PRINT_RL(KERN_CRIT
|
||||||
|
@ -281,9 +281,7 @@ struct request_queue *casdsk_disk_get_queue(struct casdsk_disk *dsk)
|
|||||||
{
|
{
|
||||||
BUG_ON(!dsk);
|
BUG_ON(!dsk);
|
||||||
BUG_ON(!dsk->bd);
|
BUG_ON(!dsk->bd);
|
||||||
BUG_ON(!dsk->bd->bd_contains);
|
return cas_bdev_whole(dsk->bd)->bd_disk->queue;
|
||||||
BUG_ON(!dsk->bd->bd_contains->bd_disk);
|
|
||||||
return dsk->bd->bd_contains->bd_disk->queue;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(casdsk_disk_get_queue);
|
EXPORT_SYMBOL(casdsk_disk_get_queue);
|
||||||
|
|
||||||
|
@ -189,27 +189,6 @@ static MAKE_RQ_RET_TYPE _casdsk_exp_obj_make_rq_fn(struct request_queue *q,
|
|||||||
return _casdsk_exp_obj_submit_bio(bio);
|
return _casdsk_exp_obj_submit_bio(bio);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _casdsk_get_next_part_no(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _casdsk_del_partitions(struct casdsk_disk *dsk)
|
static int _casdsk_del_partitions(struct casdsk_disk *dsk)
|
||||||
{
|
{
|
||||||
struct block_device *bd = casdsk_disk_get_blkdev(dsk);
|
struct block_device *bd = casdsk_disk_get_blkdev(dsk);
|
||||||
@ -249,7 +228,7 @@ static int _casdsk_del_partitions(struct casdsk_disk *dsk)
|
|||||||
goto out_copy;
|
goto out_copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((part_no = _casdsk_get_next_part_no(bd))) {
|
while ((part_no = cas_bd_get_next_part(bd))) {
|
||||||
bpart.pno = part_no;
|
bpart.pno = part_no;
|
||||||
result = copy_to_user((void __user *)usr_bpart, &bpart,
|
result = copy_to_user((void __user *)usr_bpart, &bpart,
|
||||||
sizeof(bpart));
|
sizeof(bpart));
|
||||||
@ -288,7 +267,7 @@ static int _casdsk_exp_obj_hide_parts(struct casdsk_disk *dsk)
|
|||||||
struct block_device *bd = casdsk_disk_get_blkdev(dsk);
|
struct block_device *bd = casdsk_disk_get_blkdev(dsk);
|
||||||
struct gendisk *gdsk = casdsk_disk_get_gendisk(dsk);
|
struct gendisk *gdsk = casdsk_disk_get_gendisk(dsk);
|
||||||
|
|
||||||
if (bd != bd->bd_contains)
|
if (bd != cas_bdev_whole(bd))
|
||||||
/* It is partition, no more job required */
|
/* It is partition, no more job required */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -325,7 +304,7 @@ static int _casdsk_exp_obj_set_dev_t(struct casdsk_disk *dsk, struct gendisk *gd
|
|||||||
bdev = casdsk_disk_get_blkdev(dsk);
|
bdev = casdsk_disk_get_blkdev(dsk);
|
||||||
BUG_ON(!bdev);
|
BUG_ON(!bdev);
|
||||||
|
|
||||||
if (bdev->bd_contains != bdev) {
|
if (cas_bdev_whole(bdev) != bdev) {
|
||||||
minors = 1;
|
minors = 1;
|
||||||
flags = 0;
|
flags = 0;
|
||||||
} else {
|
} else {
|
||||||
@ -352,7 +331,7 @@ static void _casdsk_exp_obj_clear_dev_t(struct casdsk_disk *dsk)
|
|||||||
struct block_device *bdev = casdsk_disk_get_blkdev(dsk);
|
struct block_device *bdev = casdsk_disk_get_blkdev(dsk);
|
||||||
struct gendisk *gdsk = casdsk_disk_get_gendisk(dsk);
|
struct gendisk *gdsk = casdsk_disk_get_gendisk(dsk);
|
||||||
|
|
||||||
if (bdev->bd_contains == bdev) {
|
if (cas_bdev_whole(bdev) == bdev) {
|
||||||
/* Restore previous configuration of bottom disk */
|
/* Restore previous configuration of bottom disk */
|
||||||
gdsk->minors = dsk->gd_minors;
|
gdsk->minors = dsk->gd_minors;
|
||||||
gdsk->flags |= dsk->gd_flags;
|
gdsk->flags |= dsk->gd_flags;
|
||||||
@ -718,7 +697,7 @@ int casdsk_exp_obj_lock(struct casdsk_disk *dsk)
|
|||||||
|
|
||||||
exp_obj = dsk->exp_obj;
|
exp_obj = dsk->exp_obj;
|
||||||
|
|
||||||
exp_obj->locked_bd = bdget_disk(exp_obj->gd, 0);
|
exp_obj->locked_bd = cas_bdget_disk(exp_obj->gd);
|
||||||
if (!exp_obj->locked_bd)
|
if (!exp_obj->locked_bd)
|
||||||
return -ENAVAIL;
|
return -ENAVAIL;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user