Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp435059imm; Fri, 1 Jun 2018 03:43:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJeEpq2KeWsPQ/8L4NUSPw5rfzTRyrdtdhZwptQkK5ml2zO0sZ9wydmbnZhJOXRtD18oOuP X-Received: by 2002:a17:902:b184:: with SMTP id s4-v6mr10350649plr.359.1527849790573; Fri, 01 Jun 2018 03:43:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527849790; cv=none; d=google.com; s=arc-20160816; b=vpzWU7KqG85vPr1721M5Xw1CAf8vPWChWujMhSBaHToQ9srRq3weCD1ktiGVDD2MXH VAGrZvqbMxG3pChslRAgSHXE3pSp+mqXp2x2Zrnld+G9rRBI9auRnGgSOR6GqqugfUjc 0kiKupROm23DW4kQKHRjdG7LuEzGw6l7EkrWuRAc2TX9yCQqsi4qxxlzuDwA898YawzO cv/ZU2C5uXilJwRIiJli4fHQkTdgQuCs0TJFsOhKtsSU5fJbIfYCqJXvnACQGOkfuP6j ljVQBe/HsdP2cWCj3n1xic42uiqrH2UOZwR1kv4MN1uRqjZJeZ6zaHwau8heK6ms7psr Pa+g== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=nKrh0AztmZnmbRc8vATrr3pcqGPmW6vFzbsqRc0zf08=; b=ReMqoMC8ApiQk6iaBC85NWsRKPKNFYOEUwW79wPj7TjMD7AoQDrtTHN+4/Xg3I3hMG uhInl3WscQT/Um8ZlSbPRQwSDYRNeTY0oFtdZ3ItsIP+61XCTA0gxMoZRxBdHS8GQYbs C1jwg4A5s/r5KpmvLnuP2s5BnGKtxyX7h4IgYMWaWJowLUmrdecUFdFZmBq7uiR/PFB6 edZu1J3keDJaur+JQr7CKaUTCT/nE3A0lvytWeDf38Jugnyo0QZHuGuTaVIGvVZVQIoQ mGEgg1uGUuK6737BSjyh84KuH0RzaU5AYetdeEPZ+ECUi4vfCSK/rmD/bjux5MrMhMyL gB+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=2ESir55i; 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 f5-v6si29901955pgn.453.2018.06.01.03.42.56; Fri, 01 Jun 2018 03:43:10 -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=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b=2ESir55i; 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 S1751702AbeFAKmN (ORCPT + 99 others); Fri, 1 Jun 2018 06:42:13 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:44969 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751423AbeFAKmL (ORCPT ); Fri, 1 Jun 2018 06:42:11 -0400 Received: by mail-lf0-f67.google.com with SMTP id 36-v6so12197205lfr.11 for ; Fri, 01 Jun 2018 03:42:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=nKrh0AztmZnmbRc8vATrr3pcqGPmW6vFzbsqRc0zf08=; b=2ESir55iGt0vOxNWHKqvQSlYkQ2Q46JJZKAKrupxmCXkoHea2/2hrBCXVrIFKzYKte YQbT4x9LPHYiBh/diIUgR+USxm4XmTpn+Jzk9ZivALW1VarcdtMtS9wY9+8NfO5Uj6ks 8cC+SZlyD0ByerzGqJNKKlnN92EBH6UG3HC5E66NoxDiGR16YIqq2Z7T3vi7Fn46/Vy6 /M2u+d67edKs+bFx80MD4JHgKotL9wbUxow3KdoidEqYLSSGBWDDNJykEFUOMjdadsGo HO4UIRFRhIkAfX1wXHC/d6+rZrwmSAZOyQa9IdrOw9eNAAXOMT4FDdMPJXP2BxCHVqxt HO8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=nKrh0AztmZnmbRc8vATrr3pcqGPmW6vFzbsqRc0zf08=; b=P0e6wZxSs6lJrKDEyx7++CGz8ytPFWyyur7MtTdKy8MKdOetvAsAbgNQcxQWL/jdik OtHFD211Czl8STUaw6yCaeNiVIr1jfc+Kim/e3zHFjJ/lkbvM4vgVWnFISWUzb5gxRn3 yrv+l12UYuhM3/sVbcWn2Fm2ASRtEI4zYs3VIbo2iDrNrlesDgMLFPneOlF7SSO8BB9w 8ULqLGNY4mnYPjduezfOGQZOiULe2iZYSSzdCpyuXmgD80lujAbgr4O0TKQPGvXlHY65 iOLLwHk2rw2bx5/BbpXXXnLEYBgPyEhyv/R6/+YL8fTVxOEvug+P1BVWzQS3PzTULnPF xeeg== X-Gm-Message-State: ALKqPwcKQLfnab7nIaUC5976OXyS1CLHsBc5pRqyX/3RTa6zoDZvZSuH W/497Z4MCz0iCbjHimN18s2amjxb X-Received: by 2002:a19:9a10:: with SMTP id c16-v6mr6762829lfe.60.1527849729628; Fri, 01 Jun 2018 03:42:09 -0700 (PDT) Received: from [192.168.0.10] (95-166-82-66-cable.dk.customer.tdc.net. [95.166.82.66]) by smtp.googlemail.com with ESMTPSA id c67-v6sm787940lfe.4.2018.06.01.03.42.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jun 2018 03:42:08 -0700 (PDT) Subject: Re: [PATCH] lightnvm: pblk: remove unnecessary bio_get/put To: =?UTF-8?Q?Javier_Gonz=c3=a1lez?= Cc: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org References: <1523874157-5216-1-git-send-email-javier@cnexlabs.com> <4453F92A-4B78-4D2B-B438-3C807DF13514@javigon.com> From: =?UTF-8?Q?Matias_Bj=c3=b8rling?= Message-ID: Date: Fri, 1 Jun 2018 12:42:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <4453F92A-4B78-4D2B-B438-3C807DF13514@javigon.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/01/2018 12:22 PM, Javier González 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ález wrote: >> >> 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. >> >> 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. >> >> Signed-off-by: Javier González >> --- >> drivers/lightnvm/pblk-read.c | 57 +++++++++++++++++++------------------------- >> 1 file changed, 24 insertions(+), 33 deletions(-) >> >> 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, struct bio *bio, >> } >> >> 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 = rqd->meta_list; >> - struct bio *bio = rqd->bio; >> struct ppa_addr ppas[PBLK_MAX_REQ_ADDRS]; >> int nr_secs = rqd->nr_ppas; >> bool advanced_bio = 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); >> } >> >> 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, struct nvm_rq *rqd, >> { >> struct nvm_tgt_dev *dev = pblk->dev; >> struct pblk_g_ctx *r_ctx = nvm_rq_to_pdu(rqd); >> - struct bio *bio = rqd->bio; >> + struct bio *int_bio = rqd->bio; >> unsigned long start_time = r_ctx->start_time; >> >> generic_end_io_acct(dev->q, READ, &pblk->disk->part0, start_time); >> >> 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 >> >> pblk_read_check_seq(pblk, rqd, r_ctx->lba); >> >> - bio_put(bio); >> - if (r_ctx->private) >> - pblk_end_user_read((struct bio *)r_ctx->private); >> + if (int_bio) >> + bio_put(int_bio); >> >> if (put_line) >> pblk_read_put_rqd_kref(pblk, rqd); >> @@ -230,16 +224,19 @@ static void __pblk_end_io_read(struct pblk *pblk, struct nvm_rq *rqd, >> static void pblk_end_io_read(struct nvm_rq *rqd) >> { >> struct pblk *pblk = rqd->private; >> + struct pblk_g_ctx *r_ctx = nvm_rq_to_pdu(rqd); >> + struct bio *bio = (struct bio *)r_ctx->private; >> >> + pblk_end_user_read(bio); >> __pblk_end_io_read(pblk, rqd, true); >> } >> >> -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 = rqd->bio; >> struct pblk_sec_meta *meta_list = rqd->meta_list; >> + struct bio *new_bio; >> struct bio_vec src_bv, dst_bv; >> void *ppa_ptr = NULL; >> void *src_p, *dst_p; >> @@ -319,7 +316,7 @@ static int pblk_partial_read_bio(struct pblk *pblk, struct nvm_rq *rqd, >> meta_list[hole].lba = lba_list_media[i]; >> >> src_bv = new_bio->bi_io_vec[i++]; >> - dst_bv = bio->bi_io_vec[bio_init_idx + hole]; >> + dst_bv = orig_bio->bi_io_vec[bio_init_idx + hole]; >> >> src_p = kmap_atomic(src_bv.bv_page); >> dst_p = kmap_atomic(dst_bv.bv_page); >> @@ -338,28 +335,26 @@ static int pblk_partial_read_bio(struct pblk *pblk, struct nvm_rq *rqd, >> >> bio_put(new_bio); >> >> - /* Complete the original bio and associated request */ >> - bio_endio(bio); >> - rqd->bio = bio; >> + /* restore original request */ >> + rqd->bio = NULL; >> rqd->nr_ppas = nr_secs; >> >> __pblk_end_io_read(pblk, rqd, false); >> - return NVM_IO_OK; >> + return NVM_IO_DONE; >> >> err: >> pr_err("pblk: failed to perform partial read\n"); >> >> /* 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; >> } >> >> -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 bio *bio, >> sector_t lba, unsigned long *read_bitmap) >> { >> struct pblk_sec_meta *meta_list = rqd->meta_list; >> - struct bio *bio = rqd->bio; >> struct ppa_addr ppa; >> >> pblk_lookup_l2p_seq(pblk, &ppa, lba, 1); >> @@ -423,14 +418,15 @@ int pblk_submit_read(struct pblk *pblk, struct bio *bio) >> rqd = pblk_alloc_rqd(pblk, PBLK_READ); >> >> rqd->opcode = NVM_OP_PREAD; >> - rqd->bio = bio; >> rqd->nr_ppas = nr_secs; >> + rqd->bio = NULL; /* cloned bio if needed */ >> rqd->private = pblk; >> rqd->end_io = pblk_end_io_read; >> >> r_ctx = nvm_rq_to_pdu(rqd); >> r_ctx->start_time = jiffies; >> r_ctx->lba = blba; >> + r_ctx->private = bio; /* original bio */ >> >> /* 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 = rqd->meta_list + pblk_dma_meta_size; >> rqd->dma_ppa_list = rqd->dma_meta_list + pblk_dma_meta_size; >> >> - 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); >> } >> >> - 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; >> } >> >> /* All sectors are to be read from the device */ >> @@ -473,13 +467,10 @@ int pblk_submit_read(struct pblk *pblk, struct bio *bio) >> } >> >> rqd->bio = int_bio; >> - r_ctx->private = bio; >> >> ret = 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; >> } >> >> @@ -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); >> >> fail_rqd_free: >> pblk_free_rqd(pblk, rqd, PBLK_READ); >> -- >> 2.7.4 You sent a larger patch serie afterwards that I thought took precedent (and not included in for-4.18/pblk). Feel free to rebase and resend.