From patchwork Sat Jan 27 01:58:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 13533912 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 69DC0C48285 for ; Sat, 27 Jan 2024 02:03:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 380476B00A4; Fri, 26 Jan 2024 21:02:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E1626B00A6; Fri, 26 Jan 2024 21:02:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E4FC6B00A4; Fri, 26 Jan 2024 21:02:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id F02D76B00A1 for ; Fri, 26 Jan 2024 21:02:58 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D2777160B85 for ; Sat, 27 Jan 2024 02:02:58 +0000 (UTC) X-FDA: 81723442836.04.36EDEBC Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by imf24.hostedemail.com (Postfix) with ESMTP id 4C141180014 for ; Sat, 27 Jan 2024 02:02:55 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf24.hostedemail.com: domain of yi.zhang@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=yi.zhang@huaweicloud.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706320977; 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=F4gKSLaarwbkUP2bBelrp4pI88/teDZ9PgWWS9mW83Y=; b=oPHMmUJCA9bXCvrsoprjNGr63hocQm/FEerGN5hcR5w20k8Pi/iBYpq8PoKlL5UuzJOJZ8 1LbXAJowQVU6fJyNMsN+JEA/WqH1Jxsa7XV1FrPWEYLgwJ3xdOLYdjrn3YfP/CCSxJHchE wMOkuAagfP+wpNKoaOiwT/jNl9CdQUk= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf24.hostedemail.com: domain of yi.zhang@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=yi.zhang@huaweicloud.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706320977; a=rsa-sha256; cv=none; b=R0SM5Oq2GELOVljiP7FxbUavFAC+SpFHG0E1V4pvSu5LZZL1JFYuJCkPxZTZfNgzyRzERp N5DkmkLwr3id5beYpgwkQJVGVxivBsm3udEqruo41CLhEe1s3Ayvyj1Dnd3e2kKu85zri2 wvVdBDTE19yH+S+kGT5ceCsw//kAJ8c= Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4TMHrk1c4Dz4f3lg6 for ; Sat, 27 Jan 2024 10:02:46 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 925E41A0232 for ; Sat, 27 Jan 2024 10:02:52 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAX5g40ZLRlGJtmCA--.7377S24; Sat, 27 Jan 2024 10:02:52 +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 20/26] ext4: implement mmap iomap path Date: Sat, 27 Jan 2024 09:58:19 +0800 Message-Id: <20240127015825.1608160-21-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--.7377S24 X-Coremail-Antispam: 1UD129KBjvJXoW7ZrykWr13Gr1xKryUJw1kZrb_yoW8Ar4fpF 9akrWrGr4xXwnF9FsagFZ8ZryYya4rWr4UWry3GFn5ZrnrZr4rtF48GF1rZF45J3yxZr40 qr45Cry8u34akrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW5JVW7JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr 0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUl 2NtUUUUU= X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ X-Rspamd-Queue-Id: 4C141180014 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: cw8dbgs6967zaqu9414h13yqywhobt1a X-HE-Tag: 1706320975-94253 X-HE-Meta: U2FsdGVkX1+6xauRrJN63CD15xKLxlxE27Bb9xDcb/buhGMwUtjptRNK/PaxEiG4oBSg0c8P/K/8bC4Yt0zi0J78UvC9Kvcbzrfq8R8MtbFB+xaahgd/hD6F0dHTe4cEDDIHEKxQMY9/VgYxt+pKQArH5/4bz69oh68s6X1qRO+jd6he+FRh2QHi+giFbM/bfEwX1Uze7VPvFtxvoujcKpsRPDYL4TypxVua2GD8wM+y39geNqbSM4jbgsrUfwFwyijM8P1J/18+ConqSAAsknZm7rOzcrBu364IyOZkqOQ8Kf1M3u4m8NJG4FV6+WWKkIHC6xCkhil2PQMCEZNze+n6riljyhTlFzHVpJUW9Qy4OIcrECOkVKX2f5eCa/+CzpGdfHaz5pisvfxwVmpyAg+uv+cx3a8NS8ArOAqO74D6rGPJ53idw2MC0dm+rDPlJas+ebKfnXpYKrcwnX/7cMt8YSaLjW0q+NmcpVXPAgNvG5Ke2mDQrc/5qwtwFNYhaZcgSAr6h77TY61psPB6sXoGBb29okjWC1UjFyss5lZ5yJ8Rox2GjoKZ/AeYW9l1THTOrcB7Os0z0bPaXjRUAjc/zn1ZLuovXsu2TOdxfZTGzsHjLfHdFGHX4Gi+HNmyhLjxMt9S841w/4hlPJVEgs91xgnnhgPF6woLncYJinkySVXINUgC8X4j7sOS8jHQROc/zxu2s0Qb4uhqiP30XtMltXGk7zCSqFSsovC6/hy0qxtq7gbKhT0nSKdr/Vxvd/qAE4beRYj2cXXYetL9DoIOCb8iDtCAGIQNSbYW1K/TUlYQkckqZXUYKi5RHxWP8EoCylwtGlf6m0GmHQecOWesE+bLZbGa11+0yDOmdOdHMUo87yfUWgVMHSQ7wbya/Uwe+2eSmEvrBkLxUyO5pGxItqoH+ThRc7V5bl+4Jo5uzqeeP1juYT0BzVTXN/ARAFyw21dpZkKNtuw3KjH yBhHdHYy KlEa/xf3cFfbAGeBtxe+UbaByOMaG98aUZyoJW+53fzytoPWWLaA8jl8XJTVkiGyhf1IzyhkiV2LeqJmh7tI6fIrMJfO25Avo9prJr5KrmyWRSBnviupzBxYxZFdzqvcJDdob2FRtZX336zLmc6JTWYZafJlFw7WK8uak7S70dTTlXX47skc7r0+2K1HxjVyedB2HOT83iRY7cOdeN0/paq9D6IbFcRhRTJib0dZI2R8GCLCLnlQHpWPRO79GONvpQ3G4 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 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 8ee0eca6a1e8..dee661e64a69 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -6466,6 +6466,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; @@ -6489,6 +6509,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;