From patchwork Wed Dec 9 13:26:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenwei Tao X-Patchwork-Id: 7808681 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0A17E9F387 for ; Wed, 9 Dec 2015 13:33:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 35D7A20460 for ; Wed, 9 Dec 2015 13:33:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2EF59203C0 for ; Wed, 9 Dec 2015 13:33:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754621AbbLINd4 (ORCPT ); Wed, 9 Dec 2015 08:33:56 -0500 Received: from mail-pf0-f175.google.com ([209.85.192.175]:36800 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754452AbbLINd4 (ORCPT ); Wed, 9 Dec 2015 08:33:56 -0500 Received: by pfdd184 with SMTP id d184so30219133pfd.3; Wed, 09 Dec 2015 05:33:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=y+mXDowfZN6xD9GBqT9jQ4Ec+jIDitGopDqJAmvicTA=; b=elD+dm+CLAwI28zBaRP3p79x2Uv18eQmcM2PYSGObk4eRWJAfeS7AxIUkqQ/B9Z3T3 8YhvYV9+jPfcieK1jDRablzpZsHzSTfwr1sH9Hg1qa771Xa3OaVXx5xRxLBL6H0Yjo9u jVrAoYVnx00Q2AO0xWfHYjG4cVovhj7P8rFo1Gig/u2xcyN1YoU6eiOnW21xj7MDECgx /scirBx+Nc7pC8+brpA4Bix7+G6P1fpVBvWDX1DRo5PKeJdS5YJutx3vd+iBVq5fTHHO VXskSG7zSP8Dr06chpbbmAUcyT7QCywK7XudKpYt5RXHKI4V4WQ2rkiXFyIkx1wNe/6y 9dXA== X-Received: by 10.98.86.10 with SMTP id k10mr12936347pfb.85.1449667704076; Wed, 09 Dec 2015 05:28:24 -0800 (PST) Received: from localhost.localdomain ([2002:dddd:1b59::dddd:1b59]) by smtp.gmail.com with ESMTPSA id ah10sm11965896pad.23.2015.12.09.05.28.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Dec 2015 05:28:23 -0800 (PST) From: Wenwei Tao To: mb@lightnvm.io Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH] lightnvm: fix bio submission issue Date: Wed, 9 Dec 2015 21:26:04 +0800 Message-Id: <1449667564-7132-1-git-send-email-ww.tao0320@gmail.com> X-Mailer: git-send-email 2.5.1.windows.1 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP put bio when submission fails, since we get it before submission. And return error when backend device driver doesn't provide a submit_io method, thus we can end IO properly. Signed-off-by: Wenwei Tao --- drivers/lightnvm/gennvm.c | 2 +- drivers/lightnvm/rrpc.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c index 35dde84..c8e53c5 100644 --- a/drivers/lightnvm/gennvm.c +++ b/drivers/lightnvm/gennvm.c @@ -343,7 +343,7 @@ static void gennvm_generic_to_addr_mode(struct nvm_dev *dev, struct nvm_rq *rqd) static int gennvm_submit_io(struct nvm_dev *dev, struct nvm_rq *rqd) { if (!dev->ops->submit_io) - return 0; + return -ENODEV; /* Convert address space */ gennvm_generic_to_addr_mode(dev, rqd); diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c index 75e59c3..77b066f 100644 --- a/drivers/lightnvm/rrpc.c +++ b/drivers/lightnvm/rrpc.c @@ -636,11 +636,12 @@ static int rrpc_end_io(struct nvm_rq *rqd, int error) if (bio_data_dir(rqd->bio) == WRITE) rrpc_end_io_write(rrpc, rrqd, laddr, npages); + bio_put(rqd->bio); + if (rrqd->flags & NVM_IOTYPE_GC) return 0; rrpc_unlock_rq(rrpc, rqd); - bio_put(rqd->bio); if (npages > 1) nvm_dev_dma_free(rrpc->dev, rqd->ppa_list, rqd->dma_ppa_list); @@ -827,6 +828,7 @@ static int rrpc_submit_io(struct rrpc *rrpc, struct bio *bio, err = nvm_submit_io(rrpc->dev, rqd); if (err) { pr_err("rrpc: I/O submission failed: %d\n", err); + bio_put(bio); return NVM_IO_ERR; }