Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp310950rdh; Thu, 23 Nov 2023 04:53:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgTtM1Fp3oPMI2v2qu+lasHp+o2/gtr9LM8Hlr4bGLHpdQOcIcph6gXAcF4vRJLhOaWDRY X-Received: by 2002:a05:620a:1233:b0:77a:4606:756d with SMTP id v19-20020a05620a123300b0077a4606756dmr5061053qkj.74.1700743994226; Thu, 23 Nov 2023 04:53:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700743994; cv=none; d=google.com; s=arc-20160816; b=Vg4616cH8EEoEN+byzWtoC1isbP45h1jqLY2bDczJh3kL58BpMhSx1AHayWxO+MRTL MMyTlpf9b3fXPif8BuY4zM+FjoVp+E1YRqFt9Ez7FJxqoRouKlcRxfB+Z10tIS8KKIVV moTq7isedmy4PGc4J6v72brxAjkeCaQL/XxF04YOiS8H1VFwpbqlRmCvVjR6HOk8QqFh VbgUj2omhiVsds6wiRwZvs3nEAOYX1luYtXh8VjY5LG1bClnbk5ZlyW4/t7YhptWnXmC CZm02bKzpGXi0RxdKES1srNdoQ2o0RB5YvFeDdz4FiKfhqaLXic1Z9KbZXfm+xzdqBmk bNiA== 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=oOmTOv+AUI5pP+2K1JIF9cRDLG6wJLT5LVUbgDD7f/k=; fh=oXgJbFeK1mY0T4jBbK/Fs3Mi9F4SdMRqpoziDljuAF4=; b=Dlu9TdxG5PTtW1oLQqddLYlqKGxiibYmnu1Ufy6h8vL2kNqf41DC17lqP259liZToB TwxaYdF2EnyBPM9ivT2HL82WttvQ+Y9WuDg6EXp42WeArdTZ+jQ8VN5KNWuV7oZM2q+P LxyIk9903MQXgZOo9nQq6UK0b5PJiWoHCj4fGjf3KnrOW4kph7qx2RyGTg+uK5wu44Qs 0mwZBffsR0XEpf7WbeAsZMGUEzkfM1mt4uKOS8WJxC1T2f5/s/a8FmCSnXTSu3MBXwbT znQAh6QEj3Qn+lycVBKb2XuB1ao2tz6qxNLIF7UW5xQgZyqE6VkS2YDL3KoyAYXnwx6r 1mwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-118-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-118-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 c12-20020a37e10c000000b0077d78a2fbfbsi278198qkm.597.2023.11.23.04.53.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 04:53:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-118-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; spf=pass (google.com: domain of linux-ext4+bounces-118-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-118-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 F422C1C21046 for ; Thu, 23 Nov 2023 12:53:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D99832E85D; Thu, 23 Nov 2023 12:52:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none X-Original-To: linux-ext4@vger.kernel.org Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02CECD40; Thu, 23 Nov 2023 04:52:09 -0800 (PST) Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SbdKt15vKz4f3m7T; Thu, 23 Nov 2023 20:52:02 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 6E38C1A0734; Thu, 23 Nov 2023 20:52:06 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDn6xHdSl9lSfnfBg--.20473S20; Thu, 23 Nov 2023 20:52:06 +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, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: [RFC PATCH 16/18] ext4: impliment mmap iomap path Date: Thu, 23 Nov 2023 20:51:18 +0800 Message-Id: <20231123125121.4064694-17-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123125121.4064694-1-yi.zhang@huaweicloud.com> References: <20231123125121.4064694-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:cCh0CgDn6xHdSl9lSfnfBg--.20473S20 X-Coremail-Antispam: 1UD129KBjvJXoWxJFyUAr4kCFyfuF4rCF4kJFb_yoW5WFyfpF 9xAF1rGr43W3sI9rs3WF4DZw15Ka4xKr4UWryfWw1Yq39FqryxtF48KFn8ZF15t3yrAF47 WF4jkryUu3Wa9rDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr 0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUQ SdkUUUUU= X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ From: Zhang Yi Impliment mmap iomap path, direct use iomap_page_mkwrite() for the .page_mkwrite() callback. Signed-off-by: Zhang Yi --- fs/ext4/ext4.h | 1 + fs/ext4/file.c | 6 ++++++ fs/ext4/inode.c | 24 ++++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 65373d53ba6a..6b3e34ea58ad 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -3006,6 +3006,7 @@ extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks); extern int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode, loff_t lstart, loff_t lend); extern vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf); +extern vm_fault_t ext4_iomap_page_mkwrite(struct vm_fault *vmf); extern qsize_t *ext4_get_reserved_space(struct inode *inode); extern int ext4_get_projid(struct inode *inode, kprojid_t *projid); extern void ext4_da_release_space(struct inode *inode, int to_free); diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 6830ea3a6c59..15fe65744cba 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -798,6 +798,12 @@ static const struct vm_operations_struct ext4_file_vm_ops = { .page_mkwrite = ext4_page_mkwrite, }; +static const struct vm_operations_struct ext4_iomap_file_vm_ops = { + .fault = filemap_fault, + .map_pages = filemap_map_pages, + .page_mkwrite = ext4_iomap_page_mkwrite, +}; + static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma) { struct inode *inode = file->f_mapping->host; diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index ca66afd61fb3..2efa898403f7 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3748,6 +3748,10 @@ const struct iomap_ops ext4_iomap_read_ops = { .iomap_begin = ext4_iomap_buffered_io_begin, }; +const struct iomap_ops ext4_iomap_page_mkwrite_ops = { + .iomap_begin = ext4_iomap_buffered_io_begin, +}; + static int ext4_iomap_read_folio(struct file *file, struct folio *folio) { return iomap_read_folio(folio, &ext4_iomap_read_ops); @@ -6698,3 +6702,23 @@ vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf) ext4_journal_stop(handle); goto out; } + +vm_fault_t ext4_iomap_page_mkwrite(struct vm_fault *vmf) +{ + struct inode *inode = file_inode(vmf->vma->vm_file); + struct address_space *mapping = inode->i_mapping; + vm_fault_t ret; + + if (unlikely(IS_IMMUTABLE(inode))) + return VM_FAULT_SIGBUS; + + sb_start_pagefault(inode->i_sb); + file_update_time(vmf->vma->vm_file); + + filemap_invalidate_lock_shared(mapping); + ret = iomap_page_mkwrite(vmf, &ext4_iomap_page_mkwrite_ops); + filemap_invalidate_unlock_shared(mapping); + + sb_end_pagefault(inode->i_sb); + return ret; +} -- 2.39.2