• Chuck Lever's avatar
    shmem: stable directory offsets · a2e45955
    Chuck Lever authored
    The current cursor-based directory offset mechanism doesn't work
    when a tmpfs filesystem is exported via NFS. This is because NFS
    clients do not open directories. Each server-side READDIR operation
    has to open the directory, read it, then close it. The cursor state
    for that directory, being associated strictly with the opened
    struct file, is thus discarded after each NFS READDIR operation.
    
    Directory offsets are cached not only by NFS clients, but also by
    user space libraries on those clients. Essentially there is no way
    to invalidate those caches when directory offsets have changed on
    an NFS server after the offset-to-dentry mapping changes. Thus the
    whole application stack depends on unchanging directory offsets.
    
    The solution we've come up with is to make the directory offset for
    each file in a tmpfs filesystem stable for the life of the directory
    entry it represents.
    
    shmem_readdir() and shmem_dir_llseek() now use an xarray to map each
    directory offset (an loff_t integer) to the memory address of a
    struct dentry.
    Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
    Message-Id: <168814734331.530310.3911190551060453102.stgit@manet.1015granger.net>
    Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
    a2e45955
shmem.c 125 KB