]> git.proxmox.com Git - mirror_zfs.git/blob - include/sys/zfs_ctldir.h
Add visibility in to cached dbufs
[mirror_zfs.git] / include / sys / zfs_ctldir.h
1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (C) 2011 Lawrence Livermore National Security, LLC.
24 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
25 * LLNL-CODE-403049.
26 * Rewritten for Linux by:
27 * Rohan Puri <rohan.puri15@gmail.com>
28 * Brian Behlendorf <behlendorf1@llnl.gov>
29 */
30
31 #ifndef _ZFS_CTLDIR_H
32 #define _ZFS_CTLDIR_H
33
34 #include <sys/vnode.h>
35 #include <sys/zfs_vfsops.h>
36 #include <sys/zfs_znode.h>
37
38 #define ZFS_CTLDIR_NAME ".zfs"
39 #define ZFS_SNAPDIR_NAME "snapshot"
40 #define ZFS_SHAREDIR_NAME "shares"
41
42 #define zfs_has_ctldir(zdp) \
43 ((zdp)->z_id == ZTOZSB(zdp)->z_root && \
44 (ZTOZSB(zdp)->z_ctldir != NULL))
45 #define zfs_show_ctldir(zdp) \
46 (zfs_has_ctldir(zdp) && \
47 (ZTOZSB(zdp)->z_show_ctldir))
48
49 typedef struct {
50 char *se_name;
51 char *se_path;
52 struct inode *se_inode;
53 taskqid_t se_taskqid;
54 avl_node_t se_node;
55 } zfs_snapentry_t;
56
57 /* zfsctl generic functions */
58 extern int snapentry_compare(const void *a, const void *b);
59 extern boolean_t zfsctl_is_node(struct inode *ip);
60 extern boolean_t zfsctl_is_snapdir(struct inode *ip);
61 extern void zfsctl_inode_inactive(struct inode *ip);
62 extern void zfsctl_inode_destroy(struct inode *ip);
63 extern int zfsctl_create(zfs_sb_t *zsb);
64 extern void zfsctl_destroy(zfs_sb_t *zsb);
65 extern struct inode *zfsctl_root(znode_t *zp);
66 extern int zfsctl_fid(struct inode *ip, fid_t *fidp);
67
68 /* zfsctl '.zfs' functions */
69 extern int zfsctl_root_lookup(struct inode *dip, char *name,
70 struct inode **ipp, int flags, cred_t *cr, int *direntflags,
71 pathname_t *realpnp);
72
73 /* zfsctl '.zfs/snapshot' functions */
74 extern int zfsctl_snapdir_lookup(struct inode *dip, char *name,
75 struct inode **ipp, int flags, cred_t *cr, int *direntflags,
76 pathname_t *realpnp);
77 extern int zfsctl_snapdir_rename(struct inode *sdip, char *sname,
78 struct inode *tdip, char *tname, cred_t *cr, int flags);
79 extern int zfsctl_snapdir_remove(struct inode *dip, char *name, cred_t *cr,
80 int flags);
81 extern int zfsctl_snapdir_mkdir(struct inode *dip, char *dirname, vattr_t *vap,
82 struct inode **ipp, cred_t *cr, int flags);
83 extern void zfsctl_snapdir_inactive(struct inode *ip);
84 extern int zfsctl_unmount_snapshot(zfs_sb_t *zsb, char *name, int flags);
85 extern int zfsctl_unmount_snapshots(zfs_sb_t *zsb, int flags, int *count);
86 extern int zfsctl_mount_snapshot(struct path *path, int flags);
87 extern int zfsctl_lookup_objset(struct super_block *sb, uint64_t objsetid,
88 zfs_sb_t **zsb);
89
90 /* zfsctl '.zfs/shares' functions */
91 extern int zfsctl_shares_lookup(struct inode *dip, char *name,
92 struct inode **ipp, int flags, cred_t *cr, int *direntflags,
93 pathname_t *realpnp);
94
95 /* zfsctl_init/fini functions */
96 extern void zfsctl_init(void);
97 extern void zfsctl_fini(void);
98
99 /*
100 * These inodes numbers are reserved for the .zfs control directory.
101 * It is important that they be no larger that 48-bits because only
102 * 6 bytes are reserved in the NFS file handle for the object number.
103 * However, they should be as large as possible to avoid conflicts
104 * with the objects which are assigned monotonically by the dmu.
105 */
106 #define ZFSCTL_INO_ROOT 0x0000FFFFFFFFFFFFULL
107 #define ZFSCTL_INO_SHARES 0x0000FFFFFFFFFFFEULL
108 #define ZFSCTL_INO_SNAPDIR 0x0000FFFFFFFFFFFDULL
109 #define ZFSCTL_INO_SNAPDIRS 0x0000FFFFFFFFFFFCULL
110
111 #define ZFSCTL_EXPIRE_SNAPSHOT 300
112
113 #endif /* _ZFS_CTLDIR_H */