[PATCH 12/19] fuse2fs: enable file IO to inline data files

Darrick J. Wong
2026-04-29T14:55:46Z

Enable file reads and writes from inline data files.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
fuse4fs/fuse4fs.c | 3 ++-
misc/fuse2fs.c | 42 ++++++++++++++++++++++++++++++++++++++++--
2 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/fuse4fs/fuse4fs.c b/fuse4fs/fuse4fs.c
index 3c3debb6f60ac7..e2421dda75475a 100644
--- a/fuse4fs/fuse4fs.c
+++ b/fuse4fs/fuse4fs.c
@@ -6566,7 +6566,8 @@ static int fuse4fs_iomap_begin_read(struct fuse4fs *ff, ext2_ino_t ino,
{
/* fall back to slow path for inline data reads */
if (inode->i_flags & EXT4_INLINE_DATA_FL)
- return -ENOSYS;
+ return fuse4fs_iomap_begin_inline(ff, ino, inode, pos, count,
+ read);

if (inode->i_flags & EXT4_EXTENTS_FL)
return fuse4fs_iomap_begin_extent(ff, ino, inode, pos, count,
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 3c76eba683a10d..eecbf60a3360c6 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -1846,7 +1846,16 @@ static void *op_init(struct fuse_conn_info *conn,
cfg->use_ino = 1;
if (ff->debug)
cfg->debug = 1;
- cfg->nullpath_ok = 1;
+
+ /*
+ * Inline data file io depends on op_read/write being fed a path, so we
+ * have to slow everyone down to look up the path from the nodeid.
+ */
+ if (fuse2fs_iomap_enabled(ff) &&
+ ext2fs_has_feature_inline_data(ff->fs->super))
+ cfg->nullpath_ok = 0;
+ else
+ cfg->nullpath_ok = 1;

fuse2fs_detach_losetup(ff);

@@ -3840,6 +3849,9 @@ static int op_read(const char *path EXT2FS_ATTR((unused)), char *buf,
size_t len, off_t offset,
struct fuse_file_info *fp)
{
+ struct fuse2fs_file_handle fhurk = {
+ .magic = FUSE2FS_FILE_MAGIC,
+ };
struct fuse2fs *ff = fuse2fs_get();
struct fuse2fs_file_handle *fh = fuse2fs_get_handle(fp);
ext2_filsys fs;
@@ -3849,10 +3861,21 @@ static int op_read(const char *path EXT2FS_ATTR((unused)), char *buf,
int ret = 0;

FUSE2FS_CHECK_CONTEXT(ff);
+
+ if (!fh)
+ fh = &fhurk;
+
FUSE2FS_CHECK_HANDLE(ff, fh);
dbg_printf(ff, "%s: ino=%d off=0x%llx len=0x%zx\n", __func__, fh->ino,
(unsigned long long)offset, len);
fs = fuse2fs_start(ff);
+
+ if (fh == &fhurk) {
+ ret = fuse2fs_file_ino(ff, path, NULL, &fhurk.ino);
+ if (ret)
+ goto out;
+ }
+
err = ext2fs_file_open(fs, fh->ino, fh->open_flags, &efp);
if (err) {
ret = translate_error(fs, fh->ino, err);
@@ -3894,6 +3917,10 @@ static int op_write(const char *path EXT2FS_ATTR((unused)),
const char *buf, size_t len, off_t offset,
struct fuse_file_info *fp)
{
+ struct fuse2fs_file_handle fhurk = {
+ .magic = FUSE2FS_FILE_MAGIC,
+ .open_flags = EXT2_FILE_WRITE,
+ };
struct fuse2fs *ff = fuse2fs_get();
struct fuse2fs_file_handle *fh = fuse2fs_get_handle(fp);
ext2_filsys fs;
@@ -3903,6 +3930,10 @@ static int op_write(const char *path EXT2FS_ATTR((unused)),
int ret = 0;

FUSE2FS_CHECK_CONTEXT(ff);
+
+ if (!fh)
+ fh = &fhurk;
+
FUSE2FS_CHECK_HANDLE(ff, fh);
dbg_printf(ff, "%s: ino=%d off=0x%llx len=0x%zx\n", __func__, fh->ino,
(unsigned long long) offset, len);
@@ -3917,6 +3948,12 @@ static int op_write(const char *path EXT2FS_ATTR((unused)),
goto out;
}

+ if (fh == &fhurk) {
+ ret = fuse2fs_file_ino(ff, path, NULL, &fhurk.ino);
+ if (ret)
+ goto out;
+ }
+
err = ext2fs_file_open(fs, fh->ino, fh->open_flags, &efp);
if (err) {
ret = translate_error(fs, fh->ino, err);
@@ -5860,7 +5897,8 @@ static int fuse2fs_iomap_begin_read(struct fuse2fs *ff, ext2_ino_t ino,
{
/* fall back to slow path for inline data reads */
if (inode->i_flags & EXT4_INLINE_DATA_FL)
- return -ENOSYS;
+ return fuse2fs_iomap_begin_inline(ff, ino, inode, pos, count,
+ read);

if (inode->i_flags & EXT4_EXTENTS_FL)
return fuse2fs_iomap_begin_extent(ff, ino, inode, pos, count,