Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp189323lqj; Wed, 10 Apr 2024 07:49:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWUG53DVENitNZ4pbh5kXMg12JaYFUmR449unL6oS49E6dv6/o9CZ9Bw1CYeFkepuNYalgwVNlEGPBaoYWSdozNFPLIWbFCChPh8hcTcA== X-Google-Smtp-Source: AGHT+IEDee5/Ub8xUh+/sLl0LfukJKQN5qI+zruCb8ykfzDX0uDu5FI5SSU9CD1LwYElZGkkO8Ev X-Received: by 2002:a05:6122:c9c:b0:4d3:3a8c:13ad with SMTP id ba28-20020a0561220c9c00b004d33a8c13admr3341645vkb.8.1712760551999; Wed, 10 Apr 2024 07:49:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712760551; cv=pass; d=google.com; s=arc-20160816; b=d3ouOmUZubQurMPLHfTjE8wPA6bJUFMs5/ipr1z/6uWPrW3rEsmUwCBik6wU2dmz0S EQcSRdqbgEGIdYs+LMxcy4x64jWnbVywAKb0P1NKOeVKUmnlMSTtEg7VgEYEtaNva3e2 gwmHoVYlg3huqBQg65Cv4yepK07y4JK029SPif1LMudWFdmVOOGIZw2bMWc+0oOvJAF7 idx97ahmV0aeDKy8M3J/ivRZd/1Wn02gePoq1kZvfiJHNTd7O9QCH401u6t4B4T322te tmyrNwRNxKNmLpml8lnZ58y9aapNVdw9mZrBk3d+hrHdtKzaXX0kkPun6TaUbIuGVI2T PyUw== ARC-Message-Signature: i=2; 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=DmeNzuRS0UtAzCMbn3rP62UIT6+e3MYM855nqaJqZuc=; fh=VCdyVZCUh9R8dltaA9/RWs/hxQzWhc63WX0fta2PQtE=; b=wQBIuwrdC1suPA4Fb9eM5Wh7Lkh5kV1fUurz/TqRMm5e3X39hBQRaQvM3cs4qPj+1i KF2RBe5I4MPTYa8bs3xIYJdTbgt0aC7eZ1eEuM7Pa2Fl+PfjlBdsMusm4DAxBZqgAyFF XjHp4aqppuen4ere2FXmhY+HO13GF0eYbzqOoMwzrwdNdEMQd9Sag8mXNs4ZRJRVe+I7 5O0sEyVrEnmgCzT2Te35XLNpKmEqY8wmEp03dW/EJCuNqfgnSx5BNlcVow3F0urj62nt 1erb9CYQEefg1LTvdIesA4wM4Z4KkYLBg8/egGmHEMXNa3kP4iJikec77xhzilSF4AYu 3K2w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-ext4+bounces-1996-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1996-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r4-20020a0cf804000000b006991273becfsi12405491qvn.534.2024.04.10.07.49.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 07:49:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1996-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-ext4+bounces-1996-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1996-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B27521C20AB1 for ; Wed, 10 Apr 2024 14:49:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CDE94181CFD; Wed, 10 Apr 2024 14:38:48 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from dggsgout11.his.huawei.com (unknown [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 E43D8180A7F; Wed, 10 Apr 2024 14:38:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712759928; cv=none; b=FzEfkuMfgSj/+uXJV7c5K4HsuBG9Ar6APWeJuLZqLjYXxHTG1AS/t9QtPQIMEDkgUEzz0XtfJqlNQOGmKyili2fytSaUMcPVumCEWE0Z4ozCa7hjeGuNymH0ImsuAksepwq86hMAnpLOFcINwFAQ+2oEGqd8AWbweSGpPOaHS7I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712759928; c=relaxed/simple; bh=SxdNjyBOuGqpoN+UGepx1nlXvYSeOVFXJrruxO4uecY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pA+t6RV4FLpOaqSSfBDaRAQEuK+taFyezekELQ/In6CX4l+9Od84TIToTkvwH3YzgooTnKmCAcfveF9j0eOqkLxEFiEOU67PMkILfEZFvjcuhuh+d58wcqAS74aWJn+DnhnpB8Aespc07QzR5ib8HL4cI4mlVWz+w8clGe3RTDA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VF56k1cnPz4f3kJs; Wed, 10 Apr 2024 22:38:38 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 9D2181A0175; Wed, 10 Apr 2024 22:38:42 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAX6RFSpBZmcwR8Jg--.63000S30; Wed, 10 Apr 2024 22:38:42 +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, david@fromorbit.com, 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 26/34] ext4: implement mmap iomap path Date: Wed, 10 Apr 2024 22:29:40 +0800 Message-Id: <20240410142948.2817554-27-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240410142948.2817554-1-yi.zhang@huaweicloud.com> References: <20240410142948.2817554-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:cCh0CgAX6RFSpBZmcwR8Jg--.63000S30 X-Coremail-Antispam: 1UD129KBjvJXoW7urW3tr48Kr4rGryUWrWxWFg_yoW8Ar48pF 9akrWrGr4xXwnI9FsagFn8ZFyYy3WrWr4UXrW3CFn5Zrnruw45Ka18WFn5ZF45J3yxZw4U Jr45Cry8u34a9rDanT9S1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ext4_iomap_page_mkwrite() for the mmap iomap path. It dirty folio and map blocks, almost all work have been done in iomap_page_mkwrite(), so call it directly. Signed-off-by: Zhang Yi --- fs/ext4/inode.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 55a4d293177d..9d694c780007 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -6484,6 +6484,26 @@ static int ext4_bh_unmapped(handle_t *handle, struct inode *inode, return !buffer_mapped(bh); } +static vm_fault_t ext4_iomap_page_mkwrite(struct vm_fault *vmf) +{ + struct inode *inode = file_inode(vmf->vma->vm_file); + const struct iomap_ops *iomap_ops; + + /* + * ext4_nonda_switch() could writeback this folio, so have to + * call it before lock folio. + * + * TODO: drop ext4_nonda_switch() after reserving enough sapce + * for metadata and merge delalloc and nodelalloc operations. + */ + if (test_opt(inode->i_sb, DELALLOC) && !ext4_nonda_switch(inode->i_sb)) + iomap_ops = &ext4_iomap_buffered_da_write_ops; + else + iomap_ops = &ext4_iomap_buffered_write_ops; + + return iomap_page_mkwrite(vmf, iomap_ops); +} + vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; @@ -6507,6 +6527,11 @@ vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf) filemap_invalidate_lock_shared(mapping); + if (ext4_test_inode_state(inode, EXT4_STATE_BUFFERED_IOMAP)) { + ret = ext4_iomap_page_mkwrite(vmf); + goto out; + } + err = ext4_convert_inline_data(inode); if (err) goto out_ret; -- 2.39.2