Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3003795imm; Fri, 10 Aug 2018 02:00:20 -0700 (PDT) X-Google-Smtp-Source: AA+uWPy+R02O3WGcaV4SWTTw3UXVi2CUjV+Q7zzbdnexhT0K5cDT70tsHygw73etzagip/qlvZp9 X-Received: by 2002:a63:714a:: with SMTP id b10-v6mr5403154pgn.73.1533891620222; Fri, 10 Aug 2018 02:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533891620; cv=none; d=google.com; s=arc-20160816; b=gksGtAUV4VRUoG6N/KnbmfJSWIEKiy3SZ2WDAtlyoHWz3pHoLVAjwg9J8DOfNIgehB 1qowTTGhu4mGI5rJw1Kc6qg1mV6FNd+LutXTbvmU2Ut83bJSd0SPbWr28jHv45bVa/Hd pgNbL5D3gdmZ7NLYl5Mv0suT8Co6QulaH4lJdGzkbb+0Gp8gRwlWMfAtg4nclehpDPnd RxYPMRqHYTJnvs2UAkpD3Si9l9qhw70KS3RmzazsZozfh12FAVHxkP7fRs82/y7uxJQR BcRbzSLqiZzMDLsb4u2IpES4Zczl611RyCOX8GPd4ZMVWt4cnc4jA08oACceXoSCzXdJ BGHA== 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:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=E7ck28YG30p+AvmsTOwRHLuHq+HW9kTe+vTVYiroLUI=; b=oLHJWW2AHOGhIIL3OqKRmWtRNOsrMBGyzKFyEj65q/3veG4lwVvgbj98JXoBxNGfZQ ZZvJoJmh5BRjMLmDt/NDNyBN/BraZ4ADqHcklhxA0TDVkHr+wB2BlPjGljWBtWwe7vIp NYUMidA/qgVbwRCJG5HbiJAkaPLOLzmP6A2+iIilGhnnhn4A4Fsz/rbH/xW1p4qQGwpd UeAQjWtiAbwsy1FZWkCewLp0Bk6aMyxmAsy5ynYHxidaVdmqfKnE8Fv7jKDVrCYA7G9f V6FidhhuL973U2D2mpoAtITFDJmMBv/D59DpTlieVE/CofxTvzklLwNC2KAMeK3RoHBn PlQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@owltronix-com.20150623.gappssmtp.com header.s=20150623 header.b=Bj3Aw1qX; 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 p1-v6si2592932plk.294.2018.08.10.02.00.05; Fri, 10 Aug 2018 02:00:20 -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=@owltronix-com.20150623.gappssmtp.com header.s=20150623 header.b=Bj3Aw1qX; 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 S1727396AbeHJKdi (ORCPT + 99 others); Fri, 10 Aug 2018 06:33:38 -0400 Received: from mail-ua1-f67.google.com ([209.85.222.67]:32843 "EHLO mail-ua1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726742AbeHJKdi (ORCPT ); Fri, 10 Aug 2018 06:33:38 -0400 Received: by mail-ua1-f67.google.com with SMTP id i4-v6so997830uak.0 for ; Fri, 10 Aug 2018 01:04:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owltronix-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=E7ck28YG30p+AvmsTOwRHLuHq+HW9kTe+vTVYiroLUI=; b=Bj3Aw1qX9lJpyuK/mvV5n0de0lNHZ8rx252BIFScWz3K8b9BoSoJ1KTeFyhmh+TuZ1 7Vbi2ItMk+SzT2/KulDdh6bFEMbx9nGVlJ/s3+OO9ghOoDKm74AyM/YQGFEvanGxcAui ihQXt4TV9UK2MsSIItTA3zCICm8gt7zXXj7u9CNoqTEYFmOEa/YACp1OeZcsd4xa1dYI KEdtVD80kdY02lXpRkW6r59XdH+1EU88pe88QPZyAKkY4aCcYd5R3gRq1pgi/5cu1xwz 1IbpIZ5EnENNgaZTnLJPF/abichF1kVWhkr7hQv8SUI2RixWU1WW9H3ETsU9agn+S3s8 yuhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=E7ck28YG30p+AvmsTOwRHLuHq+HW9kTe+vTVYiroLUI=; b=E1v67PxvxaQ4kR0l8Kr5/CC5O3UqEv7BDmRyLc/VtJ2oDwZNKzwTF2ijKMMufXee7P qRtunJn4iHJ2wGB+3Q06ZXpuXDldLHbuFIxLaYpEYCuJZGHwjQm5+zQhe+VJOhOgZd2z yOEtVAxRVew7euH2/LfHuXHFIFZyNa/UYHSK07HjPdy2GAIy3Oq8JQ+vaOTojV+2MFIb TZOr+XoGFREA3cT83lyFCgedb2ImYBQQyZPF15CqKZETzsTkzRAvZYmH7BubWsH6QxAj cuXhe8yi3VrGx0OaHOBBZMLEjDiv1gshHjGlVd3IzzNnVRTqJpKBRym7gbrDWAR4baIg zKKA== X-Gm-Message-State: AOUpUlGPD/XsXxFXKyFhQsSy84wooJwZZZqhGvpnosOxUajzt0Dc5+/f 1qGi3pVlWXqDx02ooao3voz5mxpsMNOf2oHx9IivcQ== X-Received: by 2002:a1f:6285:: with SMTP id w127-v6mr2771452vkb.78.1533888293003; Fri, 10 Aug 2018 01:04:53 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a67:984f:0:0:0:0:0 with HTTP; Fri, 10 Aug 2018 01:04:52 -0700 (PDT) In-Reply-To: <1533297919-27253-1-git-send-email-javier@cnexlabs.com> References: <1533297919-27253-1-git-send-email-javier@cnexlabs.com> From: Hans Holmberg Date: Fri, 10 Aug 2018 10:04:52 +0200 Message-ID: Subject: Re: [PATCH] lightnvm: pblk: take write semaphore on metadata To: =?UTF-8?Q?Javier_Gonz=C3=A1lez?= Cc: Matias Bjorling , linux-block@vger.kernel.org, Linux Kernel Mailing List , =?UTF-8?Q?Javier_Gonz=C3=A1lez?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 3, 2018 at 2:05 PM, Javier Gonz=C3=A1lez w= rote: > 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. > > Since metadata I/O 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 metdatada scheme could cause > ordering issues. > > Signed-off-by: Javier Gonz=C3=A1lez > --- > drivers/lightnvm/pblk-core.c | 14 ++++++++++++-- > drivers/lightnvm/pblk.h | 1 + > 2 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c > index 00984b486fea..160b54d26bfa 100644 > --- a/drivers/lightnvm/pblk-core.c > +++ b/drivers/lightnvm/pblk-core.c > @@ -493,6 +493,16 @@ int pblk_submit_io_sync(struct pblk *pblk, struct nv= m_rq *rqd) > return nvm_submit_io_sync(dev, rqd); > } > > +int pblk_submit_io_sync_sem(struct pblk *pblk, struct nvm_rq *rqd) > +{ > + if (rqd->opcode !=3D NVM_OP_PWRITE) > + pblk_submit_io_sync(pblk, rqd); > + > + pblk_down_page(pblk, rqd->ppa_list, rqd->nr_ppas); This will only work if rqd->nr_ppas > 1, better check if rqd->nr_ppas is 1 and pass &ppa->ppa_addr on to pblk_down_page when needed. > + pblk_submit_io_sync(pblk, rqd); > + pblk_up_page(pblk, rqd->ppa_list, rqd->nr_ppas); > +} > + > static void pblk_bio_map_addr_endio(struct bio *bio) > { > bio_put(bio); > @@ -737,7 +747,7 @@ static int pblk_line_submit_emeta_io(struct pblk *pbl= k, struct pblk_line *line, > } > } > > - ret =3D pblk_submit_io_sync(pblk, &rqd); > + ret =3D pblk_submit_io_sync_sem(pblk, &rqd); > if (ret) { > pblk_err(pblk, "emeta I/O submission failed: %d\n", ret); > bio_put(bio); > @@ -842,7 +852,7 @@ static int pblk_line_submit_smeta_io(struct pblk *pbl= k, struct pblk_line *line, > * the write thread is the only one sending write and erase comma= nds, > * there is no need to take the LUN semaphore. > */ > - ret =3D pblk_submit_io_sync(pblk, &rqd); > + ret =3D 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 4760af7b6499..6ccc6ad8e1ce 100644 > --- a/drivers/lightnvm/pblk.h > +++ b/drivers/lightnvm/pblk.h > @@ -782,6 +782,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); > struct bio *pblk_bio_map_addr(struct pblk *pblk, void *data, > unsigned int nr_secs, unsigned int len, > -- > 2.7.4 >