From patchwork Thu Jul 7 07:54:22 2016 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: 9218031 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 D4275607D9 for ; Thu, 7 Jul 2016 07:55:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C75BB28780 for ; Thu, 7 Jul 2016 07:55:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B823C2878F; Thu, 7 Jul 2016 07:55:14 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 3C45928780 for ; Thu, 7 Jul 2016 07:55:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933284AbcGGHy7 (ORCPT ); Thu, 7 Jul 2016 03:54:59 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35209 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933230AbcGGHy6 (ORCPT ); Thu, 7 Jul 2016 03:54:58 -0400 Received: by mail-wm0-f67.google.com with SMTP id a66so3514383wme.2 for ; Thu, 07 Jul 2016 00:54:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HadtnoNemrT0jM757p+jhuIsOjGqmxJ4F6fyn9TCsWU=; b=EoG9ALt6V79rgFME+aBAK285QjR1Q4XXDlAuzsM7cYtH+UN/qT5S4TLRw4DKbgXbRu VIWN+idMbd28wsS6azux2HltgahVhUi63JTUGczOfI0r1Z0jKwV26Dp6YKm1ub4KMgN1 uGxtt6V1YDgomYk7/wwcYGRN6AzwSRZpmpkHE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HadtnoNemrT0jM757p+jhuIsOjGqmxJ4F6fyn9TCsWU=; b=hYwhx//xjXJq9vaBL9wgQTSPDhgE9ZlFloLGavuo4G89s6sq6XkBF+wWbceLr0u3eZ lGakciMSk5cbntIZgddHt6mCSUbogfAyFVTHll6S7lOuW3FPYwYd0iPdQPEb1Sr6pSaN 8HW1dAFU9ZQHlJzaI0VcyBKsOWu0r0gSV7al4VeQ7F32qqVBMOumNr8KyqRJpTj2GD/B 4LRD2VsZwBIds3sBgizcoCsw/wBhH3P5FJWKfP82Cc3nMMPCtKFyLHylxl4yJz/GKwFG UE3+uIdMdJfu9LScjIjsVv/8czG3BUFic97urlHjBqQ2JY5KL1OKxSoHxpusPwcuiUZm 0Oag== X-Gm-Message-State: ALyK8tK7yLPrnAXhIj8VDY9DOnz0ynxKpKk49iMeIhX9PvZ1zUwa1HrVyipPGs7AsjLleQ== X-Received: by 10.28.54.147 with SMTP id y19mr1334982wmh.68.1467878091137; Thu, 07 Jul 2016 00:54:51 -0700 (PDT) Received: from Macroninja.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id i74sm1654796wmg.21.2016.07.07.00.54.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Jul 2016 00:54:50 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@fb.com Cc: =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 16/17] lightnvm: make ppa_list const in nvm_set_rqd_list Date: Thu, 7 Jul 2016 09:54:22 +0200 Message-Id: <1467878063-22919-17-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1467878063-22919-1-git-send-email-m@bjorling.me> References: <1467878063-22919-1-git-send-email-m@bjorling.me> 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 The passed by reference ppa list in nvm_set_rqd_list() is updated when multiple planes are available. In that case, each PPA plane is incremented when the device side PPA list is created. This prevents the caller to rely on the PPA list to be unmodified after a call. Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 8 +++++--- include/linux/lightnvm.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index ddc8098..00b64f7 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -237,9 +237,10 @@ void nvm_generic_to_addr_mode(struct nvm_dev *dev, struct nvm_rq *rqd) EXPORT_SYMBOL(nvm_generic_to_addr_mode); int nvm_set_rqd_ppalist(struct nvm_dev *dev, struct nvm_rq *rqd, - struct ppa_addr *ppas, int nr_ppas, int vblk) + const struct ppa_addr *ppas, int nr_ppas, int vblk) { int i, plane_cnt, pl_idx; + struct ppa_addr ppa; if ((!vblk || dev->plane_mode == NVM_PLANE_SINGLE) && nr_ppas == 1) { rqd->nr_ppas = nr_ppas; @@ -264,8 +265,9 @@ int nvm_set_rqd_ppalist(struct nvm_dev *dev, struct nvm_rq *rqd, for (i = 0; i < nr_ppas; i++) { for (pl_idx = 0; pl_idx < plane_cnt; pl_idx++) { - ppas[i].g.pl = pl_idx; - rqd->ppa_list[(pl_idx * nr_ppas) + i] = ppas[i]; + ppa = ppas[i]; + ppa.g.pl = pl_idx; + rqd->ppa_list[(pl_idx * nr_ppas) + i] = ppa; } } } diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index e9836cf..ba78b83 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -534,7 +534,7 @@ extern int nvm_submit_io(struct nvm_dev *, struct nvm_rq *); extern void nvm_generic_to_addr_mode(struct nvm_dev *, struct nvm_rq *); extern void nvm_addr_to_generic_mode(struct nvm_dev *, struct nvm_rq *); extern int nvm_set_rqd_ppalist(struct nvm_dev *, struct nvm_rq *, - struct ppa_addr *, int, int); + const struct ppa_addr *, int, int); extern void nvm_free_rqd_ppalist(struct nvm_dev *, struct nvm_rq *); extern int nvm_erase_ppa(struct nvm_dev *, struct ppa_addr *, int); extern int nvm_erase_blk(struct nvm_dev *, struct nvm_block *);