Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp162579lqj; Wed, 10 Apr 2024 07:08:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUBJ9KwIk1bubuJwLvrmgUgYoL/4wFkSCfRCjVzsNzTfhGJZYu/4dRqhqeWzPuEOO/x9T0eIgtJoJtZcvq1in4/7PMfa25GzHG6KC0TmQ== X-Google-Smtp-Source: AGHT+IFd82L9V917Nu3q9rIXXqeb1W3J+Su6293A1tD/oMmKBU0+ZFJfSiZAMA9CvPs8c0ZdvXIP X-Received: by 2002:a50:8d5d:0:b0:56d:fa24:8ab3 with SMTP id t29-20020a508d5d000000b0056dfa248ab3mr1879864edt.13.1712758133753; Wed, 10 Apr 2024 07:08:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712758133; cv=pass; d=google.com; s=arc-20160816; b=Kt/Rsj3f2aySgyI8m1hcwP3socw6cUzxjsrOx57CFuX7GclIqicQvmjSGiOkgngjHA 4VC7O4k3nJBlqZu5T+AEfox2YOtCXYZLtOesRw1LuxbJY7nwac3KlzWCv7UG1MOOoWjK mhCCTHWWpAT8A2PRxynu0RK1wp/a0B8H3WLwSAJWb0wU0ojjWppuTCkUY3vKqp7eFK7r Q72LzrEvCM5ZuwgKdwZg2gLNgFBnWjBXo3vXFwnvsBMGZ5yvL/GlcZw26jQGUfCdw96p PUrF85zgdbTlyyxG2nCd/XWrgD7Nog4MARCDqq5YGPcw33C2BpkO+iEBA8Y+GwLsNfXu 6jvw== 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=UhGiR19HeAIu8tzXykjZgtAKLLMPZj8YX6gPScUOsdE=; b=CorL3dME2CU34L7qu9GqBVGEaJ4cBABtxMqmyPTYMwZHUIv9ecwlESbMjtSNoJiK4V yaG5lrTAaDRnEt6mPz6LrYQaw+3aGLXGXJLb/DdvbaqvSjr5S25ZSYTSdvV0go2JvQAn 1V0y+osrU8d1Ee+Hm015qSyqUD3gB13pkFv5KqG0PbTkUk8eLdeU5c50kkO7DQ+ipDAQ i/xxzjiZkBkolJxI0apbLEBix4z9MMy2Th/edTSFi4CSQzvt6/N6JAw7EDekfJrdz7yu iNHUUZinnVgWbwsSKPHwT98bHPCyYPUQzG0WQr2ImRJqcPeQiEHeXc0/tXOxQZZIibXN tRYg==; 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-1966-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1966-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 18-20020a508752000000b0056e21b42abasi5583611edv.331.2024.04.10.07.08.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 07:08:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1966-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-ext4+bounces-1966-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1966-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 2F2EA1F3091C for ; Wed, 10 Apr 2024 13:44:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C181817A923; Wed, 10 Apr 2024 13:37:10 +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 43BDD178CD0; Wed, 10 Apr 2024 13:37:06 +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=1712756229; cv=none; b=WOCgVS+QI7t08XmAcr4k+VNJLU5ZNVpsIlqPMR2yTn1L+TvHNNzMot4DobaFgQUz/Agw3LzstyZBAc84dlEj1Il/WSbrr0Bws4iEgJBMfoo/9jZqQwC0OVOrg1j+TTCgq+gquPfixS/eP4NMNTwLm1kEG/jqGY7HBLq1tCKXP5o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712756229; c=relaxed/simple; bh=SxdNjyBOuGqpoN+UGepx1nlXvYSeOVFXJrruxO4uecY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UwXosCC+wUQvyAWFNHLLqZZSy4IcoFCl4gk4rPTogJ8/o8IvxubZb1GrfIJ7ADKXwgrAOO8Dyx6CNgXKzi0d53r/7gbJeyY90XDhMpRMuzJkp+LQ5qlmpx+Qr6XI4MYPWiXxYzlcXWZz8XbcGezBjNUK4xW++uHYLz2n1jEVLmU= 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.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VF3lW3BR7z4f3n6X; Wed, 10 Apr 2024 21:36:55 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 1C14C1A0E2A; Wed, 10 Apr 2024 21:37:04 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAn+RHolRZmeCl4Jg--.8806S30; Wed, 10 Apr 2024 21:37:03 +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 v4 26/34] ext4: implement mmap iomap path Date: Wed, 10 Apr 2024 21:28:10 +0800 Message-Id: <20240410132818.2812377-27-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240410132818.2812377-1-yi.zhang@huaweicloud.com> References: <20240410132818.2812377-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:cCh0CgAn+RHolRZmeCl4Jg--.8806S30 X-Coremail-Antispam: 1UD129KBjvJXoW7urW3tr48Kr4rGryUWrWxWFg_yoW8Ar48pF 9akrWrGr4xXwnI9FsagFn8ZFyYy3WrWr4UXrW3C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kwrite() 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