lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJnrk1ZDeYytdjuCdg6-O-PGjcmwS33LOnfFT_YY9SPE=x=Qxw@mail.gmail.com>
Date: Wed, 21 Jan 2026 17:13:39 -0800
From: Joanne Koong <joannelkoong@...il.com>
To: "Darrick J. Wong" <djwong@...nel.org>
Cc: miklos@...redi.hu, bernd@...ernd.com, neal@...pa.dev, 
	linux-ext4@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH 07/31] fuse: create a per-inode flag for toggling iomap

On Tue, Oct 28, 2025 at 5:46 PM Darrick J. Wong <djwong@...nel.org> wrote:
>
> From: Darrick J. Wong <djwong@...nel.org>
>
> Create a per-inode flag to control whether or not this inode actually
> uses iomap.  This is required for non-regular files because iomap
> doesn't apply there; and enables fuse filesystems to provide some
> non-iomap files if desired.
>
> Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>

The logic in this makes sense to me, left just a few comments below.

Reviewed-by: Joanne Koong <joannelkoong@...il.com>

> ---
>  fs/fuse/fuse_i.h          |   17 ++++++++++++++++
>  include/uapi/linux/fuse.h |    3 +++
>  fs/fuse/file.c            |    1 +
>  fs/fuse/file_iomap.c      |   49 +++++++++++++++++++++++++++++++++++++++++++++
>  fs/fuse/inode.c           |   26 ++++++++++++++++++------
>  5 files changed, 90 insertions(+), 6 deletions(-)
>
>
> diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
> index 839d4f2ada4656..c7aeb324fe599e 100644
> --- a/fs/fuse/fuse_i.h
> +++ b/fs/fuse/fuse_i.h
> @@ -257,6 +257,8 @@ enum {
>          * or the fuse server has an exclusive "lease" on distributed fs
>          */
>         FUSE_I_EXCLUSIVE,
> +       /* Use iomap for this inode */
> +       FUSE_I_IOMAP,
>  };
>
>  struct fuse_conn;
> @@ -1717,11 +1719,26 @@ extern const struct fuse_backing_ops fuse_iomap_backing_ops;
>
>  void fuse_iomap_mount(struct fuse_mount *fm);
>  void fuse_iomap_unmount(struct fuse_mount *fm);
> +
> +void fuse_iomap_init_reg_inode(struct inode *inode, unsigned attr_flags);
> +void fuse_iomap_init_nonreg_inode(struct inode *inode, unsigned attr_flags);
> +void fuse_iomap_evict_inode(struct inode *inode);
> +
> +static inline bool fuse_inode_has_iomap(const struct inode *inode)
> +{
> +       const struct fuse_inode *fi = get_fuse_inode(inode);
> +
> +       return test_bit(FUSE_I_IOMAP, &fi->state);
> +}
>  #else
>  # define fuse_iomap_enabled(...)               (false)
>  # define fuse_has_iomap(...)                   (false)
>  # define fuse_iomap_mount(...)                 ((void)0)
>  # define fuse_iomap_unmount(...)               ((void)0)
> +# define fuse_iomap_init_reg_inode(...)                ((void)0)
> +# define fuse_iomap_init_nonreg_inode(...)     ((void)0)
> +# define fuse_iomap_evict_inode(...)           ((void)0)
> +# define fuse_inode_has_iomap(...)             (false)
>  #endif
>
>  #endif /* _FS_FUSE_I_H */
> diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
> index e571f8ceecbfad..e949bfe022c3b0 100644
> --- a/include/uapi/linux/fuse.h
> +++ b/include/uapi/linux/fuse.h
> @@ -243,6 +243,7 @@
>   *
>   *  7.99
>   *  - add FUSE_IOMAP and iomap_{begin,end,ioend} for regular file operations
> + *  - add FUSE_ATTR_IOMAP to enable iomap for specific inodes
>   */
>
>  #ifndef _LINUX_FUSE_H
> @@ -583,9 +584,11 @@ struct fuse_file_lock {
>   *
>   * FUSE_ATTR_SUBMOUNT: Object is a submount root
>   * FUSE_ATTR_DAX: Enable DAX for this file in per inode DAX mode
> + * FUSE_ATTR_IOMAP: Use iomap for this inode
>   */
>  #define FUSE_ATTR_SUBMOUNT      (1 << 0)
>  #define FUSE_ATTR_DAX          (1 << 1)
> +#define FUSE_ATTR_IOMAP                (1 << 2)
>
>  /**
>   * Open flags
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index f1ef77a0be05bb..42c85c19f3b13b 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -3135,6 +3135,7 @@ void fuse_init_file_inode(struct inode *inode, unsigned int flags)
>         init_waitqueue_head(&fi->page_waitq);
>         init_waitqueue_head(&fi->direct_io_waitq);
>
> +       fuse_iomap_init_reg_inode(inode, flags);

imo it's a bit confusing to have this here when the rest of the
fuse_iomap_init_nonreg_inode() calls happen inside the switch case
statement. Maybe it makes sense to have this inside the switch case
like the fuse_iomap_init_nonreg_inode() calls, or alternatively move
the fuse_iomap_init_nonreg_inode() calls into their corresponding
helpers (eg fuse_init_dir(), etc.), so that it's consistent?

>         if (IS_ENABLED(CONFIG_FUSE_DAX))
>                 fuse_dax_inode_init(inode, flags);
>  }
> diff --git a/fs/fuse/file_iomap.c b/fs/fuse/file_iomap.c
> index 1b9e1bf2f799a3..fc0d5f135bacf9 100644
> --- a/fs/fuse/file_iomap.c
> +++ b/fs/fuse/file_iomap.c
> @@ -635,3 +635,52 @@ void fuse_iomap_unmount(struct fuse_mount *fm)
>         fuse_flush_requests_and_wait(fc);
>         fuse_send_destroy(fm);
>  }
> +
> +static inline void fuse_inode_set_iomap(struct inode *inode)
> +{
> +       struct fuse_inode *fi = get_fuse_inode(inode);
> +
> +       set_bit(FUSE_I_IOMAP, &fi->state);
> +}
> +
> +static inline void fuse_inode_clear_iomap(struct inode *inode)
> +{
> +       struct fuse_inode *fi = get_fuse_inode(inode);
> +
> +       clear_bit(FUSE_I_IOMAP, &fi->state);
> +}
> +
> +void fuse_iomap_init_nonreg_inode(struct inode *inode, unsigned attr_flags)
> +{
> +       struct fuse_conn *conn = get_fuse_conn(inode);
> +       struct fuse_inode *fi = get_fuse_inode(inode);
> +
> +       ASSERT(!S_ISREG(inode->i_mode));
> +
> +       if (conn->iomap && (attr_flags & FUSE_ATTR_IOMAP))
> +               set_bit(FUSE_I_EXCLUSIVE, &fi->state);
> +}
> +
> +void fuse_iomap_init_reg_inode(struct inode *inode, unsigned attr_flags)
> +{
> +       struct fuse_conn *conn = get_fuse_conn(inode);
> +       struct fuse_inode *fi = get_fuse_inode(inode);
> +
> +       ASSERT(S_ISREG(inode->i_mode));
> +
> +       if (conn->iomap && (attr_flags & FUSE_ATTR_IOMAP)) {
> +               set_bit(FUSE_I_EXCLUSIVE, &fi->state);
> +               fuse_inode_set_iomap(inode);
> +       }
> +}
> +
> +void fuse_iomap_evict_inode(struct inode *inode)
> +{
> +       struct fuse_conn *conn = get_fuse_conn(inode);
> +       struct fuse_inode *fi = get_fuse_inode(inode);
> +
> +       if (fuse_inode_has_iomap(inode))

If I'm understanding this correctly, a fuse inode can't have
FUSE_I_IOMAP set on it if conn>iomap is not enabled, correct? Maybe it
makes sense to just return if (!conn->iomap) at the very beginning, to
make that more clear?

> +               fuse_inode_clear_iomap(inode);
> +       if (conn->iomap && fuse_inode_is_exclusive(inode))
> +               clear_bit(FUSE_I_EXCLUSIVE, &fi->state);
> +}
> diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
> index 271356fa3be3ea..9b9e7b2dd0d928 100644
> --- a/fs/fuse/inode.c
> +++ b/fs/fuse/inode.c
> @@ -196,6 +196,8 @@ static void fuse_evict_inode(struct inode *inode)
>                 WARN_ON(!list_empty(&fi->write_files));
>                 WARN_ON(!list_empty(&fi->queued_writes));
>         }
> +
> +       fuse_iomap_evict_inode(inode);
>  }
>
>  static int fuse_reconfigure(struct fs_context *fsc)
> @@ -428,20 +430,32 @@ static void fuse_init_inode(struct inode *inode, struct fuse_attr *attr,
>         inode->i_size = attr->size;
>         inode_set_mtime(inode, attr->mtime, attr->mtimensec);
>         inode_set_ctime(inode, attr->ctime, attr->ctimensec);
> -       if (S_ISREG(inode->i_mode)) {
> +       switch (inode->i_mode & S_IFMT) {
> +       case S_IFREG:
>                 fuse_init_common(inode);
>                 fuse_init_file_inode(inode, attr->flags);
> -       } else if (S_ISDIR(inode->i_mode))
> +               break;
> +       case S_IFDIR:
>                 fuse_init_dir(inode);
> -       else if (S_ISLNK(inode->i_mode))
> +               fuse_iomap_init_nonreg_inode(inode, attr->flags);
> +               break;
> +       case S_IFLNK:
>                 fuse_init_symlink(inode);
> -       else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
> -                S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
> +               fuse_iomap_init_nonreg_inode(inode, attr->flags);
> +               break;
> +       case S_IFCHR:
> +       case S_IFBLK:
> +       case S_IFIFO:
> +       case S_IFSOCK:
>                 fuse_init_common(inode);
>                 init_special_inode(inode, inode->i_mode,
>                                    new_decode_dev(attr->rdev));
> -       } else
> +               fuse_iomap_init_nonreg_inode(inode, attr->flags);
> +               break;
> +       default:
>                 BUG();

Just thinking out loud here and curious to hear whether you like this
idea or not: another option is calling

if (conn->iomap)
    fuse_iomap_init_inode();

at the end, where fuse_iomap_init_inode() would be something like:

void fuse_iomap_init_inode(struct inode *inode, unsigned attr_flags)
{
    struct fuse_inode *fi = get_fuse_inode(inode);

    if (attr_flags & FUSE_ATTR_IOMAP)
          set_bit(FUSE_I_EXCLUSIVE, &fi->state);

    if (S_ISREG(inode->i_mode))
            fuse_inode_set_iomap(inode);
}

which seems simpler to me than having both
fuse_iomap_init_nonreg_inode() and fuse_iomap_init_reg_inode()
function and invoking it per i_mode case.

Thanks,
Joanne

> +               break;
> +       }
>         /*
>          * Ensure that we don't cache acls for daemons without FUSE_POSIX_ACL
>          * so they see the exact same behavior as before.
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ