[PATCH] v9fs: VFS superblock operations and glue
[deliverable/linux.git] / fs / xfs / xfs_dmapi.h
CommitLineData
1da177e4 1/*
616b1c72 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
1da177e4
LT
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 *
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32#ifndef __XFS_DMAPI_H__
33#define __XFS_DMAPI_H__
34
35/* Values used to define the on-disk version of dm_attrname_t. All
36 * on-disk attribute names start with the 8-byte string "SGI_DMI_".
37 *
38 * In the on-disk inode, DMAPI attribute names consist of the user-provided
39 * name with the DMATTR_PREFIXSTRING pre-pended. This string must NEVER be
40 * changed.
41 */
42
43#define DMATTR_PREFIXLEN 8
44#define DMATTR_PREFIXSTRING "SGI_DMI_"
45
46typedef enum {
47 DM_EVENT_INVALID = -1,
48 DM_EVENT_CANCEL = 0, /* not supported */
49 DM_EVENT_MOUNT = 1,
50 DM_EVENT_PREUNMOUNT = 2,
51 DM_EVENT_UNMOUNT = 3,
52 DM_EVENT_DEBUT = 4, /* not supported */
53 DM_EVENT_CREATE = 5,
54 DM_EVENT_CLOSE = 6, /* not supported */
55 DM_EVENT_POSTCREATE = 7,
56 DM_EVENT_REMOVE = 8,
57 DM_EVENT_POSTREMOVE = 9,
58 DM_EVENT_RENAME = 10,
59 DM_EVENT_POSTRENAME = 11,
60 DM_EVENT_LINK = 12,
61 DM_EVENT_POSTLINK = 13,
62 DM_EVENT_SYMLINK = 14,
63 DM_EVENT_POSTSYMLINK = 15,
64 DM_EVENT_READ = 16,
65 DM_EVENT_WRITE = 17,
66 DM_EVENT_TRUNCATE = 18,
67 DM_EVENT_ATTRIBUTE = 19,
68 DM_EVENT_DESTROY = 20,
69 DM_EVENT_NOSPACE = 21,
70 DM_EVENT_USER = 22,
71 DM_EVENT_MAX = 23
72} dm_eventtype_t;
73#define HAVE_DM_EVENTTYPE_T
74
75typedef enum {
76 DM_RIGHT_NULL,
77 DM_RIGHT_SHARED,
78 DM_RIGHT_EXCL
79} dm_right_t;
80#define HAVE_DM_RIGHT_T
81
82/* Defines for determining if an event message should be sent. */
83#define DM_EVENT_ENABLED(vfsp, ip, event) ( \
84 unlikely ((vfsp)->vfs_flag & VFS_DMI) && \
85 ( ((ip)->i_d.di_dmevmask & (1 << event)) || \
86 ((ip)->i_mount->m_dmevmask & (1 << event)) ) \
87 )
88
89#define DM_EVENT_ENABLED_IO(vfsp, io, event) ( \
90 unlikely ((vfsp)->vfs_flag & VFS_DMI) && \
91 ( ((io)->io_dmevmask & (1 << event)) || \
92 ((io)->io_mount->m_dmevmask & (1 << event)) ) \
93 )
94
95#define DM_XFS_VALID_FS_EVENTS ( \
96 (1 << DM_EVENT_PREUNMOUNT) | \
97 (1 << DM_EVENT_UNMOUNT) | \
98 (1 << DM_EVENT_NOSPACE) | \
99 (1 << DM_EVENT_DEBUT) | \
100 (1 << DM_EVENT_CREATE) | \
101 (1 << DM_EVENT_POSTCREATE) | \
102 (1 << DM_EVENT_REMOVE) | \
103 (1 << DM_EVENT_POSTREMOVE) | \
104 (1 << DM_EVENT_RENAME) | \
105 (1 << DM_EVENT_POSTRENAME) | \
106 (1 << DM_EVENT_LINK) | \
107 (1 << DM_EVENT_POSTLINK) | \
108 (1 << DM_EVENT_SYMLINK) | \
109 (1 << DM_EVENT_POSTSYMLINK) | \
110 (1 << DM_EVENT_ATTRIBUTE) | \
111 (1 << DM_EVENT_DESTROY) )
112
113/* Events valid in dm_set_eventlist() when called with a file handle for
114 a regular file or a symlink. These events are persistent.
115*/
116
117#define DM_XFS_VALID_FILE_EVENTS ( \
118 (1 << DM_EVENT_ATTRIBUTE) | \
119 (1 << DM_EVENT_DESTROY) )
120
121/* Events valid in dm_set_eventlist() when called with a file handle for
122 a directory. These events are persistent.
123*/
124
125#define DM_XFS_VALID_DIRECTORY_EVENTS ( \
126 (1 << DM_EVENT_CREATE) | \
127 (1 << DM_EVENT_POSTCREATE) | \
128 (1 << DM_EVENT_REMOVE) | \
129 (1 << DM_EVENT_POSTREMOVE) | \
130 (1 << DM_EVENT_RENAME) | \
131 (1 << DM_EVENT_POSTRENAME) | \
132 (1 << DM_EVENT_LINK) | \
133 (1 << DM_EVENT_POSTLINK) | \
134 (1 << DM_EVENT_SYMLINK) | \
135 (1 << DM_EVENT_POSTSYMLINK) | \
136 (1 << DM_EVENT_ATTRIBUTE) | \
137 (1 << DM_EVENT_DESTROY) )
138
139/* Events supported by the XFS filesystem. */
140#define DM_XFS_SUPPORTED_EVENTS ( \
141 (1 << DM_EVENT_MOUNT) | \
142 (1 << DM_EVENT_PREUNMOUNT) | \
143 (1 << DM_EVENT_UNMOUNT) | \
144 (1 << DM_EVENT_NOSPACE) | \
145 (1 << DM_EVENT_CREATE) | \
146 (1 << DM_EVENT_POSTCREATE) | \
147 (1 << DM_EVENT_REMOVE) | \
148 (1 << DM_EVENT_POSTREMOVE) | \
149 (1 << DM_EVENT_RENAME) | \
150 (1 << DM_EVENT_POSTRENAME) | \
151 (1 << DM_EVENT_LINK) | \
152 (1 << DM_EVENT_POSTLINK) | \
153 (1 << DM_EVENT_SYMLINK) | \
154 (1 << DM_EVENT_POSTSYMLINK) | \
155 (1 << DM_EVENT_READ) | \
156 (1 << DM_EVENT_WRITE) | \
157 (1 << DM_EVENT_TRUNCATE) | \
158 (1 << DM_EVENT_ATTRIBUTE) | \
159 (1 << DM_EVENT_DESTROY) )
160
161
162/*
163 * Definitions used for the flags field on dm_send_*_event().
164 */
165
166#define DM_FLAGS_NDELAY 0x001 /* return EAGAIN after dm_pending() */
167#define DM_FLAGS_UNWANTED 0x002 /* event not in fsys dm_eventset_t */
168#define DM_FLAGS_ISEM 0x004 /* thread holds i_sem */
1da177e4
LT
169#define DM_FLAGS_IALLOCSEM_RD 0x010 /* thread holds i_alloc_sem rd */
170#define DM_FLAGS_IALLOCSEM_WR 0x020 /* thread holds i_alloc_sem wr */
1da177e4
LT
171
172/*
173 * Based on IO_ISDIRECT, decide which i_ flag is set.
174 */
e1a40fa9
DR
175#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
176#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
177 DM_FLAGS_ISEM : 0)
178#define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_ISEM)
179#endif
180
181#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) && \
182 (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,22))
1da177e4
LT
183#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
184 DM_FLAGS_IALLOCSEM_RD : DM_FLAGS_ISEM)
185#define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_ISEM)
e1a40fa9
DR
186#endif
187
188#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,21)
1da177e4
LT
189#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
190 0 : DM_FLAGS_ISEM)
191#define DM_SEM_FLAG_WR (DM_FLAGS_ISEM)
192#endif
193
e1a40fa9 194
1da177e4
LT
195/*
196 * Macros to turn caller specified delay/block flags into
197 * dm_send_xxxx_event flag DM_FLAGS_NDELAY.
198 */
199
200#define FILP_DELAY_FLAG(filp) ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) ? \
201 DM_FLAGS_NDELAY : 0)
202#define AT_DELAY_FLAG(f) ((f&ATTR_NONBLOCK) ? DM_FLAGS_NDELAY : 0)
203
204
205extern struct bhv_vfsops xfs_dmops;
206
207#ifdef CONFIG_XFS_DMAPI
208void xfs_dm_init(struct file_system_type *);
209void xfs_dm_exit(struct file_system_type *);
210#define XFS_DM_INIT(fstype) xfs_dm_init(fstype)
211#define XFS_DM_EXIT(fstype) xfs_dm_exit(fstype)
212#else
213#define XFS_DM_INIT(fstype)
214#define XFS_DM_EXIT(fstype)
215#endif
216
217#endif /* __XFS_DMAPI_H__ */
This page took 0.077384 seconds and 5 git commands to generate.