linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Matias Bjørling" <m@bjorling.me>
To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "Matias Bjørling" <m@bjorling.me>
Subject: [RFC PATCH 10/11] lightnvm: make ppa_list const in nvm_set_rqd_list
Date: Wed, 29 Jun 2016 16:41:55 +0200	[thread overview]
Message-ID: <1467211316-22373-11-git-send-email-m@bjorling.me> (raw)
In-Reply-To: <1467211316-22373-1-git-send-email-m@bjorling.me>

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 <m@bjorling.me>
---
 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 *);
-- 
2.1.4

  parent reply	other threads:[~2016-06-29 14:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-29 14:41 [RFC PATCH 00/11] Small fixes for LightNVM Matias Bjørling
2016-06-29 14:41 ` [RFC PATCH 01/11] lightnvm: remove checkpatch warning for unsigned ints Matias Bjørling
2016-06-29 14:41 ` [RFC PATCH 02/11] lightnvm: fix checkpatch terse errors Matias Bjørling
2016-06-29 14:41 ` [RFC PATCH 03/11] lightnvm: remove open/close statistics for gennvm Matias Bjørling
2016-06-29 14:41 ` [RFC PATCH 04/11] lightnvm: rename gennvm and update description Matias Bjørling
2016-06-29 14:41 ` [RFC PATCH 05/11] lightnvm: move target mgmt into media mgr Matias Bjørling
2016-06-29 14:41 ` [RFC PATCH 06/11] lightnvm: remove nested lock conflict with mm Matias Bjørling
2016-06-29 14:41 ` [RFC PATCH 07/11] lightnvm: remove unused lists from struct rrpc_block Matias Bjørling
2016-06-29 14:41 ` [RFC PATCH 08/11] lightnvm: remove _unlocked variant of [get/put]_blk Matias Bjørling
2016-06-29 14:41 ` [RFC PATCH 09/11] lightnvm: fix lun offset calculation for mark blk Matias Bjørling
2016-06-29 14:41 ` Matias Bjørling [this message]
2016-06-29 14:41 ` [RFC PATCH 11/11] lightnvm: make __nvm_submit_ppa static Matias Bjørling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467211316-22373-11-git-send-email-m@bjorling.me \
    --to=m@bjorling.me \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).