12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 2ec26815aSDavid Howells /* internal AFS stuff 31da177e4SLinus Torvalds * 408e0e7c8SDavid Howells * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved. 51da177e4SLinus Torvalds * Written by David Howells (dhowells@redhat.com) 61da177e4SLinus Torvalds */ 71da177e4SLinus Torvalds 81da177e4SLinus Torvalds #include <linux/compiler.h> 91da177e4SLinus Torvalds #include <linux/kernel.h> 108a79790bSTina Ruchandani #include <linux/ktime.h> 111da177e4SLinus Torvalds #include <linux/fs.h> 121da177e4SLinus Torvalds #include <linux/pagemap.h> 1308e0e7c8SDavid Howells #include <linux/rxrpc.h> 1400d3b7a4SDavid Howells #include <linux/key.h> 15e8edc6e0SAlexey Dobriyan #include <linux/workqueue.h> 1600c541eaSAndrew Morton #include <linux/sched.h> 1780e50be4SChristoph Hellwig #include <linux/fscache.h> 18e1da0222SJens Axboe #include <linux/backing-dev.h> 19ff548773SDavid Howells #include <linux/uuid.h> 200722f186SSouptick Joarder #include <linux/mm_types.h> 210a5143f2SDavid Howells #include <linux/dns_resolver.h> 22f044c884SDavid Howells #include <net/net_namespace.h> 235b86d4ffSDavid Howells #include <net/netns/generic.h> 245b86d4ffSDavid Howells #include <net/sock.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 356c6c1d63SDavid Howells /* 366c6c1d63SDavid Howells * Partial file-locking emulation mode. (The problem being that AFS3 only 376c6c1d63SDavid Howells * allows whole-file locks and no upgrading/downgrading). 386c6c1d63SDavid Howells */ 396c6c1d63SDavid Howells enum afs_flock_mode { 406c6c1d63SDavid Howells afs_flock_mode_unset, 416c6c1d63SDavid Howells afs_flock_mode_local, /* Local locking only */ 426c6c1d63SDavid Howells afs_flock_mode_openafs, /* Don't get server lock for a partial lock */ 436c6c1d63SDavid Howells afs_flock_mode_strict, /* Always get a server lock for a partial lock */ 446c6c1d63SDavid Howells afs_flock_mode_write, /* Get an exclusive server lock for a partial lock */ 456c6c1d63SDavid Howells }; 466c6c1d63SDavid Howells 4713fcc683SDavid Howells struct afs_fs_context { 4800d3b7a4SDavid Howells bool force; /* T to force cell type */ 49bec5eb61Swanglei bool autocell; /* T if set auto mount operation */ 504d673da1SDavid Howells bool dyn_root; /* T if dynamic root */ 5113fcc683SDavid Howells bool no_cell; /* T if the source is "none" (for dynroot) */ 526c6c1d63SDavid Howells enum afs_flock_mode flock_mode; /* Partial file-locking emulation mode */ 5300d3b7a4SDavid Howells afs_voltype_t type; /* type of volume requested */ 5413fcc683SDavid Howells unsigned int volnamesz; /* size of volume name */ 5500d3b7a4SDavid Howells const char *volname; /* name of volume to mount */ 565b86d4ffSDavid Howells struct afs_net *net; /* the AFS net namespace stuff */ 5700d3b7a4SDavid Howells struct afs_cell *cell; /* cell in which to find volume */ 5800d3b7a4SDavid Howells struct afs_volume *volume; /* volume record */ 5900d3b7a4SDavid Howells struct key *key; /* key to use for secure mounting */ 6000d3b7a4SDavid Howells }; 6100d3b7a4SDavid Howells 628e8d7f13SDavid Howells enum afs_call_state { 6398bf40cdSDavid Howells AFS_CALL_CL_REQUESTING, /* Client: Request is being sent */ 6498bf40cdSDavid Howells AFS_CALL_CL_AWAIT_REPLY, /* Client: Awaiting reply */ 6598bf40cdSDavid Howells AFS_CALL_CL_PROC_REPLY, /* Client: rxrpc call complete; processing reply */ 6698bf40cdSDavid Howells AFS_CALL_SV_AWAIT_OP_ID, /* Server: Awaiting op ID */ 6798bf40cdSDavid Howells AFS_CALL_SV_AWAIT_REQUEST, /* Server: Awaiting request data */ 6898bf40cdSDavid Howells AFS_CALL_SV_REPLYING, /* Server: Replying */ 6998bf40cdSDavid Howells AFS_CALL_SV_AWAIT_ACK, /* Server: Awaiting final ACK */ 708e8d7f13SDavid Howells AFS_CALL_COMPLETE, /* Completed or failed */ 718e8d7f13SDavid Howells }; 72f044c884SDavid Howells 7308e0e7c8SDavid Howells /* 748b2a464cSDavid Howells * List of server addresses. 758b2a464cSDavid Howells */ 768b2a464cSDavid Howells struct afs_addr_list { 77ddd2b85fSJann Horn struct rcu_head rcu; 788b2a464cSDavid Howells refcount_t usage; 79d2ddc776SDavid Howells u32 version; /* Version */ 8068eb64c3SDavid Howells unsigned char max_addrs; 8168eb64c3SDavid Howells unsigned char nr_addrs; 823bf0fb6fSDavid Howells unsigned char preferred; /* Preferred address */ 8368eb64c3SDavid Howells unsigned char nr_ipv4; /* Number of IPv4 addresses */ 840a5143f2SDavid Howells enum dns_record_source source:8; 850a5143f2SDavid Howells enum dns_lookup_status status:8; 863bf0fb6fSDavid Howells unsigned long failed; /* Mask of addrs that failed locally/ICMP */ 873bf0fb6fSDavid Howells unsigned long responded; /* Mask of addrs that responded */ 888b2a464cSDavid Howells struct sockaddr_rxrpc addrs[]; 8968eb64c3SDavid Howells #define AFS_MAX_ADDRESSES ((unsigned int)(sizeof(unsigned long) * 8)) 908b2a464cSDavid Howells }; 918b2a464cSDavid Howells 928b2a464cSDavid Howells /* 9308e0e7c8SDavid Howells * a record of an in-progress RxRPC call 9408e0e7c8SDavid Howells */ 9508e0e7c8SDavid Howells struct afs_call { 9608e0e7c8SDavid Howells const struct afs_call_type *type; /* type of call */ 973bf0fb6fSDavid Howells struct afs_addr_list *alist; /* Address is alist[addr_ix] */ 9808e0e7c8SDavid Howells wait_queue_head_t waitq; /* processes awaiting completion */ 99341f741fSDavid Howells struct work_struct async_work; /* async I/O processor */ 10008e0e7c8SDavid Howells struct work_struct work; /* actual work processor */ 10108e0e7c8SDavid Howells struct rxrpc_call *rxcall; /* RxRPC call handle */ 10208e0e7c8SDavid Howells struct key *key; /* security for this call */ 103f044c884SDavid Howells struct afs_net *net; /* The network namespace */ 104a6853b9cSDavid Howells struct afs_server *server; /* The fileserver record if fs op (pins ref) */ 105a6853b9cSDavid Howells struct afs_vlserver *vlserver; /* The vlserver record if vl op */ 10608e0e7c8SDavid Howells void *request; /* request data (first part) */ 107fc276122SDavid Howells struct iov_iter def_iter; /* Default buffer/data iterator */ 108fc276122SDavid Howells struct iov_iter *iter; /* Iterator currently in use */ 109fc276122SDavid Howells union { /* Convenience for ->def_iter */ 11012bdcf33SDavid Howells struct kvec kvec[1]; 11112bdcf33SDavid Howells struct bio_vec bvec[1]; 11212bdcf33SDavid Howells }; 11308e0e7c8SDavid Howells void *buffer; /* reply receive buffer */ 114ffba718eSDavid Howells union { 115ffba718eSDavid Howells long ret0; /* Value to reply with instead of 0 */ 116ffba718eSDavid Howells struct afs_addr_list *ret_alist; 117ffba718eSDavid Howells struct afs_vldb_entry *ret_vldb; 118c3e9f888SDavid Howells char *ret_str; 119ffba718eSDavid Howells }; 120e49c7b2fSDavid Howells struct afs_operation *op; 121ffba718eSDavid Howells unsigned int server_index; 122341f741fSDavid Howells atomic_t usage; 1238e8d7f13SDavid Howells enum afs_call_state state; 12498bf40cdSDavid Howells spinlock_t state_lock; 12508e0e7c8SDavid Howells int error; /* error code */ 126d001648eSDavid Howells u32 abort_code; /* Remote abort ID or 0 */ 12794f699c9SDavid Howells unsigned int max_lifespan; /* Maximum lifespan to set if not 0 */ 12808e0e7c8SDavid Howells unsigned request_size; /* size of request data */ 12908e0e7c8SDavid Howells unsigned reply_max; /* maximum size of reply */ 130bcd89270SMarc Dionne unsigned count2; /* count used in unmarshalling */ 13108e0e7c8SDavid Howells unsigned char unmarshall; /* unmarshalling phase */ 1323bf0fb6fSDavid Howells unsigned char addr_ix; /* Address in ->alist */ 133dde9f095SDavid Howells bool drop_ref; /* T if need to drop ref for incoming call */ 13431143d5dSDavid Howells bool send_pages; /* T if data from mapping should be sent */ 135d001648eSDavid Howells bool need_attention; /* T if RxRPC poked us */ 13656ff9c83SDavid Howells bool async; /* T if asynchronous */ 137a68f4a27SDavid Howells bool upgrade; /* T to request service upgrade */ 1384571577fSDavid Howells bool have_reply_time; /* T if have got reply_time */ 13920b8391fSDavid Howells bool intr; /* T if interruptible */ 14038355eecSDavid Howells bool unmarshalling_error; /* T if an unmarshalling error occurred */ 141bf99a53cSDavid Howells u16 service_id; /* Actual service ID (after upgrade) */ 142a25e21f0SDavid Howells unsigned int debug_id; /* Trace ID */ 14350a2c953SDavid Howells u32 operation_ID; /* operation ID for an incoming call */ 14408e0e7c8SDavid Howells u32 count; /* count for use in unmarshalling */ 14512bdcf33SDavid Howells union { /* place to extract temporary data */ 14612bdcf33SDavid Howells struct { 14712bdcf33SDavid Howells __be32 tmp_u; 14812bdcf33SDavid Howells __be32 tmp; 14912bdcf33SDavid Howells } __attribute__((packed)); 15012bdcf33SDavid Howells __be64 tmp64; 15112bdcf33SDavid Howells }; 15212d8e95aSDavid Howells ktime_t reply_time; /* Time of first reply packet */ 15308e0e7c8SDavid Howells }; 15408e0e7c8SDavid Howells 15508e0e7c8SDavid Howells struct afs_call_type { 15600d3b7a4SDavid Howells const char *name; 157025db80cSDavid Howells unsigned int op; /* Really enum afs_fs_operation */ 15800d3b7a4SDavid Howells 15908e0e7c8SDavid Howells /* deliver request or reply data to an call 16008e0e7c8SDavid Howells * - returning an error will cause the call to be aborted 16108e0e7c8SDavid Howells */ 162d001648eSDavid Howells int (*deliver)(struct afs_call *call); 16308e0e7c8SDavid Howells 16408e0e7c8SDavid Howells /* clean up a call */ 16508e0e7c8SDavid Howells void (*destructor)(struct afs_call *call); 166341f741fSDavid Howells 167341f741fSDavid Howells /* Work function */ 168341f741fSDavid Howells void (*work)(struct work_struct *work); 1693bf0fb6fSDavid Howells 1703bf0fb6fSDavid Howells /* Call done function (gets called immediately on success or failure) */ 1713bf0fb6fSDavid Howells void (*done)(struct afs_call *call); 17208e0e7c8SDavid Howells }; 17308e0e7c8SDavid Howells 17408e0e7c8SDavid Howells /* 1754343d008SDavid Howells * Key available for writeback on a file. 1764343d008SDavid Howells */ 1774343d008SDavid Howells struct afs_wb_key { 1784343d008SDavid Howells refcount_t usage; 1794343d008SDavid Howells struct key *key; 1804343d008SDavid Howells struct list_head vnode_link; /* Link in vnode->wb_keys */ 1814343d008SDavid Howells }; 1824343d008SDavid Howells 1834343d008SDavid Howells /* 184215804a9SDavid Howells * AFS open file information record. Pointed to by file->private_data. 185215804a9SDavid Howells */ 186215804a9SDavid Howells struct afs_file { 187215804a9SDavid Howells struct key *key; /* The key this file was opened with */ 1884343d008SDavid Howells struct afs_wb_key *wb; /* Writeback key record for this file */ 189215804a9SDavid Howells }; 190215804a9SDavid Howells 191215804a9SDavid Howells static inline struct key *afs_file_key(struct file *file) 192215804a9SDavid Howells { 193215804a9SDavid Howells struct afs_file *af = file->private_data; 194215804a9SDavid Howells 195215804a9SDavid Howells return af->key; 196215804a9SDavid Howells } 197215804a9SDavid Howells 198215804a9SDavid Howells /* 199196ee9cdSDavid Howells * Record of an outstanding read operation on a vnode. 200196ee9cdSDavid Howells */ 201196ee9cdSDavid Howells struct afs_read { 202196ee9cdSDavid Howells loff_t pos; /* Where to start reading */ 203e8e581a8SDavid Howells loff_t len; /* How much we're asking for */ 204196ee9cdSDavid Howells loff_t actual_len; /* How much we're actually getting */ 2056a0e3999SDavid Howells loff_t remain; /* Amount remaining */ 206f3ddee8dSDavid Howells loff_t file_size; /* File size returned by server */ 207f3ddee8dSDavid Howells afs_dataversion_t data_version; /* Version number returned by server */ 208f3ddee8dSDavid Howells refcount_t usage; 209196ee9cdSDavid Howells unsigned int index; /* Which page we're reading into */ 210196ee9cdSDavid Howells unsigned int nr_pages; 21112bdcf33SDavid Howells unsigned int offset; /* offset into current page */ 212a58823acSDavid Howells struct afs_vnode *vnode; 213a58823acSDavid Howells void (*page_done)(struct afs_read *); 214f3ddee8dSDavid Howells struct page **pages; 215f3ddee8dSDavid Howells struct page *array[]; 216196ee9cdSDavid Howells }; 217196ee9cdSDavid Howells 218196ee9cdSDavid Howells /* 21908e0e7c8SDavid Howells * AFS superblock private data 22008e0e7c8SDavid Howells * - there's one superblock per volume 22108e0e7c8SDavid Howells */ 22208e0e7c8SDavid Howells struct afs_super_info { 2235b86d4ffSDavid Howells struct net *net_ns; /* Network namespace */ 22449566f6fSDavid Howells struct afs_cell *cell; /* The cell in which the volume resides */ 22508e0e7c8SDavid Howells struct afs_volume *volume; /* volume record */ 2266c6c1d63SDavid Howells enum afs_flock_mode flock_mode:8; /* File locking emulation mode */ 2274d673da1SDavid Howells bool dyn_root; /* True if dynamic root */ 22808e0e7c8SDavid Howells }; 22908e0e7c8SDavid Howells 23008e0e7c8SDavid Howells static inline struct afs_super_info *AFS_FS_S(struct super_block *sb) 23108e0e7c8SDavid Howells { 23208e0e7c8SDavid Howells return sb->s_fs_info; 23308e0e7c8SDavid Howells } 23408e0e7c8SDavid Howells 23508e0e7c8SDavid Howells extern struct file_system_type afs_fs_type; 23608e0e7c8SDavid Howells 23708e0e7c8SDavid Howells /* 2386f8880d8SDavid Howells * Set of substitutes for @sys. 2396f8880d8SDavid Howells */ 2406f8880d8SDavid Howells struct afs_sysnames { 2416f8880d8SDavid Howells #define AFS_NR_SYSNAME 16 2426f8880d8SDavid Howells char *subs[AFS_NR_SYSNAME]; 2436f8880d8SDavid Howells refcount_t usage; 2446f8880d8SDavid Howells unsigned short nr; 2456f8880d8SDavid Howells char blank[1]; 2466f8880d8SDavid Howells }; 2476f8880d8SDavid Howells 2486f8880d8SDavid Howells /* 249f044c884SDavid Howells * AFS network namespace record. 250f044c884SDavid Howells */ 251f044c884SDavid Howells struct afs_net { 2525b86d4ffSDavid Howells struct net *net; /* Backpointer to the owning net namespace */ 253f044c884SDavid Howells struct afs_uuid uuid; 254f044c884SDavid Howells bool live; /* F if this namespace is being removed */ 255f044c884SDavid Howells 256f044c884SDavid Howells /* AF_RXRPC I/O stuff */ 257f044c884SDavid Howells struct socket *socket; 258f044c884SDavid Howells struct afs_call *spare_incoming_call; 259f044c884SDavid Howells struct work_struct charge_preallocation_work; 260f044c884SDavid Howells struct mutex socket_mutex; 261f044c884SDavid Howells atomic_t nr_outstanding_calls; 262f044c884SDavid Howells atomic_t nr_superblocks; 263f044c884SDavid Howells 264f044c884SDavid Howells /* Cell database */ 265989782dcSDavid Howells struct rb_root cells; 2661588def9SDavid Howells struct afs_cell __rcu *ws_cell; 267989782dcSDavid Howells struct work_struct cells_manager; 268989782dcSDavid Howells struct timer_list cells_timer; 269989782dcSDavid Howells atomic_t cells_outstanding; 270989782dcSDavid Howells seqlock_t cells_lock; 2718a070a96SDavid Howells struct mutex cells_alias_lock; 272f044c884SDavid Howells 2730da0b7fdSDavid Howells struct mutex proc_cells_lock; 2746b3944e4SDavid Howells struct hlist_head proc_cells; 275f044c884SDavid Howells 276d2ddc776SDavid Howells /* Known servers. Theoretically each fileserver can only be in one 277d2ddc776SDavid Howells * cell, but in practice, people create aliases and subsets and there's 278d2ddc776SDavid Howells * no easy way to distinguish them. 279d2ddc776SDavid Howells */ 280f6cbb368SDavid Howells seqlock_t fs_lock; /* For fs_servers, fs_probe_*, fs_proc */ 281d2ddc776SDavid Howells struct rb_root fs_servers; /* afs_server (by server UUID or address) */ 282f6cbb368SDavid Howells struct list_head fs_probe_fast; /* List of afs_server to probe at 30s intervals */ 283f6cbb368SDavid Howells struct list_head fs_probe_slow; /* List of afs_server to probe at 5m intervals */ 284d2ddc776SDavid Howells struct hlist_head fs_proc; /* procfs servers list */ 285d2ddc776SDavid Howells 286d2ddc776SDavid Howells struct hlist_head fs_addresses4; /* afs_server (by lowest IPv4 addr) */ 287d2ddc776SDavid Howells struct hlist_head fs_addresses6; /* afs_server (by lowest IPv6 addr) */ 288d2ddc776SDavid Howells seqlock_t fs_addr_lock; /* For fs_addresses[46] */ 289d2ddc776SDavid Howells 290d2ddc776SDavid Howells struct work_struct fs_manager; 291d2ddc776SDavid Howells struct timer_list fs_timer; 292f6cbb368SDavid Howells 293f6cbb368SDavid Howells struct work_struct fs_prober; 294f6cbb368SDavid Howells struct timer_list fs_probe_timer; 295d2ddc776SDavid Howells atomic_t servers_outstanding; 296f044c884SDavid Howells 297f044c884SDavid Howells /* File locking renewal management */ 298f044c884SDavid Howells struct mutex lock_manager_mutex; 299f044c884SDavid Howells 300f044c884SDavid Howells /* Misc */ 3010da0b7fdSDavid Howells struct super_block *dynroot_sb; /* Dynamic root mount superblock */ 302f044c884SDavid Howells struct proc_dir_entry *proc_afs; /* /proc/net/afs directory */ 3036f8880d8SDavid Howells struct afs_sysnames *sysnames; 3046f8880d8SDavid Howells rwlock_t sysnames_lock; 305d55b4da4SDavid Howells 306d55b4da4SDavid Howells /* Statistics counters */ 307d55b4da4SDavid Howells atomic_t n_lookup; /* Number of lookups done */ 308d55b4da4SDavid Howells atomic_t n_reval; /* Number of dentries needing revalidation */ 309d55b4da4SDavid Howells atomic_t n_inval; /* Number of invalidations by the server */ 310f3ddee8dSDavid Howells atomic_t n_relpg; /* Number of invalidations by releasepage */ 311d55b4da4SDavid Howells atomic_t n_read_dir; /* Number of directory pages read */ 31263a4681fSDavid Howells atomic_t n_dir_cr; /* Number of directory entry creation edits */ 31363a4681fSDavid Howells atomic_t n_dir_rm; /* Number of directory entry removal edits */ 31476a5cb6fSDavid Howells atomic_t n_stores; /* Number of store ops */ 31576a5cb6fSDavid Howells atomic_long_t n_store_bytes; /* Number of bytes stored */ 31676a5cb6fSDavid Howells atomic_long_t n_fetch_bytes; /* Number of bytes fetched */ 31776a5cb6fSDavid Howells atomic_t n_fetches; /* Number of data fetch ops */ 318f044c884SDavid Howells }; 319f044c884SDavid Howells 3206f8880d8SDavid Howells extern const char afs_init_sysname[]; 321f044c884SDavid Howells 322989782dcSDavid Howells enum afs_cell_state { 323989782dcSDavid Howells AFS_CELL_UNSET, 324989782dcSDavid Howells AFS_CELL_ACTIVATING, 325989782dcSDavid Howells AFS_CELL_ACTIVE, 326989782dcSDavid Howells AFS_CELL_DEACTIVATING, 327989782dcSDavid Howells AFS_CELL_INACTIVE, 328989782dcSDavid Howells AFS_CELL_FAILED, 329989782dcSDavid Howells }; 330989782dcSDavid Howells 331f044c884SDavid Howells /* 332d2ddc776SDavid Howells * AFS cell record. 333d2ddc776SDavid Howells * 334d2ddc776SDavid Howells * This is a tricky concept to get right as it is possible to create aliases 335d2ddc776SDavid Howells * simply by pointing AFSDB/SRV records for two names at the same set of VL 336d2ddc776SDavid Howells * servers; it is also possible to do things like setting up two sets of VL 337d2ddc776SDavid Howells * servers, one of which provides a superset of the volumes provided by the 338d2ddc776SDavid Howells * other (for internal/external division, for example). 339d2ddc776SDavid Howells * 340d2ddc776SDavid Howells * Cells only exist in the sense that (a) a cell's name maps to a set of VL 341d2ddc776SDavid Howells * servers and (b) a cell's name is used by the client to select the key to use 342d2ddc776SDavid Howells * for authentication and encryption. The cell name is not typically used in 343d2ddc776SDavid Howells * the protocol. 344d2ddc776SDavid Howells * 3458a070a96SDavid Howells * Two cells are determined to be aliases if they have an explicit alias (YFS 3468a070a96SDavid Howells * only), share any VL servers in common or have at least one volume in common. 3478a070a96SDavid Howells * "In common" means that the address list of the VL servers or the fileservers 3488a070a96SDavid Howells * share at least one endpoint. 34908e0e7c8SDavid Howells */ 35008e0e7c8SDavid Howells struct afs_cell { 351989782dcSDavid Howells union { 352989782dcSDavid Howells struct rcu_head rcu; 353989782dcSDavid Howells struct rb_node net_node; /* Node in net->cells */ 354989782dcSDavid Howells }; 355989782dcSDavid Howells struct afs_net *net; 3568a070a96SDavid Howells struct afs_cell *alias_of; /* The cell this is an alias of */ 3578a070a96SDavid Howells struct afs_volume *root_volume; /* The root.cell volume if there is one */ 35800d3b7a4SDavid Howells struct key *anonymous_key; /* anonymous user key for this cell */ 359989782dcSDavid Howells struct work_struct manager; /* Manager for init/deinit/dns */ 3606b3944e4SDavid Howells struct hlist_node proc_link; /* /proc cell list link */ 3619b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 3629b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 3631da177e4SLinus Torvalds #endif 364989782dcSDavid Howells time64_t dns_expiry; /* Time AFSDB/SRV record expires */ 365989782dcSDavid Howells time64_t last_inactive; /* Time of last drop of usage count */ 366989782dcSDavid Howells atomic_t usage; 367989782dcSDavid Howells unsigned long flags; 368d5c32c89SDavid Howells #define AFS_CELL_FL_NO_GC 0 /* The cell was added manually, don't auto-gc */ 369d5c32c89SDavid Howells #define AFS_CELL_FL_DO_LOOKUP 1 /* DNS lookup requested */ 3708a070a96SDavid Howells #define AFS_CELL_FL_CHECK_ALIAS 2 /* Need to check for aliases */ 371989782dcSDavid Howells enum afs_cell_state state; 372989782dcSDavid Howells short error; 373d5c32c89SDavid Howells enum dns_record_source dns_source:8; /* Latest source of data from lookup */ 374d5c32c89SDavid Howells enum dns_lookup_status dns_status:8; /* Latest status of data from lookup */ 375d5c32c89SDavid Howells unsigned int dns_lookup_count; /* Counter of DNS lookups */ 376989782dcSDavid Howells 37720325960SDavid Howells /* The volumes belonging to this cell */ 37820325960SDavid Howells struct rb_root volumes; /* Tree of volumes on this server */ 37920325960SDavid Howells struct hlist_head proc_volumes; /* procfs volume list */ 38020325960SDavid Howells seqlock_t volume_lock; /* For volumes */ 38120325960SDavid Howells 382d2ddc776SDavid Howells /* Active fileserver interaction state. */ 38320325960SDavid Howells struct rb_root fs_servers; /* afs_server (by server UUID) */ 38420325960SDavid Howells seqlock_t fs_lock; /* For fs_servers */ 385989782dcSDavid Howells 386d2ddc776SDavid Howells /* VL server list. */ 3870a5143f2SDavid Howells rwlock_t vl_servers_lock; /* Lock on vl_servers */ 3880a5143f2SDavid Howells struct afs_vlserver_list __rcu *vl_servers; 3890a5143f2SDavid Howells 390989782dcSDavid Howells u8 name_len; /* Length of name */ 391989782dcSDavid Howells char name[64 + 1]; /* Cell name, case-flattened and NUL-padded */ 39208e0e7c8SDavid Howells }; 39308e0e7c8SDavid Howells 39408e0e7c8SDavid Howells /* 3950a5143f2SDavid Howells * Volume Location server record. 3960a5143f2SDavid Howells */ 3970a5143f2SDavid Howells struct afs_vlserver { 3980a5143f2SDavid Howells struct rcu_head rcu; 3990a5143f2SDavid Howells struct afs_addr_list __rcu *addresses; /* List of addresses for this VL server */ 4000a5143f2SDavid Howells unsigned long flags; 4010a5143f2SDavid Howells #define AFS_VLSERVER_FL_PROBED 0 /* The VL server has been probed */ 4020a5143f2SDavid Howells #define AFS_VLSERVER_FL_PROBING 1 /* VL server is being probed */ 4033bf0fb6fSDavid Howells #define AFS_VLSERVER_FL_IS_YFS 2 /* Server is YFS not AFS */ 4040a5143f2SDavid Howells rwlock_t lock; /* Lock on addresses */ 4050a5143f2SDavid Howells atomic_t usage; 4063bf0fb6fSDavid Howells 4073bf0fb6fSDavid Howells /* Probe state */ 4083bf0fb6fSDavid Howells wait_queue_head_t probe_wq; 4093bf0fb6fSDavid Howells atomic_t probe_outstanding; 4103bf0fb6fSDavid Howells spinlock_t probe_lock; 4113bf0fb6fSDavid Howells struct { 4123bf0fb6fSDavid Howells unsigned int rtt; /* RTT as ktime/64 */ 4133bf0fb6fSDavid Howells u32 abort_code; 4143bf0fb6fSDavid Howells short error; 4153bf0fb6fSDavid Howells bool have_result; 4163bf0fb6fSDavid Howells bool responded:1; 4173bf0fb6fSDavid Howells bool is_yfs:1; 4183bf0fb6fSDavid Howells bool not_yfs:1; 4193bf0fb6fSDavid Howells bool local_failure:1; 4203bf0fb6fSDavid Howells } probe; 4213bf0fb6fSDavid Howells 4220a5143f2SDavid Howells u16 port; 4233bf0fb6fSDavid Howells u16 name_len; /* Length of name */ 4240a5143f2SDavid Howells char name[]; /* Server name, case-flattened */ 4250a5143f2SDavid Howells }; 4260a5143f2SDavid Howells 4270a5143f2SDavid Howells /* 4280a5143f2SDavid Howells * Weighted list of Volume Location servers. 4290a5143f2SDavid Howells */ 4300a5143f2SDavid Howells struct afs_vlserver_entry { 4310a5143f2SDavid Howells u16 priority; /* Preference (as SRV) */ 4320a5143f2SDavid Howells u16 weight; /* Weight (as SRV) */ 4330a5143f2SDavid Howells enum dns_record_source source:8; 4340a5143f2SDavid Howells enum dns_lookup_status status:8; 4350a5143f2SDavid Howells struct afs_vlserver *server; 4360a5143f2SDavid Howells }; 4370a5143f2SDavid Howells 4380a5143f2SDavid Howells struct afs_vlserver_list { 4390a5143f2SDavid Howells struct rcu_head rcu; 4400a5143f2SDavid Howells atomic_t usage; 4410a5143f2SDavid Howells u8 nr_servers; 4420a5143f2SDavid Howells u8 index; /* Server currently in use */ 4433bf0fb6fSDavid Howells u8 preferred; /* Preferred server */ 4440a5143f2SDavid Howells enum dns_record_source source:8; 4450a5143f2SDavid Howells enum dns_lookup_status status:8; 4460a5143f2SDavid Howells rwlock_t lock; 4470a5143f2SDavid Howells struct afs_vlserver_entry servers[]; 4480a5143f2SDavid Howells }; 4490a5143f2SDavid Howells 4500a5143f2SDavid Howells /* 451d2ddc776SDavid Howells * Cached VLDB entry. 452d2ddc776SDavid Howells * 453d2ddc776SDavid Howells * This is pointed to by cell->vldb_entries, indexed by name. 45408e0e7c8SDavid Howells */ 455d2ddc776SDavid Howells struct afs_vldb_entry { 456d2ddc776SDavid Howells afs_volid_t vid[3]; /* Volume IDs for R/W, R/O and Bak volumes */ 45700d3b7a4SDavid Howells 458d2ddc776SDavid Howells unsigned long flags; 459d2ddc776SDavid Howells #define AFS_VLDB_HAS_RW 0 /* - R/W volume exists */ 460d2ddc776SDavid Howells #define AFS_VLDB_HAS_RO 1 /* - R/O volume exists */ 461d2ddc776SDavid Howells #define AFS_VLDB_HAS_BAK 2 /* - Backup volume exists */ 462d2ddc776SDavid Howells #define AFS_VLDB_QUERY_VALID 3 /* - Record is valid */ 463d2ddc776SDavid Howells #define AFS_VLDB_QUERY_ERROR 4 /* - VL server returned error */ 464d2ddc776SDavid Howells 465d2ddc776SDavid Howells uuid_t fs_server[AFS_NMAXNSERVERS]; 46681006805SDavid Howells u32 addr_version[AFS_NMAXNSERVERS]; /* Registration change counters */ 467d2ddc776SDavid Howells u8 fs_mask[AFS_NMAXNSERVERS]; 46808e0e7c8SDavid Howells #define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */ 46908e0e7c8SDavid Howells #define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */ 47008e0e7c8SDavid Howells #define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */ 471d2ddc776SDavid Howells short error; 472d2ddc776SDavid Howells u8 nr_servers; /* Number of server records */ 473d2ddc776SDavid Howells u8 name_len; 474d2ddc776SDavid Howells u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */ 47508e0e7c8SDavid Howells }; 47608e0e7c8SDavid Howells 47708e0e7c8SDavid Howells /* 478d2ddc776SDavid Howells * Record of fileserver with which we're actively communicating. 47908e0e7c8SDavid Howells */ 48008e0e7c8SDavid Howells struct afs_server { 481d2ddc776SDavid Howells struct rcu_head rcu; 482d2ddc776SDavid Howells union { 483d2ddc776SDavid Howells uuid_t uuid; /* Server ID */ 484d2ddc776SDavid Howells struct afs_uuid _uuid; 485d2ddc776SDavid Howells }; 486c435ee34SDavid Howells 487d2ddc776SDavid Howells struct afs_addr_list __rcu *addresses; 48820325960SDavid Howells struct afs_cell *cell; /* Cell to which belongs (pins ref) */ 4893c4c4075SDavid Howells struct rb_node uuid_rb; /* Link in net->fs_servers */ 4903c4c4075SDavid Howells struct afs_server __rcu *uuid_next; /* Next server with same UUID */ 4913c4c4075SDavid Howells struct afs_server *uuid_prev; /* Previous server with same UUID */ 492f6cbb368SDavid Howells struct list_head probe_link; /* Link in net->fs_probe_list */ 493d2ddc776SDavid Howells struct hlist_node addr4_link; /* Link in net->fs_addresses4 */ 494d2ddc776SDavid Howells struct hlist_node addr6_link; /* Link in net->fs_addresses6 */ 495d2ddc776SDavid Howells struct hlist_node proc_link; /* Link in net->fs_proc */ 496d2ddc776SDavid Howells struct afs_server *gc_next; /* Next server in manager's list */ 497977e5f8eSDavid Howells time64_t unuse_time; /* Time at which last unused */ 498c435ee34SDavid Howells unsigned long flags; 499f3c130e6SDavid Howells #define AFS_SERVER_FL_RESPONDING 0 /* The server is responding */ 50032275d3fSDavid Howells #define AFS_SERVER_FL_UPDATING 1 50132275d3fSDavid Howells #define AFS_SERVER_FL_NEEDS_UPDATE 2 /* Fileserver address list is out of date */ 50232275d3fSDavid Howells #define AFS_SERVER_FL_NOT_READY 4 /* The record is not ready for use */ 50332275d3fSDavid Howells #define AFS_SERVER_FL_NOT_FOUND 5 /* VL server says no such server */ 50432275d3fSDavid Howells #define AFS_SERVER_FL_VL_FAIL 6 /* Failed to access VL server */ 505f2686b09SDavid Howells #define AFS_SERVER_FL_MAY_HAVE_CB 8 /* May have callbacks on this fileserver */ 50632275d3fSDavid Howells #define AFS_SERVER_FL_IS_YFS 16 /* Server is YFS not AFS */ 50732275d3fSDavid Howells #define AFS_SERVER_FL_NO_IBULK 17 /* Fileserver doesn't support FS.InlineBulkStatus */ 50832275d3fSDavid Howells #define AFS_SERVER_FL_NO_RM2 18 /* Fileserver doesn't support YFS.RemoveFile2 */ 509977e5f8eSDavid Howells atomic_t ref; /* Object refcount */ 510977e5f8eSDavid Howells atomic_t active; /* Active user count */ 511d2ddc776SDavid Howells u32 addr_version; /* Address list version */ 512f3c130e6SDavid Howells unsigned int rtt; /* Server's current RTT in uS */ 51345218193SDavid Howells unsigned int debug_id; /* Debugging ID for traces */ 51408e0e7c8SDavid Howells 51508e0e7c8SDavid Howells /* file service access */ 516d2ddc776SDavid Howells rwlock_t fs_lock; /* access lock */ 51708e0e7c8SDavid Howells 51808e0e7c8SDavid Howells /* callback promise management */ 519c435ee34SDavid Howells unsigned cb_s_break; /* Break-everything counter. */ 5203bf0fb6fSDavid Howells 5213bf0fb6fSDavid Howells /* Probe state */ 522f6cbb368SDavid Howells unsigned long probed_at; /* Time last probe was dispatched (jiffies) */ 5233bf0fb6fSDavid Howells wait_queue_head_t probe_wq; 5243bf0fb6fSDavid Howells atomic_t probe_outstanding; 5253bf0fb6fSDavid Howells spinlock_t probe_lock; 5263bf0fb6fSDavid Howells struct { 527f3c130e6SDavid Howells unsigned int rtt; /* RTT in uS */ 5283bf0fb6fSDavid Howells u32 abort_code; 5293bf0fb6fSDavid Howells short error; 5303bf0fb6fSDavid Howells bool responded:1; 5313bf0fb6fSDavid Howells bool is_yfs:1; 5323bf0fb6fSDavid Howells bool not_yfs:1; 5333bf0fb6fSDavid Howells bool local_failure:1; 5343bf0fb6fSDavid Howells } probe; 535c435ee34SDavid Howells }; 536c435ee34SDavid Howells 537c435ee34SDavid Howells /* 538194d28cfSDavid Howells * Replaceable volume server list. 53908e0e7c8SDavid Howells */ 540d2ddc776SDavid Howells struct afs_server_entry { 541d2ddc776SDavid Howells struct afs_server *server; 542d2ddc776SDavid Howells }; 543d2ddc776SDavid Howells 544d2ddc776SDavid Howells struct afs_server_list { 545194d28cfSDavid Howells afs_volid_t vids[AFS_MAXTYPES]; /* Volume IDs */ 546d2ddc776SDavid Howells refcount_t usage; 5473bf0fb6fSDavid Howells unsigned char nr_servers; 5483bf0fb6fSDavid Howells unsigned char preferred; /* Preferred server */ 549d2ddc776SDavid Howells unsigned short vnovol_mask; /* Servers to be skipped due to VNOVOL */ 550d2ddc776SDavid Howells unsigned int seq; /* Set to ->servers_seq when installed */ 551d4a96becSDavid Howells rwlock_t lock; 552d2ddc776SDavid Howells struct afs_server_entry servers[]; 55308e0e7c8SDavid Howells }; 55408e0e7c8SDavid Howells 55508e0e7c8SDavid Howells /* 556d2ddc776SDavid Howells * Live AFS volume management. 55708e0e7c8SDavid Howells */ 558d2ddc776SDavid Howells struct afs_volume { 55920325960SDavid Howells union { 56020325960SDavid Howells struct rcu_head rcu; 561d2ddc776SDavid Howells afs_volid_t vid; /* volume ID */ 56220325960SDavid Howells }; 563d2ddc776SDavid Howells atomic_t usage; 564d2ddc776SDavid Howells time64_t update_at; /* Time at which to next update */ 565d2ddc776SDavid Howells struct afs_cell *cell; /* Cell to which belongs (pins ref) */ 56620325960SDavid Howells struct rb_node cell_node; /* Link in cell->volumes */ 56720325960SDavid Howells struct hlist_node proc_link; /* Link in cell->proc_volumes */ 56820325960SDavid Howells struct super_block __rcu *sb; /* Superblock on which inodes reside */ 569d2ddc776SDavid Howells unsigned long flags; 570d2ddc776SDavid Howells #define AFS_VOLUME_NEEDS_UPDATE 0 /* - T if an update needs performing */ 571d2ddc776SDavid Howells #define AFS_VOLUME_UPDATING 1 /* - T if an update is in progress */ 572d2ddc776SDavid Howells #define AFS_VOLUME_WAIT 2 /* - T if users must wait for update */ 573d2ddc776SDavid Howells #define AFS_VOLUME_DELETED 3 /* - T if volume appears deleted */ 574d2ddc776SDavid Howells #define AFS_VOLUME_OFFLINE 4 /* - T if volume offline notice given */ 575d2ddc776SDavid Howells #define AFS_VOLUME_BUSY 5 /* - T if volume busy notice given */ 57620325960SDavid Howells #define AFS_VOLUME_MAYBE_NO_IBULK 6 /* - T if some servers don't have InlineBulkStatus */ 577d2ddc776SDavid Howells #ifdef CONFIG_AFS_FSCACHE 578d2ddc776SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 579d2ddc776SDavid Howells #endif 5808a070a96SDavid Howells struct afs_server_list __rcu *servers; /* List of servers on which volume resides */ 581d2ddc776SDavid Howells rwlock_t servers_lock; /* Lock for ->servers */ 582d2ddc776SDavid Howells unsigned int servers_seq; /* Incremented each time ->servers changes */ 583d2ddc776SDavid Howells 58468251f0aSDavid Howells unsigned cb_v_break; /* Break-everything counter. */ 58590fa9b64SDavid Howells rwlock_t cb_v_break_lock; 58668251f0aSDavid Howells 587d2ddc776SDavid Howells afs_voltype_t type; /* type of volume */ 588d2ddc776SDavid Howells char type_force; /* force volume type (suppress R/O -> R/W) */ 589d2ddc776SDavid Howells u8 name_len; 590d2ddc776SDavid Howells u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */ 59108e0e7c8SDavid Howells }; 59208e0e7c8SDavid Howells 5930fafdc9fSDavid Howells enum afs_lock_state { 5940fafdc9fSDavid Howells AFS_VNODE_LOCK_NONE, /* The vnode has no lock on the server */ 5950fafdc9fSDavid Howells AFS_VNODE_LOCK_WAITING_FOR_CB, /* We're waiting for the server to break the callback */ 5960fafdc9fSDavid Howells AFS_VNODE_LOCK_SETTING, /* We're asking the server for a lock */ 5970fafdc9fSDavid Howells AFS_VNODE_LOCK_GRANTED, /* We have a lock on the server */ 5980fafdc9fSDavid Howells AFS_VNODE_LOCK_EXTENDING, /* We're extending a lock on the server */ 5990fafdc9fSDavid Howells AFS_VNODE_LOCK_NEED_UNLOCK, /* We need to unlock on the server */ 6000fafdc9fSDavid Howells AFS_VNODE_LOCK_UNLOCKING, /* We're telling the server to unlock */ 601cdfb26b4SDavid Howells AFS_VNODE_LOCK_DELETED, /* The vnode has been deleted whilst we have a lock */ 6020fafdc9fSDavid Howells }; 6030fafdc9fSDavid Howells 60408e0e7c8SDavid Howells /* 605f8de483eSDavid Howells * AFS inode private data. 606f8de483eSDavid Howells * 607f8de483eSDavid Howells * Note that afs_alloc_inode() *must* reset anything that could incorrectly 608f8de483eSDavid Howells * leak from one inode to another. 60908e0e7c8SDavid Howells */ 61008e0e7c8SDavid Howells struct afs_vnode { 61108e0e7c8SDavid Howells struct inode vfs_inode; /* the VFS's inode record */ 61208e0e7c8SDavid Howells 61308e0e7c8SDavid Howells struct afs_volume *volume; /* volume on which vnode resides */ 61408e0e7c8SDavid Howells struct afs_fid fid; /* the file identifier for this inode */ 61508e0e7c8SDavid Howells struct afs_file_status status; /* AFS status info for this file */ 616a4ff7401SDavid Howells afs_dataversion_t invalid_before; /* Child dentries are invalid before this */ 6179b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 6189b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 61908e0e7c8SDavid Howells #endif 620fe342cf7SDavid Howells struct afs_permits __rcu *permit_cache; /* cache of permits so far obtained */ 621d2ddc776SDavid Howells struct mutex io_lock; /* Lock for serialising I/O on this mutex */ 622b61f7dcfSDavid Howells struct rw_semaphore validate_lock; /* lock for validating this vnode */ 62379ddbfa5SDavid Howells struct rw_semaphore rmdir_lock; /* Lock for rmdir vs sillyrename */ 62479ddbfa5SDavid Howells struct key *silly_key; /* Silly rename key */ 6254343d008SDavid Howells spinlock_t wb_lock; /* lock for wb_keys */ 62608e0e7c8SDavid Howells spinlock_t lock; /* waitqueue/flags lock */ 62708e0e7c8SDavid Howells unsigned long flags; 628c435ee34SDavid Howells #define AFS_VNODE_CB_PROMISED 0 /* Set if vnode has a callback promise */ 629260a9803SDavid Howells #define AFS_VNODE_UNSET 1 /* set if vnode attributes not yet set */ 630f3ddee8dSDavid Howells #define AFS_VNODE_DIR_VALID 2 /* Set if dir contents are valid */ 63108e0e7c8SDavid Howells #define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */ 63208e0e7c8SDavid Howells #define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */ 63308e0e7c8SDavid Howells #define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */ 6340fafdc9fSDavid Howells #define AFS_VNODE_AUTOCELL 6 /* set if Vnode is an auto mount point */ 6350fafdc9fSDavid Howells #define AFS_VNODE_PSEUDODIR 7 /* set if Vnode is a pseudo directory */ 6365a813276SDavid Howells #define AFS_VNODE_NEW_CONTENT 8 /* Set if file has new content (create/trunc-0) */ 63708e0e7c8SDavid Howells 6384343d008SDavid Howells struct list_head wb_keys; /* List of keys available for writeback */ 639e8d6c554SDavid Howells struct list_head pending_locks; /* locks waiting to be granted */ 640e8d6c554SDavid Howells struct list_head granted_locks; /* locks granted on this file */ 641e8d6c554SDavid Howells struct delayed_work lock_work; /* work to be done in locking */ 6420fafdc9fSDavid Howells struct key *lock_key; /* Key to be used in lock ops */ 643a690f60aSDavid Howells ktime_t locked_at; /* Time at which lock obtained */ 6440fafdc9fSDavid Howells enum afs_lock_state lock_state : 8; 6450fafdc9fSDavid Howells afs_lock_type_t lock_type : 8; 64631143d5dSDavid Howells 64708e0e7c8SDavid Howells /* outstanding callback notification on this file */ 64820325960SDavid Howells void *cb_server; /* Server with callback/filelock */ 649c435ee34SDavid Howells unsigned int cb_s_break; /* Mass break counter on ->server */ 65068251f0aSDavid Howells unsigned int cb_v_break; /* Mass break counter on ->volume */ 651c435ee34SDavid Howells unsigned int cb_break; /* Break counter on vnode */ 65220325960SDavid Howells seqlock_t cb_lock; /* Lock for ->cb_server, ->status, ->cb_*break */ 653c435ee34SDavid Howells 654c435ee34SDavid Howells time64_t cb_expires_at; /* time at which callback expires */ 65508e0e7c8SDavid Howells }; 65608e0e7c8SDavid Howells 65712bdcf33SDavid Howells static inline struct fscache_cookie *afs_vnode_cache(struct afs_vnode *vnode) 65812bdcf33SDavid Howells { 65912bdcf33SDavid Howells #ifdef CONFIG_AFS_FSCACHE 66012bdcf33SDavid Howells return vnode->cache; 66112bdcf33SDavid Howells #else 66212bdcf33SDavid Howells return NULL; 66312bdcf33SDavid Howells #endif 66412bdcf33SDavid Howells } 66512bdcf33SDavid Howells 66600d3b7a4SDavid Howells /* 66700d3b7a4SDavid Howells * cached security record for one user's attempt to access a vnode 66800d3b7a4SDavid Howells */ 66900d3b7a4SDavid Howells struct afs_permit { 67000d3b7a4SDavid Howells struct key *key; /* RxRPC ticket holding a security context */ 671be080a6fSDavid Howells afs_access_t access; /* CallerAccess value for this key */ 67200d3b7a4SDavid Howells }; 67300d3b7a4SDavid Howells 67400d3b7a4SDavid Howells /* 675be080a6fSDavid Howells * Immutable cache of CallerAccess records from attempts to access vnodes. 676be080a6fSDavid Howells * These may be shared between multiple vnodes. 67700d3b7a4SDavid Howells */ 67800d3b7a4SDavid Howells struct afs_permits { 679be080a6fSDavid Howells struct rcu_head rcu; 680be080a6fSDavid Howells struct hlist_node hash_node; /* Link in hash */ 681be080a6fSDavid Howells unsigned long h; /* Hash value for this permit list */ 682be080a6fSDavid Howells refcount_t usage; 683be080a6fSDavid Howells unsigned short nr_permits; /* Number of records */ 684be080a6fSDavid Howells bool invalidated; /* Invalidated due to key change */ 685be080a6fSDavid Howells struct afs_permit permits[]; /* List of permits sorted by key pointer */ 68600d3b7a4SDavid Howells }; 68700d3b7a4SDavid Howells 688b908fe6bSDavid Howells /* 6894584ae96SDavid Howells * Error prioritisation and accumulation. 6904584ae96SDavid Howells */ 6914584ae96SDavid Howells struct afs_error { 6924584ae96SDavid Howells short error; /* Accumulated error */ 6934584ae96SDavid Howells bool responded; /* T if server responded */ 6944584ae96SDavid Howells }; 6954584ae96SDavid Howells 6964584ae96SDavid Howells /* 6978b2a464cSDavid Howells * Cursor for iterating over a server's address list. 6988b2a464cSDavid Howells */ 6998b2a464cSDavid Howells struct afs_addr_cursor { 7008b2a464cSDavid Howells struct afs_addr_list *alist; /* Current address list (pins ref) */ 7013bf0fb6fSDavid Howells unsigned long tried; /* Tried addresses */ 7023bf0fb6fSDavid Howells signed char index; /* Current address */ 7038b2a464cSDavid Howells bool responded; /* T if the current address responded */ 704744bcd71SDavid Howells unsigned short nr_iterations; /* Number of address iterations */ 7053bf0fb6fSDavid Howells short error; 7063bf0fb6fSDavid Howells u32 abort_code; 7078b2a464cSDavid Howells }; 7088b2a464cSDavid Howells 7098b2a464cSDavid Howells /* 7100a5143f2SDavid Howells * Cursor for iterating over a set of volume location servers. 7110a5143f2SDavid Howells */ 7120a5143f2SDavid Howells struct afs_vl_cursor { 7130a5143f2SDavid Howells struct afs_addr_cursor ac; 7140a5143f2SDavid Howells struct afs_cell *cell; /* The cell we're querying */ 7150a5143f2SDavid Howells struct afs_vlserver_list *server_list; /* Current server list (pins ref) */ 7163bf0fb6fSDavid Howells struct afs_vlserver *server; /* Server on which this resides */ 7170a5143f2SDavid Howells struct key *key; /* Key for the server */ 7183bf0fb6fSDavid Howells unsigned long untried; /* Bitmask of untried servers */ 7193bf0fb6fSDavid Howells short index; /* Current server */ 7200a5143f2SDavid Howells short error; 7210a5143f2SDavid Howells unsigned short flags; 7220a5143f2SDavid Howells #define AFS_VL_CURSOR_STOP 0x0001 /* Set to cease iteration */ 7230a5143f2SDavid Howells #define AFS_VL_CURSOR_RETRY 0x0002 /* Set to do a retry */ 7240a5143f2SDavid Howells #define AFS_VL_CURSOR_RETRIED 0x0004 /* Set if started a retry */ 725744bcd71SDavid Howells unsigned short nr_iterations; /* Number of server iterations */ 7260a5143f2SDavid Howells }; 7270a5143f2SDavid Howells 7280a5143f2SDavid Howells /* 729e49c7b2fSDavid Howells * Fileserver operation methods. 730e49c7b2fSDavid Howells */ 731e49c7b2fSDavid Howells struct afs_operation_ops { 732e49c7b2fSDavid Howells void (*issue_afs_rpc)(struct afs_operation *op); 733e49c7b2fSDavid Howells void (*issue_yfs_rpc)(struct afs_operation *op); 734e49c7b2fSDavid Howells void (*success)(struct afs_operation *op); 735e49c7b2fSDavid Howells void (*aborted)(struct afs_operation *op); 736e49c7b2fSDavid Howells void (*edit_dir)(struct afs_operation *op); 737e49c7b2fSDavid Howells void (*put)(struct afs_operation *op); 738e49c7b2fSDavid Howells }; 739e49c7b2fSDavid Howells 740e49c7b2fSDavid Howells struct afs_vnode_param { 741e49c7b2fSDavid Howells struct afs_vnode *vnode; 742e49c7b2fSDavid Howells struct afs_fid fid; /* Fid to access */ 743e49c7b2fSDavid Howells struct afs_status_cb scb; /* Returned status and callback promise */ 744e49c7b2fSDavid Howells afs_dataversion_t dv_before; /* Data version before the call */ 745e49c7b2fSDavid Howells unsigned int cb_break_before; /* cb_break + cb_s_break before the call */ 746e49c7b2fSDavid Howells u8 dv_delta; /* Expected change in data version */ 747e49c7b2fSDavid Howells bool put_vnode; /* T if we have a ref on the vnode */ 748e49c7b2fSDavid Howells bool need_io_lock; /* T if we need the I/O lock on this */ 749e49c7b2fSDavid Howells }; 750e49c7b2fSDavid Howells 751e49c7b2fSDavid Howells /* 752e49c7b2fSDavid Howells * Fileserver operation wrapper, handling server and address rotation 753e49c7b2fSDavid Howells * asynchronously. May make simultaneous calls to multiple servers. 7548b2a464cSDavid Howells */ 755a310082fSDavid Howells struct afs_operation { 756e49c7b2fSDavid Howells struct afs_net *net; /* Network namespace */ 757e49c7b2fSDavid Howells struct key *key; /* Key for the cell */ 758a58823acSDavid Howells const struct afs_call_type *type; /* Type of call done */ 759e49c7b2fSDavid Howells const struct afs_operation_ops *ops; 760e49c7b2fSDavid Howells 761e49c7b2fSDavid Howells /* Parameters/results for the operation */ 762e49c7b2fSDavid Howells struct afs_volume *volume; /* Volume being accessed */ 763e49c7b2fSDavid Howells struct afs_vnode_param file[2]; 764e49c7b2fSDavid Howells struct afs_vnode_param *more_files; 765e49c7b2fSDavid Howells struct afs_volsync volsync; 766e49c7b2fSDavid Howells struct dentry *dentry; /* Dentry to be altered */ 767e49c7b2fSDavid Howells struct dentry *dentry_2; /* Second dentry to be altered */ 768e49c7b2fSDavid Howells struct timespec64 mtime; /* Modification time to record */ 769e49c7b2fSDavid Howells short nr_files; /* Number of entries in file[], more_files */ 770e49c7b2fSDavid Howells short error; 771e49c7b2fSDavid Howells unsigned int abort_code; 772e49c7b2fSDavid Howells unsigned int debug_id; 773e49c7b2fSDavid Howells 774e49c7b2fSDavid Howells unsigned int cb_v_break; /* Volume break counter before op */ 775e49c7b2fSDavid Howells unsigned int cb_s_break; /* Server break counter before op */ 776e49c7b2fSDavid Howells 777e49c7b2fSDavid Howells union { 778e49c7b2fSDavid Howells struct { 779e49c7b2fSDavid Howells int which; /* Which ->file[] to fetch for */ 780e49c7b2fSDavid Howells } fetch_status; 781e49c7b2fSDavid Howells struct { 782e49c7b2fSDavid Howells int reason; /* enum afs_edit_dir_reason */ 783e49c7b2fSDavid Howells mode_t mode; 784e49c7b2fSDavid Howells const char *symlink; 785e49c7b2fSDavid Howells } create; 786e49c7b2fSDavid Howells struct { 787e49c7b2fSDavid Howells bool need_rehash; 788e49c7b2fSDavid Howells } unlink; 789e49c7b2fSDavid Howells struct { 790e49c7b2fSDavid Howells struct dentry *rehash; 791e49c7b2fSDavid Howells struct dentry *tmp; 792e49c7b2fSDavid Howells bool new_negative; 793e49c7b2fSDavid Howells } rename; 794e49c7b2fSDavid Howells struct { 795e49c7b2fSDavid Howells struct afs_read *req; 796e49c7b2fSDavid Howells } fetch; 797e49c7b2fSDavid Howells struct { 798e49c7b2fSDavid Howells struct afs_vnode *lvnode; /* vnode being locked */ 799e49c7b2fSDavid Howells afs_lock_type_t type; 800e49c7b2fSDavid Howells } lock; 801e49c7b2fSDavid Howells struct { 802e49c7b2fSDavid Howells struct address_space *mapping; /* Pages being written from */ 803e49c7b2fSDavid Howells pgoff_t first; /* first page in mapping to deal with */ 804e49c7b2fSDavid Howells pgoff_t last; /* last page in mapping to deal with */ 805e49c7b2fSDavid Howells unsigned first_offset; /* offset into mapping[first] */ 806e49c7b2fSDavid Howells unsigned last_to; /* amount of mapping[last] */ 807e49c7b2fSDavid Howells } store; 808e49c7b2fSDavid Howells struct { 809e49c7b2fSDavid Howells struct iattr *attr; 810e49c7b2fSDavid Howells } setattr; 811e49c7b2fSDavid Howells struct afs_acl *acl; 812e49c7b2fSDavid Howells struct yfs_acl *yacl; 813e49c7b2fSDavid Howells struct { 814e49c7b2fSDavid Howells struct afs_volume_status vs; 815e49c7b2fSDavid Howells struct kstatfs *buf; 816e49c7b2fSDavid Howells } volstatus; 817e49c7b2fSDavid Howells }; 818e49c7b2fSDavid Howells 819e49c7b2fSDavid Howells /* Fileserver iteration state */ 8208b2a464cSDavid Howells struct afs_addr_cursor ac; 821d2ddc776SDavid Howells struct afs_server_list *server_list; /* Current server list (pins ref) */ 82220325960SDavid Howells struct afs_server *server; /* Server we're using (ref pinned by server_list) */ 823e49c7b2fSDavid Howells struct afs_call *call; 8243bf0fb6fSDavid Howells unsigned long untried; /* Bitmask of untried servers */ 8253bf0fb6fSDavid Howells short index; /* Current server */ 826e49c7b2fSDavid Howells unsigned short nr_iterations; /* Number of server iterations */ 827e49c7b2fSDavid Howells 828e49c7b2fSDavid Howells unsigned int flags; 829a310082fSDavid Howells #define AFS_OPERATION_STOP 0x0001 /* Set to cease iteration */ 830a310082fSDavid Howells #define AFS_OPERATION_VBUSY 0x0002 /* Set if seen VBUSY */ 831a310082fSDavid Howells #define AFS_OPERATION_VMOVED 0x0004 /* Set if seen VMOVED */ 832a310082fSDavid Howells #define AFS_OPERATION_VNOVOL 0x0008 /* Set if seen VNOVOL */ 833a310082fSDavid Howells #define AFS_OPERATION_CUR_ONLY 0x0010 /* Set if current server only (file lock held) */ 834a310082fSDavid Howells #define AFS_OPERATION_NO_VSLEEP 0x0020 /* Set to prevent sleep on VBUSY, VOFFLINE, ... */ 835e49c7b2fSDavid Howells #define AFS_OPERATION_UNINTR 0x0040 /* Set if op is uninterruptible */ 836e49c7b2fSDavid Howells #define AFS_OPERATION_DOWNGRADE 0x0080 /* Set to retry with downgraded opcode */ 837e49c7b2fSDavid Howells #define AFS_OPERATION_LOCK_0 0x0100 /* Set if have io_lock on file[0] */ 838e49c7b2fSDavid Howells #define AFS_OPERATION_LOCK_1 0x0200 /* Set if have io_lock on file[1] */ 8398b2a464cSDavid Howells }; 8408b2a464cSDavid Howells 841402cb8ddSDavid Howells /* 842402cb8ddSDavid Howells * Cache auxiliary data. 843402cb8ddSDavid Howells */ 844402cb8ddSDavid Howells struct afs_vnode_cache_aux { 845402cb8ddSDavid Howells u64 data_version; 846402cb8ddSDavid Howells } __packed; 847402cb8ddSDavid Howells 84898bf40cdSDavid Howells #include <trace/events/afs.h> 84998bf40cdSDavid Howells 85008e0e7c8SDavid Howells /*****************************************************************************/ 85108e0e7c8SDavid Howells /* 8528b2a464cSDavid Howells * addr_list.c 8538b2a464cSDavid Howells */ 8548b2a464cSDavid Howells static inline struct afs_addr_list *afs_get_addrlist(struct afs_addr_list *alist) 8558b2a464cSDavid Howells { 8568b2a464cSDavid Howells if (alist) 8578b2a464cSDavid Howells refcount_inc(&alist->usage); 8588b2a464cSDavid Howells return alist; 8598b2a464cSDavid Howells } 8608b2a464cSDavid Howells extern struct afs_addr_list *afs_alloc_addrlist(unsigned int, 8618b2a464cSDavid Howells unsigned short, 8628b2a464cSDavid Howells unsigned short); 8638b2a464cSDavid Howells extern void afs_put_addrlist(struct afs_addr_list *); 8640a5143f2SDavid Howells extern struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *, 8650a5143f2SDavid Howells const char *, size_t, char, 8668b2a464cSDavid Howells unsigned short, unsigned short); 8670a5143f2SDavid Howells extern struct afs_vlserver_list *afs_dns_query(struct afs_cell *, time64_t *); 8688b2a464cSDavid Howells extern bool afs_iterate_addresses(struct afs_addr_cursor *); 8698b2a464cSDavid Howells extern int afs_end_cursor(struct afs_addr_cursor *); 8708b2a464cSDavid Howells 871bf99a53cSDavid Howells extern void afs_merge_fs_addr4(struct afs_addr_list *, __be32, u16); 872bf99a53cSDavid Howells extern void afs_merge_fs_addr6(struct afs_addr_list *, __be32 *, u16); 873d2ddc776SDavid Howells 8748b2a464cSDavid Howells /* 8759b3f26c9SDavid Howells * cache.c 8769b3f26c9SDavid Howells */ 8779b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 8789b3f26c9SDavid Howells extern struct fscache_netfs afs_cache_netfs; 8799b3f26c9SDavid Howells extern struct fscache_cookie_def afs_cell_cache_index_def; 8809b3f26c9SDavid Howells extern struct fscache_cookie_def afs_volume_cache_index_def; 8819b3f26c9SDavid Howells extern struct fscache_cookie_def afs_vnode_cache_index_def; 8829b3f26c9SDavid Howells #else 8839b3f26c9SDavid Howells #define afs_cell_cache_index_def (*(struct fscache_cookie_def *) NULL) 8849b3f26c9SDavid Howells #define afs_volume_cache_index_def (*(struct fscache_cookie_def *) NULL) 8859b3f26c9SDavid Howells #define afs_vnode_cache_index_def (*(struct fscache_cookie_def *) NULL) 8869b3f26c9SDavid Howells #endif 8879b3f26c9SDavid Howells 8889b3f26c9SDavid Howells /* 88908e0e7c8SDavid Howells * callback.c 89008e0e7c8SDavid Howells */ 89108e0e7c8SDavid Howells extern void afs_init_callback_state(struct afs_server *); 892051d2525SDavid Howells extern void __afs_break_callback(struct afs_vnode *, enum afs_cb_break_reason); 893051d2525SDavid Howells extern void afs_break_callback(struct afs_vnode *, enum afs_cb_break_reason); 8945cf9dd55SDavid Howells extern void afs_break_callbacks(struct afs_server *, size_t, struct afs_callback_break *); 895c435ee34SDavid Howells 89668251f0aSDavid Howells static inline unsigned int afs_calc_vnode_cb_break(struct afs_vnode *vnode) 89768251f0aSDavid Howells { 898eeba1e9cSDavid Howells return vnode->cb_break + vnode->cb_v_break; 89968251f0aSDavid Howells } 90068251f0aSDavid Howells 90118ac6185SDavid Howells static inline bool afs_cb_is_broken(unsigned int cb_break, 90220325960SDavid Howells const struct afs_vnode *vnode) 90368251f0aSDavid Howells { 90420325960SDavid Howells return cb_break != (vnode->cb_break + vnode->volume->cb_v_break); 90568251f0aSDavid Howells } 90668251f0aSDavid Howells 9071da177e4SLinus Torvalds /* 9081da177e4SLinus Torvalds * cell.c 9091da177e4SLinus Torvalds */ 910989782dcSDavid Howells extern int afs_cell_init(struct afs_net *, const char *); 911989782dcSDavid Howells extern struct afs_cell *afs_lookup_cell_rcu(struct afs_net *, const char *, unsigned); 912989782dcSDavid Howells extern struct afs_cell *afs_lookup_cell(struct afs_net *, const char *, unsigned, 913989782dcSDavid Howells const char *, bool); 9148b2a464cSDavid Howells extern struct afs_cell *afs_get_cell(struct afs_cell *); 9159ed900b1SDavid Howells extern void afs_put_cell(struct afs_net *, struct afs_cell *); 916989782dcSDavid Howells extern void afs_manage_cells(struct work_struct *); 917989782dcSDavid Howells extern void afs_cells_timer(struct timer_list *); 918f044c884SDavid Howells extern void __net_exit afs_cell_purge(struct afs_net *); 91908e0e7c8SDavid Howells 92008e0e7c8SDavid Howells /* 92108e0e7c8SDavid Howells * cmservice.c 92208e0e7c8SDavid Howells */ 92308e0e7c8SDavid Howells extern bool afs_cm_incoming_call(struct afs_call *); 92408e0e7c8SDavid Howells 9251da177e4SLinus Torvalds /* 9261da177e4SLinus Torvalds * dir.c 9271da177e4SLinus Torvalds */ 9284b6f5d20SArjan van de Ven extern const struct file_operations afs_dir_file_operations; 9294d673da1SDavid Howells extern const struct inode_operations afs_dir_inode_operations; 930f3ddee8dSDavid Howells extern const struct address_space_operations afs_dir_aops; 9314d673da1SDavid Howells extern const struct dentry_operations afs_fs_dentry_operations; 9324d673da1SDavid Howells 93366c7e1d3SDavid Howells extern void afs_d_release(struct dentry *); 93466c7e1d3SDavid Howells 93566c7e1d3SDavid Howells /* 93663a4681fSDavid Howells * dir_edit.c 93763a4681fSDavid Howells */ 93863a4681fSDavid Howells extern void afs_edit_dir_add(struct afs_vnode *, struct qstr *, struct afs_fid *, 93963a4681fSDavid Howells enum afs_edit_dir_reason); 94063a4681fSDavid Howells extern void afs_edit_dir_remove(struct afs_vnode *, struct qstr *, enum afs_edit_dir_reason); 94163a4681fSDavid Howells 94263a4681fSDavid Howells /* 94379ddbfa5SDavid Howells * dir_silly.c 94479ddbfa5SDavid Howells */ 94579ddbfa5SDavid Howells extern int afs_sillyrename(struct afs_vnode *, struct afs_vnode *, 94679ddbfa5SDavid Howells struct dentry *, struct key *); 94779ddbfa5SDavid Howells extern int afs_silly_iput(struct dentry *, struct inode *); 94879ddbfa5SDavid Howells 94979ddbfa5SDavid Howells /* 95066c7e1d3SDavid Howells * dynroot.c 95166c7e1d3SDavid Howells */ 95266c7e1d3SDavid Howells extern const struct inode_operations afs_dynroot_inode_operations; 95366c7e1d3SDavid Howells extern const struct dentry_operations afs_dynroot_dentry_operations; 95466c7e1d3SDavid Howells 95566c7e1d3SDavid Howells extern struct inode *afs_try_auto_mntpt(struct dentry *, struct inode *); 9560da0b7fdSDavid Howells extern int afs_dynroot_mkdir(struct afs_net *, struct afs_cell *); 9570da0b7fdSDavid Howells extern void afs_dynroot_rmdir(struct afs_net *, struct afs_cell *); 9580da0b7fdSDavid Howells extern int afs_dynroot_populate(struct super_block *); 9590da0b7fdSDavid Howells extern void afs_dynroot_depopulate(struct super_block *); 9601da177e4SLinus Torvalds 9611da177e4SLinus Torvalds /* 9621da177e4SLinus Torvalds * file.c 9631da177e4SLinus Torvalds */ 964f5e54d6eSChristoph Hellwig extern const struct address_space_operations afs_fs_aops; 965754661f1SArjan van de Ven extern const struct inode_operations afs_file_inode_operations; 96600d3b7a4SDavid Howells extern const struct file_operations afs_file_operations; 96700d3b7a4SDavid Howells 9684343d008SDavid Howells extern int afs_cache_wb_key(struct afs_vnode *, struct afs_file *); 9694343d008SDavid Howells extern void afs_put_wb_key(struct afs_wb_key *); 97000d3b7a4SDavid Howells extern int afs_open(struct inode *, struct file *); 97100d3b7a4SDavid Howells extern int afs_release(struct inode *, struct file *); 972d2ddc776SDavid Howells extern int afs_fetch_data(struct afs_vnode *, struct key *, struct afs_read *); 973f6d335c0SAl Viro extern int afs_page_filler(void *, struct page *); 974196ee9cdSDavid Howells extern void afs_put_read(struct afs_read *); 9751da177e4SLinus Torvalds 976d4438a25SDavid Howells static inline struct afs_read *afs_get_read(struct afs_read *req) 977d4438a25SDavid Howells { 978d4438a25SDavid Howells refcount_inc(&req->usage); 979d4438a25SDavid Howells return req; 980d4438a25SDavid Howells } 981d4438a25SDavid Howells 9821da177e4SLinus Torvalds /* 983e8d6c554SDavid Howells * flock.c 984e8d6c554SDavid Howells */ 985f044c884SDavid Howells extern struct workqueue_struct *afs_lock_manager; 986f044c884SDavid Howells 987a690f60aSDavid Howells extern void afs_lock_op_done(struct afs_call *); 988e8d6c554SDavid Howells extern void afs_lock_work(struct work_struct *); 989e8d6c554SDavid Howells extern void afs_lock_may_be_available(struct afs_vnode *); 990e8d6c554SDavid Howells extern int afs_lock(struct file *, int, struct file_lock *); 991e8d6c554SDavid Howells extern int afs_flock(struct file *, int, struct file_lock *); 992e8d6c554SDavid Howells 993e8d6c554SDavid Howells /* 99408e0e7c8SDavid Howells * fsclient.c 99508e0e7c8SDavid Howells */ 996e49c7b2fSDavid Howells extern void afs_fs_fetch_status(struct afs_operation *); 997e49c7b2fSDavid Howells extern void afs_fs_fetch_data(struct afs_operation *); 998e49c7b2fSDavid Howells extern void afs_fs_create_file(struct afs_operation *); 999e49c7b2fSDavid Howells extern void afs_fs_make_dir(struct afs_operation *); 1000e49c7b2fSDavid Howells extern void afs_fs_remove_file(struct afs_operation *); 1001e49c7b2fSDavid Howells extern void afs_fs_remove_dir(struct afs_operation *); 1002e49c7b2fSDavid Howells extern void afs_fs_link(struct afs_operation *); 1003e49c7b2fSDavid Howells extern void afs_fs_symlink(struct afs_operation *); 1004e49c7b2fSDavid Howells extern void afs_fs_rename(struct afs_operation *); 1005e49c7b2fSDavid Howells extern void afs_fs_store_data(struct afs_operation *); 1006e49c7b2fSDavid Howells extern void afs_fs_setattr(struct afs_operation *); 1007e49c7b2fSDavid Howells extern void afs_fs_get_volume_status(struct afs_operation *); 1008e49c7b2fSDavid Howells extern void afs_fs_set_lock(struct afs_operation *); 1009e49c7b2fSDavid Howells extern void afs_fs_extend_lock(struct afs_operation *); 1010e49c7b2fSDavid Howells extern void afs_fs_release_lock(struct afs_operation *); 1011d2ddc776SDavid Howells extern int afs_fs_give_up_all_callbacks(struct afs_net *, struct afs_server *, 1012d2ddc776SDavid Howells struct afs_addr_cursor *, struct key *); 1013f6cbb368SDavid Howells extern bool afs_fs_get_capabilities(struct afs_net *, struct afs_server *, 1014f6cbb368SDavid Howells struct afs_addr_cursor *, struct key *); 1015e49c7b2fSDavid Howells extern void afs_fs_inline_bulk_status(struct afs_operation *); 101608e0e7c8SDavid Howells 1017260f082bSDavid Howells struct afs_acl { 1018260f082bSDavid Howells u32 size; 1019260f082bSDavid Howells u8 data[]; 1020260f082bSDavid Howells }; 1021260f082bSDavid Howells 1022e49c7b2fSDavid Howells extern void afs_fs_fetch_acl(struct afs_operation *); 1023e49c7b2fSDavid Howells extern void afs_fs_store_acl(struct afs_operation *); 1024e49c7b2fSDavid Howells 1025e49c7b2fSDavid Howells /* 1026e49c7b2fSDavid Howells * fs_operation.c 1027e49c7b2fSDavid Howells */ 1028e49c7b2fSDavid Howells extern struct afs_operation *afs_alloc_operation(struct key *, struct afs_volume *); 1029e49c7b2fSDavid Howells extern int afs_put_operation(struct afs_operation *); 1030e49c7b2fSDavid Howells extern bool afs_begin_vnode_operation(struct afs_operation *); 1031e49c7b2fSDavid Howells extern void afs_wait_for_operation(struct afs_operation *); 1032e49c7b2fSDavid Howells extern int afs_do_sync_operation(struct afs_operation *); 1033e49c7b2fSDavid Howells 1034e49c7b2fSDavid Howells static inline void afs_op_nomem(struct afs_operation *op) 1035e49c7b2fSDavid Howells { 1036e49c7b2fSDavid Howells op->error = -ENOMEM; 1037e49c7b2fSDavid Howells } 1038e49c7b2fSDavid Howells 1039e49c7b2fSDavid Howells static inline void afs_op_set_vnode(struct afs_operation *op, unsigned int n, 1040e49c7b2fSDavid Howells struct afs_vnode *vnode) 1041e49c7b2fSDavid Howells { 1042e49c7b2fSDavid Howells op->file[n].vnode = vnode; 1043e49c7b2fSDavid Howells op->file[n].need_io_lock = true; 1044e49c7b2fSDavid Howells } 1045e49c7b2fSDavid Howells 1046e49c7b2fSDavid Howells static inline void afs_op_set_fid(struct afs_operation *op, unsigned int n, 1047e49c7b2fSDavid Howells const struct afs_fid *fid) 1048e49c7b2fSDavid Howells { 1049e49c7b2fSDavid Howells op->file[n].fid = *fid; 1050e49c7b2fSDavid Howells } 1051260f082bSDavid Howells 105208e0e7c8SDavid Howells /* 10533bf0fb6fSDavid Howells * fs_probe.c 10543bf0fb6fSDavid Howells */ 10553bf0fb6fSDavid Howells extern void afs_fileserver_probe_result(struct afs_call *); 1056f6cbb368SDavid Howells extern void afs_fs_probe_fileserver(struct afs_net *, struct afs_server *, struct key *, bool); 10573bf0fb6fSDavid Howells extern int afs_wait_for_fs_probes(struct afs_server_list *, unsigned long); 1058f6cbb368SDavid Howells extern void afs_fs_probe_dispatcher(struct work_struct *); 10593bf0fb6fSDavid Howells 10603bf0fb6fSDavid Howells /* 10611da177e4SLinus Torvalds * inode.c 10621da177e4SLinus Torvalds */ 1063e49c7b2fSDavid Howells extern void afs_vnode_commit_status(struct afs_operation *, struct afs_vnode_param *); 1064a58823acSDavid Howells extern int afs_fetch_status(struct afs_vnode *, struct key *, bool, afs_access_t *); 1065e49c7b2fSDavid Howells extern int afs_ilookup5_test_by_fid(struct inode *, void *); 10664d673da1SDavid Howells extern struct inode *afs_iget_pseudo_dir(struct super_block *, bool); 1067e49c7b2fSDavid Howells extern struct inode *afs_iget(struct afs_operation *, struct afs_vnode_param *); 1068e49c7b2fSDavid Howells extern struct inode *afs_root_iget(struct super_block *, struct key *); 1069416351f2SDavid Howells extern void afs_zap_data(struct afs_vnode *); 1070c925bd0aSDavid Howells extern bool afs_check_validity(struct afs_vnode *); 1071260a9803SDavid Howells extern int afs_validate(struct afs_vnode *, struct key *); 1072a528d35eSDavid Howells extern int afs_getattr(const struct path *, struct kstat *, u32, unsigned int); 107331143d5dSDavid Howells extern int afs_setattr(struct dentry *, struct iattr *); 1074b57922d9SAl Viro extern void afs_evict_inode(struct inode *); 1075bec5eb61Swanglei extern int afs_drop_inode(struct inode *); 10761da177e4SLinus Torvalds 10771da177e4SLinus Torvalds /* 10781da177e4SLinus Torvalds * main.c 10791da177e4SLinus Torvalds */ 10800ad53eeeSTejun Heo extern struct workqueue_struct *afs_wq; 10815b86d4ffSDavid Howells extern int afs_net_id; 10825b86d4ffSDavid Howells 10835b86d4ffSDavid Howells static inline struct afs_net *afs_net(struct net *net) 10845b86d4ffSDavid Howells { 10855b86d4ffSDavid Howells return net_generic(net, afs_net_id); 10865b86d4ffSDavid Howells } 10875b86d4ffSDavid Howells 10885b86d4ffSDavid Howells static inline struct afs_net *afs_sb2net(struct super_block *sb) 10895b86d4ffSDavid Howells { 10905b86d4ffSDavid Howells return afs_net(AFS_FS_S(sb)->net_ns); 10915b86d4ffSDavid Howells } 1092f044c884SDavid Howells 1093f044c884SDavid Howells static inline struct afs_net *afs_d2net(struct dentry *dentry) 1094f044c884SDavid Howells { 10955b86d4ffSDavid Howells return afs_sb2net(dentry->d_sb); 1096f044c884SDavid Howells } 1097f044c884SDavid Howells 1098f044c884SDavid Howells static inline struct afs_net *afs_i2net(struct inode *inode) 1099f044c884SDavid Howells { 11005b86d4ffSDavid Howells return afs_sb2net(inode->i_sb); 1101f044c884SDavid Howells } 1102f044c884SDavid Howells 1103f044c884SDavid Howells static inline struct afs_net *afs_v2net(struct afs_vnode *vnode) 1104f044c884SDavid Howells { 11055b86d4ffSDavid Howells return afs_i2net(&vnode->vfs_inode); 1106f044c884SDavid Howells } 1107f044c884SDavid Howells 1108f044c884SDavid Howells static inline struct afs_net *afs_sock2net(struct sock *sk) 1109f044c884SDavid Howells { 11105b86d4ffSDavid Howells return net_generic(sock_net(sk), afs_net_id); 1111f044c884SDavid Howells } 11121da177e4SLinus Torvalds 1113d55b4da4SDavid Howells static inline void __afs_stat(atomic_t *s) 1114d55b4da4SDavid Howells { 1115d55b4da4SDavid Howells atomic_inc(s); 1116d55b4da4SDavid Howells } 1117d55b4da4SDavid Howells 1118d55b4da4SDavid Howells #define afs_stat_v(vnode, n) __afs_stat(&afs_v2net(vnode)->n) 1119d55b4da4SDavid Howells 11201da177e4SLinus Torvalds /* 112108e0e7c8SDavid Howells * misc.c 112208e0e7c8SDavid Howells */ 112308e0e7c8SDavid Howells extern int afs_abort_to_error(u32); 11244584ae96SDavid Howells extern void afs_prioritise_error(struct afs_error *, int, u32); 112508e0e7c8SDavid Howells 112608e0e7c8SDavid Howells /* 11271da177e4SLinus Torvalds * mntpt.c 11281da177e4SLinus Torvalds */ 1129754661f1SArjan van de Ven extern const struct inode_operations afs_mntpt_inode_operations; 1130bec5eb61Swanglei extern const struct inode_operations afs_autocell_inode_operations; 11314b6f5d20SArjan van de Ven extern const struct file_operations afs_mntpt_file_operations; 11321da177e4SLinus Torvalds 1133d18610b0SDavid Howells extern struct vfsmount *afs_d_automount(struct path *); 113408e0e7c8SDavid Howells extern void afs_mntpt_kill_timer(void); 11351da177e4SLinus Torvalds 11361da177e4SLinus Torvalds /* 11371da177e4SLinus Torvalds * proc.c 11381da177e4SLinus Torvalds */ 1139b6cfbecaSDavid Howells #ifdef CONFIG_PROC_FS 1140f044c884SDavid Howells extern int __net_init afs_proc_init(struct afs_net *); 1141f044c884SDavid Howells extern void __net_exit afs_proc_cleanup(struct afs_net *); 11425b86d4ffSDavid Howells extern int afs_proc_cell_setup(struct afs_cell *); 11435b86d4ffSDavid Howells extern void afs_proc_cell_remove(struct afs_cell *); 11446f8880d8SDavid Howells extern void afs_put_sysnames(struct afs_sysnames *); 1145b6cfbecaSDavid Howells #else 1146b6cfbecaSDavid Howells static inline int afs_proc_init(struct afs_net *net) { return 0; } 1147b6cfbecaSDavid Howells static inline void afs_proc_cleanup(struct afs_net *net) {} 1148b6cfbecaSDavid Howells static inline int afs_proc_cell_setup(struct afs_cell *cell) { return 0; } 1149b6cfbecaSDavid Howells static inline void afs_proc_cell_remove(struct afs_cell *cell) {} 1150b6cfbecaSDavid Howells static inline void afs_put_sysnames(struct afs_sysnames *sysnames) {} 1151b6cfbecaSDavid Howells #endif 11521da177e4SLinus Torvalds 115308e0e7c8SDavid Howells /* 1154d2ddc776SDavid Howells * rotate.c 1155d2ddc776SDavid Howells */ 1156a310082fSDavid Howells extern bool afs_select_fileserver(struct afs_operation *); 1157e49c7b2fSDavid Howells extern void afs_dump_edestaddrreq(const struct afs_operation *); 1158d2ddc776SDavid Howells 1159d2ddc776SDavid Howells /* 116008e0e7c8SDavid Howells * rxrpc.c 116108e0e7c8SDavid Howells */ 1162f044c884SDavid Howells extern struct workqueue_struct *afs_async_calls; 11638324f0bcSDavid Howells 1164f044c884SDavid Howells extern int __net_init afs_open_socket(struct afs_net *); 1165f044c884SDavid Howells extern void __net_exit afs_close_socket(struct afs_net *); 1166f044c884SDavid Howells extern void afs_charge_preallocation(struct work_struct *); 1167341f741fSDavid Howells extern void afs_put_call(struct afs_call *); 11680b9bf381SDavid Howells extern void afs_make_call(struct afs_addr_cursor *, struct afs_call *, gfp_t); 11690b9bf381SDavid Howells extern long afs_wait_for_call_to_complete(struct afs_call *, struct afs_addr_cursor *); 1170f044c884SDavid Howells extern struct afs_call *afs_alloc_flat_call(struct afs_net *, 1171f044c884SDavid Howells const struct afs_call_type *, 117208e0e7c8SDavid Howells size_t, size_t); 117308e0e7c8SDavid Howells extern void afs_flat_call_destructor(struct afs_call *); 117408e0e7c8SDavid Howells extern void afs_send_empty_reply(struct afs_call *); 1175b908fe6bSDavid Howells extern void afs_send_simple_reply(struct afs_call *, const void *, size_t); 117612bdcf33SDavid Howells extern int afs_extract_data(struct afs_call *, bool); 11777126ead9SDavid Howells extern int afs_protocol_error(struct afs_call *, enum afs_eproto_cause); 117808e0e7c8SDavid Howells 1179e49c7b2fSDavid Howells static inline void afs_make_op_call(struct afs_operation *op, struct afs_call *call, 1180e49c7b2fSDavid Howells gfp_t gfp) 118120b8391fSDavid Howells { 1182e49c7b2fSDavid Howells op->call = call; 1183a310082fSDavid Howells op->type = call->type; 1184e49c7b2fSDavid Howells call->op = op; 1185e49c7b2fSDavid Howells call->key = op->key; 1186e49c7b2fSDavid Howells call->intr = !(op->flags & AFS_OPERATION_UNINTR); 1187e49c7b2fSDavid Howells afs_make_call(&op->ac, call, gfp); 118820b8391fSDavid Howells } 118920b8391fSDavid Howells 119012bdcf33SDavid Howells static inline void afs_extract_begin(struct afs_call *call, void *buf, size_t size) 119112bdcf33SDavid Howells { 119212bdcf33SDavid Howells call->kvec[0].iov_base = buf; 119312bdcf33SDavid Howells call->kvec[0].iov_len = size; 1194fc276122SDavid Howells iov_iter_kvec(&call->def_iter, READ, call->kvec, 1, size); 119512bdcf33SDavid Howells } 119612bdcf33SDavid Howells 119712bdcf33SDavid Howells static inline void afs_extract_to_tmp(struct afs_call *call) 119812bdcf33SDavid Howells { 119912bdcf33SDavid Howells afs_extract_begin(call, &call->tmp, sizeof(call->tmp)); 120012bdcf33SDavid Howells } 120112bdcf33SDavid Howells 120212bdcf33SDavid Howells static inline void afs_extract_to_tmp64(struct afs_call *call) 120312bdcf33SDavid Howells { 120412bdcf33SDavid Howells afs_extract_begin(call, &call->tmp64, sizeof(call->tmp64)); 120512bdcf33SDavid Howells } 120612bdcf33SDavid Howells 120712bdcf33SDavid Howells static inline void afs_extract_discard(struct afs_call *call, size_t size) 120812bdcf33SDavid Howells { 1209fc276122SDavid Howells iov_iter_discard(&call->def_iter, READ, size); 121012bdcf33SDavid Howells } 121112bdcf33SDavid Howells 121212bdcf33SDavid Howells static inline void afs_extract_to_buf(struct afs_call *call, size_t size) 121312bdcf33SDavid Howells { 121412bdcf33SDavid Howells afs_extract_begin(call, call->buffer, size); 121512bdcf33SDavid Howells } 121612bdcf33SDavid Howells 1217d001648eSDavid Howells static inline int afs_transfer_reply(struct afs_call *call) 1218372ee163SDavid Howells { 121912bdcf33SDavid Howells return afs_extract_data(call, false); 1220372ee163SDavid Howells } 1221372ee163SDavid Howells 122298bf40cdSDavid Howells static inline bool afs_check_call_state(struct afs_call *call, 122398bf40cdSDavid Howells enum afs_call_state state) 122498bf40cdSDavid Howells { 122598bf40cdSDavid Howells return READ_ONCE(call->state) == state; 122698bf40cdSDavid Howells } 122798bf40cdSDavid Howells 122898bf40cdSDavid Howells static inline bool afs_set_call_state(struct afs_call *call, 122998bf40cdSDavid Howells enum afs_call_state from, 123098bf40cdSDavid Howells enum afs_call_state to) 123198bf40cdSDavid Howells { 123298bf40cdSDavid Howells bool ok = false; 123398bf40cdSDavid Howells 123498bf40cdSDavid Howells spin_lock_bh(&call->state_lock); 123598bf40cdSDavid Howells if (call->state == from) { 123698bf40cdSDavid Howells call->state = to; 123798bf40cdSDavid Howells trace_afs_call_state(call, from, to, 0, 0); 123898bf40cdSDavid Howells ok = true; 123998bf40cdSDavid Howells } 124098bf40cdSDavid Howells spin_unlock_bh(&call->state_lock); 124198bf40cdSDavid Howells return ok; 124298bf40cdSDavid Howells } 124398bf40cdSDavid Howells 124498bf40cdSDavid Howells static inline void afs_set_call_complete(struct afs_call *call, 124598bf40cdSDavid Howells int error, u32 remote_abort) 124698bf40cdSDavid Howells { 124798bf40cdSDavid Howells enum afs_call_state state; 124898bf40cdSDavid Howells bool ok = false; 124998bf40cdSDavid Howells 125098bf40cdSDavid Howells spin_lock_bh(&call->state_lock); 125198bf40cdSDavid Howells state = call->state; 125298bf40cdSDavid Howells if (state != AFS_CALL_COMPLETE) { 125398bf40cdSDavid Howells call->abort_code = remote_abort; 125498bf40cdSDavid Howells call->error = error; 125598bf40cdSDavid Howells call->state = AFS_CALL_COMPLETE; 125698bf40cdSDavid Howells trace_afs_call_state(call, state, AFS_CALL_COMPLETE, 125798bf40cdSDavid Howells error, remote_abort); 125898bf40cdSDavid Howells ok = true; 125998bf40cdSDavid Howells } 126098bf40cdSDavid Howells spin_unlock_bh(&call->state_lock); 1261dde9f095SDavid Howells if (ok) { 126298bf40cdSDavid Howells trace_afs_call_done(call); 1263dde9f095SDavid Howells 1264dde9f095SDavid Howells /* Asynchronous calls have two refs to release - one from the alloc and 1265dde9f095SDavid Howells * one queued with the work item - and we can't just deallocate the 1266dde9f095SDavid Howells * call because the work item may be queued again. 1267dde9f095SDavid Howells */ 1268dde9f095SDavid Howells if (call->drop_ref) 1269dde9f095SDavid Howells afs_put_call(call); 1270dde9f095SDavid Howells } 127198bf40cdSDavid Howells } 127298bf40cdSDavid Howells 127308e0e7c8SDavid Howells /* 127400d3b7a4SDavid Howells * security.c 127500d3b7a4SDavid Howells */ 1276be080a6fSDavid Howells extern void afs_put_permits(struct afs_permits *); 127700d3b7a4SDavid Howells extern void afs_clear_permits(struct afs_vnode *); 1278a58823acSDavid Howells extern void afs_cache_permit(struct afs_vnode *, struct key *, unsigned int, 1279a58823acSDavid Howells struct afs_status_cb *); 1280416351f2SDavid Howells extern void afs_zap_permits(struct rcu_head *); 128100d3b7a4SDavid Howells extern struct key *afs_request_key(struct afs_cell *); 12828b6a666aSDavid Howells extern struct key *afs_request_key_rcu(struct afs_cell *); 12830fafdc9fSDavid Howells extern int afs_check_permit(struct afs_vnode *, struct key *, afs_access_t *); 128410556cb2SAl Viro extern int afs_permission(struct inode *, int); 1285be080a6fSDavid Howells extern void __exit afs_clean_up_permit_cache(void); 128600d3b7a4SDavid Howells 128700d3b7a4SDavid Howells /* 128808e0e7c8SDavid Howells * server.c 128908e0e7c8SDavid Howells */ 129008e0e7c8SDavid Howells extern spinlock_t afs_server_peer_lock; 129108e0e7c8SDavid Howells 1292f044c884SDavid Howells extern struct afs_server *afs_find_server(struct afs_net *, 1293f044c884SDavid Howells const struct sockaddr_rxrpc *); 1294d2ddc776SDavid Howells extern struct afs_server *afs_find_server_by_uuid(struct afs_net *, const uuid_t *); 129581006805SDavid Howells extern struct afs_server *afs_lookup_server(struct afs_cell *, struct key *, const uuid_t *, u32); 129645218193SDavid Howells extern struct afs_server *afs_get_server(struct afs_server *, enum afs_server_trace); 1297977e5f8eSDavid Howells extern struct afs_server *afs_use_server(struct afs_server *, enum afs_server_trace); 1298977e5f8eSDavid Howells extern void afs_unuse_server(struct afs_net *, struct afs_server *, enum afs_server_trace); 1299977e5f8eSDavid Howells extern void afs_unuse_server_notime(struct afs_net *, struct afs_server *, enum afs_server_trace); 130045218193SDavid Howells extern void afs_put_server(struct afs_net *, struct afs_server *, enum afs_server_trace); 1301d2ddc776SDavid Howells extern void afs_manage_servers(struct work_struct *); 1302d2ddc776SDavid Howells extern void afs_servers_timer(struct timer_list *); 1303f6cbb368SDavid Howells extern void afs_fs_probe_timer(struct timer_list *); 1304f044c884SDavid Howells extern void __net_exit afs_purge_servers(struct afs_net *); 1305a310082fSDavid Howells extern bool afs_check_server_record(struct afs_operation *, struct afs_server *); 1306d2ddc776SDavid Howells 1307f6cbb368SDavid Howells static inline void afs_inc_servers_outstanding(struct afs_net *net) 1308f6cbb368SDavid Howells { 1309f6cbb368SDavid Howells atomic_inc(&net->servers_outstanding); 1310f6cbb368SDavid Howells } 1311f6cbb368SDavid Howells 1312f6cbb368SDavid Howells static inline void afs_dec_servers_outstanding(struct afs_net *net) 1313f6cbb368SDavid Howells { 1314f6cbb368SDavid Howells if (atomic_dec_and_test(&net->servers_outstanding)) 1315f6cbb368SDavid Howells wake_up_var(&net->servers_outstanding); 1316f6cbb368SDavid Howells } 1317f6cbb368SDavid Howells 1318f6cbb368SDavid Howells static inline bool afs_is_probing_server(struct afs_server *server) 1319f6cbb368SDavid Howells { 1320f6cbb368SDavid Howells return list_empty(&server->probe_link); 1321f6cbb368SDavid Howells } 1322f6cbb368SDavid Howells 1323d2ddc776SDavid Howells /* 1324d2ddc776SDavid Howells * server_list.c 1325d2ddc776SDavid Howells */ 1326d2ddc776SDavid Howells static inline struct afs_server_list *afs_get_serverlist(struct afs_server_list *slist) 1327d2ddc776SDavid Howells { 1328d2ddc776SDavid Howells refcount_inc(&slist->usage); 1329d2ddc776SDavid Howells return slist; 1330d2ddc776SDavid Howells } 1331d2ddc776SDavid Howells 1332d2ddc776SDavid Howells extern void afs_put_serverlist(struct afs_net *, struct afs_server_list *); 1333d2ddc776SDavid Howells extern struct afs_server_list *afs_alloc_server_list(struct afs_cell *, struct key *, 1334d2ddc776SDavid Howells struct afs_vldb_entry *, 1335d2ddc776SDavid Howells u8); 1336d2ddc776SDavid Howells extern bool afs_annotate_server_list(struct afs_server_list *, struct afs_server_list *); 133708e0e7c8SDavid Howells 133808e0e7c8SDavid Howells /* 133900d3b7a4SDavid Howells * super.c 134000d3b7a4SDavid Howells */ 1341f044c884SDavid Howells extern int __init afs_fs_init(void); 13425b86d4ffSDavid Howells extern void afs_fs_exit(void); 134300d3b7a4SDavid Howells 134400d3b7a4SDavid Howells /* 134508e0e7c8SDavid Howells * vlclient.c 134608e0e7c8SDavid Howells */ 13470a5143f2SDavid Howells extern struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_vl_cursor *, 13480a5143f2SDavid Howells const char *, int); 13490a5143f2SDavid Howells extern struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *, const uuid_t *); 13500b9bf381SDavid Howells extern struct afs_call *afs_vl_get_capabilities(struct afs_net *, struct afs_addr_cursor *, 13510b9bf381SDavid Howells struct key *, struct afs_vlserver *, unsigned int); 13520a5143f2SDavid Howells extern struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *, const uuid_t *); 1353c3e9f888SDavid Howells extern char *afs_yfsvl_get_cell_name(struct afs_vl_cursor *); 13540a5143f2SDavid Howells 13550a5143f2SDavid Howells /* 13568a070a96SDavid Howells * vl_alias.c 13578a070a96SDavid Howells */ 13588a070a96SDavid Howells extern int afs_cell_detect_alias(struct afs_cell *, struct key *); 13598a070a96SDavid Howells 13608a070a96SDavid Howells /* 13613bf0fb6fSDavid Howells * vl_probe.c 13623bf0fb6fSDavid Howells */ 13633bf0fb6fSDavid Howells extern void afs_vlserver_probe_result(struct afs_call *); 13643bf0fb6fSDavid Howells extern int afs_send_vl_probes(struct afs_net *, struct key *, struct afs_vlserver_list *); 13653bf0fb6fSDavid Howells extern int afs_wait_for_vl_probes(struct afs_vlserver_list *, unsigned long); 13663bf0fb6fSDavid Howells 13673bf0fb6fSDavid Howells /* 13680a5143f2SDavid Howells * vl_rotate.c 13690a5143f2SDavid Howells */ 13700a5143f2SDavid Howells extern bool afs_begin_vlserver_operation(struct afs_vl_cursor *, 13710a5143f2SDavid Howells struct afs_cell *, struct key *); 13720a5143f2SDavid Howells extern bool afs_select_vlserver(struct afs_vl_cursor *); 13730a5143f2SDavid Howells extern bool afs_select_current_vlserver(struct afs_vl_cursor *); 13740a5143f2SDavid Howells extern int afs_end_vlserver_operation(struct afs_vl_cursor *); 13750a5143f2SDavid Howells 13760a5143f2SDavid Howells /* 13770a5143f2SDavid Howells * vlserver_list.c 13780a5143f2SDavid Howells */ 13790a5143f2SDavid Howells static inline struct afs_vlserver *afs_get_vlserver(struct afs_vlserver *vlserver) 13800a5143f2SDavid Howells { 13810a5143f2SDavid Howells atomic_inc(&vlserver->usage); 13820a5143f2SDavid Howells return vlserver; 13830a5143f2SDavid Howells } 13840a5143f2SDavid Howells 13850a5143f2SDavid Howells static inline struct afs_vlserver_list *afs_get_vlserverlist(struct afs_vlserver_list *vllist) 13860a5143f2SDavid Howells { 13870a5143f2SDavid Howells if (vllist) 13880a5143f2SDavid Howells atomic_inc(&vllist->usage); 13890a5143f2SDavid Howells return vllist; 13900a5143f2SDavid Howells } 13910a5143f2SDavid Howells 13920a5143f2SDavid Howells extern struct afs_vlserver *afs_alloc_vlserver(const char *, size_t, unsigned short); 13930a5143f2SDavid Howells extern void afs_put_vlserver(struct afs_net *, struct afs_vlserver *); 13940a5143f2SDavid Howells extern struct afs_vlserver_list *afs_alloc_vlserver_list(unsigned int); 13950a5143f2SDavid Howells extern void afs_put_vlserverlist(struct afs_net *, struct afs_vlserver_list *); 13960a5143f2SDavid Howells extern struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *, 13970a5143f2SDavid Howells const void *, size_t); 139808e0e7c8SDavid Howells 139908e0e7c8SDavid Howells /* 140008e0e7c8SDavid Howells * volume.c 140108e0e7c8SDavid Howells */ 140213fcc683SDavid Howells extern struct afs_volume *afs_create_volume(struct afs_fs_context *); 1403d2ddc776SDavid Howells extern void afs_activate_volume(struct afs_volume *); 1404d2ddc776SDavid Howells extern void afs_deactivate_volume(struct afs_volume *); 1405cca37d45SDavid Howells extern struct afs_volume *afs_get_volume(struct afs_volume *, enum afs_volume_trace); 1406cca37d45SDavid Howells extern void afs_put_volume(struct afs_net *, struct afs_volume *, enum afs_volume_trace); 1407a310082fSDavid Howells extern int afs_check_volume_status(struct afs_volume *, struct afs_operation *); 140808e0e7c8SDavid Howells 140931143d5dSDavid Howells /* 141031143d5dSDavid Howells * write.c 141131143d5dSDavid Howells */ 141231143d5dSDavid Howells extern int afs_set_page_dirty(struct page *); 141315b4650eSNick Piggin extern int afs_write_begin(struct file *file, struct address_space *mapping, 141415b4650eSNick Piggin loff_t pos, unsigned len, unsigned flags, 141515b4650eSNick Piggin struct page **pagep, void **fsdata); 141615b4650eSNick Piggin extern int afs_write_end(struct file *file, struct address_space *mapping, 141715b4650eSNick Piggin loff_t pos, unsigned len, unsigned copied, 141815b4650eSNick Piggin struct page *page, void *fsdata); 141931143d5dSDavid Howells extern int afs_writepage(struct page *, struct writeback_control *); 142031143d5dSDavid Howells extern int afs_writepages(struct address_space *, struct writeback_control *); 142150b5551dSAl Viro extern ssize_t afs_file_write(struct kiocb *, struct iov_iter *); 142202c24a82SJosef Bacik extern int afs_fsync(struct file *, loff_t, loff_t, int); 14230722f186SSouptick Joarder extern vm_fault_t afs_page_mkwrite(struct vm_fault *vmf); 14244343d008SDavid Howells extern void afs_prune_wb_keys(struct afs_vnode *); 14254343d008SDavid Howells extern int afs_launder_page(struct page *); 142631143d5dSDavid Howells 1427d3e3b7eaSDavid Howells /* 1428d3e3b7eaSDavid Howells * xattr.c 1429d3e3b7eaSDavid Howells */ 1430d3e3b7eaSDavid Howells extern const struct xattr_handler *afs_xattr_handlers[]; 1431d3e3b7eaSDavid Howells extern ssize_t afs_listxattr(struct dentry *, char *, size_t); 143231143d5dSDavid Howells 143330062bd1SDavid Howells /* 143430062bd1SDavid Howells * yfsclient.c 143530062bd1SDavid Howells */ 1436e49c7b2fSDavid Howells extern void yfs_fs_fetch_file_status(struct afs_operation *); 1437e49c7b2fSDavid Howells extern void yfs_fs_fetch_data(struct afs_operation *); 1438e49c7b2fSDavid Howells extern void yfs_fs_create_file(struct afs_operation *); 1439e49c7b2fSDavid Howells extern void yfs_fs_make_dir(struct afs_operation *); 1440e49c7b2fSDavid Howells extern void yfs_fs_remove_file2(struct afs_operation *); 1441e49c7b2fSDavid Howells extern void yfs_fs_remove_file(struct afs_operation *); 1442e49c7b2fSDavid Howells extern void yfs_fs_remove_dir(struct afs_operation *); 1443e49c7b2fSDavid Howells extern void yfs_fs_link(struct afs_operation *); 1444e49c7b2fSDavid Howells extern void yfs_fs_symlink(struct afs_operation *); 1445e49c7b2fSDavid Howells extern void yfs_fs_rename(struct afs_operation *); 1446e49c7b2fSDavid Howells extern void yfs_fs_store_data(struct afs_operation *); 1447e49c7b2fSDavid Howells extern void yfs_fs_setattr(struct afs_operation *); 1448e49c7b2fSDavid Howells extern void yfs_fs_get_volume_status(struct afs_operation *); 1449e49c7b2fSDavid Howells extern void yfs_fs_set_lock(struct afs_operation *); 1450e49c7b2fSDavid Howells extern void yfs_fs_extend_lock(struct afs_operation *); 1451e49c7b2fSDavid Howells extern void yfs_fs_release_lock(struct afs_operation *); 1452e49c7b2fSDavid Howells extern void yfs_fs_fetch_status(struct afs_operation *); 1453e49c7b2fSDavid Howells extern void yfs_fs_inline_bulk_status(struct afs_operation *); 1454d2ddc776SDavid Howells 1455ae46578bSDavid Howells struct yfs_acl { 1456ae46578bSDavid Howells struct afs_acl *acl; /* Dir/file/symlink ACL */ 1457ae46578bSDavid Howells struct afs_acl *vol_acl; /* Whole volume ACL */ 1458ae46578bSDavid Howells u32 inherit_flag; /* True if ACL is inherited from parent dir */ 1459ae46578bSDavid Howells u32 num_cleaned; /* Number of ACEs removed due to subject removal */ 1460ae46578bSDavid Howells unsigned int flags; 1461ae46578bSDavid Howells #define YFS_ACL_WANT_ACL 0x01 /* Set if caller wants ->acl */ 1462ae46578bSDavid Howells #define YFS_ACL_WANT_VOL_ACL 0x02 /* Set if caller wants ->vol_acl */ 1463ae46578bSDavid Howells }; 1464ae46578bSDavid Howells 1465ae46578bSDavid Howells extern void yfs_free_opaque_acl(struct yfs_acl *); 1466e49c7b2fSDavid Howells extern void yfs_fs_fetch_opaque_acl(struct afs_operation *); 1467e49c7b2fSDavid Howells extern void yfs_fs_store_opaque_acl2(struct afs_operation *); 1468ae46578bSDavid Howells 1469d2ddc776SDavid Howells /* 1470d2ddc776SDavid Howells * Miscellaneous inline functions. 1471d2ddc776SDavid Howells */ 1472d2ddc776SDavid Howells static inline struct afs_vnode *AFS_FS_I(struct inode *inode) 1473d2ddc776SDavid Howells { 1474d2ddc776SDavid Howells return container_of(inode, struct afs_vnode, vfs_inode); 1475d2ddc776SDavid Howells } 1476d2ddc776SDavid Howells 1477d2ddc776SDavid Howells static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode) 1478d2ddc776SDavid Howells { 1479d2ddc776SDavid Howells return &vnode->vfs_inode; 1480d2ddc776SDavid Howells } 1481d2ddc776SDavid Howells 1482a310082fSDavid Howells static inline void afs_check_for_remote_deletion(struct afs_operation *op, 1483d2ddc776SDavid Howells struct afs_vnode *vnode) 1484d2ddc776SDavid Howells { 1485e49c7b2fSDavid Howells if (op->error == -ENOENT) { 1486d2ddc776SDavid Howells set_bit(AFS_VNODE_DELETED, &vnode->flags); 1487051d2525SDavid Howells afs_break_callback(vnode, afs_cb_break_for_deleted); 1488d2ddc776SDavid Howells } 1489d2ddc776SDavid Howells } 1490d2ddc776SDavid Howells 1491e49c7b2fSDavid Howells /* 1492e49c7b2fSDavid Howells * Note that a dentry got changed. We need to set d_fsdata to the data version 1493e49c7b2fSDavid Howells * number derived from the result of the operation. It doesn't matter if 1494e49c7b2fSDavid Howells * d_fsdata goes backwards as we'll just revalidate. 1495e49c7b2fSDavid Howells */ 1496e49c7b2fSDavid Howells static inline void afs_update_dentry_version(struct afs_operation *op, 1497e49c7b2fSDavid Howells struct afs_vnode_param *dir_vp, 1498e49c7b2fSDavid Howells struct dentry *dentry) 1499e49c7b2fSDavid Howells { 1500e49c7b2fSDavid Howells if (!op->error) 1501e49c7b2fSDavid Howells dentry->d_fsdata = 1502e49c7b2fSDavid Howells (void *)(unsigned long)dir_vp->scb.status.data_version; 1503e49c7b2fSDavid Howells } 1504e49c7b2fSDavid Howells 1505f51375cdSDavid Howells static inline int afs_io_error(struct afs_call *call, enum afs_io_error where) 1506f51375cdSDavid Howells { 1507f51375cdSDavid Howells trace_afs_io_error(call->debug_id, -EIO, where); 1508f51375cdSDavid Howells return -EIO; 1509f51375cdSDavid Howells } 1510f51375cdSDavid Howells 1511f51375cdSDavid Howells static inline int afs_bad(struct afs_vnode *vnode, enum afs_file_error where) 1512f51375cdSDavid Howells { 1513f51375cdSDavid Howells trace_afs_file_error(vnode, -EIO, where); 1514f51375cdSDavid Howells return -EIO; 1515f51375cdSDavid Howells } 1516d2ddc776SDavid Howells 151708e0e7c8SDavid Howells /*****************************************************************************/ 151808e0e7c8SDavid Howells /* 151908e0e7c8SDavid Howells * debug tracing 152008e0e7c8SDavid Howells */ 152108e0e7c8SDavid Howells extern unsigned afs_debug; 152208e0e7c8SDavid Howells 152308e0e7c8SDavid Howells #define dbgprintk(FMT,...) \ 1524ad16df84SSven Schnelle printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__) 152508e0e7c8SDavid Howells 1526530b6412SHarvey Harrison #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__) 1527530b6412SHarvey Harrison #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) 152808e0e7c8SDavid Howells #define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__) 152908e0e7c8SDavid Howells 153008e0e7c8SDavid Howells 153108e0e7c8SDavid Howells #if defined(__KDEBUG) 153208e0e7c8SDavid Howells #define _enter(FMT,...) kenter(FMT,##__VA_ARGS__) 153308e0e7c8SDavid Howells #define _leave(FMT,...) kleave(FMT,##__VA_ARGS__) 153408e0e7c8SDavid Howells #define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__) 153508e0e7c8SDavid Howells 153608e0e7c8SDavid Howells #elif defined(CONFIG_AFS_DEBUG) 153708e0e7c8SDavid Howells #define AFS_DEBUG_KENTER 0x01 153808e0e7c8SDavid Howells #define AFS_DEBUG_KLEAVE 0x02 153908e0e7c8SDavid Howells #define AFS_DEBUG_KDEBUG 0x04 154008e0e7c8SDavid Howells 154108e0e7c8SDavid Howells #define _enter(FMT,...) \ 154208e0e7c8SDavid Howells do { \ 154308e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \ 154408e0e7c8SDavid Howells kenter(FMT,##__VA_ARGS__); \ 154508e0e7c8SDavid Howells } while (0) 154608e0e7c8SDavid Howells 154708e0e7c8SDavid Howells #define _leave(FMT,...) \ 154808e0e7c8SDavid Howells do { \ 154908e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \ 155008e0e7c8SDavid Howells kleave(FMT,##__VA_ARGS__); \ 155108e0e7c8SDavid Howells } while (0) 155208e0e7c8SDavid Howells 155308e0e7c8SDavid Howells #define _debug(FMT,...) \ 155408e0e7c8SDavid Howells do { \ 155508e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \ 155608e0e7c8SDavid Howells kdebug(FMT,##__VA_ARGS__); \ 155708e0e7c8SDavid Howells } while (0) 155808e0e7c8SDavid Howells 155908e0e7c8SDavid Howells #else 156012fdff3fSDavid Howells #define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__) 156112fdff3fSDavid Howells #define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) 156212fdff3fSDavid Howells #define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__) 156308e0e7c8SDavid Howells #endif 156408e0e7c8SDavid Howells 156508e0e7c8SDavid Howells /* 156608e0e7c8SDavid Howells * debug assertion checking 156708e0e7c8SDavid Howells */ 156808e0e7c8SDavid Howells #if 1 // defined(__KDEBUGALL) 156908e0e7c8SDavid Howells 157008e0e7c8SDavid Howells #define ASSERT(X) \ 157108e0e7c8SDavid Howells do { \ 157208e0e7c8SDavid Howells if (unlikely(!(X))) { \ 157308e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 157408e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 157508e0e7c8SDavid Howells BUG(); \ 157608e0e7c8SDavid Howells } \ 157708e0e7c8SDavid Howells } while(0) 157808e0e7c8SDavid Howells 157908e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y) \ 158008e0e7c8SDavid Howells do { \ 158108e0e7c8SDavid Howells if (unlikely(!((X) OP (Y)))) { \ 158208e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 158308e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 158408e0e7c8SDavid Howells printk(KERN_ERR "%lu " #OP " %lu is false\n", \ 158508e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 158608e0e7c8SDavid Howells printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ 158708e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 158808e0e7c8SDavid Howells BUG(); \ 158908e0e7c8SDavid Howells } \ 159008e0e7c8SDavid Howells } while(0) 159108e0e7c8SDavid Howells 1592416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H) \ 1593416351f2SDavid Howells do { \ 1594416351f2SDavid Howells if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) { \ 1595416351f2SDavid Howells printk(KERN_ERR "\n"); \ 1596416351f2SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 1597416351f2SDavid Howells printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n", \ 1598416351f2SDavid Howells (unsigned long)(L), (unsigned long)(N), \ 1599416351f2SDavid Howells (unsigned long)(H)); \ 1600416351f2SDavid Howells printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \ 1601416351f2SDavid Howells (unsigned long)(L), (unsigned long)(N), \ 1602416351f2SDavid Howells (unsigned long)(H)); \ 1603416351f2SDavid Howells BUG(); \ 1604416351f2SDavid Howells } \ 1605416351f2SDavid Howells } while(0) 1606416351f2SDavid Howells 160708e0e7c8SDavid Howells #define ASSERTIF(C, X) \ 160808e0e7c8SDavid Howells do { \ 160908e0e7c8SDavid Howells if (unlikely((C) && !(X))) { \ 161008e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 161108e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 161208e0e7c8SDavid Howells BUG(); \ 161308e0e7c8SDavid Howells } \ 161408e0e7c8SDavid Howells } while(0) 161508e0e7c8SDavid Howells 161608e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y) \ 161708e0e7c8SDavid Howells do { \ 161808e0e7c8SDavid Howells if (unlikely((C) && !((X) OP (Y)))) { \ 161908e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 162008e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 162108e0e7c8SDavid Howells printk(KERN_ERR "%lu " #OP " %lu is false\n", \ 162208e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 162308e0e7c8SDavid Howells printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ 162408e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 162508e0e7c8SDavid Howells BUG(); \ 162608e0e7c8SDavid Howells } \ 162708e0e7c8SDavid Howells } while(0) 162808e0e7c8SDavid Howells 162908e0e7c8SDavid Howells #else 163008e0e7c8SDavid Howells 163108e0e7c8SDavid Howells #define ASSERT(X) \ 163208e0e7c8SDavid Howells do { \ 163308e0e7c8SDavid Howells } while(0) 163408e0e7c8SDavid Howells 163508e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y) \ 163608e0e7c8SDavid Howells do { \ 163708e0e7c8SDavid Howells } while(0) 163808e0e7c8SDavid Howells 1639416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H) \ 1640416351f2SDavid Howells do { \ 1641416351f2SDavid Howells } while(0) 1642416351f2SDavid Howells 164308e0e7c8SDavid Howells #define ASSERTIF(C, X) \ 164408e0e7c8SDavid Howells do { \ 164508e0e7c8SDavid Howells } while(0) 164608e0e7c8SDavid Howells 164708e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y) \ 164808e0e7c8SDavid Howells do { \ 164908e0e7c8SDavid Howells } while(0) 165008e0e7c8SDavid Howells 165108e0e7c8SDavid Howells #endif /* __KDEBUGALL */ 1652