diff options
author | Coly Li <colyli@suse.de> | 2023-09-06 11:40:53 +0800 |
---|---|---|
committer | Coly Li <colyli@suse.de> | 2023-09-06 11:40:53 +0800 |
commit | 2e1935a83673fbe0ec4535308c6231413946c1b5 (patch) | |
tree | 6353730c22886790e7c52698de245b90913e618d | |
parent | 62192d0140511f8489265a1e81ca2543e20c37cd (diff) | |
download | bcache-patches-master.tar.gz |
8 files changed, 55 insertions, 508 deletions
diff --git a/for-next/20221207_ye_xingchen_bcache_convert_to_use_sysfs_emit_sysfs_emit_at_apis.mbx b/for-next/20221207_ye_xingchen_bcache_convert_to_use_sysfs_emit_sysfs_emit_at_apis.mbx deleted file mode 100644 index d054edb..0000000 --- a/for-next/20221207_ye_xingchen_bcache_convert_to_use_sysfs_emit_sysfs_emit_at_apis.mbx +++ /dev/null @@ -1,74 +0,0 @@ -From git@z Thu Jan 1 00:00:00 1970 -Subject: [PATCH] bcache: Convert to use sysfs_emit()/sysfs_emit_at() APIs -From: ye.xingchen@zte.com.cn <ye.xingchen@zte.com.cn> -Date: Wed, 07 Dec 2022 17:02:35 +0800 -Message-Id: <202212071702359325169@zte.com.cn> -To: <colyli@suse.de> -Cc: <kent.overstreet@gmail.com>, <linux-bcache@vger.kernel.org>, <linux-kernel@vger.kernel.org> -List-Id: <linux-bcache.vger.kernel.org> -MIME-Version: 1.0 -Content-Type: text/plain; charset="utf-8" -Content-Transfer-Encoding: 7bit - -From: ye xingchen <ye.xingchen@zte.com.cn> - -Follow the advice of the Documentation/filesystems/sysfs.rst and show() -should only use sysfs_emit() or sysfs_emit_at() when formatting the -value to be returned to user space. - -Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn> ---- - drivers/md/bcache/sysfs.c | 31 +++++++++++++++---------------- - 1 file changed, 15 insertions(+), 16 deletions(-) - -diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c -index c6f677059214..0e2c1880f60b 100644 ---- a/drivers/md/bcache/sysfs.c -+++ b/drivers/md/bcache/sysfs.c -@@ -1111,26 +1111,25 @@ SHOW(__bch_cache) - - vfree(p); - -- ret = scnprintf(buf, PAGE_SIZE, -- "Unused: %zu%%\n" -- "Clean: %zu%%\n" -- "Dirty: %zu%%\n" -- "Metadata: %zu%%\n" -- "Average: %llu\n" -- "Sectors per Q: %zu\n" -- "Quantiles: [", -- unused * 100 / (size_t) ca->sb.nbuckets, -- available * 100 / (size_t) ca->sb.nbuckets, -- dirty * 100 / (size_t) ca->sb.nbuckets, -- meta * 100 / (size_t) ca->sb.nbuckets, sum, -- n * ca->sb.bucket_size / (ARRAY_SIZE(q) + 1)); -+ ret = sysfs_emit(buf, -+ "Unused: %zu%%\n" -+ "Clean: %zu%%\n" -+ "Dirty: %zu%%\n" -+ "Metadata: %zu%%\n" -+ "Average: %llu\n" -+ "Sectors per Q: %zu\n" -+ "Quantiles: [", -+ unused * 100 / (size_t) ca->sb.nbuckets, -+ available * 100 / (size_t) ca->sb.nbuckets, -+ dirty * 100 / (size_t) ca->sb.nbuckets, -+ meta * 100 / (size_t) ca->sb.nbuckets, sum, -+ n * ca->sb.bucket_size / (ARRAY_SIZE(q) + 1)); - - for (i = 0; i < ARRAY_SIZE(q); i++) -- ret += scnprintf(buf + ret, PAGE_SIZE - ret, -- "%u ", q[i]); -+ ret += sysfs_emit_at(buf, ret, "%u ", q[i]); - ret--; - -- ret += scnprintf(buf + ret, PAGE_SIZE - ret, "]\n"); -+ ret += sysfs_emit_at(buf, ret, "]\n"); - - return ret; - } - --- -2.25.1 - - diff --git a/for-next/20230214_linux_bcache_make_kobj_type_structures_constant.mbx b/for-next/20230214_linux_bcache_make_kobj_type_structures_constant.mbx deleted file mode 100644 index 2d70d11..0000000 --- a/for-next/20230214_linux_bcache_make_kobj_type_structures_constant.mbx +++ /dev/null @@ -1,64 +0,0 @@ -From git@z Thu Jan 1 00:00:00 1970 -Subject: [PATCH] bcache: make kobj_type structures constant -From: Thomas Weißschuh <linux@weissschuh.net> -Date: Tue, 14 Feb 2023 03:13:39 +0000 -Message-Id: <20230214-kobj_type-bcache-v1-1-cf00ead7bee7@weissschuh.net> -MIME-Version: 1.0 -Content-Type: text/plain; charset="utf-8" -Content-Transfer-Encoding: 8bit - -Since commit ee6d3dd4ed48 ("driver core: make kobj_type constant.") -the driver core allows the usage of const struct kobj_type. - -Take advantage of this to constify the structure definitions to prevent -modification at runtime. - -Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> ---- - drivers/md/bcache/bcache.h | 10 +++++----- - drivers/md/bcache/sysfs.h | 2 +- - 2 files changed, 6 insertions(+), 6 deletions(-) - -diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h -index aebb7ef10e63..a522f4f1f992 100644 ---- a/drivers/md/bcache/bcache.h -+++ b/drivers/md/bcache/bcache.h -@@ -1004,11 +1004,11 @@ extern struct workqueue_struct *bch_flush_wq; - extern struct mutex bch_register_lock; - extern struct list_head bch_cache_sets; - --extern struct kobj_type bch_cached_dev_ktype; --extern struct kobj_type bch_flash_dev_ktype; --extern struct kobj_type bch_cache_set_ktype; --extern struct kobj_type bch_cache_set_internal_ktype; --extern struct kobj_type bch_cache_ktype; -+extern const struct kobj_type bch_cached_dev_ktype; -+extern const struct kobj_type bch_flash_dev_ktype; -+extern const struct kobj_type bch_cache_set_ktype; -+extern const struct kobj_type bch_cache_set_internal_ktype; -+extern const struct kobj_type bch_cache_ktype; - - void bch_cached_dev_release(struct kobject *kobj); - void bch_flash_dev_release(struct kobject *kobj); -diff --git a/drivers/md/bcache/sysfs.h b/drivers/md/bcache/sysfs.h -index a2ff6447b699..65b8bd975ab1 100644 ---- a/drivers/md/bcache/sysfs.h -+++ b/drivers/md/bcache/sysfs.h -@@ -3,7 +3,7 @@ - #define _BCACHE_SYSFS_H_ - - #define KTYPE(type) \ --struct kobj_type type ## _ktype = { \ -+const struct kobj_type type ## _ktype = { \ - .release = type ## _release, \ - .sysfs_ops = &((const struct sysfs_ops) { \ - .show = type ## _show, \ - ---- -base-commit: f6feea56f66d34259c4222fa02e8171c4f2673d1 -change-id: 20230214-kobj_type-bcache-6d2bd129b0fa - -Best regards, --- -Thomas Weißschuh <linux@weissschuh.net> - diff --git a/for-next/20230225_andrea_tomassetti_opensource_bcache_remove_dead_references_to_cache_readaheads.mbx b/for-next/20230225_andrea_tomassetti_opensource_bcache_remove_dead_references_to_cache_readaheads.mbx deleted file mode 100644 index 650d185..0000000 --- a/for-next/20230225_andrea_tomassetti_opensource_bcache_remove_dead_references_to_cache_readaheads.mbx +++ /dev/null @@ -1,47 +0,0 @@ -From git@z Thu Jan 1 00:00:00 1970 -Subject: [PATCH] bcache: Remove dead references to cache_readaheads -From: Andrea Tomassetti <andrea.tomassetti-opensource@devo.com> -Date: Sat, 25 Feb 2023 16:33:55 +0100 -Message-Id: <20230225153355.2779474-1-andrea.tomassetti-opensource@devo.com> -MIME-Version: 1.0 -Content-Type: text/plain; charset="utf-8" -Content-Transfer-Encoding: 7bit - -The cache_readaheads stat counter is not used anymore and should be -removed. - -Signed-off-by: Andrea Tomassetti <andrea.tomassetti-opensource@devo.com> ---- - Documentation/admin-guide/bcache.rst | 3 --- - drivers/md/bcache/stats.h | 1 - - 2 files changed, 4 deletions(-) - -diff --git a/Documentation/admin-guide/bcache.rst b/Documentation/admin-guide/bcache.rst -index bb5032a99234..6fdb495ac466 100644 ---- a/Documentation/admin-guide/bcache.rst -+++ b/Documentation/admin-guide/bcache.rst -@@ -508,9 +508,6 @@ cache_miss_collisions - cache miss, but raced with a write and data was already present (usually 0 - since the synchronization for cache misses was rewritten) - --cache_readaheads -- Count of times readahead occurred. -- - Sysfs - cache set - ~~~~~~~~~~~~~~~~~ - -diff --git a/drivers/md/bcache/stats.h b/drivers/md/bcache/stats.h -index bd3afc856d53..21b445f8af15 100644 ---- a/drivers/md/bcache/stats.h -+++ b/drivers/md/bcache/stats.h -@@ -18,7 +18,6 @@ struct cache_stats { - unsigned long cache_misses; - unsigned long cache_bypass_hits; - unsigned long cache_bypass_misses; -- unsigned long cache_readaheads; - unsigned long cache_miss_collisions; - unsigned long sectors_bypassed; - --- -2.39.2 - diff --git a/for-next/20230906_rand_sec96_bcache_prevent_potential_division_by_zero_error.mbx b/for-next/20230906_rand_sec96_bcache_prevent_potential_division_by_zero_error.mbx new file mode 100644 index 0000000..c4c62b5 --- /dev/null +++ b/for-next/20230906_rand_sec96_bcache_prevent_potential_division_by_zero_error.mbx @@ -0,0 +1,54 @@ +From git@z Thu Jan 1 00:00:00 1970 +Subject: [PATCH] bcache: prevent potential division by zero error +From: Rand Deeb <rand.sec96@gmail.com> +Date: Wed, 06 Sep 2023 04:22:49 +0300 +Message-Id: <20230906012249.49203-1-rand.sec96@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 7bit + +In SHOW(), the variable 'n' is of type 'size_t.' While there is a +conditional check to verify that 'n' is not equal to zero before +executing the 'do_div' macro, concerns arise regarding potential +division by zero error in 64-bit environments. + +The concern arises when 'n' is 64 bits in size, greater than zero, and +the lower 32 bits of it are zeros. In such cases, the conditional check +passes because 'n' is non-zero, but the 'do_div' macro casts 'n' to +'uint32_t,' effectively truncating it to its lower 32 bits. +Consequently, the 'n' value becomes zero. + +To fix this potential division by zero error and ensure precise +division handling, this commit replaces the 'do_div' macro with +div64_u64(). div64_u64() is designed to work with 64-bit operands, +guaranteeing that division is performed correctly. + +This change enhances the robustness of the code, ensuring that division +operations yield accurate results in all scenarios, eliminating the +possibility of division by zero, and improving compatibility across +different 64-bit environments. + +Found by Linux Verification Center (linuxtesting.org) with SVACE. + +Signed-off-by: Rand Deeb <rand.sec96@gmail.com> +Signed-off-by: Coly Li <colyli@suse.de> +--- + drivers/md/bcache/sysfs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c +index 554e3afc9b68..ca3e2f000cd4 100644 +--- a/drivers/md/bcache/sysfs.c ++++ b/drivers/md/bcache/sysfs.c +@@ -1078,7 +1078,7 @@ SHOW(__bch_cache) + sum += INITIAL_PRIO - cached[i]; + + if (n) +- do_div(sum, n); ++ sum = div64_u64(sum, n); + + for (i = 0; i < ARRAY_SIZE(q); i++) + q[i] = INITIAL_PRIO - cached[n * (i + 1) / +-- +2.34.1 + diff --git a/for-next/[PATCH 1_2] bcache_ fixup btree_cache_wait list damage.eml b/for-next/[PATCH 1_2] bcache_ fixup btree_cache_wait list damage.eml deleted file mode 100644 index 25188fd..0000000 --- a/for-next/[PATCH 1_2] bcache_ fixup btree_cache_wait list damage.eml +++ /dev/null @@ -1,171 +0,0 @@ -Return-Path: <mingzhe.zou@easystack.cn> -Delivered-To: colyli -Received: from dovecot-director2.suse.de ([192.168.254.65]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) - by imap2.suse-dmz.suse.de with LMTPS - id tcrmJrvvRmK1NwAAMHmgww - (envelope-from <mingzhe.zou@easystack.cn>) - for <colyli>; Fri, 01 Apr 2022 12:27:39 +0000 -Received: from relay2.suse.de ([149.44.160.134]) - (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) - by dovecot-director2.suse.de with LMTPS - id KGCAJLvvRmJsTQAApTUePA - (envelope-from <mingzhe.zou@easystack.cn>) - for <colyli@imap.suse.de>; Fri, 01 Apr 2022 12:27:39 +0000 -Received: from relay2.suse.de (localhost [127.0.0.1]) - by relay2.suse.de (Postfix) with ESMTP id 8C5A4A3B89 - for <colyli@imap.suse.de>; Fri, 1 Apr 2022 12:27:39 +0000 (UTC) -X-Virus-Scanned: by amavisd-new at relay2.suse.de -X-Spam-Flag: NO -X-Spam-Score: 0.77 -X-Spam-Level: -X-Spam-Status: No, score=0.77 tagged_above=-9999 required=5 - tests=[BAYES_50=0.8, RCVD_IN_DNSWL_NONE=-0.0001, - RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, - T_SCC_BODY_TEXT_LINE=-0.01] autolearn=no autolearn_force=no -Received: from relay2.suse.de ([127.0.0.1]) - by relay2.suse.de (relay2.suse.de [127.0.0.1]) (amavisd-new, port 10026) - with ESMTP id tYeLYEP5FXWf for <colyli@imap.suse.de>; - Fri, 1 Apr 2022 12:27:33 +0000 (UTC) -Received: from mx2.suse.de (unknown [149.44.161.68]) - (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) - (No client certificate requested) - by relay2.suse.de (Postfix) with ESMTPS id 9FD91A3B95 - for <colyli@imap.suse.de>; Fri, 1 Apr 2022 12:27:32 +0000 (UTC) -Received: from mail-m2835.qiye.163.com (mail-m2835.qiye.163.com [103.74.28.35]) - (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) - (No client certificate requested) - by mx2.suse.de (Postfix) with ESMTPS id 5B880AD0E - for <colyli@suse.de>; Fri, 1 Apr 2022 12:27:30 +0000 (UTC) -Received: from localhost.localdomain (unknown [218.94.118.90]) - by mail-m2835.qiye.163.com (Hmail) with ESMTPA id 1FCC38A07D6; - Fri, 1 Apr 2022 20:27:28 +0800 (CST) -From: mingzhe.zou@easystack.cn -To: colyli@suse.de, - linux-bcache@vger.kernel.org -Cc: zoumingzhe@qq.com, - ZouMingzhe <mingzhe.zou@easystack.cn> -Subject: [PATCH 1/2] bcache: fixup btree_cache_wait list damage -Date: Fri, 1 Apr 2022 20:27:24 +0800 -Message-Id: <20220401122725.17725-1-mingzhe.zou@easystack.cn> -X-Mailer: git-send-email 2.17.1 -X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgPGg8OCBgUHx5ZQUlOS1dZCBgUCR5ZQVlLVUtZV1 - kWDxoPAgseWUFZKDYvK1lXWShZQUlCN1dZLVlBSVdZDwkaFQgSH1lBWRpKSUhWHRpMTU4fTBodSk - 1LVRkRExYaEhckFA4PWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVS1kG -X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6ODY6Tjo*ATIoFExDGDYvDhM2 - KzwwFFFVSlVKTU9DQ0pNS09DT0xDVTMWGhIXVRYSFRwBEx5VARQOOx4aCAIIDxoYEFUYFUVZV1kS - C1lBWUlKQ1VCT1VKSkNVQktZV1kIAVlBT0JKSzcG -X-HM-Tid: 0a7fe518488e841dkuqw1fcc38a07d6 - -From: ZouMingzhe <mingzhe.zou@easystack.cn> - -We get a kernel crash about "list_add corruption. next->prev should be -prev (ffff9c801bc01210), but was ffff9c77b688237c. (next=ffffae586d8afe68)." - -crash> struct list_head 0xffff9c801bc01210 -struct list_head { - next = 0xffffae586d8afe68, - prev = 0xffffae586d8afe68 -} -crash> struct list_head 0xffff9c77b688237c -struct list_head { - next = 0x0, - prev = 0x0 -} -crash> struct list_head 0xffffae586d8afe68 -struct list_head struct: invalid kernel virtual address: ffffae586d8afe68 type: "gdb_readmem_callback" -Cannot access memory at address 0xffffae586d8afe68 - -[230469.019492] Call Trace: -[230469.032041] prepare_to_wait+0x8a/0xb0 -[230469.044363] ? bch_btree_keys_free+0x6c/0xc0 [escache] -[230469.056533] mca_cannibalize_lock+0x72/0x90 [escache] -[230469.068788] mca_alloc+0x2ae/0x450 [escache] -[230469.080790] bch_btree_node_get+0x136/0x2d0 [escache] -[230469.092681] bch_btree_check_thread+0x1e1/0x260 [escache] -[230469.104382] ? finish_wait+0x80/0x80 -[230469.115884] ? bch_btree_check_recurse+0x1a0/0x1a0 [escache] -[230469.127259] kthread+0x112/0x130 -[230469.138448] ? kthread_flush_work_fn+0x10/0x10 -[230469.149477] ret_from_fork+0x35/0x40 - -bch_btree_check_thread() and bch_dirty_init_thread() maybe call -mca_cannibalize() to cannibalize other cached btree nodes. Only -one thread can do it at a time, so the op of other threads will -be added to the btree_cache_wait list. - -We must call finish_wait() to remove op from btree_cache_wait -before free it's memory address. Otherwise, the list will be -damaged. Also should call bch_cannibalize_unlock() to release -the btree_cache_alloc_lock and wake_up other waiters. - -Signed-off-by: Mingzhe Zou <mingzhe.zou@easystack.cn> ---- - drivers/md/bcache/btree.c | 10 +++++++++- - drivers/md/bcache/btree.h | 2 ++ - drivers/md/bcache/writeback.c | 8 ++++++++ - 3 files changed, 19 insertions(+), 1 deletion(-) - -diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c -index ad9f16689419..f8e6f5c7c736 100644 ---- a/drivers/md/bcache/btree.c -+++ b/drivers/md/bcache/btree.c -@@ -885,7 +885,7 @@ static struct btree *mca_cannibalize(struct cache_set *c, struct btree_op *op, - * cannibalize_bucket() will take. This means every time we unlock the root of - * the btree, we need to release this lock if we have it held. - */ --static void bch_cannibalize_unlock(struct cache_set *c) -+void bch_cannibalize_unlock(struct cache_set *c) - { - spin_lock(&c->btree_cannibalize_lock); - if (c->btree_cache_alloc_lock == current) { -@@ -1968,6 +1968,14 @@ static int bch_btree_check_thread(void *arg) - c->gc_stats.nodes++; - bch_btree_op_init(&op, 0); - ret = bcache_btree(check_recurse, p, c->root, &op); -+ /* The op may be added to cache_set's btree_cache_wait -+ * in mca_cannibalize(), must ensure it is removed from -+ * the list and release btree_cache_alloc_lock before -+ * free op memory. -+ * Otherwise, the btree_cache_wait will be damaged. -+ */ -+ bch_cannibalize_unlock(c); -+ finish_wait(&c->btree_cache_wait, &(&op)->wait); - if (ret) - goto out; - } -diff --git a/drivers/md/bcache/btree.h b/drivers/md/bcache/btree.h -index 50482107134f..435e82574ac3 100644 ---- a/drivers/md/bcache/btree.h -+++ b/drivers/md/bcache/btree.h -@@ -365,6 +365,8 @@ static inline void force_wake_up_gc(struct cache_set *c) - _r; \ - }) - -+void bch_cannibalize_unlock(struct cache_set *c); -+ - #define MAP_DONE 0 - #define MAP_CONTINUE 1 - -diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c -index 9ee0005874cd..5b828555bca8 100644 ---- a/drivers/md/bcache/writeback.c -+++ b/drivers/md/bcache/writeback.c -@@ -865,6 +865,14 @@ static int bch_root_node_dirty_init(struct cache_set *c, - } - } while (ret == -EAGAIN); - -+ /* The op may be added to cache_set's btree_cache_wait -+ * in mca_cannibalize(), must ensure it is removed from -+ * the list and release btree_cache_alloc_lock before -+ * free op memory. -+ * Otherwise, the btree_cache_wait will be damaged. -+ */ -+ bch_cannibalize_unlock(c); -+ finish_wait(&c->btree_cache_wait, &(&op.op)->wait); - return ret; - } - --- -2.17.1 - diff --git a/for-next/v3_20230217_zyytlz_wz_bcache_remove_some_unnecessary_null_point_check_for_the_return_value_of___bch_.mbx b/for-next/v3_20230217_zyytlz_wz_bcache_remove_some_unnecessary_null_point_check_for_the_return_value_of___bch_.mbx deleted file mode 100644 index 48f99a9..0000000 --- a/for-next/v3_20230217_zyytlz_wz_bcache_remove_some_unnecessary_null_point_check_for_the_return_value_of___bch_.mbx +++ /dev/null @@ -1,101 +0,0 @@ -From git@z Thu Jan 1 00:00:00 1970 -Subject: [PATCH v3] bcache: Remove some unnecessary NULL point check for - the return value of __bch_btree_node_alloc-related pointer -From: Zheng Wang <zyytlz.wz@163.com> -Date: Fri, 17 Feb 2023 18:09:01 +0800 -Message-Id: <20230217100901.707245-1-zyytlz.wz@163.com> -MIME-Version: 1.0 -Content-Type: text/plain; charset="utf-8" -Content-Transfer-Encoding: 7bit - -Due to the previously fix of __bch_btree_node_alloc, the return value will -never be a NULL pointer. So IS_ERR is enough to handle the failure - situation. Fix it by replacing IS_ERR_OR_NULL check to IS_ERR check. - -Fixes: cafe56359144 ("bcache: A block layer cache") -Cc: stable@vger.kernel.org -Signed-off-by: Zheng Wang <zyytlz.wz@163.com> ---- -v3: -- Add Cc: stable@vger.kernel.org suggested by Eric -v2: -- Replace more checks ---- - drivers/md/bcache/btree.c | 10 +++++----- - drivers/md/bcache/super.c | 4 ++-- - 2 files changed, 7 insertions(+), 7 deletions(-) - -diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c -index 147c493a989a..7c21e54468bf 100644 ---- a/drivers/md/bcache/btree.c -+++ b/drivers/md/bcache/btree.c -@@ -1138,7 +1138,7 @@ static struct btree *btree_node_alloc_replacement(struct btree *b, - { - struct btree *n = bch_btree_node_alloc(b->c, op, b->level, b->parent); - -- if (!IS_ERR_OR_NULL(n)) { -+ if (!IS_ERR(n)) { - mutex_lock(&n->write_lock); - bch_btree_sort_into(&b->keys, &n->keys, &b->c->sort); - bkey_copy_key(&n->key, &b->key); -@@ -1340,7 +1340,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op, - memset(new_nodes, 0, sizeof(new_nodes)); - closure_init_stack(&cl); - -- while (nodes < GC_MERGE_NODES && !IS_ERR_OR_NULL(r[nodes].b)) -+ while (nodes < GC_MERGE_NODES && !IS_ERR(r[nodes].b)) - keys += r[nodes++].keys; - - blocks = btree_default_blocks(b->c) * 2 / 3; -@@ -1352,7 +1352,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op, - - for (i = 0; i < nodes; i++) { - new_nodes[i] = btree_node_alloc_replacement(r[i].b, NULL); -- if (IS_ERR_OR_NULL(new_nodes[i])) -+ if (IS_ERR(new_nodes[i])) - goto out_nocoalesce; - } - -@@ -1487,7 +1487,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op, - bch_keylist_free(&keylist); - - for (i = 0; i < nodes; i++) -- if (!IS_ERR_OR_NULL(new_nodes[i])) { -+ if (!IS_ERR(new_nodes[i])) { - btree_node_free(new_nodes[i]); - rw_unlock(true, new_nodes[i]); - } -@@ -1669,7 +1669,7 @@ static int bch_btree_gc_root(struct btree *b, struct btree_op *op, - if (should_rewrite) { - n = btree_node_alloc_replacement(b, NULL); - -- if (!IS_ERR_OR_NULL(n)) { -+ if (!IS_ERR(n)) { - bch_btree_node_write_sync(n); - - bch_btree_set_root(n); -diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c -index ba3909bb6bea..7660962e7b8b 100644 ---- a/drivers/md/bcache/super.c -+++ b/drivers/md/bcache/super.c -@@ -1724,7 +1724,7 @@ static void cache_set_flush(struct closure *cl) - if (!IS_ERR_OR_NULL(c->gc_thread)) - kthread_stop(c->gc_thread); - -- if (!IS_ERR_OR_NULL(c->root)) -+ if (!IS_ERR(c->root)) - list_add(&c->root->list, &c->btree_cache); - - /* -@@ -2088,7 +2088,7 @@ static int run_cache_set(struct cache_set *c) - - err = "cannot allocate new btree root"; - c->root = __bch_btree_node_alloc(c, NULL, 0, true, NULL); -- if (IS_ERR_OR_NULL(c->root)) -+ if (IS_ERR(c->root)) - goto err; - - mutex_lock(&c->root->write_lock); --- -2.25.1 - diff --git a/for-next/v3_20230218_zyytlz_wz_bcache_fix___bch_btree_node_alloc_to_make_the_failure_behavior_consistent.mbx b/for-next/v3_20230218_zyytlz_wz_bcache_fix___bch_btree_node_alloc_to_make_the_failure_behavior_consistent.mbx deleted file mode 100644 index 9aef3d4..0000000 --- a/for-next/v3_20230218_zyytlz_wz_bcache_fix___bch_btree_node_alloc_to_make_the_failure_behavior_consistent.mbx +++ /dev/null @@ -1,50 +0,0 @@ -From git@z Thu Jan 1 00:00:00 1970 -Subject: [PATCH v3] bcache: Fix __bch_btree_node_alloc to make the failure - behavior consistent -From: Zheng Wang <zyytlz.wz@163.com> -Date: Sat, 18 Feb 2023 15:23:35 +0800 -Message-Id: <20230218072335.1537099-1-zyytlz.wz@163.com> -MIME-Version: 1.0 -Content-Type: text/plain; charset="utf-8" -Content-Transfer-Encoding: 7bit - -In some specific situation, the return value of __bch_btree_node_alloc may -be NULL. This may lead to poential NULL pointer dereference in caller - function like a calling chaion : - btree_split->bch_btree_node_alloc->__bch_btree_node_alloc. - -Fix it by initialize return value in __bch_btree_node_alloc before return. - -Fixes: cafe56359144 ("bcache: A block layer cache") -Cc: stable@vger.kernel.org -Signed-off-by: Zheng Wang <zyytlz.wz@163.com> ---- -v3: -- Add Cc: stable@vger.kernel.org suggested by Eric -v2: -- split patch v1 into two patches to make it clearer suggested by Coly Li ---- - drivers/md/bcache/btree.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c -index 147c493a989a..cae25e74b9e0 100644 ---- a/drivers/md/bcache/btree.c -+++ b/drivers/md/bcache/btree.c -@@ -1090,10 +1090,12 @@ struct btree *__bch_btree_node_alloc(struct cache_set *c, struct btree_op *op, - struct btree *parent) - { - BKEY_PADDED(key) k; -- struct btree *b = ERR_PTR(-EAGAIN); -+ struct btree *b; - - mutex_lock(&c->bucket_lock); - retry: -+ /* return ERR_PTR(-EAGAIN) when it fails */ -+ b = ERR_PTR(-EAGAIN); - if (__bch_bucket_alloc_set(c, RESERVE_BTREE, &k.key, wait)) - goto err; - --- -2.25.1 - diff --git a/for-test/badblocks/v6/v6-0001-badblocks-add-more-helper-structure-and-routines-.patch b/for-test/badblocks/v6/v6-0001-badblocks-add-more-helper-structure-and-routines-.patch index e32c433..2b84892 100644 --- a/for-test/badblocks/v6/v6-0001-badblocks-add-more-helper-structure-and-routines-.patch +++ b/for-test/badblocks/v6/v6-0001-badblocks-add-more-helper-structure-and-routines-.patch @@ -23,13 +23,13 @@ clear, they will be used in the improved badblocks code in following patches. Signed-off-by: Coly Li <colyli@suse.de> +Reviewed-by: Xiao Ni <xni@redhat.com> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Geliang Tang <geliang.tang@suse.com> Cc: Hannes Reinecke <hare@suse.de> Cc: Jens Axboe <axboe@kernel.dk> Cc: NeilBrown <neilb@suse.de> Cc: Vishal L Verma <vishal.l.verma@intel.com> -Cc: Xiao Ni <xni@redhat.com> --- include/linux/badblocks.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) |