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> |
| 18 | #include "afs.h" |
| 19 | #include "afs_vl.h" |
| 20 | |
| 21 | #define AFS_CELL_MAX_ADDRS 15 |
| 22 | |
| 23 | struct afs_call; |
| 24 | |
| 25 | typedef enum { |
| 26 | AFS_VL_NEW, /* new, uninitialised record */ |
| 27 | AFS_VL_CREATING, /* creating record */ |
| 28 | AFS_VL_VALID, /* record is pending */ |
| 29 | AFS_VL_NO_VOLUME, /* no such volume available */ |
| 30 | AFS_VL_UPDATING, /* update in progress */ |
| 31 | AFS_VL_VOLUME_DELETED, /* volume was deleted */ |
| 32 | AFS_VL_UNCERTAIN, /* uncertain state (update failed) */ |
| 33 | } __attribute__((packed)) afs_vlocation_state_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame^] | 36 | * definition of how to wait for the completion of an operation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame^] | 38 | struct afs_wait_mode { |
| 39 | /* RxRPC received message notification */ |
| 40 | void (*rx_wakeup)(struct afs_call *call); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame^] | 42 | /* synchronous call waiter and call dispatched notification */ |
| 43 | int (*wait)(struct afs_call *call); |
| 44 | |
| 45 | /* asynchronous call completion */ |
| 46 | void (*async_complete)(void *reply, int error); |
| 47 | }; |
| 48 | |
| 49 | extern const struct afs_wait_mode afs_sync_call; |
| 50 | extern const struct afs_wait_mode afs_async_call; |
| 51 | |
| 52 | /* |
| 53 | * a record of an in-progress RxRPC call |
| 54 | */ |
| 55 | struct afs_call { |
| 56 | const struct afs_call_type *type; /* type of call */ |
| 57 | const struct afs_wait_mode *wait_mode; /* completion wait mode */ |
| 58 | wait_queue_head_t waitq; /* processes awaiting completion */ |
| 59 | struct work_struct async_work; /* asynchronous work processor */ |
| 60 | struct work_struct work; /* actual work processor */ |
| 61 | struct sk_buff_head rx_queue; /* received packets */ |
| 62 | struct rxrpc_call *rxcall; /* RxRPC call handle */ |
| 63 | struct key *key; /* security for this call */ |
| 64 | struct afs_server *server; /* server affected by incoming CM call */ |
| 65 | void *request; /* request data (first part) */ |
| 66 | void *request2; /* request data (second part) */ |
| 67 | void *buffer; /* reply receive buffer */ |
| 68 | void *reply; /* reply buffer (first part) */ |
| 69 | void *reply2; /* reply buffer (second part) */ |
| 70 | void *reply3; /* reply buffer (third part) */ |
| 71 | enum { /* call state */ |
| 72 | AFS_CALL_REQUESTING, /* request is being sent for outgoing call */ |
| 73 | AFS_CALL_AWAIT_REPLY, /* awaiting reply to outgoing call */ |
| 74 | AFS_CALL_AWAIT_OP_ID, /* awaiting op ID on incoming call */ |
| 75 | AFS_CALL_AWAIT_REQUEST, /* awaiting request data on incoming call */ |
| 76 | AFS_CALL_REPLYING, /* replying to incoming call */ |
| 77 | AFS_CALL_AWAIT_ACK, /* awaiting final ACK of incoming call */ |
| 78 | AFS_CALL_COMPLETE, /* successfully completed */ |
| 79 | AFS_CALL_BUSY, /* server was busy */ |
| 80 | AFS_CALL_ABORTED, /* call was aborted */ |
| 81 | AFS_CALL_ERROR, /* call failed due to error */ |
| 82 | } state; |
| 83 | int error; /* error code */ |
| 84 | unsigned request_size; /* size of request data */ |
| 85 | unsigned reply_max; /* maximum size of reply */ |
| 86 | unsigned reply_size; /* current size of reply */ |
| 87 | unsigned short offset; /* offset into received data store */ |
| 88 | unsigned char unmarshall; /* unmarshalling phase */ |
| 89 | bool incoming; /* T if incoming call */ |
| 90 | u16 service_id; /* RxRPC service ID to call */ |
| 91 | __be16 port; /* target UDP port */ |
| 92 | __be32 operation_ID; /* operation ID for an incoming call */ |
| 93 | u32 count; /* count for use in unmarshalling */ |
| 94 | __be32 tmp; /* place to extract temporary data */ |
| 95 | }; |
| 96 | |
| 97 | struct afs_call_type { |
| 98 | /* deliver request or reply data to an call |
| 99 | * - returning an error will cause the call to be aborted |
| 100 | */ |
| 101 | int (*deliver)(struct afs_call *call, struct sk_buff *skb, |
| 102 | bool last); |
| 103 | |
| 104 | /* map an abort code to an error number */ |
| 105 | int (*abort_to_error)(u32 abort_code); |
| 106 | |
| 107 | /* clean up a call */ |
| 108 | void (*destructor)(struct afs_call *call); |
| 109 | }; |
| 110 | |
| 111 | /* |
| 112 | * AFS superblock private data |
| 113 | * - there's one superblock per volume |
| 114 | */ |
| 115 | struct afs_super_info { |
| 116 | struct afs_volume *volume; /* volume record */ |
| 117 | char rwparent; /* T if parent is R/W AFS volume */ |
| 118 | }; |
| 119 | |
| 120 | static inline struct afs_super_info *AFS_FS_S(struct super_block *sb) |
| 121 | { |
| 122 | return sb->s_fs_info; |
| 123 | } |
| 124 | |
| 125 | extern struct file_system_type afs_fs_type; |
| 126 | |
| 127 | /* |
| 128 | * entry in the cached cell catalogue |
| 129 | */ |
| 130 | struct afs_cache_cell { |
| 131 | char name[64]; /* cell name (padded with NULs) */ |
| 132 | struct in_addr vl_servers[15]; /* cached cell VL servers */ |
| 133 | }; |
| 134 | |
| 135 | /* |
| 136 | * AFS cell record |
| 137 | */ |
| 138 | struct afs_cell { |
| 139 | atomic_t usage; |
| 140 | struct list_head link; /* main cell list link */ |
| 141 | struct list_head proc_link; /* /proc cell list link */ |
| 142 | struct proc_dir_entry *proc_dir; /* /proc dir for this cell */ |
| 143 | #ifdef AFS_CACHING_SUPPORT |
| 144 | struct cachefs_cookie *cache; /* caching cookie */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | #endif |
| 146 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame^] | 147 | /* server record management */ |
| 148 | rwlock_t servers_lock; /* active server list lock */ |
| 149 | struct list_head servers; /* active server list */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame^] | 151 | /* volume location record management */ |
| 152 | struct rw_semaphore vl_sem; /* volume management serialisation semaphore */ |
| 153 | struct list_head vl_list; /* cell's active VL record list */ |
| 154 | spinlock_t vl_lock; /* vl_list lock */ |
| 155 | unsigned short vl_naddrs; /* number of VL servers in addr list */ |
| 156 | unsigned short vl_curr_svix; /* current server index */ |
| 157 | struct in_addr vl_addrs[AFS_CELL_MAX_ADDRS]; /* cell VL server addresses */ |
| 158 | |
| 159 | char name[0]; /* cell name - must go last */ |
| 160 | }; |
| 161 | |
| 162 | /* |
| 163 | * entry in the cached volume location catalogue |
| 164 | */ |
| 165 | struct afs_cache_vlocation { |
| 166 | uint8_t name[64 + 1]; /* volume name (lowercase, padded with NULs) */ |
| 167 | uint8_t nservers; /* number of entries used in servers[] */ |
| 168 | uint8_t vidmask; /* voltype mask for vid[] */ |
| 169 | uint8_t srvtmask[8]; /* voltype masks for servers[] */ |
| 170 | #define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */ |
| 171 | #define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */ |
| 172 | #define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */ |
| 173 | |
| 174 | afs_volid_t vid[3]; /* volume IDs for R/W, R/O and Bak volumes */ |
| 175 | struct in_addr servers[8]; /* fileserver addresses */ |
| 176 | time_t rtime; /* last retrieval time */ |
| 177 | }; |
| 178 | |
| 179 | /* |
| 180 | * volume -> vnode hash table entry |
| 181 | */ |
| 182 | struct afs_cache_vhash { |
| 183 | afs_voltype_t vtype; /* which volume variation */ |
| 184 | uint8_t hash_bucket; /* which hash bucket this represents */ |
| 185 | } __attribute__((packed)); |
| 186 | |
| 187 | /* |
| 188 | * AFS volume location record |
| 189 | */ |
| 190 | struct afs_vlocation { |
| 191 | atomic_t usage; |
| 192 | time_t time_of_death; /* time at which put reduced usage to 0 */ |
| 193 | struct list_head link; /* link in cell volume location list */ |
| 194 | struct list_head grave; /* link in master graveyard list */ |
| 195 | struct list_head update; /* link in master update list */ |
| 196 | struct afs_cell *cell; /* cell to which volume belongs */ |
| 197 | #ifdef AFS_CACHING_SUPPORT |
| 198 | struct cachefs_cookie *cache; /* caching cookie */ |
| 199 | #endif |
| 200 | struct afs_cache_vlocation vldb; /* volume information DB record */ |
| 201 | struct afs_volume *vols[3]; /* volume access record pointer (index by type) */ |
| 202 | wait_queue_head_t waitq; /* status change waitqueue */ |
| 203 | time_t update_at; /* time at which record should be updated */ |
| 204 | rwlock_t lock; /* access lock */ |
| 205 | afs_vlocation_state_t state; /* volume location state */ |
| 206 | unsigned short upd_rej_cnt; /* ENOMEDIUM count during update */ |
| 207 | unsigned short upd_busy_cnt; /* EBUSY count during update */ |
| 208 | bool valid; /* T if valid */ |
| 209 | }; |
| 210 | |
| 211 | /* |
| 212 | * AFS fileserver record |
| 213 | */ |
| 214 | struct afs_server { |
| 215 | atomic_t usage; |
| 216 | time_t time_of_death; /* time at which put reduced usage to 0 */ |
| 217 | struct in_addr addr; /* server address */ |
| 218 | struct afs_cell *cell; /* cell in which server resides */ |
| 219 | struct list_head link; /* link in cell's server list */ |
| 220 | struct list_head grave; /* link in master graveyard list */ |
| 221 | struct rb_node master_rb; /* link in master by-addr tree */ |
| 222 | struct rw_semaphore sem; /* access lock */ |
| 223 | |
| 224 | /* file service access */ |
| 225 | struct rb_root fs_vnodes; /* vnodes backed by this server (ordered by FID) */ |
| 226 | unsigned long fs_act_jif; /* time at which last activity occurred */ |
| 227 | unsigned long fs_dead_jif; /* time at which no longer to be considered dead */ |
| 228 | spinlock_t fs_lock; /* access lock */ |
| 229 | int fs_state; /* 0 or reason FS currently marked dead (-errno) */ |
| 230 | |
| 231 | /* callback promise management */ |
| 232 | struct rb_root cb_promises; /* vnode expiration list (ordered earliest first) */ |
| 233 | struct delayed_work cb_updater; /* callback updater */ |
| 234 | struct delayed_work cb_break_work; /* collected break dispatcher */ |
| 235 | wait_queue_head_t cb_break_waitq; /* space available in cb_break waitqueue */ |
| 236 | spinlock_t cb_lock; /* access lock */ |
| 237 | struct afs_callback cb_break[64]; /* ring of callbacks awaiting breaking */ |
| 238 | atomic_t cb_break_n; /* number of pending breaks */ |
| 239 | u8 cb_break_head; /* head of callback breaking ring */ |
| 240 | u8 cb_break_tail; /* tail of callback breaking ring */ |
| 241 | }; |
| 242 | |
| 243 | /* |
| 244 | * AFS volume access record |
| 245 | */ |
| 246 | struct afs_volume { |
| 247 | atomic_t usage; |
| 248 | struct afs_cell *cell; /* cell to which belongs (unrefd ptr) */ |
| 249 | struct afs_vlocation *vlocation; /* volume location */ |
| 250 | #ifdef AFS_CACHING_SUPPORT |
| 251 | struct cachefs_cookie *cache; /* caching cookie */ |
| 252 | #endif |
| 253 | afs_volid_t vid; /* volume ID */ |
| 254 | afs_voltype_t type; /* type of volume */ |
| 255 | char type_force; /* force volume type (suppress R/O -> R/W) */ |
| 256 | unsigned short nservers; /* number of server slots filled */ |
| 257 | unsigned short rjservers; /* number of servers discarded due to -ENOMEDIUM */ |
| 258 | struct afs_server *servers[8]; /* servers on which volume resides (ordered) */ |
| 259 | struct rw_semaphore server_sem; /* lock for accessing current server */ |
| 260 | }; |
| 261 | |
| 262 | /* |
| 263 | * vnode catalogue entry |
| 264 | */ |
| 265 | struct afs_cache_vnode { |
| 266 | afs_vnodeid_t vnode_id; /* vnode ID */ |
| 267 | unsigned vnode_unique; /* vnode ID uniquifier */ |
| 268 | afs_dataversion_t data_version; /* data version */ |
| 269 | }; |
| 270 | |
| 271 | /* |
| 272 | * AFS inode private data |
| 273 | */ |
| 274 | struct afs_vnode { |
| 275 | struct inode vfs_inode; /* the VFS's inode record */ |
| 276 | |
| 277 | struct afs_volume *volume; /* volume on which vnode resides */ |
| 278 | struct afs_server *server; /* server currently supplying this file */ |
| 279 | struct afs_fid fid; /* the file identifier for this inode */ |
| 280 | struct afs_file_status status; /* AFS status info for this file */ |
| 281 | #ifdef AFS_CACHING_SUPPORT |
| 282 | struct cachefs_cookie *cache; /* caching cookie */ |
| 283 | #endif |
| 284 | |
| 285 | wait_queue_head_t update_waitq; /* status fetch waitqueue */ |
| 286 | unsigned update_cnt; /* number of outstanding ops that will update the |
| 287 | * status */ |
| 288 | spinlock_t lock; /* waitqueue/flags lock */ |
| 289 | unsigned long flags; |
| 290 | #define AFS_VNODE_CB_BROKEN 0 /* set if vnode's callback was broken */ |
| 291 | #define AFS_VNODE_CHANGED 1 /* set if vnode's metadata changed */ |
| 292 | #define AFS_VNODE_MODIFIED 2 /* set if vnode's data modified */ |
| 293 | #define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */ |
| 294 | #define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */ |
| 295 | #define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */ |
| 296 | #define AFS_VNODE_DIR_CHANGED 6 /* set if vnode's parent dir metadata changed */ |
| 297 | #define AFS_VNODE_DIR_MODIFIED 7 /* set if vnode's parent dir data modified */ |
| 298 | |
| 299 | /* outstanding callback notification on this file */ |
| 300 | struct rb_node server_rb; /* link in server->fs_vnodes */ |
| 301 | struct rb_node cb_promise; /* link in server->cb_promises */ |
| 302 | struct work_struct cb_broken_work; /* work to be done on callback break */ |
| 303 | struct mutex cb_broken_lock; /* lock against multiple attempts to fix break */ |
| 304 | // struct list_head cb_hash_link; /* link in master callback hash */ |
| 305 | time_t cb_expires; /* time at which callback expires */ |
| 306 | time_t cb_expires_at; /* time used to order cb_promise */ |
| 307 | unsigned cb_version; /* callback version */ |
| 308 | unsigned cb_expiry; /* callback expiry time */ |
| 309 | afs_callback_type_t cb_type; /* type of callback */ |
| 310 | bool cb_promised; /* true if promise still holds */ |
| 311 | }; |
| 312 | |
| 313 | /*****************************************************************************/ |
| 314 | /* |
| 315 | * callback.c |
| 316 | */ |
| 317 | extern void afs_init_callback_state(struct afs_server *); |
| 318 | extern void afs_broken_callback_work(struct work_struct *); |
| 319 | extern void afs_break_callbacks(struct afs_server *, size_t, |
| 320 | struct afs_callback[]); |
| 321 | extern void afs_give_up_callback(struct afs_vnode *); |
| 322 | extern void afs_dispatch_give_up_callbacks(struct work_struct *); |
| 323 | extern void afs_flush_callback_breaks(struct afs_server *); |
| 324 | extern int __init afs_callback_update_init(void); |
| 325 | extern void __exit afs_callback_update_kill(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | |
| 327 | /* |
| 328 | * cell.c |
| 329 | */ |
| 330 | extern struct rw_semaphore afs_proc_cells_sem; |
| 331 | extern struct list_head afs_proc_cells; |
| 332 | #ifdef AFS_CACHING_SUPPORT |
| 333 | extern struct cachefs_index_def afs_cache_cell_index_def; |
| 334 | #endif |
| 335 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame^] | 336 | #define afs_get_cell(C) do { atomic_inc(&(C)->usage); } while(0) |
| 337 | extern int afs_cell_init(char *); |
| 338 | extern struct afs_cell *afs_cell_create(const char *, char *); |
| 339 | extern struct afs_cell *afs_cell_lookup(const char *, unsigned); |
| 340 | extern struct afs_cell *afs_grab_cell(struct afs_cell *); |
| 341 | extern void afs_put_cell(struct afs_cell *); |
| 342 | extern void afs_cell_purge(void); |
| 343 | |
| 344 | /* |
| 345 | * cmservice.c |
| 346 | */ |
| 347 | extern bool afs_cm_incoming_call(struct afs_call *); |
| 348 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | /* |
| 350 | * dir.c |
| 351 | */ |
Arjan van de Ven | 754661f | 2007-02-12 00:55:38 -0800 | [diff] [blame] | 352 | extern const struct inode_operations afs_dir_inode_operations; |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 353 | extern const struct file_operations afs_dir_file_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | |
| 355 | /* |
| 356 | * file.c |
| 357 | */ |
Christoph Hellwig | f5e54d6 | 2006-06-28 04:26:44 -0700 | [diff] [blame] | 358 | extern const struct address_space_operations afs_fs_aops; |
Arjan van de Ven | 754661f | 2007-02-12 00:55:38 -0800 | [diff] [blame] | 359 | extern const struct inode_operations afs_file_inode_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | |
| 361 | #ifdef AFS_CACHING_SUPPORT |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 362 | extern int afs_cache_get_page_cookie(struct page *, struct cachefs_page **); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | #endif |
| 364 | |
| 365 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame^] | 366 | * fsclient.c |
| 367 | */ |
| 368 | extern int afs_fs_fetch_file_status(struct afs_server *, |
| 369 | struct afs_vnode *, |
| 370 | struct afs_volsync *, |
| 371 | const struct afs_wait_mode *); |
| 372 | extern int afs_fs_give_up_callbacks(struct afs_server *, |
| 373 | const struct afs_wait_mode *); |
| 374 | extern int afs_fs_fetch_data(struct afs_server *, struct afs_vnode *, off_t, |
| 375 | size_t, struct page *, struct afs_volsync *, |
| 376 | const struct afs_wait_mode *); |
| 377 | |
| 378 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | * inode.c |
| 380 | */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame^] | 381 | extern struct inode *afs_iget(struct super_block *, struct afs_fid *); |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 382 | extern int afs_inode_getattr(struct vfsmount *, struct dentry *, |
| 383 | struct kstat *); |
| 384 | extern void afs_clear_inode(struct inode *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | |
| 386 | /* |
| 387 | * main.c |
| 388 | */ |
| 389 | #ifdef AFS_CACHING_SUPPORT |
| 390 | extern struct cachefs_netfs afs_cache_netfs; |
| 391 | #endif |
| 392 | |
| 393 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame^] | 394 | * misc.c |
| 395 | */ |
| 396 | extern int afs_abort_to_error(u32); |
| 397 | |
| 398 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | * mntpt.c |
| 400 | */ |
Arjan van de Ven | 754661f | 2007-02-12 00:55:38 -0800 | [diff] [blame] | 401 | extern const struct inode_operations afs_mntpt_inode_operations; |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 402 | extern const struct file_operations afs_mntpt_file_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | extern unsigned long afs_mntpt_expiry_timeout; |
| 404 | |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 405 | extern int afs_mntpt_check_symlink(struct afs_vnode *); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame^] | 406 | extern void afs_mntpt_kill_timer(void); |
| 407 | extern void afs_umount_begin(struct vfsmount *, int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | |
| 409 | /* |
| 410 | * super.c |
| 411 | */ |
| 412 | extern int afs_fs_init(void); |
| 413 | extern void afs_fs_exit(void); |
| 414 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | /* |
| 416 | * proc.c |
| 417 | */ |
| 418 | extern int afs_proc_init(void); |
| 419 | extern void afs_proc_cleanup(void); |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 420 | extern int afs_proc_cell_setup(struct afs_cell *); |
| 421 | extern void afs_proc_cell_remove(struct afs_cell *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame^] | 423 | /* |
| 424 | * rxrpc.c |
| 425 | */ |
| 426 | extern int afs_open_socket(void); |
| 427 | extern void afs_close_socket(void); |
| 428 | extern int afs_make_call(struct in_addr *, struct afs_call *, gfp_t, |
| 429 | const struct afs_wait_mode *); |
| 430 | extern struct afs_call *afs_alloc_flat_call(const struct afs_call_type *, |
| 431 | size_t, size_t); |
| 432 | extern void afs_flat_call_destructor(struct afs_call *); |
| 433 | extern void afs_transfer_reply(struct afs_call *, struct sk_buff *); |
| 434 | extern void afs_send_empty_reply(struct afs_call *); |
| 435 | extern int afs_extract_data(struct afs_call *, struct sk_buff *, bool, void *, |
| 436 | size_t); |
| 437 | |
| 438 | /* |
| 439 | * server.c |
| 440 | */ |
| 441 | extern spinlock_t afs_server_peer_lock; |
| 442 | |
| 443 | #define afs_get_server(S) do { atomic_inc(&(S)->usage); } while(0) |
| 444 | |
| 445 | extern struct afs_server *afs_lookup_server(struct afs_cell *, |
| 446 | const struct in_addr *); |
| 447 | extern struct afs_server *afs_find_server(const struct in_addr *); |
| 448 | extern void afs_put_server(struct afs_server *); |
| 449 | extern void __exit afs_purge_servers(void); |
| 450 | |
| 451 | /* |
| 452 | * vlclient.c |
| 453 | */ |
| 454 | #ifdef AFS_CACHING_SUPPORT |
| 455 | extern struct cachefs_index_def afs_vlocation_cache_index_def; |
| 456 | #endif |
| 457 | |
| 458 | extern int afs_vl_get_entry_by_name(struct in_addr *, const char *, |
| 459 | struct afs_cache_vlocation *, |
| 460 | const struct afs_wait_mode *); |
| 461 | extern int afs_vl_get_entry_by_id(struct in_addr *, afs_volid_t, afs_voltype_t, |
| 462 | struct afs_cache_vlocation *, |
| 463 | const struct afs_wait_mode *); |
| 464 | |
| 465 | /* |
| 466 | * vlocation.c |
| 467 | */ |
| 468 | #define afs_get_vlocation(V) do { atomic_inc(&(V)->usage); } while(0) |
| 469 | |
| 470 | extern int __init afs_vlocation_update_init(void); |
| 471 | extern struct afs_vlocation *afs_vlocation_lookup(struct afs_cell *, |
| 472 | const char *, size_t); |
| 473 | extern void afs_put_vlocation(struct afs_vlocation *); |
| 474 | extern void __exit afs_vlocation_purge(void); |
| 475 | |
| 476 | /* |
| 477 | * vnode.c |
| 478 | */ |
| 479 | #ifdef AFS_CACHING_SUPPORT |
| 480 | extern struct cachefs_index_def afs_vnode_cache_index_def; |
| 481 | #endif |
| 482 | |
| 483 | extern struct afs_timer_ops afs_vnode_cb_timed_out_ops; |
| 484 | |
| 485 | static inline struct afs_vnode *AFS_FS_I(struct inode *inode) |
| 486 | { |
| 487 | return container_of(inode, struct afs_vnode, vfs_inode); |
| 488 | } |
| 489 | |
| 490 | static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode) |
| 491 | { |
| 492 | return &vnode->vfs_inode; |
| 493 | } |
| 494 | |
| 495 | extern int afs_vnode_fetch_status(struct afs_vnode *); |
| 496 | extern int afs_vnode_fetch_data(struct afs_vnode *vnode, off_t, size_t, |
| 497 | struct page *); |
| 498 | |
| 499 | /* |
| 500 | * volume.c |
| 501 | */ |
| 502 | #ifdef AFS_CACHING_SUPPORT |
| 503 | extern struct cachefs_index_def afs_volume_cache_index_def; |
| 504 | #endif |
| 505 | |
| 506 | #define afs_get_volume(V) do { atomic_inc(&(V)->usage); } while(0) |
| 507 | |
| 508 | extern void afs_put_volume(struct afs_volume *); |
| 509 | extern struct afs_volume *afs_volume_lookup(const char *, struct afs_cell *, |
| 510 | int); |
| 511 | extern struct afs_server *afs_volume_pick_fileserver(struct afs_vnode *); |
| 512 | extern int afs_volume_release_fileserver(struct afs_vnode *, |
| 513 | struct afs_server *, int); |
| 514 | |
| 515 | /*****************************************************************************/ |
| 516 | /* |
| 517 | * debug tracing |
| 518 | */ |
| 519 | extern unsigned afs_debug; |
| 520 | |
| 521 | #define dbgprintk(FMT,...) \ |
| 522 | printk("[%x%-6.6s] "FMT"\n", smp_processor_id(), current->comm ,##__VA_ARGS__) |
| 523 | |
| 524 | /* make sure we maintain the format strings, even when debugging is disabled */ |
| 525 | static inline __attribute__((format(printf,1,2))) |
| 526 | void _dbprintk(const char *fmt, ...) |
| 527 | { |
| 528 | } |
| 529 | |
| 530 | #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__FUNCTION__ ,##__VA_ARGS__) |
| 531 | #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__FUNCTION__ ,##__VA_ARGS__) |
| 532 | #define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__) |
| 533 | |
| 534 | |
| 535 | #if defined(__KDEBUG) |
| 536 | #define _enter(FMT,...) kenter(FMT,##__VA_ARGS__) |
| 537 | #define _leave(FMT,...) kleave(FMT,##__VA_ARGS__) |
| 538 | #define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__) |
| 539 | |
| 540 | #elif defined(CONFIG_AFS_DEBUG) |
| 541 | #define AFS_DEBUG_KENTER 0x01 |
| 542 | #define AFS_DEBUG_KLEAVE 0x02 |
| 543 | #define AFS_DEBUG_KDEBUG 0x04 |
| 544 | |
| 545 | #define _enter(FMT,...) \ |
| 546 | do { \ |
| 547 | if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \ |
| 548 | kenter(FMT,##__VA_ARGS__); \ |
| 549 | } while (0) |
| 550 | |
| 551 | #define _leave(FMT,...) \ |
| 552 | do { \ |
| 553 | if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \ |
| 554 | kleave(FMT,##__VA_ARGS__); \ |
| 555 | } while (0) |
| 556 | |
| 557 | #define _debug(FMT,...) \ |
| 558 | do { \ |
| 559 | if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \ |
| 560 | kdebug(FMT,##__VA_ARGS__); \ |
| 561 | } while (0) |
| 562 | |
| 563 | #else |
| 564 | #define _enter(FMT,...) _dbprintk("==> %s("FMT")",__FUNCTION__ ,##__VA_ARGS__) |
| 565 | #define _leave(FMT,...) _dbprintk("<== %s()"FMT"",__FUNCTION__ ,##__VA_ARGS__) |
| 566 | #define _debug(FMT,...) _dbprintk(" "FMT ,##__VA_ARGS__) |
| 567 | #endif |
| 568 | |
| 569 | /* |
| 570 | * debug assertion checking |
| 571 | */ |
| 572 | #if 1 // defined(__KDEBUGALL) |
| 573 | |
| 574 | #define ASSERT(X) \ |
| 575 | do { \ |
| 576 | if (unlikely(!(X))) { \ |
| 577 | printk(KERN_ERR "\n"); \ |
| 578 | printk(KERN_ERR "AFS: Assertion failed\n"); \ |
| 579 | BUG(); \ |
| 580 | } \ |
| 581 | } while(0) |
| 582 | |
| 583 | #define ASSERTCMP(X, OP, Y) \ |
| 584 | do { \ |
| 585 | if (unlikely(!((X) OP (Y)))) { \ |
| 586 | printk(KERN_ERR "\n"); \ |
| 587 | printk(KERN_ERR "AFS: Assertion failed\n"); \ |
| 588 | printk(KERN_ERR "%lu " #OP " %lu is false\n", \ |
| 589 | (unsigned long)(X), (unsigned long)(Y)); \ |
| 590 | printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ |
| 591 | (unsigned long)(X), (unsigned long)(Y)); \ |
| 592 | BUG(); \ |
| 593 | } \ |
| 594 | } while(0) |
| 595 | |
| 596 | #define ASSERTIF(C, X) \ |
| 597 | do { \ |
| 598 | if (unlikely((C) && !(X))) { \ |
| 599 | printk(KERN_ERR "\n"); \ |
| 600 | printk(KERN_ERR "AFS: Assertion failed\n"); \ |
| 601 | BUG(); \ |
| 602 | } \ |
| 603 | } while(0) |
| 604 | |
| 605 | #define ASSERTIFCMP(C, X, OP, Y) \ |
| 606 | do { \ |
| 607 | if (unlikely((C) && !((X) OP (Y)))) { \ |
| 608 | printk(KERN_ERR "\n"); \ |
| 609 | printk(KERN_ERR "AFS: Assertion failed\n"); \ |
| 610 | printk(KERN_ERR "%lu " #OP " %lu is false\n", \ |
| 611 | (unsigned long)(X), (unsigned long)(Y)); \ |
| 612 | printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ |
| 613 | (unsigned long)(X), (unsigned long)(Y)); \ |
| 614 | BUG(); \ |
| 615 | } \ |
| 616 | } while(0) |
| 617 | |
| 618 | #else |
| 619 | |
| 620 | #define ASSERT(X) \ |
| 621 | do { \ |
| 622 | } while(0) |
| 623 | |
| 624 | #define ASSERTCMP(X, OP, Y) \ |
| 625 | do { \ |
| 626 | } while(0) |
| 627 | |
| 628 | #define ASSERTIF(C, X) \ |
| 629 | do { \ |
| 630 | } while(0) |
| 631 | |
| 632 | #define ASSERTIFCMP(C, X, OP, Y) \ |
| 633 | do { \ |
| 634 | } while(0) |
| 635 | |
| 636 | #endif /* __KDEBUGALL */ |