David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 1 | /* internal AFS stuff |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 3 | * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * Written by David Howells (dhowells@redhat.com) |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | */ |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/compiler.h> |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/fs.h> |
| 15 | #include <linux/pagemap.h> |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 16 | #include <linux/skbuff.h> |
| 17 | #include <linux/rxrpc.h> |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 18 | #include <linux/key.h> |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 19 | #include "afs.h" |
| 20 | #include "afs_vl.h" |
| 21 | |
| 22 | #define AFS_CELL_MAX_ADDRS 15 |
| 23 | |
| 24 | struct afs_call; |
| 25 | |
| 26 | typedef enum { |
| 27 | AFS_VL_NEW, /* new, uninitialised record */ |
| 28 | AFS_VL_CREATING, /* creating record */ |
| 29 | AFS_VL_VALID, /* record is pending */ |
| 30 | AFS_VL_NO_VOLUME, /* no such volume available */ |
| 31 | AFS_VL_UPDATING, /* update in progress */ |
| 32 | AFS_VL_VOLUME_DELETED, /* volume was deleted */ |
| 33 | AFS_VL_UNCERTAIN, /* uncertain state (update failed) */ |
| 34 | } __attribute__((packed)) afs_vlocation_state_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 36 | struct afs_mount_params { |
| 37 | bool rwpath; /* T if the parent should be considered R/W */ |
| 38 | bool force; /* T to force cell type */ |
| 39 | afs_voltype_t type; /* type of volume requested */ |
| 40 | int volnamesz; /* size of volume name */ |
| 41 | const char *volname; /* name of volume to mount */ |
| 42 | struct afs_cell *cell; /* cell in which to find volume */ |
| 43 | struct afs_volume *volume; /* volume record */ |
| 44 | struct key *key; /* key to use for secure mounting */ |
| 45 | }; |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 48 | * definition of how to wait for the completion of an operation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 50 | struct afs_wait_mode { |
| 51 | /* RxRPC received message notification */ |
| 52 | void (*rx_wakeup)(struct afs_call *call); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 54 | /* synchronous call waiter and call dispatched notification */ |
| 55 | int (*wait)(struct afs_call *call); |
| 56 | |
| 57 | /* asynchronous call completion */ |
| 58 | void (*async_complete)(void *reply, int error); |
| 59 | }; |
| 60 | |
| 61 | extern const struct afs_wait_mode afs_sync_call; |
| 62 | extern const struct afs_wait_mode afs_async_call; |
| 63 | |
| 64 | /* |
| 65 | * a record of an in-progress RxRPC call |
| 66 | */ |
| 67 | struct afs_call { |
| 68 | const struct afs_call_type *type; /* type of call */ |
| 69 | const struct afs_wait_mode *wait_mode; /* completion wait mode */ |
| 70 | wait_queue_head_t waitq; /* processes awaiting completion */ |
| 71 | struct work_struct async_work; /* asynchronous work processor */ |
| 72 | struct work_struct work; /* actual work processor */ |
| 73 | struct sk_buff_head rx_queue; /* received packets */ |
| 74 | struct rxrpc_call *rxcall; /* RxRPC call handle */ |
| 75 | struct key *key; /* security for this call */ |
| 76 | struct afs_server *server; /* server affected by incoming CM call */ |
| 77 | void *request; /* request data (first part) */ |
| 78 | void *request2; /* request data (second part) */ |
| 79 | void *buffer; /* reply receive buffer */ |
| 80 | void *reply; /* reply buffer (first part) */ |
| 81 | void *reply2; /* reply buffer (second part) */ |
| 82 | void *reply3; /* reply buffer (third part) */ |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 83 | void *reply4; /* reply buffer (fourth part) */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 84 | enum { /* call state */ |
| 85 | AFS_CALL_REQUESTING, /* request is being sent for outgoing call */ |
| 86 | AFS_CALL_AWAIT_REPLY, /* awaiting reply to outgoing call */ |
| 87 | AFS_CALL_AWAIT_OP_ID, /* awaiting op ID on incoming call */ |
| 88 | AFS_CALL_AWAIT_REQUEST, /* awaiting request data on incoming call */ |
| 89 | AFS_CALL_REPLYING, /* replying to incoming call */ |
| 90 | AFS_CALL_AWAIT_ACK, /* awaiting final ACK of incoming call */ |
| 91 | AFS_CALL_COMPLETE, /* successfully completed */ |
| 92 | AFS_CALL_BUSY, /* server was busy */ |
| 93 | AFS_CALL_ABORTED, /* call was aborted */ |
| 94 | AFS_CALL_ERROR, /* call failed due to error */ |
| 95 | } state; |
| 96 | int error; /* error code */ |
| 97 | unsigned request_size; /* size of request data */ |
| 98 | unsigned reply_max; /* maximum size of reply */ |
| 99 | unsigned reply_size; /* current size of reply */ |
| 100 | unsigned short offset; /* offset into received data store */ |
| 101 | unsigned char unmarshall; /* unmarshalling phase */ |
| 102 | bool incoming; /* T if incoming call */ |
| 103 | u16 service_id; /* RxRPC service ID to call */ |
| 104 | __be16 port; /* target UDP port */ |
| 105 | __be32 operation_ID; /* operation ID for an incoming call */ |
| 106 | u32 count; /* count for use in unmarshalling */ |
| 107 | __be32 tmp; /* place to extract temporary data */ |
| 108 | }; |
| 109 | |
| 110 | struct afs_call_type { |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 111 | const char *name; |
| 112 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 113 | /* deliver request or reply data to an call |
| 114 | * - returning an error will cause the call to be aborted |
| 115 | */ |
| 116 | int (*deliver)(struct afs_call *call, struct sk_buff *skb, |
| 117 | bool last); |
| 118 | |
| 119 | /* map an abort code to an error number */ |
| 120 | int (*abort_to_error)(u32 abort_code); |
| 121 | |
| 122 | /* clean up a call */ |
| 123 | void (*destructor)(struct afs_call *call); |
| 124 | }; |
| 125 | |
| 126 | /* |
| 127 | * AFS superblock private data |
| 128 | * - there's one superblock per volume |
| 129 | */ |
| 130 | struct afs_super_info { |
| 131 | struct afs_volume *volume; /* volume record */ |
| 132 | char rwparent; /* T if parent is R/W AFS volume */ |
| 133 | }; |
| 134 | |
| 135 | static inline struct afs_super_info *AFS_FS_S(struct super_block *sb) |
| 136 | { |
| 137 | return sb->s_fs_info; |
| 138 | } |
| 139 | |
| 140 | extern struct file_system_type afs_fs_type; |
| 141 | |
| 142 | /* |
| 143 | * entry in the cached cell catalogue |
| 144 | */ |
| 145 | struct afs_cache_cell { |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 146 | char name[AFS_MAXCELLNAME]; /* cell name (padded with NULs) */ |
| 147 | struct in_addr vl_servers[15]; /* cached cell VL servers */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | /* |
| 151 | * AFS cell record |
| 152 | */ |
| 153 | struct afs_cell { |
| 154 | atomic_t usage; |
| 155 | struct list_head link; /* main cell list link */ |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 156 | struct key *anonymous_key; /* anonymous user key for this cell */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 157 | struct list_head proc_link; /* /proc cell list link */ |
| 158 | struct proc_dir_entry *proc_dir; /* /proc dir for this cell */ |
| 159 | #ifdef AFS_CACHING_SUPPORT |
| 160 | struct cachefs_cookie *cache; /* caching cookie */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | #endif |
| 162 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 163 | /* server record management */ |
| 164 | rwlock_t servers_lock; /* active server list lock */ |
| 165 | struct list_head servers; /* active server list */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 167 | /* volume location record management */ |
| 168 | struct rw_semaphore vl_sem; /* volume management serialisation semaphore */ |
| 169 | struct list_head vl_list; /* cell's active VL record list */ |
| 170 | spinlock_t vl_lock; /* vl_list lock */ |
| 171 | unsigned short vl_naddrs; /* number of VL servers in addr list */ |
| 172 | unsigned short vl_curr_svix; /* current server index */ |
| 173 | struct in_addr vl_addrs[AFS_CELL_MAX_ADDRS]; /* cell VL server addresses */ |
| 174 | |
| 175 | char name[0]; /* cell name - must go last */ |
| 176 | }; |
| 177 | |
| 178 | /* |
| 179 | * entry in the cached volume location catalogue |
| 180 | */ |
| 181 | struct afs_cache_vlocation { |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 182 | /* volume name (lowercase, padded with NULs) */ |
| 183 | uint8_t name[AFS_MAXVOLNAME + 1]; |
| 184 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 185 | uint8_t nservers; /* number of entries used in servers[] */ |
| 186 | uint8_t vidmask; /* voltype mask for vid[] */ |
| 187 | uint8_t srvtmask[8]; /* voltype masks for servers[] */ |
| 188 | #define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */ |
| 189 | #define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */ |
| 190 | #define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */ |
| 191 | |
| 192 | afs_volid_t vid[3]; /* volume IDs for R/W, R/O and Bak volumes */ |
| 193 | struct in_addr servers[8]; /* fileserver addresses */ |
| 194 | time_t rtime; /* last retrieval time */ |
| 195 | }; |
| 196 | |
| 197 | /* |
| 198 | * volume -> vnode hash table entry |
| 199 | */ |
| 200 | struct afs_cache_vhash { |
| 201 | afs_voltype_t vtype; /* which volume variation */ |
| 202 | uint8_t hash_bucket; /* which hash bucket this represents */ |
| 203 | } __attribute__((packed)); |
| 204 | |
| 205 | /* |
| 206 | * AFS volume location record |
| 207 | */ |
| 208 | struct afs_vlocation { |
| 209 | atomic_t usage; |
| 210 | time_t time_of_death; /* time at which put reduced usage to 0 */ |
| 211 | struct list_head link; /* link in cell volume location list */ |
| 212 | struct list_head grave; /* link in master graveyard list */ |
| 213 | struct list_head update; /* link in master update list */ |
| 214 | struct afs_cell *cell; /* cell to which volume belongs */ |
| 215 | #ifdef AFS_CACHING_SUPPORT |
| 216 | struct cachefs_cookie *cache; /* caching cookie */ |
| 217 | #endif |
| 218 | struct afs_cache_vlocation vldb; /* volume information DB record */ |
| 219 | struct afs_volume *vols[3]; /* volume access record pointer (index by type) */ |
| 220 | wait_queue_head_t waitq; /* status change waitqueue */ |
| 221 | time_t update_at; /* time at which record should be updated */ |
David S. Miller | 39bf094 | 2007-04-26 20:39:14 -0700 | [diff] [blame] | 222 | spinlock_t lock; /* access lock */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 223 | afs_vlocation_state_t state; /* volume location state */ |
| 224 | unsigned short upd_rej_cnt; /* ENOMEDIUM count during update */ |
| 225 | unsigned short upd_busy_cnt; /* EBUSY count during update */ |
| 226 | bool valid; /* T if valid */ |
| 227 | }; |
| 228 | |
| 229 | /* |
| 230 | * AFS fileserver record |
| 231 | */ |
| 232 | struct afs_server { |
| 233 | atomic_t usage; |
| 234 | time_t time_of_death; /* time at which put reduced usage to 0 */ |
| 235 | struct in_addr addr; /* server address */ |
| 236 | struct afs_cell *cell; /* cell in which server resides */ |
| 237 | struct list_head link; /* link in cell's server list */ |
| 238 | struct list_head grave; /* link in master graveyard list */ |
| 239 | struct rb_node master_rb; /* link in master by-addr tree */ |
| 240 | struct rw_semaphore sem; /* access lock */ |
| 241 | |
| 242 | /* file service access */ |
| 243 | struct rb_root fs_vnodes; /* vnodes backed by this server (ordered by FID) */ |
| 244 | unsigned long fs_act_jif; /* time at which last activity occurred */ |
| 245 | unsigned long fs_dead_jif; /* time at which no longer to be considered dead */ |
| 246 | spinlock_t fs_lock; /* access lock */ |
| 247 | int fs_state; /* 0 or reason FS currently marked dead (-errno) */ |
| 248 | |
| 249 | /* callback promise management */ |
| 250 | struct rb_root cb_promises; /* vnode expiration list (ordered earliest first) */ |
| 251 | struct delayed_work cb_updater; /* callback updater */ |
| 252 | struct delayed_work cb_break_work; /* collected break dispatcher */ |
| 253 | wait_queue_head_t cb_break_waitq; /* space available in cb_break waitqueue */ |
| 254 | spinlock_t cb_lock; /* access lock */ |
| 255 | struct afs_callback cb_break[64]; /* ring of callbacks awaiting breaking */ |
| 256 | atomic_t cb_break_n; /* number of pending breaks */ |
| 257 | u8 cb_break_head; /* head of callback breaking ring */ |
| 258 | u8 cb_break_tail; /* tail of callback breaking ring */ |
| 259 | }; |
| 260 | |
| 261 | /* |
| 262 | * AFS volume access record |
| 263 | */ |
| 264 | struct afs_volume { |
| 265 | atomic_t usage; |
| 266 | struct afs_cell *cell; /* cell to which belongs (unrefd ptr) */ |
| 267 | struct afs_vlocation *vlocation; /* volume location */ |
| 268 | #ifdef AFS_CACHING_SUPPORT |
| 269 | struct cachefs_cookie *cache; /* caching cookie */ |
| 270 | #endif |
| 271 | afs_volid_t vid; /* volume ID */ |
| 272 | afs_voltype_t type; /* type of volume */ |
| 273 | char type_force; /* force volume type (suppress R/O -> R/W) */ |
| 274 | unsigned short nservers; /* number of server slots filled */ |
| 275 | unsigned short rjservers; /* number of servers discarded due to -ENOMEDIUM */ |
| 276 | struct afs_server *servers[8]; /* servers on which volume resides (ordered) */ |
| 277 | struct rw_semaphore server_sem; /* lock for accessing current server */ |
| 278 | }; |
| 279 | |
| 280 | /* |
| 281 | * vnode catalogue entry |
| 282 | */ |
| 283 | struct afs_cache_vnode { |
| 284 | afs_vnodeid_t vnode_id; /* vnode ID */ |
| 285 | unsigned vnode_unique; /* vnode ID uniquifier */ |
| 286 | afs_dataversion_t data_version; /* data version */ |
| 287 | }; |
| 288 | |
| 289 | /* |
| 290 | * AFS inode private data |
| 291 | */ |
| 292 | struct afs_vnode { |
| 293 | struct inode vfs_inode; /* the VFS's inode record */ |
| 294 | |
| 295 | struct afs_volume *volume; /* volume on which vnode resides */ |
| 296 | struct afs_server *server; /* server currently supplying this file */ |
| 297 | struct afs_fid fid; /* the file identifier for this inode */ |
| 298 | struct afs_file_status status; /* AFS status info for this file */ |
| 299 | #ifdef AFS_CACHING_SUPPORT |
| 300 | struct cachefs_cookie *cache; /* caching cookie */ |
| 301 | #endif |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 302 | struct afs_permits *permits; /* cache of permits so far obtained */ |
| 303 | struct mutex permits_lock; /* lock for altering permits list */ |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 304 | struct mutex validate_lock; /* lock for validating this vnode */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 305 | wait_queue_head_t update_waitq; /* status fetch waitqueue */ |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 306 | int update_cnt; /* number of outstanding ops that will update the |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 307 | * status */ |
| 308 | spinlock_t lock; /* waitqueue/flags lock */ |
| 309 | unsigned long flags; |
| 310 | #define AFS_VNODE_CB_BROKEN 0 /* set if vnode's callback was broken */ |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 311 | #define AFS_VNODE_UNSET 1 /* set if vnode attributes not yet set */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 312 | #define AFS_VNODE_MODIFIED 2 /* set if vnode's data modified */ |
| 313 | #define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */ |
| 314 | #define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */ |
| 315 | #define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 316 | |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 317 | long acl_order; /* ACL check count (callback break count) */ |
| 318 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 319 | /* outstanding callback notification on this file */ |
| 320 | struct rb_node server_rb; /* link in server->fs_vnodes */ |
| 321 | struct rb_node cb_promise; /* link in server->cb_promises */ |
| 322 | struct work_struct cb_broken_work; /* work to be done on callback break */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 323 | time_t cb_expires; /* time at which callback expires */ |
| 324 | time_t cb_expires_at; /* time used to order cb_promise */ |
| 325 | unsigned cb_version; /* callback version */ |
| 326 | unsigned cb_expiry; /* callback expiry time */ |
| 327 | afs_callback_type_t cb_type; /* type of callback */ |
| 328 | bool cb_promised; /* true if promise still holds */ |
| 329 | }; |
| 330 | |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 331 | /* |
| 332 | * cached security record for one user's attempt to access a vnode |
| 333 | */ |
| 334 | struct afs_permit { |
| 335 | struct key *key; /* RxRPC ticket holding a security context */ |
| 336 | afs_access_t access_mask; /* access mask for this key */ |
| 337 | }; |
| 338 | |
| 339 | /* |
| 340 | * cache of security records from attempts to access a vnode |
| 341 | */ |
| 342 | struct afs_permits { |
| 343 | struct rcu_head rcu; /* disposal procedure */ |
| 344 | int count; /* number of records */ |
| 345 | struct afs_permit permits[0]; /* the permits so far examined */ |
| 346 | }; |
| 347 | |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 348 | /* |
| 349 | * record of one of a system's set of network interfaces |
| 350 | */ |
| 351 | struct afs_interface { |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 352 | struct in_addr address; /* IPv4 address bound to interface */ |
| 353 | struct in_addr netmask; /* netmask applied to address */ |
| 354 | unsigned mtu; /* MTU of interface */ |
| 355 | }; |
| 356 | |
| 357 | /* |
| 358 | * UUID definition [internet draft] |
| 359 | * - the timestamp is a 60-bit value, split 32/16/12, and goes in 100ns |
| 360 | * increments since midnight 15th October 1582 |
| 361 | * - add AFS_UUID_TO_UNIX_TIME to convert unix time in 100ns units to UUID |
| 362 | * time |
| 363 | * - the clock sequence is a 14-bit counter to avoid duplicate times |
| 364 | */ |
| 365 | struct afs_uuid { |
| 366 | u32 time_low; /* low part of timestamp */ |
| 367 | u16 time_mid; /* mid part of timestamp */ |
| 368 | u16 time_hi_and_version; /* high part of timestamp and version */ |
David Howells | b1bdb69 | 2007-04-27 15:28:45 -0700 | [diff] [blame] | 369 | #define AFS_UUID_TO_UNIX_TIME 0x01b21dd213814000ULL |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 370 | #define AFS_UUID_TIMEHI_MASK 0x0fff |
| 371 | #define AFS_UUID_VERSION_TIME 0x1000 /* time-based UUID */ |
| 372 | #define AFS_UUID_VERSION_NAME 0x3000 /* name-based UUID */ |
| 373 | #define AFS_UUID_VERSION_RANDOM 0x4000 /* (pseudo-)random generated UUID */ |
| 374 | u8 clock_seq_hi_and_reserved; /* clock seq hi and variant */ |
| 375 | #define AFS_UUID_CLOCKHI_MASK 0x3f |
| 376 | #define AFS_UUID_VARIANT_STD 0x80 |
| 377 | u8 clock_seq_low; /* clock seq low */ |
| 378 | u8 node[6]; /* spatially unique node ID (MAC addr) */ |
| 379 | }; |
| 380 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 381 | /*****************************************************************************/ |
| 382 | /* |
| 383 | * callback.c |
| 384 | */ |
| 385 | extern void afs_init_callback_state(struct afs_server *); |
| 386 | extern void afs_broken_callback_work(struct work_struct *); |
| 387 | extern void afs_break_callbacks(struct afs_server *, size_t, |
| 388 | struct afs_callback[]); |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 389 | extern void afs_discard_callback_on_delete(struct afs_vnode *); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 390 | extern void afs_give_up_callback(struct afs_vnode *); |
| 391 | extern void afs_dispatch_give_up_callbacks(struct work_struct *); |
| 392 | extern void afs_flush_callback_breaks(struct afs_server *); |
| 393 | extern int __init afs_callback_update_init(void); |
David Howells | fbb3fcb | 2007-05-03 03:12:46 -0700 | [diff] [blame] | 394 | extern void afs_callback_update_kill(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | |
| 396 | /* |
| 397 | * cell.c |
| 398 | */ |
| 399 | extern struct rw_semaphore afs_proc_cells_sem; |
| 400 | extern struct list_head afs_proc_cells; |
| 401 | #ifdef AFS_CACHING_SUPPORT |
| 402 | extern struct cachefs_index_def afs_cache_cell_index_def; |
| 403 | #endif |
| 404 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 405 | #define afs_get_cell(C) do { atomic_inc(&(C)->usage); } while(0) |
| 406 | extern int afs_cell_init(char *); |
| 407 | extern struct afs_cell *afs_cell_create(const char *, char *); |
| 408 | extern struct afs_cell *afs_cell_lookup(const char *, unsigned); |
| 409 | extern struct afs_cell *afs_grab_cell(struct afs_cell *); |
| 410 | extern void afs_put_cell(struct afs_cell *); |
| 411 | extern void afs_cell_purge(void); |
| 412 | |
| 413 | /* |
| 414 | * cmservice.c |
| 415 | */ |
| 416 | extern bool afs_cm_incoming_call(struct afs_call *); |
| 417 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | /* |
| 419 | * dir.c |
| 420 | */ |
Arjan van de Ven | 754661f | 2007-02-12 00:55:38 -0800 | [diff] [blame] | 421 | extern const struct inode_operations afs_dir_inode_operations; |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 422 | extern const struct file_operations afs_dir_file_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 424 | extern int afs_permission(struct inode *, int, struct nameidata *); |
| 425 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | /* |
| 427 | * file.c |
| 428 | */ |
Christoph Hellwig | f5e54d6 | 2006-06-28 04:26:44 -0700 | [diff] [blame] | 429 | extern const struct address_space_operations afs_fs_aops; |
Arjan van de Ven | 754661f | 2007-02-12 00:55:38 -0800 | [diff] [blame] | 430 | extern const struct inode_operations afs_file_inode_operations; |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 431 | extern const struct file_operations afs_file_operations; |
| 432 | |
| 433 | extern int afs_open(struct inode *, struct file *); |
| 434 | extern int afs_release(struct inode *, struct file *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 437 | * fsclient.c |
| 438 | */ |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 439 | extern int afs_fs_fetch_file_status(struct afs_server *, struct key *, |
| 440 | struct afs_vnode *, struct afs_volsync *, |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 441 | const struct afs_wait_mode *); |
| 442 | extern int afs_fs_give_up_callbacks(struct afs_server *, |
| 443 | const struct afs_wait_mode *); |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 444 | extern int afs_fs_fetch_data(struct afs_server *, struct key *, |
| 445 | struct afs_vnode *, off_t, size_t, struct page *, |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 446 | const struct afs_wait_mode *); |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 447 | extern int afs_fs_create(struct afs_server *, struct key *, |
| 448 | struct afs_vnode *, const char *, umode_t, |
| 449 | struct afs_fid *, struct afs_file_status *, |
| 450 | struct afs_callback *, |
| 451 | const struct afs_wait_mode *); |
| 452 | extern int afs_fs_remove(struct afs_server *, struct key *, |
| 453 | struct afs_vnode *, const char *, bool, |
| 454 | const struct afs_wait_mode *); |
| 455 | extern int afs_fs_link(struct afs_server *, struct key *, struct afs_vnode *, |
| 456 | struct afs_vnode *, const char *, |
| 457 | const struct afs_wait_mode *); |
| 458 | extern int afs_fs_symlink(struct afs_server *, struct key *, |
| 459 | struct afs_vnode *, const char *, const char *, |
| 460 | struct afs_fid *, struct afs_file_status *, |
| 461 | const struct afs_wait_mode *); |
| 462 | extern int afs_fs_rename(struct afs_server *, struct key *, |
| 463 | struct afs_vnode *, const char *, |
| 464 | struct afs_vnode *, const char *, |
| 465 | const struct afs_wait_mode *); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 466 | |
| 467 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | * inode.c |
| 469 | */ |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 470 | extern struct inode *afs_iget(struct super_block *, struct key *, |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 471 | struct afs_fid *, struct afs_file_status *, |
| 472 | struct afs_callback *); |
David Howells | 416351f | 2007-05-09 02:33:45 -0700 | [diff] [blame^] | 473 | extern void afs_zap_data(struct afs_vnode *); |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 474 | extern int afs_validate(struct afs_vnode *, struct key *); |
David Howells | 416351f | 2007-05-09 02:33:45 -0700 | [diff] [blame^] | 475 | extern int afs_getattr(struct vfsmount *, struct dentry *, struct kstat *); |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 476 | extern void afs_clear_inode(struct inode *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | |
| 478 | /* |
| 479 | * main.c |
| 480 | */ |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 481 | extern struct afs_uuid afs_uuid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | #ifdef AFS_CACHING_SUPPORT |
| 483 | extern struct cachefs_netfs afs_cache_netfs; |
| 484 | #endif |
| 485 | |
| 486 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 487 | * misc.c |
| 488 | */ |
| 489 | extern int afs_abort_to_error(u32); |
| 490 | |
| 491 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | * mntpt.c |
| 493 | */ |
Arjan van de Ven | 754661f | 2007-02-12 00:55:38 -0800 | [diff] [blame] | 494 | extern const struct inode_operations afs_mntpt_inode_operations; |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 495 | extern const struct file_operations afs_mntpt_file_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | extern unsigned long afs_mntpt_expiry_timeout; |
| 497 | |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 498 | extern int afs_mntpt_check_symlink(struct afs_vnode *, struct key *); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 499 | extern void afs_mntpt_kill_timer(void); |
| 500 | extern void afs_umount_begin(struct vfsmount *, int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | |
| 502 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | * proc.c |
| 504 | */ |
| 505 | extern int afs_proc_init(void); |
| 506 | extern void afs_proc_cleanup(void); |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 507 | extern int afs_proc_cell_setup(struct afs_cell *); |
| 508 | extern void afs_proc_cell_remove(struct afs_cell *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 510 | /* |
| 511 | * rxrpc.c |
| 512 | */ |
| 513 | extern int afs_open_socket(void); |
| 514 | extern void afs_close_socket(void); |
| 515 | extern int afs_make_call(struct in_addr *, struct afs_call *, gfp_t, |
| 516 | const struct afs_wait_mode *); |
| 517 | extern struct afs_call *afs_alloc_flat_call(const struct afs_call_type *, |
| 518 | size_t, size_t); |
| 519 | extern void afs_flat_call_destructor(struct afs_call *); |
| 520 | extern void afs_transfer_reply(struct afs_call *, struct sk_buff *); |
| 521 | extern void afs_send_empty_reply(struct afs_call *); |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 522 | extern void afs_send_simple_reply(struct afs_call *, const void *, size_t); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 523 | extern int afs_extract_data(struct afs_call *, struct sk_buff *, bool, void *, |
| 524 | size_t); |
| 525 | |
| 526 | /* |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 527 | * security.c |
| 528 | */ |
| 529 | extern void afs_clear_permits(struct afs_vnode *); |
| 530 | extern void afs_cache_permit(struct afs_vnode *, struct key *, long); |
David Howells | 416351f | 2007-05-09 02:33:45 -0700 | [diff] [blame^] | 531 | extern void afs_zap_permits(struct rcu_head *); |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 532 | extern struct key *afs_request_key(struct afs_cell *); |
| 533 | extern int afs_permission(struct inode *, int, struct nameidata *); |
| 534 | |
| 535 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 536 | * server.c |
| 537 | */ |
| 538 | extern spinlock_t afs_server_peer_lock; |
| 539 | |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 540 | #define afs_get_server(S) \ |
| 541 | do { \ |
| 542 | _debug("GET SERVER %d", atomic_read(&(S)->usage)); \ |
| 543 | atomic_inc(&(S)->usage); \ |
| 544 | } while(0) |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 545 | |
| 546 | extern struct afs_server *afs_lookup_server(struct afs_cell *, |
| 547 | const struct in_addr *); |
| 548 | extern struct afs_server *afs_find_server(const struct in_addr *); |
| 549 | extern void afs_put_server(struct afs_server *); |
| 550 | extern void __exit afs_purge_servers(void); |
| 551 | |
| 552 | /* |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 553 | * super.c |
| 554 | */ |
| 555 | extern int afs_fs_init(void); |
| 556 | extern void afs_fs_exit(void); |
| 557 | |
| 558 | /* |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 559 | * use-rtnetlink.c |
| 560 | */ |
| 561 | extern int afs_get_ipv4_interfaces(struct afs_interface *, size_t, bool); |
David Howells | ec9c948 | 2007-05-03 03:29:41 -0700 | [diff] [blame] | 562 | extern int afs_get_MAC_address(u8 *, size_t); |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 563 | |
| 564 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 565 | * vlclient.c |
| 566 | */ |
| 567 | #ifdef AFS_CACHING_SUPPORT |
| 568 | extern struct cachefs_index_def afs_vlocation_cache_index_def; |
| 569 | #endif |
| 570 | |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 571 | extern int afs_vl_get_entry_by_name(struct in_addr *, struct key *, |
| 572 | const char *, struct afs_cache_vlocation *, |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 573 | const struct afs_wait_mode *); |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 574 | extern int afs_vl_get_entry_by_id(struct in_addr *, struct key *, |
| 575 | afs_volid_t, afs_voltype_t, |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 576 | struct afs_cache_vlocation *, |
| 577 | const struct afs_wait_mode *); |
| 578 | |
| 579 | /* |
| 580 | * vlocation.c |
| 581 | */ |
| 582 | #define afs_get_vlocation(V) do { atomic_inc(&(V)->usage); } while(0) |
| 583 | |
| 584 | extern int __init afs_vlocation_update_init(void); |
| 585 | extern struct afs_vlocation *afs_vlocation_lookup(struct afs_cell *, |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 586 | struct key *, |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 587 | const char *, size_t); |
| 588 | extern void afs_put_vlocation(struct afs_vlocation *); |
David Howells | fbb3fcb | 2007-05-03 03:12:46 -0700 | [diff] [blame] | 589 | extern void afs_vlocation_purge(void); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 590 | |
| 591 | /* |
| 592 | * vnode.c |
| 593 | */ |
| 594 | #ifdef AFS_CACHING_SUPPORT |
| 595 | extern struct cachefs_index_def afs_vnode_cache_index_def; |
| 596 | #endif |
| 597 | |
| 598 | extern struct afs_timer_ops afs_vnode_cb_timed_out_ops; |
| 599 | |
| 600 | static inline struct afs_vnode *AFS_FS_I(struct inode *inode) |
| 601 | { |
| 602 | return container_of(inode, struct afs_vnode, vfs_inode); |
| 603 | } |
| 604 | |
| 605 | static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode) |
| 606 | { |
| 607 | return &vnode->vfs_inode; |
| 608 | } |
| 609 | |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 610 | extern void afs_vnode_finalise_status_update(struct afs_vnode *, |
| 611 | struct afs_server *); |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 612 | extern int afs_vnode_fetch_status(struct afs_vnode *, struct afs_vnode *, |
| 613 | struct key *); |
| 614 | extern int afs_vnode_fetch_data(struct afs_vnode *, struct key *, |
| 615 | off_t, size_t, struct page *); |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 616 | extern int afs_vnode_create(struct afs_vnode *, struct key *, const char *, |
| 617 | umode_t, struct afs_fid *, struct afs_file_status *, |
| 618 | struct afs_callback *, struct afs_server **); |
| 619 | extern int afs_vnode_remove(struct afs_vnode *, struct key *, const char *, |
| 620 | bool); |
| 621 | extern int afs_vnode_link(struct afs_vnode *, struct afs_vnode *, struct key *, |
| 622 | const char *); |
| 623 | extern int afs_vnode_symlink(struct afs_vnode *, struct key *, const char *, |
| 624 | const char *, struct afs_fid *, |
| 625 | struct afs_file_status *, struct afs_server **); |
| 626 | extern int afs_vnode_rename(struct afs_vnode *, struct afs_vnode *, |
| 627 | struct key *, const char *, const char *); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 628 | |
| 629 | /* |
| 630 | * volume.c |
| 631 | */ |
| 632 | #ifdef AFS_CACHING_SUPPORT |
| 633 | extern struct cachefs_index_def afs_volume_cache_index_def; |
| 634 | #endif |
| 635 | |
| 636 | #define afs_get_volume(V) do { atomic_inc(&(V)->usage); } while(0) |
| 637 | |
| 638 | extern void afs_put_volume(struct afs_volume *); |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 639 | extern struct afs_volume *afs_volume_lookup(struct afs_mount_params *); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 640 | extern struct afs_server *afs_volume_pick_fileserver(struct afs_vnode *); |
| 641 | extern int afs_volume_release_fileserver(struct afs_vnode *, |
| 642 | struct afs_server *, int); |
| 643 | |
| 644 | /*****************************************************************************/ |
| 645 | /* |
| 646 | * debug tracing |
| 647 | */ |
| 648 | extern unsigned afs_debug; |
| 649 | |
| 650 | #define dbgprintk(FMT,...) \ |
| 651 | printk("[%x%-6.6s] "FMT"\n", smp_processor_id(), current->comm ,##__VA_ARGS__) |
| 652 | |
| 653 | /* make sure we maintain the format strings, even when debugging is disabled */ |
| 654 | static inline __attribute__((format(printf,1,2))) |
| 655 | void _dbprintk(const char *fmt, ...) |
| 656 | { |
| 657 | } |
| 658 | |
| 659 | #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__FUNCTION__ ,##__VA_ARGS__) |
| 660 | #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__FUNCTION__ ,##__VA_ARGS__) |
| 661 | #define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__) |
| 662 | |
| 663 | |
| 664 | #if defined(__KDEBUG) |
| 665 | #define _enter(FMT,...) kenter(FMT,##__VA_ARGS__) |
| 666 | #define _leave(FMT,...) kleave(FMT,##__VA_ARGS__) |
| 667 | #define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__) |
| 668 | |
| 669 | #elif defined(CONFIG_AFS_DEBUG) |
| 670 | #define AFS_DEBUG_KENTER 0x01 |
| 671 | #define AFS_DEBUG_KLEAVE 0x02 |
| 672 | #define AFS_DEBUG_KDEBUG 0x04 |
| 673 | |
| 674 | #define _enter(FMT,...) \ |
| 675 | do { \ |
| 676 | if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \ |
| 677 | kenter(FMT,##__VA_ARGS__); \ |
| 678 | } while (0) |
| 679 | |
| 680 | #define _leave(FMT,...) \ |
| 681 | do { \ |
| 682 | if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \ |
| 683 | kleave(FMT,##__VA_ARGS__); \ |
| 684 | } while (0) |
| 685 | |
| 686 | #define _debug(FMT,...) \ |
| 687 | do { \ |
| 688 | if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \ |
| 689 | kdebug(FMT,##__VA_ARGS__); \ |
| 690 | } while (0) |
| 691 | |
| 692 | #else |
| 693 | #define _enter(FMT,...) _dbprintk("==> %s("FMT")",__FUNCTION__ ,##__VA_ARGS__) |
| 694 | #define _leave(FMT,...) _dbprintk("<== %s()"FMT"",__FUNCTION__ ,##__VA_ARGS__) |
| 695 | #define _debug(FMT,...) _dbprintk(" "FMT ,##__VA_ARGS__) |
| 696 | #endif |
| 697 | |
| 698 | /* |
| 699 | * debug assertion checking |
| 700 | */ |
| 701 | #if 1 // defined(__KDEBUGALL) |
| 702 | |
| 703 | #define ASSERT(X) \ |
| 704 | do { \ |
| 705 | if (unlikely(!(X))) { \ |
| 706 | printk(KERN_ERR "\n"); \ |
| 707 | printk(KERN_ERR "AFS: Assertion failed\n"); \ |
| 708 | BUG(); \ |
| 709 | } \ |
| 710 | } while(0) |
| 711 | |
| 712 | #define ASSERTCMP(X, OP, Y) \ |
| 713 | do { \ |
| 714 | if (unlikely(!((X) OP (Y)))) { \ |
| 715 | printk(KERN_ERR "\n"); \ |
| 716 | printk(KERN_ERR "AFS: Assertion failed\n"); \ |
| 717 | printk(KERN_ERR "%lu " #OP " %lu is false\n", \ |
| 718 | (unsigned long)(X), (unsigned long)(Y)); \ |
| 719 | printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ |
| 720 | (unsigned long)(X), (unsigned long)(Y)); \ |
| 721 | BUG(); \ |
| 722 | } \ |
| 723 | } while(0) |
| 724 | |
David Howells | 416351f | 2007-05-09 02:33:45 -0700 | [diff] [blame^] | 725 | #define ASSERTRANGE(L, OP1, N, OP2, H) \ |
| 726 | do { \ |
| 727 | if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) { \ |
| 728 | printk(KERN_ERR "\n"); \ |
| 729 | printk(KERN_ERR "AFS: Assertion failed\n"); \ |
| 730 | printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n", \ |
| 731 | (unsigned long)(L), (unsigned long)(N), \ |
| 732 | (unsigned long)(H)); \ |
| 733 | printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \ |
| 734 | (unsigned long)(L), (unsigned long)(N), \ |
| 735 | (unsigned long)(H)); \ |
| 736 | BUG(); \ |
| 737 | } \ |
| 738 | } while(0) |
| 739 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 740 | #define ASSERTIF(C, X) \ |
| 741 | do { \ |
| 742 | if (unlikely((C) && !(X))) { \ |
| 743 | printk(KERN_ERR "\n"); \ |
| 744 | printk(KERN_ERR "AFS: Assertion failed\n"); \ |
| 745 | BUG(); \ |
| 746 | } \ |
| 747 | } while(0) |
| 748 | |
| 749 | #define ASSERTIFCMP(C, X, OP, Y) \ |
| 750 | do { \ |
| 751 | if (unlikely((C) && !((X) OP (Y)))) { \ |
| 752 | printk(KERN_ERR "\n"); \ |
| 753 | printk(KERN_ERR "AFS: Assertion failed\n"); \ |
| 754 | printk(KERN_ERR "%lu " #OP " %lu is false\n", \ |
| 755 | (unsigned long)(X), (unsigned long)(Y)); \ |
| 756 | printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ |
| 757 | (unsigned long)(X), (unsigned long)(Y)); \ |
| 758 | BUG(); \ |
| 759 | } \ |
| 760 | } while(0) |
| 761 | |
| 762 | #else |
| 763 | |
| 764 | #define ASSERT(X) \ |
| 765 | do { \ |
| 766 | } while(0) |
| 767 | |
| 768 | #define ASSERTCMP(X, OP, Y) \ |
| 769 | do { \ |
| 770 | } while(0) |
| 771 | |
David Howells | 416351f | 2007-05-09 02:33:45 -0700 | [diff] [blame^] | 772 | #define ASSERTRANGE(L, OP1, N, OP2, H) \ |
| 773 | do { \ |
| 774 | } while(0) |
| 775 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 776 | #define ASSERTIF(C, X) \ |
| 777 | do { \ |
| 778 | } while(0) |
| 779 | |
| 780 | #define ASSERTIFCMP(C, X, OP, Y) \ |
| 781 | do { \ |
| 782 | } while(0) |
| 783 | |
| 784 | #endif /* __KDEBUGALL */ |