From patchwork Tue Jan 24 11:52:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 9535029 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EE46D6042D for ; Tue, 24 Jan 2017 11:52:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E12CD205AD for ; Tue, 24 Jan 2017 11:52:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4D9A26CFC; Tue, 24 Jan 2017 11:52:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52434205AD for ; Tue, 24 Jan 2017 11:52:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750904AbdAXLwu (ORCPT ); Tue, 24 Jan 2017 06:52:50 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33128 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750888AbdAXLwt (ORCPT ); Tue, 24 Jan 2017 06:52:49 -0500 Received: by mail-wm0-f66.google.com with SMTP id r144so34103192wme.0 for ; Tue, 24 Jan 2017 03:52:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mzbeIUF2cMUjWedEI2cWu+i8ifSJv8iIKoWb5bPQQHg=; b=aBcdoZEP2nf1FJMtD2MIBYlF1dC0nQFrrTcmudyizv0UccWEUoZlvtEnc1W/ui69BA V1hzfrD6GfuW0Qpt9TZ3s8LomZDnlmXU9YrAh6JO1o+AdYERAW9pXAqdGol30/DNG9Dg DEbVl2Alu0lvt7LUO9FNAhm5j1i0BD7JBdsa8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mzbeIUF2cMUjWedEI2cWu+i8ifSJv8iIKoWb5bPQQHg=; b=LIIhrSKhlxXGaf+mIde2xJKwqmqic8uXBIRmn0luGpgYOeJTfcWm9o4EFcijVK0a6Z yIJTDGTNObYX/IP+9xn+nx7wMlOB3c4xAZKWfOsZSwMlbf60Hob+VryCt3F8uH5dR7Fu i0NVF+S6bDqndIuppSJrJzjNybAP6H0OrRmd6LkiyCURvcIEnYV2zdLyljteH1gkbzmg aN14Ejqq7TGckNv0k7iF8TuPWh3MugqITA+efDSxIhyD3PpTCe+WH7m8E4xYil0MC7jG MR4XgCEa5sC1ppiEstxOjjThitu7aRjgyPPfb+wybZobCAV9XDhgMiTU+/9rHN7HebWc uBog== X-Gm-Message-State: AIkVDXLlLbH6Z1lTye4qKRF0q5/BpHZbNg+HsG4IEaaD5v14vNrkv5R2yfm/kAukM1Ry7A== X-Received: by 10.28.98.2 with SMTP id w2mr19297753wmb.66.1485258768098; Tue, 24 Jan 2017 03:52:48 -0800 (PST) Received: from skyninja.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id s17sm19558305wrc.6.2017.01.24.03.52.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 03:52:47 -0800 (PST) From: "=?UTF-8?q?Matias=20Bj=C3=B8rling?=" X-Google-Original-From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH] lightnvm: use end_io callback instead of instance Date: Tue, 24 Jan 2017 12:52:37 +0100 Message-Id: <20170124115237.18698-1-matias@cnexlabs.com> X-Mailer: git-send-email 2.9.3 MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When the lightnvm core had the "gennvm" layer between the device and the target, there was a need for the core to be able to figure out which target it should send an end_io callback to. Leading to a "double" end_io, first for the media manager instance, and then for the target instance. Now that core and gennvm is merged, there is no longer a need for this, and a single end_io callback will do. Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 5 ++--- drivers/lightnvm/rrpc.c | 11 +++++------ drivers/lightnvm/rrpc.h | 3 --- include/linux/lightnvm.h | 11 +++-------- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 80cd767..4abd334 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -776,14 +776,13 @@ EXPORT_SYMBOL(nvm_free_rqd_ppalist); void nvm_end_io(struct nvm_rq *rqd, int error) { struct nvm_tgt_dev *tgt_dev = rqd->dev; - struct nvm_tgt_instance *ins = rqd->ins; /* Convert address space */ if (tgt_dev) nvm_rq_dev_to_tgt(tgt_dev, rqd); - rqd->error = error; - ins->tt->end_io(rqd); + if (rqd->end_io) + rqd->end_io(rqd, error); } EXPORT_SYMBOL(nvm_end_io); diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c index 9fb7de3..c399f55 100644 --- a/drivers/lightnvm/rrpc.c +++ b/drivers/lightnvm/rrpc.c @@ -777,16 +777,16 @@ static void rrpc_end_io_write(struct rrpc *rrpc, struct rrpc_rq *rrqd, } } -static void rrpc_end_io(struct nvm_rq *rqd) +static void rrpc_end_io(struct nvm_rq *rqd, int error) { - struct rrpc *rrpc = container_of(rqd->ins, struct rrpc, instance); + struct rrpc *rrpc = rqd->private; struct nvm_tgt_dev *dev = rrpc->dev; struct rrpc_rq *rrqd = nvm_rq_to_pdu(rqd); uint8_t npages = rqd->nr_ppas; sector_t laddr = rrpc_get_laddr(rqd->bio) - npages; if (bio_data_dir(rqd->bio) == WRITE) { - if (rqd->error == NVM_RSP_ERR_FAILWRITE) + if (error == NVM_RSP_ERR_FAILWRITE) rrpc_mark_bad_block(rrpc, rqd); rrpc_end_io_write(rrpc, rrqd, laddr, npages); @@ -972,8 +972,9 @@ static int rrpc_submit_io(struct rrpc *rrpc, struct bio *bio, bio_get(bio); rqd->bio = bio; - rqd->ins = &rrpc->instance; + rqd->private = rrpc; rqd->nr_ppas = nr_pages; + rqd->end_io = rrpc_end_io; rrq->flags = flags; err = nvm_submit_io(dev, rqd); @@ -1532,7 +1533,6 @@ static void *rrpc_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk) if (!rrpc) return ERR_PTR(-ENOMEM); - rrpc->instance.tt = &tt_rrpc; rrpc->dev = dev; rrpc->disk = tdisk; @@ -1611,7 +1611,6 @@ static struct nvm_tgt_type tt_rrpc = { .make_rq = rrpc_make_rq, .capacity = rrpc_capacity, - .end_io = rrpc_end_io, .init = rrpc_init, .exit = rrpc_exit, diff --git a/drivers/lightnvm/rrpc.h b/drivers/lightnvm/rrpc.h index 94e4d73..fdb6ff9 100644 --- a/drivers/lightnvm/rrpc.h +++ b/drivers/lightnvm/rrpc.h @@ -102,9 +102,6 @@ struct rrpc_lun { }; struct rrpc { - /* instance must be kept in top to resolve rrpc in unprep */ - struct nvm_tgt_instance instance; - struct nvm_tgt_dev *dev; struct gendisk *disk; diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index ce0b2da..f6e2376 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -213,10 +213,6 @@ struct nvm_target { struct gendisk *disk; }; -struct nvm_tgt_instance { - struct nvm_tgt_type *tt; -}; - #define ADDR_EMPTY (~0ULL) #define NVM_VERSION_MAJOR 1 @@ -224,10 +220,9 @@ struct nvm_tgt_instance { #define NVM_VERSION_PATCH 0 struct nvm_rq; -typedef void (nvm_end_io_fn)(struct nvm_rq *); +typedef void (nvm_end_io_fn)(struct nvm_rq *, int); struct nvm_rq { - struct nvm_tgt_instance *ins; struct nvm_tgt_dev *dev; struct bio *bio; @@ -250,7 +245,8 @@ struct nvm_rq { uint16_t flags; u64 ppa_status; /* ppa media status */ - int error; + + void *private; }; static inline struct nvm_rq *nvm_rq_from_pdu(void *pdu) @@ -450,7 +446,6 @@ struct nvm_tgt_type { /* target entry points */ nvm_tgt_make_rq_fn *make_rq; nvm_tgt_capacity_fn *capacity; - nvm_end_io_fn *end_io; /* module-specific init/teardown */ nvm_tgt_init_fn *init;