--- linux-4.9.37/fs/buffer.c 2017-07-12 16:42:41.000000000 +0300 +++ linux-4.9.y/fs/buffer.c 2021-06-07 13:01:34.000000000 +0300 @@ -1276,10 +1276,17 @@ */ static void bh_lru_install(struct buffer_head *bh) { - struct buffer_head *evictee = NULL; +#ifdef CONFIG_GOKE_MC + struct buffer_head *evictee = bh; + struct bh_lru *b; + int i; +#else + struct buffer_head *evictee = NULL; +#endif check_irqs_on(); bh_lru_lock(); +#ifndef CONFIG_GOKE_MC if (__this_cpu_read(bh_lrus.bhs[0]) != bh) { struct buffer_head *bhs[BH_LRU_SIZE]; int in; @@ -1310,6 +1317,22 @@ if (evictee) __brelse(evictee); +#endif + +#ifdef CONFIG_GOKE_MC + b = this_cpu_ptr(&bh_lrus); + for (i = 0; i < BH_LRU_SIZE; i++) { + swap(evictee, b->bhs[i]); + if (evictee == bh) { + bh_lru_unlock(); + return; + } + } + + get_bh(bh); + bh_lru_unlock(); + brelse(evictee); +#endif } /*