Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5003290imm; Tue, 21 Aug 2018 04:50:53 -0700 (PDT) X-Google-Smtp-Source: AA+uWPytcJS1ARuIdVAQP3z5rjTyZPKWZhGXO9FpLrSX29ABDXGuC0fa3TTWoC13EszkscVjzKJk X-Received: by 2002:a63:706:: with SMTP id 6-v6mr18728267pgh.137.1534852253915; Tue, 21 Aug 2018 04:50:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534852253; cv=none; d=google.com; s=arc-20160816; b=Zi+zKuozsxa+NRO97YgR2nU+9R5TrNmeRcOBSMm1UMAVCFHPKO6u6v+UY90w2TH2zP wjyEDvGvriWXveeRfcMRSfhLX4CtkaHcuYB9SlLhaayGyLwim5KUcQ+Gkj7F337kPHsl nJQc6njh+2WtZNW5UUyE9c0nCa4lZJtzz18NudD0Bp0VbBCWmB1a+k204WDvxwbsljQI QKgIIMTOZqptWqxGIZntRqvRjqJ4ZB2G5HSKKgP+neEuhpNlRfjTiPO6TiuIudCOnoGv AZFDJStCtUi3awI7ZfMcBh8ikKuU7rgFSVroqfTFnFBrI+VUjGVF8VevKHshHMILuZop nzGg== 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:mime-version :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=LQz+pJENNVIdSe/xDXZSzhu/OA0ZONBSglbwT5nB4TU=; b=kH0mQVTQvP7Vv3DLcFum/DL2HAePtFuTViDH4LZua/AS/BU/Car613eQJk+zF4X+zl SfY3NRXn8b1YLhDoUX0pE7NkZ7jVo+wDMJC2lHn1YwurN0kU3+nKNGqTZmYtDUyt88+q eIBnGh7BPPdyK1YxCN7Mbkd91H8L6RipX71W+qkChSWNBaZMAsDknhvwxifaUo+ewmb7 xHsjeUM17r88y7qYUgycQbBqwHz7TcnZFqRobMVQtdZWBNiMpFCkbhRgfylgSz6muQEx ssPIZp2n5lS5jeFPHBzR1PDRRNbOrSfeHkYSkdZCdLTFcQUiKh2p6IM1nK17XIHsm7p7 4Fsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b="VC/3dEWh"; 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 p123-v6si13061663pfg.281.2018.08.21.04.50.37; Tue, 21 Aug 2018 04:50:53 -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="VC/3dEWh"; 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 S1727189AbeHUPEk (ORCPT + 99 others); Tue, 21 Aug 2018 11:04:40 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:35573 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726832AbeHUPEk (ORCPT ); Tue, 21 Aug 2018 11:04:40 -0400 Received: by mail-lj1-f195.google.com with SMTP id p10-v6so14063281ljg.2 for ; Tue, 21 Aug 2018 04:44:50 -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=LQz+pJENNVIdSe/xDXZSzhu/OA0ZONBSglbwT5nB4TU=; b=VC/3dEWhj7xGo4axQa1elHxIX6gJiy3a9bK4M3dtNtKl5M+T9m8KGZKPCy1cy4PDXo 7yAcNgYaxHzIlhM4OJk3jmhqmMC2SG23xByFLeEMNzx46Rb9gcn7MEjLm+cLZH4DML2v qRcKILllzAcsYc/gxPtzgZgy1zjke90twkdb5v51BwgXo9rR4bDnDkvEYQO4mfxI5e9L CwwnwaQ/PMtD5nWq3DV8fMtYz7GYyaMaHWRVc3JVpG+h6ACIc7RPxl0ND5g3Kb0Q+tWs V7C7nUhAgVXSuPXN5nseigkxWQ7UUAJbZ3b1wOPGqe2+K180YiJKUvM/x3RjBIEOx0ab 1GdQ== 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=LQz+pJENNVIdSe/xDXZSzhu/OA0ZONBSglbwT5nB4TU=; b=Wn+VWt2Q/bMzFp2piPXR4QtTvyLcGnj26T4k7jDI4D8H4wLDJ0r+Fv1iKkWV8I/TR9 +hSL4q6JDR1lx3gICHcVEBHDkqPLA0quRvZnAeb2MPg/PnDkGlxmenHgwBrbhXM93zeu 14mp5d/ATN2HUEg/CzsIuDdb0HcHOJySqIA/YNbSJLQ/huojfQvXnL6gjDtSq91zkMrB WfykXD0KPkHwAQe2/N94z8vZUbydIDfnnTWokIoXPP5F1fG4D5P6TT1wpyYi+Ys1Vlck iFSA6pbEf+7L/avrepZ8GvdySlp0SmDH9947f/Jz+KPheLqdUsgr9AW+zqqM9qUZ8CPU GJVg== X-Gm-Message-State: AOUpUlHV4WQHnInH8dRJqadUVVUEuPRP/7JHOjqfBtR0WdDZDa8rM0gb 1oERFiZ+ziTwTcAVtbI7MgrXjw== X-Received: by 2002:a2e:380d:: with SMTP id f13-v6mr35877095lja.74.1534851889489; Tue, 21 Aug 2018 04:44:49 -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 b15-v6sm1596283lfg.18.2018.08.21.04.44.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 04:44:48 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=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?Matias=20Bj=C3=B8rling?= Subject: [PATCH v2] lightnvm: pblk: refactor put line fn on read completion Date: Tue, 21 Aug 2018 13:44:41 +0200 Message-Id: <20180821114441.23147-1-mb@lightnvm.io> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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ørling Reviewed-by: Javier González 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 = &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 = (rqd->nr_ppas > 1) ? rqd->ppa_list : &rqd->ppa_addr; + + for (i = 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 != 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 = (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_end_user_read(struct bio *bio) { #ifdef CONFIG_NVM_PBLK_DEBUG @@ -208,7 +192,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_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