Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6515798rdb; Tue, 2 Jan 2024 04:51:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvIk0LSZPLCBp1AouNo9QnHeSEdaCo8dMDsa4f0lgmAr4i0RfWnBM3kUczY4Viyiz3kpX2 X-Received: by 2002:a2e:b535:0:b0:2cc:7718:edfe with SMTP id z21-20020a2eb535000000b002cc7718edfemr7051490ljm.41.1704199877647; Tue, 02 Jan 2024 04:51:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704199877; cv=none; d=google.com; s=arc-20160816; b=zCU8E7aHDq4htUq4WzYSKx8b8LPOBypU6LJoz7qDyaaTMeYRWpB430mNk6Ahs865cn 9nU1/qBYs+RpS/ZsD/26QjdidcJm+FQg0A+guy+SFLOW/n09GeSZnoxQt/vKp+bS/3lF kWQT/UlAVIdSrf2FKkvf5SjkFFbt9EtgrkG16cFXdT82F+Zc/XX7G/XdxnWqT8C+gSuB D8sC772O+DuCt0FMdnGhwUpLNCbn3CYxe9o69SXXHbUDuWi/co/2KZWonK2Gl95LbH04 37/WmEjTwyg/sq4svu9m2kO05MJjRAuV2Ou2rqDeCD4NRwqbaep32M9RjRryFWBAmgYS X0sA== 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=IHE4+XDuS4AhWCiTfJ5VaA+75WemC7KjtXs1r70duok=; fh=yWWoL3IRufgA/+2kSpO6uyfw9eN3ZOO7zvul0qbDPkA=; b=S45BbMB9mO0B56eTKSPL7m8/86aBo546sXC7SNMQk0UtJe6Ss3WjGBK3s1e97rgVSg hfjbnGeScU6iAnvSeGZRwHIO+48JKLQE75iJesFJPXNP+Z6aR/g+JGto4y6dipLX085K sDmOAQlg3v5hdJmXHZhgtYGngA/aytIdZbyCDon8RLkh0/c8IYcIoGyoTIlRonqVuQ4V o7sx5Fyw1qCbXvdff6e6XCMUFUn9xHIA8IyrnpaDF36yvYDrETH2YSc4Z6Nqe1SMShB0 6v0RjrpN7MHMeVBY2uZ8eAW9XBJyuHsi+uAFsZy0um+SwHGrHiQ4HcBq1QuAmscGzABC tcNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-612-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-612-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 cz18-20020a0564021cb200b00556adb23bd1si70536edb.528.2024.01.02.04.51.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 04:51:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-612-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-612-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-612-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 B5F791F24475 for ; Tue, 2 Jan 2024 12:44:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 14C5F154AE; Tue, 2 Jan 2024 12:42:20 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) (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 5912D14F61; Tue, 2 Jan 2024 12:42:18 +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.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4T4CD42tJgz4f3kFq; Tue, 2 Jan 2024 20:42:12 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id A2A581A09EB; Tue, 2 Jan 2024 20:42:15 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgBnwUGUBJRl+EvDFQ--.31823S23; Tue, 02 Jan 2024 20:42:15 +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 19/25] ext4: implement mmap iomap path Date: Tue, 2 Jan 2024 20:39:12 +0800 Message-Id: <20240102123918.799062-20-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--.31823S23 X-Coremail-Antispam: 1UD129KBjvJXoW7ZrykWr13Gr1xKryUJw1kZrb_yoW8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x5xdzvxpfor3voofrz/ From: Zhang Yi Implement mmap iomap path, add ext4_iomap_page_mkwrite() to map blocks and dirty folio, almost everying have been done in iomap_page_mkwrite(), so invoke 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 c22b49521df2..ec390bb59b6b 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -6401,6 +6401,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; @@ -6424,6 +6444,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