Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6516352rdb; Tue, 2 Jan 2024 04:52:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFv6S9HT6lXQ9KiN/RK+FKAPFCIK0y+M+WWzE1X1EFKEqZv9hZNRdQ5CDTiIoW9TIsdySrY X-Received: by 2002:a50:8d58:0:b0:54a:f72d:38b2 with SMTP id t24-20020a508d58000000b0054af72d38b2mr10580481edt.8.1704199954504; Tue, 02 Jan 2024 04:52:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704199954; cv=none; d=google.com; s=arc-20160816; b=Shx+78QIRuYHTXQ1mixHKxK0RadK5z6GiRhK424IWSw9q08+fTQjLhqEcUWSb8taCM PLl5NZQP+De7JbM+CmIZcE+Cyj+2khUL4XryYA6nqd05epZtIw6miWihQZEDxABcLD90 kzGNwQU5RC5tl3l3c6xiaqJQImD9gkFAo3D4zi1soeVabkzyacxWy5i8gxSOoqJfbl0C e8NkaFc+T4zH7dAWdff0frCSxJDrghHCdSHZwNu23PAxzWw6ECNck/xX7hI3spsjj0k9 wlTerQU4YWaumWyj973cpCBxGTmOL9O4w6em7DfhrRj+zUDo93pdaWylDZZk7b56Wxvf /n8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=0yX1oIPNedORYEt87tF6uMdqEjQWvDkcG92o6cjnUek=; fh=yWWoL3IRufgA/+2kSpO6uyfw9eN3ZOO7zvul0qbDPkA=; b=w7vEKZT+N+TCZGcJt6OkgMI5Sb+u7qLuH/QzfGAbSLIG8zhj1rPyYxhhdvdcYLA46Q o833wmAyDXQkmoKk4dn3FMp4WPlsOIqPRBFF1AZyBQRR8v8b1iUqoYXLe9drV7Kkqtnr QDpa177Wt1qi55kk2e7TsCoqOC0eRBF4WzQkoWCO/LQZFxQqqGxbGeffBGQdqPR2i5ZI G3g9Nh6rwQXhVUEAeFuF8b+RjWahfJ9J+ufDMS4PwqVjfP/iwFNN7w3SwuNrac8rBuAj zbdYpA34mMllouZYKga24/F5tws6tQ0+7JxL1t0zbcIY6kpqqDQHf0N7w0q/s5NbBbKh 8tdA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-605-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-605-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 17-20020a508e11000000b00553a31e25ecsi10710417edw.692.2024.01.02.04.52.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 04:52:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-605-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-605-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-605-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C04CF1F23D0A for ; Tue, 2 Jan 2024 12:43:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3830F14A85; Tue, 2 Jan 2024 12:42:16 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C08B125CB; Tue, 2 Jan 2024 12:42:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4T4CCx50Zwz4f3nKL; Tue, 2 Jan 2024 20:42:05 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 5381B1A017F; Tue, 2 Jan 2024 20:42:11 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgBnwUGUBJRl+EvDFQ--.31823S15; Tue, 02 Jan 2024 20:42:11 +0800 (CST) From: Zhang Yi To: linux-ext4@vger.kernel.org Cc: linux-fsdevel@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, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com, wangkefeng.wang@huawei.com Subject: [RFC PATCH v2 11/25] ext4: also mark extent as delalloc if it's been unwritten Date: Tue, 2 Jan 2024 20:39:04 +0800 Message-Id: <20240102123918.799062-12-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240102123918.799062-1-yi.zhang@huaweicloud.com> References: <20240102123918.799062-1-yi.zhang@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:gCh0CgBnwUGUBJRl+EvDFQ--.31823S15 X-Coremail-Antispam: 1UD129KBjvJXoW7AF1xtFW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-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ From: Zhang Yi Mark extent as delalloc if it's been unwritten, this delalloc flag will last until write back. It would be useful to indicate the map length when writing data back after converting regular file's buffered write path to iomap. Signed-off-by: Zhang Yi --- fs/ext4/inode.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 44033828db44..9ac9bb548a4c 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -1742,7 +1742,11 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock, #ifdef ES_AGGRESSIVE_TEST ext4_map_blocks_es_recheck(NULL, inode, map, &orig_map, 0); #endif - return retval; + if (ext4_es_is_delayed(&es) || ext4_es_is_written(&es)) + return retval; + + down_read(&EXT4_I(inode)->i_data_sem); + goto insert_extent; } /* @@ -1770,9 +1774,11 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock, inode->i_ino, retval, map->m_len); WARN_ON(1); } - +insert_extent: status = map->m_flags & EXT4_MAP_UNWRITTEN ? EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN; + if (status == EXTENT_STATUS_UNWRITTEN) + status |= EXTENT_STATUS_DELAYED; ext4_es_insert_extent(inode, map->m_lblk, map->m_len, map->m_pblk, status); up_read(&EXT4_I(inode)->i_data_sem); -- 2.39.2