From patchwork Tue Nov 21 16:32:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 167823 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp748621vqb; Tue, 21 Nov 2023 08:33:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVLLUis03WaRzTc48F1w6aE0szaqxqIo3taj5Z6KmymO9CwS5YXQaszwIJqtmCHXGAYTFG X-Received: by 2002:a17:903:2308:b0:1ce:6453:16db with SMTP id d8-20020a170903230800b001ce645316dbmr14426711plh.18.1700584401932; Tue, 21 Nov 2023 08:33:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700584401; cv=none; d=google.com; s=arc-20160816; b=sJWyg+1TuiPapMIbyLiRKWdXi2rORokrQ/rTlWNQSh9vIvx+fC/aHE/Cos3BHKHUkF XWsJzsOb+Lfk9PQBc0CFkATdkRmzDlhbAeOTFmRntZzikJ4NBRf7B8t6LZMy7m1DUmay lfPBS/IMy48pf7mqLSH3u5q9Ad/cSK8YV9pU+aj9UGPUaeV2pnBiJtC+Bz4b5jPMivLe TuXn8YLM+1nCWorGnkrns0UN5LlJC/2ytKbXnLQ7jE2PQWv3n8NzkuyTZ+6pkfm3SO4Y FvmUcBzU4bO1S1hIVPOBdnOfKoOtXZVEFeI62wHoczP75zZV/eCysnNUmYzA4MGxp0zu Ydqg== 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=y11EPBw6Lm5qyOJhsqEqb7tG55lP+MYRPoNKJnVwwys=; fh=5/viNv8Fzx+nCNW5PGLTL+Se/9D0Q8TrzLPV3SudCmU=; b=vnJIFbEMH9aTx+iuvyFlPGoMyIvh0kn9ge+jFpocryDPPhsfSlL3pLDfqaFzoawCzy eGi97DcwAcWROYMel88qg5PH1D4fAjVqn73wPuH9dC7qrPifWNjeb6PyPhvYayTA/ltu KnpaQV2u1tYqBrf984zZX+XmyM8T8SLTnr16Ee5KWLW7O3s4bUud4quxdeTXxOPAN8Sw W7ZkWp0GTMvX7y7xlkHKyymCrO1MGe6tu7wpcmLaRdwDwm2JaUaDR6ayVv+Wrio6RtAh IuiRxvJ/H0j2PYj7/JHiGdTNZ0p6hHSNMykaQDzPS0tQXVdTo/P3moGdTMwV2y98oEHq DNRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=VOeMVvJm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id j11-20020a170902da8b00b001cf747e89c1si663413plx.145.2023.11.21.08.33.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 08:33:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=VOeMVvJm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 2B3B280C3A08; Tue, 21 Nov 2023 08:33:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233945AbjKUQcw (ORCPT + 99 others); Tue, 21 Nov 2023 11:32:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233556AbjKUQcn (ORCPT ); Tue, 21 Nov 2023 11:32:43 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52CFB19E; Tue, 21 Nov 2023 08:32:40 -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=1700584360; x=1732120360; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=L3NVSoa0Cpx4pPFIb1TUWiVH9DFoJOyUHEUP90OBa2o=; b=VOeMVvJmaIxB9oqY60BqtyFKYrkSxRBb1mq2L1T3iR7qHnEf4At7hJwY 0orSLXxrxFvtE7CG27IRrOyhrB/xj1u0Kb/LQQhSlJR0o4hmd6ffKmdT3 EoHjbO1Es3ND4apR0b3F1oW2MkTZv/chhnVGwhQ2N1zHcwvRFDCIkz75l YY60XsKE0tqg8Wvg6MN33m0IJ6qd0MxmBpioH+jzNMGLbaOvJWHXhF/QV tYnxx5WuIi62s/cxHOnq+1JUPWNO2ya3SUeNFigQQpDH1yylP/7WRNTKS JkapmtWtWwxnBO+ToOQOnRFMEN4kQ8tXXxla/H2d///dc7Ph9VqiiJLM7 A==; X-CSE-ConnectionGUID: 3JGdFnzGRSWh2k++jw3oxw== X-CSE-MsgGUID: nzNMQh8DQPmy/kX0jkgMBw== X-IronPort-AV: E=Sophos;i="6.04,216,1695657600"; d="scan'208";a="3076038" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 22 Nov 2023 00:32:38 +0800 IronPort-SDR: ZW7tzteNq4G/Ea4JGzf0Pp9WSW6Bz19/35qspf9REDQQlIa5nQ9IjgKpvDd30WnGdgakJeiH/k Kiqltc7Y+ua481d33pw1U8n0pLYDRc17Y5vatPQF34ByKz4v9ftxsLBC7eUjqrCkbFMx2mbNFI JWeppZgicR8RtGnkC9T0A3EieioOw0zMfa+2xP+DFkxulHTxcSnR3nkG+eeJ/pUxjf3z+lK9FO 4LNipNJrvFUcZ5q2tUcPjkB4OFiHgsVEP2Unl11FC3p4dDVlkF0JVXm7T7ZlMYyd3IORMrwXpx +Fs= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 21 Nov 2023 07:38:16 -0800 IronPort-SDR: IOKuH+FE/Sxtimd3j5gs6rbKKgH4w5JW7AtaTKCl1+ZX6G+wtmAZPCkaIlDsSVHaZkYYWFk8Oq 0vxxGEVQKzpUL8lCaE7fCxR1cEsMMRtPenl/6oFiMuh1fxMGoFDh3N7uJskra70O/A/Odk6lKL 6cUJOLxCBc21SesKtl25Xnijz1f8JwpRfdyiPx6lSZgKMy4BTSfKGqHYnMjhnJnG5sBq9URVIL EmHHQ/WrieVC8aMYMd+1G1mwd8Kb/xGQnFqym/zstEBKRMQ8YG6ZfQ+CxETtpz0bQtIvTFG13Z Kuc= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip02.wdc.com with ESMTP; 21 Nov 2023 08:32:38 -0800 From: Johannes Thumshirn Date: Tue, 21 Nov 2023 08:32:31 -0800 Subject: [PATCH 2/5] btrfs: zoned: don't clear dirty flag of extent buffer MIME-Version: 1.0 Message-Id: <20231121-josef-generic-163-v1-2-049e37185841@wdc.com> References: <20231121-josef-generic-163-v1-0-049e37185841@wdc.com> In-Reply-To: <20231121-josef-generic-163-v1-0-049e37185841@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=1700584354; l=2264; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=L3NVSoa0Cpx4pPFIb1TUWiVH9DFoJOyUHEUP90OBa2o=; b=T9kBt7f2Hj0NyDJUnB2/A2fnDALdHmF2eaDZtiMrukTgRelffox9lplELS0/Arzh7ecOgcrM6 1OmbzpOZOpzCtJdugdkd6eXglwZSesqiGu59vI2GkXuBp+uKTtTS3ib 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 groat.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 (groat.vger.email [0.0.0.0]); Tue, 21 Nov 2023 08:33:08 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783191989462473565 X-GMAIL-MSGID: 1783191989462473565 One a zoned filesystem, never clear the dirty flag of an extent buffer, but instead mark it as cancelled. On writeout, when encountering cancelled extent_buffers, zero them out. Signed-off-by: Johannes Thumshirn Reviewed-by: Christoph Hellwig --- fs/btrfs/disk-io.c | 2 +- fs/btrfs/extent_io.c | 7 +++++-- fs/btrfs/zoned.c | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index ff6140e7eef7..f259bae1c3ee 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -255,7 +255,7 @@ blk_status_t btree_csum_one_bio(struct btrfs_bio *bbio) return BLK_STS_IOERR; if (test_bit(EXTENT_BUFFER_CANCELLED, &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 74f984885719..8bc5025ce278 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3748,6 +3748,11 @@ void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans, if (trans && btrfs_header_generation(eb) != trans->transid) return; + if (btrfs_is_zoned(fs_info)) { + set_bit(EXTENT_BUFFER_CANCELLED, &eb->bflags); + return; + } + if (!test_and_clear_bit(EXTENT_BUFFER_DIRTY, &eb->bflags)) return; @@ -4139,8 +4144,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_CANCELLED, &eb->bflags)); - if (check_eb_range(eb, start, len)) return; diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 89cd1664efe1..117e041bdc7a 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_CANCELLED, &eb->bflags)); memzero_extent_buffer(eb, 0, eb->len); set_bit(EXTENT_BUFFER_CANCELLED, &eb->bflags);