mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Matias Bjørling" <mb@lightnvm.io>
To: javier@cnexlabs.com
Cc: igor.j.konopko@intel.com, marcin.dziegielewski@intel.com,
	hans.holmberg@cnexlabs.com, hlitz@ucsc.edu,
	youngtack.jin@circuitblvd.com, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lightnvm: introduce nvm_rq_to_ppa_list
Date: Mon, 20 Aug 2018 14:46:44 +0200	[thread overview]
Message-ID: <d03ed26c-cb06-d9b7-e7ee-d0b78316641a@lightnvm.io> (raw)
In-Reply-To: <DA2F1D94-23DC-4739-9056-351992D972EE@cnexlabs.com>

On 08/20/2018 02:38 PM, Javier Gonzalez wrote:
>> On 20 Aug 2018, at 14.12, Matias Bjørling <mb@lightnvm.io> wrote:
>>
>> There is a number of places in the lightnvm subsystem where the user
>> iterates over the ppa list. Before iterating, the user must know if it
>> is a single or multiple LBAs due to vector commands using either the
>> nvm_rq ->ppa_addr or ->ppa_list fields on command submission, which
>> leads to open-coding the if/else statement.
>>
>> Instead of having multiple if/else's, move it into a function that can
>> be called by its users.
>>
>> Signed-off-by: Matias Bjørling <mb@lightnvm.io>
>> ---
>> drivers/lightnvm/pblk-read.c  | 4 +---
>> drivers/lightnvm/pblk-write.c | 5 +----
>> drivers/lightnvm/pblk.h       | 4 +---
>> include/linux/lightnvm.h      | 5 +++++
>> 4 files changed, 8 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/lightnvm/pblk-read.c b/drivers/lightnvm/pblk-read.c
>> index f275c7e5abe4..696d3a9c9cf0 100644
>> --- a/drivers/lightnvm/pblk-read.c
>> +++ b/drivers/lightnvm/pblk-read.c
>> @@ -175,11 +175,9 @@ static void __pblk_read_put_line(struct pblk *pblk, struct ppa_addr ppa)
>>
>> static void pblk_read_put_line(struct pblk *pblk, struct nvm_rq *rqd)
>> {
>> -	struct ppa_addr *ppa_list;
>> +	struct ppa_addr *ppa_list = nvm_rq_to_ppa_list(rqd);
>> 	int i;
>>
>> -	ppa_list = (rqd->nr_ppas > 1) ? rqd->ppa_list : &rqd->ppa_addr;
>> -
>> 	for (i = 0; i < rqd->nr_ppas; i++)
>> 		__pblk_read_put_line(pblk, ppa_list[i]);
>> }
>> diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c
>> index df99c45778d4..a92450ec7698 100644
>> --- a/drivers/lightnvm/pblk-write.c
>> +++ b/drivers/lightnvm/pblk-write.c
>> @@ -212,10 +212,7 @@ static void pblk_submit_rec(struct work_struct *work)
>>
>> 	pblk_log_write_err(pblk, rqd);
>>
>> -	if (rqd->nr_ppas == 1)
>> -		ppa_list = &rqd->ppa_addr;
>> -	else
>> -		ppa_list = rqd->ppa_list;
>> +	ppa_list = nvm_rq_to_ppa_list(rqd);
>>
>> 	pblk_map_remaining(pblk, ppa_list);
>> 	pblk_queue_resubmit(pblk, c_ctx);
>> diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h
>> index 64ae0c7ed3bb..bda098c7cc3b 100644
>> --- a/drivers/lightnvm/pblk.h
>> +++ b/drivers/lightnvm/pblk.h
>> @@ -1335,9 +1335,7 @@ static inline int pblk_boundary_ppa_checks(struct nvm_tgt_dev *tgt_dev,
>> static inline int pblk_check_io(struct pblk *pblk, struct nvm_rq *rqd)
>> {
>> 	struct nvm_tgt_dev *dev = pblk->dev;
>> -	struct ppa_addr *ppa_list;
>> -
>> -	ppa_list = (rqd->nr_ppas > 1) ? rqd->ppa_list : &rqd->ppa_addr;
>> +	struct ppa_addr *ppa_list = nvm_rq_to_ppa_list(rqd);
>>
>> 	if (pblk_boundary_ppa_checks(dev, ppa_list, rqd->nr_ppas)) {
>> 		WARN_ON(1);
>> diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h
>> index 0106984400bc..1497e275f90f 100644
>> --- a/include/linux/lightnvm.h
>> +++ b/include/linux/lightnvm.h
>> @@ -487,6 +487,11 @@ static inline struct ppa_addr dev_to_generic_addr(struct nvm_dev *dev,
>> 	return l;
>> }
>>
>> +static inline struct ppa_addr *nvm_rq_to_ppa_list(struct nvm_rq *rqd)
>> +{
>> +	return (rqd->nr_ppas > 1) ? rqd->ppa_list : &rqd->ppa_addr;
>> +}
>> +
>> typedef blk_qc_t (nvm_tgt_make_rq_fn)(struct request_queue *, struct bio *);
>> typedef sector_t (nvm_tgt_capacity_fn)(void *);
>> typedef void *(nvm_tgt_init_fn)(struct nvm_tgt_dev *, struct gendisk *,
>> --
>> 2.11.0
> 
> Hans made a similar patch some time ago. There are a number of places
> where you want to use this helper too, also outside of pblk. You can
> look at it here [1]
> 
> [1] https://github.com/OpenChannelSSD/linux/commits/for-4.20/pblk
> 
>     fdd88185bfed
>     17609afb2db9
> 
> Javier
> 

I like Hans' better. Hans, could you please merge my patch with yours? I 
prefer the nvm_rq_to_ppa_list naming, rqdata -> rqd, and if short-hand.


  reply	other threads:[~2018-08-20 12:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-20 12:12 Matias Bjørling
2018-08-20 12:38 ` Javier Gonzalez
2018-08-20 12:46   ` Matias Bjørling [this message]
2018-08-20 14:36     ` Hans Holmberg

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=d03ed26c-cb06-d9b7-e7ee-d0b78316641a@lightnvm.io \
    --to=mb@lightnvm.io \
    --cc=hans.holmberg@cnexlabs.com \
    --cc=hlitz@ucsc.edu \
    --cc=igor.j.konopko@intel.com \
    --cc=javier@cnexlabs.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcin.dziegielewski@intel.com \
    --cc=youngtack.jin@circuitblvd.com \
    /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

all inboxes | Powered by JetHome®