Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp80516pxb; Sun, 15 Aug 2021 23:58:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+Dh0BgIg6HLcHe8H+cXXfm68faO7f8DekeN+a5YOpGIpfrOG11IraZToBmXAmUyuwf9Jf X-Received: by 2002:a17:906:72ce:: with SMTP id m14mr14312867ejl.394.1629097108615; Sun, 15 Aug 2021 23:58:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629097108; cv=none; d=google.com; s=arc-20160816; b=FIRLkONNBGk6crFvpbpOxzl2FV7DoLHFYbpT4yj/fvORnKJ+6+062xixDiMdB5i+wB aNpagZjJXzgiEqY/lZWxpp2gtE1aYmUO1RFBcBEWTAGRHymR3vCqfSW361IjT/jXATLV Ysx1uTb4ehMczKkd6dm4aZoFlLtLO+a4O7jYw1RMg5pkrQCSNpfDxM6ieABl9dwgFcSW 5ThK/Dm2czC4Zm+r169FzItjNMtc8RMJ8/NLxxnjInOLoQHPxxi3M9BfkbvncQXV/GgE QGr+B+50h6Ce4G6Jyw29zOFetk8HvE75jdgWx5JLn8iXEdDzGoQGxqXBQUZLSRiVwI0T dvOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:references:cc:to:from :subject; bh=qkn1rK43fj8NQ6Y274i+My9qX7FDS+jWaS2i84gc9K8=; b=WxtEzL3+5ZkHhHK32bi1m6DgqqGyhtlw8t8H+0UHC+ZXtwTRYPMnvl/cUcDx62h9ZT 0kSLiIvxNL1afC0wFR+B8b9gMkut67aDudvi9dZbjbx7EDBBDziLkqY/lgVfRihTEcLp kVAxCph3JjAxMftMYI0hVEcX+xKVxIwnwmhpn9l/dNu8FA+L2bBzLLkf5dJts2kLWYcC YorRutUfThKSCLx9aZyHhPtyAyyQwdfg7jxLzDY8ZOfm8JeGfF7E+CBFaU6UyHa97TB0 6tL7gJRYONO3vxaq1UhzcRmJ1MXYXbVjuu25OhKE56WDYZJwue36gtIOIaqzlORcclcK NERA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b18si9216833ejh.638.2021.08.15.23.57.56; Sun, 15 Aug 2021 23:58:28 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233512AbhHPG6K (ORCPT + 99 others); Mon, 16 Aug 2021 02:58:10 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:8417 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233349AbhHPG6K (ORCPT ); Mon, 16 Aug 2021 02:58:10 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Gp4cw3WTjz85NG; Mon, 16 Aug 2021 14:53:36 +0800 (CST) Received: from dggema766-chm.china.huawei.com (10.1.198.208) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Mon, 16 Aug 2021 14:57:37 +0800 Received: from [10.174.177.210] (10.174.177.210) by dggema766-chm.china.huawei.com (10.1.198.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Mon, 16 Aug 2021 14:57:37 +0800 Subject: Re: [PATCH] ext4: if zeroout fails fall back to splitting the extent node From: yangerkun To: Theodore Ts'o , Ext4 Developers List CC: References: <20210813212701.366447-1-tytso@mit.edu> <2714202a-872e-aa75-7033-fb06a47b9241@huawei.com> Message-ID: <9fdbfcce-961d-8074-e431-5d867fbf5216@huawei.com> Date: Mon, 16 Aug 2021 14:57:36 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: <2714202a-872e-aa75-7033-fb06a47b9241@huawei.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.210] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggema766-chm.china.huawei.com (10.1.198.208) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 在 2021/8/14 10:15, yangerkun 写道: > > > 在 2021/8/14 5:27, Theodore Ts'o 写道: >> 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? > > Will do it. Thanks for the patch, it can help us to pass the testcase. And after some review, it's really a better fix for me. Thanks, Kun. > >> >>   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) >> > .