git: sys/kern: Add struct file* arg to VOP_{GETATTR, SETATTR, READ, WRITE, FSYNC, READDIR}

Tomohiro Kusumi tkusumi at crater.dragonflybsd.org
Sun Mar 31 10:04:29 PDT 2019


commit 2dfa19fa300df7648d9bf56b69c2cfd345882046
Author: Tomohiro Kusumi <kusumi.tomohiro at gmail.com>
Date:   Mon Apr 1 01:30:07 2019 +0900

    sys/kern: Add struct file* arg to VOP_{GETATTR,SETATTR,READ,WRITE,FSYNC,READDIR}
    
    This commit changes VOP interface to support FUSE API/ABI.
    It just adds an additional struct file* argument to VOP's, so that
    FUSE VOP's can access *fp pointer (currently accessible only from
    caller of VOP's if any, with exception of VOP_OPEN(), VOP_CLOSE(),
    etc) and make use of its ->private_data pointer.
    
    FUSE API/ABI requires FUSE to maintain a per file (usually per file
    descriptor) data called fh. The fh is an opaque data whose purpose
    may differ among userspace filesystems, but typically used to store
    file descriptor value or arbitrary userspace address used by the
    userspace filesystem process.
    
    Below diagram illustrates typical flow of maintaining fh. The
    userspace filesystem uses fd obtained from opening backing store
    (e.g fd for regular file, socket, etc) for fh, as a consequence of
    end user's open(2) syscall, and expects FUSE to maintain that value
    for future use as an identifier for userspace.
    
    * Notes on Linux VFS I/F vs BSD VFS I/F:
    In Linux, supporting the concept of fh is quite straight forward since
    Linux kernel has functions vector built around (opened)file including
    things like mmap(2) handler, in addition to a vector built around
    inode.
    
    But since DragonFly doesn't have a vector built around file (other
    than a simple struct fileops, which doesn't meet requirements of fh),
    this change was needed for selected VOP's as minimum requirements
    for initial FUSE API/ABI support.
    
    --
    FUSE user                  FUSE                       FUSE userspace fs
    |                          |                          |
    |---------open(2)--------->|                          |
    | * issue VOP_OPEN         |---------VOP_OPEN-------->|
    |                          | * issue FUSE_OPEN        | * open something
    |                          |                          | * reply fd as fh
    |                          |<--------VOP_OPEN---------|
    |<--------open(2)----------| * store fh in fp         |
    | * open success           |                          |
    |                          |                          |
    |...                       |                          |
    |...                       |                          |
    |                          |                          |
    |---------read(2)--------->|                          |
    | * issue VOP_READ         |---------VOP_READ-------->|
    |                          | * issue FUSE_READ        |
    |                          |   with fh from fp        | * read something
    |                          |                          |   using fh for fd
    |                          |<--------VOP_READ---------|
    |<--------read(2)----------| * return read bytes      |
    | * uiomove() success      |                          |
    |                          |                          |

Summary of changes:
 sys/kern/kern_fp.c       |  2 +-
 sys/kern/uipc_syscalls.c |  4 ++--
 sys/kern/vfs_syscalls.c  | 12 ++++++------
 sys/kern/vfs_vnops.c     |  6 +++---
 sys/kern/vfs_vopops.c    | 21 +++++++++++++++------
 sys/sys/vfsops.h         | 44 ++++++++++++++++++++++++++++++++------------
 6 files changed, 59 insertions(+), 30 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/2dfa19fa300df7648d9bf56b69c2cfd345882046


-- 
DragonFly BSD source repository


More information about the Commits mailing list