1ec26815aSDavid Howells /* internal AFS stuff 21da177e4SLinus Torvalds * 308e0e7c8SDavid Howells * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved. 41da177e4SLinus Torvalds * Written by David Howells (dhowells@redhat.com) 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or 71da177e4SLinus Torvalds * modify it under the terms of the GNU General Public License 81da177e4SLinus Torvalds * as published by the Free Software Foundation; either version 91da177e4SLinus Torvalds * 2 of the License, or (at your option) any later version. 101da177e4SLinus Torvalds */ 111da177e4SLinus Torvalds 121da177e4SLinus Torvalds #include <linux/compiler.h> 131da177e4SLinus Torvalds #include <linux/kernel.h> 148a79790bSTina Ruchandani #include <linux/ktime.h> 151da177e4SLinus Torvalds #include <linux/fs.h> 161da177e4SLinus Torvalds #include <linux/pagemap.h> 1708e0e7c8SDavid Howells #include <linux/rxrpc.h> 1800d3b7a4SDavid Howells #include <linux/key.h> 19e8edc6e0SAlexey Dobriyan #include <linux/workqueue.h> 2000c541eaSAndrew Morton #include <linux/sched.h> 2180e50be4SChristoph Hellwig #include <linux/fscache.h> 22e1da0222SJens Axboe #include <linux/backing-dev.h> 23ff548773SDavid Howells #include <linux/uuid.h> 24f044c884SDavid Howells #include <net/net_namespace.h> 258324f0bcSDavid Howells #include <net/af_rxrpc.h> 2600c541eaSAndrew Morton 2708e0e7c8SDavid Howells #include "afs.h" 2808e0e7c8SDavid Howells #include "afs_vl.h" 2908e0e7c8SDavid Howells 3008e0e7c8SDavid Howells #define AFS_CELL_MAX_ADDRS 15 3108e0e7c8SDavid Howells 3231143d5dSDavid Howells struct pagevec; 3308e0e7c8SDavid Howells struct afs_call; 3408e0e7c8SDavid Howells 3508e0e7c8SDavid Howells typedef enum { 3608e0e7c8SDavid Howells AFS_VL_NEW, /* new, uninitialised record */ 3708e0e7c8SDavid Howells AFS_VL_CREATING, /* creating record */ 3808e0e7c8SDavid Howells AFS_VL_VALID, /* record is pending */ 3908e0e7c8SDavid Howells AFS_VL_NO_VOLUME, /* no such volume available */ 4008e0e7c8SDavid Howells AFS_VL_UPDATING, /* update in progress */ 4108e0e7c8SDavid Howells AFS_VL_VOLUME_DELETED, /* volume was deleted */ 4208e0e7c8SDavid Howells AFS_VL_UNCERTAIN, /* uncertain state (update failed) */ 4308e0e7c8SDavid Howells } __attribute__((packed)) afs_vlocation_state_t; 441da177e4SLinus Torvalds 4500d3b7a4SDavid Howells struct afs_mount_params { 4600d3b7a4SDavid Howells bool rwpath; /* T if the parent should be considered R/W */ 4700d3b7a4SDavid Howells bool force; /* T to force cell type */ 48bec5eb61Swanglei bool autocell; /* T if set auto mount operation */ 4900d3b7a4SDavid Howells afs_voltype_t type; /* type of volume requested */ 5000d3b7a4SDavid Howells int volnamesz; /* size of volume name */ 5100d3b7a4SDavid Howells const char *volname; /* name of volume to mount */ 52f044c884SDavid Howells struct afs_net *net; /* Network namespace in effect */ 5300d3b7a4SDavid Howells struct afs_cell *cell; /* cell in which to find volume */ 5400d3b7a4SDavid Howells struct afs_volume *volume; /* volume record */ 5500d3b7a4SDavid Howells struct key *key; /* key to use for secure mounting */ 5600d3b7a4SDavid Howells }; 5700d3b7a4SDavid Howells 58c435ee34SDavid Howells struct afs_iget_data { 59c435ee34SDavid Howells struct afs_fid fid; 60c435ee34SDavid Howells struct afs_volume *volume; /* volume on which resides */ 61c435ee34SDavid Howells }; 62c435ee34SDavid Howells 638e8d7f13SDavid Howells enum afs_call_state { 648e8d7f13SDavid Howells AFS_CALL_REQUESTING, /* request is being sent for outgoing call */ 658e8d7f13SDavid Howells AFS_CALL_AWAIT_REPLY, /* awaiting reply to outgoing call */ 668e8d7f13SDavid Howells AFS_CALL_AWAIT_OP_ID, /* awaiting op ID on incoming call */ 678e8d7f13SDavid Howells AFS_CALL_AWAIT_REQUEST, /* awaiting request data on incoming call */ 688e8d7f13SDavid Howells AFS_CALL_REPLYING, /* replying to incoming call */ 698e8d7f13SDavid Howells AFS_CALL_AWAIT_ACK, /* awaiting final ACK of incoming call */ 708e8d7f13SDavid Howells AFS_CALL_COMPLETE, /* Completed or failed */ 718e8d7f13SDavid Howells }; 72f044c884SDavid Howells 7308e0e7c8SDavid Howells /* 7408e0e7c8SDavid Howells * a record of an in-progress RxRPC call 7508e0e7c8SDavid Howells */ 7608e0e7c8SDavid Howells struct afs_call { 7708e0e7c8SDavid Howells const struct afs_call_type *type; /* type of call */ 7808e0e7c8SDavid Howells wait_queue_head_t waitq; /* processes awaiting completion */ 79341f741fSDavid Howells struct work_struct async_work; /* async I/O processor */ 8008e0e7c8SDavid Howells struct work_struct work; /* actual work processor */ 8108e0e7c8SDavid Howells struct rxrpc_call *rxcall; /* RxRPC call handle */ 8208e0e7c8SDavid Howells struct key *key; /* security for this call */ 83f044c884SDavid Howells struct afs_net *net; /* The network namespace */ 84d0676a16SDavid Howells struct afs_server *cm_server; /* Server affected by incoming CM call */ 85c435ee34SDavid Howells struct afs_server *server; /* Server used by client call */ 8608e0e7c8SDavid Howells void *request; /* request data (first part) */ 8731143d5dSDavid Howells struct address_space *mapping; /* page set */ 8831143d5dSDavid Howells struct afs_writeback *wb; /* writeback being performed */ 8908e0e7c8SDavid Howells void *buffer; /* reply receive buffer */ 9097e3043aSDavid Howells void *reply[4]; /* Where to put the reply */ 9131143d5dSDavid Howells pgoff_t first; /* first page in mapping to deal with */ 9231143d5dSDavid Howells pgoff_t last; /* last page in mapping to deal with */ 93d001648eSDavid Howells size_t offset; /* offset into received data store */ 94341f741fSDavid Howells atomic_t usage; 958e8d7f13SDavid Howells enum afs_call_state state; 9608e0e7c8SDavid Howells int error; /* error code */ 97d001648eSDavid Howells u32 abort_code; /* Remote abort ID or 0 */ 9808e0e7c8SDavid Howells unsigned request_size; /* size of request data */ 9908e0e7c8SDavid Howells unsigned reply_max; /* maximum size of reply */ 10031143d5dSDavid Howells unsigned first_offset; /* offset into mapping[first] */ 101c435ee34SDavid Howells unsigned int cb_break; /* cb_break + cb_s_break before the call */ 102bcd89270SMarc Dionne union { 10331143d5dSDavid Howells unsigned last_to; /* amount of mapping[last] */ 104bcd89270SMarc Dionne unsigned count2; /* count used in unmarshalling */ 105bcd89270SMarc Dionne }; 10608e0e7c8SDavid Howells unsigned char unmarshall; /* unmarshalling phase */ 10708e0e7c8SDavid Howells bool incoming; /* T if incoming call */ 10831143d5dSDavid Howells bool send_pages; /* T if data from mapping should be sent */ 109d001648eSDavid Howells bool need_attention; /* T if RxRPC poked us */ 11056ff9c83SDavid Howells bool async; /* T if asynchronous */ 11133cd7f2bSDavid Howells bool ret_reply0; /* T if should return reply[0] on success */ 112a68f4a27SDavid Howells bool upgrade; /* T to request service upgrade */ 11308e0e7c8SDavid Howells u16 service_id; /* RxRPC service ID to call */ 11450a2c953SDavid Howells u32 operation_ID; /* operation ID for an incoming call */ 11508e0e7c8SDavid Howells u32 count; /* count for use in unmarshalling */ 11608e0e7c8SDavid Howells __be32 tmp; /* place to extract temporary data */ 11731143d5dSDavid Howells afs_dataversion_t store_version; /* updated version expected from store */ 11808e0e7c8SDavid Howells }; 11908e0e7c8SDavid Howells 12008e0e7c8SDavid Howells struct afs_call_type { 12100d3b7a4SDavid Howells const char *name; 12200d3b7a4SDavid Howells 12308e0e7c8SDavid Howells /* deliver request or reply data to an call 12408e0e7c8SDavid Howells * - returning an error will cause the call to be aborted 12508e0e7c8SDavid Howells */ 126d001648eSDavid Howells int (*deliver)(struct afs_call *call); 12708e0e7c8SDavid Howells 12808e0e7c8SDavid Howells /* clean up a call */ 12908e0e7c8SDavid Howells void (*destructor)(struct afs_call *call); 130341f741fSDavid Howells 131341f741fSDavid Howells /* Work function */ 132341f741fSDavid Howells void (*work)(struct work_struct *work); 13308e0e7c8SDavid Howells }; 13408e0e7c8SDavid Howells 13508e0e7c8SDavid Howells /* 136196ee9cdSDavid Howells * Record of an outstanding read operation on a vnode. 137196ee9cdSDavid Howells */ 138196ee9cdSDavid Howells struct afs_read { 139196ee9cdSDavid Howells loff_t pos; /* Where to start reading */ 140e8e581a8SDavid Howells loff_t len; /* How much we're asking for */ 141196ee9cdSDavid Howells loff_t actual_len; /* How much we're actually getting */ 1426a0e3999SDavid Howells loff_t remain; /* Amount remaining */ 143196ee9cdSDavid Howells atomic_t usage; 144196ee9cdSDavid Howells unsigned int index; /* Which page we're reading into */ 145196ee9cdSDavid Howells unsigned int nr_pages; 146196ee9cdSDavid Howells void (*page_done)(struct afs_call *, struct afs_read *); 147196ee9cdSDavid Howells struct page *pages[]; 148196ee9cdSDavid Howells }; 149196ee9cdSDavid Howells 150196ee9cdSDavid Howells /* 15131143d5dSDavid Howells * record of an outstanding writeback on a vnode 15231143d5dSDavid Howells */ 15331143d5dSDavid Howells struct afs_writeback { 15431143d5dSDavid Howells struct list_head link; /* link in vnode->writebacks */ 15531143d5dSDavid Howells struct work_struct writer; /* work item to perform the writeback */ 15631143d5dSDavid Howells struct afs_vnode *vnode; /* vnode to which this write applies */ 15731143d5dSDavid Howells struct key *key; /* owner of this write */ 15831143d5dSDavid Howells wait_queue_head_t waitq; /* completion and ready wait queue */ 15931143d5dSDavid Howells pgoff_t first; /* first page in batch */ 16031143d5dSDavid Howells pgoff_t point; /* last page in current store op */ 16131143d5dSDavid Howells pgoff_t last; /* last page in batch (inclusive) */ 16231143d5dSDavid Howells unsigned offset_first; /* offset into first page of start of write */ 16331143d5dSDavid Howells unsigned to_last; /* offset into last page of end of write */ 16431143d5dSDavid Howells int num_conflicts; /* count of conflicting writes in list */ 16531143d5dSDavid Howells int usage; 16631143d5dSDavid Howells bool conflicts; /* T if has dependent conflicts */ 16731143d5dSDavid Howells enum { 16831143d5dSDavid Howells AFS_WBACK_SYNCING, /* synchronisation being performed */ 16931143d5dSDavid Howells AFS_WBACK_PENDING, /* write pending */ 17031143d5dSDavid Howells AFS_WBACK_CONFLICTING, /* conflicting writes posted */ 17131143d5dSDavid Howells AFS_WBACK_WRITING, /* writing back */ 17231143d5dSDavid Howells AFS_WBACK_COMPLETE /* the writeback record has been unlinked */ 17331143d5dSDavid Howells } state __attribute__((packed)); 17431143d5dSDavid Howells }; 17531143d5dSDavid Howells 17631143d5dSDavid Howells /* 17708e0e7c8SDavid Howells * AFS superblock private data 17808e0e7c8SDavid Howells * - there's one superblock per volume 17908e0e7c8SDavid Howells */ 18008e0e7c8SDavid Howells struct afs_super_info { 181f044c884SDavid Howells struct afs_net *net; /* Network namespace */ 18249566f6fSDavid Howells struct afs_cell *cell; /* The cell in which the volume resides */ 18308e0e7c8SDavid Howells struct afs_volume *volume; /* volume record */ 18408e0e7c8SDavid Howells char rwparent; /* T if parent is R/W AFS volume */ 18508e0e7c8SDavid Howells }; 18608e0e7c8SDavid Howells 18708e0e7c8SDavid Howells static inline struct afs_super_info *AFS_FS_S(struct super_block *sb) 18808e0e7c8SDavid Howells { 18908e0e7c8SDavid Howells return sb->s_fs_info; 19008e0e7c8SDavid Howells } 19108e0e7c8SDavid Howells 19208e0e7c8SDavid Howells extern struct file_system_type afs_fs_type; 19308e0e7c8SDavid Howells 19408e0e7c8SDavid Howells /* 195f044c884SDavid Howells * AFS network namespace record. 196f044c884SDavid Howells */ 197f044c884SDavid Howells struct afs_net { 198f044c884SDavid Howells struct afs_uuid uuid; 199f044c884SDavid Howells bool live; /* F if this namespace is being removed */ 200f044c884SDavid Howells 201f044c884SDavid Howells /* AF_RXRPC I/O stuff */ 202f044c884SDavid Howells struct socket *socket; 203f044c884SDavid Howells struct afs_call *spare_incoming_call; 204f044c884SDavid Howells struct work_struct charge_preallocation_work; 205f044c884SDavid Howells struct mutex socket_mutex; 206f044c884SDavid Howells atomic_t nr_outstanding_calls; 207f044c884SDavid Howells atomic_t nr_superblocks; 208f044c884SDavid Howells 209f044c884SDavid Howells /* Cell database */ 210f044c884SDavid Howells struct list_head cells; 211f044c884SDavid Howells struct afs_cell *ws_cell; 212f044c884SDavid Howells rwlock_t cells_lock; 213f044c884SDavid Howells struct rw_semaphore cells_sem; 214f044c884SDavid Howells wait_queue_head_t cells_freeable_wq; 215f044c884SDavid Howells 216f044c884SDavid Howells struct rw_semaphore proc_cells_sem; 217f044c884SDavid Howells struct list_head proc_cells; 218f044c884SDavid Howells 219f044c884SDavid Howells /* Volume location database */ 220f044c884SDavid Howells struct list_head vl_updates; /* VL records in need-update order */ 221f044c884SDavid Howells struct list_head vl_graveyard; /* Inactive VL records */ 222f044c884SDavid Howells struct delayed_work vl_reaper; 223f044c884SDavid Howells struct delayed_work vl_updater; 224f044c884SDavid Howells spinlock_t vl_updates_lock; 225f044c884SDavid Howells spinlock_t vl_graveyard_lock; 226f044c884SDavid Howells 227f044c884SDavid Howells /* File locking renewal management */ 228f044c884SDavid Howells struct mutex lock_manager_mutex; 229f044c884SDavid Howells 230f044c884SDavid Howells /* Server database */ 231f044c884SDavid Howells struct rb_root servers; /* Active servers */ 232f044c884SDavid Howells rwlock_t servers_lock; 233f044c884SDavid Howells struct list_head server_graveyard; /* Inactive server LRU list */ 234f044c884SDavid Howells spinlock_t server_graveyard_lock; 23559fa1c4aSDavid Howells struct timer_list server_timer; 23659fa1c4aSDavid Howells struct work_struct server_reaper; 23759fa1c4aSDavid Howells atomic_t servers_outstanding; 238f044c884SDavid Howells 239f044c884SDavid Howells /* Misc */ 240f044c884SDavid Howells struct proc_dir_entry *proc_afs; /* /proc/net/afs directory */ 241f044c884SDavid Howells }; 242f044c884SDavid Howells 243f044c884SDavid Howells extern struct afs_net __afs_net;// Dummy AFS network namespace; TODO: replace with real netns 244f044c884SDavid Howells 245f044c884SDavid Howells /* 24608e0e7c8SDavid Howells * AFS cell record 24708e0e7c8SDavid Howells */ 24808e0e7c8SDavid Howells struct afs_cell { 24908e0e7c8SDavid Howells atomic_t usage; 25008e0e7c8SDavid Howells struct list_head link; /* main cell list link */ 251f044c884SDavid Howells struct afs_net *net; /* The network namespace */ 25200d3b7a4SDavid Howells struct key *anonymous_key; /* anonymous user key for this cell */ 25308e0e7c8SDavid Howells struct list_head proc_link; /* /proc cell list link */ 2549b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 2559b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 2561da177e4SLinus Torvalds #endif 2571da177e4SLinus Torvalds 25808e0e7c8SDavid Howells /* server record management */ 25908e0e7c8SDavid Howells rwlock_t servers_lock; /* active server list lock */ 26008e0e7c8SDavid Howells struct list_head servers; /* active server list */ 2611da177e4SLinus Torvalds 26208e0e7c8SDavid Howells /* volume location record management */ 26308e0e7c8SDavid Howells struct rw_semaphore vl_sem; /* volume management serialisation semaphore */ 26408e0e7c8SDavid Howells struct list_head vl_list; /* cell's active VL record list */ 26508e0e7c8SDavid Howells spinlock_t vl_lock; /* vl_list lock */ 26608e0e7c8SDavid Howells unsigned short vl_naddrs; /* number of VL servers in addr list */ 26708e0e7c8SDavid Howells unsigned short vl_curr_svix; /* current server index */ 2684d9df986SDavid Howells struct sockaddr_rxrpc vl_addrs[AFS_CELL_MAX_ADDRS]; /* cell VL server addresses */ 26908e0e7c8SDavid Howells 27008e0e7c8SDavid Howells char name[0]; /* cell name - must go last */ 27108e0e7c8SDavid Howells }; 27208e0e7c8SDavid Howells 27308e0e7c8SDavid Howells /* 27408e0e7c8SDavid Howells * entry in the cached volume location catalogue 27508e0e7c8SDavid Howells */ 27608e0e7c8SDavid Howells struct afs_cache_vlocation { 27700d3b7a4SDavid Howells /* volume name (lowercase, padded with NULs) */ 27800d3b7a4SDavid Howells uint8_t name[AFS_MAXVOLNAME + 1]; 27900d3b7a4SDavid Howells 28008e0e7c8SDavid Howells uint8_t nservers; /* number of entries used in servers[] */ 28108e0e7c8SDavid Howells uint8_t vidmask; /* voltype mask for vid[] */ 28208e0e7c8SDavid Howells uint8_t srvtmask[8]; /* voltype masks for servers[] */ 28308e0e7c8SDavid Howells #define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */ 28408e0e7c8SDavid Howells #define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */ 28508e0e7c8SDavid Howells #define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */ 28608e0e7c8SDavid Howells 28708e0e7c8SDavid Howells afs_volid_t vid[3]; /* volume IDs for R/W, R/O and Bak volumes */ 2884d9df986SDavid Howells struct sockaddr_rxrpc servers[8]; /* fileserver addresses */ 28908e0e7c8SDavid Howells time_t rtime; /* last retrieval time */ 29008e0e7c8SDavid Howells }; 29108e0e7c8SDavid Howells 29208e0e7c8SDavid Howells /* 29308e0e7c8SDavid Howells * AFS volume location record 29408e0e7c8SDavid Howells */ 29508e0e7c8SDavid Howells struct afs_vlocation { 29608e0e7c8SDavid Howells atomic_t usage; 2978a79790bSTina Ruchandani time64_t time_of_death; /* time at which put reduced usage to 0 */ 29808e0e7c8SDavid Howells struct list_head link; /* link in cell volume location list */ 29908e0e7c8SDavid Howells struct list_head grave; /* link in master graveyard list */ 30008e0e7c8SDavid Howells struct list_head update; /* link in master update list */ 30108e0e7c8SDavid Howells struct afs_cell *cell; /* cell to which volume belongs */ 30208e0e7c8SDavid Howells struct afs_cache_vlocation vldb; /* volume information DB record */ 30308e0e7c8SDavid Howells struct afs_volume *vols[3]; /* volume access record pointer (index by type) */ 30408e0e7c8SDavid Howells wait_queue_head_t waitq; /* status change waitqueue */ 3058a79790bSTina Ruchandani time64_t update_at; /* time at which record should be updated */ 30639bf0949SDavid S. Miller spinlock_t lock; /* access lock */ 30708e0e7c8SDavid Howells afs_vlocation_state_t state; /* volume location state */ 30808e0e7c8SDavid Howells unsigned short upd_rej_cnt; /* ENOMEDIUM count during update */ 30908e0e7c8SDavid Howells unsigned short upd_busy_cnt; /* EBUSY count during update */ 31008e0e7c8SDavid Howells bool valid; /* T if valid */ 31108e0e7c8SDavid Howells }; 31208e0e7c8SDavid Howells 31308e0e7c8SDavid Howells /* 31408e0e7c8SDavid Howells * AFS fileserver record 31508e0e7c8SDavid Howells */ 31608e0e7c8SDavid Howells struct afs_server { 31708e0e7c8SDavid Howells atomic_t usage; 3188a79790bSTina Ruchandani time64_t time_of_death; /* time at which put reduced usage to 0 */ 3194d9df986SDavid Howells struct sockaddr_rxrpc addr; /* server address */ 3209ed900b1SDavid Howells struct afs_net *net; /* Network namespace in which the server resides */ 32108e0e7c8SDavid Howells struct afs_cell *cell; /* cell in which server resides */ 32208e0e7c8SDavid Howells struct list_head link; /* link in cell's server list */ 32308e0e7c8SDavid Howells struct list_head grave; /* link in master graveyard list */ 324c435ee34SDavid Howells 32508e0e7c8SDavid Howells struct rb_node master_rb; /* link in master by-addr tree */ 32608e0e7c8SDavid Howells struct rw_semaphore sem; /* access lock */ 327c435ee34SDavid Howells unsigned long flags; 328c435ee34SDavid Howells #define AFS_SERVER_NEW 0 /* New server, don't inc cb_s_break */ 32908e0e7c8SDavid Howells 33008e0e7c8SDavid Howells /* file service access */ 33108e0e7c8SDavid Howells int fs_state; /* 0 or reason FS currently marked dead (-errno) */ 332c435ee34SDavid Howells spinlock_t fs_lock; /* access lock */ 33308e0e7c8SDavid Howells 33408e0e7c8SDavid Howells /* callback promise management */ 335c435ee34SDavid Howells struct list_head cb_interests; /* List of superblocks using this server */ 336c435ee34SDavid Howells unsigned cb_s_break; /* Break-everything counter. */ 337c435ee34SDavid Howells rwlock_t cb_break_lock; /* Volume finding lock */ 338c435ee34SDavid Howells }; 339c435ee34SDavid Howells 340c435ee34SDavid Howells /* 341c435ee34SDavid Howells * Interest by a superblock on a server. 342c435ee34SDavid Howells */ 343c435ee34SDavid Howells struct afs_cb_interest { 344c435ee34SDavid Howells struct list_head cb_link; /* Link in server->cb_interests */ 345c435ee34SDavid Howells struct afs_server *server; /* Server on which this interest resides */ 346c435ee34SDavid Howells struct super_block *sb; /* Superblock on which inodes reside */ 347c435ee34SDavid Howells afs_volid_t vid; /* Volume ID to match */ 348c435ee34SDavid Howells refcount_t usage; 34908e0e7c8SDavid Howells }; 35008e0e7c8SDavid Howells 35108e0e7c8SDavid Howells /* 35208e0e7c8SDavid Howells * AFS volume access record 35308e0e7c8SDavid Howells */ 35408e0e7c8SDavid Howells struct afs_volume { 35508e0e7c8SDavid Howells atomic_t usage; 35608e0e7c8SDavid Howells struct afs_cell *cell; /* cell to which belongs (unrefd ptr) */ 35708e0e7c8SDavid Howells struct afs_vlocation *vlocation; /* volume location */ 3589b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 3599b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 36008e0e7c8SDavid Howells #endif 36108e0e7c8SDavid Howells afs_volid_t vid; /* volume ID */ 36208e0e7c8SDavid Howells afs_voltype_t type; /* type of volume */ 36308e0e7c8SDavid Howells char type_force; /* force volume type (suppress R/O -> R/W) */ 36408e0e7c8SDavid Howells unsigned short nservers; /* number of server slots filled */ 36508e0e7c8SDavid Howells unsigned short rjservers; /* number of servers discarded due to -ENOMEDIUM */ 36608e0e7c8SDavid Howells struct afs_server *servers[8]; /* servers on which volume resides (ordered) */ 367c435ee34SDavid Howells struct afs_cb_interest *cb_interests[8]; /* Interests on servers for callbacks */ 36808e0e7c8SDavid Howells struct rw_semaphore server_sem; /* lock for accessing current server */ 36908e0e7c8SDavid Howells }; 37008e0e7c8SDavid Howells 37108e0e7c8SDavid Howells /* 37208e0e7c8SDavid Howells * vnode catalogue entry 37308e0e7c8SDavid Howells */ 37408e0e7c8SDavid Howells struct afs_cache_vnode { 37508e0e7c8SDavid Howells afs_vnodeid_t vnode_id; /* vnode ID */ 37608e0e7c8SDavid Howells unsigned vnode_unique; /* vnode ID uniquifier */ 37708e0e7c8SDavid Howells afs_dataversion_t data_version; /* data version */ 37808e0e7c8SDavid Howells }; 37908e0e7c8SDavid Howells 38008e0e7c8SDavid Howells /* 38108e0e7c8SDavid Howells * AFS inode private data 38208e0e7c8SDavid Howells */ 38308e0e7c8SDavid Howells struct afs_vnode { 38408e0e7c8SDavid Howells struct inode vfs_inode; /* the VFS's inode record */ 38508e0e7c8SDavid Howells 38608e0e7c8SDavid Howells struct afs_volume *volume; /* volume on which vnode resides */ 38708e0e7c8SDavid Howells struct afs_fid fid; /* the file identifier for this inode */ 38808e0e7c8SDavid Howells struct afs_file_status status; /* AFS status info for this file */ 3899b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 3909b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 39108e0e7c8SDavid Howells #endif 39200d3b7a4SDavid Howells struct afs_permits *permits; /* cache of permits so far obtained */ 39300d3b7a4SDavid Howells struct mutex permits_lock; /* lock for altering permits list */ 394260a9803SDavid Howells struct mutex validate_lock; /* lock for validating this vnode */ 39508e0e7c8SDavid Howells wait_queue_head_t update_waitq; /* status fetch waitqueue */ 396260a9803SDavid Howells int update_cnt; /* number of outstanding ops that will update the 39708e0e7c8SDavid Howells * status */ 39831143d5dSDavid Howells spinlock_t writeback_lock; /* lock for writebacks */ 39908e0e7c8SDavid Howells spinlock_t lock; /* waitqueue/flags lock */ 40008e0e7c8SDavid Howells unsigned long flags; 401c435ee34SDavid Howells #define AFS_VNODE_CB_PROMISED 0 /* Set if vnode has a callback promise */ 402260a9803SDavid Howells #define AFS_VNODE_UNSET 1 /* set if vnode attributes not yet set */ 403c435ee34SDavid Howells #define AFS_VNODE_DIR_MODIFIED 2 /* set if dir vnode's data modified */ 40408e0e7c8SDavid Howells #define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */ 40508e0e7c8SDavid Howells #define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */ 40608e0e7c8SDavid Howells #define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */ 407e8d6c554SDavid Howells #define AFS_VNODE_LOCKING 6 /* set if waiting for lock on vnode */ 408e8d6c554SDavid Howells #define AFS_VNODE_READLOCKED 7 /* set if vnode is read-locked on the server */ 409e8d6c554SDavid Howells #define AFS_VNODE_WRITELOCKED 8 /* set if vnode is write-locked on the server */ 410e8d6c554SDavid Howells #define AFS_VNODE_UNLOCKING 9 /* set if vnode is being unlocked on the server */ 411bec5eb61Swanglei #define AFS_VNODE_AUTOCELL 10 /* set if Vnode is an auto mount point */ 412bec5eb61Swanglei #define AFS_VNODE_PSEUDODIR 11 /* set if Vnode is a pseudo directory */ 41308e0e7c8SDavid Howells 41400d3b7a4SDavid Howells long acl_order; /* ACL check count (callback break count) */ 41500d3b7a4SDavid Howells 41631143d5dSDavid Howells struct list_head writebacks; /* alterations in pagecache that need writing */ 417e8d6c554SDavid Howells struct list_head pending_locks; /* locks waiting to be granted */ 418e8d6c554SDavid Howells struct list_head granted_locks; /* locks granted on this file */ 419e8d6c554SDavid Howells struct delayed_work lock_work; /* work to be done in locking */ 420e8d6c554SDavid Howells struct key *unlock_key; /* key to be used in unlocking */ 42131143d5dSDavid Howells 42208e0e7c8SDavid Howells /* outstanding callback notification on this file */ 423c435ee34SDavid Howells struct afs_cb_interest *cb_interest; /* Server on which this resides */ 424c435ee34SDavid Howells unsigned int cb_s_break; /* Mass break counter on ->server */ 425c435ee34SDavid Howells unsigned int cb_break; /* Break counter on vnode */ 426c435ee34SDavid Howells seqlock_t cb_lock; /* Lock for ->cb_interest, ->status, ->cb_*break */ 427c435ee34SDavid Howells 428c435ee34SDavid Howells time64_t cb_expires_at; /* time at which callback expires */ 42908e0e7c8SDavid Howells unsigned cb_version; /* callback version */ 43008e0e7c8SDavid Howells afs_callback_type_t cb_type; /* type of callback */ 43108e0e7c8SDavid Howells }; 43208e0e7c8SDavid Howells 43300d3b7a4SDavid Howells /* 43400d3b7a4SDavid Howells * cached security record for one user's attempt to access a vnode 43500d3b7a4SDavid Howells */ 43600d3b7a4SDavid Howells struct afs_permit { 43700d3b7a4SDavid Howells struct key *key; /* RxRPC ticket holding a security context */ 43800d3b7a4SDavid Howells afs_access_t access_mask; /* access mask for this key */ 43900d3b7a4SDavid Howells }; 44000d3b7a4SDavid Howells 44100d3b7a4SDavid Howells /* 44200d3b7a4SDavid Howells * cache of security records from attempts to access a vnode 44300d3b7a4SDavid Howells */ 44400d3b7a4SDavid Howells struct afs_permits { 44500d3b7a4SDavid Howells struct rcu_head rcu; /* disposal procedure */ 44600d3b7a4SDavid Howells int count; /* number of records */ 44700d3b7a4SDavid Howells struct afs_permit permits[0]; /* the permits so far examined */ 44800d3b7a4SDavid Howells }; 44900d3b7a4SDavid Howells 450b908fe6bSDavid Howells /* 451b908fe6bSDavid Howells * record of one of a system's set of network interfaces 452b908fe6bSDavid Howells */ 453b908fe6bSDavid Howells struct afs_interface { 454b908fe6bSDavid Howells struct in_addr address; /* IPv4 address bound to interface */ 455b908fe6bSDavid Howells struct in_addr netmask; /* netmask applied to address */ 456b908fe6bSDavid Howells unsigned mtu; /* MTU of interface */ 457b908fe6bSDavid Howells }; 458b908fe6bSDavid Howells 45908e0e7c8SDavid Howells /*****************************************************************************/ 46008e0e7c8SDavid Howells /* 4619b3f26c9SDavid Howells * cache.c 4629b3f26c9SDavid Howells */ 4639b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 4649b3f26c9SDavid Howells extern struct fscache_netfs afs_cache_netfs; 4659b3f26c9SDavid Howells extern struct fscache_cookie_def afs_cell_cache_index_def; 4669b3f26c9SDavid Howells extern struct fscache_cookie_def afs_volume_cache_index_def; 4679b3f26c9SDavid Howells extern struct fscache_cookie_def afs_vnode_cache_index_def; 4689b3f26c9SDavid Howells #else 4699b3f26c9SDavid Howells #define afs_cell_cache_index_def (*(struct fscache_cookie_def *) NULL) 4709b3f26c9SDavid Howells #define afs_volume_cache_index_def (*(struct fscache_cookie_def *) NULL) 4719b3f26c9SDavid Howells #define afs_vnode_cache_index_def (*(struct fscache_cookie_def *) NULL) 4729b3f26c9SDavid Howells #endif 4739b3f26c9SDavid Howells 4749b3f26c9SDavid Howells /* 47508e0e7c8SDavid Howells * callback.c 47608e0e7c8SDavid Howells */ 47708e0e7c8SDavid Howells extern void afs_init_callback_state(struct afs_server *); 478c435ee34SDavid Howells extern void afs_break_callback(struct afs_vnode *); 479c435ee34SDavid Howells extern void afs_break_callbacks(struct afs_server *, size_t,struct afs_callback[]); 480c435ee34SDavid Howells 481c435ee34SDavid Howells extern int afs_register_server_cb_interest(struct afs_vnode *, struct afs_cb_interest **, 482c435ee34SDavid Howells struct afs_server *); 483c435ee34SDavid Howells extern void afs_put_cb_interest(struct afs_net *, struct afs_cb_interest *); 484c435ee34SDavid Howells extern void afs_clear_callback_interests(struct afs_net *, struct afs_volume *); 485c435ee34SDavid Howells 486c435ee34SDavid Howells static inline struct afs_cb_interest *afs_get_cb_interest(struct afs_cb_interest *cbi) 487c435ee34SDavid Howells { 488c435ee34SDavid Howells refcount_inc(&cbi->usage); 489c435ee34SDavid Howells return cbi; 490c435ee34SDavid Howells } 4911da177e4SLinus Torvalds 4921da177e4SLinus Torvalds /* 4931da177e4SLinus Torvalds * cell.c 4941da177e4SLinus Torvalds */ 49549566f6fSDavid Howells static inline struct afs_cell *afs_get_cell(struct afs_cell *cell) 49649566f6fSDavid Howells { 49749566f6fSDavid Howells if (cell) 49849566f6fSDavid Howells atomic_inc(&cell->usage); 49949566f6fSDavid Howells return cell; 50049566f6fSDavid Howells } 501f044c884SDavid Howells extern int afs_cell_init(struct afs_net *, char *); 502f044c884SDavid Howells extern struct afs_cell *afs_cell_create(struct afs_net *, const char *, unsigned, char *, bool); 503f044c884SDavid Howells extern struct afs_cell *afs_cell_lookup(struct afs_net *, const char *, unsigned, bool); 50408e0e7c8SDavid Howells extern struct afs_cell *afs_grab_cell(struct afs_cell *); 5059ed900b1SDavid Howells extern void afs_put_cell(struct afs_net *, struct afs_cell *); 506f044c884SDavid Howells extern void __net_exit afs_cell_purge(struct afs_net *); 50708e0e7c8SDavid Howells 50808e0e7c8SDavid Howells /* 50908e0e7c8SDavid Howells * cmservice.c 51008e0e7c8SDavid Howells */ 51108e0e7c8SDavid Howells extern bool afs_cm_incoming_call(struct afs_call *); 51208e0e7c8SDavid Howells 5131da177e4SLinus Torvalds /* 5141da177e4SLinus Torvalds * dir.c 5151da177e4SLinus Torvalds */ 516754661f1SArjan van de Ven extern const struct inode_operations afs_dir_inode_operations; 517d61dcce2SAl Viro extern const struct dentry_operations afs_fs_dentry_operations; 5184b6f5d20SArjan van de Ven extern const struct file_operations afs_dir_file_operations; 5191da177e4SLinus Torvalds 5201da177e4SLinus Torvalds /* 5211da177e4SLinus Torvalds * file.c 5221da177e4SLinus Torvalds */ 523f5e54d6eSChristoph Hellwig extern const struct address_space_operations afs_fs_aops; 524754661f1SArjan van de Ven extern const struct inode_operations afs_file_inode_operations; 52500d3b7a4SDavid Howells extern const struct file_operations afs_file_operations; 52600d3b7a4SDavid Howells 52700d3b7a4SDavid Howells extern int afs_open(struct inode *, struct file *); 52800d3b7a4SDavid Howells extern int afs_release(struct inode *, struct file *); 529f6d335c0SAl Viro extern int afs_page_filler(void *, struct page *); 530196ee9cdSDavid Howells extern void afs_put_read(struct afs_read *); 5311da177e4SLinus Torvalds 5321da177e4SLinus Torvalds /* 533e8d6c554SDavid Howells * flock.c 534e8d6c554SDavid Howells */ 535f044c884SDavid Howells extern struct workqueue_struct *afs_lock_manager; 536f044c884SDavid Howells 537e8d6c554SDavid Howells extern void afs_lock_work(struct work_struct *); 538e8d6c554SDavid Howells extern void afs_lock_may_be_available(struct afs_vnode *); 539e8d6c554SDavid Howells extern int afs_lock(struct file *, int, struct file_lock *); 540e8d6c554SDavid Howells extern int afs_flock(struct file *, int, struct file_lock *); 541e8d6c554SDavid Howells 542e8d6c554SDavid Howells /* 54308e0e7c8SDavid Howells * fsclient.c 54408e0e7c8SDavid Howells */ 54500d3b7a4SDavid Howells extern int afs_fs_fetch_file_status(struct afs_server *, struct key *, 54600d3b7a4SDavid Howells struct afs_vnode *, struct afs_volsync *, 54756ff9c83SDavid Howells bool); 548f044c884SDavid Howells extern int afs_fs_give_up_callbacks(struct afs_net *, struct afs_server *, bool); 54900d3b7a4SDavid Howells extern int afs_fs_fetch_data(struct afs_server *, struct key *, 55056ff9c83SDavid Howells struct afs_vnode *, struct afs_read *, bool); 551260a9803SDavid Howells extern int afs_fs_create(struct afs_server *, struct key *, 552260a9803SDavid Howells struct afs_vnode *, const char *, umode_t, 553260a9803SDavid Howells struct afs_fid *, struct afs_file_status *, 55456ff9c83SDavid Howells struct afs_callback *, bool); 555260a9803SDavid Howells extern int afs_fs_remove(struct afs_server *, struct key *, 55656ff9c83SDavid Howells struct afs_vnode *, const char *, bool, bool); 557260a9803SDavid Howells extern int afs_fs_link(struct afs_server *, struct key *, struct afs_vnode *, 55856ff9c83SDavid Howells struct afs_vnode *, const char *, bool); 559260a9803SDavid Howells extern int afs_fs_symlink(struct afs_server *, struct key *, 560260a9803SDavid Howells struct afs_vnode *, const char *, const char *, 56156ff9c83SDavid Howells struct afs_fid *, struct afs_file_status *, bool); 562260a9803SDavid Howells extern int afs_fs_rename(struct afs_server *, struct key *, 563260a9803SDavid Howells struct afs_vnode *, const char *, 56456ff9c83SDavid Howells struct afs_vnode *, const char *, bool); 56531143d5dSDavid Howells extern int afs_fs_store_data(struct afs_server *, struct afs_writeback *, 56656ff9c83SDavid Howells pgoff_t, pgoff_t, unsigned, unsigned, bool); 56731143d5dSDavid Howells extern int afs_fs_setattr(struct afs_server *, struct key *, 56856ff9c83SDavid Howells struct afs_vnode *, struct iattr *, bool); 56945222b9eSDavid Howells extern int afs_fs_get_volume_status(struct afs_server *, struct key *, 57045222b9eSDavid Howells struct afs_vnode *, 57156ff9c83SDavid Howells struct afs_volume_status *, bool); 572e8d6c554SDavid Howells extern int afs_fs_set_lock(struct afs_server *, struct key *, 57356ff9c83SDavid Howells struct afs_vnode *, afs_lock_type_t, bool); 574e8d6c554SDavid Howells extern int afs_fs_extend_lock(struct afs_server *, struct key *, 57556ff9c83SDavid Howells struct afs_vnode *, bool); 576e8d6c554SDavid Howells extern int afs_fs_release_lock(struct afs_server *, struct key *, 57756ff9c83SDavid Howells struct afs_vnode *, bool); 578c435ee34SDavid Howells extern int afs_fs_give_up_all_callbacks(struct afs_server *, struct key *, bool); 57908e0e7c8SDavid Howells 58008e0e7c8SDavid Howells /* 5811da177e4SLinus Torvalds * inode.c 5821da177e4SLinus Torvalds */ 583c435ee34SDavid Howells extern int afs_iget5_test(struct inode *, void *); 584bec5eb61Swanglei extern struct inode *afs_iget_autocell(struct inode *, const char *, int, 585bec5eb61Swanglei struct key *); 58600d3b7a4SDavid Howells extern struct inode *afs_iget(struct super_block *, struct key *, 587260a9803SDavid Howells struct afs_fid *, struct afs_file_status *, 588260a9803SDavid Howells struct afs_callback *); 589416351f2SDavid Howells extern void afs_zap_data(struct afs_vnode *); 590260a9803SDavid Howells extern int afs_validate(struct afs_vnode *, struct key *); 591a528d35eSDavid Howells extern int afs_getattr(const struct path *, struct kstat *, u32, unsigned int); 59231143d5dSDavid Howells extern int afs_setattr(struct dentry *, struct iattr *); 593b57922d9SAl Viro extern void afs_evict_inode(struct inode *); 594bec5eb61Swanglei extern int afs_drop_inode(struct inode *); 5951da177e4SLinus Torvalds 5961da177e4SLinus Torvalds /* 5971da177e4SLinus Torvalds * main.c 5981da177e4SLinus Torvalds */ 5990ad53eeeSTejun Heo extern struct workqueue_struct *afs_wq; 600f044c884SDavid Howells 601f044c884SDavid Howells static inline struct afs_net *afs_d2net(struct dentry *dentry) 602f044c884SDavid Howells { 603f044c884SDavid Howells return &__afs_net; 604f044c884SDavid Howells } 605f044c884SDavid Howells 606f044c884SDavid Howells static inline struct afs_net *afs_i2net(struct inode *inode) 607f044c884SDavid Howells { 608f044c884SDavid Howells return &__afs_net; 609f044c884SDavid Howells } 610f044c884SDavid Howells 611f044c884SDavid Howells static inline struct afs_net *afs_v2net(struct afs_vnode *vnode) 612f044c884SDavid Howells { 613f044c884SDavid Howells return &__afs_net; 614f044c884SDavid Howells } 615f044c884SDavid Howells 616f044c884SDavid Howells static inline struct afs_net *afs_sock2net(struct sock *sk) 617f044c884SDavid Howells { 618f044c884SDavid Howells return &__afs_net; 619f044c884SDavid Howells } 620f044c884SDavid Howells 621f044c884SDavid Howells static inline struct afs_net *afs_get_net(struct afs_net *net) 622f044c884SDavid Howells { 623f044c884SDavid Howells return net; 624f044c884SDavid Howells } 625f044c884SDavid Howells 626f044c884SDavid Howells static inline void afs_put_net(struct afs_net *net) 627f044c884SDavid Howells { 628f044c884SDavid Howells } 6291da177e4SLinus Torvalds 6301da177e4SLinus Torvalds /* 63108e0e7c8SDavid Howells * misc.c 63208e0e7c8SDavid Howells */ 63308e0e7c8SDavid Howells extern int afs_abort_to_error(u32); 63408e0e7c8SDavid Howells 63508e0e7c8SDavid Howells /* 6361da177e4SLinus Torvalds * mntpt.c 6371da177e4SLinus Torvalds */ 638754661f1SArjan van de Ven extern const struct inode_operations afs_mntpt_inode_operations; 639bec5eb61Swanglei extern const struct inode_operations afs_autocell_inode_operations; 6404b6f5d20SArjan van de Ven extern const struct file_operations afs_mntpt_file_operations; 6411da177e4SLinus Torvalds 642d18610b0SDavid Howells extern struct vfsmount *afs_d_automount(struct path *); 64308e0e7c8SDavid Howells extern void afs_mntpt_kill_timer(void); 6441da177e4SLinus Torvalds 6451da177e4SLinus Torvalds /* 646b4db2b35SArnd Bergmann * netdevices.c 647b4db2b35SArnd Bergmann */ 648b4db2b35SArnd Bergmann extern int afs_get_ipv4_interfaces(struct afs_interface *, size_t, bool); 649b4db2b35SArnd Bergmann 650b4db2b35SArnd Bergmann /* 6511da177e4SLinus Torvalds * proc.c 6521da177e4SLinus Torvalds */ 653f044c884SDavid Howells extern int __net_init afs_proc_init(struct afs_net *); 654f044c884SDavid Howells extern void __net_exit afs_proc_cleanup(struct afs_net *); 655f044c884SDavid Howells extern int afs_proc_cell_setup(struct afs_net *, struct afs_cell *); 656f044c884SDavid Howells extern void afs_proc_cell_remove(struct afs_net *, struct afs_cell *); 6571da177e4SLinus Torvalds 65808e0e7c8SDavid Howells /* 65908e0e7c8SDavid Howells * rxrpc.c 66008e0e7c8SDavid Howells */ 661f044c884SDavid Howells extern struct workqueue_struct *afs_async_calls; 6628324f0bcSDavid Howells 663f044c884SDavid Howells extern int __net_init afs_open_socket(struct afs_net *); 664f044c884SDavid Howells extern void __net_exit afs_close_socket(struct afs_net *); 665f044c884SDavid Howells extern void afs_charge_preallocation(struct work_struct *); 666341f741fSDavid Howells extern void afs_put_call(struct afs_call *); 667341f741fSDavid Howells extern int afs_queue_call_work(struct afs_call *); 66833cd7f2bSDavid Howells extern long afs_make_call(struct sockaddr_rxrpc *, struct afs_call *, gfp_t, bool); 669f044c884SDavid Howells extern struct afs_call *afs_alloc_flat_call(struct afs_net *, 670f044c884SDavid Howells const struct afs_call_type *, 67108e0e7c8SDavid Howells size_t, size_t); 67208e0e7c8SDavid Howells extern void afs_flat_call_destructor(struct afs_call *); 67308e0e7c8SDavid Howells extern void afs_send_empty_reply(struct afs_call *); 674b908fe6bSDavid Howells extern void afs_send_simple_reply(struct afs_call *, const void *, size_t); 675d001648eSDavid Howells extern int afs_extract_data(struct afs_call *, void *, size_t, bool); 67608e0e7c8SDavid Howells 677d001648eSDavid Howells static inline int afs_transfer_reply(struct afs_call *call) 678372ee163SDavid Howells { 679d001648eSDavid Howells return afs_extract_data(call, call->buffer, call->reply_max, false); 680372ee163SDavid Howells } 681372ee163SDavid Howells 68208e0e7c8SDavid Howells /* 68300d3b7a4SDavid Howells * security.c 68400d3b7a4SDavid Howells */ 68500d3b7a4SDavid Howells extern void afs_clear_permits(struct afs_vnode *); 68600d3b7a4SDavid Howells extern void afs_cache_permit(struct afs_vnode *, struct key *, long); 687416351f2SDavid Howells extern void afs_zap_permits(struct rcu_head *); 68800d3b7a4SDavid Howells extern struct key *afs_request_key(struct afs_cell *); 68910556cb2SAl Viro extern int afs_permission(struct inode *, int); 69000d3b7a4SDavid Howells 69100d3b7a4SDavid Howells /* 69208e0e7c8SDavid Howells * server.c 69308e0e7c8SDavid Howells */ 69408e0e7c8SDavid Howells extern spinlock_t afs_server_peer_lock; 69508e0e7c8SDavid Howells 696c435ee34SDavid Howells static inline struct afs_server *afs_get_server(struct afs_server *server) 697c435ee34SDavid Howells { 698c435ee34SDavid Howells atomic_inc(&server->usage); 699c435ee34SDavid Howells return server; 700c435ee34SDavid Howells } 70108e0e7c8SDavid Howells 70259fa1c4aSDavid Howells extern void afs_server_timer(struct timer_list *); 70308e0e7c8SDavid Howells extern struct afs_server *afs_lookup_server(struct afs_cell *, 7044d9df986SDavid Howells struct sockaddr_rxrpc *); 705f044c884SDavid Howells extern struct afs_server *afs_find_server(struct afs_net *, 706f044c884SDavid Howells const struct sockaddr_rxrpc *); 7079ed900b1SDavid Howells extern void afs_put_server(struct afs_net *, struct afs_server *); 708f044c884SDavid Howells extern void afs_reap_server(struct work_struct *); 709f044c884SDavid Howells extern void __net_exit afs_purge_servers(struct afs_net *); 71008e0e7c8SDavid Howells 71108e0e7c8SDavid Howells /* 71200d3b7a4SDavid Howells * super.c 71300d3b7a4SDavid Howells */ 714f044c884SDavid Howells extern int __init afs_fs_init(void); 715f044c884SDavid Howells extern void __exit afs_fs_exit(void); 71600d3b7a4SDavid Howells 71700d3b7a4SDavid Howells /* 71808e0e7c8SDavid Howells * vlclient.c 71908e0e7c8SDavid Howells */ 720f044c884SDavid Howells extern int afs_vl_get_entry_by_name(struct afs_net *, 7214d9df986SDavid Howells struct sockaddr_rxrpc *, struct key *, 72200d3b7a4SDavid Howells const char *, struct afs_cache_vlocation *, 72356ff9c83SDavid Howells bool); 724f044c884SDavid Howells extern int afs_vl_get_entry_by_id(struct afs_net *, 7254d9df986SDavid Howells struct sockaddr_rxrpc *, struct key *, 72600d3b7a4SDavid Howells afs_volid_t, afs_voltype_t, 72756ff9c83SDavid Howells struct afs_cache_vlocation *, bool); 72808e0e7c8SDavid Howells 72908e0e7c8SDavid Howells /* 73008e0e7c8SDavid Howells * vlocation.c 73108e0e7c8SDavid Howells */ 732f044c884SDavid Howells extern struct workqueue_struct *afs_vlocation_update_worker; 733f044c884SDavid Howells 73408e0e7c8SDavid Howells #define afs_get_vlocation(V) do { atomic_inc(&(V)->usage); } while(0) 73508e0e7c8SDavid Howells 736f044c884SDavid Howells extern struct afs_vlocation *afs_vlocation_lookup(struct afs_net *, 737f044c884SDavid Howells struct afs_cell *, 73800d3b7a4SDavid Howells struct key *, 73908e0e7c8SDavid Howells const char *, size_t); 740f044c884SDavid Howells extern void afs_put_vlocation(struct afs_net *, struct afs_vlocation *); 741f044c884SDavid Howells extern void afs_vlocation_updater(struct work_struct *); 742f044c884SDavid Howells extern void afs_vlocation_reaper(struct work_struct *); 743f044c884SDavid Howells extern void __net_exit afs_vlocation_purge(struct afs_net *); 74408e0e7c8SDavid Howells 74508e0e7c8SDavid Howells /* 74608e0e7c8SDavid Howells * vnode.c 74708e0e7c8SDavid Howells */ 74808e0e7c8SDavid Howells static inline struct afs_vnode *AFS_FS_I(struct inode *inode) 74908e0e7c8SDavid Howells { 75008e0e7c8SDavid Howells return container_of(inode, struct afs_vnode, vfs_inode); 75108e0e7c8SDavid Howells } 75208e0e7c8SDavid Howells 75308e0e7c8SDavid Howells static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode) 75408e0e7c8SDavid Howells { 75508e0e7c8SDavid Howells return &vnode->vfs_inode; 75608e0e7c8SDavid Howells } 75708e0e7c8SDavid Howells 758260a9803SDavid Howells extern void afs_vnode_finalise_status_update(struct afs_vnode *, 759260a9803SDavid Howells struct afs_server *); 76000d3b7a4SDavid Howells extern int afs_vnode_fetch_status(struct afs_vnode *, struct afs_vnode *, 761c435ee34SDavid Howells struct key *, bool); 76200d3b7a4SDavid Howells extern int afs_vnode_fetch_data(struct afs_vnode *, struct key *, 763196ee9cdSDavid Howells struct afs_read *); 764260a9803SDavid Howells extern int afs_vnode_create(struct afs_vnode *, struct key *, const char *, 765260a9803SDavid Howells umode_t, struct afs_fid *, struct afs_file_status *, 766260a9803SDavid Howells struct afs_callback *, struct afs_server **); 767260a9803SDavid Howells extern int afs_vnode_remove(struct afs_vnode *, struct key *, const char *, 768260a9803SDavid Howells bool); 769260a9803SDavid Howells extern int afs_vnode_link(struct afs_vnode *, struct afs_vnode *, struct key *, 770260a9803SDavid Howells const char *); 771260a9803SDavid Howells extern int afs_vnode_symlink(struct afs_vnode *, struct key *, const char *, 772260a9803SDavid Howells const char *, struct afs_fid *, 773260a9803SDavid Howells struct afs_file_status *, struct afs_server **); 774260a9803SDavid Howells extern int afs_vnode_rename(struct afs_vnode *, struct afs_vnode *, 775260a9803SDavid Howells struct key *, const char *, const char *); 77631143d5dSDavid Howells extern int afs_vnode_store_data(struct afs_writeback *, pgoff_t, pgoff_t, 77731143d5dSDavid Howells unsigned, unsigned); 77831143d5dSDavid Howells extern int afs_vnode_setattr(struct afs_vnode *, struct key *, struct iattr *); 77945222b9eSDavid Howells extern int afs_vnode_get_volume_status(struct afs_vnode *, struct key *, 78045222b9eSDavid Howells struct afs_volume_status *); 781e8d6c554SDavid Howells extern int afs_vnode_set_lock(struct afs_vnode *, struct key *, 782e8d6c554SDavid Howells afs_lock_type_t); 783e8d6c554SDavid Howells extern int afs_vnode_extend_lock(struct afs_vnode *, struct key *); 784e8d6c554SDavid Howells extern int afs_vnode_release_lock(struct afs_vnode *, struct key *); 78508e0e7c8SDavid Howells 78608e0e7c8SDavid Howells /* 78708e0e7c8SDavid Howells * volume.c 78808e0e7c8SDavid Howells */ 78949566f6fSDavid Howells static inline struct afs_volume *afs_get_volume(struct afs_volume *volume) 79049566f6fSDavid Howells { 79149566f6fSDavid Howells if (volume) 79249566f6fSDavid Howells atomic_inc(&volume->usage); 79349566f6fSDavid Howells return volume; 79449566f6fSDavid Howells } 79508e0e7c8SDavid Howells 7969ed900b1SDavid Howells extern void afs_put_volume(struct afs_cell *, struct afs_volume *); 79700d3b7a4SDavid Howells extern struct afs_volume *afs_volume_lookup(struct afs_mount_params *); 79808e0e7c8SDavid Howells extern struct afs_server *afs_volume_pick_fileserver(struct afs_vnode *); 79908e0e7c8SDavid Howells extern int afs_volume_release_fileserver(struct afs_vnode *, 80008e0e7c8SDavid Howells struct afs_server *, int); 80108e0e7c8SDavid Howells 80231143d5dSDavid Howells /* 80331143d5dSDavid Howells * write.c 80431143d5dSDavid Howells */ 80531143d5dSDavid Howells extern int afs_set_page_dirty(struct page *); 80631143d5dSDavid Howells extern void afs_put_writeback(struct afs_writeback *); 80715b4650eSNick Piggin extern int afs_write_begin(struct file *file, struct address_space *mapping, 80815b4650eSNick Piggin loff_t pos, unsigned len, unsigned flags, 80915b4650eSNick Piggin struct page **pagep, void **fsdata); 81015b4650eSNick Piggin extern int afs_write_end(struct file *file, struct address_space *mapping, 81115b4650eSNick Piggin loff_t pos, unsigned len, unsigned copied, 81215b4650eSNick Piggin struct page *page, void *fsdata); 81331143d5dSDavid Howells extern int afs_writepage(struct page *, struct writeback_control *); 81431143d5dSDavid Howells extern int afs_writepages(struct address_space *, struct writeback_control *); 81531143d5dSDavid Howells extern void afs_pages_written_back(struct afs_vnode *, struct afs_call *); 81650b5551dSAl Viro extern ssize_t afs_file_write(struct kiocb *, struct iov_iter *); 81731143d5dSDavid Howells extern int afs_writeback_all(struct afs_vnode *); 81858fed94dSDavid Howells extern int afs_flush(struct file *, fl_owner_t); 81902c24a82SJosef Bacik extern int afs_fsync(struct file *, loff_t, loff_t, int); 82031143d5dSDavid Howells 821d3e3b7eaSDavid Howells /* 822d3e3b7eaSDavid Howells * xattr.c 823d3e3b7eaSDavid Howells */ 824d3e3b7eaSDavid Howells extern const struct xattr_handler *afs_xattr_handlers[]; 825d3e3b7eaSDavid Howells extern ssize_t afs_listxattr(struct dentry *, char *, size_t); 82631143d5dSDavid Howells 82708e0e7c8SDavid Howells /*****************************************************************************/ 82808e0e7c8SDavid Howells /* 82908e0e7c8SDavid Howells * debug tracing 83008e0e7c8SDavid Howells */ 8318e8d7f13SDavid Howells #include <trace/events/afs.h> 8328e8d7f13SDavid Howells 83308e0e7c8SDavid Howells extern unsigned afs_debug; 83408e0e7c8SDavid Howells 83508e0e7c8SDavid Howells #define dbgprintk(FMT,...) \ 836ad16df84SSven Schnelle printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__) 83708e0e7c8SDavid Howells 838530b6412SHarvey Harrison #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__) 839530b6412SHarvey Harrison #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) 84008e0e7c8SDavid Howells #define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__) 84108e0e7c8SDavid Howells 84208e0e7c8SDavid Howells 84308e0e7c8SDavid Howells #if defined(__KDEBUG) 84408e0e7c8SDavid Howells #define _enter(FMT,...) kenter(FMT,##__VA_ARGS__) 84508e0e7c8SDavid Howells #define _leave(FMT,...) kleave(FMT,##__VA_ARGS__) 84608e0e7c8SDavid Howells #define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__) 84708e0e7c8SDavid Howells 84808e0e7c8SDavid Howells #elif defined(CONFIG_AFS_DEBUG) 84908e0e7c8SDavid Howells #define AFS_DEBUG_KENTER 0x01 85008e0e7c8SDavid Howells #define AFS_DEBUG_KLEAVE 0x02 85108e0e7c8SDavid Howells #define AFS_DEBUG_KDEBUG 0x04 85208e0e7c8SDavid Howells 85308e0e7c8SDavid Howells #define _enter(FMT,...) \ 85408e0e7c8SDavid Howells do { \ 85508e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \ 85608e0e7c8SDavid Howells kenter(FMT,##__VA_ARGS__); \ 85708e0e7c8SDavid Howells } while (0) 85808e0e7c8SDavid Howells 85908e0e7c8SDavid Howells #define _leave(FMT,...) \ 86008e0e7c8SDavid Howells do { \ 86108e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \ 86208e0e7c8SDavid Howells kleave(FMT,##__VA_ARGS__); \ 86308e0e7c8SDavid Howells } while (0) 86408e0e7c8SDavid Howells 86508e0e7c8SDavid Howells #define _debug(FMT,...) \ 86608e0e7c8SDavid Howells do { \ 86708e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \ 86808e0e7c8SDavid Howells kdebug(FMT,##__VA_ARGS__); \ 86908e0e7c8SDavid Howells } while (0) 87008e0e7c8SDavid Howells 87108e0e7c8SDavid Howells #else 87212fdff3fSDavid Howells #define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__) 87312fdff3fSDavid Howells #define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) 87412fdff3fSDavid Howells #define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__) 87508e0e7c8SDavid Howells #endif 87608e0e7c8SDavid Howells 87708e0e7c8SDavid Howells /* 87808e0e7c8SDavid Howells * debug assertion checking 87908e0e7c8SDavid Howells */ 88008e0e7c8SDavid Howells #if 1 // defined(__KDEBUGALL) 88108e0e7c8SDavid Howells 88208e0e7c8SDavid Howells #define ASSERT(X) \ 88308e0e7c8SDavid Howells do { \ 88408e0e7c8SDavid Howells if (unlikely(!(X))) { \ 88508e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 88608e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 88708e0e7c8SDavid Howells BUG(); \ 88808e0e7c8SDavid Howells } \ 88908e0e7c8SDavid Howells } while(0) 89008e0e7c8SDavid Howells 89108e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y) \ 89208e0e7c8SDavid Howells do { \ 89308e0e7c8SDavid Howells if (unlikely(!((X) OP (Y)))) { \ 89408e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 89508e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 89608e0e7c8SDavid Howells printk(KERN_ERR "%lu " #OP " %lu is false\n", \ 89708e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 89808e0e7c8SDavid Howells printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ 89908e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 90008e0e7c8SDavid Howells BUG(); \ 90108e0e7c8SDavid Howells } \ 90208e0e7c8SDavid Howells } while(0) 90308e0e7c8SDavid Howells 904416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H) \ 905416351f2SDavid Howells do { \ 906416351f2SDavid Howells if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) { \ 907416351f2SDavid Howells printk(KERN_ERR "\n"); \ 908416351f2SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 909416351f2SDavid Howells printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n", \ 910416351f2SDavid Howells (unsigned long)(L), (unsigned long)(N), \ 911416351f2SDavid Howells (unsigned long)(H)); \ 912416351f2SDavid Howells printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \ 913416351f2SDavid Howells (unsigned long)(L), (unsigned long)(N), \ 914416351f2SDavid Howells (unsigned long)(H)); \ 915416351f2SDavid Howells BUG(); \ 916416351f2SDavid Howells } \ 917416351f2SDavid Howells } while(0) 918416351f2SDavid Howells 91908e0e7c8SDavid Howells #define ASSERTIF(C, X) \ 92008e0e7c8SDavid Howells do { \ 92108e0e7c8SDavid Howells if (unlikely((C) && !(X))) { \ 92208e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 92308e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 92408e0e7c8SDavid Howells BUG(); \ 92508e0e7c8SDavid Howells } \ 92608e0e7c8SDavid Howells } while(0) 92708e0e7c8SDavid Howells 92808e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y) \ 92908e0e7c8SDavid Howells do { \ 93008e0e7c8SDavid Howells if (unlikely((C) && !((X) OP (Y)))) { \ 93108e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 93208e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 93308e0e7c8SDavid Howells printk(KERN_ERR "%lu " #OP " %lu is false\n", \ 93408e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 93508e0e7c8SDavid Howells printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ 93608e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 93708e0e7c8SDavid Howells BUG(); \ 93808e0e7c8SDavid Howells } \ 93908e0e7c8SDavid Howells } while(0) 94008e0e7c8SDavid Howells 94108e0e7c8SDavid Howells #else 94208e0e7c8SDavid Howells 94308e0e7c8SDavid Howells #define ASSERT(X) \ 94408e0e7c8SDavid Howells do { \ 94508e0e7c8SDavid Howells } while(0) 94608e0e7c8SDavid Howells 94708e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y) \ 94808e0e7c8SDavid Howells do { \ 94908e0e7c8SDavid Howells } while(0) 95008e0e7c8SDavid Howells 951416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H) \ 952416351f2SDavid Howells do { \ 953416351f2SDavid Howells } while(0) 954416351f2SDavid Howells 95508e0e7c8SDavid Howells #define ASSERTIF(C, X) \ 95608e0e7c8SDavid Howells do { \ 95708e0e7c8SDavid Howells } while(0) 95808e0e7c8SDavid Howells 95908e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y) \ 96008e0e7c8SDavid Howells do { \ 96108e0e7c8SDavid Howells } while(0) 96208e0e7c8SDavid Howells 96308e0e7c8SDavid Howells #endif /* __KDEBUGALL */ 964