From patchwork Mon Aug 20 11:43:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10570249 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A6CE921 for ; Mon, 20 Aug 2018 11:43:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67807292EA for ; Mon, 20 Aug 2018 11:43:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 591FA292F7; Mon, 20 Aug 2018 11:43:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37AFB292EA for ; Mon, 20 Aug 2018 11:43:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726229AbeHTO64 (ORCPT ); Mon, 20 Aug 2018 10:58:56 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:33841 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726141AbeHTO64 (ORCPT ); Mon, 20 Aug 2018 10:58:56 -0400 Received: by mail-lf1-f65.google.com with SMTP id g9-v6so5418069lfh.1 for ; Mon, 20 Aug 2018 04:43:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Iun9iKLkriRSJZS1TokO8ENAazUqaQVi8hlmEjAFGIo=; b=iNS4O6M//MTbaQ9boaKAHC5eJnKyB2aTT+13OsfNNoJDPxSRh3vfewZGc5f65f1LZC p79/fQi/5C0fxggN5KC4tmaYOaBjhSK4e1ze/1nlunpte5+h8eIvLWo2dwr+J7fBGpRr lnCwh5w9VzTQdK6lkYcZImcxEUiv39Pnsu/L9RMv4bX0flPWDh+mW04aQ+v1nUVoMpH0 HBPIDYJKHPFLeh391OZV6xH6JtaEvG02R0B5IJISypg7OTNF0zhib4dpu8tMv5NG52dW sQF6sSHPXVACOTAWJ3XAdY43D578/YUcKw/6nDTWzFB/WGlmlBidg01jUVFBPw6s92pv thlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Iun9iKLkriRSJZS1TokO8ENAazUqaQVi8hlmEjAFGIo=; b=t+a35Mm0V93/quuf6YTvLoDIrgsJcYousQJ6SXMPN6mp81vNKaudLMUJMVdqCpg25l kGvsmX+id1AnxYqo831CbRK9ttvdOwMkfDSYv39Gkw/YgHuMqKxuUPcxrd6c0cv1xcfS 0J3nMguhLwPBrGRSHgahtVfa/1/aVUhNjBdzmWsXWMK7NB+XMFKKSFmv4BIYl9+vnI19 G0+uTQcoUZHCg9/GTMhZrUTQUZ0uqfiov8D8JPEfQFA1QRwr7tJJk67M0yaEzGy2lhd2 rujd2n053YSv21BQAT+P7+d7MRZv9iObBhbuUj6LvrTDa89Vb3rCI1+4HcRLaTS4wtQw tH5w== X-Gm-Message-State: AOUpUlElw/aXK/e7Tt+BClGcvECBHwXR0anaj4akdGmPGQGYyPo+0D0t MDKFDEfdvKugOGsYZGE/d72c06+un2c= X-Google-Smtp-Source: AA+uWPwuMS24IDIKS6cxzXATmVmxpeBs2l9yAJUb0XtC6YvP3oOatawUZx+TM5nL59vmFqge9bANDQ== X-Received: by 2002:a19:7d84:: with SMTP id y126-v6mr4663685lfc.94.1534765417449; Mon, 20 Aug 2018 04:43:37 -0700 (PDT) Received: from localhost.localdomain (95-166-82-66-cable.dk.customer.tdc.net. [95.166.82.66]) by smtp.gmail.com with ESMTPSA id q73-v6sm1759529lfi.86.2018.08.20.04.43.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 04:43:36 -0700 (PDT) From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: igor.j.konopko@intel.com, marcin.dziegielewski@intel.com, javier@cnexlabs.com, hans.holmberg@cnexlabs.com, hlitz@ucsc.edu, youngtack.jin@circuitblvd.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Mat?= =?utf-8?q?ias_Bj=C3=B8rling?= Subject: [PATCH] lightnvm: pblk: refactor put line fn on read completion Date: Mon, 20 Aug 2018 13:43:20 +0200 Message-Id: <20180820114320.3764-1-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Matias Bjørling Reviewed-by: Javier González --- drivers/lightnvm/pblk-read.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/lightnvm/pblk-read.c b/drivers/lightnvm/pblk-read.c index cd2f61eed6a0..16858eaf694a 100644 --- a/drivers/lightnvm/pblk-read.c +++ b/drivers/lightnvm/pblk-read.c @@ -165,20 +165,23 @@ static void pblk_read_check_rand(struct pblk *pblk, struct nvm_rq *rqd, WARN_ONCE(j != rqd->nr_ppas, "pblk: corrupted random request\n"); } -static void pblk_read_put_rqd_kref(struct pblk *pblk, struct nvm_rq *rqd) +static void __pblk_read_put_line(struct pblk *pblk, struct ppa_addr ppa) { - struct ppa_addr *ppa_list; - int i; - - ppa_list = (rqd->nr_ppas > 1) ? rqd->ppa_list : &rqd->ppa_addr; - - for (i = 0; i < rqd->nr_ppas; i++) { - struct ppa_addr ppa = ppa_list[i]; struct pblk_line *line; line = &pblk->lines[pblk_ppa_to_line(ppa)]; kref_put(&line->ref, pblk_line_put_wq); - } +} + +static void pblk_read_put_line(struct pblk *pblk, struct nvm_rq *rqd) +{ + struct ppa_addr *ppa_list; + 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]); } static void pblk_end_user_read(struct bio *bio) @@ -208,7 +211,7 @@ static void __pblk_end_io_read(struct pblk *pblk, struct nvm_rq *rqd, bio_put(int_bio); if (put_line) - pblk_read_put_rqd_kref(pblk, rqd); + pblk_read_put_line(pblk, rqd); #ifdef CONFIG_NVM_PBLK_DEBUG atomic_long_add(rqd->nr_ppas, &pblk->sync_reads);