Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp432361rdh; Thu, 23 Nov 2023 07:48:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IGlaSlf1LDbtxY+s0ph/gGpVIQUFEPJRRkPrS1FfZBSEWYX4yVrilddRYY4rPRJfBpOGCbv X-Received: by 2002:a05:6a20:a115:b0:18a:d5a6:7e14 with SMTP id q21-20020a056a20a11500b0018ad5a67e14mr5380420pzk.56.1700754525406; Thu, 23 Nov 2023 07:48:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700754524; cv=none; d=google.com; s=arc-20160816; b=dxTv4RLwgsOSbkYG2LmCAoWctf+2bNbeepBIwDoXdPwlCRj751Q9UpIhlQStU88R8o A8ZCmYwkkTIqpGZIPFBPPrA0s97J71C5Bb56xfjBf21QPpfyMnkSNXuRV1HyelOJoonW oHMeoClfR9ML9aeh7in34i/+lMrwCFTnUktSL9szbwH9RWzNvK/43FXsqQ0uc7nzZVS2 zlGi69hXgvnYxuY0NFGP32Pt2FGRoRYHWoFL+e3sYxsN/uvb36ciHwhckpJSguEnJY/3 cCi1M9hFHEzyzk5jCV5AmEopTuSW8qp36O7YWp8kl5wWAYcbhmEY4LbpmncHTFL9UILj /yjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :wdcironportexception:ironport-sdr:ironport-sdr:dkim-signature; bh=cRqnRQ+A/26ZyuQR771lSW30xSFox6va9f6CMgoA7Rc=; fh=5/viNv8Fzx+nCNW5PGLTL+Se/9D0Q8TrzLPV3SudCmU=; b=qxYs6zqq6CWpjbCCs3iSQ1VFaA3BwJ2uM0yw/1em0wySvvb627K3BvBFMm7tBLdPMM BNEyJyp1Ec1vvgibDHTfw9mGHpTlWwcDmMf5Tlhv/f+MFcd+d0GIFzneBwAgPYpUUNcM 9XSY2Bg3XlHrQWe6/5OUAjm6hxj+Di26BsrnwPneEeHlzwoUIrWG2i6mmJUwl34mhgr6 5xJradi499+uL0Y8wGFl3gTChH8DowSMH6SIdi5xM0GuqGoW8JQ3SSc8Vu3sVp1P3wDq Ew9PacD1LV/wEoaFccocQcodujxkYocx8WVSQWQmSb6gkADtWy6i4I0hEh7yC/k4Ty07 atAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b="R+9dpOg/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id x9-20020a63fe49000000b0057795cb4f16si1541317pgj.684.2023.11.23.07.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 07:48:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b="R+9dpOg/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 826E48239103; Thu, 23 Nov 2023 07:48:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346209AbjKWPsG (ORCPT + 99 others); Thu, 23 Nov 2023 10:48:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346191AbjKWPr6 (ORCPT ); Thu, 23 Nov 2023 10:47:58 -0500 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60E7310C7; Thu, 23 Nov 2023 07:48:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1700754485; x=1732290485; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=wDRvUXJ6mVtVEukoOw489ax7uRNihNJAyUogAfyAXjo=; b=R+9dpOg/6Hp3aHGsBdmm0rvSxUfETtUxXGRJrfe4pDF0I6dES9gQQwUl dkNlQNcTF++HUIZM+w9PsFDUVlMS9/USXW5czV5kJbRtvM3JqtNeFJ0r+ NO9s6I8T6b/LOnf7i3At4Kw7vGu30xBtR+Uh4C8MarjCLlQ6UwrMh2vpD mkhXgQ/EfojE1WhN2sCvUpuZwfQd/lrJ3NwnlHtWSEKO2k7jobRfzZNyq qoLGgkUGtV01hW4JAzdEs0x8ILESpNdQmixRAElFypUSm+opPCtKprNA9 oqjKuh0aY81loE4aa3ZZ9cEeGOYUCUswYbfoKGIa1qhOGcswRbhbHHNvU Q==; X-CSE-ConnectionGUID: qm7DTtz6QSmbuesitw53/A== X-CSE-MsgGUID: dn+w52BeRFuwgv74kXNuBA== X-IronPort-AV: E=Sophos;i="6.04,222,1695657600"; d="scan'208";a="3129202" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 23 Nov 2023 23:47:30 +0800 IronPort-SDR: iQWjHGWnJ2d3Al3koAjvSDHT6ncLcFx6OLwirWGTxoRWOVkAAG93GoZ/J9gKGFZt73/bndgdYb gldZet+AtQDEyrOjMC1YoCj68EWhgrYY0HaoxJ7AitfbSfN8H3tb/948RLhT85c1ffLoeP/mMx ghclrDD7DJHG/tswgccqFZNyy/O/hUjqwQgw2jGj4r5mbKlGoUS40uUm2WaDEzkALoj4Lgyb9h fMFVT59YyOBvleveehkFzLor6S9ORxp7ihkMHqgJT3Q5d/z8RAANpgxrfGcia5xcVMuhWv4XTY HFI= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 23 Nov 2023 06:58:46 -0800 IronPort-SDR: lsfs8oPCU2giWsDgpzJxi9WE8DUXV7CFkSxklSygvHSG9EcNPfeN4Q4gYK83j5EJMjQauUSJbN 0LuCQNzc8GKl7XOJHWw3MJ+mLXoUhI5RZcpXcSLj930p2e7dQtsmHT4fVu7TAtaRYQTXgcM6Zy 6IWKfhkMtvD1srEUhdqhmdJ/3i9CZu9u99dUftFIVRXFOML7abbd3wAoYXeS/ooUCeN2BPlt5p 7neHxvd2fgcTfUu0rwpk/OSaWS44EGWxlLLPpceVXBfNJ7SmN8Phgzsj/OnS4lVDNSIPfCzto3 JsU= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip01.wdc.com with ESMTP; 23 Nov 2023 07:47:27 -0800 From: Johannes Thumshirn Date: Thu, 23 Nov 2023 07:47:16 -0800 Subject: [PATCH v2 2/5] btrfs: zoned: don't clear dirty flag of extent buffer MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231123-josef-generic-163-v2-2-ed1a79a8e51e@wdc.com> References: <20231123-josef-generic-163-v2-0-ed1a79a8e51e@wdc.com> In-Reply-To: <20231123-josef-generic-163-v2-0-ed1a79a8e51e@wdc.com> To: Chris Mason , Josef Bacik , David Sterba Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Naohiro Aota , Johannes Thumshirn X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1700754443; l=3002; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=wDRvUXJ6mVtVEukoOw489ax7uRNihNJAyUogAfyAXjo=; b=sWqCwaHo+SgYIPyXduOpD5Wi4szyqt/vJ2WunGbdgKcWSpUf3mkQvzvJRN8D03LagqUwYT2YG ExQbTtlzkgRBdoyFKyIELaHsoyYWiZUrx4ehZgrX39GtkPzHYsyrjo1 X-Developer-Key: i=johannes.thumshirn@wdc.com; a=ed25519; pk=TGmHKs78FdPi+QhrViEvjKIGwReUGCfa+3LEnGoR2KM= X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 23 Nov 2023 07:48:41 -0800 (PST) One a zoned filesystem, never clear the dirty flag of an extent buffer, but instead mark it as zeroout. On writeout, when encountering a marked extent_buffer, zero it out. Reviewed-by: Christoph Hellwig Reviewed-by: Josef Bacik Signed-off-by: Johannes Thumshirn --- fs/btrfs/disk-io.c | 7 ++++++- fs/btrfs/extent_io.c | 16 ++++++++++++++-- fs/btrfs/zoned.c | 3 ++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 460b88526f56..9c09062d3d0a 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -254,8 +254,13 @@ blk_status_t btree_csum_one_bio(struct btrfs_bio *bbio) if (WARN_ON_ONCE(bbio->bio.bi_iter.bi_size != eb->len)) return BLK_STS_IOERR; + /* + * If an extent_buffer is marked as EXTENT_BUFFER_ZONED_ZEROOUT, don't + * checksum it but zero-out its content. This is done to preserve + * ordering of I/O without unnecessarily writing out data. + */ if (test_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags)) { - WARN_ON_ONCE(found_start != 0); + memzero_extent_buffer(eb, 0, eb->len); return BLK_STS_OK; } diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 49514ef829fb..c378094b5cc8 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3748,6 +3748,20 @@ void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans, if (trans && btrfs_header_generation(eb) != trans->transid) return; + /* + * Instead of clearing the dirty flag off of the buffer, mark it as + * EXTENT_BUFFER_ZONED_ZEROOUT. This allows us to preserve + * write-ordering in zoned mode, without the need to later re-dirty + * the extent_buffer. + * + * The actual zeroout of the buffer will happen later in + * btree_csum_one_bio. + */ + if (btrfs_is_zoned(fs_info)) { + set_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags); + return; + } + if (!test_and_clear_bit(EXTENT_BUFFER_DIRTY, &eb->bflags)) return; @@ -4139,8 +4153,6 @@ static void __write_extent_buffer(const struct extent_buffer *eb, /* For unmapped (dummy) ebs, no need to check their uptodate status. */ const bool check_uptodate = !test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags); - WARN_ON(test_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags)); - if (check_eb_range(eb, start, len)) return; diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index b9bfde6fb929..ed8e002b33e7 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -1722,7 +1722,8 @@ void btrfs_redirty_list_add(struct btrfs_transaction *trans, btrfs_header_flag(eb, BTRFS_HEADER_FLAG_WRITTEN)) return; - ASSERT(!test_bit(EXTENT_BUFFER_DIRTY, &eb->bflags)); + ASSERT(test_bit(EXTENT_BUFFER_DIRTY, &eb->bflags)); + ASSERT(test_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags)); memzero_extent_buffer(eb, 0, eb->len); set_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags); -- 2.41.0