From patchwork Sat Jan 27 01:58:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 13533902 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 BDBD8C47422 for ; Sat, 27 Jan 2024 02:03:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF65C6B0098; Fri, 26 Jan 2024 21:02:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C2F3B6B0099; Fri, 26 Jan 2024 21:02:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5FDD6B009A; Fri, 26 Jan 2024 21:02:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 8C9286B0098 for ; Fri, 26 Jan 2024 21:02:53 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 60FCC1204DF for ; Sat, 27 Jan 2024 02:02:53 +0000 (UTC) X-FDA: 81723442626.25.53E154F Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by imf28.hostedemail.com (Postfix) with ESMTP id E2A8DC000B for ; Sat, 27 Jan 2024 02:02:50 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.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=1706320971; 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=0yX1oIPNedORYEt87tF6uMdqEjQWvDkcG92o6cjnUek=; b=5N2MpmKdY1K55133TiLctNy9AxVo2sNML8407tHuz2FN7M1huTo/wXdzfXgI20BUnK/rdj PYi5PU8r/laKaYetVVekzYUxq9s7hCE3zdUOBp2GWi4qc2M4AU8gF6hV55DhGqLan9IP5n BPrtYTHKqwlj1XCal44YxM33Af62Q4g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706320971; a=rsa-sha256; cv=none; b=CZvyZVCNrnF5iGxMtssrpc9RFJFob1kMn6GaDWYW1S6ZMsZU8cxB458R/A0JOLYfdQbGHM yegC4EGiWgIINRaoUMAhlvCQG/X5/asblRRvL0yXCiCG++KTyY4/lTGRTAE/WqUulWp4J8 rkWt7ecFIDZfARJ8kdVsGbR70GrlhCk= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=pass (imf28.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.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4TMHrh1Lsxz4f3k62 for ; Sat, 27 Jan 2024 10:02:44 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 985391A016E for ; Sat, 27 Jan 2024 10:02:46 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAX5g40ZLRlGJtmCA--.7377S15; Sat, 27 Jan 2024 10:02:46 +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 v3 11/26] ext4: also mark extent as delalloc if it's been unwritten Date: Sat, 27 Jan 2024 09:58:10 +0800 Message-Id: <20240127015825.1608160-12-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240127015825.1608160-1-yi.zhang@huaweicloud.com> References: <20240127015825.1608160-1-yi.zhang@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: cCh0CgAX5g40ZLRlGJtmCA--.7377S15 X-Coremail-Antispam: 1UD129KBjvJXoW7AF1xtFW8Ww48JrWxur4fGrg_yoW8GFWUpa 97C34rGr4UX348uayIyF1UZr1rKa4UKrWUtFs8uF1jya4fGF9a9F10yFyI9FyxKrWrJ3yF qF48Kry8Cay8A37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr 0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUl 2NtUUUUU= X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ X-Stat-Signature: pdu3kgssy4ndo6hyjjbgyogxonxmz9ws X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: E2A8DC000B X-Rspam-User: X-HE-Tag: 1706320970-272684 X-HE-Meta: U2FsdGVkX18SnMYYgJIsPtBGg9SzbUAPC6AYHZCipm0DMCpweCm+QOg9XaFJPHxQamw3jws+hhDCq3YSj1jvQPjxNyO0LjNMGpPHOMWj9sjNsDs7wzZ3MD19Oey6Lloq4rcjOXuB4Lbf/u04KV6UcCtlqZW2NqrX4fzLbQcMOfy5/Q5JtmIRnyCCZAG5ys/11u0ACaE+PpX5YT4R/iGvOJdOd17ja5wgG+yiCFDZYMhe97cU8i55reuS7nCLk8rxFVmSnkTvlLSOy7EfdUnZkussrozOKd+TVuhSu7UY27HtvGPgTljeglV1ldBLOBmMHLPWVR+tjomOCVAaXPdNybKgTG/4NQPHeIWm2drpFsyt3XTIIEsZGP2TBOQ2D7iLNtN5dqEj+e3WfWXR3GLnQZhAcqGT4hMM8lGurKkap/D77sQzy30lDLzZ3RaKQyH+jpFz0tfNrRCPcyvbkZG5ojPmh+SxM4fIkK6Sq8StKlYh9g23znHpUX0prGDILmt3fZasAWD/Frpn2/tOIbe9DVNiYx+E9pueuduN/4SSZxZ1Pker56HJb7j4ZQQ0vg0B/fbx0j25UU8QCjEPWRTXJC6G74MIJO8opJX+xui05yTrdN6BkuvAuiMYT6RteTxuCgiBSIa2964JJUJtCH8uYJtmyX46vbGvTvCgwlYfckWK93fBZanROKZEOejlBINsAYipvbmdR1i5AXOlZxK6USOrfBPQtPwswIsKkYq9qzkVLPMYwtYBjd12eZrsDAYzv1P7Ie69yepYggtHnM/oVP6eH0e1oKLTTP01bAUX6ECrlFx9H+s3VkfIaXQYgyVG22MoGZzRWQnJkC4VHeDbo4GFvbRGtL5EqNk/9y/eWD+b20e/wV3hn9Rs9Gz6ufvlLwiOJJZCw4T6mSFWby7umekZyvJ8AAZNudlHEuqZI2hf3VaBTSTDTk8Ufpa9eqgCqOs1r2ICQIGuUSZzQs8 obccCKXA w2CVYcMc+DhqVvZpvfNzii1CvTM5qnij6jZfRcfyg8TaQv75Hwg5lyqbEo2yZyCX/OfmNMnGAB5JL18cJ7Ti57ZvPVAwKa4QTcB9612+OCSs0nS/VqpH8NxiWLtIIOqRAkxhbY0iuRDScUDhJpY6S/nLBZWWl34JjGx3tV6GOpKkNE4sasCJIlTIMp3brl1LyhlgNvg0z9aUsUTdlmtWhntY1hr/eJePrYCkH2w9Bvkkm52tLb8sYzNG4pjkZ7o8whNsthYkiNTA96hoMCVNo/byi1A== 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 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);