Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1283041 > unrolled thread

[PATCH] lightnvm: put blks when luns configure failed

Started byWenwei Tao <ww.tao0320@gmail.com>
First post2015-12-03 14:30 +0100
Last post2015-12-04 13:30 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] lightnvm: put blks when luns configure failed Wenwei Tao <ww.tao0320@gmail.com> - 2015-12-03 14:30 +0100
    Re: [PATCH] lightnvm: put blks when luns configure failed Matias Bjørling <mb@lightnvm.io> - 2015-12-04 13:30 +0100

#1283041 — [PATCH] lightnvm: put blks when luns configure failed

FromWenwei Tao <ww.tao0320@gmail.com>
Date2015-12-03 14:30 +0100
Subject[PATCH] lightnvm: put blks when luns configure failed
Message-ID<qBC7n-5Es-1@gated-at.bofh.it>
put the allocated blks back to the free list
when the luns configure failed, to make these
blks useable to others.

Signed-off-by: Wenwei Tao <ww.tao0320@gmail.com>
---
 drivers/lightnvm/rrpc.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c
index 75e59c3..1bb2f97 100644
--- a/drivers/lightnvm/rrpc.c
+++ b/drivers/lightnvm/rrpc.c
@@ -202,6 +202,20 @@ static void rrpc_put_blk(struct rrpc *rrpc, struct rrpc_block *rblk)
 	nvm_put_blk(rrpc->dev, rblk->parent);
 }
 
+static void rrpc_put_blks(struct rrpc *rrpc)
+{
+	struct rrpc_lun *rlun;
+	int i;
+
+	for (i = 0; i < rrpc->nr_luns; i++) {
+		rlun = &rrpc->luns[i];
+		if (rlun->cur)
+			rrpc_put_blk(rrpc, rlun->cur);
+		if (rlun->gc_cur)
+			rrpc_put_blk(rrpc, rlun->gc_cur);
+	}
+}
+
 static struct rrpc_lun *get_next_lun(struct rrpc *rrpc)
 {
 	int next = atomic_inc_return(&rrpc->next_lun);
@@ -1224,18 +1238,21 @@ static int rrpc_luns_configure(struct rrpc *rrpc)
 
 		rblk = rrpc_get_blk(rrpc, rlun, 0);
 		if (!rblk)
-			return -EINVAL;
+			goto err;
 
 		rrpc_set_lun_cur(rlun, rblk);
 
 		/* Emergency gc block */
 		rblk = rrpc_get_blk(rrpc, rlun, 1);
 		if (!rblk)
-			return -EINVAL;
+			goto err;
 		rlun->gc_cur = rblk;
 	}
 
 	return 0;
+err:
+	rrpc_put_blks(rrpc);
+	return -EINVAL;
 }
 
 static struct nvm_tgt_type tt_rrpc;
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1283779

FromMatias Bjørling <mb@lightnvm.io>
Date2015-12-04 13:30 +0100
Message-ID<qBXES-2B5-17@gated-at.bofh.it>
In reply to#1283041
On 12/03/2015 02:27 PM, Wenwei Tao wrote:
> put the allocated blks back to the free list
> when the luns configure failed, to make these
> blks useable to others.
>
> Signed-off-by: Wenwei Tao <ww.tao0320@gmail.com>
> ---
>   drivers/lightnvm/rrpc.c | 21 +++++++++++++++++++--
>   1 file changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c
> index 75e59c3..1bb2f97 100644
> --- a/drivers/lightnvm/rrpc.c
> +++ b/drivers/lightnvm/rrpc.c
> @@ -202,6 +202,20 @@ static void rrpc_put_blk(struct rrpc *rrpc, struct rrpc_block *rblk)
>   	nvm_put_blk(rrpc->dev, rblk->parent);
>   }
>
> +static void rrpc_put_blks(struct rrpc *rrpc)
> +{
> +	struct rrpc_lun *rlun;
> +	int i;
> +
> +	for (i = 0; i < rrpc->nr_luns; i++) {
> +		rlun = &rrpc->luns[i];
> +		if (rlun->cur)
> +			rrpc_put_blk(rrpc, rlun->cur);
> +		if (rlun->gc_cur)
> +			rrpc_put_blk(rrpc, rlun->gc_cur);
> +	}
> +}
> +
>   static struct rrpc_lun *get_next_lun(struct rrpc *rrpc)
>   {
>   	int next = atomic_inc_return(&rrpc->next_lun);
> @@ -1224,18 +1238,21 @@ static int rrpc_luns_configure(struct rrpc *rrpc)
>
>   		rblk = rrpc_get_blk(rrpc, rlun, 0);
>   		if (!rblk)
> -			return -EINVAL;
> +			goto err;
>
>   		rrpc_set_lun_cur(rlun, rblk);
>
>   		/* Emergency gc block */
>   		rblk = rrpc_get_blk(rrpc, rlun, 1);
>   		if (!rblk)
> -			return -EINVAL;
> +			goto err;
>   		rlun->gc_cur = rblk;
>   	}
>
>   	return 0;
> +err:
> +	rrpc_put_blks(rrpc);
> +	return -EINVAL;
>   }
>
>   static struct nvm_tgt_type tt_rrpc;
>

Thanks Tao, applied.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web