aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColy Li <colyli@suse.de>2018-05-22 21:43:14 +0800
committerColy Li <colyli@suse.de>2018-05-22 21:43:14 +0800
commit6349398f35519d3bdc65db3efb97d3635daf8438 (patch)
treed1b6c31507f535d7955c8ac4bd92d7acef2352d2
parent35a60ab7128513a522445166773fd5ea6bdc9552 (diff)
downloadbcache-patches-6349398f35519d3bdc65db3efb97d3635daf8438.tar.gz
sort for-next, for-review, for-test
-rw-r--r--for-next/0000-cover-letter.patch25
-rw-r--r--for-next/0001-bcache-stop-bcache-device-when-backing-device-is-off.patch4
-rw-r--r--for-next/0003-bcache-Move-couple-of-string-arrays-to-sysfs.c.patch (renamed from for-next/0004-bcache-Move-couple-of-string-arrays-to-sysfs.c.patch)6
-rw-r--r--for-next/0003-bcache-Split-out-crc64-to-library.patch452
-rw-r--r--for-next/0004-bcache-Move-couple-of-functions-to-sysfs.c.patch (renamed from for-next/0005-bcache-Move-couple-of-functions-to-sysfs.c.patch)6
-rw-r--r--for-next/0005-bcache-Replace-bch_read_string_list-by-__sysfs_match.patch (renamed from for-next/0006-bcache-Replace-bch_read_string_list-by-__sysfs_match.patch)22
-rw-r--r--for-review/0001-lib-crc64.c-add-license-information.patch32
-rw-r--r--for-review/0002-bcache-do-not-check-return-value-of-debugfs_create_d.patch129
-rw-r--r--for-review/0003-bcache-display-rate-debug-parameters-to-0-when-write.patch71
-rw-r--r--for-review/0004-bcache-avoid-unncessary-cache-prefetch-bch_btree_nod.patch52
-rw-r--r--for-review/0005-bcache-add-a-comment-in-register_bdev.patch24
-rw-r--r--for-review/0006-bcache-fix-mistaken-code-comments-in-struct-cache.patch27
-rw-r--r--for-review/0007-bcache-fix-mistaken-comments-in-bch_keylist_realloc.patch25
-rw-r--r--for-review/0008-bcache-add-code-comments-for-bset.c.patch149
-rw-r--r--for-review/0009-bcache-initiate-bcache_debug-to-NULL.patch39
-rw-r--r--for-review/old/0001-bcache-add-a-comment-in-register_bdev.patch (renamed from for-test/0001-bcache-add-a-comment-in-register_bdev.patch)0
-rw-r--r--for-review/old/0001-bcache-avoid-unncessary-cache-prefetch-bch_btree_nod.patch (renamed from for-test/0001-bcache-avoid-unncessary-cache-prefetch-bch_btree_nod.patch)0
-rw-r--r--for-review/old/0001-bcache-do-not-check-return-value-of-debugfs_create_d.patch129
-rw-r--r--for-review/old/0001-bcache-fix-mistaken-code-comments-in-struct-cache.patch (renamed from for-test/0001-bcache-fix-mistaken-code-comments-in-struct-cache.patch)0
-rw-r--r--for-review/old/0001-bcache-fix-mistaken-comments-in-bch_keylist_realloc.patch (renamed from for-test/0001-bcache-fix-mistaken-comments-in-bch_keylist_realloc.patch)0
-rw-r--r--for-review/old/0001-bcache-initiate-bcache_debug-to-NULL.patch (renamed from for-test/0001-bcache-initiate-bcache_debug-to-NULL.patch)0
-rw-r--r--for-review/old/0001-lib-crc64.c-add-license-information.patch32
-rw-r--r--for-review/old/0002-bcache-add-code-comments-for-bset.c.patch (renamed from for-test/0002-bcache-add-code-comments-for-bset.c.patch)0
-rw-r--r--for-review/old/0002-bcache-display-rate-debug-parameters-to-0-when-write.patch (renamed from for-next/0002-bcache-display-rate-debug-parameters-to-0-when-write.patch)0
24 files changed, 740 insertions, 484 deletions
diff --git a/for-next/0000-cover-letter.patch b/for-next/0000-cover-letter.patch
index c0f470f..9ceddb0 100644
--- a/for-next/0000-cover-letter.patch
+++ b/for-next/0000-cover-letter.patch
@@ -1,48 +1,47 @@
-From 7eb6f521e353310e2c409cd1167a260ef14f0043 Mon Sep 17 00:00:00 2001
+From d770559a20a94b95c1ae345620fe926154c652a4 Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
-Date: Mon, 14 May 2018 22:28:21 +0800
-Subject: [PATCH 0/6] bcache patches for 4.18
+Date: Tue, 22 May 2018 16:42:50 +0800
+Subject: [PATCH 0/5] bcache patches for 4.18
Hi Jens,
-We don't have too many changes in bcache for 4.18.
+Here is the first wave bcache patches for linux v4.18.
Andy Shevchenko contributes a patch to move crc64 calculation into
lib/crc64.c, and this is the first public crc64 implementation in Linux
kernel. He also contributes other 3 nice code clean up patches.
-There are patches from me, the first is about backing device failure, and
-the second is a code cleanup patch for writeback debug information.
+The patch from me is about backing device failure and reviewed by Hannnes.
-Please pick them for 4.18. Thanks in advance.
+So far there are still several patches are waiting for review, once they
+have peer reviewer I will post them in following waves.
+
+Please pick the first wave for 4.18. Thanks in advance.
Coly Li
---
-
Andy Shevchenko (4):
bcache: Split out crc64 to library
bcache: Move couple of string arrays to sysfs.c
bcache: Move couple of functions to sysfs.c
bcache: Replace bch_read_string_list() by __sysfs_match_string()
-Coly Li (2):
+Coly Li (1):
bcache: stop bcache device when backing device is offline
- bcache: display rate debug parameters to 0 when writeback is not
- running
drivers/md/bcache/Kconfig | 1 +
drivers/md/bcache/bcache.h | 6 +-
drivers/md/bcache/btree.c | 2 +-
drivers/md/bcache/request.c | 2 +-
drivers/md/bcache/super.c | 75 ++++++++++++++------
- drivers/md/bcache/sysfs.c | 77 ++++++++++++++------
+ drivers/md/bcache/sysfs.c | 51 ++++++++++----
drivers/md/bcache/util.c | 166 --------------------------------------------
drivers/md/bcache/util.h | 9 +--
include/linux/crc64.h | 9 +++
lib/Kconfig | 8 +++
lib/Makefile | 1 +
lib/crc64.c | 137 ++++++++++++++++++++++++++++++++++++
- 12 files changed, 272 insertions(+), 221 deletions(-)
+ 12 files changed, 256 insertions(+), 211 deletions(-)
create mode 100644 include/linux/crc64.h
create mode 100644 lib/crc64.c
diff --git a/for-next/0001-bcache-stop-bcache-device-when-backing-device-is-off.patch b/for-next/0001-bcache-stop-bcache-device-when-backing-device-is-off.patch
index d3c43fe..304bc80 100644
--- a/for-next/0001-bcache-stop-bcache-device-when-backing-device-is-off.patch
+++ b/for-next/0001-bcache-stop-bcache-device-when-backing-device-is-off.patch
@@ -1,7 +1,7 @@
-From 09fd66ede248eee3bf40181794ee04a8a5fdb020 Mon Sep 17 00:00:00 2001
+From 46cdc46d3bf31cc42a9d1488daa3b857a32ab07f Mon Sep 17 00:00:00 2001
From: Coly Li <colyli@suse.de>
Date: Mon, 5 Feb 2018 23:52:40 +0800
-Subject: [PATCH 1/6] bcache: stop bcache device when backing device is offline
+Subject: [PATCH 1/5] bcache: stop bcache device when backing device is offline
Currently bcache does not handle backing device failure, if backing
device is offline and disconnected from system, its bcache device can still
diff --git a/for-next/0004-bcache-Move-couple-of-string-arrays-to-sysfs.c.patch b/for-next/0003-bcache-Move-couple-of-string-arrays-to-sysfs.c.patch
index 81f628b..2bfeeb1 100644
--- a/for-next/0004-bcache-Move-couple-of-string-arrays-to-sysfs.c.patch
+++ b/for-next/0003-bcache-Move-couple-of-string-arrays-to-sysfs.c.patch
@@ -1,7 +1,7 @@
-From 085720832c32d9625b3c2cc039364462483f8b44 Mon Sep 17 00:00:00 2001
+From 40ace42dc6a0eb0a66ab40741f55db7911ea225e Mon Sep 17 00:00:00 2001
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Fri, 4 May 2018 23:49:14 +0300
-Subject: [PATCH 4/6] bcache: Move couple of string arrays to sysfs.c
+Subject: [PATCH 3/5] bcache: Move couple of string arrays to sysfs.c
There is couple of string arrays that are used exclusively in sysfs.c.
Move it to there and make them static.
@@ -61,7 +61,7 @@ index 12d45dc8e5da..88538c70eb51 100644
struct mutex bch_register_lock;
LIST_HEAD(bch_cache_sets);
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
-index 6ef6616fb76e..70bc5e376a7e 100644
+index dfeef583ee50..0275450a0da9 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -16,6 +16,24 @@
diff --git a/for-next/0003-bcache-Split-out-crc64-to-library.patch b/for-next/0003-bcache-Split-out-crc64-to-library.patch
deleted file mode 100644
index 67a579e..0000000
--- a/for-next/0003-bcache-Split-out-crc64-to-library.patch
+++ /dev/null
@@ -1,452 +0,0 @@
-From 6add8d6a30932a98838be150e3b6b44bd41949db Mon Sep 17 00:00:00 2001
-From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-Date: Fri, 4 May 2018 19:00:15 +0300
-Subject: [PATCH 3/6] bcache: Split out crc64 to library
-
-For generic use split out crc64 code to a separate module
-in the library folder.
-
-No functional change intended.
-
-Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-Signed-off-by: Coly Li <colyli@suse.de>
----
- drivers/md/bcache/Kconfig | 1 +
- drivers/md/bcache/bcache.h | 2 +-
- drivers/md/bcache/btree.c | 2 +-
- drivers/md/bcache/request.c | 2 +-
- drivers/md/bcache/super.c | 4 +-
- drivers/md/bcache/util.c | 131 ------------------------------------------
- drivers/md/bcache/util.h | 4 +-
- include/linux/crc64.h | 9 +++
- lib/Kconfig | 8 +++
- lib/Makefile | 1 +
- lib/crc64.c | 137 ++++++++++++++++++++++++++++++++++++++++++++
- 11 files changed, 162 insertions(+), 139 deletions(-)
- create mode 100644 include/linux/crc64.h
- create mode 100644 lib/crc64.c
-
-diff --git a/drivers/md/bcache/Kconfig b/drivers/md/bcache/Kconfig
-index 4d200883c505..e94179e7fd76 100644
---- a/drivers/md/bcache/Kconfig
-+++ b/drivers/md/bcache/Kconfig
-@@ -1,6 +1,7 @@
-
- config BCACHE
- tristate "Block device as cache"
-+ select CRC64
- ---help---
- Allows a block device to be used as cache for other devices; uses
- a btree for indexing and the layout is optimized for SSDs.
-diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
-index ba98547c4ca0..a425fb49fd47 100644
---- a/drivers/md/bcache/bcache.h
-+++ b/drivers/md/bcache/bcache.h
-@@ -803,7 +803,7 @@ static inline bool ptr_available(struct cache_set *c, const struct bkey *k,
- * jset: The checksum is _always_ the first 8 bytes of these structs
- */
- #define csum_set(i) \
-- bch_crc64(((void *) (i)) + sizeof(uint64_t), \
-+ crc64(((void *) (i)) + sizeof(uint64_t), \
- ((void *) bset_bkey_last(i)) - \
- (((void *) (i)) + sizeof(uint64_t)))
-
-diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
-index 17936b2dc7d6..c239862127e7 100644
---- a/drivers/md/bcache/btree.c
-+++ b/drivers/md/bcache/btree.c
-@@ -194,7 +194,7 @@ static uint64_t btree_csum_set(struct btree *b, struct bset *i)
- uint64_t crc = b->key.ptr[0];
- void *data = (void *) i + 8, *end = bset_bkey_last(i);
-
-- crc = bch_crc64_update(crc, data, end - data);
-+ crc = crc64_update(crc, data, end - data);
- return crc ^ 0xffffffffffffffffULL;
- }
-
-diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
-index 8e3e8655ed63..65dbc0ccd913 100644
---- a/drivers/md/bcache/request.c
-+++ b/drivers/md/bcache/request.c
-@@ -45,7 +45,7 @@ static void bio_csum(struct bio *bio, struct bkey *k)
-
- bio_for_each_segment(bv, bio, iter) {
- void *d = kmap(bv.bv_page) + bv.bv_offset;
-- csum = bch_crc64_update(csum, d, bv.bv_len);
-+ csum = crc64_update(csum, d, bv.bv_len);
- kunmap(bv.bv_page);
- }
-
-diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
-index a16b5b1df62a..12d45dc8e5da 100644
---- a/drivers/md/bcache/super.c
-+++ b/drivers/md/bcache/super.c
-@@ -567,7 +567,7 @@ void bch_prio_write(struct cache *ca)
-
- p->next_bucket = ca->prio_buckets[i + 1];
- p->magic = pset_magic(&ca->sb);
-- p->csum = bch_crc64(&p->magic, bucket_bytes(ca) - 8);
-+ p->csum = crc64(&p->magic, bucket_bytes(ca) - 8);
-
- bucket = bch_bucket_alloc(ca, RESERVE_PRIO, true);
- BUG_ON(bucket == -1);
-@@ -617,7 +617,7 @@ static void prio_read(struct cache *ca, uint64_t bucket)
-
- prio_io(ca, bucket, REQ_OP_READ, 0);
-
-- if (p->csum != bch_crc64(&p->magic, bucket_bytes(ca) - 8))
-+ if (p->csum != crc64(&p->magic, bucket_bytes(ca) - 8))
- pr_warn("bad csum reading priorities");
-
- if (p->magic != pset_magic(&ca->sb))
-diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c
-index 74febd5230df..cdf822c0ac1b 100644
---- a/drivers/md/bcache/util.c
-+++ b/drivers/md/bcache/util.c
-@@ -314,134 +314,3 @@ int bch_bio_alloc_pages(struct bio *bio, gfp_t gfp_mask)
-
- return 0;
- }
--
--/*
-- * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group (Any
-- * use permitted, subject to terms of PostgreSQL license; see.)
--
-- * If we have a 64-bit integer type, then a 64-bit CRC looks just like the
-- * usual sort of implementation. (See Ross Williams' excellent introduction
-- * A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS, available from
-- * ftp://ftp.rocksoft.com/papers/crc_v3.txt or several other net sites.)
-- * If we have no working 64-bit type, then fake it with two 32-bit registers.
-- *
-- * The present implementation is a normal (not "reflected", in Williams'
-- * terms) 64-bit CRC, using initial all-ones register contents and a final
-- * bit inversion. The chosen polynomial is borrowed from the DLT1 spec
-- * (ECMA-182, available from http://www.ecma.ch/ecma1/STAND/ECMA-182.HTM):
-- *
-- * x^64 + x^62 + x^57 + x^55 + x^54 + x^53 + x^52 + x^47 + x^46 + x^45 +
-- * x^40 + x^39 + x^38 + x^37 + x^35 + x^33 + x^32 + x^31 + x^29 + x^27 +
-- * x^24 + x^23 + x^22 + x^21 + x^19 + x^17 + x^13 + x^12 + x^10 + x^9 +
-- * x^7 + x^4 + x + 1
--*/
--
--static const uint64_t crc_table[256] = {
-- 0x0000000000000000ULL, 0x42F0E1EBA9EA3693ULL, 0x85E1C3D753D46D26ULL,
-- 0xC711223CFA3E5BB5ULL, 0x493366450E42ECDFULL, 0x0BC387AEA7A8DA4CULL,
-- 0xCCD2A5925D9681F9ULL, 0x8E224479F47CB76AULL, 0x9266CC8A1C85D9BEULL,
-- 0xD0962D61B56FEF2DULL, 0x17870F5D4F51B498ULL, 0x5577EEB6E6BB820BULL,
-- 0xDB55AACF12C73561ULL, 0x99A54B24BB2D03F2ULL, 0x5EB4691841135847ULL,
-- 0x1C4488F3E8F96ED4ULL, 0x663D78FF90E185EFULL, 0x24CD9914390BB37CULL,
-- 0xE3DCBB28C335E8C9ULL, 0xA12C5AC36ADFDE5AULL, 0x2F0E1EBA9EA36930ULL,
-- 0x6DFEFF5137495FA3ULL, 0xAAEFDD6DCD770416ULL, 0xE81F3C86649D3285ULL,
-- 0xF45BB4758C645C51ULL, 0xB6AB559E258E6AC2ULL, 0x71BA77A2DFB03177ULL,
-- 0x334A9649765A07E4ULL, 0xBD68D2308226B08EULL, 0xFF9833DB2BCC861DULL,
-- 0x388911E7D1F2DDA8ULL, 0x7A79F00C7818EB3BULL, 0xCC7AF1FF21C30BDEULL,
-- 0x8E8A101488293D4DULL, 0x499B3228721766F8ULL, 0x0B6BD3C3DBFD506BULL,
-- 0x854997BA2F81E701ULL, 0xC7B97651866BD192ULL, 0x00A8546D7C558A27ULL,
-- 0x4258B586D5BFBCB4ULL, 0x5E1C3D753D46D260ULL, 0x1CECDC9E94ACE4F3ULL,
-- 0xDBFDFEA26E92BF46ULL, 0x990D1F49C77889D5ULL, 0x172F5B3033043EBFULL,
-- 0x55DFBADB9AEE082CULL, 0x92CE98E760D05399ULL, 0xD03E790CC93A650AULL,
-- 0xAA478900B1228E31ULL, 0xE8B768EB18C8B8A2ULL, 0x2FA64AD7E2F6E317ULL,
-- 0x6D56AB3C4B1CD584ULL, 0xE374EF45BF6062EEULL, 0xA1840EAE168A547DULL,
-- 0x66952C92ECB40FC8ULL, 0x2465CD79455E395BULL, 0x3821458AADA7578FULL,
-- 0x7AD1A461044D611CULL, 0xBDC0865DFE733AA9ULL, 0xFF3067B657990C3AULL,
-- 0x711223CFA3E5BB50ULL, 0x33E2C2240A0F8DC3ULL, 0xF4F3E018F031D676ULL,
-- 0xB60301F359DBE0E5ULL, 0xDA050215EA6C212FULL, 0x98F5E3FE438617BCULL,
-- 0x5FE4C1C2B9B84C09ULL, 0x1D14202910527A9AULL, 0x93366450E42ECDF0ULL,
-- 0xD1C685BB4DC4FB63ULL, 0x16D7A787B7FAA0D6ULL, 0x5427466C1E109645ULL,
-- 0x4863CE9FF6E9F891ULL, 0x0A932F745F03CE02ULL, 0xCD820D48A53D95B7ULL,
-- 0x8F72ECA30CD7A324ULL, 0x0150A8DAF8AB144EULL, 0x43A04931514122DDULL,
-- 0x84B16B0DAB7F7968ULL, 0xC6418AE602954FFBULL, 0xBC387AEA7A8DA4C0ULL,
-- 0xFEC89B01D3679253ULL, 0x39D9B93D2959C9E6ULL, 0x7B2958D680B3FF75ULL,
-- 0xF50B1CAF74CF481FULL, 0xB7FBFD44DD257E8CULL, 0x70EADF78271B2539ULL,
-- 0x321A3E938EF113AAULL, 0x2E5EB66066087D7EULL, 0x6CAE578BCFE24BEDULL,
-- 0xABBF75B735DC1058ULL, 0xE94F945C9C3626CBULL, 0x676DD025684A91A1ULL,
-- 0x259D31CEC1A0A732ULL, 0xE28C13F23B9EFC87ULL, 0xA07CF2199274CA14ULL,
-- 0x167FF3EACBAF2AF1ULL, 0x548F120162451C62ULL, 0x939E303D987B47D7ULL,
-- 0xD16ED1D631917144ULL, 0x5F4C95AFC5EDC62EULL, 0x1DBC74446C07F0BDULL,
-- 0xDAAD56789639AB08ULL, 0x985DB7933FD39D9BULL, 0x84193F60D72AF34FULL,
-- 0xC6E9DE8B7EC0C5DCULL, 0x01F8FCB784FE9E69ULL, 0x43081D5C2D14A8FAULL,
-- 0xCD2A5925D9681F90ULL, 0x8FDAB8CE70822903ULL, 0x48CB9AF28ABC72B6ULL,
-- 0x0A3B7B1923564425ULL, 0x70428B155B4EAF1EULL, 0x32B26AFEF2A4998DULL,
-- 0xF5A348C2089AC238ULL, 0xB753A929A170F4ABULL, 0x3971ED50550C43C1ULL,
-- 0x7B810CBBFCE67552ULL, 0xBC902E8706D82EE7ULL, 0xFE60CF6CAF321874ULL,
-- 0xE224479F47CB76A0ULL, 0xA0D4A674EE214033ULL, 0x67C58448141F1B86ULL,
-- 0x253565A3BDF52D15ULL, 0xAB1721DA49899A7FULL, 0xE9E7C031E063ACECULL,
-- 0x2EF6E20D1A5DF759ULL, 0x6C0603E6B3B7C1CAULL, 0xF6FAE5C07D3274CDULL,
-- 0xB40A042BD4D8425EULL, 0x731B26172EE619EBULL, 0x31EBC7FC870C2F78ULL,
-- 0xBFC9838573709812ULL, 0xFD39626EDA9AAE81ULL, 0x3A28405220A4F534ULL,
-- 0x78D8A1B9894EC3A7ULL, 0x649C294A61B7AD73ULL, 0x266CC8A1C85D9BE0ULL,
-- 0xE17DEA9D3263C055ULL, 0xA38D0B769B89F6C6ULL, 0x2DAF4F0F6FF541ACULL,
-- 0x6F5FAEE4C61F773FULL, 0xA84E8CD83C212C8AULL, 0xEABE6D3395CB1A19ULL,
-- 0x90C79D3FEDD3F122ULL, 0xD2377CD44439C7B1ULL, 0x15265EE8BE079C04ULL,
-- 0x57D6BF0317EDAA97ULL, 0xD9F4FB7AE3911DFDULL, 0x9B041A914A7B2B6EULL,
-- 0x5C1538ADB04570DBULL, 0x1EE5D94619AF4648ULL, 0x02A151B5F156289CULL,
-- 0x4051B05E58BC1E0FULL, 0x87409262A28245BAULL, 0xC5B073890B687329ULL,
-- 0x4B9237F0FF14C443ULL, 0x0962D61B56FEF2D0ULL, 0xCE73F427ACC0A965ULL,
-- 0x8C8315CC052A9FF6ULL, 0x3A80143F5CF17F13ULL, 0x7870F5D4F51B4980ULL,
-- 0xBF61D7E80F251235ULL, 0xFD913603A6CF24A6ULL, 0x73B3727A52B393CCULL,
-- 0x31439391FB59A55FULL, 0xF652B1AD0167FEEAULL, 0xB4A25046A88DC879ULL,
-- 0xA8E6D8B54074A6ADULL, 0xEA16395EE99E903EULL, 0x2D071B6213A0CB8BULL,
-- 0x6FF7FA89BA4AFD18ULL, 0xE1D5BEF04E364A72ULL, 0xA3255F1BE7DC7CE1ULL,
-- 0x64347D271DE22754ULL, 0x26C49CCCB40811C7ULL, 0x5CBD6CC0CC10FAFCULL,
-- 0x1E4D8D2B65FACC6FULL, 0xD95CAF179FC497DAULL, 0x9BAC4EFC362EA149ULL,
-- 0x158E0A85C2521623ULL, 0x577EEB6E6BB820B0ULL, 0x906FC95291867B05ULL,
-- 0xD29F28B9386C4D96ULL, 0xCEDBA04AD0952342ULL, 0x8C2B41A1797F15D1ULL,
-- 0x4B3A639D83414E64ULL, 0x09CA82762AAB78F7ULL, 0x87E8C60FDED7CF9DULL,
-- 0xC51827E4773DF90EULL, 0x020905D88D03A2BBULL, 0x40F9E43324E99428ULL,
-- 0x2CFFE7D5975E55E2ULL, 0x6E0F063E3EB46371ULL, 0xA91E2402C48A38C4ULL,
-- 0xEBEEC5E96D600E57ULL, 0x65CC8190991CB93DULL, 0x273C607B30F68FAEULL,
-- 0xE02D4247CAC8D41BULL, 0xA2DDA3AC6322E288ULL, 0xBE992B5F8BDB8C5CULL,
-- 0xFC69CAB42231BACFULL, 0x3B78E888D80FE17AULL, 0x7988096371E5D7E9ULL,
-- 0xF7AA4D1A85996083ULL, 0xB55AACF12C735610ULL, 0x724B8ECDD64D0DA5ULL,
-- 0x30BB6F267FA73B36ULL, 0x4AC29F2A07BFD00DULL, 0x08327EC1AE55E69EULL,
-- 0xCF235CFD546BBD2BULL, 0x8DD3BD16FD818BB8ULL, 0x03F1F96F09FD3CD2ULL,
-- 0x41011884A0170A41ULL, 0x86103AB85A2951F4ULL, 0xC4E0DB53F3C36767ULL,
-- 0xD8A453A01B3A09B3ULL, 0x9A54B24BB2D03F20ULL, 0x5D45907748EE6495ULL,
-- 0x1FB5719CE1045206ULL, 0x919735E51578E56CULL, 0xD367D40EBC92D3FFULL,
-- 0x1476F63246AC884AULL, 0x568617D9EF46BED9ULL, 0xE085162AB69D5E3CULL,
-- 0xA275F7C11F7768AFULL, 0x6564D5FDE549331AULL, 0x279434164CA30589ULL,
-- 0xA9B6706FB8DFB2E3ULL, 0xEB46918411358470ULL, 0x2C57B3B8EB0BDFC5ULL,
-- 0x6EA7525342E1E956ULL, 0x72E3DAA0AA188782ULL, 0x30133B4B03F2B111ULL,
-- 0xF7021977F9CCEAA4ULL, 0xB5F2F89C5026DC37ULL, 0x3BD0BCE5A45A6B5DULL,
-- 0x79205D0E0DB05DCEULL, 0xBE317F32F78E067BULL, 0xFCC19ED95E6430E8ULL,
-- 0x86B86ED5267CDBD3ULL, 0xC4488F3E8F96ED40ULL, 0x0359AD0275A8B6F5ULL,
-- 0x41A94CE9DC428066ULL, 0xCF8B0890283E370CULL, 0x8D7BE97B81D4019FULL,
-- 0x4A6ACB477BEA5A2AULL, 0x089A2AACD2006CB9ULL, 0x14DEA25F3AF9026DULL,
-- 0x562E43B4931334FEULL, 0x913F6188692D6F4BULL, 0xD3CF8063C0C759D8ULL,
-- 0x5DEDC41A34BBEEB2ULL, 0x1F1D25F19D51D821ULL, 0xD80C07CD676F8394ULL,
-- 0x9AFCE626CE85B507ULL,
--};
--
--uint64_t bch_crc64_update(uint64_t crc, const void *_data, size_t len)
--{
-- const unsigned char *data = _data;
--
-- while (len--) {
-- int i = ((int) (crc >> 56) ^ *data++) & 0xFF;
-- crc = crc_table[i] ^ (crc << 8);
-- }
--
-- return crc;
--}
--
--uint64_t bch_crc64(const void *data, size_t len)
--{
-- uint64_t crc = 0xffffffffffffffffULL;
--
-- crc = bch_crc64_update(crc, data, len);
--
-- return crc ^ 0xffffffffffffffffULL;
--}
-diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h
-index 268024529edd..bd70f1c6a176 100644
---- a/drivers/md/bcache/util.h
-+++ b/drivers/md/bcache/util.h
-@@ -4,6 +4,7 @@
- #define _BCACHE_UTIL_H
-
- #include <linux/blkdev.h>
-+#include <linux/crc64.h>
- #include <linux/errno.h>
- #include <linux/kernel.h>
- #include <linux/sched/clock.h>
-@@ -567,7 +568,4 @@ static inline sector_t bdev_sectors(struct block_device *bdev)
- return bdev->bd_inode->i_size >> 9;
- }
-
--uint64_t bch_crc64_update(uint64_t, const void *, size_t);
--uint64_t bch_crc64(const void *, size_t);
--
- #endif /* _BCACHE_UTIL_H */
-diff --git a/include/linux/crc64.h b/include/linux/crc64.h
-new file mode 100644
-index 000000000000..2a8f6005e8ee
---- /dev/null
-+++ b/include/linux/crc64.h
-@@ -0,0 +1,9 @@
-+#ifndef _LINUX_CRC64_H
-+#define _LINUX_CRC64_H
-+
-+#include <linux/types.h>
-+
-+uint64_t crc64_update(uint64_t crc, const void *data, size_t len);
-+uint64_t crc64(const void *data, size_t len);
-+
-+#endif /* _LINUX_CRC64_H */
-diff --git a/lib/Kconfig b/lib/Kconfig
-index 5fe577673b98..fa69362fba01 100644
---- a/lib/Kconfig
-+++ b/lib/Kconfig
-@@ -170,6 +170,14 @@ config CRC32_BIT
-
- endchoice
-
-+config CRC64
-+ tristate "CRC64 functions"
-+ help
-+ This option is provided for the case where no in-kernel-tree
-+ modules require CRC64 functions, but a module built outside
-+ the kernel tree does. Such modules that use library CRC64
-+ functions require M here.
-+
- config CRC4
- tristate "CRC4 functions"
- help
-diff --git a/lib/Makefile b/lib/Makefile
-index ce20696d5a92..32d574d89059 100644
---- a/lib/Makefile
-+++ b/lib/Makefile
-@@ -108,6 +108,7 @@ obj-$(CONFIG_CRC_T10DIF)+= crc-t10dif.o
- obj-$(CONFIG_CRC_ITU_T) += crc-itu-t.o
- obj-$(CONFIG_CRC32) += crc32.o
- obj-$(CONFIG_CRC32_SELFTEST) += crc32test.o
-+obj-$(CONFIG_CRC64) += crc64.o
- obj-$(CONFIG_CRC4) += crc4.o
- obj-$(CONFIG_CRC7) += crc7.o
- obj-$(CONFIG_LIBCRC32C) += libcrc32c.o
-diff --git a/lib/crc64.c b/lib/crc64.c
-new file mode 100644
-index 000000000000..ed0ffac7b26a
---- /dev/null
-+++ b/lib/crc64.c
-@@ -0,0 +1,137 @@
-+/*
-+ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group (Any
-+ * use permitted, subject to terms of PostgreSQL license; see.)
-+
-+ * If we have a 64-bit integer type, then a 64-bit CRC looks just like the
-+ * usual sort of implementation. (See Ross Williams' excellent introduction
-+ * A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS, available from
-+ * ftp://ftp.rocksoft.com/papers/crc_v3.txt or several other net sites.)
-+ * If we have no working 64-bit type, then fake it with two 32-bit registers.
-+ *
-+ * The present implementation is a normal (not "reflected", in Williams'
-+ * terms) 64-bit CRC, using initial all-ones register contents and a final
-+ * bit inversion. The chosen polynomial is borrowed from the DLT1 spec
-+ * (ECMA-182, available from http://www.ecma.ch/ecma1/STAND/ECMA-182.HTM):
-+ *
-+ * x^64 + x^62 + x^57 + x^55 + x^54 + x^53 + x^52 + x^47 + x^46 + x^45 +
-+ * x^40 + x^39 + x^38 + x^37 + x^35 + x^33 + x^32 + x^31 + x^29 + x^27 +
-+ * x^24 + x^23 + x^22 + x^21 + x^19 + x^17 + x^13 + x^12 + x^10 + x^9 +
-+ * x^7 + x^4 + x + 1
-+*/
-+
-+#include <linux/crc64.h>
-+#include <linux/module.h>
-+
-+static const uint64_t crc_table[256] = {
-+ 0x0000000000000000ULL, 0x42F0E1EBA9EA3693ULL, 0x85E1C3D753D46D26ULL,
-+ 0xC711223CFA3E5BB5ULL, 0x493366450E42ECDFULL, 0x0BC387AEA7A8DA4CULL,
-+ 0xCCD2A5925D9681F9ULL, 0x8E224479F47CB76AULL, 0x9266CC8A1C85D9BEULL,
-+ 0xD0962D61B56FEF2DULL, 0x17870F5D4F51B498ULL, 0x5577EEB6E6BB820BULL,
-+ 0xDB55AACF12C73561ULL, 0x99A54B24BB2D03F2ULL, 0x5EB4691841135847ULL,
-+ 0x1C4488F3E8F96ED4ULL, 0x663D78FF90E185EFULL, 0x24CD9914390BB37CULL,
-+ 0xE3DCBB28C335E8C9ULL, 0xA12C5AC36ADFDE5AULL, 0x2F0E1EBA9EA36930ULL,
-+ 0x6DFEFF5137495FA3ULL, 0xAAEFDD6DCD770416ULL, 0xE81F3C86649D3285ULL,
-+ 0xF45BB4758C645C51ULL, 0xB6AB559E258E6AC2ULL, 0x71BA77A2DFB03177ULL,
-+ 0x334A9649765A07E4ULL, 0xBD68D2308226B08EULL, 0xFF9833DB2BCC861DULL,
-+ 0x388911E7D1F2DDA8ULL, 0x7A79F00C7818EB3BULL, 0xCC7AF1FF21C30BDEULL,
-+ 0x8E8A101488293D4DULL, 0x499B3228721766F8ULL, 0x0B6BD3C3DBFD506BULL,
-+ 0x854997BA2F81E701ULL, 0xC7B97651866BD192ULL, 0x00A8546D7C558A27ULL,
-+ 0x4258B586D5BFBCB4ULL, 0x5E1C3D753D46D260ULL, 0x1CECDC9E94ACE4F3ULL,
-+ 0xDBFDFEA26E92BF46ULL, 0x990D1F49C77889D5ULL, 0x172F5B3033043EBFULL,
-+ 0x55DFBADB9AEE082CULL, 0x92CE98E760D05399ULL, 0xD03E790CC93A650AULL,
-+ 0xAA478900B1228E31ULL, 0xE8B768EB18C8B8A2ULL, 0x2FA64AD7E2F6E317ULL,
-+ 0x6D56AB3C4B1CD584ULL, 0xE374EF45BF6062EEULL, 0xA1840EAE168A547DULL,
-+ 0x66952C92ECB40FC8ULL, 0x2465CD79455E395BULL, 0x3821458AADA7578FULL,
-+ 0x7AD1A461044D611CULL, 0xBDC0865DFE733AA9ULL, 0xFF3067B657990C3AULL,
-+ 0x711223CFA3E5BB50ULL, 0x33E2C2240A0F8DC3ULL, 0xF4F3E018F031D676ULL,
-+ 0xB60301F359DBE0E5ULL, 0xDA050215EA6C212FULL, 0x98F5E3FE438617BCULL,
-+ 0x5FE4C1C2B9B84C09ULL, 0x1D14202910527A9AULL, 0x93366450E42ECDF0ULL,
-+ 0xD1C685BB4DC4FB63ULL, 0x16D7A787B7FAA0D6ULL, 0x5427466C1E109645ULL,
-+ 0x4863CE9FF6E9F891ULL, 0x0A932F745F03CE02ULL, 0xCD820D48A53D95B7ULL,
-+ 0x8F72ECA30CD7A324ULL, 0x0150A8DAF8AB144EULL, 0x43A04931514122DDULL,
-+ 0x84B16B0DAB7F7968ULL, 0xC6418AE602954FFBULL, 0xBC387AEA7A8DA4C0ULL,
-+ 0xFEC89B01D3679253ULL, 0x39D9B93D2959C9E6ULL, 0x7B2958D680B3FF75ULL,
-+ 0xF50B1CAF74CF481FULL, 0xB7FBFD44DD257E8CULL, 0x70EADF78271B2539ULL,
-+ 0x321A3E938EF113AAULL, 0x2E5EB66066087D7EULL, 0x6CAE578BCFE24BEDULL,
-+ 0xABBF75B735DC1058ULL, 0xE94F945C9C3626CBULL, 0x676DD025684A91A1ULL,
-+ 0x259D31CEC1A0A732ULL, 0xE28C13F23B9EFC87ULL, 0xA07CF2199274CA14ULL,
-+ 0x167FF3EACBAF2AF1ULL, 0x548F120162451C62ULL, 0x939E303D987B47D7ULL,
-+ 0xD16ED1D631917144ULL, 0x5F4C95AFC5EDC62EULL, 0x1DBC74446C07F0BDULL,
-+ 0xDAAD56789639AB08ULL, 0x985DB7933FD39D9BULL, 0x84193F60D72AF34FULL,
-+ 0xC6E9DE8B7EC0C5DCULL, 0x01F8FCB784FE9E69ULL, 0x43081D5C2D14A8FAULL,
-+ 0xCD2A5925D9681F90ULL, 0x8FDAB8CE70822903ULL, 0x48CB9AF28ABC72B6ULL,
-+ 0x0A3B7B1923564425ULL, 0x70428B155B4EAF1EULL, 0x32B26AFEF2A4998DULL,
-+ 0xF5A348C2089AC238ULL, 0xB753A929A170F4ABULL, 0x3971ED50550C43C1ULL,
-+ 0x7B810CBBFCE67552ULL, 0xBC902E8706D82EE7ULL, 0xFE60CF6CAF321874ULL,
-+ 0xE224479F47CB76A0ULL, 0xA0D4A674EE214033ULL, 0x67C58448141F1B86ULL,
-+ 0x253565A3BDF52D15ULL, 0xAB1721DA49899A7FULL, 0xE9E7C031E063ACECULL,
-+ 0x2EF6E20D1A5DF759ULL, 0x6C0603E6B3B7C1CAULL, 0xF6FAE5C07D3274CDULL,
-+ 0xB40A042BD4D8425EULL, 0x731B26172EE619EBULL, 0x31EBC7FC870C2F78ULL,
-+ 0xBFC9838573709812ULL, 0xFD39626EDA9AAE81ULL, 0x3A28405220A4F534ULL,
-+ 0x78D8A1B9894EC3A7ULL, 0x649C294A61B7AD73ULL, 0x266CC8A1C85D9BE0ULL,
-+ 0xE17DEA9D3263C055ULL, 0xA38D0B769B89F6C6ULL, 0x2DAF4F0F6FF541ACULL,
-+ 0x6F5FAEE4C61F773FULL, 0xA84E8CD83C212C8AULL, 0xEABE6D3395CB1A19ULL,
-+ 0x90C79D3FEDD3F122ULL, 0xD2377CD44439C7B1ULL, 0x15265EE8BE079C04ULL,
-+ 0x57D6BF0317EDAA97ULL, 0xD9F4FB7AE3911DFDULL, 0x9B041A914A7B2B6EULL,
-+ 0x5C1538ADB04570DBULL, 0x1EE5D94619AF4648ULL, 0x02A151B5F156289CULL,
-+ 0x4051B05E58BC1E0FULL, 0x87409262A28245BAULL, 0xC5B073890B687329ULL,
-+ 0x4B9237F0FF14C443ULL, 0x0962D61B56FEF2D0ULL, 0xCE73F427ACC0A965ULL,
-+ 0x8C8315CC052A9FF6ULL, 0x3A80143F5CF17F13ULL, 0x7870F5D4F51B4980ULL,
-+ 0xBF61D7E80F251235ULL, 0xFD913603A6CF24A6ULL, 0x73B3727A52B393CCULL,
-+ 0x31439391FB59A55FULL, 0xF652B1AD0167FEEAULL, 0xB4A25046A88DC879ULL,
-+ 0xA8E6D8B54074A6ADULL, 0xEA16395EE99E903EULL, 0x2D071B6213A0CB8BULL,
-+ 0x6FF7FA89BA4AFD18ULL, 0xE1D5BEF04E364A72ULL, 0xA3255F1BE7DC7CE1ULL,
-+ 0x64347D271DE22754ULL, 0x26C49CCCB40811C7ULL, 0x5CBD6CC0CC10FAFCULL,
-+ 0x1E4D8D2B65FACC6FULL, 0xD95CAF179FC497DAULL, 0x9BAC4EFC362EA149ULL,
-+ 0x158E0A85C2521623ULL, 0x577EEB6E6BB820B0ULL, 0x906FC95291867B05ULL,
-+ 0xD29F28B9386C4D96ULL, 0xCEDBA04AD0952342ULL, 0x8C2B41A1797F15D1ULL,
-+ 0x4B3A639D83414E64ULL, 0x09CA82762AAB78F7ULL, 0x87E8C60FDED7CF9DULL,
-+ 0xC51827E4773DF90EULL, 0x020905D88D03A2BBULL, 0x40F9E43324E99428ULL,
-+ 0x2CFFE7D5975E55E2ULL, 0x6E0F063E3EB46371ULL, 0xA91E2402C48A38C4ULL,
-+ 0xEBEEC5E96D600E57ULL, 0x65CC8190991CB93DULL, 0x273C607B30F68FAEULL,
-+ 0xE02D4247CAC8D41BULL, 0xA2DDA3AC6322E288ULL, 0xBE992B5F8BDB8C5CULL,
-+ 0xFC69CAB42231BACFULL, 0x3B78E888D80FE17AULL, 0x7988096371E5D7E9ULL,
-+ 0xF7AA4D1A85996083ULL, 0xB55AACF12C735610ULL, 0x724B8ECDD64D0DA5ULL,
-+ 0x30BB6F267FA73B36ULL, 0x4AC29F2A07BFD00DULL, 0x08327EC1AE55E69EULL,
-+ 0xCF235CFD546BBD2BULL, 0x8DD3BD16FD818BB8ULL, 0x03F1F96F09FD3CD2ULL,
-+ 0x41011884A0170A41ULL, 0x86103AB85A2951F4ULL, 0xC4E0DB53F3C36767ULL,
-+ 0xD8A453A01B3A09B3ULL, 0x9A54B24BB2D03F20ULL, 0x5D45907748EE6495ULL,
-+ 0x1FB5719CE1045206ULL, 0x919735E51578E56CULL, 0xD367D40EBC92D3FFULL,
-+ 0x1476F63246AC884AULL, 0x568617D9EF46BED9ULL, 0xE085162AB69D5E3CULL,
-+ 0xA275F7C11F7768AFULL, 0x6564D5FDE549331AULL, 0x279434164CA30589ULL,
-+ 0xA9B6706FB8DFB2E3ULL, 0xEB46918411358470ULL, 0x2C57B3B8EB0BDFC5ULL,
-+ 0x6EA7525342E1E956ULL, 0x72E3DAA0AA188782ULL, 0x30133B4B03F2B111ULL,
-+ 0xF7021977F9CCEAA4ULL, 0xB5F2F89C5026DC37ULL, 0x3BD0BCE5A45A6B5DULL,
-+ 0x79205D0E0DB05DCEULL, 0xBE317F32F78E067BULL, 0xFCC19ED95E6430E8ULL,
-+ 0x86B86ED5267CDBD3ULL, 0xC4488F3E8F96ED40ULL, 0x0359AD0275A8B6F5ULL,
-+ 0x41A94CE9DC428066ULL, 0xCF8B0890283E370CULL, 0x8D7BE97B81D4019FULL,
-+ 0x4A6ACB477BEA5A2AULL, 0x089A2AACD2006CB9ULL, 0x14DEA25F3AF9026DULL,
-+ 0x562E43B4931334FEULL, 0x913F6188692D6F4BULL, 0xD3CF8063C0C759D8ULL,
-+ 0x5DEDC41A34BBEEB2ULL, 0x1F1D25F19D51D821ULL, 0xD80C07CD676F8394ULL,
-+ 0x9AFCE626CE85B507ULL,
-+};
-+
-+uint64_t crc64_update(uint64_t crc, const void *data, size_t len)
-+{
-+ const unsigned char *_data = data;
-+
-+ while (len--) {
-+ int i = ((int) (crc >> 56) ^ *_data++) & 0xFF;
-+ crc = crc_table[i] ^ (crc << 8);
-+ }
-+
-+ return crc;
-+}
-+EXPORT_SYMBOL_GPL(crc64_update);
-+
-+uint64_t crc64(const void *data, size_t len)
-+{
-+ uint64_t crc = 0xffffffffffffffffULL;
-+
-+ crc = crc64_update(crc, data, len);
-+
-+ return crc ^ 0xffffffffffffffffULL;
-+}
-+EXPORT_SYMBOL_GPL(crc64);
-+
-+MODULE_DESCRIPTION("CRC64 calculations");
---
-2.16.3
-
diff --git a/for-next/0005-bcache-Move-couple-of-functions-to-sysfs.c.patch b/for-next/0004-bcache-Move-couple-of-functions-to-sysfs.c.patch
index ca38627..69f8b37 100644
--- a/for-next/0005-bcache-Move-couple-of-functions-to-sysfs.c.patch
+++ b/for-next/0004-bcache-Move-couple-of-functions-to-sysfs.c.patch
@@ -1,7 +1,7 @@
-From 7633adc6cebd2c731dc3288cb2c9a872e8392b29 Mon Sep 17 00:00:00 2001
+From cac31b06f08518b0f3885b67b187926a00163839 Mon Sep 17 00:00:00 2001
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Fri, 4 May 2018 23:49:15 +0300
-Subject: [PATCH 5/6] bcache: Move couple of functions to sysfs.c
+Subject: [PATCH 4/5] bcache: Move couple of functions to sysfs.c
There is couple of functions that are used exclusively in sysfs.c.
Move it to there and make them static.
@@ -19,7 +19,7 @@ Signed-off-by: Coly Li <colyli@suse.de>
3 files changed, 35 insertions(+), 40 deletions(-)
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
-index 70bc5e376a7e..09f77dc42648 100644
+index 0275450a0da9..36f4396dbd63 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -132,6 +132,41 @@ rw_attribute(btree_shrinker_disabled);
diff --git a/for-next/0006-bcache-Replace-bch_read_string_list-by-__sysfs_match.patch b/for-next/0005-bcache-Replace-bch_read_string_list-by-__sysfs_match.patch
index 033aa8b..e8751ed 100644
--- a/for-next/0006-bcache-Replace-bch_read_string_list-by-__sysfs_match.patch
+++ b/for-next/0005-bcache-Replace-bch_read_string_list-by-__sysfs_match.patch
@@ -1,7 +1,7 @@
-From 7eb6f521e353310e2c409cd1167a260ef14f0043 Mon Sep 17 00:00:00 2001
+From d770559a20a94b95c1ae345620fe926154c652a4 Mon Sep 17 00:00:00 2001
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Sat, 5 May 2018 20:59:09 +0800
-Subject: [PATCH 6/6] bcache: Replace bch_read_string_list() by
+Subject: [PATCH 5/5] bcache: Replace bch_read_string_list() by
__sysfs_match_string()
Kernel library has a common function to match user input from sysfs
@@ -15,7 +15,7 @@ Signed-off-by: Coly Li <colyli@suse.de>
1 file changed, 9 insertions(+), 35 deletions(-)
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
-index 09f77dc42648..d02dcd6d5c50 100644
+index 36f4396dbd63..8ccbc8f3b3af 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -18,7 +18,6 @@
@@ -62,7 +62,7 @@ index 09f77dc42648..d02dcd6d5c50 100644
SHOW(__bch_cached_dev)
{
struct cached_dev *dc = container_of(kobj, struct cached_dev,
-@@ -178,12 +155,12 @@ SHOW(__bch_cached_dev)
+@@ -177,12 +154,12 @@ SHOW(__bch_cached_dev)
if (attr == &sysfs_cache_mode)
return bch_snprint_string_list(buf, PAGE_SIZE,
@@ -77,7 +77,7 @@ index 09f77dc42648..d02dcd6d5c50 100644
dc->stop_when_cache_set_failed);
-@@ -312,8 +289,7 @@ STORE(__cached_dev)
+@@ -306,8 +283,7 @@ STORE(__cached_dev)
bch_cached_dev_run(dc);
if (attr == &sysfs_cache_mode) {
@@ -87,7 +87,7 @@ index 09f77dc42648..d02dcd6d5c50 100644
if (v < 0)
return v;
-@@ -324,8 +300,7 @@ STORE(__cached_dev)
+@@ -318,8 +294,7 @@ STORE(__cached_dev)
}
if (attr == &sysfs_stop_when_cache_set_failed) {
@@ -97,7 +97,7 @@ index 09f77dc42648..d02dcd6d5c50 100644
if (v < 0)
return v;
-@@ -694,6 +669,7 @@ SHOW_LOCKED(bch_cache_set)
+@@ -688,6 +663,7 @@ SHOW_LOCKED(bch_cache_set)
STORE(__bch_cache_set)
{
struct cache_set *c = container_of(kobj, struct cache_set, kobj);
@@ -105,7 +105,7 @@ index 09f77dc42648..d02dcd6d5c50 100644
if (attr == &sysfs_unregister)
bch_cache_set_unregister(c);
-@@ -757,8 +733,7 @@ STORE(__bch_cache_set)
+@@ -751,8 +727,7 @@ STORE(__bch_cache_set)
c->congested_write_threshold_us);
if (attr == &sysfs_errors) {
@@ -115,7 +115,7 @@ index 09f77dc42648..d02dcd6d5c50 100644
if (v < 0)
return v;
-@@ -773,8 +748,7 @@ STORE(__bch_cache_set)
+@@ -767,8 +742,7 @@ STORE(__bch_cache_set)
c->error_decay = strtoul_or_return(buf) / 88;
if (attr == &sysfs_io_disable) {
@@ -125,7 +125,7 @@ index 09f77dc42648..d02dcd6d5c50 100644
if (v) {
if (test_and_set_bit(CACHE_SET_IO_DISABLE,
&c->flags))
-@@ -988,6 +962,7 @@ SHOW_LOCKED(bch_cache)
+@@ -982,6 +956,7 @@ SHOW_LOCKED(bch_cache)
STORE(__bch_cache)
{
struct cache *ca = container_of(kobj, struct cache, kobj);
@@ -133,7 +133,7 @@ index 09f77dc42648..d02dcd6d5c50 100644
if (attr == &sysfs_discard) {
bool v = strtoul_or_return(buf);
-@@ -1002,8 +977,7 @@ STORE(__bch_cache)
+@@ -996,8 +971,7 @@ STORE(__bch_cache)
}
if (attr == &sysfs_cache_replacement_policy) {
diff --git a/for-review/0001-lib-crc64.c-add-license-information.patch b/for-review/0001-lib-crc64.c-add-license-information.patch
new file mode 100644
index 0000000..5457d3c
--- /dev/null
+++ b/for-review/0001-lib-crc64.c-add-license-information.patch
@@ -0,0 +1,32 @@
+From 6c8a57fa27941ea096ca525d8025718b8f837b3e Mon Sep 17 00:00:00 2001
+From: Coly Li <colyli@suse.de>
+Date: Tue, 22 May 2018 16:50:39 +0800
+Subject: [PATCH 1/9] lib/crc64.c: add license information
+
+This patch adds MODULE_LICENSE("GPL") to remove a kernel build warning
+information. Also as Andy Shevchenko suggested, adds a SPDX header into
+lib/crc64.c file.
+
+Signed-off-by: Coly Li <colyli@suse.de>
+Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+---
+ lib/crc64.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/lib/crc64.c b/lib/crc64.c
+index ed0ffac7b26a..30d1bb58dd5c 100644
+--- a/lib/crc64.c
++++ b/lib/crc64.c
+@@ -1,3 +1,4 @@
++// SPDX-License-Identifier: GPL-2.0
+ /*
+ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group (Any
+ * use permitted, subject to terms of PostgreSQL license; see.)
+@@ -135,3 +136,4 @@ uint64_t crc64(const void *data, size_t len)
+ EXPORT_SYMBOL_GPL(crc64);
+
+ MODULE_DESCRIPTION("CRC64 calculations");
++MODULE_LICENSE("GPL");
+--
+2.16.3
+
diff --git a/for-review/0002-bcache-do-not-check-return-value-of-debugfs_create_d.patch b/for-review/0002-bcache-do-not-check-return-value-of-debugfs_create_d.patch
new file mode 100644
index 0000000..95e2587
--- /dev/null
+++ b/for-review/0002-bcache-do-not-check-return-value-of-debugfs_create_d.patch
@@ -0,0 +1,129 @@
+From 82fcdaaebf8e00a4613e2611917ac08fbe4baba5 Mon Sep 17 00:00:00 2001
+From: Coly Li <colyli@suse.de>
+Date: Tue, 22 May 2018 14:29:09 +0800
+Subject: [PATCH 2/9] bcache: do not check return value of debugfs_create_dir()
+
+Greg KH suggests that normal code should not care about debugfs. Therefore
+no matter successful or failed of debugfs_create_dir() execution, it is
+unncessary to check its return value.
+
+There are two functions called debugfs_create_dir() and check the return
+value, which are bch_debug_init() and closure_debug_init(). This patch
+changes these two functions from int to void type, and ignore return values
+of debugfs_create_dir().
+
+This patch does not fix exact bug, just makes things work as they should.
+
+Signed-off-by: Coly Li <colyli@suse.de>
+Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Cc: Kai Krakow <kai@kaishome.de>
+Cc: Kent Overstreet <kent.overstreet@gmail.com>
+---
+ drivers/md/bcache/bcache.h | 2 +-
+ drivers/md/bcache/closure.c | 13 +++++++++----
+ drivers/md/bcache/closure.h | 4 ++--
+ drivers/md/bcache/debug.c | 11 ++++++-----
+ drivers/md/bcache/super.c | 4 +++-
+ 5 files changed, 21 insertions(+), 13 deletions(-)
+
+diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
+index a84fd5c32e19..9f336a2c729d 100644
+--- a/drivers/md/bcache/bcache.h
++++ b/drivers/md/bcache/bcache.h
+@@ -995,7 +995,7 @@ void bch_open_buckets_free(struct cache_set *);
+ int bch_cache_allocator_start(struct cache *ca);
+
+ void bch_debug_exit(void);
+-int bch_debug_init(struct kobject *);
++void bch_debug_init(struct kobject *);
+ void bch_request_exit(void);
+ int bch_request_init(void);
+
+diff --git a/drivers/md/bcache/closure.c b/drivers/md/bcache/closure.c
+index 0e14969182c6..618253683d40 100644
+--- a/drivers/md/bcache/closure.c
++++ b/drivers/md/bcache/closure.c
+@@ -199,11 +199,16 @@ static const struct file_operations debug_ops = {
+ .release = single_release
+ };
+
+-int __init closure_debug_init(void)
++void __init closure_debug_init(void)
+ {
+- closure_debug = debugfs_create_file("closures",
+- 0400, bcache_debug, NULL, &debug_ops);
+- return IS_ERR_OR_NULL(closure_debug);
++ if (!IS_ERR_OR_NULL(bcache_debug))
++ /*
++ * it is unnecessary to check return value of
++ * debugfs_create_file(), we should not care
++ * about this.
++ */
++ closure_debug = debugfs_create_file(
++ "closures", 0400, bcache_debug, NULL, &debug_ops);
+ }
+ #endif
+
+diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
+index 71427eb5fdae..7c2c5bc7c88b 100644
+--- a/drivers/md/bcache/closure.h
++++ b/drivers/md/bcache/closure.h
+@@ -186,13 +186,13 @@ static inline void closure_sync(struct closure *cl)
+
+ #ifdef CONFIG_BCACHE_CLOSURES_DEBUG
+
+-int closure_debug_init(void);
++void closure_debug_init(void);
+ void closure_debug_create(struct closure *cl);
+ void closure_debug_destroy(struct closure *cl);
+
+ #else
+
+-static inline int closure_debug_init(void) { return 0; }
++static inline void closure_debug_init(void) {}
+ static inline void closure_debug_create(struct closure *cl) {}
+ static inline void closure_debug_destroy(struct closure *cl) {}
+
+diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
+index d030ce3025a6..57f8f5aeee55 100644
+--- a/drivers/md/bcache/debug.c
++++ b/drivers/md/bcache/debug.c
+@@ -248,11 +248,12 @@ void bch_debug_exit(void)
+ debugfs_remove_recursive(bcache_debug);
+ }
+
+-int __init bch_debug_init(struct kobject *kobj)
++void __init bch_debug_init(struct kobject *kobj)
+ {
+- if (!IS_ENABLED(CONFIG_DEBUG_FS))
+- return 0;
+-
++ /*
++ * it is unnecessary to check return value of
++ * debugfs_create_file(), we should not care
++ * about this.
++ */
+ bcache_debug = debugfs_create_dir("bcache", NULL);
+- return IS_ERR_OR_NULL(bcache_debug);
+ }
+diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
+index 88538c70eb51..a45420fb0a84 100644
+--- a/drivers/md/bcache/super.c
++++ b/drivers/md/bcache/super.c
+@@ -2336,10 +2336,12 @@ static int __init bcache_init(void)
+ if (!(bcache_wq = alloc_workqueue("bcache", WQ_MEM_RECLAIM, 0)) ||
+ !(bcache_kobj = kobject_create_and_add("bcache", fs_kobj)) ||
+ bch_request_init() ||
+- bch_debug_init(bcache_kobj) || closure_debug_init() ||
+ sysfs_create_files(bcache_kobj, files))
+ goto err;
+
++ bch_debug_init(bcache_kobj);
++ closure_debug_init();
++
+ return 0;
+ err:
+ bcache_exit();
+--
+2.16.3
+
diff --git a/for-review/0003-bcache-display-rate-debug-parameters-to-0-when-write.patch b/for-review/0003-bcache-display-rate-debug-parameters-to-0-when-write.patch
new file mode 100644
index 0000000..4348bd9
--- /dev/null
+++ b/for-review/0003-bcache-display-rate-debug-parameters-to-0-when-write.patch
@@ -0,0 +1,71 @@
+From fe56b7c54dd05b2af3424602eec95935d9fceddc Mon Sep 17 00:00:00 2001
+From: Coly Li <colyli@suse.de>
+Date: Sat, 5 May 2018 20:52:33 +0800
+Subject: [PATCH 3/9] bcache: display rate debug parameters to 0 when writeback
+ is not running
+
+When writeback is not running, writeback rate should be 0, other value is
+misleading. And the following dyanmic writeback rate debug parameters
+should be 0 too,
+ rate, proportional, integral, change
+otherwise they are misleading when writeback is not running.
+
+Signed-off-by: Coly Li <colyli@suse.de>
+---
+ drivers/md/bcache/sysfs.c | 26 ++++++++++++++++----------
+ 1 file changed, 16 insertions(+), 10 deletions(-)
+
+diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
+index 8ccbc8f3b3af..d02dcd6d5c50 100644
+--- a/drivers/md/bcache/sysfs.c
++++ b/drivers/md/bcache/sysfs.c
+@@ -149,6 +149,7 @@ SHOW(__bch_cached_dev)
+ struct cached_dev *dc = container_of(kobj, struct cached_dev,
+ disk.kobj);
+ const char *states[] = { "no cache", "clean", "dirty", "inconsistent" };
++ int wb = dc->writeback_running;
+
+ #define var(stat) (dc->stat)
+
+@@ -170,7 +171,7 @@ SHOW(__bch_cached_dev)
+ var_printf(writeback_running, "%i");
+ var_print(writeback_delay);
+ var_print(writeback_percent);
+- sysfs_hprint(writeback_rate, dc->writeback_rate.rate << 9);
++ sysfs_hprint(writeback_rate, wb ? dc->writeback_rate.rate << 9 : 0);
+ sysfs_hprint(io_errors, atomic_read(&dc->io_errors));
+ sysfs_printf(io_error_limit, "%i", dc->error_limit);
+ sysfs_printf(io_disable, "%i", dc->io_disable);
+@@ -188,15 +189,20 @@ SHOW(__bch_cached_dev)
+ char change[20];
+ s64 next_io;
+
+- bch_hprint(rate, dc->writeback_rate.rate << 9);
+- bch_hprint(dirty, bcache_dev_sectors_dirty(&dc->disk) << 9);
+- bch_hprint(target, dc->writeback_rate_target << 9);
+- bch_hprint(proportional,dc->writeback_rate_proportional << 9);
+- bch_hprint(integral, dc->writeback_rate_integral_scaled << 9);
+- bch_hprint(change, dc->writeback_rate_change << 9);
+-
+- next_io = div64_s64(dc->writeback_rate.next - local_clock(),
+- NSEC_PER_MSEC);
++ /*
++ * Except for dirty and target, other values should
++ * be 0 if writeback is not running.
++ */
++ bch_hprint(rate, wb ? dc->writeback_rate.rate << 9 : 0);
++ bch_hprint(dirty, bcache_dev_sectors_dirty(&dc->disk) << 9);
++ bch_hprint(target, dc->writeback_rate_target << 9);
++ bch_hprint(proportional,
++ wb ? dc->writeback_rate_proportional << 9 : 0);
++ bch_hprint(integral,
++ wb ? dc->writeback_rate_integral_scaled << 9 : 0);
++ bch_hprint(change, wb ? dc->writeback_rate_change << 9 : 0);
++ next_io = wb ? div64_s64(dc->writeback_rate.next-local_clock(),
++ NSEC_PER_MSEC) : 0;
+
+ return sprintf(buf,
+ "rate:\t\t%s/sec\n"
+--
+2.16.3
+
diff --git a/for-review/0004-bcache-avoid-unncessary-cache-prefetch-bch_btree_nod.patch b/for-review/0004-bcache-avoid-unncessary-cache-prefetch-bch_btree_nod.patch
new file mode 100644
index 0000000..21a1891
--- /dev/null
+++ b/for-review/0004-bcache-avoid-unncessary-cache-prefetch-bch_btree_nod.patch
@@ -0,0 +1,52 @@
+From 01250edde7040647d26d625a764ef200c44733be Mon Sep 17 00:00:00 2001
+From: Coly Li <colyli@suse.de>
+Date: Mon, 26 Mar 2018 15:05:08 +0800
+Subject: [PATCH 4/9] bcache: avoid unncessary cache prefetch
+ bch_btree_node_get()
+
+In bch_btree_node_get() the read-in btree node will be partially
+prefetched into L1 cache for following bset iteration (if there is).
+But if the btree node read is failed, the perfetch operations will
+waste L1 cache space. This patch checkes whether read operation and
+only does cache prefetch when read I/O successed.
+
+Signed-off-by: Coly Li <colyli@suse.de>
+---
+ drivers/md/bcache/btree.c | 14 +++++++-------
+ 1 file changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
+index c239862127e7..81712b6090ba 100644
+--- a/drivers/md/bcache/btree.c
++++ b/drivers/md/bcache/btree.c
+@@ -1008,6 +1008,13 @@ struct btree *bch_btree_node_get(struct cache_set *c, struct btree_op *op,
+ BUG_ON(b->level != level);
+ }
+
++ if (btree_node_io_error(b)) {
++ rw_unlock(write, b);
++ return ERR_PTR(-EIO);
++ }
++
++ BUG_ON(!b->written);
++
+ b->parent = parent;
+ b->accessed = 1;
+
+@@ -1019,13 +1026,6 @@ struct btree *bch_btree_node_get(struct cache_set *c, struct btree_op *op,
+ for (; i <= b->keys.nsets; i++)
+ prefetch(b->keys.set[i].data);
+
+- if (btree_node_io_error(b)) {
+- rw_unlock(write, b);
+- return ERR_PTR(-EIO);
+- }
+-
+- BUG_ON(!b->written);
+-
+ return b;
+ }
+
+--
+2.16.3
+
diff --git a/for-review/0005-bcache-add-a-comment-in-register_bdev.patch b/for-review/0005-bcache-add-a-comment-in-register_bdev.patch
new file mode 100644
index 0000000..69cc96f
--- /dev/null
+++ b/for-review/0005-bcache-add-a-comment-in-register_bdev.patch
@@ -0,0 +1,24 @@
+From ff5c308373003de9621fbd15af7a9bc3e39c824b Mon Sep 17 00:00:00 2001
+From: Coly Li <colyli@suse.de>
+Date: Mon, 20 Nov 2017 16:53:48 +0800
+Subject: [PATCH 5/9] bcache: add a comment in register_bdev()
+
+---
+ drivers/md/bcache/super.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
+index a45420fb0a84..187b36ceb335 100644
+--- a/drivers/md/bcache/super.c
++++ b/drivers/md/bcache/super.c
+@@ -1287,6 +1287,7 @@ static void register_bdev(struct cache_sb *sb, struct page *sb_page,
+ pr_info("registered backing device %s", dc->backing_dev_name);
+
+ list_add(&dc->list, &uncached_devices);
++ /* attch to a matched cache set if it exists */
+ list_for_each_entry(c, &bch_cache_sets, list)
+ bch_cached_dev_attach(dc, c, NULL);
+
+--
+2.16.3
+
diff --git a/for-review/0006-bcache-fix-mistaken-code-comments-in-struct-cache.patch b/for-review/0006-bcache-fix-mistaken-code-comments-in-struct-cache.patch
new file mode 100644
index 0000000..411466f
--- /dev/null
+++ b/for-review/0006-bcache-fix-mistaken-code-comments-in-struct-cache.patch
@@ -0,0 +1,27 @@
+From a02d46668520bf5a1a2faa7802b290bf61b1cda1 Mon Sep 17 00:00:00 2001
+From: Coly Li <colyli@suse.de>
+Date: Mon, 13 Nov 2017 23:55:01 +0800
+Subject: [PATCH 6/9] bcache: fix mistaken code comments in struct cache
+
+---
+ drivers/md/bcache/bcache.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
+index 9f336a2c729d..877cc7ba60ac 100644
+--- a/drivers/md/bcache/bcache.h
++++ b/drivers/md/bcache/bcache.h
+@@ -423,8 +423,8 @@ struct cache {
+ /*
+ * When allocating new buckets, prio_write() gets first dibs - since we
+ * may not be allocate at all without writing priorities and gens.
+- * prio_buckets[] contains the last buckets we wrote priorities to (so
+- * gc can mark them as metadata), prio_next[] contains the buckets
++ * prio_last_buckets[] contains the last buckets we wrote priorities to (so
++ * gc can mark them as metadata), prio_buckets[] contains the buckets
+ * allocated for the next prio write.
+ */
+ uint64_t *prio_buckets;
+--
+2.16.3
+
diff --git a/for-review/0007-bcache-fix-mistaken-comments-in-bch_keylist_realloc.patch b/for-review/0007-bcache-fix-mistaken-comments-in-bch_keylist_realloc.patch
new file mode 100644
index 0000000..f896d37
--- /dev/null
+++ b/for-review/0007-bcache-fix-mistaken-comments-in-bch_keylist_realloc.patch
@@ -0,0 +1,25 @@
+From cba06224f263bd4a1c365dc66623f570959e1d93 Mon Sep 17 00:00:00 2001
+From: Coly Li <colyli@suse.de>
+Date: Tue, 14 Nov 2017 00:09:50 +0800
+Subject: [PATCH 7/9] bcache: fix mistaken comments in bch_keylist_realloc()
+
+---
+ drivers/md/bcache/request.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
+index 65dbc0ccd913..ef13860511d6 100644
+--- a/drivers/md/bcache/request.c
++++ b/drivers/md/bcache/request.c
+@@ -107,7 +107,7 @@ static int bch_keylist_realloc(struct keylist *l, unsigned u64s,
+ /*
+ * The journalling code doesn't handle the case where the keys to insert
+ * is bigger than an empty write: If we just return -ENOMEM here,
+- * bio_insert() and bio_invalidate() will insert the keys created so far
++ * bch_data_insert_keys() will insert the keys created so far
+ * and finish the rest when the keylist is empty.
+ */
+ if (newsize * sizeof(uint64_t) > block_bytes(c) - sizeof(struct jset))
+--
+2.16.3
+
diff --git a/for-review/0008-bcache-add-code-comments-for-bset.c.patch b/for-review/0008-bcache-add-code-comments-for-bset.c.patch
new file mode 100644
index 0000000..bce7f22
--- /dev/null
+++ b/for-review/0008-bcache-add-code-comments-for-bset.c.patch
@@ -0,0 +1,149 @@
+From dbdd6f58facae493906bd8cb73ece7c0c097b94d Mon Sep 17 00:00:00 2001
+From: Coly Li <colyli@suse.de>
+Date: Thu, 12 Apr 2018 17:24:18 +0800
+Subject: [PATCH 8/9] bcache: add code comments for bset.c
+
+This patch tries to add code comments in bset.c, to make some
+tricky code and designment to be more comprehensible. Most information
+of this patch comes from the discussion between Kent and I, he
+offers very informative details. If there is any mistake
+of the idea behind the code, no doubt that's from me misrepresentation.
+
+Signed-off-by: Coly Li <colyli@suse.de>
+---
+ drivers/md/bcache/bset.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 63 insertions(+)
+
+diff --git a/drivers/md/bcache/bset.c b/drivers/md/bcache/bset.c
+index 579c696a5fe0..fc94ef0f2869 100644
+--- a/drivers/md/bcache/bset.c
++++ b/drivers/md/bcache/bset.c
+@@ -366,6 +366,10 @@ EXPORT_SYMBOL(bch_btree_keys_init);
+
+ /* Binary tree stuff for auxiliary search trees */
+
++/*
++ * return array index next to j when does in-order traverse
++ * of a binary tree which is stored in a linear array
++ */
+ static unsigned inorder_next(unsigned j, unsigned size)
+ {
+ if (j * 2 + 1 < size) {
+@@ -379,6 +383,10 @@ static unsigned inorder_next(unsigned j, unsigned size)
+ return j;
+ }
+
++/*
++ * return array index previous to j when does in-order traverse
++ * of a binary tree which is stored in a linear array
++ */
+ static unsigned inorder_prev(unsigned j, unsigned size)
+ {
+ if (j * 2 < size) {
+@@ -421,6 +429,10 @@ static unsigned __to_inorder(unsigned j, unsigned size, unsigned extra)
+ return j;
+ }
+
++/*
++ * Return the cacheline index in bset_tree->data, where j is index
++ * from a linear array which stores the auxiliar binary tree
++ */
+ static unsigned to_inorder(unsigned j, struct bset_tree *t)
+ {
+ return __to_inorder(j, t->size, t->extra);
+@@ -441,6 +453,10 @@ static unsigned __inorder_to_tree(unsigned j, unsigned size, unsigned extra)
+ return j;
+ }
+
++/*
++ * Return an index from a linear array which stores the auxiliar binary
++ * tree, j is the cacheline index of t->data.
++ */
+ static unsigned inorder_to_tree(unsigned j, struct bset_tree *t)
+ {
+ return __inorder_to_tree(j, t->size, t->extra);
+@@ -546,6 +562,20 @@ static inline uint64_t shrd128(uint64_t high, uint64_t low, uint8_t shift)
+ return low;
+ }
+
++/*
++ * Calculate mantissa value for struct bkey_float.
++ * If most significant bit of f->exponent is not set, then
++ * - f->exponent >> 6 is 0
++ * - p[0] points to bkey->low
++ * - p[-1] borrows bits from KEY_INODE() of bkey->high
++ * if most isgnificant bits of f->exponent is set, then
++ * - f->exponent >> 6 is 1
++ * - p[0] points to bits from KEY_INODE() of bkey->high
++ * - p[-1] points to other bits from KEY_INODE() of
++ * bkey->high too.
++ * See make_bfloat() to check when most significant bit of f->exponent
++ * is set or not.
++ */
+ static inline unsigned bfloat_mantissa(const struct bkey *k,
+ struct bkey_float *f)
+ {
+@@ -570,6 +600,16 @@ static void make_bfloat(struct bset_tree *t, unsigned j)
+ BUG_ON(m < l || m > r);
+ BUG_ON(bkey_next(p) != m);
+
++ /*
++ * If l and r have different KEY_INODE values (different backing
++ * device), f->exponent records how many least significant bits
++ * are different in KEY_INODE values and sets most significant
++ * bits to 1 (by +64).
++ * If l and r have same KEY_INODE value, f->exponent records
++ * how many different bits in least significant bits of bkey->low.
++ * See bfloat_mantiss() how the most significant bit of
++ * f->exponent is used to calculate bfloat mantissa value.
++ */
+ if (KEY_INODE(l) != KEY_INODE(r))
+ f->exponent = fls64(KEY_INODE(r) ^ KEY_INODE(l)) + 64;
+ else
+@@ -633,6 +673,15 @@ void bch_bset_init_next(struct btree_keys *b, struct bset *i, uint64_t magic)
+ }
+ EXPORT_SYMBOL(bch_bset_init_next);
+
++/*
++ * Build auxiliary binary tree 'struct bset_tree *t', this tree is used to
++ * accelerate bkey search in a btree node (pointed by bset_tree->data in
++ * memory). After search in the auxiliar tree by calling bset_search_tree(),
++ * a struct bset_search_iter is returned which indicates range [l, r] from
++ * bset_tree->data where the searching bkey might be inside. Then a followed
++ * linear comparison does the exact search, see __bch_bset_search() for how
++ * the auxiliary tree is used.
++ */
+ void bch_bset_build_written_tree(struct btree_keys *b)
+ {
+ struct bset_tree *t = bset_tree_last(b);
+@@ -898,6 +947,17 @@ static struct bset_search_iter bset_search_tree(struct bset_tree *t,
+ unsigned inorder, j, n = 1;
+
+ do {
++ /*
++ * A bit trick here.
++ * If p < t->size, (int)(p - t->size) is a minus value and
++ * the most significant bit is set, right shifting 31 bits
++ * gets 1. If p >= t->size, the most significant bit is
++ * not set, right shifting 31 bits gets 0.
++ * So the following 2 lines equals to
++ * if (p >= t->size)
++ * p = 0;
++ * but a branch instruction is avoided.
++ */
+ unsigned p = n << 4;
+ p &= ((int) (p - t->size)) >> 31;
+
+@@ -907,6 +967,9 @@ static struct bset_search_iter bset_search_tree(struct bset_tree *t,
+ f = &t->tree[j];
+
+ /*
++ * Similar bit trick, use subtract operation to avoid a branch
++ * instruction.
++ *
+ * n = (f->mantissa > bfloat_mantissa())
+ * ? j * 2
+ * : j * 2 + 1;
+--
+2.16.3
+
diff --git a/for-review/0009-bcache-initiate-bcache_debug-to-NULL.patch b/for-review/0009-bcache-initiate-bcache_debug-to-NULL.patch
new file mode 100644
index 0000000..ec2191c
--- /dev/null
+++ b/for-review/0009-bcache-initiate-bcache_debug-to-NULL.patch
@@ -0,0 +1,39 @@
+From b7921ac926e2095fa7337f1d8776545c82ef5531 Mon Sep 17 00:00:00 2001
+From: Coly Li <colyli@suse.de>
+Date: Wed, 16 May 2018 22:10:53 +0800
+Subject: [PATCH 9/9] bcache: initiate bcache_debug to NULL
+
+Global variable bcache_debug is firstly initialized in bch_debug_init(),
+and destroyed in bch_debug_exit(). bch_debug_init() is called in
+bcache_init() with many other functions, if one of the previous calling
+onces failed, bcache_exit() will be called in the failure path.
+
+The problem is, if bcache_init() fails before bch_debug_init() is called,
+then in bcache_exit() when bch_debug_exit() is called to destroy global
+variable bcache_debug, at this moment bcache_debug is unndefined, then the
+test of "if (!IS_ERR_OR_NULL(bcache_debug))" might be buggy.
+
+This patch initializes global varabile bcache_debug to be NULL, to make
+the failure code path to be predictable.
+
+Signed-off-by: Coly Li <colyli@suse.de>
+---
+ drivers/md/bcache/debug.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
+index 57f8f5aeee55..24b0eb65ddec 100644
+--- a/drivers/md/bcache/debug.c
++++ b/drivers/md/bcache/debug.c
+@@ -17,7 +17,7 @@
+ #include <linux/random.h>
+ #include <linux/seq_file.h>
+
+-struct dentry *bcache_debug;
++struct dentry *bcache_debug = NULL;
+
+ #ifdef CONFIG_BCACHE_DEBUG
+
+--
+2.16.3
+
diff --git a/for-test/0001-bcache-add-a-comment-in-register_bdev.patch b/for-review/old/0001-bcache-add-a-comment-in-register_bdev.patch
index 2377298..2377298 100644
--- a/for-test/0001-bcache-add-a-comment-in-register_bdev.patch
+++ b/for-review/old/0001-bcache-add-a-comment-in-register_bdev.patch
diff --git a/for-test/0001-bcache-avoid-unncessary-cache-prefetch-bch_btree_nod.patch b/for-review/old/0001-bcache-avoid-unncessary-cache-prefetch-bch_btree_nod.patch
index 5c5accd..5c5accd 100644
--- a/for-test/0001-bcache-avoid-unncessary-cache-prefetch-bch_btree_nod.patch
+++ b/for-review/old/0001-bcache-avoid-unncessary-cache-prefetch-bch_btree_nod.patch
diff --git a/for-review/old/0001-bcache-do-not-check-return-value-of-debugfs_create_d.patch b/for-review/old/0001-bcache-do-not-check-return-value-of-debugfs_create_d.patch
new file mode 100644
index 0000000..1f41e00
--- /dev/null
+++ b/for-review/old/0001-bcache-do-not-check-return-value-of-debugfs_create_d.patch
@@ -0,0 +1,129 @@
+From 93f52e54361ba8059aa47368bb3aa96d56d5af58 Mon Sep 17 00:00:00 2001
+From: Coly Li <colyli@suse.de>
+Date: Tue, 22 May 2018 14:29:09 +0800
+Subject: [PATCH] bcache: do not check return value of debugfs_create_dir()
+
+Greg KH suggests that normal code should not care about debugfs. Therefore
+no matter successful or failed of debugfs_create_dir() execution, it is
+unncessary to check its return value.
+
+There are two functions called debugfs_create_dir() and check the return
+value, which are bch_debug_init() and closure_debug_init(). This patch
+changes these two functions from int to void type, and ignore return values
+of debugfs_create_dir().
+
+This patch does not fix exact bug, just makes things work as they should.
+
+Signed-off-by: Coly Li <colyli@suse.de>
+Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Cc: Kai Krakow <kai@kaishome.de>
+Cc: Kent Overstreet <kent.overstreet@gmail.com>
+---
+ drivers/md/bcache/bcache.h | 2 +-
+ drivers/md/bcache/closure.c | 13 +++++++++----
+ drivers/md/bcache/closure.h | 4 ++--
+ drivers/md/bcache/debug.c | 11 ++++++-----
+ drivers/md/bcache/super.c | 4 +++-
+ 5 files changed, 21 insertions(+), 13 deletions(-)
+
+diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
+index 3a0cfb237af9..bee6251d2d40 100644
+--- a/drivers/md/bcache/bcache.h
++++ b/drivers/md/bcache/bcache.h
+@@ -995,7 +995,7 @@ void bch_open_buckets_free(struct cache_set *);
+ int bch_cache_allocator_start(struct cache *ca);
+
+ void bch_debug_exit(void);
+-int bch_debug_init(struct kobject *);
++void bch_debug_init(struct kobject *);
+ void bch_request_exit(void);
+ int bch_request_init(void);
+
+diff --git a/drivers/md/bcache/closure.c b/drivers/md/bcache/closure.c
+index 0e14969182c6..618253683d40 100644
+--- a/drivers/md/bcache/closure.c
++++ b/drivers/md/bcache/closure.c
+@@ -199,11 +199,16 @@ static const struct file_operations debug_ops = {
+ .release = single_release
+ };
+
+-int __init closure_debug_init(void)
++void __init closure_debug_init(void)
+ {
+- closure_debug = debugfs_create_file("closures",
+- 0400, bcache_debug, NULL, &debug_ops);
+- return IS_ERR_OR_NULL(closure_debug);
++ if (!IS_ERR_OR_NULL(bcache_debug))
++ /*
++ * it is unnecessary to check return value of
++ * debugfs_create_file(), we should not care
++ * about this.
++ */
++ closure_debug = debugfs_create_file(
++ "closures", 0400, bcache_debug, NULL, &debug_ops);
+ }
+ #endif
+
+diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
+index 71427eb5fdae..7c2c5bc7c88b 100644
+--- a/drivers/md/bcache/closure.h
++++ b/drivers/md/bcache/closure.h
+@@ -186,13 +186,13 @@ static inline void closure_sync(struct closure *cl)
+
+ #ifdef CONFIG_BCACHE_CLOSURES_DEBUG
+
+-int closure_debug_init(void);
++void closure_debug_init(void);
+ void closure_debug_create(struct closure *cl);
+ void closure_debug_destroy(struct closure *cl);
+
+ #else
+
+-static inline int closure_debug_init(void) { return 0; }
++static inline void closure_debug_init(void) {}
+ static inline void closure_debug_create(struct closure *cl) {}
+ static inline void closure_debug_destroy(struct closure *cl) {}
+
+diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
+index d030ce3025a6..57f8f5aeee55 100644
+--- a/drivers/md/bcache/debug.c
++++ b/drivers/md/bcache/debug.c
+@@ -248,11 +248,12 @@ void bch_debug_exit(void)
+ debugfs_remove_recursive(bcache_debug);
+ }
+
+-int __init bch_debug_init(struct kobject *kobj)
++void __init bch_debug_init(struct kobject *kobj)
+ {
+- if (!IS_ENABLED(CONFIG_DEBUG_FS))
+- return 0;
+-
++ /*
++ * it is unnecessary to check return value of
++ * debugfs_create_file(), we should not care
++ * about this.
++ */
+ bcache_debug = debugfs_create_dir("bcache", NULL);
+- return IS_ERR_OR_NULL(bcache_debug);
+ }
+diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
+index 3dea06b41d43..2b62671e4d83 100644
+--- a/drivers/md/bcache/super.c
++++ b/drivers/md/bcache/super.c
+@@ -2301,10 +2301,12 @@ static int __init bcache_init(void)
+ if (!(bcache_wq = alloc_workqueue("bcache", WQ_MEM_RECLAIM, 0)) ||
+ !(bcache_kobj = kobject_create_and_add("bcache", fs_kobj)) ||
+ bch_request_init() ||
+- bch_debug_init(bcache_kobj) || closure_debug_init() ||
+ sysfs_create_files(bcache_kobj, files))
+ goto err;
+
++ bch_debug_init(bcache_kobj);
++ closure_debug_init();
++
+ return 0;
+ err:
+ bcache_exit();
+--
+2.16.3
+
diff --git a/for-test/0001-bcache-fix-mistaken-code-comments-in-struct-cache.patch b/for-review/old/0001-bcache-fix-mistaken-code-comments-in-struct-cache.patch
index 3e52bcc..3e52bcc 100644
--- a/for-test/0001-bcache-fix-mistaken-code-comments-in-struct-cache.patch
+++ b/for-review/old/0001-bcache-fix-mistaken-code-comments-in-struct-cache.patch
diff --git a/for-test/0001-bcache-fix-mistaken-comments-in-bch_keylist_realloc.patch b/for-review/old/0001-bcache-fix-mistaken-comments-in-bch_keylist_realloc.patch
index 9a23a70..9a23a70 100644
--- a/for-test/0001-bcache-fix-mistaken-comments-in-bch_keylist_realloc.patch
+++ b/for-review/old/0001-bcache-fix-mistaken-comments-in-bch_keylist_realloc.patch
diff --git a/for-test/0001-bcache-initiate-bcache_debug-to-NULL.patch b/for-review/old/0001-bcache-initiate-bcache_debug-to-NULL.patch
index 7468a61..7468a61 100644
--- a/for-test/0001-bcache-initiate-bcache_debug-to-NULL.patch
+++ b/for-review/old/0001-bcache-initiate-bcache_debug-to-NULL.patch
diff --git a/for-review/old/0001-lib-crc64.c-add-license-information.patch b/for-review/old/0001-lib-crc64.c-add-license-information.patch
new file mode 100644
index 0000000..a2ba5ec
--- /dev/null
+++ b/for-review/old/0001-lib-crc64.c-add-license-information.patch
@@ -0,0 +1,32 @@
+From 6c8a57fa27941ea096ca525d8025718b8f837b3e Mon Sep 17 00:00:00 2001
+From: Coly Li <colyli@suse.de>
+Date: Tue, 22 May 2018 16:50:39 +0800
+Subject: [PATCH v2] lib/crc64.c: add license information
+
+This patch adds MODULE_LICENSE("GPL") to remove a kernel build warning
+information. Also as Andy Shevchenko suggested, adds a SPDX header into
+lib/crc64.c file.
+
+Signed-off-by: Coly Li <colyli@suse.de>
+Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+---
+ lib/crc64.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/lib/crc64.c b/lib/crc64.c
+index ed0ffac7b26a..30d1bb58dd5c 100644
+--- a/lib/crc64.c
++++ b/lib/crc64.c
+@@ -1,3 +1,4 @@
++// SPDX-License-Identifier: GPL-2.0
+ /*
+ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group (Any
+ * use permitted, subject to terms of PostgreSQL license; see.)
+@@ -135,3 +136,4 @@ uint64_t crc64(const void *data, size_t len)
+ EXPORT_SYMBOL_GPL(crc64);
+
+ MODULE_DESCRIPTION("CRC64 calculations");
++MODULE_LICENSE("GPL");
+--
+2.16.3
+
diff --git a/for-test/0002-bcache-add-code-comments-for-bset.c.patch b/for-review/old/0002-bcache-add-code-comments-for-bset.c.patch
index 1f75019..1f75019 100644
--- a/for-test/0002-bcache-add-code-comments-for-bset.c.patch
+++ b/for-review/old/0002-bcache-add-code-comments-for-bset.c.patch
diff --git a/for-next/0002-bcache-display-rate-debug-parameters-to-0-when-write.patch b/for-review/old/0002-bcache-display-rate-debug-parameters-to-0-when-write.patch
index bac6c40..bac6c40 100644
--- a/for-next/0002-bcache-display-rate-debug-parameters-to-0-when-write.patch
+++ b/for-review/old/0002-bcache-display-rate-debug-parameters-to-0-when-write.patch