From: Darrick J. Wong <djwong@xxxxxxxxxx> Enable file reads and writes from inline data files. Signed-off-by: "Darrick J. Wong" <djwong@xxxxxxxxxx> --- misc/fuse2fs.c | 42 ++++++++++++++++++++++++++++++++++++++++-- misc/fuse4fs.c | 3 ++- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 97b010b8dc1055..fc83d2d21c600b 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -1472,7 +1472,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; #endif if (ff->kernel) { @@ -3427,6 +3436,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; @@ -3436,10 +3448,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); @@ -3481,6 +3504,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; @@ -3490,6 +3517,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); @@ -3504,6 +3535,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); @@ -5511,7 +5548,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, diff --git a/misc/fuse4fs.c b/misc/fuse4fs.c index 3bb6140b35570e..6de9f69d05de0b 100644 --- a/misc/fuse4fs.c +++ b/misc/fuse4fs.c @@ -5857,7 +5857,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,