On 4/13/22 8:42 PM, Zou Mingzhe wrote:
在 2022/4/11 11:04, mingzhe.zou@xxxxxxxxxxxx 写道:
From: ZouMingzhe <mingzhe.zou@xxxxxxxxxxxx>
handle error when call bch_cached_dev_attach() function
Signed-off-by: Mingzhe Zou <mingzhe.zou@xxxxxxxxxxxx>
---
drivers/md/bcache/super.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index e4a53c849fa6..940eea5f94de 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1460,7 +1460,7 @@ static int register_bdev(struct cache_sb *sb,
struct cache_sb_disk *sb_disk,
{
const char *err = "cannot allocate memory";
struct cache_set *c;
- int ret = -ENOMEM;
+ int ret = -ENOMEM, ret_tmp;
memcpy(&dc->sb, sb, sizeof(struct cache_sb));
dc->bdev = bdev;
@@ -1480,8 +1480,14 @@ static int register_bdev(struct cache_sb *sb,
struct cache_sb_disk *sb_disk,
list_add(&dc->list, &uncached_devices);
/* attach to a matched cache set if it exists */
- list_for_each_entry(c, &bch_cache_sets, list)
- bch_cached_dev_attach(dc, c, NULL);
+ err = "failed to attach cached device";
+ list_for_each_entry(c, &bch_cache_sets, list) {
+ ret_tmp = bch_cached_dev_attach(dc, c, NULL);
+ if (ret_tmp)
+ ret = ret_tmp;
+ }
+ if (ret)
+ goto err;
Hi, coly
Wrong here.
I have send v3.
mingzhe
Sure. BTW, next time it would be more convenient for me if you post new
version in another email thread. Otherwise there is a little chance that
I am confused with previous patches.
Thanks.
Coly Li