Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4109557imm; Mon, 20 Aug 2018 09:59:16 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwrpG/4Pk167yZN1OjUg4ENceLOKCMGJZi7f33N0hlUVFMl6oNzZAhnpJ0KhLCH9R1alijM X-Received: by 2002:a17:902:744a:: with SMTP id e10-v6mr16530347plt.165.1534784356858; Mon, 20 Aug 2018 09:59:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534784356; cv=none; d=google.com; s=arc-20160816; b=IUqSJes5Is6a7jLKBKS9DlnlV8dxqtOwsVtZC5sbPCxmBUYPDcdxQ39/KsqJSR22AQ DZ6t+dlawgLCiSzM8xxXPE58o1YpkyLNkOAf6Ec1SXPYEP3C7hLiYfDp3bqQSLVptwvO Gvgkkf66n/lNuosKbLXFGPGExtEO/jG31VVMxZa0JcH40K0pslLsW6kHayyzY3BJnvp1 0h1Ol5dD3dhsJeBaNZ5NuNzkUkW3SsKxvffMrfoi/LI9UaLA4oRXBfhKiVjHYdpRCSMw MrR+NfIq50m0gZj8tca3m+YSDbG+1ThZ1WzYtzHYYT51zf6GEDmjQlR4R1YnimiPNDV8 2x+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=fH+i8pRfg0nbB2m88oq4W1kCxYUFJkurjeXrZA2aAZc=; b=0wo0h9XsYQttIMNHzFPVC5xeoibnWn5+7lXrVCrvHscfBethTC8+sx8nWGZPPU3NQZ H1Lbm+66553UYuGHh/caSLh7D7RjwvWFMsiY7tXLbafnxtY4USF1XT5YN02KGkBmcIWm x8cyMav5PIiyz+UaMZhYD0yw8qbZZJg6C9fGjw/5qk1P2aTDlXbfx99E1O9Xh0Y6+9ZG W4fb9v+VCPUcvaAnYyYlnkb/UnNW6rP69e0DJfcczdLAxzbd/6gQqtRf2h74m/hDb5V/ UpRL4J66WPbh5kItFHSoiNO14Itn5RPjFfUkQqIiuUj2AzWYXQf0yZ2Xe4qmLOxUvvXH 4UbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@owltronix-com.20150623.gappssmtp.com header.s=20150623 header.b=QbrhAFEM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a8-v6si10223581ple.189.2018.08.20.09.59.00; Mon, 20 Aug 2018 09:59:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@owltronix-com.20150623.gappssmtp.com header.s=20150623 header.b=QbrhAFEM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727047AbeHTRwv (ORCPT + 99 others); Mon, 20 Aug 2018 13:52:51 -0400 Received: from mail-ua1-f66.google.com ([209.85.222.66]:33230 "EHLO mail-ua1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726826AbeHTRwv (ORCPT ); Mon, 20 Aug 2018 13:52:51 -0400 Received: by mail-ua1-f66.google.com with SMTP id i4-v6so9860197uak.0 for ; Mon, 20 Aug 2018 07:36:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owltronix-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=fH+i8pRfg0nbB2m88oq4W1kCxYUFJkurjeXrZA2aAZc=; b=QbrhAFEMyCipI8lZIjFcKpSArNrD0KoEHg9ClO4ZTqnm6zwE73Yf+A/eKabJFs2JEZ cJ0OfKZfE92pZm/JT4Te1eCpbUk1g9WfoM/27u3+wP2i9e07pC6i+k0ni3IJJwfYfhDt /zeUHE7v1G+NG78VbDEwGo00FwhP/zcF/ga/hNpCREWm5yQesu1StFdQiTuKJ6fkH+wG +97i/45EVuGycS3oiC6tVrYtWqitiw2sMDxV9JEtX+F3O0rmiKrUdUQPNSQwoflQpBK+ Nl8FXQhdT5hqMLXHN2e9Bcr1IKWO7HJ9XknzIWu/7X1LtfR95s4E+wRkHgyKx7awEN8i WwNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=fH+i8pRfg0nbB2m88oq4W1kCxYUFJkurjeXrZA2aAZc=; b=ImEKqZlHyfTZIFO1ijOdzSs+qV/FfQ+NMRoI+L1kLUxytRjmCfRJ5ZckU2aP3aQnbN Xu7kpBi/TZPun25+H4CVJklWrtqwGuYr1ND4/KZRVdalezuEk39dAlQQd780Q9Gm0teI zptI7hXh48i+i3VT+1Qibq7QtlMezqGUBWR4WeEk3LZ0Pfh216gYX6nD1BxUYno93iI0 yC3u9qOxhKNZ4ry+lFxQzrxKSw6jzg8ZRudBX0G2i3MVq6vNYNEm/xDZKLdLylgCjTLj 3AMPxF8+gLLBHTHcAk2ZmVaWKett4qOokgJj6RrE7+hSRB30XZSWV/fzMn0TfAyjkegc kLlA== X-Gm-Message-State: AOUpUlE6oVakDsu4fBzR4nmsBkq8+092ukj1+SbhPgi8nbU9u//aWj/2 BwwC62fKBrLTeLxL32Dv93jlTRcc53CbKXzvzTwwmQ== X-Received: by 2002:ab0:6583:: with SMTP id v3-v6mr30372803uam.107.1534775816217; Mon, 20 Aug 2018 07:36:56 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a67:984f:0:0:0:0:0 with HTTP; Mon, 20 Aug 2018 07:36:55 -0700 (PDT) In-Reply-To: References: <20180820121217.11393-1-mb@lightnvm.io> From: Hans Holmberg Date: Mon, 20 Aug 2018 16:36:55 +0200 Message-ID: Subject: Re: [PATCH] lightnvm: introduce nvm_rq_to_ppa_list To: =?UTF-8?Q?Matias_Bj=C3=B8rling?= Cc: Javier Gonzalez , igor.j.konopko@intel.com, marcin.dziegielewski@intel.com, Hans Holmberg , hlitz@ucsc.edu, youngtack.jin@circuitblvd.com, linux-block@vger.kernel.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Will do. i'll squash your patch with my two. Your commit message is better, so i hope you don't mind me using it :) All the best, Hans On Mon, Aug 20, 2018 at 2:46 PM, Matias Bj=C3=B8rling wrot= e: > On 08/20/2018 02:38 PM, Javier Gonzalez wrote: >>> >>> On 20 Aug 2018, at 14.12, Matias Bj=C3=B8rling 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=C3=B8rling >>> --- >>> 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 =3D nvm_rq_to_ppa_list(rqd); >>> int i; >>> >>> - ppa_list =3D (rqd->nr_ppas > 1) ? rqd->ppa_list : &rqd->ppa_add= r; >>> - >>> for (i =3D 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 =3D=3D 1) >>> - ppa_list =3D &rqd->ppa_addr; >>> - else >>> - ppa_list =3D rqd->ppa_list; >>> + ppa_list =3D 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 =3D pblk->dev; >>> - struct ppa_addr *ppa_list; >>> - >>> - ppa_list =3D (rqd->nr_ppas > 1) ? rqd->ppa_list : &rqd->ppa_add= r; >>> + struct ppa_addr *ppa_list =3D 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 bi= o >>> *); >>> 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. >