blob: cdc2d3464a1af7ddc84efac8bcdca346cb773926 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott7b718762005-11-02 14:58:39 +11002 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott7b718762005-11-02 14:58:39 +11005 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott7b718762005-11-02 14:58:39 +11009 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott7b718762005-11-02 14:58:39 +110014 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 */
18#ifndef __XFS_DMAPI_H__
19#define __XFS_DMAPI_H__
20
Olaf Hering733482e2005-11-08 21:34:55 -080021#include <linux/version.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022/* Values used to define the on-disk version of dm_attrname_t. All
23 * on-disk attribute names start with the 8-byte string "SGI_DMI_".
24 *
25 * In the on-disk inode, DMAPI attribute names consist of the user-provided
26 * name with the DMATTR_PREFIXSTRING pre-pended. This string must NEVER be
27 * changed.
28 */
29
30#define DMATTR_PREFIXLEN 8
31#define DMATTR_PREFIXSTRING "SGI_DMI_"
32
33typedef enum {
34 DM_EVENT_INVALID = -1,
35 DM_EVENT_CANCEL = 0, /* not supported */
36 DM_EVENT_MOUNT = 1,
37 DM_EVENT_PREUNMOUNT = 2,
38 DM_EVENT_UNMOUNT = 3,
39 DM_EVENT_DEBUT = 4, /* not supported */
40 DM_EVENT_CREATE = 5,
41 DM_EVENT_CLOSE = 6, /* not supported */
42 DM_EVENT_POSTCREATE = 7,
43 DM_EVENT_REMOVE = 8,
44 DM_EVENT_POSTREMOVE = 9,
45 DM_EVENT_RENAME = 10,
46 DM_EVENT_POSTRENAME = 11,
47 DM_EVENT_LINK = 12,
48 DM_EVENT_POSTLINK = 13,
49 DM_EVENT_SYMLINK = 14,
50 DM_EVENT_POSTSYMLINK = 15,
51 DM_EVENT_READ = 16,
52 DM_EVENT_WRITE = 17,
53 DM_EVENT_TRUNCATE = 18,
54 DM_EVENT_ATTRIBUTE = 19,
55 DM_EVENT_DESTROY = 20,
56 DM_EVENT_NOSPACE = 21,
57 DM_EVENT_USER = 22,
58 DM_EVENT_MAX = 23
59} dm_eventtype_t;
60#define HAVE_DM_EVENTTYPE_T
61
62typedef enum {
63 DM_RIGHT_NULL,
64 DM_RIGHT_SHARED,
65 DM_RIGHT_EXCL
66} dm_right_t;
67#define HAVE_DM_RIGHT_T
68
69/* Defines for determining if an event message should be sent. */
Eric Sandeen948c6d4f2007-08-23 16:19:57 +100070#ifdef HAVE_DMAPI
Christoph Hellwigeb9df392007-08-16 18:42:07 +100071#define DM_EVENT_ENABLED(ip, event) ( \
Christoph Hellwigbd186aa2007-08-30 17:21:12 +100072 unlikely ((ip)->i_mount->m_flags & XFS_MOUNT_DMAPI) && \
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 ( ((ip)->i_d.di_dmevmask & (1 << event)) || \
74 ((ip)->i_mount->m_dmevmask & (1 << event)) ) \
75 )
Eric Sandeen948c6d4f2007-08-23 16:19:57 +100076#else
77#define DM_EVENT_ENABLED(ip, event) (0)
78#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
Linus Torvalds1da177e2005-04-16 15:20:36 -070080#define DM_XFS_VALID_FS_EVENTS ( \
81 (1 << DM_EVENT_PREUNMOUNT) | \
82 (1 << DM_EVENT_UNMOUNT) | \
83 (1 << DM_EVENT_NOSPACE) | \
84 (1 << DM_EVENT_DEBUT) | \
85 (1 << DM_EVENT_CREATE) | \
86 (1 << DM_EVENT_POSTCREATE) | \
87 (1 << DM_EVENT_REMOVE) | \
88 (1 << DM_EVENT_POSTREMOVE) | \
89 (1 << DM_EVENT_RENAME) | \
90 (1 << DM_EVENT_POSTRENAME) | \
91 (1 << DM_EVENT_LINK) | \
92 (1 << DM_EVENT_POSTLINK) | \
93 (1 << DM_EVENT_SYMLINK) | \
94 (1 << DM_EVENT_POSTSYMLINK) | \
95 (1 << DM_EVENT_ATTRIBUTE) | \
96 (1 << DM_EVENT_DESTROY) )
97
98/* Events valid in dm_set_eventlist() when called with a file handle for
99 a regular file or a symlink. These events are persistent.
100*/
101
102#define DM_XFS_VALID_FILE_EVENTS ( \
103 (1 << DM_EVENT_ATTRIBUTE) | \
104 (1 << DM_EVENT_DESTROY) )
105
106/* Events valid in dm_set_eventlist() when called with a file handle for
107 a directory. These events are persistent.
108*/
109
110#define DM_XFS_VALID_DIRECTORY_EVENTS ( \
111 (1 << DM_EVENT_CREATE) | \
112 (1 << DM_EVENT_POSTCREATE) | \
113 (1 << DM_EVENT_REMOVE) | \
114 (1 << DM_EVENT_POSTREMOVE) | \
115 (1 << DM_EVENT_RENAME) | \
116 (1 << DM_EVENT_POSTRENAME) | \
117 (1 << DM_EVENT_LINK) | \
118 (1 << DM_EVENT_POSTLINK) | \
119 (1 << DM_EVENT_SYMLINK) | \
120 (1 << DM_EVENT_POSTSYMLINK) | \
121 (1 << DM_EVENT_ATTRIBUTE) | \
122 (1 << DM_EVENT_DESTROY) )
123
124/* Events supported by the XFS filesystem. */
125#define DM_XFS_SUPPORTED_EVENTS ( \
126 (1 << DM_EVENT_MOUNT) | \
127 (1 << DM_EVENT_PREUNMOUNT) | \
128 (1 << DM_EVENT_UNMOUNT) | \
129 (1 << DM_EVENT_NOSPACE) | \
130 (1 << DM_EVENT_CREATE) | \
131 (1 << DM_EVENT_POSTCREATE) | \
132 (1 << DM_EVENT_REMOVE) | \
133 (1 << DM_EVENT_POSTREMOVE) | \
134 (1 << DM_EVENT_RENAME) | \
135 (1 << DM_EVENT_POSTRENAME) | \
136 (1 << DM_EVENT_LINK) | \
137 (1 << DM_EVENT_POSTLINK) | \
138 (1 << DM_EVENT_SYMLINK) | \
139 (1 << DM_EVENT_POSTSYMLINK) | \
140 (1 << DM_EVENT_READ) | \
141 (1 << DM_EVENT_WRITE) | \
142 (1 << DM_EVENT_TRUNCATE) | \
143 (1 << DM_EVENT_ATTRIBUTE) | \
144 (1 << DM_EVENT_DESTROY) )
145
146
147/*
148 * Definitions used for the flags field on dm_send_*_event().
149 */
150
151#define DM_FLAGS_NDELAY 0x001 /* return EAGAIN after dm_pending() */
152#define DM_FLAGS_UNWANTED 0x002 /* event not in fsys dm_eventset_t */
Jes Sorensen1b1dcc12006-01-09 15:59:24 -0800153#define DM_FLAGS_IMUX 0x004 /* thread holds i_mutex */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154#define DM_FLAGS_IALLOCSEM_RD 0x010 /* thread holds i_alloc_sem rd */
155#define DM_FLAGS_IALLOCSEM_WR 0x020 /* thread holds i_alloc_sem wr */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156
157/*
David Chinner050e7142006-11-11 18:05:06 +1100158 * Pull in platform specific event flags defines
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 */
David Chinner050e7142006-11-11 18:05:06 +1100160#include "xfs_dmapi_priv.h"
Dean Roehriche1a40fa2005-06-22 10:20:44 +1000161
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162/*
163 * Macros to turn caller specified delay/block flags into
164 * dm_send_xxxx_event flag DM_FLAGS_NDELAY.
165 */
166
167#define FILP_DELAY_FLAG(filp) ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) ? \
168 DM_FLAGS_NDELAY : 0)
Christoph Hellwig0f285c82008-07-18 17:13:28 +1000169#define AT_DELAY_FLAG(f) ((f & XFS_ATTR_NONBLOCK) ? DM_FLAGS_NDELAY : 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171#endif /* __XFS_DMAPI_H__ */