Extending 'configure' script

Functions and macros dependent on different kernel versions are now generated
before compilation basing on current kernel capabilities instead of hardcoding
them for specific kernels.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
Michal Mielewczyk 2019-05-24 09:23:13 -04:00
parent f88d78f603
commit 1e5355eba1
50 changed files with 1079 additions and 742 deletions

1
.gitignore vendored
View File

@ -3,7 +3,6 @@
*.bak *.bak
*.log *.log
*.o *.o
*.d
*.so *.so
*.ko *.ko
*.ko.* *.ko.*

103
configure vendored
View File

@ -4,103 +4,14 @@
# SPDX-License-Identifier: BSD-3-Clause-Clear # SPDX-License-Identifier: BSD-3-Clause-Clear
# #
MODULE_FILE=test_mod.c SCRIPTPATH=`dirname $0`
OBJ_MOD=test_mod.o SCRIPTPATH=`realpath $SCRIPTPATH`
KERN_VER=`uname -r`
PWD=`pwd`
NPROC=`nproc`
DEFINE_FILE=modules/generated_defines.h
CONFIG_FILES=`ls $SCRIPTPATH/configure.d/*.conf`
add_define() { rm -f $SCRIPTPATH/modules/generated_defines.h
echo -n "#define " >> $DEFINE_FILE
for arg in "$@"; do
echo -e "$arg" >> $DEFINE_FILE
done
}
add_function() { for file in $CONFIG_FILES; do
for arg in "$@"; do /bin/bash $file
echo -e "$arg" >> $DEFINE_FILE done
done
}
compile_module(){
if [ $# -gt 1 ]
then
INCLUDE="#include <$2>"
else
INCLUDE=""
fi
############# TEST MODULE #############
cat > $MODULE_FILE << EOF
#include <linux/module.h>
#include <linux/kernel.h>
$INCLUDE
int init_module(void) {
$1;
return 0;
}
void cleanup_module(void) {};
EOF
#######################################
make -C /lib/modules/$KERN_VER/build M=$PWD modules\
obj-m=$OBJ_MOD -j$NPROC &> /dev/null
local ret=$?
if [ $ret -eq 0 ]; then
make -j$NPROC -C /lib/modules/$KERN_VER/build M=$PWD clean\
obj-m=test.o &> /dev/null
fi
return $ret
}
kernel_not_supp_fail() {
echo "Current kernel is not supported!"
rm $DEFINE_FILE
exit 1
}
rm -f $DEFINE_FILE
compile_module "part_round_stats(1, 1)" "linux/genhd.h"
if [ $? -eq 0 ]; then
add_define "CAS_PART_ROUND_STATS(q, cpu, part) part_round_stats(cpu, part)"
else
compile_module "part_round_stats(NULL, 1, 1)" "linux/genhd.h"
if [ $? -eq 0 ]; then
add_define "CAS_PART_ROUND_STATS(q, cpu, part)\\"\
"\tpart_round_stats(q, cpu, part)"
fi
fi
compile_module "part_inc_in_flight(1, 1)" "linux/genhd.h"
if [ $? -eq 0 ]; then
add_define "CAS_PART_INC_IN_FLIGHT(q, cpu, part)\\"\
"\tpart_inc_in_flight(cpu, part)"
else
compile_module "part_inc_in_flight(NULL, 1, 1)" "linux/genhd.h"
if [ $? -eq 0 ]; then
add_define "CAS_PART_INC_IN_FLIGHT(q, cpu, part)\\"\
"\tpart_inc_in_flight(q, cpu, part)"
fi
fi
compile_module "part_dec_in_flight(1, 1)" "linux/genhd.h"
if [ $? -eq 0 ]; then
add_define "CAS_PART_DEC_IN_FLIGHT(q, cpu, part)\\"\
"\tpart_dec_in_flight(cpu, part)"
else
compile_module "part_dec_in_flight(NULL, 1, 1)" "linux/genhd.h"
if [ $? -eq 0 ]; then
add_define "CAS_PART_DEC_IN_FLIGHT(q, cpu, part)\\"\
"\tpart_dec_in_flight(q, cpu, part)"
fi
fi

14
configure.d/Makefile Normal file
View File

@ -0,0 +1,14 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
obj-m += test_mod.o
MAKE_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
all:
make -C /lib/modules/$(shell uname -r)/build M=$(MAKE_DIR) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(MAKE_DIR) clean

View File

@ -0,0 +1,16 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "struct bio b;blk_rq_append_bio(NULL, &b)" "linux/blkdev.h"
then
add_define "cas_blk_rq_append_bio(rq, bounce_bio) \\
blk_rq_append_bio(rq, bounce_bio"
else
add_define "cas_blk_rq_append_bio(rq, bounce_bio) \\
blk_rq_append_bio(rq, &bounce_bio)"
fi

View File

@ -0,0 +1,17 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "lookup_bdev(\"some_path\")" "linux/fs.h"
then
add_define "CAS_LOOKUP_BDEV(PATH) \\
lookup_bdev(PATH)"
elif compile_module "lookup_bdev(\"some_path\", 0)" "linux/fs.h"
then
add_define "CAS_LOOKUP_BDEV(PATH) \\
lookup_bdev(PATH, 0)"
fi

View File

@ -0,0 +1,21 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "RQF_SOFTBARRIER" "linux/blkdev.h"
then
add_define "CAS_CHECK_BARRIER(bio) \\
((CAS_BIO_OP_FLAGS(bio) & RQF_SOFTBARRIER) != 0)"
elif compile_module "REQ_SOFTBARRIER" "linux/blk_types.h"
then
add_define "CAS_CHECK_BARRIER(bio) \\
((CAS_BIO_OP_FLAGS(bio) & REQ_SOFTBARRIER) != 0)"
elif compile_module "BIO_RW_BARRIER" "linux/fs.h"
then
add_define "CAS_CHECK_BARRIER(bio) \\
(bio_rw_flagged((bio), BIO_RW_BARRIER))"
fi

View File

@ -0,0 +1,27 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "bio_clone(NULL, 0)" "linux/bio.h"
then
add_function "static inline struct bio *cas_bio_clone(struct bio *bio, gfp_t gfp_mask)
{
return bio_clone(bio, gfp_mask);
}"
elif compile_module "bio_clone_kmalloc(NULL, 0)" "linux/bio.h"
then
add_function "static inline struct bio *cas_bio_clone(struct bio *bio, gfp_t gfp_mask)
{
return bio_clone_kmalloc(bio, gfp_mask);
}"
elif compile_module "bio_clone_fast(NULL, 0, NULL)" "linux/bio.h"
then
add_function "static inline struct bio *cas_bio_clone(struct bio *bio, gfp_t gfp_mask)
{
return bio_clone_fast(bio, gfp_mask, NULL);
}"
fi

31
configure.d/bio_cmpl.conf Normal file
View File

@ -0,0 +1,31 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "struct bio b;b.bi_end_io(NULL, 0)" "linux/bio.h"
then
add_define "CAS_BIO_ENDIO(BIO, BYTES_DONE, ERROR) \\
bio_endio(BIO, ERROR)"
add_define "CAS_DECLARE_BLOCK_CALLBACK(name, BIO, BYTES_DONE, ERROR) \\
void name##_callback(BIO, ERROR)"
add_define "CAS_BLOCK_CALLBACK_ERROR(BIO, ERROR) \\
ERROR"
elif compile_module "struct bio b;b.bi_end_io(NULL)" "linux/bio.h"
then
add_define "CAS_BIO_ENDIO(BIO, BYTES_DONE, ERROR) \\
({ CAS_BIO_OP_STATUS(BIO) = ERROR; bio_endio(BIO); })"
add_define "CAS_DECLARE_BLOCK_CALLBACK(name, BIO, BYTES_DONE, ERROR) \\
void name##_callback(BIO)"
add_define "CAS_BLOCK_CALLBACK_ERROR(BIO, ERROR) \\
CAS_BIO_OP_STATUS(BIO)"
fi
add_define "CAS_REFER_BLOCK_CALLBACK(name) \\
name##_callback"
add_define "CAS_BLOCK_CALLBACK_INIT(BIO) \\
{; }"
add_define "CAS_BLOCK_CALLBACK_RETURN(BIO) \\
{ return; }"

View File

@ -0,0 +1,33 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "bio_op(NULL)" "linux/bio.h"
then
add_define "CAS_IS_DISCARD(bio) \\
(bio_op(bio) == REQ_OP_DISCARD)"
add_define "CAS_BIO_DISCARD \\
(REQ_OP_DISCARD)"
elif compile_module "REQ_OP_MASK" "linux/blk_types.h"
then
add_define "CAS_IS_DISCARD(bio) \\
(((CAS_BIO_OP_FLAGS(bio)) & REQ_OP_MASK) == REQ_OP_DISCARD)"
add_define "CAS_BIO_DISCARD \\
((REQ_OP_WRITE | REQ_OP_DISCARD))"
elif compile_module "REQ_OP_DISCARD" "linux/blk_types.h"
then
add_define "CAS_IS_DISCARD(bio) \\
((CAS_BIO_OP_FLAGS(bio)) & REQ_OP_DISCARD)"
add_define "CAS_BIO_DISCARD \\
((REQ_OP_WRITE | REQ_OP_DISCARD))"
elif compile_module "REQ_DISCARD" "linux/blk_types.h"
then
add_define "CAS_IS_DISCARD(bio) \\
((CAS_BIO_OP_FLAGS(bio)) & REQ_DISCARD)"
add_define "CAS_BIO_DISCARD \\
(REQ_WRITE | REQ_DISCARD)"
fi

17
configure.d/bio_err.conf Normal file
View File

@ -0,0 +1,17 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "struct bio b;b.bi_status" "linux/bio.h"
then
add_define "CAS_BIO_OP_STATUS(bio) \\
bio->bi_status"
elif compile_module "struct bio b;b.bi_error" "linux/bio.h"
then
add_define "CAS_BIO_OP_STATUS(bio) \\
bio->bi_error"
fi

View File

@ -0,0 +1,19 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "struct bio b;b.bi_opf" "linux/bio.h"
then
add_define "CAS_BIO_OP_FLAGS_FORMAT \"0x%016X\""
add_define "CAS_BIO_OP_FLAGS(bio) \\
(bio)->bi_opf"
elif compile_module "struct bio b;b.bi_rw" "linux/bio.h"
then
add_define "CAS_BIO_OP_FLAGS_FORMAT \"0x%016lX\""
add_define "CAS_BIO_OP_FLAGS(bio) \\
(bio)->bi_rw"
fi

25
configure.d/bio_iter.conf Normal file
View File

@ -0,0 +1,25 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "struct bio b;b.bi_iter.bi_size" "linux/bio.h"
then
add_define "CAS_BIO_BISIZE(bio) \\
bio->bi_iter.bi_size"
add_define "CAS_BIO_BIIDX(bio) \\
bio->bi_iter.bi_idx"
add_define "CAS_BIO_BISECTOR(bio) \\
bio->bi_iter.bi_sector"
elif compile_module "struct bio b;b.bi_size" "linux/bio.h"
then
add_define "CAS_BIO_BISIZE(bio) \\
bio->bi_size"
add_define "CAS_BIO_BIIDX(bio) \\
bio->bi_idx"
add_define "CAS_BIO_BISECTOR(bio) \\
bio->bi_sector"
fi

16
configure.d/biovec.conf Normal file
View File

@ -0,0 +1,16 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "struct bio b;&bio_iovec(&b)" "linux/bio.h"
then
add_define "CAS_SEGMENT_BVEC(vec) \\
(&(vec))"
else
add_define "CAS_SEGMENT_BVEC(vec) \\
(vec)"
fi

16
configure.d/block_pc.conf Normal file
View File

@ -0,0 +1,16 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "blk_rq_set_block_pc(NULL)" "linux/blkdev.h"
then
add_define "cas_blk_rq_set_block_pc(rq) \\
blk_rq_set_block_pc(rq)"
else
add_define "cas_blk_rq_set_block_pc(rq) \\
{}"
fi

View File

@ -0,0 +1,62 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
SCRIPTPATH=`dirname $0`
SCRIPTPATH=`realpath $SCRIPTPATH`
MODULE_FILE=$SCRIPTPATH/test_mod.c
OBJ_MOD=$SCRIPTPATH/test_mod.o
KERN_VER=`uname -r`
NPROC=`nproc`
DEFINE_FILE=$SCRIPTPATH/../modules/generated_defines.h
add_define() {
printf "#define %s\n" $1 >> $DEFINE_FILE
}
add_function() {
printf "%s\n" $1 >> $DEFINE_FILE
}
compile_module(){
if [ $# -gt 1 ]
then
INCLUDE="#include <$2>"
else
INCLUDE=""
fi
############# TEST MODULE #############
cat > $MODULE_FILE <<- EOF
#include <linux/module.h>
#include <linux/kernel.h>
$INCLUDE
int init_module(void) {
$1;
return 0;
}
void cleanup_module(void) {};
EOF
#######################################
make -C $SCRIPTPATH &> /dev/null
local ret=$?
if [ $ret -eq 0 ]; then
make -C $SCRIPTPATH clean &> /dev/null
fi
return $ret
}
kernel_not_supp_fail() {
echo "Current kernel is not supported!"
rm $DEFINE_FILE
exit 1
}
IFS='?'

View File

@ -0,0 +1,16 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "deamonize(\"some_name\", NULL)" "linux/sched.h"
then
add_define "CAS_DAEMONIZE(name, arg...) \\
daemonize(name, ##arg)"
else
add_define "CAS_DAEMONIZE(name, arg...) \\
do { } while (0)"
fi

17
configure.d/dentry.conf Normal file
View File

@ -0,0 +1,17 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "struct dentry dentry;dentry.d_u.d_alias" "linux/dcache.h"
then
add_define "CAS_ALIAS_NODE_TO_DENTRY(alias) \\
container_of(alias, struct dentry, d_u.d_alias)"
elif compile_module "struct dentry dentry;dentry.d_alias" "linux/dcache.h"
then
add_define "CAS_ALIAS_NODE_TO_DENTRY(alias) \\
container_of(alias, struct dentry, d_alias)"
fi

View File

@ -0,0 +1,16 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "struct queue_limits q;q.discard_zeroes_data" "linux/blkdev.h"
then
add_define "CAS_SET_DISCARD_ZEROES_DATA(queue_limits, val) \\
queue_limits.discard_zeroes_data = val"
else
add_define "CAS_SET_DISCARD_ZEROES_DATA(queue_limits, val) \\
({})"
fi

View File

@ -0,0 +1,21 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "REQ_PREFLUSH" "linux/blk_types.h"
then
add_define "CAS_REQ_FLUSH \\
REQ_PREFLUSH"
add_define "CAS_FLUSH_SUPPORTED \\
1"
elif compile_module "REQ_FLUSH" "linux/blk_types.h"
then
add_define "CAS_REQ_FLUSH \\
REQ_FLUSH"
add_define "CAS_FLUSH_SUPPORTED \\
1"
fi

View File

@ -0,0 +1,32 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "WRITE_FLUSH_FUA" "linux/fs.h"
then
add_define "CAS_WRITE_FLUSH_FUA \\
WRITE_FLUSH_FUA"
if compile_module "BIO_FUA" "linux/bio.h"
then
add_define "CAS_IS_WRITE_FLUSH_FUA(flags) \\
((BIO_FUA | BIO_FLUSH) == ((flags) & (BIO_FUA | BIO_FLUSH)))"
else
add_define "CAS_IS_WRITE_FLUSH_FUA(flags) \\
((REQ_FUA | CAS_REQ_FLUSH) == ((flags) & (REQ_FUA | CAS_REQ_FLUSH)))"
fi
elif compile_module "REQ_PREFLUSH" "linux/blk_types.h"
then
add_define "CAS_IS_WRITE_FLUSH_FUA(flags) \\
((REQ_PREFLUSH | REQ_FUA) == ((flags) & (REQ_PREFLUSH |REQ_FUA)))"
add_define "CAS_WRITE_FLUSH_FUA \\
(REQ_PREFLUSH | REQ_FUA)"
else
add_define "CAS_IS_WRITE_FLUSH_FUA(flags) \\
0"
add_define "CAS_WRITE_FLUSH_FUA \\
WRITE_BARRIER"
fi

View File

@ -0,0 +1,85 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if
compile_module "generic_start_io_acct(NULL, 0, 0, NULL)" "linux/bio.h"
then
add_function "
static inline void cas_generic_start_io_acct(struct request_queue *q,
int rw, unsigned long sectors, struct hd_struct *part) {
generic_start_io_acct(q, rw, sectors, part);
}"
add_function "
static inline void cas_generic_end_io_acct(struct request_queue *q,
int rw, struct hd_struct *part, unsigned long start_time)
{
generic_end_io_acct(q, rw, part, start_time);
}"
elif compile_module "generic_start_io_acct(0, 0, NULL)" "linux/bio.h"
then
add_function "
static inline void cas_generic_start_io_acct(struct request_queue *q,
int rw, unsigned long sectors, struct hd_struct *part)
{
generic_start_io_acct(rw, sectors, part);
}"
add_function "
static inline void cas_generic_end_io_acct(struct request_queue *q,
int rw, struct hd_struct *part, unsigned long start_time)
{
generic_end_io_acct(rw, part, start_time);
}"
elif compile_module "part_round_stats(1, 1)" "linux/genhd.h"
then
add_function "
static inline void cas_generic_start_io_acct(struct request_queue *q,
int rw, unsigned long sectors, struct hd_struct *part)
{
int cpu = part_stat_lock();
part_round_stats(cpu, part);
part_stat_inc(cpu, part, ios[rw]);
part_stat_add(cpu, part, sectors[rw], sectors);
part_inc_in_flight(part, rw);
part_stat_unlock();
}"
add_function "
static inline void cas_generic_end_io_acct(struct request_queue *q,
int rw, struct hd_struct *part, unsigned long start_time)
{
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_unlock();
}"
elif compile_module "part_round_stats(NULL, 1, 1)" "linux/genhd.h"
then
add_function "
static inline void cas_generic_start_io_acct(struct request_queue *q,
int rw, unsigned long sectors, struct hd_struct *part)
{
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], sectors);
part_inc_in_flight(NULL, part, rw);
part_stat_unlock();
}"
add_function "
static inline void cas_generic_end_io_acct(struct request_queue *q,
int rw, struct hd_struct *part, unsigned long start_time)
{
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_unlock();
}"
fi

View File

@ -0,0 +1,32 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "global_zone_page_state(1)" "linux/mm.h"
then
add_function "
static inline unsigned long cas_global_zone_page_state(enum zone_stat_item item)
{
return global_zone_page_state(item);
}"
add_define "CAS_BIO_SET_DEV(bio, bdev) \\
bio_set_dev(bio, bdev)"
add_define "CAS_BIO_GET_DEV(bio) \\
bio->bi_disk"
elif compile_module "global_page_state(1)" "linux/mm.h"
then
add_function "
static inline unsigned long cas_global_zone_page_state(enum zone_stat_item item)
{
return global_page_state(item);
}"
add_define "CAS_BIO_SET_DEV(bio, bdev) \\
bio->bi_bdev = bdev"
add_define "CAS_BIO_GET_DEV(bio) \\
bio->bi_bdev->bd_disk"
fi

25
configure.d/hlist.conf Normal file
View File

@ -0,0 +1,25 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "struct hlist_node list" "linux/types.h"
then
add_define "CAS_ALIAS_NODE_TYPE \\
struct hlist_node"
add_define "CAS_DENTRY_LIST_EMPTY(head) \\
hlist_empty(head)"
add_define "CAS_INODE_FOR_EACH_DENTRY(pos, head) \\
hlist_for_each(pos, head)"
elif compile_module "struct list_head list" "linux/list.h"
then
add_define "CAS_ALIAS_NODE_TYPE \\
struct list_head"
add_define "CAS_DENTRY_LIST_EMPTY(head) \\
list_empty(head)"
add_define "CAS_INODE_FOR_EACH_DENTRY(pos, head) \\
list_for_each(pos, head)"
fi

17
configure.d/inode.conf Normal file
View File

@ -0,0 +1,17 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "struct file file;file.f_inode" "linux/fs.h"
then
add_define "CAS_FILE_INODE(file) \\
file->f_inode"
elif compile_module "struct file file;file->f_dentry->d_inode" "linux/fs.h"
then
add_define "CAS_FILE_INODE(file) \\
file->f_dentry->d_inode"
fi

39
configure.d/make_req.conf Normal file
View File

@ -0,0 +1,39 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "blk_make_request(NULL, NULL, 0)" "linux/blkdev.h"
then
add_function "
static inline struct request *cas_blk_make_request(struct request_queue *q,
struct bio *bio, gfp_t gfp_mask)
{
return blk_make_request(q, bio, gfp_mask);
}"
else
add_function "
static inline struct request *cas_blk_make_request(struct request_queue *q,
struct bio *bio, gfp_t gfp_mask)
{
struct request *rq = blk_get_request(q, bio_data_dir(bio), gfp_mask);
if (IS_ERR(rq))
return rq;
cas_blk_rq_set_block_pc(rq);
rq->q = q;
for_each_bio(bio) {
struct bio *bounce_bio = bio;
int ret;
cas_blk_queue_bounce(q, &bounce_bio);
ret = cas_blk_rq_append_bio(rq, bounce_bio);
if (unlikely(ret)) {
blk_put_request(rq);
return ERR_PTR(ret);
}
}
return rq;
}"
fi

39
configure.d/munmap.conf Normal file
View File

@ -0,0 +1,39 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "vm_munmap(0, 0)" "linux/mm.h"
then
add_function "
#include <uapi/asm-generic/mman-common.h>
static inline unsigned long cas_vm_mmap(struct file *file,
unsigned long addr, unsigned long len)
{
return vm_mmap(file, addr, len, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, 0);
}"
add_function "
static inline int cas_vm_munmap(unsigned long start, size_t len)
{
return vm_munmap(start, len);
}"
elif compile_module "do_munmap(NULL, 0)" "linux/mm.h"
then
add_function "
#include <asm-generic/mman-common.h>
static inline unsigned long cas_vm_mmap(struct file *file,
unsigned long addr, unsigned long len)
{
return do_mmap_pgoff(file, addr, len, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, 0);
}"
add_function "
static inline int cas_vm_munmap(unsigned long start, size_t len)
{
return do_munmap(current->mm, start, len);
}"
fi

View File

@ -0,0 +1,16 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "blk_queue_bounce(NULL, NULL);" "linux/blkdev.h"
then
add_define "cas_blk_queue_bounce(q, bounce_bio) \\
blk_queue_bounce(q, bounce_bio)"
else
add_define "cas_blk_queue_bounce(q, bounce_bio) \\
({})"
fi

View File

@ -0,0 +1,16 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "struct request_queue q;q.limits.chunk_sectors" "linux/blkdev.h"
then
add_define "CAS_SET_QUEUE_CHUNK_SECTORS(queue, chunk_size) \\
queue->limits.chunk_sectors = chunk_size"
else
add_define "CAS_SET_QUEUE_CHUNK_SECTORS(queue, chunk_size) \\
{;}"
fi

View File

@ -0,0 +1,16 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "blk_queue_flag_set(0, NULL)" "linux/blkdev.h"
then
add_define "cas_queue_flag_set_unlocked(flag, request_queue) \\
blk_queue_flag_set(flag, request_queue)"
else
add_define "cas_queue_flag_set_unlocked(flag, request_queue) \\
queue_flag_set_unlocked(flag, request_queue)"
fi

View File

@ -0,0 +1,53 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
# RHEL 7.3
if compile_module "struct queue_limits q;q.limits_aux" "linux/blkdev.h"
then
add_function "
static inline void cas_copy_queue_limits(struct request_queue *exp_q,
struct request_queue *cache_q, struct request_queue *core_q)
{
struct queue_limits_aux *l_aux = exp_q->limits.limits_aux;
exp_q->limits = cache_q->limits;
exp_q->limits.limits_aux = l_aux;
if (exp_q->limits.limits_aux && cache_q->limits.limits_aux)
*exp_q->limits.limits_aux = *cache_q->limits.limits_aux;
exp_q->limits.max_sectors = core_q->limits.max_sectors;
exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors;
exp_q->limits.max_segments = core_q->limits.max_segments;
exp_q->limits.max_write_same_sectors = 0;
if (queue_virt_boundary(cache_q))
queue_flag_set(QUEUE_FLAG_NOMERGES, cache_q);
}"
elif compile_module "struct queue_limits q;q.max_write_zeroes_sectors" "linux/blkdev.h"
then
add_function "
static inline void cas_copy_queue_limits(struct request_queue *exp_q,
struct request_queue *cache_q, struct request_queue *core_q)
{
exp_q->limits = cache_q->limits;
exp_q->limits.max_sectors = core_q->limits.max_sectors;
exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors;
exp_q->limits.max_segments = core_q->limits.max_segments;
exp_q->limits.max_write_same_sectors = 0;
exp_q->limits.max_write_zeroes_sectors = 0;
}"
elif compile_module "struct queue_limits q;q.max_write_same_sectors" "linux/blkdev.h"
then
add_function "
static inline void cas_copy_queue_limits(struct request_queue *exp_q,
struct request_queue *cache_q, struct request_queue *core_q)
{
exp_q->limits = cache_q->limits;
exp_q->limits.max_sectors = core_q->limits.max_sectors;
exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors;
exp_q->limits.max_segments = core_q->limits.max_segments;
exp_q->limits.max_write_same_sectors = 0;
}"
fi

View File

@ -0,0 +1,38 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "blk_queue_write_cache(NULL, 0, 0)" "linux/blkdev.h"
then
add_define "CAS_CHECK_QUEUE_FLUSH(q) \\
test_bit(QUEUE_FLAG_WC, &(q)->queue_flags)"
add_define "CAS_CHECK_QUEUE_FUA(q) \\
test_bit(QUEUE_FLAG_FUA, &(q)->queue_flags)"
add_function "
static inline void cas_set_queue_flush_fua(struct request_queue *q,
bool flush, bool fua)
{
blk_queue_write_cache(q, flush, fua);
}"
elif compile_module "struct request_queue rq;rq.flush_flags" "linux/blkdev.h"
then
add_define "CAS_CHECK_QUEUE_FLUSH(q) \\
((q)->flush_flags & CAS_REQ_FLUSH)"
add_define "CAS_CHECK_QUEUE_FUA(q) \\
((q)->flush_flags & REQ_FUA)"
add_function "static inline void cas_set_queue_flush_fua(struct request_queue *q,
bool flush, bool fua)
{
unsigned int flags = 0;
if (flush)
flags |= CAS_REQ_FLUSH;
if (fua)
flags |= REQ_FUA;
if (flags)
blk_queue_flush(q, flags);
}"
fi

30
configure.d/req_fs.conf Normal file
View File

@ -0,0 +1,30 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "REQ_TYPE_FS" "linux/blkdev.h"
then
add_function "
static inline int cas_is_rq_type_fs(struct request *rq)
{
return rq->cmd_type == REQ_TYPE_FS;
}"
else
add_function "
static inline int cas_is_rq_type_fs(struct request *rq)
{
switch (req_op(rq)){
case REQ_OP_READ:
case REQ_OP_WRITE:
case REQ_OP_FLUSH:
case REQ_OP_DISCARD:
return true;
default:
return false;
}
}"
fi

View File

@ -0,0 +1,44 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
# submit_bio() can be defined in "bio.h" or in "fs.h"
# If it is defind in fs.h, three possibilities are available:
# * it takes one argument and retuns non-void
# * it takes two arguments and returns non-void
# * it takse two arguments and is void-type
if compile_module "submit_bio(NULL)" "linux/bio.h"
then
add_function "
static inline blk_qc_t cas_submit_bio(int rw, struct bio *bio)
{
CAS_BIO_OP_FLAGS(bio) |= rw;
return submit_bio(bio);
}"
elif compile_module "submit_bio(NULL)" "linux/fs.h"
then
add_function "
static inline blk_qc_t cas_submit_bio(int rw, struct bio *bio)
{
CAS_BIO_OP_FLAGS(bio) |= rw;
return submit_bio(bio);
}"
elif compile_module "void *t=submit_bio(0, NULL)" "linux/fs.h"
then
add_function "
static inline blk_qc_t cas_submit_bio(int rw, struct bio *bio)
{
return submit_bio(rw, bio);
}"
elif compile_module "submit_bio(0, NULL)" "linux/fs.h"
then
add_function "
static inline void cas_submit_bio(int rw, struct bio *bio)
{
submit_bio(rw, bio);
}"
fi

13
configure.d/whlt.conf Normal file
View File

@ -0,0 +1,13 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "struct bio b;b.bi_write_hint" "linux/bio.h"
then
add_define "CAS_WLTH_SUPPORT \\
1"
fi

View File

@ -0,0 +1,17 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "WRITE" "linux/blk_types.h"
then
add_define "CAS_RQ_DATA_DIR_WR \\
WRITE"
elif compile_module "REQ_WRITE" "linux/blk_types.h"
then
add_define "CAS_RQ_DATA_DIR_WR \\
REQ_WRITE"
fi

View File

@ -0,0 +1,38 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "WRITE_FLUSH" "linux/fs.h"
then
add_define "CAS_RQ_IS_FLUSH(rq) \\
((rq)->cmd_flags & CAS_REQ_FLUSH)"
add_define "CAS_WRITE_FLUSH \\
WRITE_FLUSH"
if compile_module "BIO_FLUSH" "linux/bio.h"
then
add_define "CAS_IS_WRITE_FLUSH(flags) \\
((flags) & BIO_FLUSH)"
else
add_define "CAS_IS_WRITE_FLUSH(flags) \\
((flags) & CAS_REQ_FLUSH)"
fi
elif compile_module "REQ_PREFLUSH" "linux/blk_types.h"
then
add_define "CAS_RQ_IS_FLUSH(rq) \\
((rq)->cmd_flags & REQ_PREFLUSH)"
add_define "CAS_WRITE_FLUSH \\
(REQ_OP_WRITE | REQ_PREFLUSH)"
add_define "CAS_IS_WRITE_FLUSH(flags) \\
(CAS_WRITE_FLUSH == ((flags) & CAS_WRITE_FLUSH))"
else
add_define "CAS_RQ_IS_FLUSH(rq) \\
0"
add_define "CAS_IS_WRITE_FLUSH(flags) \\
(WRITE_BARRIER == ((flags) & WRITE_BARRIER))"
add_define "CAS_WRITE_FLUSH \\
WRITE_BARRIER"
fi

View File

@ -0,0 +1,32 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
. `dirname $0`/conf_framework
if compile_module "WRITE_FUA" "linux/fs.h"
then
add_define "CAS_WRITE_FUA \\
WRITE_FUA"
if compile_module "BIO_FUA" "linux/bio.h"
then
add_define "CAS_IS_WRITE_FUA(flags) \\
((flags) & BIO_FUA)"
else
add_define "CAS_IS_WRITE_FUA(flags) \\
((flags) & REQ_FUA)"
fi
elif compile_module "REQ_FUA" "linux/blk_types.h"
then
add_define "CAS_IS_WRITE_FUA(flags) \\
((flags) & REQ_FUA)"
add_define "CAS_WRITE_FUA \\
REQ_FUA"
else
add_define "CAS_IS_WRITE_FUA(flags) \\
0"
add_define "CAS_WRITE_FUA \\
WRITE_BARRIER"
fi

View File

@ -47,8 +47,8 @@ default: $(VERSION_FILE) sync
clean: clean:
cd $(KERNEL_DIR) && make M=$(PWD) clean cd $(KERNEL_DIR) && make M=$(PWD) clean
rm $(PWD)/generated_defines.h
distclean: clean distsync distclean: clean distsync
rm $(PWD)/generated_defines.h
install: install:
@echo "Installing Open-CAS modules" @echo "Installing Open-CAS modules"

View File

@ -209,7 +209,7 @@ static cas_cls_eval_t _cas_cls_numeric_test_u(
return cas_cls_eval_no; return cas_cls_eval_no;
} }
#ifdef WLTH_SUPPORT #ifdef CAS_WLTH_SUPPORT
/* Write lifetime hint condition test */ /* Write lifetime hint condition test */
static cas_cls_eval_t _cas_cls_wlth_test(struct cas_classifier *cls, static cas_cls_eval_t _cas_cls_wlth_test(struct cas_classifier *cls,
struct cas_cls_condition *c, struct cas_cls_io *io, struct cas_cls_condition *c, struct cas_cls_io *io,
@ -300,9 +300,9 @@ static void _cas_cls_directory_resolve_work(struct work_struct *work)
static struct dentry *_cas_cls_dir_get_inode_dentry(struct inode *inode) static struct dentry *_cas_cls_dir_get_inode_dentry(struct inode *inode)
{ {
struct dentry *d = NULL, *iter; struct dentry *d = NULL, *iter;
ALIAS_NODE_TYPE *pos; /* alias list current element */ CAS_ALIAS_NODE_TYPE *pos; /* alias list current element */
if (DENTRY_LIST_EMPTY(&inode->i_dentry)) if (CAS_DENTRY_LIST_EMPTY(&inode->i_dentry))
return NULL; return NULL;
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
@ -310,8 +310,8 @@ static struct dentry *_cas_cls_dir_get_inode_dentry(struct inode *inode)
if (S_ISDIR(inode->i_mode)) if (S_ISDIR(inode->i_mode))
goto unlock; goto unlock;
INODE_FOR_EACH_DENTRY(pos, &inode->i_dentry) { CAS_INODE_FOR_EACH_DENTRY(pos, &inode->i_dentry) {
iter = ALIAS_NODE_TO_DENTRY(pos); iter = CAS_ALIAS_NODE_TO_DENTRY(pos);
spin_lock(&iter->d_lock); spin_lock(&iter->d_lock);
if (!d_unhashed(iter)) if (!d_unhashed(iter))
d = iter; d = iter;
@ -428,7 +428,7 @@ static struct cas_cls_condition_handler _handlers[] = {
_cas_cls_generic_dtr }, _cas_cls_generic_dtr },
{ "directory", _cas_cls_directory_test, _cas_cls_directory_ctr, { "directory", _cas_cls_directory_test, _cas_cls_directory_ctr,
_cas_cls_directory_dtr }, _cas_cls_directory_dtr },
#ifdef WLTH_SUPPORT #ifdef CAS_WLTH_SUPPORT
{ "wlth", _cas_cls_wlth_test, _cas_cls_numeric_ctr, { "wlth", _cas_cls_wlth_test, _cas_cls_numeric_ctr,
_cas_cls_generic_dtr}, _cas_cls_generic_dtr},
#endif #endif
@ -929,7 +929,7 @@ static void _cas_cls_get_bio_context(struct bio *bio,
return; return;
ctx->bio = bio; ctx->bio = bio;
if (!SEGMENT_BVEC(bio_iovec(bio))) if (!CAS_SEGMENT_BVEC(bio_iovec(bio)))
return; return;
page = bio_page(bio); page = bio_page(bio);

View File

@ -338,7 +338,7 @@ static int _cas_ctx_logger_print_rl(ocf_logger_t logger, const char *func_name)
if (!func_name) if (!func_name)
return -EINVAL; return -EINVAL;
return CAS_RATELIMIT(&cas_log_rl, func_name); return ___ratelimit(&cas_log_rl, func_name);
} }
/* /*

View File

@ -368,7 +368,8 @@ int cache_mng_cache_check_device(struct kcas_cache_check_device *cmd_info)
char holder[] = "CAS CHECK CACHE DEVICE\n"; char holder[] = "CAS CHECK CACHE DEVICE\n";
int result; int result;
bdev = OPEN_BDEV_EXCLUSIVE(cmd_info->path_name, FMODE_READ, holder); bdev = blkdev_get_by_path(cmd_info->path_name, (FMODE_EXCL|FMODE_READ),
holder);
if (IS_ERR(bdev)) { if (IS_ERR(bdev)) {
return (PTR_ERR(bdev) == -EBUSY) ? return (PTR_ERR(bdev) == -EBUSY) ?
-OCF_ERR_NOT_OPEN_EXC : -OCF_ERR_NOT_OPEN_EXC :
@ -392,7 +393,7 @@ int cache_mng_cache_check_device(struct kcas_cache_check_device *cmd_info)
cas_blk_close_volume(volume); cas_blk_close_volume(volume);
out_bdev: out_bdev:
CLOSE_BDEV_EXCLUSIVE(bdev, FMODE_READ); blkdev_put(bdev, (FMODE_EXCL|FMODE_READ));
return result; return result;
} }
@ -455,7 +456,7 @@ int cache_mng_update_core_uuid(ocf_cache_t cache, ocf_core_id_t id, ocf_uuid_t u
bdvol = bd_object(vol); bdvol = bd_object(vol);
/* lookup block device object for device pointed by uuid */ /* lookup block device object for device pointed by uuid */
bdev = LOOKUP_BDEV(uuid->data); bdev = CAS_LOOKUP_BDEV(uuid->data);
if (IS_ERR(bdev)) { if (IS_ERR(bdev)) {
printk(KERN_ERR "failed to lookup bdev%s\n", (char*)uuid->data); printk(KERN_ERR "failed to lookup bdev%s\n", (char*)uuid->data);
return -ENODEV; return -ENODEV;
@ -958,7 +959,8 @@ int cache_mng_prepare_cache_cfg(struct ocf_mngt_cache_config *cfg,
return -OCF_ERR_INVAL; return -OCF_ERR_INVAL;
} }
bdev = OPEN_BDEV_EXCLUSIVE(device_cfg->uuid.data, FMODE_READ, holder); bdev = blkdev_get_by_path(device_cfg->uuid.data, (FMODE_EXCL|FMODE_READ),
holder);
if (IS_ERR(bdev)) { if (IS_ERR(bdev)) {
return (PTR_ERR(bdev) == -EBUSY) ? return (PTR_ERR(bdev) == -EBUSY) ?
-OCF_ERR_NOT_OPEN_EXC : -OCF_ERR_NOT_OPEN_EXC :
@ -967,7 +969,7 @@ int cache_mng_prepare_cache_cfg(struct ocf_mngt_cache_config *cfg,
is_part = (bdev->bd_contains != bdev); is_part = (bdev->bd_contains != bdev);
part_count = cas_blk_get_part_count(bdev); part_count = cas_blk_get_part_count(bdev);
CLOSE_BDEV_EXCLUSIVE(bdev, FMODE_READ); blkdev_put(bdev, (FMODE_EXCL|FMODE_READ));
if (!is_part && part_count > 1 && !device_cfg->force) if (!is_part && part_count > 1 && !device_cfg->force)
return -KCAS_ERR_CONTAINS_PART; return -KCAS_ERR_CONTAINS_PART;

View File

@ -37,6 +37,7 @@
#include <linux/crc32.h> #include <linux/crc32.h>
#include <linux/nmi.h> #include <linux/nmi.h>
#include <linux/ratelimit.h> #include <linux/ratelimit.h>
#include <linux/mm.h>
#include "generated_defines.h" #include "generated_defines.h"
@ -51,294 +52,6 @@
#endif #endif
#endif #endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32)
#error Unsupported Linux Kernel Version
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
#define FILE_INODE(file) file->f_inode
#else
#define FILE_INODE(file) file->f_dentry->d_inode
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 76)
#define DENTRY_ALIAS_HEAD(dentry) (dentry)->d_u.d_alias
#define ALIAS_NODE_TO_DENTRY(alias) container_of(alias, struct dentry, d_u.d_alias)
#else
#define DENTRY_ALIAS_HEAD(dentry) (dentry)->d_alias
#define ALIAS_NODE_TO_DENTRY(alias) container_of(alias, struct dentry, d_alias)
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
#define ALIAS_NODE_TYPE struct hlist_node
#define DENTRY_LIST_EMPTY(head) hlist_empty(head)
#define INODE_FOR_EACH_DENTRY(pos, head) hlist_for_each(pos, head)
#else
#define DENTRY_LIST_EMPTY(head) list_empty(head)
#define ALIAS_NODE_TYPE struct list_head
#define INODE_FOR_EACH_DENTRY(pos, head) list_for_each(pos, head)
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0)
#define BIO_OP_STATUS(bio) bio->bi_status
#else
#define BIO_OP_STATUS(bio) bio->bi_error
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0)
#define WLTH_SUPPORT
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
#define BIO_ENDIO(BIO, BYTES_DONE, ERROR) \
({ BIO_OP_STATUS(BIO) = ERROR; bio_endio(BIO); })
#else
#define BIO_ENDIO(BIO, BYTES_DONE, ERROR) bio_endio(BIO, ERROR)
#endif
#define REFER_BLOCK_CALLBACK(name) name##_callback
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
#define DECLARE_BLOCK_CALLBACK(name, BIO, BYTES_DONE, ERROR) \
void name##_callback(BIO, ERROR)
#define BLOCK_CALLBACK_INIT(BIO) {; }
#define BLOCK_CALLBACK_RETURN() { return; }
#define BLOCK_CALLBACK_ERROR(BIO, ERROR) ERROR
#else
#define DECLARE_BLOCK_CALLBACK(name, BIO, BYTES_DONE, ERROR) \
void name##_callback(BIO)
#define BLOCK_CALLBACK_INIT(BIO) {; }
#define BLOCK_CALLBACK_RETURN() { return; }
#define BLOCK_CALLBACK_ERROR(BIO, ERROR) BIO_OP_STATUS(BIO)
#endif
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 37)
#define OPEN_BDEV_EXCLUSIVE(PATH, FMODE, HOLDER) \
blkdev_get_by_path(PATH, (FMODE_EXCL | FMODE), HOLDER)
#define CLOSE_BDEV_EXCLUSIVE(BDEV, FMODE) \
blkdev_put(BDEV, (FMODE_EXCL | FMODE))
#else
#define OPEN_BDEV_EXCLUSIVE(PATH, FMODE, HOLDER) \
open_bdev_exclusive(PATH, FMODE, HOLDER)
#define CLOSE_BDEV_EXCLUSIVE(BDEV, FMODE) \
close_bdev_exclusive(BDEV, FMODE)
#endif
#ifdef CAS_UBUNTU
#define LOOKUP_BDEV(PATH) lookup_bdev(PATH, 0)
#else
#define LOOKUP_BDEV(PATH) lookup_bdev(PATH)
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) || defined CAS_SLES12SP3
#define BIO_OP_FLAGS_FORMAT "0x%016X"
#define BIO_OP_FLAGS(bio) (bio)->bi_opf
#else
#define BIO_OP_FLAGS_FORMAT "0x%016lX"
#define BIO_OP_FLAGS(bio) (bio)->bi_rw
#endif
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 32)
#define BIO_RW_FLAGS ((1U << BIO_RW_UNPLUG) | \
(1U << BIO_RW_NOIDLE) | (1U << BIO_RW_SYNCIO))
#define BIO_SET_RW_FLAGS(bio) BIO_OP_FLAGS((bio)) |= BIO_RW_FLAGS
#else
#define BIO_RW_FLAGS 0
#define BIO_SET_RW_FLAGS(bio)
#endif
#if defined RQF_SOFTBARRIER
#define CHECK_BARRIER(bio) ((BIO_OP_FLAGS(bio) & RQF_SOFTBARRIER) != 0)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 1)
#define CHECK_BARRIER(bio) ((BIO_OP_FLAGS(bio) & REQ_SOFTBARRIER) != 0)
#else
#define CHECK_BARRIER(bio) (bio_rw_flagged((bio), BIO_RW_BARRIER))
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) || defined CAS_SLES12SP3
#define RQ_DATA_DIR(rq) rq_data_dir(rq)
#define RQ_DATA_DIR_WR WRITE
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)
#define RQ_DATA_DIR(rq) rq_data_dir(rq)
#define RQ_DATA_DIR_WR REQ_WRITE
#else
#define RQ_DATA_DIR(rq) rq_data_dir(rq)
#define RQ_DATA_DIR_WR WRITE
#endif
#if defined REQ_PREFLUSH
#define CAS_REQ_FLUSH REQ_PREFLUSH
#define CAS_FLUSH_SUPPORTED
#elif defined REQ_FLUSH
#define CAS_REQ_FLUSH REQ_FLUSH
#define CAS_FLUSH_SUPPORTED
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0) || defined CAS_SLES12SP3
#define CHECK_QUEUE_FLUSH(q) test_bit(QUEUE_FLAG_WC, &(q)->queue_flags)
#define CHECK_QUEUE_FUA(q) test_bit(QUEUE_FLAG_FUA, &(q)->queue_flags)
static inline void cas_set_queue_flush_fua(struct request_queue *q,
bool flush, bool fua)
{
blk_queue_write_cache(q, flush, fua);
}
#else
#define CHECK_QUEUE_FLUSH(q) ((q)->flush_flags & CAS_REQ_FLUSH)
#define CHECK_QUEUE_FUA(q) ((q)->flush_flags & REQ_FUA)
static inline void cas_set_queue_flush_fua(struct request_queue *q,
bool flush, bool fua)
{
unsigned int flags = 0;
if (flush)
flags |= CAS_REQ_FLUSH;
if (fua)
flags |= REQ_FUA;
if (flags)
blk_queue_flush(q, flags);
}
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
#ifdef WRITE_FLUSH
#define RQ_IS_FLUSH(rq) ((rq)->cmd_flags & CAS_REQ_FLUSH)
#ifdef BIO_FLUSH
#define CAS_IS_WRITE_FLUSH(flags) ((flags) & BIO_FLUSH)
#else
#define CAS_IS_WRITE_FLUSH(flags) \
((flags) & CAS_REQ_FLUSH)
#endif
#define OCF_WRITE_FLUSH WRITE_FLUSH
#elif defined REQ_PREFLUSH
#define RQ_IS_FLUSH(rq) ((rq)->cmd_flags & REQ_PREFLUSH)
#define OCF_WRITE_FLUSH (REQ_OP_WRITE | REQ_PREFLUSH)
#define CAS_IS_WRITE_FLUSH(flags) \
(OCF_WRITE_FLUSH == ((flags) & OCF_WRITE_FLUSH))
#else
#define RQ_IS_FLUSH(rq) 0
#define CAS_IS_WRITE_FLUSH(flags) \
(WRITE_BARRIER == ((flags) & WRITE_BARRIER))
#define OCF_WRITE_FLUSH WRITE_BARRIER
#endif /* #ifdef WRITE_FLUSH */
#ifdef WRITE_FLUSH_FUA
#define OCF_WRITE_FLUSH_FUA WRITE_FLUSH_FUA
#ifdef BIO_FUA
#define CAS_IS_WRITE_FLUSH_FUA(flags) \
((BIO_FUA | BIO_FLUSH) == \
((flags) & (BIO_FUA | BIO_FLUSH)))
#else
#define CAS_IS_WRITE_FLUSH_FUA(flags) \
((REQ_FUA | CAS_REQ_FLUSH) == \
((flags) & (REQ_FUA | CAS_REQ_FLUSH)))
#endif
#elif defined REQ_PREFLUSH
#define CAS_IS_WRITE_FLUSH_FUA(flags) \
((REQ_PREFLUSH | REQ_FUA) == \
((flags) & (REQ_PREFLUSH |REQ_FUA)))
#define OCF_WRITE_FLUSH_FUA (REQ_PREFLUSH | REQ_FUA)
#else
#define CAS_IS_WRITE_FLUSH_FUA(flags) 0
#define OCF_WRITE_FLUSH_FUA WRITE_BARRIER
#endif /* #ifdef WRITE_FLUSH_FUA */
#ifdef WRITE_FUA
#ifdef BIO_FUA
#define CAS_IS_WRITE_FUA(flags) ((flags) & BIO_FUA)
#else
#define CAS_IS_WRITE_FUA(flags) ((flags) & REQ_FUA)
#endif
#define OCF_WRITE_FUA WRITE_FUA
#elif defined REQ_FUA
#define CAS_IS_WRITE_FUA(flags) ((flags) & REQ_FUA)
#define OCF_WRITE_FUA REQ_FUA
#else
#define CAS_IS_WRITE_FUA(flags) 0
#define OCF_WRITE_FUA WRITE_BARRIER
#endif /* #ifdef WRITE_FUA */
#endif /* #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) */
#if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 7, 9)
#define DAEMONIZE(name, arg...) daemonize(name, ##arg)
#else
#define DAEMONIZE(name, arg...) do { } while (0)
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
#define SET_QUEUE_CHUNK_SECTORS(queue, chunk_size) \
queue->limits.chunk_sectors = chunk_size;
#else
#define SET_QUEUE_CHUNK_SECTORS(queue, chunk_size) {; }
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)
#define BIO_BISIZE(bio) bio->bi_size
#define BIO_BIIDX(bio) bio->bi_idx
#define BIO_BISECTOR(bio) bio->bi_sector
#else
#define BIO_BISIZE(bio) bio->bi_iter.bi_size
#define BIO_BISECTOR(bio) bio->bi_iter.bi_sector
#define BIO_BIIDX(bio) bio->bi_iter.bi_idx
#endif
#ifdef CAS_SLES12SP3
#define CAS_IS_DISCARD(bio) \
(((BIO_OP_FLAGS(bio)) & REQ_OP_MASK) == REQ_OP_DISCARD)
#define CAS_BIO_DISCARD \
((REQ_OP_WRITE | REQ_OP_DISCARD))
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
#define CAS_IS_DISCARD(bio) \
(bio_op(bio) == REQ_OP_DISCARD)
#define CAS_BIO_DISCARD \
(REQ_OP_DISCARD)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
#define CAS_IS_DISCARD(bio) \
((BIO_OP_FLAGS(bio)) & REQ_OP_DISCARD)
#define CAS_BIO_DISCARD \
((REQ_OP_WRITE | REQ_OP_DISCARD))
#elif LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32)
#define CAS_IS_DISCARD(bio) ((BIO_OP_FLAGS(bio)) & REQ_DISCARD)
#define CAS_BIO_DISCARD (REQ_WRITE | REQ_DISCARD)
#else
#define CAS_IS_DISCARD(bio) ((BIO_OP_FLAGS(bio)) & (1 << BIO_RW_DISCARD))
#define CAS_BIO_DISCARD ((1 << BIO_RW) | (1 << BIO_RW_DISCARD))
#endif
#include <linux/mm.h>
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32)
#include <uapi/asm-generic/mman-common.h>
static inline unsigned long cas_vm_mmap(struct file *file,
unsigned long addr, unsigned long len)
{
return vm_mmap(file, addr, len, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, 0);
}
static inline int cas_vm_munmap(unsigned long start, size_t len)
{
return vm_munmap(start, len);
}
#else
#include <asm-generic/mman-common.h>
static inline unsigned long cas_vm_mmap(struct file *file,
unsigned long addr, unsigned long len)
{
return do_mmap_pgoff(file, addr, len, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, 0);
}
static inline int cas_vm_munmap(unsigned long start, size_t len)
{
return do_munmap(current->mm, start, len);
}
#endif
/* /*
* For 8KB process kernel stack check if request is not continous and * For 8KB process kernel stack check if request is not continous and
* submit each bio as separate request. This prevent nvme driver from * submit each bio as separate request. This prevent nvme driver from
@ -349,12 +62,6 @@ static inline int cas_vm_munmap(unsigned long start, size_t len)
#define RQ_CHECK_CONTINOUS #define RQ_CHECK_CONTINOUS
#endif #endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)
#define SEGMENT_BVEC(vec) (&(vec))
#else
#define SEGMENT_BVEC(vec) (vec)
#endif
#ifndef SHRT_MIN #ifndef SHRT_MIN
#define SHRT_MIN ((s16)-32768) #define SHRT_MIN ((s16)-32768)
#endif #endif
@ -371,125 +78,6 @@ static inline int cas_vm_munmap(unsigned long start, size_t len)
#endif #endif
#endif #endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0) || defined CAS_SLES12SP3
static inline blk_qc_t cas_submit_bio(int rw, struct bio *bio)
{
BIO_OP_FLAGS(bio) |= rw;
return submit_bio(bio);
}
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)
static inline blk_qc_t cas_submit_bio(int rw, struct bio *bio)
{
return submit_bio(rw, bio);
}
#else
static inline void cas_submit_bio(int rw, struct bio *bio)
{
submit_bio(rw, bio);
}
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
#define cas_blk_rq_set_block_pc(rq) {}
#else
#define cas_blk_rq_set_block_pc(rq) blk_rq_set_block_pc(rq)
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0)
#define cas_blk_queue_bounce(q, bounce_bio) ({})
#else
#define cas_blk_queue_bounce(q, bounce_bio) blk_queue_bounce(q, bounce_bio)
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 11)
#define cas_blk_rq_append_bio(rq, bounce_bio) blk_rq_append_bio(rq, &bounce_bio)
#else
#define cas_blk_rq_append_bio(rq, bounce_bio) blk_rq_append_bio(rq, bounce_bio)
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) || defined CAS_SLES12SP3
static inline struct request *cas_blk_make_request(struct request_queue *q,
struct bio *bio, gfp_t gfp_mask)
{
struct request *rq = blk_get_request(q, bio_data_dir(bio), gfp_mask);
if (IS_ERR(rq))
return rq;
cas_blk_rq_set_block_pc(rq);
rq->q = q;
for_each_bio(bio) {
struct bio *bounce_bio = bio;
int ret;
cas_blk_queue_bounce(q, &bounce_bio);
ret = cas_blk_rq_append_bio(rq, bounce_bio);
if (unlikely(ret)) {
blk_put_request(rq);
return ERR_PTR(ret);
}
}
return rq;
}
#else
static inline struct request *cas_blk_make_request(struct request_queue *q,
struct bio *bio, gfp_t gfp_mask)
{
return blk_make_request(q, bio, gfp_mask);
}
#endif
#ifdef CAS_RHEL_73
static inline void cas_copy_queue_limits(struct request_queue *exp_q,
struct request_queue *cache_q, struct request_queue *core_q)
{
struct queue_limits_aux *l_aux = exp_q->limits.limits_aux;
exp_q->limits = cache_q->limits;
exp_q->limits.limits_aux = l_aux;
if (exp_q->limits.limits_aux && cache_q->limits.limits_aux)
*exp_q->limits.limits_aux = *cache_q->limits.limits_aux;
exp_q->limits.max_sectors = core_q->limits.max_sectors;
exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors;
exp_q->limits.max_segments = core_q->limits.max_segments;
exp_q->limits.max_write_same_sectors = 0;
/*
* Workaround for RHEL/CentOS 7.3 bug in kernel.
* Merging implementation on blk-mq does not respec virt boundary
* restriction and front merges bios with non-zero offsets.
* This leads to request with gaps between bios and in consequence
* triggers BUG_ON() in nvme driver or silently corrupts data.
* To prevent this, disable merging on cache queue if there are
* requirements regarding virt boundary (marking bios with REQ_NOMERGE
* does not solve this problem).
*/
if (queue_virt_boundary(cache_q))
queue_flag_set(QUEUE_FLAG_NOMERGES, cache_q);
}
#else
static inline void cas_copy_queue_limits(struct request_queue *exp_q,
struct request_queue *cache_q, struct request_queue *core_q)
{
exp_q->limits = cache_q->limits;
exp_q->limits.max_sectors = core_q->limits.max_sectors;
exp_q->limits.max_hw_sectors = core_q->limits.max_hw_sectors;
exp_q->limits.max_segments = core_q->limits.max_segments;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0) || defined CAS_SLES12SP3
exp_q->limits.max_write_same_sectors = 0;
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) || defined CAS_SLES12SP3
exp_q->limits.max_write_zeroes_sectors = 0;
#endif
}
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
#define CAS_GARBAGE_COLLECTOR #define CAS_GARBAGE_COLLECTOR
#endif #endif
@ -499,132 +87,4 @@ static inline void cas_copy_queue_limits(struct request_queue *exp_q,
if (printk_ratelimit()) \ if (printk_ratelimit()) \
printk(__VA_ARGS__) printk(__VA_ARGS__)
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
static inline void cas_generic_start_io_acct(struct request_queue *q,
int rw, unsigned long sectors, struct hd_struct *part)
{
int cpu = part_stat_lock();
CAS_PART_ROUND_STATS(q, cpu, part);
part_stat_inc(cpu, part, ios[rw]);
part_stat_add(cpu, part, sectors[rw], sectors);
CAS_PART_INC_IN_FLIGHT(q, part, rw);
part_stat_unlock();
}
static inline void cas_generic_end_io_acct(struct request_queue *q,
int rw, struct hd_struct *part, unsigned long start_time)
{
unsigned long duration = jiffies - start_time;
int cpu = part_stat_lock();
part_stat_add(cpu, part, ticks[rw], duration);
CAS_PART_ROUND_STATS(q, cpu, part);
CAS_PART_DEC_IN_FLIGHT(q, part, rw);
part_stat_unlock();
}
#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)
static inline void cas_generic_start_io_acct(struct request_queue *q,
int rw, unsigned long sectors, struct hd_struct *part)
{
generic_start_io_acct(rw, sectors, part);
}
static inline void cas_generic_end_io_acct(struct request_queue *q,
int rw, struct hd_struct *part, unsigned long start_time)
{
generic_end_io_acct(rw, part, start_time);
}
#else
static inline void cas_generic_start_io_acct(struct request_queue *q,
int rw, unsigned long sectors, struct hd_struct *part)
{
generic_start_io_acct(q, rw, sectors, part);
}
static inline void cas_generic_end_io_acct(struct request_queue *q,
int rw, struct hd_struct *part, unsigned long start_time)
{
generic_end_io_acct(q, rw, part, start_time);
}
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
static inline unsigned long cas_global_zone_page_state(enum zone_stat_item item)
{
return global_zone_page_state(item);
}
#define CAS_BIO_SET_DEV(bio, bdev) bio_set_dev(bio, bdev)
#define CAS_BIO_GET_DEV(bio) bio->bi_disk
#else
static inline unsigned long cas_global_zone_page_state(enum zone_stat_item item)
{
return global_page_state(item);
}
#define CAS_BIO_SET_DEV(bio, bdev) bio->bi_bdev = bdev
#define CAS_BIO_GET_DEV(bio) bio->bi_bdev->bd_disk
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)
#define CAS_RATELIMIT(state, func_name) __ratelimit(state)
#else
#define CAS_RATELIMIT(state, func_name) ___ratelimit(state, func_name)
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)
static inline struct bio *cas_bio_clone(struct bio *bio, gfp_t gfp_mask)
{
return bio_clone_fast(bio, gfp_mask, NULL);
}
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0)
static inline struct bio *cas_bio_clone(struct bio *bio, gfp_t gfp_mask)
{
return bio_clone_kmalloc(bio, gfp_mask);
}
#define CAS_BLK_STATUS_T blk_status_t
#else
static inline struct bio *cas_bio_clone(struct bio *bio, gfp_t gfp_mask)
{
return bio_clone(bio, gfp_mask);
}
#define CAS_BLK_STATUS_T int
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
static inline int is_rq_type_fs(struct request *rq)
{
switch (req_op(rq)){
case REQ_OP_READ:
case REQ_OP_WRITE:
case REQ_OP_FLUSH:
case REQ_OP_DISCARD:
return true;
default:
return false;
}
}
#else
static inline int is_rq_type_fs(struct request *rq)
{
return rq->cmd_type == REQ_TYPE_FS;
}
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
#define CAS_SET_DISCARD_ZEROES_DATA(queue_limits, val) ({})
#else
#define CAS_SET_DISCARD_ZEROES_DATA(queue_limits, val) \
queue_limits.discard_zeroes_data = val
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
#define cas_queue_flag_set_unlocked(flag, request_queue) \
blk_queue_flag_set(flag, request_queue)
#else
#define cas_queue_flag_set_unlocked(flag, request_queue) \
queue_flag_set_unlocked(flag, request_queue)
#endif
#endif /* #ifndef __LINUX_KERNEL_VERSION_H__ */ #endif /* #ifndef __LINUX_KERNEL_VERSION_H__ */

View File

@ -31,7 +31,7 @@ static int _cas_io_queue_thread(void *data)
info = ocf_queue_get_priv(q); info = ocf_queue_get_priv(q);
BUG_ON(!info); BUG_ON(!info);
DAEMONIZE(info->thread->comm); CAS_DAEMONIZE(info->thread->comm);
complete(&info->compl); complete(&info->compl);
@ -81,7 +81,7 @@ static int _cas_cleaner_thread(void *data)
info = ocf_cleaner_get_priv(c); info = ocf_cleaner_get_priv(c);
BUG_ON(!info); BUG_ON(!info);
DAEMONIZE(info->thread->comm); CAS_DAEMONIZE(info->thread->comm);
complete(&info->compl); complete(&info->compl);
@ -127,7 +127,7 @@ static int _cas_metadata_updater_thread(void *data)
info = ocf_metadata_updater_get_priv(mu); info = ocf_metadata_updater_get_priv(mu);
BUG_ON(!info); BUG_ON(!info);
DAEMONIZE(info->thread->comm); CAS_DAEMONIZE(info->thread->comm);
complete(&info->compl); complete(&info->compl);

View File

@ -316,7 +316,7 @@ static int _cas_nvme_format_namespace_by_path(const char *device_path,
goto out1; goto out1;
} }
bdev = OPEN_BDEV_EXCLUSIVE(device_path, bdev = blkdev_get_by_path(device_path,
FMODE_READ | FMODE_WRITE | FMODE_EXCL, holder); FMODE_READ | FMODE_WRITE | FMODE_EXCL, holder);
if (IS_ERR(bdev)) { if (IS_ERR(bdev)) {
if (PTR_ERR(bdev) == -EBUSY) if (PTR_ERR(bdev) == -EBUSY)
@ -378,7 +378,7 @@ static int _cas_nvme_format_namespace_by_path(const char *device_path,
ret = ioctl_by_bdev(bdev, BLKRRPART, (unsigned long)NULL); ret = ioctl_by_bdev(bdev, BLKRRPART, (unsigned long)NULL);
out2: out2:
CLOSE_BDEV_EXCLUSIVE(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL); blkdev_put(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL);
out1: out1:
kfree(id); kfree(id);
kfree(ns); kfree(ns);

View File

@ -434,7 +434,7 @@ static void cas_atomic_end_atom(struct cas_atomic_io *atom, int error)
ocf_io_put(io); ocf_io_put(io);
} }
static DECLARE_BLOCK_CALLBACK(cas_atomic_fire_atom, struct bio *bio, static CAS_DECLARE_BLOCK_CALLBACK(cas_atomic_fire_atom, struct bio *bio,
unsigned int bytes, int error) unsigned int bytes, int error)
{ {
int err; int err;
@ -443,12 +443,12 @@ static DECLARE_BLOCK_CALLBACK(cas_atomic_fire_atom, struct bio *bio,
BUG_ON(!bio); BUG_ON(!bio);
BUG_ON(!bio->bi_private); BUG_ON(!bio->bi_private);
err = BLOCK_CALLBACK_ERROR(bio, error); err = CAS_BLOCK_CALLBACK_ERROR(bio, error);
atom = bio->bi_private; atom = bio->bi_private;
BUG_ON(!atom->master); BUG_ON(!atom->master);
bdobj = bd_object(atom->volume); bdobj = bd_object(atom->volume);
CAS_DEBUG_PARAM("BIO result = %d", BLOCK_CALLBACK_ERROR(bio, error)); CAS_DEBUG_PARAM("BIO result = %d", CAS_BLOCK_CALLBACK_ERROR(bio, error));
if (err != 0) if (err != 0)
goto out; goto out;
@ -504,7 +504,7 @@ static void _cas_atomic_setup_cmd(
cmd->rw.opcode = (dir == OCF_WRITE) ? nvme_cmd_write : nvme_cmd_read; cmd->rw.opcode = (dir == OCF_WRITE) ? nvme_cmd_write : nvme_cmd_read;
cmd->rw.nsid = cpu_to_le32(ns_id); cmd->rw.nsid = cpu_to_le32(ns_id);
cmd->rw.slba = cpu_to_le64(BIO_BISECTOR(bio)); cmd->rw.slba = cpu_to_le64(CAS_BIO_BISECTOR(bio));
cmd->rw.length = cpu_to_le16((bytes / SECTOR_SIZE) - 1); cmd->rw.length = cpu_to_le16((bytes / SECTOR_SIZE) - 1);
cmd->rw.control = cpu_to_le16(NVME_RW_LR); cmd->rw.control = cpu_to_le16(NVME_RW_LR);
@ -562,11 +562,11 @@ static void cas_atomic_fire_atom(int dir, struct ocf_io *io,
/* Setup BIO */ /* Setup BIO */
bio->bi_bdev = bdev; bio->bi_bdev = bdev;
BIO_BISECTOR(bio) = atom->addr / SECTOR_SIZE; CAS_BIO_BISECTOR(bio) = atom->addr / SECTOR_SIZE;
bio->bi_next = NULL; bio->bi_next = NULL;
bio->bi_private = atom; bio->bi_private = atom;
BIO_OP_FLAGS(bio) |= io->flags; CAS_BIO_OP_FLAGS(bio) |= io->flags;
bio->bi_end_io = REFER_BLOCK_CALLBACK(cas_atomic_fire_atom); bio->bi_end_io = CAS_REFER_BLOCK_CALLBACK(cas_atomic_fire_atom);
/* Add pages to the BIO */ /* Add pages to the BIO */
bvec = atom->data->vec; bvec = atom->data->vec;
@ -726,8 +726,8 @@ static int cas_atomic_submit_discard_bio(struct cas_atomic_io *atom)
} }
nvm_discard->cattr = cpu_to_le32(0); nvm_discard->cattr = cpu_to_le32(0);
nvm_discard->nlb = cpu_to_le32(BIO_BISIZE(atom->bio) >> SECTOR_SHIFT); nvm_discard->nlb = cpu_to_le32(CAS_BIO_BISIZE(atom->bio) >> SECTOR_SHIFT);
nvm_discard->slba = cpu_to_le64(BIO_BISECTOR(atom->bio)); nvm_discard->slba = cpu_to_le64(CAS_BIO_BISECTOR(atom->bio));
cmd->dsm.opcode = nvme_cmd_dsm; cmd->dsm.opcode = nvme_cmd_dsm;
cmd->dsm.nsid = cpu_to_le32(ns_id); cmd->dsm.nsid = cpu_to_le32(ns_id);
@ -739,8 +739,8 @@ static int cas_atomic_submit_discard_bio(struct cas_atomic_io *atom)
offset = offset_in_page(nvm_discard); offset = offset_in_page(nvm_discard);
blk_add_request_payload(req, page, offset, sizeof(*nvm_discard)); blk_add_request_payload(req, page, offset, sizeof(*nvm_discard));
req->__sector = BIO_BISECTOR(atom->bio); req->__sector = CAS_BIO_BISECTOR(atom->bio);
req->__data_len = BIO_BISIZE(atom->bio); req->__data_len = CAS_BIO_BISIZE(atom->bio);
req->ioprio = bio_prio(atom->bio); req->ioprio = bio_prio(atom->bio);
req->timeout = ADMIN_TIMEOUT; req->timeout = ADMIN_TIMEOUT;
@ -782,7 +782,7 @@ static int cas_atomic_special_req_prepare(struct cas_atomic_io *atom,
return -ENOMEM; return -ENOMEM;
} }
atom->bio->bi_end_io = REFER_BLOCK_CALLBACK(cas_atomic_fire_atom); atom->bio->bi_end_io = CAS_REFER_BLOCK_CALLBACK(cas_atomic_fire_atom);
atom->bio->bi_bdev = bdev; atom->bio->bi_bdev = bdev;
atom->bio->bi_private = atom; atom->bio->bi_private = atom;
@ -826,9 +826,9 @@ void cas_atomic_submit_discard(struct ocf_io *io)
/* Set up specific field */ /* Set up specific field */
atom->discard = true; atom->discard = true;
BIO_OP_FLAGS(atom->bio) = CAS_BIO_DISCARD; CAS_BIO_OP_FLAGS(atom->bio) = CAS_BIO_DISCARD;
BIO_BISECTOR(atom->bio) = io->addr / SECTOR_SIZE; CAS_BIO_BISECTOR(atom->bio) = io->addr / SECTOR_SIZE;
BIO_BISIZE(atom->bio) = io->bytes; CAS_BIO_BISIZE(atom->bio) = io->bytes;
atom->request = cas_blk_make_request(q, atom->bio, GFP_NOIO); atom->request = cas_blk_make_request(q, atom->bio, GFP_NOIO);
if (IS_ERR(atom->request)) { if (IS_ERR(atom->request)) {
@ -872,7 +872,7 @@ void cas_atomic_submit_flush(struct ocf_io *io)
return; return;
} }
if (!CHECK_QUEUE_FLUSH(q)) { if (!CAS_CHECK_QUEUE_FLUSH(q)) {
/* This block device does not support flush */ /* This block device does not support flush */
atomic_sub(blkio->dirty, &bdobj->potentially_dirty); atomic_sub(blkio->dirty, &bdobj->potentially_dirty);
io->end(io, 0); io->end(io, 0);

View File

@ -358,12 +358,12 @@ static inline int _cas_detect_blk_type(const char *path, uint8_t *type,
struct block_device *bdev; struct block_device *bdev;
char holder[] = "CAS DETECT\n"; char holder[] = "CAS DETECT\n";
bdev = OPEN_BDEV_EXCLUSIVE(path, FMODE_READ, holder); bdev = blkdev_get_by_path(path, (FMODE_EXCL|FMODE_READ), holder);
if (IS_ERR(bdev)) if (IS_ERR(bdev))
return -OCF_ERR_NOT_OPEN_EXC; return -OCF_ERR_NOT_OPEN_EXC;
ret = cas_blk_identify_type_by_bdev(bdev, type, atomic_params); ret = cas_blk_identify_type_by_bdev(bdev, type, atomic_params);
CLOSE_BDEV_EXCLUSIVE(bdev, FMODE_READ); blkdev_put(bdev, (FMODE_EXCL|FMODE_READ));
return ret; return ret;
} }
@ -437,9 +437,9 @@ int _cas_blk_identify_type(const char *path, uint8_t *type,
if (IS_ERR(file)) if (IS_ERR(file))
return -OCF_ERR_INVAL_VOLUME_TYPE; return -OCF_ERR_INVAL_VOLUME_TYPE;
if (S_ISBLK(FILE_INODE(file)->i_mode)) if (S_ISBLK(CAS_FILE_INODE(file)->i_mode))
*type = BLOCK_DEVICE_VOLUME; *type = BLOCK_DEVICE_VOLUME;
else if (S_ISCHR(FILE_INODE(file)->i_mode)) else if (S_ISCHR(CAS_FILE_INODE(file)->i_mode))
*type = NVME_CONTROLLER; *type = NVME_CONTROLLER;
else else
result = -OCF_ERR_INVAL_VOLUME_TYPE; result = -OCF_ERR_INVAL_VOLUME_TYPE;

View File

@ -11,10 +11,10 @@
static inline bool cas_blk_is_flush_io(unsigned long flags) static inline bool cas_blk_is_flush_io(unsigned long flags)
{ {
if ((flags & OCF_WRITE_FLUSH) == OCF_WRITE_FLUSH) if ((flags & CAS_WRITE_FLUSH) == CAS_WRITE_FLUSH)
return true; return true;
if ((flags & OCF_WRITE_FLUSH_FUA) == OCF_WRITE_FLUSH_FUA) if ((flags & CAS_WRITE_FLUSH_FUA) == CAS_WRITE_FLUSH_FUA)
return true; return true;
return false; return false;

View File

@ -198,7 +198,7 @@ static void cas_bd_io_end(struct ocf_io *io, int error)
/* /*
* *
*/ */
DECLARE_BLOCK_CALLBACK(cas_bd_io_end, struct bio *bio, CAS_DECLARE_BLOCK_CALLBACK(cas_bd_io_end, struct bio *bio,
unsigned int bytes_done, int error) unsigned int bytes_done, int error)
{ {
struct ocf_io *io; struct ocf_io *io;
@ -208,11 +208,11 @@ DECLARE_BLOCK_CALLBACK(cas_bd_io_end, struct bio *bio,
BUG_ON(!bio); BUG_ON(!bio);
BUG_ON(!bio->bi_private); BUG_ON(!bio->bi_private);
BLOCK_CALLBACK_INIT(bio); CAS_BLOCK_CALLBACK_INIT(bio);
io = bio->bi_private; io = bio->bi_private;
bdobj = bd_object(io->volume); bdobj = bd_object(io->volume);
BUG_ON(!bdobj); BUG_ON(!bdobj);
err = BLOCK_CALLBACK_ERROR(bio, error); err = CAS_BLOCK_CALLBACK_ERROR(bio, error);
bdio = cas_io_to_blkio(io); bdio = cas_io_to_blkio(io);
BUG_ON(!bdio); BUG_ON(!bdio);
@ -235,13 +235,13 @@ DECLARE_BLOCK_CALLBACK(cas_bd_io_end, struct bio *bio,
} }
} }
out: out:
if (err == -EOPNOTSUPP && (BIO_OP_FLAGS(bio) & CAS_BIO_DISCARD)) if (err == -EOPNOTSUPP && (CAS_BIO_OP_FLAGS(bio) & CAS_BIO_DISCARD))
err = 0; err = 0;
cas_bd_io_end(io, err); cas_bd_io_end(io, err);
bio_put(bio); bio_put(bio);
BLOCK_CALLBACK_RETURN(); CAS_BLOCK_CALLBACK_RETURN();
} }
static void block_dev_submit_flush(struct ocf_io *io) static void block_dev_submit_flush(struct ocf_io *io)
@ -274,7 +274,7 @@ static void block_dev_submit_flush(struct ocf_io *io)
goto out; goto out;
} }
if (!CHECK_QUEUE_FLUSH(q)) { if (!CAS_CHECK_QUEUE_FLUSH(q)) {
/* This block device does not support flush, call back */ /* This block device does not support flush, call back */
atomic_sub(blkio->dirty, &bdobj->potentially_dirty); atomic_sub(blkio->dirty, &bdobj->potentially_dirty);
goto out; goto out;
@ -289,12 +289,12 @@ static void block_dev_submit_flush(struct ocf_io *io)
blkio->dir = io->dir; blkio->dir = io->dir;
bio->bi_end_io = REFER_BLOCK_CALLBACK(cas_bd_io_end); bio->bi_end_io = CAS_REFER_BLOCK_CALLBACK(cas_bd_io_end);
CAS_BIO_SET_DEV(bio, bdev); CAS_BIO_SET_DEV(bio, bdev);
bio->bi_private = io; bio->bi_private = io;
atomic_inc(&blkio->rq_remaning); atomic_inc(&blkio->rq_remaning);
cas_submit_bio(OCF_WRITE_FLUSH, bio); cas_submit_bio(CAS_WRITE_FLUSH, bio);
out: out:
cas_bd_io_end(io, blkio->error); cas_bd_io_end(io, blkio->error);
@ -374,11 +374,11 @@ void block_dev_submit_discard(struct ocf_io *io)
} }
CAS_BIO_SET_DEV(bio, bd); CAS_BIO_SET_DEV(bio, bd);
BIO_BISECTOR(bio) = start; CAS_BIO_BISECTOR(bio) = start;
BIO_BISIZE(bio) = bio_sects << SECTOR_SHIFT; CAS_BIO_BISIZE(bio) = bio_sects << SECTOR_SHIFT;
bio->bi_next = NULL; bio->bi_next = NULL;
bio->bi_private = io; bio->bi_private = io;
bio->bi_end_io = REFER_BLOCK_CALLBACK(cas_bd_io_end); bio->bi_end_io = CAS_REFER_BLOCK_CALLBACK(cas_bd_io_end);
atomic_inc(&blkio->rq_remaning); atomic_inc(&blkio->rq_remaning);
cas_submit_bio(CAS_BIO_DISCARD, bio); cas_submit_bio(CAS_BIO_DISCARD, bio);
@ -479,12 +479,11 @@ static void block_dev_submit_io(struct ocf_io *io)
/* Setup BIO */ /* Setup BIO */
CAS_BIO_SET_DEV(bio, bdobj->btm_bd); CAS_BIO_SET_DEV(bio, bdobj->btm_bd);
BIO_BISECTOR(bio) = addr / SECTOR_SIZE; CAS_BIO_BISECTOR(bio) = addr / SECTOR_SIZE;
bio->bi_next = NULL; bio->bi_next = NULL;
bio->bi_private = io; bio->bi_private = io;
BIO_OP_FLAGS(bio) |= io->flags; CAS_BIO_OP_FLAGS(bio) |= io->flags;
BIO_SET_RW_FLAGS(bio); bio->bi_end_io = CAS_REFER_BLOCK_CALLBACK(cas_bd_io_end);
bio->bi_end_io = REFER_BLOCK_CALLBACK(cas_bd_io_end);
/* Add pages */ /* Add pages */
while (cas_io_iter_is_next(iter) && bytes) { while (cas_io_iter_is_next(iter) && bytes) {
@ -588,7 +587,7 @@ int block_dev_try_get_io_class(struct bio *bio, int *io_class)
{ {
struct ocf_io *io; struct ocf_io *io;
if (bio->bi_end_io != REFER_BLOCK_CALLBACK(cas_bd_io_end)) if (bio->bi_end_io != CAS_REFER_BLOCK_CALLBACK(cas_bd_io_end))
return -1; return -1;
io = bio->bi_private; io = bio->bi_private;

View File

@ -5,7 +5,7 @@
#include "cas_cache.h" #include "cas_cache.h"
#define BLK_RQ_POS(rq) (BIO_BISECTOR((rq)->bio)) #define BLK_RQ_POS(rq) (CAS_BIO_BISECTOR((rq)->bio))
#define BLK_RQ_BYTES(rq) blk_rq_bytes(rq) #define BLK_RQ_BYTES(rq) blk_rq_bytes(rq)
extern u32 use_io_scheduler; extern u32 use_io_scheduler;
@ -24,7 +24,7 @@ static inline bool _blockdev_can_handle_rq(struct request *rq)
{ {
int error = 0; int error = 0;
if (unlikely(!is_rq_type_fs(rq))) if (unlikely(!cas_is_rq_type_fs(rq)))
error = __LINE__; error = __LINE__;
if (unlikely(rq->next_rq)) if (unlikely(rq->next_rq))
@ -104,7 +104,7 @@ void block_dev_complete_bio_fast(struct ocf_io *io, int error)
_blockdev_end_io_acct(bio, data->start_time); _blockdev_end_io_acct(bio, data->start_time);
BIO_ENDIO(bio, BIO_BISIZE(bio), error); CAS_BIO_ENDIO(bio, CAS_BIO_BISIZE(bio), error);
ocf_io_put(io); ocf_io_put(io);
cas_free_blk_data(data); cas_free_blk_data(data);
} }
@ -113,7 +113,7 @@ void block_dev_complete_bio_discard(struct ocf_io *io, int error)
{ {
struct bio *bio = io->priv1; struct bio *bio = io->priv1;
BIO_ENDIO(bio, BIO_BISIZE(bio), error); CAS_BIO_ENDIO(bio, CAS_BIO_BISIZE(bio), error);
ocf_io_put(io); ocf_io_put(io);
} }
@ -161,7 +161,7 @@ bool _blockdev_is_request_barier(struct request *rq)
struct bio *i_bio = rq->bio; struct bio *i_bio = rq->bio;
for_each_bio(i_bio) { for_each_bio(i_bio) {
if (CHECK_BARRIER(i_bio)) if (CAS_CHECK_BARRIER(i_bio))
return true; return true;
} }
return false; return false;
@ -186,13 +186,13 @@ static int _blockdev_alloc_many_requests(ocf_core_t core,
bio = rq->bio; bio = rq->bio;
for_each_bio(bio) { for_each_bio(bio) {
/* Setup BIO flags */ /* Setup BIO flags */
if (CAS_IS_WRITE_FLUSH_FUA(BIO_OP_FLAGS(bio))) { if (CAS_IS_WRITE_FLUSH_FUA(CAS_BIO_OP_FLAGS(bio))) {
/* FLUSH and FUA */ /* FLUSH and FUA */
flags = OCF_WRITE_FLUSH_FUA; flags = CAS_WRITE_FLUSH_FUA;
} else if (CAS_IS_WRITE_FUA(BIO_OP_FLAGS(bio))) { } else if (CAS_IS_WRITE_FUA(CAS_BIO_OP_FLAGS(bio))) {
/* FUA */ /* FUA */
flags = OCF_WRITE_FUA; flags = CAS_WRITE_FUA;
} else if (CAS_IS_WRITE_FLUSH(BIO_OP_FLAGS(bio))) { } else if (CAS_IS_WRITE_FLUSH(CAS_BIO_OP_FLAGS(bio))) {
/* FLUSH - It shall be handled in request handler */ /* FLUSH - It shall be handled in request handler */
error = -EINVAL; error = -EINVAL;
break; break;
@ -220,8 +220,8 @@ static int _blockdev_alloc_many_requests(ocf_core_t core,
data->io = sub_io; data->io = sub_io;
ocf_io_configure(sub_io, BIO_BISECTOR(bio) << SECTOR_SHIFT, ocf_io_configure(sub_io, CAS_BIO_BISECTOR(bio) << SECTOR_SHIFT,
BIO_BISIZE(bio), (bio_data_dir(bio) == READ) ? CAS_BIO_BISIZE(bio), (bio_data_dir(bio) == READ) ?
OCF_READ : OCF_WRITE, OCF_READ : OCF_WRITE,
cas_cls_classify(cache, bio), flags); cas_cls_classify(cache, bio), flags);
@ -294,7 +294,7 @@ static int _blkdev_handle_flush_request(struct request *rq, ocf_core_t core)
if (!io) if (!io)
return -ENOMEM; return -ENOMEM;
ocf_io_configure(io, 0, 0, OCF_WRITE, 0, OCF_WRITE_FLUSH); ocf_io_configure(io, 0, 0, OCF_WRITE, 0, CAS_WRITE_FLUSH);
ocf_io_set_queue(io, cache_priv->io_queues[smp_processor_id()]); ocf_io_set_queue(io, cache_priv->io_queues[smp_processor_id()]);
ocf_io_set_cmpl(io, rq, NULL, block_dev_complete_flush); ocf_io_set_cmpl(io, rq, NULL, block_dev_complete_flush);
@ -359,8 +359,8 @@ static uint32_t _blkdev_scan_request(ocf_cache_t cache, struct request *rq,
* request, and prevent nvme driver from splitting requests. * request, and prevent nvme driver from splitting requests.
* For large requests, nvme splitting causes stack overrun. * For large requests, nvme splitting causes stack overrun.
*/ */
if (!_bvec_is_mergeable(SEGMENT_BVEC(bvec_prev), if (!_bvec_is_mergeable(CAS_SEGMENT_BVEC(bvec_prev),
SEGMENT_BVEC(bvec))) { CAS_SEGMENT_BVEC(bvec))) {
*single_io = false; *single_io = false;
continue; continue;
} }
@ -404,13 +404,13 @@ static int _blkdev_handle_request(struct request *rq, ocf_core_t core)
return -ENOTSUPP; return -ENOTSUPP;
} }
if ((rq->cmd_flags & REQ_FUA) && RQ_IS_FLUSH(rq)) { if ((rq->cmd_flags & REQ_FUA) && CAS_RQ_IS_FLUSH(rq)) {
/* FLUSH and FUA */ /* FLUSH and FUA */
master_flags = OCF_WRITE_FLUSH_FUA; master_flags = CAS_WRITE_FLUSH_FUA;
} else if (rq->cmd_flags & REQ_FUA) { } else if (rq->cmd_flags & REQ_FUA) {
/* FUA */ /* FUA */
master_flags = OCF_WRITE_FUA; master_flags = CAS_WRITE_FUA;
} else if (RQ_IS_FLUSH(rq)) { } else if (CAS_RQ_IS_FLUSH(rq)) {
/* FLUSH */ /* FLUSH */
return _blkdev_handle_flush_request(rq, core); return _blkdev_handle_flush_request(rq, core);
} }
@ -422,7 +422,7 @@ static int _blkdev_handle_request(struct request *rq, ocf_core_t core)
} }
ocf_io_configure(io, BLK_RQ_POS(rq) << SECTOR_SHIFT, BLK_RQ_BYTES(rq), ocf_io_configure(io, BLK_RQ_POS(rq) << SECTOR_SHIFT, BLK_RQ_BYTES(rq),
(RQ_DATA_DIR(rq) == RQ_DATA_DIR_WR) ? (rq_data_dir(rq) == CAS_RQ_DATA_DIR_WR) ?
OCF_WRITE : OCF_READ, OCF_WRITE : OCF_READ,
cas_cls_classify(cache, rq->bio), master_flags); cas_cls_classify(cache, rq->bio), master_flags);
@ -506,10 +506,10 @@ static int _blkdev_handle_request(struct request *rq, ocf_core_t core)
static inline int _blkdev_can_hndl_bio(struct bio *bio) static inline int _blkdev_can_hndl_bio(struct bio *bio)
{ {
if (CHECK_BARRIER(bio)) { if (CAS_CHECK_BARRIER(bio)) {
CAS_PRINT_RL(KERN_WARNING CAS_PRINT_RL(KERN_WARNING
"special bio was sent, not supported!\n"); "special bio was sent, not supported!\n");
BIO_ENDIO(bio, BIO_BISIZE(bio), -EOPNOTSUPP); CAS_BIO_ENDIO(bio, CAS_BIO_BISIZE(bio), -EOPNOTSUPP);
return -ENOTSUPP; return -ENOTSUPP;
} }
@ -518,13 +518,13 @@ static inline int _blkdev_can_hndl_bio(struct bio *bio)
static inline bool _blkdev_is_flush_fua_bio(struct bio *bio) static inline bool _blkdev_is_flush_fua_bio(struct bio *bio)
{ {
if (CAS_IS_WRITE_FLUSH_FUA(BIO_OP_FLAGS(bio))) { if (CAS_IS_WRITE_FLUSH_FUA(CAS_BIO_OP_FLAGS(bio))) {
/* FLUSH and FUA */ /* FLUSH and FUA */
return true; return true;
} else if (CAS_IS_WRITE_FUA(BIO_OP_FLAGS(bio))) { } else if (CAS_IS_WRITE_FUA(CAS_BIO_OP_FLAGS(bio))) {
/* FUA */ /* FUA */
return true; return true;
} else if (CAS_IS_WRITE_FLUSH(BIO_OP_FLAGS(bio))) { } else if (CAS_IS_WRITE_FLUSH(CAS_BIO_OP_FLAGS(bio))) {
/* FLUSH */ /* FLUSH */
return true; return true;
@ -552,8 +552,8 @@ void _blockdev_set_exported_object_flush_fua(ocf_core_t core)
exp_q = casdisk_functions.casdsk_exp_obj_get_queue(bd_core_vol->dsk); exp_q = casdisk_functions.casdsk_exp_obj_get_queue(bd_core_vol->dsk);
cache_q = casdisk_functions.casdsk_disk_get_queue(bd_cache_vol->dsk); cache_q = casdisk_functions.casdsk_disk_get_queue(bd_cache_vol->dsk);
flush = (CHECK_QUEUE_FLUSH(core_q) || CHECK_QUEUE_FLUSH(cache_q)); flush = (CAS_CHECK_QUEUE_FLUSH(core_q) || CAS_CHECK_QUEUE_FLUSH(cache_q));
fua = (CHECK_QUEUE_FUA(core_q) || CHECK_QUEUE_FUA(cache_q)); fua = (CAS_CHECK_QUEUE_FUA(core_q) || CAS_CHECK_QUEUE_FUA(cache_q));
cas_set_queue_flush_fua(exp_q, flush, fua); cas_set_queue_flush_fua(exp_q, flush, fua);
#endif #endif
@ -658,7 +658,7 @@ static int _blockdev_set_geometry(struct casdsk_disk *dsk, void *private)
blk_queue_stack_limits(exp_q, core_q); blk_queue_stack_limits(exp_q, core_q);
/* We don't want to receive splitted requests*/ /* We don't want to receive splitted requests*/
SET_QUEUE_CHUNK_SECTORS(exp_q, 0); CAS_SET_QUEUE_CHUNK_SECTORS(exp_q, 0);
_blockdev_set_exported_object_flush_fua(core); _blockdev_set_exported_object_flush_fua(core);
@ -712,11 +712,11 @@ static void _blockdev_make_request_discard(struct casdsk_disk *dsk,
if (!io) { if (!io) {
CAS_PRINT_RL(KERN_CRIT CAS_PRINT_RL(KERN_CRIT
"Out of memory. Ending IO processing.\n"); "Out of memory. Ending IO processing.\n");
BIO_ENDIO(bio, BIO_BISIZE(bio), -ENOMEM); CAS_BIO_ENDIO(bio, CAS_BIO_BISIZE(bio), -ENOMEM);
return; return;
} }
ocf_io_configure(io, BIO_BISECTOR(bio) << SECTOR_SHIFT, BIO_BISIZE(bio), ocf_io_configure(io, CAS_BIO_BISECTOR(bio) << SECTOR_SHIFT, CAS_BIO_BISIZE(bio),
0, 0, 0); 0, 0, 0);
ocf_io_set_queue(io, cache_priv->io_queues[smp_processor_id()]); ocf_io_set_queue(io, cache_priv->io_queues[smp_processor_id()]);
@ -754,18 +754,18 @@ static int _blockdev_make_request_fast(struct casdsk_disk *dsk,
return CASDSK_BIO_HANDLED; return CASDSK_BIO_HANDLED;
} }
if (unlikely(BIO_BISIZE(bio) == 0)) { if (unlikely(CAS_BIO_BISIZE(bio) == 0)) {
CAS_PRINT_RL(KERN_ERR CAS_PRINT_RL(KERN_ERR
"Not able to handle empty BIO, flags = " "Not able to handle empty BIO, flags = "
BIO_OP_FLAGS_FORMAT "\n", BIO_OP_FLAGS(bio)); CAS_BIO_OP_FLAGS_FORMAT "\n", CAS_BIO_OP_FLAGS(bio));
BIO_ENDIO(bio, BIO_BISIZE(bio), -EINVAL); CAS_BIO_ENDIO(bio, CAS_BIO_BISIZE(bio), -EINVAL);
return CASDSK_BIO_HANDLED; return CASDSK_BIO_HANDLED;
} }
data = cas_alloc_blk_data(bio_segments(bio), GFP_ATOMIC); data = cas_alloc_blk_data(bio_segments(bio), GFP_ATOMIC);
if (!data) { if (!data) {
CAS_PRINT_RL(KERN_CRIT "BIO data vector allocation error\n"); CAS_PRINT_RL(KERN_CRIT "BIO data vector allocation error\n");
BIO_ENDIO(bio, BIO_BISIZE(bio), -ENOMEM); CAS_BIO_ENDIO(bio, CAS_BIO_BISIZE(bio), -ENOMEM);
return CASDSK_BIO_HANDLED; return CASDSK_BIO_HANDLED;
} }
@ -778,11 +778,11 @@ static int _blockdev_make_request_fast(struct casdsk_disk *dsk,
if (!io) { if (!io) {
printk(KERN_CRIT "Out of memory. Ending IO processing.\n"); printk(KERN_CRIT "Out of memory. Ending IO processing.\n");
cas_free_blk_data(data); cas_free_blk_data(data);
BIO_ENDIO(bio, BIO_BISIZE(bio), -ENOMEM); CAS_BIO_ENDIO(bio, CAS_BIO_BISIZE(bio), -ENOMEM);
return CASDSK_BIO_HANDLED; return CASDSK_BIO_HANDLED;
} }
ocf_io_configure(io, BIO_BISECTOR(bio) << SECTOR_SHIFT, BIO_BISIZE(bio), ocf_io_configure(io, CAS_BIO_BISECTOR(bio) << SECTOR_SHIFT, CAS_BIO_BISIZE(bio),
(bio_data_dir(bio) == READ) ? OCF_READ : OCF_WRITE, (bio_data_dir(bio) == READ) ? OCF_READ : OCF_WRITE,
cas_cls_classify(cache, bio), 0); cas_cls_classify(cache, bio), 0);
@ -790,7 +790,7 @@ static int _blockdev_make_request_fast(struct casdsk_disk *dsk,
if (ret < 0) { if (ret < 0) {
ocf_io_put(io); ocf_io_put(io);
cas_free_blk_data(data); cas_free_blk_data(data);
BIO_ENDIO(bio, BIO_BISIZE(bio), -EINVAL); CAS_BIO_ENDIO(bio, CAS_BIO_BISIZE(bio), -EINVAL);
return CASDSK_BIO_HANDLED; return CASDSK_BIO_HANDLED;
} }

View File

@ -120,25 +120,25 @@ static inline void _casdsk_exp_obj_handle_bio_att(struct casdsk_disk *dsk,
dsk->exp_obj->mk_rq_fn(q, bio); dsk->exp_obj->mk_rq_fn(q, bio);
} }
DECLARE_BLOCK_CALLBACK(_casdsk_exp_obj_bio_pt_io, struct bio *bio, CAS_DECLARE_BLOCK_CALLBACK(_casdsk_exp_obj_bio_pt_io, struct bio *bio,
unsigned int bytes_done, int error) unsigned int bytes_done, int error)
{ {
struct casdsk_exp_obj_pt_io_ctx *io; struct casdsk_exp_obj_pt_io_ctx *io;
BUG_ON(!bio); BUG_ON(!bio);
BLOCK_CALLBACK_INIT(bio); CAS_BLOCK_CALLBACK_INIT(bio);
io = bio->bi_private; io = bio->bi_private;
BUG_ON(!io); BUG_ON(!io);
BIO_ENDIO(io->bio, BIO_BISIZE(io->bio), CAS_BIO_ENDIO(io->bio, CAS_BIO_BISIZE(io->bio),
BLOCK_CALLBACK_ERROR(bio, error)); CAS_BLOCK_CALLBACK_ERROR(bio, error));
if (atomic_dec_return(&io->dsk->exp_obj->pt_ios) < 0) if (atomic_dec_return(&io->dsk->exp_obj->pt_ios) < 0)
BUG(); BUG();
bio_put(bio); bio_put(bio);
kmem_cache_free(casdsk_module->pt_io_ctx_cache, io); kmem_cache_free(casdsk_module->pt_io_ctx_cache, io);
BLOCK_CALLBACK_RETURN(); CAS_BLOCK_CALLBACK_RETURN();
} }
static inline void _casdsk_exp_obj_handle_bio_pt(struct casdsk_disk *dsk, static inline void _casdsk_exp_obj_handle_bio_pt(struct casdsk_disk *dsk,
@ -150,14 +150,14 @@ static inline void _casdsk_exp_obj_handle_bio_pt(struct casdsk_disk *dsk,
io = kmem_cache_zalloc(casdsk_module->pt_io_ctx_cache, GFP_ATOMIC); io = kmem_cache_zalloc(casdsk_module->pt_io_ctx_cache, GFP_ATOMIC);
if (!io) { if (!io) {
BIO_ENDIO(bio, BIO_BISIZE(bio), -ENOMEM); CAS_BIO_ENDIO(bio, CAS_BIO_BISIZE(bio), -ENOMEM);
return; return;
} }
cloned_bio = cas_bio_clone(bio, GFP_ATOMIC); cloned_bio = cas_bio_clone(bio, GFP_ATOMIC);
if (!cloned_bio) { if (!cloned_bio) {
kmem_cache_free(casdsk_module->pt_io_ctx_cache, io); kmem_cache_free(casdsk_module->pt_io_ctx_cache, io);
BIO_ENDIO(bio, BIO_BISIZE(bio), -ENOMEM); CAS_BIO_ENDIO(bio, CAS_BIO_BISIZE(bio), -ENOMEM);
return; return;
} }
@ -168,8 +168,8 @@ static inline void _casdsk_exp_obj_handle_bio_pt(struct casdsk_disk *dsk,
CAS_BIO_SET_DEV(cloned_bio, casdsk_disk_get_blkdev(dsk)); CAS_BIO_SET_DEV(cloned_bio, casdsk_disk_get_blkdev(dsk));
cloned_bio->bi_private = io; cloned_bio->bi_private = io;
cloned_bio->bi_end_io = REFER_BLOCK_CALLBACK(_casdsk_exp_obj_bio_pt_io); cloned_bio->bi_end_io = CAS_REFER_BLOCK_CALLBACK(_casdsk_exp_obj_bio_pt_io);
cas_submit_bio(BIO_OP_FLAGS(cloned_bio), cloned_bio); cas_submit_bio(CAS_BIO_OP_FLAGS(cloned_bio), cloned_bio);
} }
static inline void _casdsk_exp_obj_handle_bio(struct casdsk_disk *dsk, static inline void _casdsk_exp_obj_handle_bio(struct casdsk_disk *dsk,
@ -181,7 +181,7 @@ static inline void _casdsk_exp_obj_handle_bio(struct casdsk_disk *dsk,
else if (casdsk_disk_is_pt(dsk)) else if (casdsk_disk_is_pt(dsk))
_casdsk_exp_obj_handle_bio_pt(dsk, q, bio); _casdsk_exp_obj_handle_bio_pt(dsk, q, bio);
else if (casdsk_disk_is_shutdown(dsk)) else if (casdsk_disk_is_shutdown(dsk))
BIO_ENDIO(bio, BIO_BISIZE(bio), -EIO); CAS_BIO_ENDIO(bio, CAS_BIO_BISIZE(bio), -EIO);
else else
BUG(); BUG();
} }