提交 b278db77 编写于 作者: X Xu Wei 提交者: Yang Yingliang

Make compile successful when CONFIG_BCACHE is not set.

euleros inclusion
category: feature
bugzilla: https://bugzilla.openeuler.org/show_bug.cgi?id=327
CVE: NA

When kernel config don't enbale CONFIG_BCACHE, compiling bcache module will
fail. This patch add the judgment for CONFIG_BCACHE macro to make sure
compiling bcache module success.
Signed-off-by: Nqinghaixiang <xuweiqhx@163.com>
Signed-off-by: NXu Wei <xuwei56@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
Reviewed-by: NLi Ruilin <liruilin4@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 59a67a69
...@@ -370,6 +370,7 @@ unsigned int bch_get_congested(struct cache_set *c) ...@@ -370,6 +370,7 @@ unsigned int bch_get_congested(struct cache_set *c)
return i > 0 ? i : 1; return i > 0 ? i : 1;
} }
#if IS_ENABLED(CONFIG_BCACHE)
static void add_sequential(struct task_struct *t) static void add_sequential(struct task_struct *t)
{ {
ewma_add(t->sequential_io_avg, ewma_add(t->sequential_io_avg,
...@@ -377,6 +378,7 @@ static void add_sequential(struct task_struct *t) ...@@ -377,6 +378,7 @@ static void add_sequential(struct task_struct *t)
t->sequential_io = 0; t->sequential_io = 0;
} }
#endif
static struct hlist_head *iohash(struct cached_dev *dc, uint64_t k) static struct hlist_head *iohash(struct cached_dev *dc, uint64_t k)
{ {
...@@ -388,7 +390,9 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio) ...@@ -388,7 +390,9 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio)
struct cache_set *c = dc->disk.c; struct cache_set *c = dc->disk.c;
unsigned int mode = cache_mode(dc); unsigned int mode = cache_mode(dc);
unsigned int sectors, congested = bch_get_congested(c); unsigned int sectors, congested = bch_get_congested(c);
#if IS_ENABLED(CONFIG_BCACHE)
struct task_struct *task = current; struct task_struct *task = current;
#endif
struct io *i; struct io *i;
if (test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags) || if (test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags) ||
...@@ -443,7 +447,9 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio) ...@@ -443,7 +447,9 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio)
i = list_first_entry(&dc->io_lru, struct io, lru); i = list_first_entry(&dc->io_lru, struct io, lru);
#if IS_ENABLED(CONFIG_BCACHE)
add_sequential(task); add_sequential(task);
#endif
i->sequential = 0; i->sequential = 0;
found: found:
if (i->sequential + bio->bi_iter.bi_size > i->sequential) if (i->sequential + bio->bi_iter.bi_size > i->sequential)
...@@ -451,7 +457,9 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio) ...@@ -451,7 +457,9 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio)
i->last = bio_end_sector(bio); i->last = bio_end_sector(bio);
i->jiffies = jiffies + msecs_to_jiffies(5000); i->jiffies = jiffies + msecs_to_jiffies(5000);
#if IS_ENABLED(CONFIG_BCACHE)
task->sequential_io = i->sequential; task->sequential_io = i->sequential;
#endif
hlist_del(&i->hash); hlist_del(&i->hash);
hlist_add_head(&i->hash, iohash(dc, i->last)); hlist_add_head(&i->hash, iohash(dc, i->last));
...@@ -459,8 +467,12 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio) ...@@ -459,8 +467,12 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio)
spin_unlock(&dc->io_lock); spin_unlock(&dc->io_lock);
#if IS_ENABLED(CONFIG_BCACHE)
sectors = max(task->sequential_io, sectors = max(task->sequential_io,
task->sequential_io_avg) >> 9; task->sequential_io_avg) >> 9;
#else
sectors = i->sequential >> 9;
#endif
if (dc->sequential_cutoff && if (dc->sequential_cutoff &&
sectors >= dc->sequential_cutoff >> 9) { sectors >= dc->sequential_cutoff >> 9) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册