Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753265AbbL2Jh0 (ORCPT ); Tue, 29 Dec 2015 04:37:26 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:34711 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751618AbbL2JhS (ORCPT ); Tue, 29 Dec 2015 04:37:18 -0500 Subject: Re: [PATCH] lightnvm: put block back to gc list on its reclaim fail To: Wenwei Tao References: <1451377622-5175-1-git-send-email-ww.tao0320@gmail.com> Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org From: =?UTF-8?Q?Matias_Bj=c3=b8rling?= Message-ID: <5682544C.1030307@lightnvm.io> Date: Tue, 29 Dec 2015 10:37:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1451377622-5175-1-git-send-email-ww.tao0320@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1755 Lines: 53 On 12/29/2015 09:27 AM, Wenwei Tao wrote: > We delete a block from the gc list before reclaim it, so > put it back to the list on its reclaim fail, otherwize > this block will not get reclaimed and be programable > in the future. > > Signed-off-by: Wenwei Tao > --- > drivers/lightnvm/rrpc.c | 18 ++++++++++++++---- > 1 file changed, 14 insertions(+), 4 deletions(-) > > diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c > index d40c140..67b14d4 100644 > --- a/drivers/lightnvm/rrpc.c > +++ b/drivers/lightnvm/rrpc.c > @@ -379,16 +379,26 @@ static void rrpc_block_gc(struct work_struct *work) > struct rrpc *rrpc = gcb->rrpc; > struct rrpc_block *rblk = gcb->rblk; > struct nvm_dev *dev = rrpc->dev; > + struct nvm_lun *lun = rblk->parent->lun; > + struct rrpc_lun *rlun = &rrpc->luns[lun->id - rrpc->lun_offset]; > > + mempool_free(gcb, rrpc->gcb_pool); > pr_debug("nvm: block '%lu' being reclaimed\n", rblk->parent->id); > > if (rrpc_move_valid_pages(rrpc, rblk)) > - goto done; > + goto put_back; > + > + if (nvm_erase_blk(dev, rblk->parent)) > + goto put_back; > > - nvm_erase_blk(dev, rblk->parent); > rrpc_put_blk(rrpc, rblk); > -done: > - mempool_free(gcb, rrpc->gcb_pool); > + > + return; > + > +put_back: > + spin_lock(&rlun->lock); > + list_add_tail(&rblk->prio, &rlun->prio_list); > + spin_unlock(&rlun->lock); > } > > /* the block with highest number of invalid pages, will be in the beginning > Thanks Tao. I've applied it for 4.5. -- 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/