From patchwork Tue Oct 9 11:12:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10632291 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 A5785112B for ; Tue, 9 Oct 2018 11:16:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8614228A5E for ; Tue, 9 Oct 2018 11:16:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A69A28A69; Tue, 9 Oct 2018 11:16:21 +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 1672428A73 for ; Tue, 9 Oct 2018 11:16:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726986AbeJISbf (ORCPT ); Tue, 9 Oct 2018 14:31:35 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:33960 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726985AbeJISbf (ORCPT ); Tue, 9 Oct 2018 14:31:35 -0400 Received: by mail-pl1-f193.google.com with SMTP id f18-v6so681393plr.1 for ; Tue, 09 Oct 2018 04:15:08 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=g7JGJXrZcJTYtzXBSO8ITsCgwbjUBsGV01Gzzox45vg=; b=tz+xhY9ACp5KFI7zzphhvo5ziTKg+83Vod4TGZsG20KJD+lYbNJ/VLxIpQKG6XiNuZ ltYCs7YlEZfENZPDr8uSSVfPbTRBhc3s6c0Io6m26XfW0G/7nLiCr8Ojkl9bnvqAI7Vq qsBWzVDQmkJ9RCsEyZ+H3rUuIVSoP4BNMMWYsQhQX/y5iGjAn2yYycbtA+pMKEJjEIh5 Zem44DdR58slri92Oyxu5z8jrkmX9uyNjZ89mI1lSkW9t/zlmibq09fRNQ24UChT8pHZ 06t1d3h+0EmHvVxw7bfUPskBWbQSRiaUbrZmTmqBFpS9Xy4cM6tnPXr0hZ3lRZvvj4fQ ESEQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=g7JGJXrZcJTYtzXBSO8ITsCgwbjUBsGV01Gzzox45vg=; b=lsT0Cd/tVZpn0zkVEnI5iQVp3DT3gxdKjAiDlhou2bI8azeMxYc7+L4WQFRxxE9PmQ 4MDQ1qBRT/N2XIcSwgT2gLGHxC7WrtHzn8f2Fy+ggqx1jmPRW4BcMrw8QaHEaeMCVKfO ZaG0paiTiFUonNqmDZO9J7J6zsj3fMylZLMxpVzp3jEfw7jvV+tNtzegF5jkVb/tjhDM exUOKqRfjPlzpEmJxIwQbxbl2B8UN51FI7t0H7ThxVGU2kjRKObPuwsfKKsztUtrSOn2 gr8Ncepg+f5Ealf8O8/2e2iGE9WCmeA1hAcgeL/Rqdwp67kMSr37pKFGTuYo6oxntMyG LvPQ== X-Gm-Message-State: ABuFfoiK4TGhN+fOjXg/u5VtU7UpK8Ae8B34rg1TYQYeTDDUMNibOjCA d83wfNjfeq2IdaTED53San9YfVUVPx1F3A== X-Google-Smtp-Source: ACcGV62XNXA1EPUnKNqn5uB34ctiUSqBVZaoDhxoYSuBmW1MmMn58i83VtyXXCZSZPnoiFOF21SP9g== X-Received: by 2002:a17:902:263:: with SMTP id 90-v6mr28088003plc.190.1539083708369; Tue, 09 Oct 2018 04:15:08 -0700 (PDT) Received: from skyninja.hgst.com (rap-us.hgst.com. [199.255.44.250]) by smtp.gmail.com with ESMTPSA id p1-v6sm25342380pff.128.2018.10.09.04.15.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 04:15:06 -0700 (PDT) From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Jav?= =?utf-8?q?ier_Gonz=C3=A1lez?= , =?utf-8?q?Javier_Gonz?= =?utf-8?q?=C3=A1lez?= , =?utf-8?q?Matias_Bj=C3=B8rling?= Subject: [GIT PULL 34/45] lightnvm: pblk: take write semaphore on metadata Date: Tue, 9 Oct 2018 13:12:04 +0200 Message-Id: <20181009111215.7653-35-mb@lightnvm.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181009111215.7653-1-mb@lightnvm.io> References: <20181009111215.7653-1-mb@lightnvm.io> 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 From: Javier González pblk guarantees write ordering at a chunk level through a per open chunk semaphore. At this point, since we only have an open I/O stream for both user and GC data, the semaphore is per parallel unit. For the metadata I/O that is synchronous, the semaphore is not needed as ordering is guaranteed. However, if the metadata scheme changes or multiple streams are open, this guarantee might not be preserved. This patch makes sure that all writes go through the semaphore, even for synchronous I/O. This is consistent with pblk's write I/O model. It also simplifies maintenance since changes in the metadata scheme could cause ordering issues. Signed-off-by: Javier González Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-core.c | 16 +++++++++++++++- drivers/lightnvm/pblk.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c index 49cef93e328e..a3ce4a36dd33 100644 --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -557,6 +557,20 @@ int pblk_submit_io_sync(struct pblk *pblk, struct nvm_rq *rqd) return ret; } +int pblk_submit_io_sync_sem(struct pblk *pblk, struct nvm_rq *rqd) +{ + struct ppa_addr *ppa_list; + int ret; + + ppa_list = (rqd->nr_ppas > 1) ? rqd->ppa_list : &rqd->ppa_addr; + + pblk_down_chunk(pblk, ppa_list[0]); + ret = pblk_submit_io_sync(pblk, rqd); + pblk_up_chunk(pblk, ppa_list[0]); + + return ret; +} + static void pblk_bio_map_addr_endio(struct bio *bio) { bio_put(bio); @@ -787,7 +801,7 @@ static int pblk_line_smeta_write(struct pblk *pblk, struct pblk_line *line, meta_list[i].lba = lba_list[paddr] = addr_empty; } - ret = pblk_submit_io_sync(pblk, &rqd); + ret = pblk_submit_io_sync_sem(pblk, &rqd); if (ret) { pblk_err(pblk, "smeta I/O submission failed: %d\n", ret); bio_put(bio); diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h index 02e2c02b0cf4..4c015c457197 100644 --- a/drivers/lightnvm/pblk.h +++ b/drivers/lightnvm/pblk.h @@ -792,6 +792,7 @@ void pblk_log_write_err(struct pblk *pblk, struct nvm_rq *rqd); void pblk_log_read_err(struct pblk *pblk, struct nvm_rq *rqd); int pblk_submit_io(struct pblk *pblk, struct nvm_rq *rqd); int pblk_submit_io_sync(struct pblk *pblk, struct nvm_rq *rqd); +int pblk_submit_io_sync_sem(struct pblk *pblk, struct nvm_rq *rqd); int pblk_submit_meta_io(struct pblk *pblk, struct pblk_line *meta_line); void pblk_check_chunk_state_update(struct pblk *pblk, struct nvm_rq *rqd); struct bio *pblk_bio_map_addr(struct pblk *pblk, void *data,