Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp1129344pxb; Fri, 13 Aug 2021 14:29:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGL9QXqbd4mj97kUYeyfC49bltqa73hextWthlCTTqAkULQPgnKZ/QQXXdHU23MnMt2YNj X-Received: by 2002:a05:6402:424c:: with SMTP id g12mr5564302edb.121.1628890183291; Fri, 13 Aug 2021 14:29:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628890183; cv=none; d=google.com; s=arc-20160816; b=v4CTNPaZoc/DCXI1uIrzT1JyrdovycolrJluPAt+QYtL6pQJXqo1SUqW93Tvi8m7hO 1sSbn3UZLOSW0ifpXC8Z1OVoKP5EISx2INtWd9GRpeB0FWBMICKPhgkoyGOHd7YmnA+5 BG8dznHYew3Vq8MxbHSPAn2XC2cY8YTlXw41HNLevznJeqZIwHkjuNPiEu8KeAKsnDOo iYN+NfAGQ3GQpuRSJdVbOK8gL17gYBA6pTYf5KBMxDXiMD/mBr6fR4h0A+/Rak3NyvKT H9oBleH+cdhDh35X0+P8RnVAuysA4LHKiQRCWWbsmoV8oRVReicUGj97u/j0IiAavvW7 eqCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=yIpgDKlEY6ipex78LGeCgJkakSZPzOqUeQnNJ+gsoyw=; b=VNNCRoirBZICxqhLw2/bsg9YNu9NV9EackaCZA2rml6wwDOtfVdSJ347p2MkzCkbBA S07CTyZxGPHY5+19N8Iv0S+HtcNZx1juTNvbqmbpxI6ydSltjoLdQMR0fIHp5oY3zWcN Vb+/lmJZ8a7ZGubXP/zLETGzgNxt/3qgKtDYesmUTv91ZgxUG8a01ZelpKIzyVdmO+6G ysLIDEu0DJyE7iVgMd0nEGtCi5Acb5eaawcL8FAlyd8f9XIvQnobaDaYwYZGMbW2H4mX Cm5cmVcCenHw2D8v2Z7vwO02B6jy0DGFGCgXkRUtodIMXvKVO1G1BLIU+Qx0Klxwn8as 68zg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nd36si649294ejc.253.2021.08.13.14.29.05; Fri, 13 Aug 2021 14:29:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234737AbhHMV1m (ORCPT + 99 others); Fri, 13 Aug 2021 17:27:42 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:36211 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234716AbhHMV1m (ORCPT ); Fri, 13 Aug 2021 17:27:42 -0400 Received: from cwcc.thunk.org (pool-72-74-133-215.bstnma.fios.verizon.net [72.74.133.215]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 17DLR5br031990 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 13 Aug 2021 17:27:06 -0400 Received: by cwcc.thunk.org (Postfix, from userid 15806) id 80C7315C37C1; Fri, 13 Aug 2021 17:27:05 -0400 (EDT) From: "Theodore Ts'o" To: Ext4 Developers List Cc: "Theodore Ts'o" , yangerkun@huawei.com, yukuai3@huawei.com Subject: [PATCH] ext4: if zeroout fails fall back to splitting the extent node Date: Fri, 13 Aug 2021 17:27:01 -0400 Message-Id: <20210813212701.366447-1-tytso@mit.edu> X-Mailer: git-send-email 2.31.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org If the underlying storage device is using thin-provisioning, it's possible for a zeroout operation to return ENOSPC. Commit df22291ff0fd ("ext4: Retry block allocation if we have free blocks left") added logic to retry block allocation since we might get free block after we commit a transaction. But the ENOSPC from thin-provisioning will confuse ext4, and lead to an infinite loop. Since using zeroout instead of splitting the extent node is an optimization, if it fails, we might as well fall back to splitting the extent node. Reported-by: yangerkun Signed-off-by: Theodore Ts'o --- I've run this through my battery of tests, and it doesn't cause any regressions. Yangerkun, can you test this and see if this works for you? fs/ext4/extents.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 92ad64b89d9b..501516cadc1b 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -3569,7 +3569,7 @@ static int ext4_ext_convert_to_initialized(handle_t *handle, split_map.m_len - ee_block); err = ext4_ext_zeroout(inode, &zero_ex1); if (err) - goto out; + goto fallback; split_map.m_len = allocated; } if (split_map.m_lblk - ee_block + split_map.m_len < @@ -3583,7 +3583,7 @@ static int ext4_ext_convert_to_initialized(handle_t *handle, ext4_ext_pblock(ex)); err = ext4_ext_zeroout(inode, &zero_ex2); if (err) - goto out; + goto fallback; } split_map.m_len += split_map.m_lblk - ee_block; @@ -3592,6 +3592,7 @@ static int ext4_ext_convert_to_initialized(handle_t *handle, } } +fallback: err = ext4_split_extent(handle, inode, ppath, &split_map, split_flag, flags); if (err > 0) -- 2.31.0