Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp54599imm; Tue, 21 Aug 2018 14:27:57 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxEZuIhae5baVCJfOw4rfy9eqR4f8vLSnxg4WPGHL0toCeWhB3GyyRj4oCjNks36657ldK3 X-Received: by 2002:a17:902:1ab:: with SMTP id b40-v6mr51368125plb.55.1534886877437; Tue, 21 Aug 2018 14:27:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534886877; cv=none; d=google.com; s=arc-20160816; b=X5t0rqRT+jVA5/3c5gSwnx+rd/G6d9mj4qgVOqdF1svAXAlJ9snWh6AwsJh++gufuF iXiQ+mqB4WJOJMdFwiUkldy2bhziKXqKjRSN0inMlfJc32QUy4A2NZav1OkhOcLAXIZZ Uxb+VLXR9+GOdLIYCxcuHu37ZmEqn9Zcd8FzLEqMquHeMp7i7cW7BTd1tQP+o85nTbQv M+2xUZ2nj4iAPMqkneV5DJCU77OTY+xILtEwTvzUiCCouciEUuvLv4aGaLHFK4/8B0r0 U3wdK1uruQwmaFs+33Nk9QH/k0Zo+VvofkzlHUPM2RXXhMINLVcSb4FufLFLcjKuYEw7 hC3g== 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:in-reply-to:references:mime-version :dkim-signature:arc-authentication-results; bh=Z410QeI9xStMbX3pyICN17asT3/ywjL4aa6wXQOzhm4=; b=CznbRbdk16VjbObIwOO1jkkZdeodgMfB8/9W61k/l8CHeuWYTWe4ZncA3HIZXTlXKw AZgk5amuo1THuUfEkyBrGZ/eorTAycenyypaH5doFz/748LGS9TW96uaSNOkW4BE63jB MlnJjFVrddOR7atN3uTnuir+WVtRw3KhZSJGfx9mYEe6rr8+mvghKqXr6hdVrjDkDTDQ azUSe7ZtDzDkTncPCI4odn02qHhEbRO0+nwXNqcJ4/ekyjKlbLv/92ojHNfQfKc9NYwe jyQIJ7MySGusrU6ZK7fqVXPBZN5YKAcJOV5S/sV9W+0IOPN8fe8EscMtNfNpJdwu0kHj RBKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ucsc.edu header.s=ucsc-google header.b=lIs6V7te; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ucsc.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x8-v6si3982127pgr.445.2018.08.21.14.27.42; Tue, 21 Aug 2018 14:27:57 -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=@ucsc.edu header.s=ucsc-google header.b=lIs6V7te; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ucsc.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727611AbeHVAqZ (ORCPT + 99 others); Tue, 21 Aug 2018 20:46:25 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36914 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726703AbeHVAqY (ORCPT ); Tue, 21 Aug 2018 20:46:24 -0400 Received: by mail-wr1-f65.google.com with SMTP id u12-v6so17007944wrr.4 for ; Tue, 21 Aug 2018 14:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucsc.edu; s=ucsc-google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Z410QeI9xStMbX3pyICN17asT3/ywjL4aa6wXQOzhm4=; b=lIs6V7tel5YmPobUC5jT0ksCZ02hI+eKsiEgGJRRfAdJCGsjNeRmgukAU55A6fmHfP +a/GjPywHFuZg0fKCruYGfCFp05BLJam2G3lGqWO2+7YN6Vtx2VD5/5EVbOpNJqEDc4g ucm3fQ5YX4hmAS0mFy7Q8qXhL3xo+F9ifV5cQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Z410QeI9xStMbX3pyICN17asT3/ywjL4aa6wXQOzhm4=; b=YBvhyDOh4XMwc2IKgG9Yn+VWce59jKQSplz1LiIH+drCyXCDQSxYMk83M0E19LXPCf 5UzbtDOxDgrGaAXbdE9soAYPSxP4ODdSWVTpjbntCEwgrz0NNHnXZAZMnBBiExNY1urp YyIRnONQqe4kCq5S55BD8LOV+M81UnfDKFna+ETJLnGHoQg/sTU+mwOpYf2RsqoqFZqy SKuaAw97XGu1RPL3xPo/u0f9BWXLQE9gRPTkFDwHzSy0cys+VZdPRzS0skpqw8+zeelw /KBeXhm61LSm2BxnEThUQxSMJMd3SfzgEaymo2Q2ujx5jmZ1ShZ+XyRCu4E5YdubfZBU hIRQ== X-Gm-Message-State: APzg51AIwuI88lMg9MFil1O5GOdf0cQuoLMcZDw8Cpe7FVbZY3eC049R ckUbSAT+HW8u0jNkBnjAICEJ0SyYxGKeacCas58qFA== X-Received: by 2002:adf:9281:: with SMTP id 1-v6mr4839135wrn.69.1534886672897; Tue, 21 Aug 2018 14:24:32 -0700 (PDT) MIME-Version: 1.0 References: <20180821114441.23147-1-mb@lightnvm.io> In-Reply-To: <20180821114441.23147-1-mb@lightnvm.io> From: Heiner Litz Date: Tue, 21 Aug 2018 23:24:01 +0200 Message-ID: Subject: Re: [PATCH v2] lightnvm: pblk: refactor put line fn on read completion To: =?UTF-8?Q?Matias_Bj=C3=B8rling?= Cc: igor.j.konopko@intel.com, marcin.dziegielewski@intel.com, Javier Gonzalez , hans.holmberg@cnexlabs.com, youngtack.jin@circuitblvd.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org 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 Thanks, Matias! LGTM On Tue, Aug 21, 2018 at 1:44 PM Matias Bj=C3=B8rling wrote= : > > The read completion path uses the put_line variable to decide whether > the reference on a line should be released. The function name used for > that is pblk_read_put_rqd_kref, which could lead one to believe that it > is the rqd that is releasing the reference, while it is the line > reference that is put. > > Rename and also split the function in two to account for either rqd or > single ppa callers and move it to core, such that it later can be used > in the write path as well. > > Signed-off-by: Matias Bj=C3=B8rling > Reviewed-by: Javier Gonz=C3=A1lez > Reviewed-by: Heiner Litz > > Changes since v1: > > Moved into core for Heiner to later integrate with his RAIL > patches. > --- > drivers/lightnvm/pblk-core.c | 19 +++++++++++++++++++ > drivers/lightnvm/pblk-read.c | 18 +----------------- > drivers/lightnvm/pblk.h | 2 ++ > 3 files changed, 22 insertions(+), 17 deletions(-) > > diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c > index e0b513d07e14..5f99cf396072 100644 > --- a/drivers/lightnvm/pblk-core.c > +++ b/drivers/lightnvm/pblk-core.c > @@ -1426,6 +1426,25 @@ struct pblk_line *pblk_line_get_first_data(struct = pblk *pblk) > return line; > } > > +void pblk_ppa_to_line_put(struct pblk *pblk, struct ppa_addr ppa) > +{ > + struct pblk_line *line; > + > + line =3D &pblk->lines[pblk_ppa_to_line(ppa)]; > + kref_put(&line->ref, pblk_line_put_wq); > +} > + > +void pblk_rq_to_line_put(struct pblk *pblk, struct nvm_rq *rqd) > +{ > + struct ppa_addr *ppa_list; > + int i; > + > + ppa_list =3D (rqd->nr_ppas > 1) ? rqd->ppa_list : &rqd->ppa_addr; > + > + for (i =3D 0; i < rqd->nr_ppas; i++) > + pblk_ppa_to_line_put(pblk, ppa_list[i]); > +} > + > static void pblk_stop_writes(struct pblk *pblk, struct pblk_line *line) > { > lockdep_assert_held(&pblk->l_mg.free_lock); > diff --git a/drivers/lightnvm/pblk-read.c b/drivers/lightnvm/pblk-read.c > index 1ad501721d0f..dc8233f3fd6c 100644 > --- a/drivers/lightnvm/pblk-read.c > +++ b/drivers/lightnvm/pblk-read.c > @@ -165,22 +165,6 @@ static void pblk_read_check_rand(struct pblk *pblk, = struct nvm_rq *rqd, > WARN_ONCE(j !=3D rqd->nr_ppas, "pblk: corrupted random request\n"= ); > } > > -static void pblk_read_put_rqd_kref(struct pblk *pblk, struct nvm_rq *rqd= ) > -{ > - struct ppa_addr *ppa_list; > - int i; > - > - ppa_list =3D (rqd->nr_ppas > 1) ? rqd->ppa_list : &rqd->ppa_addr; > - > - for (i =3D 0; i < rqd->nr_ppas; i++) { > - struct ppa_addr ppa =3D ppa_list[i]; > - struct pblk_line *line; > - > - line =3D &pblk->lines[pblk_ppa_to_line(ppa)]; > - kref_put(&line->ref, pblk_line_put_wq); > - } > -} > - > static void pblk_end_user_read(struct bio *bio) > { > #ifdef CONFIG_NVM_PBLK_DEBUG > @@ -208,7 +192,7 @@ static void __pblk_end_io_read(struct pblk *pblk, str= uct nvm_rq *rqd, > bio_put(int_bio); > > if (put_line) > - pblk_read_put_rqd_kref(pblk, rqd); > + pblk_rq_to_line_put(pblk, rqd); > > #ifdef CONFIG_NVM_PBLK_DEBUG > atomic_long_add(rqd->nr_ppas, &pblk->sync_reads); > diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h > index 64ae0c7ed3bb..be67bbfa3d0a 100644 > --- a/drivers/lightnvm/pblk.h > +++ b/drivers/lightnvm/pblk.h > @@ -787,6 +787,8 @@ struct bio *pblk_bio_map_addr(struct pblk *pblk, void= *data, > struct pblk_line *pblk_line_get(struct pblk *pblk); > struct pblk_line *pblk_line_get_first_data(struct pblk *pblk); > struct pblk_line *pblk_line_replace_data(struct pblk *pblk); > +void pblk_ppa_to_line_put(struct pblk *pblk, struct ppa_addr ppa); > +void pblk_rq_to_line_put(struct pblk *pblk, struct nvm_rq *rqd); > int pblk_line_recov_alloc(struct pblk *pblk, struct pblk_line *line); > void pblk_line_recov_close(struct pblk *pblk, struct pblk_line *line); > struct pblk_line *pblk_line_get_data(struct pblk *pblk); > -- > 2.11.0 >