{"id":2230304,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2230304/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/patch/177747214715.4107473.4460452026157984455.stgit@frogsfrogsfrogs/","project":{"id":8,"url":"http://patchwork.ozlabs.org/api/1.1/projects/8/?format=json","name":"Linux ext4 filesystem development","link_name":"linux-ext4","list_id":"linux-ext4.vger.kernel.org","list_email":"linux-ext4@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<177747214715.4107473.4460452026157984455.stgit@frogsfrogsfrogs>","date":"2026-04-29T14:55:14","name":"[10/19] fuse2fs: don't do file data block IO when iomap is enabled","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"cf43d1c5ce29ad0aab07dd746ec0fa0a34916f5e","submitter":{"id":77032,"url":"http://patchwork.ozlabs.org/api/1.1/people/77032/?format=json","name":"Darrick J. Wong","email":"djwong@kernel.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ext4/patch/177747214715.4107473.4460452026157984455.stgit@frogsfrogsfrogs/mbox/","series":[{"id":502087,"url":"http://patchwork.ozlabs.org/api/1.1/series/502087/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/list/?series=502087","date":"2026-04-29T14:53:09","name":"[01/19] fuse2fs: implement bare minimum iomap for file mapping reporting","version":1,"mbox":"http://patchwork.ozlabs.org/series/502087/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2230304/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2230304/checks/","tags":{},"headers":{"Return-Path":"\n <SRS0=fdGs=C4=vger.kernel.org=linux-ext4+bounces-16199-patchwork-incoming=ozlabs.org@ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-ext4@vger.kernel.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","patchwork-incoming@ozlabs.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=t1zX1Zox;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org\n (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org;\n envelope-from=srs0=fdgs=c4=vger.kernel.org=linux-ext4+bounces-16199-patchwork-incoming=ozlabs.org@ozlabs.org;\n receiver=patchwork.ozlabs.org)","gandalf.ozlabs.org;\n arc=pass smtp.remote-ip=172.232.135.74 arc.chain=subspace.kernel.org","gandalf.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=kernel.org","gandalf.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=t1zX1Zox;\n\tdkim-atps=neutral","gandalf.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.232.135.74; helo=sto.lore.kernel.org;\n envelope-from=linux-ext4+bounces-16199-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"t1zX1Zox\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g5L2P28y7z1yHZ\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 00:55:25 +1000 (AEST)","from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\tby gandalf.ozlabs.org (Postfix) with ESMTP id 4g5L2P1bhmz4wLR\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 00:55:25 +1000 (AEST)","by gandalf.ozlabs.org (Postfix)\n\tid 4g5L2P1Xncz4wM1; Thu, 30 Apr 2026 00:55:25 +1000 (AEST)","from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby gandalf.ozlabs.org (Postfix) with ESMTPS id 4g5L2K3mJjz4wLR\n\tfor <patchwork-incoming@ozlabs.org>; Thu, 30 Apr 2026 00:55:21 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id 1B58D300748E\n\tfor <patchwork-incoming@ozlabs.org>; Wed, 29 Apr 2026 14:55:19 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 3843032694F;\n\tWed, 29 Apr 2026 14:55:15 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id EE8E627EFE9;\n\tWed, 29 Apr 2026 14:55:14 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id C789EC19425;\n\tWed, 29 Apr 2026 14:55:14 +0000 (UTC)"],"ARC-Seal":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1777474525; cv=pass;\n\tb=l/c0by1ctaXR038jNJukkvP0itdQSZQkx95TmfCQqBEFK3iTy4DIJE9PCVslfTF5G834Czjk33VDoV0MPSarnVJr6aq7H8AGoVTcSVMUuMRPfgk6sxD48a88z2MyxLpvUz+1Q6PufzKQuYHY1/F8dcWoCM1bvz+hcmVhDI1e8zuIjKoajZOftCxtQBlq6VUYuQp53eJU6+ngTcHxkdTACLQetkHnBAboeAboazZvYuFckXhcs3fwzcK22CB2LpjSIyp0b0GMDRDfaDL4VjkeWlMNcSXFFimQOPvMKFVHPQsXRxBSHIOa6hDoCerrWDY1/lzSphr4E2RRSwblW8Y2Ng==","i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777474515; cv=none;\n b=M0u7OJXKmhRVxufYNfR7qUlWw7iVxG7ocf1JyE4P//cU4Pz+Wz25HRla6ENYNybLwdo/DECSv8HozSP6hTehaa6w8qqY3TTTQKDNG6kuYrTaoUkjOE9dKR2HMpXq36GG9F8Q1gtuHkd6RXxIrhDhHy92VmUiJorfidSoaKjB0Qg="],"ARC-Message-Signature":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707;\n\tt=1777474525; c=relaxed/relaxed;\n\tbh=GQV61fBNNtcBKhJc0srbZC/9/am8hY8aqTOwUWGhQQI=;\n\th=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References:\n\t MIME-Version:Content-Type;\n b=QTMWZ5Dp+32QpNPBb7hGW1mYAQcm0eIgWAE11hSdQ1bk7lhAOY+T7vvchXb7XyVqUeewI9GspcrTW8p9HiaWup7zNdCpqaHLbwtetyToZBCw/l7GSkQKD1KtDdlZVoamNqRr17SWBD8tdo4A71tOU2o/RHphmzFfXgvTBgAHJ7jT7M4JpE+lfDTl/Y9Dex7PknJnOj5SsexPd+VwzweKUS4M/1wZZJB+wo7MQ+Ct7HJChhHbiJFy5YNXhk/MsCYi2SDtES/lcrrv2emiGvZSKkJ2lzDwr1qughW0xXmOJ5UruiSg+G289QIPqSlTrZ6o63/SUCLub1IHV9ShOpFwtQ==","i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777474515; c=relaxed/simple;\n\tbh=MeWH8mVd3Dj1CODKGWznPYE5sSmxPDPVVpQoWGL7Ia0=;\n\th=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References:\n\t MIME-Version:Content-Type;\n b=aDiK1SChl0ZpTduQdkLTCv4mxDwhgU6/1iav3oKij8pFdb4wWFKzzD79t05fCQlYJDF8o7165b6AUt7ccWkQzWJdJ4l4bOOrgcWfT0Z9CnihJ9rUdVw3IXsxs1tHKlqxdp7a5D8dJAFkA8NPUPn1ORGwCktuKmMSYiVUMSMEYtw="],"ARC-Authentication-Results":["i=2; gandalf.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=kernel.org;\n dkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=t1zX1Zox; dkim-atps=neutral;\n spf=pass (client-ip=172.232.135.74; helo=sto.lore.kernel.org;\n envelope-from=linux-ext4+bounces-16199-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org","i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=t1zX1Zox; arc=none smtp.client-ip=10.30.226.201"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1777474514;\n\tbh=MeWH8mVd3Dj1CODKGWznPYE5sSmxPDPVVpQoWGL7Ia0=;\n\th=Date:Subject:From:To:Cc:In-Reply-To:References:From;\n\tb=t1zX1ZoxViViulUYacUBw44s2Vd80V2ilmRq/uWLKpt8kCJ1TWRYNg3fr0tUVH0Jz\n\t EfbvlL7iSBzOsPtwD9d8iC17WtPQWbbKWMEE0q9rQdzwN2Mj5fhO4g2E5B2R93EDkl\n\t 6afout+pnryFoZYvEX26XgqfsEkCsCLxzD4GuHPntgfwARFchacItAzn4e5zk4Z4mq\n\t dlhojeq1gWgqLdbynqu2nUOU9Cc6JV2I70sVs2cEC/RN/CHG0yp9kHiibopZF3rjYu\n\t q4pwtG8wE8Q2b7rAqx1lLQ2GPfFOpB1fGasw3McOeGnKUEKWPZae/A72MF5DkTsONg\n\t chUcYKUggdusA==","Date":"Wed, 29 Apr 2026 07:55:14 -0700","Subject":"[PATCH 10/19] fuse2fs: don't do file data block IO when iomap is\n enabled","From":"\"Darrick J. Wong\" <djwong@kernel.org>","To":"tytso@mit.edu","Cc":"bernd@bsbernd.com, miklos@szeredi.hu, linux-ext4@vger.kernel.org,\n neal@gompa.dev, linux-fsdevel@vger.kernel.org, fuse-devel@lists.linux.dev,\n joannelkoong@gmail.com","Message-ID":"<177747214715.4107473.4460452026157984455.stgit@frogsfrogsfrogs>","In-Reply-To":"<177747214459.4107473.9520724883867588970.stgit@frogsfrogsfrogs>","References":"<177747214459.4107473.9520724883867588970.stgit@frogsfrogsfrogs>","Precedence":"bulk","X-Mailing-List":"linux-ext4@vger.kernel.org","List-Id":"<linux-ext4.vger.kernel.org>","List-Subscribe":"<mailto:linux-ext4+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-ext4+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","X-Spam-Status":"No, score=-1.2 required=5.0 tests=ARC_SIGNED,ARC_VALID,\n\tDKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,\n\tMAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled\n\tversion=4.0.1","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org"},"content":"From: Darrick J. Wong <djwong@kernel.org>\n\nWhen iomap is in use for the page cache, the kernel will take care of\nall the file data block IO for us, including zeroing of punched ranges\nand post-EOF bytes.  fuse2fs only needs to do IO for inline data.\n\nTherefore, set the NOBLOCKIO ext2_file flag so that libext2fs will not\ndo any regular file IO to or from disk blocks at all.\n\nSigned-off-by: \"Darrick J. Wong\" <djwong@kernel.org>\n---\n fuse4fs/fuse4fs.c |   11 +++++++-\n misc/fuse2fs.c    |   72 ++++++++++++++++++++++++++++++++++++++++++++++++++++-\n 2 files changed, 81 insertions(+), 2 deletions(-)","diff":"diff --git a/fuse4fs/fuse4fs.c b/fuse4fs/fuse4fs.c\nindex 40713b0d0d5e37..68f1f7c02df223 100644\n--- a/fuse4fs/fuse4fs.c\n+++ b/fuse4fs/fuse4fs.c\n@@ -3933,9 +3933,14 @@ static int fuse4fs_truncate(struct fuse4fs *ff, ext2_ino_t ino, off_t new_size)\n \text2_file_t file;\n \t__u64 old_isize;\n \terrcode_t err;\n+\tint flags = EXT2_FILE_WRITE;\n \tint ret = 0;\n \n-\terr = ext2fs_file_open(fs, ino, EXT2_FILE_WRITE, &file);\n+\t/* the kernel handles all eof zeroing for us in iomap mode */\n+\tif (fuse4fs_iomap_enabled(ff))\n+\t\tflags |= EXT2_FILE_NOBLOCKIO;\n+\n+\terr = ext2fs_file_open(fs, ino, flags, &file);\n \tif (err)\n \t\treturn translate_error(fs, ino, err);\n \n@@ -4030,6 +4035,10 @@ static int fuse4fs_open_file(struct fuse4fs *ff, const struct fuse_ctx *ctxt,\n \tif (linked)\n \t\tcheck |= L_OK;\n \n+\t/* the kernel handles all block IO for us in iomap mode */\n+\tif (fuse4fs_iomap_enabled(ff))\n+\t\tfile->open_flags |= EXT2_FILE_NOBLOCKIO;\n+\n \t/*\n \t * If the caller wants to truncate the file, we need to ask for full\n \t * write access even if the caller claims to be appending.\ndiff --git a/misc/fuse2fs.c b/misc/fuse2fs.c\nindex a37851cdf30785..f7653dc6c20c3f 100644\n--- a/misc/fuse2fs.c\n+++ b/misc/fuse2fs.c\n@@ -3463,15 +3463,72 @@ static int fuse2fs_punch_posteof(struct fuse2fs *ff, ext2_ino_t ino,\n \treturn 0;\n }\n \n+/*\n+ * Decide if file IO for this inode can use iomap.\n+ *\n+ * It turns out that libfuse creates internal node ids that have nothing to do\n+ * with the ext2_ino_t that we give it.  These internal node ids are what\n+ * actually gets igetted in the kernel, which means that there can be multiple\n+ * fuse_inode objects in the kernel for a single hardlinked ondisk ext2 inode.\n+ *\n+ * What this means, horrifyingly, is that on a fuse filesystem that supports\n+ * hard links, the in-kernel i_rwsem does not protect against concurrent writes\n+ * between files that point to the same inode.  That in turn means that the\n+ * file mode and size can get desynchronized between the multiple fuse_inode\n+ * objects.  This also means that we cannot cache iomaps in the kernel AT ALL\n+ * because the caches will get out of sync, leading to WARN_ONs from the iomap\n+ * zeroing code and probably data corruption after that.\n+ *\n+ * Therefore, libfuse won't let us create hardlinks of iomap files, and we must\n+ * never turn on iomap for existing hardlinked files.  Long term it means we\n+ * have to find a way around this loss of functionality.  fuse4fs gets around\n+ * this by being a low level fuse driver and controlling the nodeids itself.\n+ *\n+ * Returns 0 for no, 1 for yes, or a negative errno.\n+ */\n+#ifdef HAVE_FUSE_IOMAP\n+static int fuse2fs_file_uses_iomap(struct fuse2fs *ff, ext2_ino_t ino)\n+{\n+\tstruct stat statbuf;\n+\tint ret;\n+\n+\tif (!fuse2fs_iomap_enabled(ff))\n+\t\treturn 0;\n+\n+\tret = stat_inode(ff->fs, ino, &statbuf);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\t/* the kernel handles all block IO for us in iomap mode */\n+\treturn fuse_fs_can_enable_iomap(&statbuf);\n+}\n+#else\n+# define fuse2fs_file_uses_iomap(...)\t(0)\n+#endif\n+\n static int fuse2fs_truncate(struct fuse2fs *ff, ext2_ino_t ino, off_t new_size)\n {\n \text2_filsys fs = ff->fs;\n \text2_file_t file;\n \t__u64 old_isize;\n \terrcode_t err;\n+\tint flags = EXT2_FILE_WRITE;\n \tint ret = 0;\n \n-\terr = ext2fs_file_open(fs, ino, EXT2_FILE_WRITE, &file);\n+\t/* the kernel handles all eof zeroing for us in iomap mode */\n+\tret = fuse2fs_file_uses_iomap(ff, ino);\n+\tswitch (ret) {\n+\tcase 0:\n+\t\tbreak;\n+\tcase 1:\n+\t\tflags |= EXT2_FILE_NOBLOCKIO;\n+\t\tret = 0;\n+\t\tbreak;\n+\tdefault:\n+\t\treturn ret;\n+\t}\n+\n+\terr = ext2fs_file_open(fs, ino, flags, &file);\n \tif (err)\n \t\treturn translate_error(fs, ino, err);\n \n@@ -3626,6 +3683,19 @@ static int __op_open(struct fuse2fs *ff, const char *path,\n \t\t\tgoto out;\n \t}\n \n+\t/* the kernel handles all block IO for us in iomap mode */\n+\tret = fuse2fs_file_uses_iomap(ff, file->ino);\n+\tswitch (ret) {\n+\tcase 0:\n+\t\tbreak;\n+\tcase 1:\n+\t\tfile->open_flags |= EXT2_FILE_NOBLOCKIO;\n+\t\tret = 0;\n+\t\tbreak;\n+\tdefault:\n+\t\tgoto out;\n+\t}\n+\n \tif (fp->flags & O_TRUNC) {\n \t\tret = fuse2fs_truncate(ff, file->ino, 0);\n \t\tif (ret)\n","prefixes":["10/19"]}