Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support accessing .zfs/snapshot via NFS #2797

Closed
wants to merge 7 commits into from
Closed

Support accessing .zfs/snapshot via NFS #2797

wants to merge 7 commits into from

Commits on Feb 12, 2015

  1. Set MNT_SHRINKABLE on snapshot mount

    We could set MNT_SHRINKABLE when mouting snapshot mount instead of using
    occasional post mount getattr.
    
    Signed-off-by: Andrey Vesnovaty <andrey.vesnovaty@gmail.com>
    Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
    andrey-ve authored and yshui committed Feb 12, 2015
    Configuration menu
    Copy the full SHA
    c9e1346 View commit details
    Browse the repository at this point in the history
  2. Fix invalid fileid for snapshot root dentry

    Prevents NFS client from detection of different fileids of snapshot root dentry
    before & after snapshot mount.
    
    Signed-off-by: Andrey Vesnovaty <andrey.vesnovaty@gmail.com>
    andrey-ve authored and yshui committed Feb 12, 2015
    Configuration menu
    Copy the full SHA
    c7f3a6a View commit details
    Browse the repository at this point in the history
  3. zfsctl: No need to sync ctldir inodes

    There's no metadata to write to disk for ctldir inodes. So we check if
    a inode belongs to the ctldir in zpl_commit_metadata, and returns
    immediately if it is.
    
    Signed-off-by: Andrey Vesnovaty <andrey.vesnovaty@gmail.com>
    andrey-ve authored and yshui committed Feb 12, 2015
    Configuration menu
    Copy the full SHA
    c373c76 View commit details
    Browse the repository at this point in the history
  4. Save snapshot root dentry on snapshot mount

    When it's need to decode snapshot file handly it hard to get snapshot sb.
    On the contrary on snapshot mount it's easy to get snapshot sb because
    mount path available in the context of snapshot mount.
    
    Signed-off-by: Andrey Vesnovaty <andrey.vesnovaty@gmail.com>
    andrey-ve authored and yshui committed Feb 12, 2015
    Configuration menu
    Copy the full SHA
    9c03a22 View commit details
    Browse the repository at this point in the history
  5. Ensure long fids is used for snapshot

    We have to use long fids to include the dataset id.
    
    Signed-off-by: Andrey Vesnovaty <andrey.vesnovaty@gmail.com>
    andrey-ve authored and yshui committed Feb 12, 2015
    Configuration menu
    Copy the full SHA
    e46013a View commit details
    Browse the repository at this point in the history

Commits on Feb 16, 2015

  1. Add helper function to get mount path of a dataset

    This will be used in later commit which add support for decoding
    snapshot fh. This is needed because in case the snapshot is not mounted
    when decoding its fh, we have to trigger an automount. And to trigger a
    snapshot automount, we have to know its path.
    
    In this commit we add a helper function which get the mount path from
    zpool and dataset properties (namely altroot and mountpoint
    properties). This is practically the same method used by the userspace
    zfs commandline tool. This method won't work for dataset with 'legacy'
    mountpoint, but we have to do it this way because newer Linux
    kernel hides the mount point information from file systems.
    
    Theoretically the proper solution of the problem is to eliminate the
    need to mount a snapshot, and just generate all snapshot related information
    on access. However this will require a lot more work and probably
    significant changes to how zfs handle snapshots. So I think we better
    leave this for later.
    
    Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
    yshui authored and jjoy-zz committed Feb 16, 2015
    Configuration menu
    Copy the full SHA
    2a8749a View commit details
    Browse the repository at this point in the history
  2. Add encode and decode support for snapshot fh

    The snapshot file handle should provide enough info in order to get the right
    objsetid and right object in the objset defined by objsetid. Therefore
    we encode the snapshot fh as objsetid + inode.
    
    The objsetid should be encoded for every snapshot dentry including root dentry;
    for snapshot root dentry zf_gen should be 0.
    
    To decode a snapshot fh, we simply extract the objsetid and the inode,
    then we try to retrive the super block stored in the snapentry. Zero matching
    snapentry means the snapshot is not mounted. In this case we try to
    trigger a automount of the snapshot by doing a path lookup on the full
    snapshot path, and then try again.
    
    If zf_gen is 0, we return the snapshot root dentry.
    
    Also added a configure check for kern_path, since it is not available
    in earlier kernels.
    
    Signed-off-by: Andrey Vesnovaty <andrey.vesnovaty@gmail.com>
    Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
    andrey-ve authored and jjoy-zz committed Feb 16, 2015
    Configuration menu
    Copy the full SHA
    4bdaed0 View commit details
    Browse the repository at this point in the history