Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp440028imm; Fri, 1 Jun 2018 03:49:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIHycBXctX2bU67UtWwtO8JrCz9dD0bTuIVrnPOcpirbAJgwAqJSktiO+kumDPxq9dVVdMb X-Received: by 2002:a17:902:6546:: with SMTP id d6-v6mr10074003pln.196.1527850142915; Fri, 01 Jun 2018 03:49:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527850142; cv=none; d=google.com; s=arc-20160816; b=pt62m4KQBREG1GT71Kz6oEuGDE1/JF5EgXc6a8tzSZ1mAqZfJBHr2IPleEWKY8QJTQ tMNSrLIVHpdzd05+w4gIZNg3vXikyXl1bbTjdanEGFEQm9p5oJkrNW4D5jbDuuIxaxl1 DJUXb9MBakRT9bgO9LnHj6V9Bvv3Zb8rT6K+pl3mQ2bmfTT+TrL6Ia8gIqFLPduLuMgs /djzYtwrch6bh7bhI+bmSNYogNTHChuHkfv7UsrcU9l1iZO/NJjnWoAoIEldSZnWaJBq 1CgkHGzD0aRfKNwP3+oN3MBmtSzct8D7mHTckMPs7erbBL+Isie3p01aYKB+4hDYvBec t00g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature:arc-authentication-results; bh=jbmVo9dMKvSiCyLKJI80RBK9enV0E8/AP8lTgW8/u78=; b=GR0Gjm+OpE2iG0g7E5y+6zSm/1/172ZWyh6KFOUjOw8wNlH5bo/AXQHXIhum4r9h30 ZvqGdylJvMcbye+niWiIQFqXu7QmGxace/LMj/qzzzlBVpJF0WrB9xwKaY39u5W5nz25 O/OHoZBIPbAC6+MG1H4CifQUa0Dveii4LJUE8/Jbrh9Tv9rgayBO/a5EmPK+GLZwDFCB dPMs79AmNRqPbz2SxDXWp51tIRuEjqX0aDKDo+U7LUAWWVmvtRF9SOwry99Fd5VmSykA N37JFUdxQ2ADOeZuzrZPHTWWpJsIroDgDJWIpKvQA66Xe/WXhTZ0oqxFBCZ1OGfRrHI1 yzTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YMQCgfT2; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s1-v6si38147841plr.332.2018.06.01.03.48.48; Fri, 01 Jun 2018 03:49:02 -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=@gmail.com header.s=20161025 header.b=YMQCgfT2; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751378AbeFAKsP (ORCPT + 99 others); Fri, 1 Jun 2018 06:48:15 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33157 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750790AbeFAKsN (ORCPT ); Fri, 1 Jun 2018 06:48:13 -0400 Received: by mail-wm0-f68.google.com with SMTP id z6-v6so4889852wma.0; Fri, 01 Jun 2018 03:48:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=jbmVo9dMKvSiCyLKJI80RBK9enV0E8/AP8lTgW8/u78=; b=YMQCgfT2lT5JtaSWrWjYF9M8crM484jN7ZXqsJ1OZDQCaKSTtmL9cA+GY5AGzGdtJ2 mmTTBnjUQED2nTrOI7kN0n1SNTg2UOZsle//ThjEpfxs1d07jalMdpG0/6Stwcf1z/r3 rv8w8JlTcGvWrVf3f9GLfdPi7Dbkf0R0eW1t9RV6K+8aaY+2S5SxjTMyJVFULZIE0hxY Bk9W0XQU+fEvw1iBZK6okTfRH8OOy8zvmqM12dVY2SHvJUmRL32YbkwwCmsvhdPpjhJW JAWADk9PgbtwHY4EEAXUUjCczCzYgVVd1tp8oNb+yPIwE3EdzdGzErpK6Y87lpyWLlBU vVQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=jbmVo9dMKvSiCyLKJI80RBK9enV0E8/AP8lTgW8/u78=; b=NheVNBTvq+1gIJ/IeOAR4XfalONuDiQcaJ4MzIJ0y5PPDLdHmXULINxkMG5pPrE2/K +7aOgmbDrMUCcUpLOdd0W31zOvhN68VjS8DpfF5zWPIK4tQEuyewEMmIN81AUarXj/0e 6mj0Eebpqn2sRZ9uli4Tsj4Aa9vPyGV+E5GO96mpxtNQCNTk0oHhDEwZfvy/v4xUYoLz uVT4sBAr6NzZagPCB4HJAGp1DI+maUvznt+QPhHwOS8C9Se+7/k1Itx8RL9bQQQwlumq 9+NgW+LLDLrz5Q99SK5ILPv7pxrqne6ZsPbj6zHBgfq8Tl8EkhcmizF0fOhA8p8rDjmA jIdQ== X-Gm-Message-State: ALKqPwe52AAKyBJ5zylhOrY3Ggj6tJQDEa6W4V2UGHr1dCJkJfs4axCW SjgYWXB/CL1ZpYDDcwR75zU= X-Received: by 2002:a50:ad78:: with SMTP id z53-v6mr7142499edc.306.1527850092422; Fri, 01 Jun 2018 03:48:12 -0700 (PDT) Received: from [172.20.28.91] (6164198-cl69.boa.fiberby.dk. [193.106.164.198]) by smtp.gmail.com with ESMTPSA id c7-v6sm21297298edi.79.2018.06.01.03.48.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jun 2018 03:48:11 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (1.0) Subject: Re: [PATCH] lightnvm: pblk: remove unnecessary bio_get/put From: =?utf-8?Q?Javier_Gonz=C3=A1lez?= X-Mailer: iPhone Mail (15E302) In-Reply-To: Date: Fri, 1 Jun 2018 12:48:10 +0200 Cc: =?utf-8?Q?Javier_Gonz=C3=A1lez?= , Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <1523874157-5216-1-git-send-email-javier@cnexlabs.com> <4453F92A-4B78-4D2B-B438-3C807DF13514@javigon.com> To: =?utf-8?Q?Matias_Bj=C3=B8rling?= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On 1 Jun 2018, at 12.42, Matias Bj=C3=B8rling wrote: >=20 >> On 06/01/2018 12:22 PM, Javier Gonz=C3=A1lez wrote: >> Hi Matias, >> I see that you did not pick up this patch for 4.18. Any reason for it? >> Thanks, >> Javier >>> On 16 Apr 2018, at 12.22, Javier Gonz=C3=A1lez wrot= e: >>>=20 >>> In the read path, pblk gets a reference to the incoming bio and puts it >>> after ending the bio. Though this behavior is correct, it is unnecessary= >>> since pblk is the one putting the bio, therefore, it cannot disappear >>> underneath it. >>>=20 >>> Removing this reference, allows to clean up rqd->bio and avoid pointer >>> bouncing for the different read paths. Now, the incoming bio always >>> resides in the read context and pblk's internal bios (if any) reside in >>> rqd->bio. >>>=20 >>> Signed-off-by: Javier Gonz=C3=A1lez >>> --- >>> drivers/lightnvm/pblk-read.c | 57 +++++++++++++++++++-------------------= ------ >>> 1 file changed, 24 insertions(+), 33 deletions(-) >>>=20 >>> diff --git a/drivers/lightnvm/pblk-read.c b/drivers/lightnvm/pblk-read.c= >>> index 2f8224354c62..5464e4177c87 100644 >>> --- a/drivers/lightnvm/pblk-read.c >>> +++ b/drivers/lightnvm/pblk-read.c >>> @@ -39,10 +39,10 @@ static int pblk_read_from_cache(struct pblk *pblk, s= truct bio *bio, >>> } >>>=20 >>> static void pblk_read_ppalist_rq(struct pblk *pblk, struct nvm_rq *rqd, >>> - sector_t blba, unsigned long *read_bitmap) >>> + struct bio *bio, sector_t blba, >>> + unsigned long *read_bitmap) >>> { >>> struct pblk_sec_meta *meta_list =3D rqd->meta_list; >>> - struct bio *bio =3D rqd->bio; >>> struct ppa_addr ppas[PBLK_MAX_REQ_ADDRS]; >>> int nr_secs =3D rqd->nr_ppas; >>> bool advanced_bio =3D false; >>> @@ -189,7 +189,6 @@ static void pblk_end_user_read(struct bio *bio) >>> WARN_ONCE(bio->bi_status, "pblk: corrupted read bio\n"); >>> #endif >>> bio_endio(bio); >>> - bio_put(bio); >>> } >>>=20 >>> static void __pblk_end_io_read(struct pblk *pblk, struct nvm_rq *rqd, >>> @@ -197,23 +196,18 @@ static void __pblk_end_io_read(struct pblk *pblk, s= truct nvm_rq *rqd, >>> { >>> struct nvm_tgt_dev *dev =3D pblk->dev; >>> struct pblk_g_ctx *r_ctx =3D nvm_rq_to_pdu(rqd); >>> - struct bio *bio =3D rqd->bio; >>> + struct bio *int_bio =3D rqd->bio; >>> unsigned long start_time =3D r_ctx->start_time; >>>=20 >>> generic_end_io_acct(dev->q, READ, &pblk->disk->part0, start_time); >>>=20 >>> if (rqd->error) >>> pblk_log_read_err(pblk, rqd); >>> -#ifdef CONFIG_NVM_DEBUG >>> - else >>> - WARN_ONCE(bio->bi_status, "pblk: corrupted read error\n"); >>> -#endif >>>=20 >>> pblk_read_check_seq(pblk, rqd, r_ctx->lba); >>>=20 >>> - bio_put(bio); >>> - if (r_ctx->private) >>> - pblk_end_user_read((struct bio *)r_ctx->private); >>> + if (int_bio) >>> + bio_put(int_bio); >>>=20 >>> if (put_line) >>> pblk_read_put_rqd_kref(pblk, rqd); >>> @@ -230,16 +224,19 @@ static void __pblk_end_io_read(struct pblk *pblk, s= truct nvm_rq *rqd, >>> static void pblk_end_io_read(struct nvm_rq *rqd) >>> { >>> struct pblk *pblk =3D rqd->private; >>> + struct pblk_g_ctx *r_ctx =3D nvm_rq_to_pdu(rqd); >>> + struct bio *bio =3D (struct bio *)r_ctx->private; >>>=20 >>> + pblk_end_user_read(bio); >>> __pblk_end_io_read(pblk, rqd, true); >>> } >>>=20 >>> -static int pblk_partial_read_bio(struct pblk *pblk, struct nvm_rq *rqd,= >>> - unsigned int bio_init_idx, >>> - unsigned long *read_bitmap) >>> +static int pblk_partial_read(struct pblk *pblk, struct nvm_rq *rqd, >>> + struct bio *orig_bio, unsigned int bio_init_idx, >>> + unsigned long *read_bitmap) >>> { >>> - struct bio *new_bio, *bio =3D rqd->bio; >>> struct pblk_sec_meta *meta_list =3D rqd->meta_list; >>> + struct bio *new_bio; >>> struct bio_vec src_bv, dst_bv; >>> void *ppa_ptr =3D NULL; >>> void *src_p, *dst_p; >>> @@ -319,7 +316,7 @@ static int pblk_partial_read_bio(struct pblk *pblk, s= truct nvm_rq *rqd, >>> meta_list[hole].lba =3D lba_list_media[i]; >>>=20 >>> src_bv =3D new_bio->bi_io_vec[i++]; >>> - dst_bv =3D bio->bi_io_vec[bio_init_idx + hole]; >>> + dst_bv =3D orig_bio->bi_io_vec[bio_init_idx + hole]; >>>=20 >>> src_p =3D kmap_atomic(src_bv.bv_page); >>> dst_p =3D kmap_atomic(dst_bv.bv_page); >>> @@ -338,28 +335,26 @@ static int pblk_partial_read_bio(struct pblk *pblk= , struct nvm_rq *rqd, >>>=20 >>> bio_put(new_bio); >>>=20 >>> - /* Complete the original bio and associated request */ >>> - bio_endio(bio); >>> - rqd->bio =3D bio; >>> + /* restore original request */ >>> + rqd->bio =3D NULL; >>> rqd->nr_ppas =3D nr_secs; >>>=20 >>> __pblk_end_io_read(pblk, rqd, false); >>> - return NVM_IO_OK; >>> + return NVM_IO_DONE; >>>=20 >>> err: >>> pr_err("pblk: failed to perform partial read\n"); >>>=20 >>> /* Free allocated pages in new bio */ >>> - pblk_bio_free_pages(pblk, bio, 0, new_bio->bi_vcnt); >>> + pblk_bio_free_pages(pblk, orig_bio, 0, new_bio->bi_vcnt); >>> __pblk_end_io_read(pblk, rqd, false); >>> return NVM_IO_ERR; >>> } >>>=20 >>> -static void pblk_read_rq(struct pblk *pblk, struct nvm_rq *rqd, >>> +static void pblk_read_rq(struct pblk *pblk, struct nvm_rq *rqd, struct b= io *bio, >>> sector_t lba, unsigned long *read_bitmap) >>> { >>> struct pblk_sec_meta *meta_list =3D rqd->meta_list; >>> - struct bio *bio =3D rqd->bio; >>> struct ppa_addr ppa; >>>=20 >>> pblk_lookup_l2p_seq(pblk, &ppa, lba, 1); >>> @@ -423,14 +418,15 @@ int pblk_submit_read(struct pblk *pblk, struct bio= *bio) >>> rqd =3D pblk_alloc_rqd(pblk, PBLK_READ); >>>=20 >>> rqd->opcode =3D NVM_OP_PREAD; >>> - rqd->bio =3D bio; >>> rqd->nr_ppas =3D nr_secs; >>> + rqd->bio =3D NULL; /* cloned bio if needed */ >>> rqd->private =3D pblk; >>> rqd->end_io =3D pblk_end_io_read; >>>=20 >>> r_ctx =3D nvm_rq_to_pdu(rqd); >>> r_ctx->start_time =3D jiffies; >>> r_ctx->lba =3D blba; >>> + r_ctx->private =3D bio; /* original bio */ >>>=20 >>> /* Save the index for this bio's start. This is needed in case >>> * we need to fill a partial read. >>> @@ -448,17 +444,15 @@ int pblk_submit_read(struct pblk *pblk, struct bio= *bio) >>> rqd->ppa_list =3D rqd->meta_list + pblk_dma_meta_size; >>> rqd->dma_ppa_list =3D rqd->dma_meta_list + pblk_dma_meta_size; >>>=20 >>> - pblk_read_ppalist_rq(pblk, rqd, blba, &read_bitmap); >>> + pblk_read_ppalist_rq(pblk, rqd, bio, blba, &read_bitmap); >>> } else { >>> - pblk_read_rq(pblk, rqd, blba, &read_bitmap); >>> + pblk_read_rq(pblk, rqd, bio, blba, &read_bitmap); >>> } >>>=20 >>> - bio_get(bio); >>> if (bitmap_full(&read_bitmap, nr_secs)) { >>> - bio_endio(bio); >>> atomic_inc(&pblk->inflight_io); >>> __pblk_end_io_read(pblk, rqd, false); >>> - return NVM_IO_OK; >>> + return NVM_IO_DONE; >>> } >>>=20 >>> /* All sectors are to be read from the device */ >>> @@ -473,13 +467,10 @@ int pblk_submit_read(struct pblk *pblk, struct bio= *bio) >>> } >>>=20 >>> rqd->bio =3D int_bio; >>> - r_ctx->private =3D bio; >>>=20 >>> ret =3D pblk_submit_io(pblk, rqd); >>> if (ret) { >>> pr_err("pblk: read IO submission failed\n"); >>> - if (int_bio) >>> - bio_put(int_bio); >>> goto fail_end_io; >>> } >>>=20 >>> @@ -489,7 +480,7 @@ int pblk_submit_read(struct pblk *pblk, struct bio *= bio) >>> /* The read bio request could be partially filled by the write buffer= , >>> * but there are some holes that need to be read from the drive. >>> */ >>> - return pblk_partial_read_bio(pblk, rqd, bio_init_idx, &read_bitmap)= ; >>> + return pblk_partial_read(pblk, rqd, bio, bio_init_idx, &read_bitmap= ); >>>=20 >>> fail_rqd_free: >>> pblk_free_rqd(pblk, rqd, PBLK_READ); >>> -- >>> 2.7.4 >=20 > You sent a larger patch serie afterwards that I thought took precedent (an= d not included in for-4.18/pblk). Feel free to rebase and resend. Sounds good. I thought you had some comments on it - that=E2=80=99s why I wa= ited a couple of days after you sent the PR. I=E2=80=99ll resend now. Can yo= u apply it to the 4.18 PR? Thanks! Javier.=20=