From patchwork Wed Apr 10 13:28:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 13624554 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D83FCD1299 for ; Wed, 10 Apr 2024 13:37:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 70DF66B00A4; Wed, 10 Apr 2024 09:37:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6BE346B00A5; Wed, 10 Apr 2024 09:37:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 585376B00A6; Wed, 10 Apr 2024 09:37:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 3F75F6B00A4 for ; Wed, 10 Apr 2024 09:37:06 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 07706A072D for ; Wed, 10 Apr 2024 13:37:06 +0000 (UTC) X-FDA: 81993723252.14.F0657BD Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by imf25.hostedemail.com (Postfix) with ESMTP id BB497A0027 for ; Wed, 10 Apr 2024 13:37:03 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of yi.zhang@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=yi.zhang@huaweicloud.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712756224; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=37SfuM5G3Dj7+7QLVyT1la8ndDsI8tsv6jHJ3LlC8EU=; b=nMDJs31hhmVsCuKbpJ1Bfp54eUAPrWUEpsttIwvcWo4uwob5E7ANt9PdAWL4d6Ch7Z0Lrf rL8KXbv/YsyLcY7XCiEp40BSlldiJzLVE+j8szHAGUlIdCXTFESKlbCjXXMjp4cJH8sR4m sUtyKEwogxgkQqA2GiiLNHlqIzrDlRQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712756224; a=rsa-sha256; cv=none; b=8Exhtb7brKCBafEScDYRMJOWl1xHkgVkitTph9IDHg54So4TJRJPV4obF68tSpubZjW/vP 2DBXQE3/KWbLhF7I7GWF/8aRtJGFD6znhzAaufer+OmuFZoTrE45UVz8BkZXuV9U324pFa iRoCTuZyKo4jlWQMlBzF52PCZDwwWCU= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of yi.zhang@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=yi.zhang@huaweicloud.com; dmarc=none Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VF3lR4d7dz4f3mHL for ; Wed, 10 Apr 2024 21:36:51 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 4E4231A0E1F for ; Wed, 10 Apr 2024 21:37:00 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAn+RHolRZmeCl4Jg--.8806S24; Wed, 10 Apr 2024 21:37:00 +0800 (CST) From: Zhang Yi To: linux-ext4@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, ritesh.list@gmail.com, hch@infradead.org, djwong@kernel.org, willy@infradead.org, zokeefe@google.com, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com, wangkefeng.wang@huawei.com Subject: [RFC PATCH v4 20/34] ext4: use reserved metadata blocks when splitting extent on endio Date: Wed, 10 Apr 2024 21:28:04 +0800 Message-Id: <20240410132818.2812377-21-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240410132818.2812377-1-yi.zhang@huaweicloud.com> References: <20240410132818.2812377-1-yi.zhang@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: cCh0CgAn+RHolRZmeCl4Jg--.8806S24 X-Coremail-Antispam: 1UD129KBjvJXoW7tr1UXw4xWrW5ZFy8Ary5Jwb_yoW8Wryfpr 9rAF1xWr40v3Wj9FW8u3WUJryrC3WUWF47GrZ8t3y29ay7Jr1ruF47K3WrZFyFqrZ7Xw4j vr40qa48Zwn5Aa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW5JVW7JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr 0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUA rcfUUUUU= X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ X-Rspamd-Queue-Id: BB497A0027 X-Rspam-User: X-Stat-Signature: 9etdyizrho6fggqtgn6uwxpngnzx9t7i X-Rspamd-Server: rspam03 X-HE-Tag: 1712756223-621935 X-HE-Meta: U2FsdGVkX19TyITEFxWj8IFOb6EKHnvGI4495vtTGezv4TIuUyNAm7v890DYZi1682gy0YbVbIuRKepCwCjPIVIWYouCFx7fhnFiFr5tOF6RftFwDVcGSsem3eyfENjYqEPyahWRYjfkPYRqlON2f8QpfVpi2aVqmLk+FEFSBYmndpZUBBGgMYCSIN4c8RjoF7OKLRALELw002RzHBrOnjUNg1zEXk2iCof4UgNWBA5TfIek5ClTy1wmfFoQ51KKwbqwKxmcd2J0NOoG43w9d0Wgp4CMezVpinMFVeuq5hqHj/+Wk43/CaHQXL+B61m8KwpCM+5IAD4XPSaGKL+Y6C5AEYPD+xUs8ZFyb/CMcdD8tDBpOs2eKiMduYuJjfBY6YGEIwUeDo+S9bfLriGGeNmb1QPgvHo2h7LpCwz+t3LIlnNUuh5M0bcxmtrBmIVFjg/F6FUW2oLjtHHImyIqgR9zxKPw/1QBeAvCd+Y2ERwXePV5Rp/Fkaa5VJhBl6ofN+c+Dg+Ppco5s/BV2N9MLmoCKqdcfNbI+LAuZhe4WPnDFq/3qBvWERsL60/eIlC3eNvNguzpwHAKQGkSfES9TZShKX6y3xQ0qu69HUNBf7i0QJMQK+k/jj6IMRSPYaqZwbepe8hrGXr7OtQEsYU8KSkuVt5Di3TSKnjR4MnfO8kEmyrTQmR4CzmEtyYoJRrCZL3ixgDq3cxNIZTYoPcDhnApSgCEHyOBBzvUQ3u/f7inQ/ffz4mPOdQPJrBMVTR83RDCKZ/dKbJLAtf1rgHOd3zK7E/kfCRPFcnhy17p919MImch8djZjJX+zVE7SJB19Wn2ri/EPY8J6v4Xd0WPqHB7pfpOzUu8EwjojWgqlts9zy3WinY5Qm7iy1bk/zOiwQupIYxzvbZgq9ToAkK1V9GKZWBMOPqbk3lDdEVqS14VHrfLmsohnCtxk+99hyXnuCMmRxqIMDcJLVlZWZM WnRC0wx0 wG+FY X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Zhang Yi ext4 only reserved space for delalloc for data blocks, doesn't reserve space for metadata blocks in ext4_da_reserve_space(). Besides, if we enable dioread_nolock mount option, it also doesn't reserve metadata blocks for the extent status conversion. In order to prevent data loss caused by fail to allocate metadata blocks on writeback, we reserve 2% space or 4096 blocks for meta data, and use EXT4_GET_BLOCKS_PRE_IO to do the potential split in advance. But all these two methods were just best efforts, if it's really running out of sapce, there is no difference between splitting extent on writeback and on IO completed, both will lead to data loss. The best way is to reserve enough space for metadata. Before that, we can at least make sure that things won't get worse if we postpone splitting extent to endio. So let's use reserved sapce in endio too. Signed-off-by: Zhang Yi --- fs/ext4/extents.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 8bc8a519f745..fcb1916a7c29 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -3722,7 +3722,8 @@ static int ext4_convert_unwritten_extents_endio(handle_t *handle, (unsigned long long)map->m_lblk, map->m_len); #endif err = ext4_split_convert_extents(handle, inode, map, ppath, - EXT4_GET_BLOCKS_CONVERT); + EXT4_GET_BLOCKS_CONVERT | + EXT4_GET_BLOCKS_METADATA_NOFAIL); if (err < 0) return err; path = ext4_find_extent(inode, map->m_lblk, ppath, 0);