diff options
author | Brian Behlendorf <[email protected]> | 2015-04-24 16:21:13 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2015-08-31 13:54:39 -0700 |
commit | 278bee9319ba5947b995673d2c76e0333f2d33d4 (patch) | |
tree | a621142a2d5314b460cbf1a8bc6b6092f7a46424 /include/sys/zfs_ctldir.h | |
parent | b23975cbe0f249671c131b0d6e4ae1bb10594440 (diff) |
Linux 3.18 compat: Snapshot auto-mounting
Re-factor the .zfs/snapshot auto-mouting code to take in to account
changes made to the upstream kernels. And to lay the groundwork for
enabling access to .zfs snapshots via NFS clients. This patch makes
the following core improvements.
* All actively auto-mounted snapshots are now tracked in two global
trees which are indexed by snapshot name and objset id respectively.
This allows for fast lookups of any auto-mounted snapshot regardless
without needing access to the parent dataset.
* Snapshot entries are added to the tree in zfsctl_snapshot_mount().
However, they are now removed from the tree in the context of the
unmount process. This eliminates the need complicated error logic
in zfsctl_snapshot_unmount() to handle unmount failures.
* References are now taken on the snapshot entries in the tree to
ensure they always remain valid while a task is outstanding.
* The MNT_SHRINKABLE flag is set on the snapshot vfsmount_t right
after the auto-mount succeeds. This allows to kernel to unmount
idle auto-mounted snapshots if needed removing the need for the
zfsctl_unmount_snapshots() function.
* Snapshots in active use will not be automatically unmounted. As
long as at least one dentry is revalidated every zfs_expire_snapshot/2
seconds the auto-unmount expiration timer will be extended.
* Commit torvalds/linux@bafc9b7 caused snapshots auto-mounted by ZFS
to be immediately unmounted when the dentry was revalidated. This
was a consequence of ZFS invaliding all snapdir dentries to ensure that
negative dentries didn't mask new snapshots. This patch modifies the
behavior such that only negative dentries are invalidated. This solves
the issue and may result in a performance improvement.
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #3589
Closes #3344
Closes #3295
Closes #3257
Closes #3243
Closes #3030
Closes #2841
Diffstat (limited to 'include/sys/zfs_ctldir.h')
-rw-r--r-- | include/sys/zfs_ctldir.h | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/include/sys/zfs_ctldir.h b/include/sys/zfs_ctldir.h index 1ff23a298..960a9a629 100644 --- a/include/sys/zfs_ctldir.h +++ b/include/sys/zfs_ctldir.h @@ -32,6 +32,7 @@ #define _ZFS_CTLDIR_H #include <sys/vnode.h> +#include <sys/pathname.h> #include <sys/zfs_vfsops.h> #include <sys/zfs_znode.h> @@ -46,23 +47,16 @@ (zfs_has_ctldir(zdp) && \ (ZTOZSB(zdp)->z_show_ctldir)) -typedef struct { - char *se_name; - char *se_path; - struct inode *se_inode; - taskqid_t se_taskqid; - avl_node_t se_node; -} zfs_snapentry_t; +extern int zfs_expire_snapshot; /* zfsctl generic functions */ -extern int snapentry_compare(const void *a, const void *b); -extern boolean_t zfsctl_is_node(struct inode *ip); -extern boolean_t zfsctl_is_snapdir(struct inode *ip); -extern void zfsctl_inode_inactive(struct inode *ip); -extern void zfsctl_inode_destroy(struct inode *ip); extern int zfsctl_create(zfs_sb_t *zsb); extern void zfsctl_destroy(zfs_sb_t *zsb); extern struct inode *zfsctl_root(znode_t *zp); +extern void zfsctl_init(void); +extern void zfsctl_fini(void); +extern boolean_t zfsctl_is_node(struct inode *ip); +extern boolean_t zfsctl_is_snapdir(struct inode *ip); extern int zfsctl_fid(struct inode *ip, fid_t *fidp); /* zfsctl '.zfs' functions */ @@ -81,9 +75,9 @@ extern int zfsctl_snapdir_remove(struct inode *dip, char *name, cred_t *cr, extern int zfsctl_snapdir_mkdir(struct inode *dip, char *dirname, vattr_t *vap, struct inode **ipp, cred_t *cr, int flags); extern void zfsctl_snapdir_inactive(struct inode *ip); -extern int zfsctl_unmount_snapshot(zfs_sb_t *zsb, char *name, int flags); -extern int zfsctl_unmount_snapshots(zfs_sb_t *zsb, int flags, int *count); -extern int zfsctl_mount_snapshot(struct path *path, int flags); +extern int zfsctl_snapshot_mount(struct path *path, int flags); +extern int zfsctl_snapshot_unmount(char *snapname, int flags); +extern int zfsctl_snapshot_unmount_delay(uint64_t objsetid, int delay); extern int zfsctl_lookup_objset(struct super_block *sb, uint64_t objsetid, zfs_sb_t **zsb); @@ -92,10 +86,6 @@ extern int zfsctl_shares_lookup(struct inode *dip, char *name, struct inode **ipp, int flags, cred_t *cr, int *direntflags, pathname_t *realpnp); -/* zfsctl_init/fini functions */ -extern void zfsctl_init(void); -extern void zfsctl_fini(void); - /* * These inodes numbers are reserved for the .zfs control directory. * It is important that they be no larger that 48-bits because only |