X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=include%2Fsys%2Fzfs_ctldir.h;h=1ff23a298856dbae7afbd7dd44fb07ead86399f4;hb=556011dbec2d10579819078559a77630fc559112;hp=f88ef95fdca871fc6f864bdfe76725866b4346df;hpb=6283f55ea1b91e680386388c17d14b89e344fa8d;p=zfs.git diff --git a/include/sys/zfs_ctldir.h b/include/sys/zfs_ctldir.h index f88ef95..1ff23a2 100644 --- a/include/sys/zfs_ctldir.h +++ b/include/sys/zfs_ctldir.h @@ -20,54 +20,94 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (C) 2011 Lawrence Livermore National Security, LLC. + * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). + * LLNL-CODE-403049. + * Rewritten for Linux by: + * Rohan Puri + * Brian Behlendorf */ #ifndef _ZFS_CTLDIR_H #define _ZFS_CTLDIR_H -#include #include #include #include -#ifdef __cplusplus -extern "C" { -#endif - #define ZFS_CTLDIR_NAME ".zfs" +#define ZFS_SNAPDIR_NAME "snapshot" +#define ZFS_SHAREDIR_NAME "shares" #define zfs_has_ctldir(zdp) \ - ((zdp)->z_id == (zdp)->z_zfsvfs->z_root && \ - ((zdp)->z_zfsvfs->z_ctldir != NULL)) + ((zdp)->z_id == ZTOZSB(zdp)->z_root && \ + (ZTOZSB(zdp)->z_ctldir != NULL)) #define zfs_show_ctldir(zdp) \ (zfs_has_ctldir(zdp) && \ - ((zdp)->z_zfsvfs->z_show_ctldir)) + (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; + +/* 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 int zfsctl_fid(struct inode *ip, fid_t *fidp); -void zfsctl_create(zfsvfs_t *); -void zfsctl_destroy(zfsvfs_t *); -vnode_t *zfsctl_root(znode_t *); -void zfsctl_init(void); -void zfsctl_fini(void); -boolean_t zfsctl_is_node(vnode_t *); +/* zfsctl '.zfs' functions */ +extern int zfsctl_root_lookup(struct inode *dip, char *name, + struct inode **ipp, int flags, cred_t *cr, int *direntflags, + pathname_t *realpnp); -int zfsctl_rename_snapshot(const char *from, const char *to); -int zfsctl_destroy_snapshot(const char *snapname, int force); -int zfsctl_umount_snapshots(vfs_t *, int, cred_t *); +/* zfsctl '.zfs/snapshot' functions */ +extern int zfsctl_snapdir_lookup(struct inode *dip, char *name, + struct inode **ipp, int flags, cred_t *cr, int *direntflags, + pathname_t *realpnp); +extern int zfsctl_snapdir_rename(struct inode *sdip, char *sname, + struct inode *tdip, char *tname, cred_t *cr, int flags); +extern int zfsctl_snapdir_remove(struct inode *dip, char *name, cred_t *cr, + int flags); +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_lookup_objset(struct super_block *sb, uint64_t objsetid, + zfs_sb_t **zsb); -int zfsctl_root_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, pathname_t *pnp, - int flags, vnode_t *rdir, cred_t *cr, caller_context_t *ct, - int *direntflags, pathname_t *realpnp); +/* zfsctl '.zfs/shares' functions */ +extern int zfsctl_shares_lookup(struct inode *dip, char *name, + struct inode **ipp, int flags, cred_t *cr, int *direntflags, + pathname_t *realpnp); -int zfsctl_make_fid(zfsvfs_t *zfsvfsp, uint64_t object, uint32_t gen, - fid_t *fidp); -int zfsctl_lookup_objset(vfs_t *vfsp, uint64_t objsetid, zfsvfs_t **zfsvfsp); +/* zfsctl_init/fini functions */ +extern void zfsctl_init(void); +extern void zfsctl_fini(void); -#define ZFSCTL_INO_ROOT 0x1 -#define ZFSCTL_INO_SNAPDIR 0x2 -#define ZFSCTL_INO_SHARES 0x3 +/* + * These inodes numbers are reserved for the .zfs control directory. + * It is important that they be no larger that 48-bits because only + * 6 bytes are reserved in the NFS file handle for the object number. + * However, they should be as large as possible to avoid conflicts + * with the objects which are assigned monotonically by the dmu. + */ +#define ZFSCTL_INO_ROOT 0x0000FFFFFFFFFFFFULL +#define ZFSCTL_INO_SHARES 0x0000FFFFFFFFFFFEULL +#define ZFSCTL_INO_SNAPDIR 0x0000FFFFFFFFFFFDULL +#define ZFSCTL_INO_SNAPDIRS 0x0000FFFFFFFFFFFCULL -#ifdef __cplusplus -} -#endif +#define ZFSCTL_EXPIRE_SNAPSHOT 300 #endif /* _ZFS_CTLDIR_H */