1ec26815aSDavid Howells /* internal AFS stuff 21da177e4SLinus Torvalds * 308e0e7c8SDavid Howells * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved. 41da177e4SLinus Torvalds * Written by David Howells (dhowells@redhat.com) 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or 71da177e4SLinus Torvalds * modify it under the terms of the GNU General Public License 81da177e4SLinus Torvalds * as published by the Free Software Foundation; either version 91da177e4SLinus Torvalds * 2 of the License, or (at your option) any later version. 101da177e4SLinus Torvalds */ 111da177e4SLinus Torvalds 121da177e4SLinus Torvalds #include <linux/compiler.h> 131da177e4SLinus Torvalds #include <linux/kernel.h> 148a79790bSTina Ruchandani #include <linux/ktime.h> 151da177e4SLinus Torvalds #include <linux/fs.h> 161da177e4SLinus Torvalds #include <linux/pagemap.h> 1708e0e7c8SDavid Howells #include <linux/rxrpc.h> 1800d3b7a4SDavid Howells #include <linux/key.h> 19e8edc6e0SAlexey Dobriyan #include <linux/workqueue.h> 2000c541eaSAndrew Morton #include <linux/sched.h> 2180e50be4SChristoph Hellwig #include <linux/fscache.h> 22e1da0222SJens Axboe #include <linux/backing-dev.h> 23ff548773SDavid Howells #include <linux/uuid.h> 24f044c884SDavid Howells #include <net/net_namespace.h> 255b86d4ffSDavid Howells #include <net/netns/generic.h> 265b86d4ffSDavid Howells #include <net/sock.h> 278324f0bcSDavid Howells #include <net/af_rxrpc.h> 2800c541eaSAndrew Morton 2908e0e7c8SDavid Howells #include "afs.h" 3008e0e7c8SDavid Howells #include "afs_vl.h" 3108e0e7c8SDavid Howells 3208e0e7c8SDavid Howells #define AFS_CELL_MAX_ADDRS 15 3308e0e7c8SDavid Howells 3431143d5dSDavid Howells struct pagevec; 3508e0e7c8SDavid Howells struct afs_call; 3608e0e7c8SDavid Howells 3700d3b7a4SDavid Howells struct afs_mount_params { 3800d3b7a4SDavid Howells bool rwpath; /* T if the parent should be considered R/W */ 3900d3b7a4SDavid Howells bool force; /* T to force cell type */ 40bec5eb61Swanglei bool autocell; /* T if set auto mount operation */ 414d673da1SDavid Howells bool dyn_root; /* T if dynamic root */ 4200d3b7a4SDavid Howells afs_voltype_t type; /* type of volume requested */ 4300d3b7a4SDavid Howells int volnamesz; /* size of volume name */ 4400d3b7a4SDavid Howells const char *volname; /* name of volume to mount */ 455b86d4ffSDavid Howells struct net *net_ns; /* Network namespace in effect */ 465b86d4ffSDavid Howells struct afs_net *net; /* the AFS net namespace stuff */ 4700d3b7a4SDavid Howells struct afs_cell *cell; /* cell in which to find volume */ 4800d3b7a4SDavid Howells struct afs_volume *volume; /* volume record */ 4900d3b7a4SDavid Howells struct key *key; /* key to use for secure mounting */ 5000d3b7a4SDavid Howells }; 5100d3b7a4SDavid Howells 52c435ee34SDavid Howells struct afs_iget_data { 53c435ee34SDavid Howells struct afs_fid fid; 54c435ee34SDavid Howells struct afs_volume *volume; /* volume on which resides */ 55c435ee34SDavid Howells }; 56c435ee34SDavid Howells 578e8d7f13SDavid Howells enum afs_call_state { 5898bf40cdSDavid Howells AFS_CALL_CL_REQUESTING, /* Client: Request is being sent */ 5998bf40cdSDavid Howells AFS_CALL_CL_AWAIT_REPLY, /* Client: Awaiting reply */ 6098bf40cdSDavid Howells AFS_CALL_CL_PROC_REPLY, /* Client: rxrpc call complete; processing reply */ 6198bf40cdSDavid Howells AFS_CALL_SV_AWAIT_OP_ID, /* Server: Awaiting op ID */ 6298bf40cdSDavid Howells AFS_CALL_SV_AWAIT_REQUEST, /* Server: Awaiting request data */ 6398bf40cdSDavid Howells AFS_CALL_SV_REPLYING, /* Server: Replying */ 6498bf40cdSDavid Howells AFS_CALL_SV_AWAIT_ACK, /* Server: Awaiting final ACK */ 658e8d7f13SDavid Howells AFS_CALL_COMPLETE, /* Completed or failed */ 668e8d7f13SDavid Howells }; 67f044c884SDavid Howells 6808e0e7c8SDavid Howells /* 698b2a464cSDavid Howells * List of server addresses. 708b2a464cSDavid Howells */ 718b2a464cSDavid Howells struct afs_addr_list { 728b2a464cSDavid Howells struct rcu_head rcu; /* Must be first */ 738b2a464cSDavid Howells refcount_t usage; 74d2ddc776SDavid Howells u32 version; /* Version */ 758b2a464cSDavid Howells unsigned short nr_addrs; 768b2a464cSDavid Howells unsigned short index; /* Address currently in use */ 77d2ddc776SDavid Howells unsigned short nr_ipv4; /* Number of IPv4 addresses */ 78bf99a53cSDavid Howells unsigned long probed; /* Mask of servers that have been probed */ 79bf99a53cSDavid Howells unsigned long yfs; /* Mask of servers that are YFS */ 808b2a464cSDavid Howells struct sockaddr_rxrpc addrs[]; 818b2a464cSDavid Howells }; 828b2a464cSDavid Howells 838b2a464cSDavid Howells /* 8408e0e7c8SDavid Howells * a record of an in-progress RxRPC call 8508e0e7c8SDavid Howells */ 8608e0e7c8SDavid Howells struct afs_call { 8708e0e7c8SDavid Howells const struct afs_call_type *type; /* type of call */ 8808e0e7c8SDavid Howells wait_queue_head_t waitq; /* processes awaiting completion */ 89341f741fSDavid Howells struct work_struct async_work; /* async I/O processor */ 9008e0e7c8SDavid Howells struct work_struct work; /* actual work processor */ 9108e0e7c8SDavid Howells struct rxrpc_call *rxcall; /* RxRPC call handle */ 9208e0e7c8SDavid Howells struct key *key; /* security for this call */ 93f044c884SDavid Howells struct afs_net *net; /* The network namespace */ 94d0676a16SDavid Howells struct afs_server *cm_server; /* Server affected by incoming CM call */ 95d2ddc776SDavid Howells struct afs_cb_interest *cbi; /* Callback interest for server used */ 9608e0e7c8SDavid Howells void *request; /* request data (first part) */ 974343d008SDavid Howells struct address_space *mapping; /* Pages being written from */ 9808e0e7c8SDavid Howells void *buffer; /* reply receive buffer */ 9997e3043aSDavid Howells void *reply[4]; /* Where to put the reply */ 10031143d5dSDavid Howells pgoff_t first; /* first page in mapping to deal with */ 10131143d5dSDavid Howells pgoff_t last; /* last page in mapping to deal with */ 102d001648eSDavid Howells size_t offset; /* offset into received data store */ 103341f741fSDavid Howells atomic_t usage; 1048e8d7f13SDavid Howells enum afs_call_state state; 10598bf40cdSDavid Howells spinlock_t state_lock; 10608e0e7c8SDavid Howells int error; /* error code */ 107d001648eSDavid Howells u32 abort_code; /* Remote abort ID or 0 */ 10808e0e7c8SDavid Howells unsigned request_size; /* size of request data */ 10908e0e7c8SDavid Howells unsigned reply_max; /* maximum size of reply */ 11031143d5dSDavid Howells unsigned first_offset; /* offset into mapping[first] */ 111c435ee34SDavid Howells unsigned int cb_break; /* cb_break + cb_s_break before the call */ 112bcd89270SMarc Dionne union { 11331143d5dSDavid Howells unsigned last_to; /* amount of mapping[last] */ 114bcd89270SMarc Dionne unsigned count2; /* count used in unmarshalling */ 115bcd89270SMarc Dionne }; 11608e0e7c8SDavid Howells unsigned char unmarshall; /* unmarshalling phase */ 11708e0e7c8SDavid Howells bool incoming; /* T if incoming call */ 11831143d5dSDavid Howells bool send_pages; /* T if data from mapping should be sent */ 119d001648eSDavid Howells bool need_attention; /* T if RxRPC poked us */ 12056ff9c83SDavid Howells bool async; /* T if asynchronous */ 12133cd7f2bSDavid Howells bool ret_reply0; /* T if should return reply[0] on success */ 122a68f4a27SDavid Howells bool upgrade; /* T to request service upgrade */ 123bf99a53cSDavid Howells u16 service_id; /* Actual service ID (after upgrade) */ 124a25e21f0SDavid Howells unsigned int debug_id; /* Trace ID */ 12550a2c953SDavid Howells u32 operation_ID; /* operation ID for an incoming call */ 12608e0e7c8SDavid Howells u32 count; /* count for use in unmarshalling */ 12708e0e7c8SDavid Howells __be32 tmp; /* place to extract temporary data */ 1280c3a5ac2SDavid Howells afs_dataversion_t expected_version; /* Updated version expected from store */ 1290c3a5ac2SDavid Howells afs_dataversion_t expected_version_2; /* 2nd updated version expected from store */ 13008e0e7c8SDavid Howells }; 13108e0e7c8SDavid Howells 13208e0e7c8SDavid Howells struct afs_call_type { 13300d3b7a4SDavid Howells const char *name; 134025db80cSDavid Howells unsigned int op; /* Really enum afs_fs_operation */ 13500d3b7a4SDavid Howells 13608e0e7c8SDavid Howells /* deliver request or reply data to an call 13708e0e7c8SDavid Howells * - returning an error will cause the call to be aborted 13808e0e7c8SDavid Howells */ 139d001648eSDavid Howells int (*deliver)(struct afs_call *call); 14008e0e7c8SDavid Howells 14108e0e7c8SDavid Howells /* clean up a call */ 14208e0e7c8SDavid Howells void (*destructor)(struct afs_call *call); 143341f741fSDavid Howells 144341f741fSDavid Howells /* Work function */ 145341f741fSDavid Howells void (*work)(struct work_struct *work); 14608e0e7c8SDavid Howells }; 14708e0e7c8SDavid Howells 14808e0e7c8SDavid Howells /* 1494343d008SDavid Howells * Key available for writeback on a file. 1504343d008SDavid Howells */ 1514343d008SDavid Howells struct afs_wb_key { 1524343d008SDavid Howells refcount_t usage; 1534343d008SDavid Howells struct key *key; 1544343d008SDavid Howells struct list_head vnode_link; /* Link in vnode->wb_keys */ 1554343d008SDavid Howells }; 1564343d008SDavid Howells 1574343d008SDavid Howells /* 158215804a9SDavid Howells * AFS open file information record. Pointed to by file->private_data. 159215804a9SDavid Howells */ 160215804a9SDavid Howells struct afs_file { 161215804a9SDavid Howells struct key *key; /* The key this file was opened with */ 1624343d008SDavid Howells struct afs_wb_key *wb; /* Writeback key record for this file */ 163215804a9SDavid Howells }; 164215804a9SDavid Howells 165215804a9SDavid Howells static inline struct key *afs_file_key(struct file *file) 166215804a9SDavid Howells { 167215804a9SDavid Howells struct afs_file *af = file->private_data; 168215804a9SDavid Howells 169215804a9SDavid Howells return af->key; 170215804a9SDavid Howells } 171215804a9SDavid Howells 172215804a9SDavid Howells /* 173196ee9cdSDavid Howells * Record of an outstanding read operation on a vnode. 174196ee9cdSDavid Howells */ 175196ee9cdSDavid Howells struct afs_read { 176196ee9cdSDavid Howells loff_t pos; /* Where to start reading */ 177e8e581a8SDavid Howells loff_t len; /* How much we're asking for */ 178196ee9cdSDavid Howells loff_t actual_len; /* How much we're actually getting */ 1796a0e3999SDavid Howells loff_t remain; /* Amount remaining */ 180f3ddee8dSDavid Howells loff_t file_size; /* File size returned by server */ 181f3ddee8dSDavid Howells afs_dataversion_t data_version; /* Version number returned by server */ 182f3ddee8dSDavid Howells refcount_t usage; 183196ee9cdSDavid Howells unsigned int index; /* Which page we're reading into */ 184196ee9cdSDavid Howells unsigned int nr_pages; 185196ee9cdSDavid Howells void (*page_done)(struct afs_call *, struct afs_read *); 186f3ddee8dSDavid Howells struct page **pages; 187f3ddee8dSDavid Howells struct page *array[]; 188196ee9cdSDavid Howells }; 189196ee9cdSDavid Howells 190196ee9cdSDavid Howells /* 19108e0e7c8SDavid Howells * AFS superblock private data 19208e0e7c8SDavid Howells * - there's one superblock per volume 19308e0e7c8SDavid Howells */ 19408e0e7c8SDavid Howells struct afs_super_info { 1955b86d4ffSDavid Howells struct net *net_ns; /* Network namespace */ 19649566f6fSDavid Howells struct afs_cell *cell; /* The cell in which the volume resides */ 19708e0e7c8SDavid Howells struct afs_volume *volume; /* volume record */ 1984d673da1SDavid Howells bool dyn_root; /* True if dynamic root */ 19908e0e7c8SDavid Howells }; 20008e0e7c8SDavid Howells 20108e0e7c8SDavid Howells static inline struct afs_super_info *AFS_FS_S(struct super_block *sb) 20208e0e7c8SDavid Howells { 20308e0e7c8SDavid Howells return sb->s_fs_info; 20408e0e7c8SDavid Howells } 20508e0e7c8SDavid Howells 20608e0e7c8SDavid Howells extern struct file_system_type afs_fs_type; 20708e0e7c8SDavid Howells 20808e0e7c8SDavid Howells /* 2096f8880d8SDavid Howells * Set of substitutes for @sys. 2106f8880d8SDavid Howells */ 2116f8880d8SDavid Howells struct afs_sysnames { 2126f8880d8SDavid Howells #define AFS_NR_SYSNAME 16 2136f8880d8SDavid Howells char *subs[AFS_NR_SYSNAME]; 2146f8880d8SDavid Howells refcount_t usage; 2156f8880d8SDavid Howells unsigned short nr; 2166f8880d8SDavid Howells char blank[1]; 2176f8880d8SDavid Howells }; 2186f8880d8SDavid Howells 2196f8880d8SDavid Howells /* 220f044c884SDavid Howells * AFS network namespace record. 221f044c884SDavid Howells */ 222f044c884SDavid Howells struct afs_net { 2235b86d4ffSDavid Howells struct net *net; /* Backpointer to the owning net namespace */ 224f044c884SDavid Howells struct afs_uuid uuid; 225f044c884SDavid Howells bool live; /* F if this namespace is being removed */ 226f044c884SDavid Howells 227f044c884SDavid Howells /* AF_RXRPC I/O stuff */ 228f044c884SDavid Howells struct socket *socket; 229f044c884SDavid Howells struct afs_call *spare_incoming_call; 230f044c884SDavid Howells struct work_struct charge_preallocation_work; 231f044c884SDavid Howells struct mutex socket_mutex; 232f044c884SDavid Howells atomic_t nr_outstanding_calls; 233f044c884SDavid Howells atomic_t nr_superblocks; 234f044c884SDavid Howells 235f044c884SDavid Howells /* Cell database */ 236989782dcSDavid Howells struct rb_root cells; 2371588def9SDavid Howells struct afs_cell __rcu *ws_cell; 238989782dcSDavid Howells struct work_struct cells_manager; 239989782dcSDavid Howells struct timer_list cells_timer; 240989782dcSDavid Howells atomic_t cells_outstanding; 241989782dcSDavid Howells seqlock_t cells_lock; 242f044c884SDavid Howells 2430da0b7fdSDavid Howells struct mutex proc_cells_lock; 244f044c884SDavid Howells struct list_head proc_cells; 245f044c884SDavid Howells 246d2ddc776SDavid Howells /* Known servers. Theoretically each fileserver can only be in one 247d2ddc776SDavid Howells * cell, but in practice, people create aliases and subsets and there's 248d2ddc776SDavid Howells * no easy way to distinguish them. 249d2ddc776SDavid Howells */ 250d2ddc776SDavid Howells seqlock_t fs_lock; /* For fs_servers */ 251d2ddc776SDavid Howells struct rb_root fs_servers; /* afs_server (by server UUID or address) */ 252d2ddc776SDavid Howells struct list_head fs_updates; /* afs_server (by update_at) */ 253d2ddc776SDavid Howells struct hlist_head fs_proc; /* procfs servers list */ 254d2ddc776SDavid Howells 255d2ddc776SDavid Howells struct hlist_head fs_addresses4; /* afs_server (by lowest IPv4 addr) */ 256d2ddc776SDavid Howells struct hlist_head fs_addresses6; /* afs_server (by lowest IPv6 addr) */ 257d2ddc776SDavid Howells seqlock_t fs_addr_lock; /* For fs_addresses[46] */ 258d2ddc776SDavid Howells 259d2ddc776SDavid Howells struct work_struct fs_manager; 260d2ddc776SDavid Howells struct timer_list fs_timer; 261d2ddc776SDavid Howells atomic_t servers_outstanding; 262f044c884SDavid Howells 263f044c884SDavid Howells /* File locking renewal management */ 264f044c884SDavid Howells struct mutex lock_manager_mutex; 265f044c884SDavid Howells 266f044c884SDavid Howells /* Misc */ 2670da0b7fdSDavid Howells struct super_block *dynroot_sb; /* Dynamic root mount superblock */ 268f044c884SDavid Howells struct proc_dir_entry *proc_afs; /* /proc/net/afs directory */ 2696f8880d8SDavid Howells struct afs_sysnames *sysnames; 2706f8880d8SDavid Howells rwlock_t sysnames_lock; 271d55b4da4SDavid Howells 272d55b4da4SDavid Howells /* Statistics counters */ 273d55b4da4SDavid Howells atomic_t n_lookup; /* Number of lookups done */ 274d55b4da4SDavid Howells atomic_t n_reval; /* Number of dentries needing revalidation */ 275d55b4da4SDavid Howells atomic_t n_inval; /* Number of invalidations by the server */ 276f3ddee8dSDavid Howells atomic_t n_relpg; /* Number of invalidations by releasepage */ 277d55b4da4SDavid Howells atomic_t n_read_dir; /* Number of directory pages read */ 27863a4681fSDavid Howells atomic_t n_dir_cr; /* Number of directory entry creation edits */ 27963a4681fSDavid Howells atomic_t n_dir_rm; /* Number of directory entry removal edits */ 28076a5cb6fSDavid Howells atomic_t n_stores; /* Number of store ops */ 28176a5cb6fSDavid Howells atomic_long_t n_store_bytes; /* Number of bytes stored */ 28276a5cb6fSDavid Howells atomic_long_t n_fetch_bytes; /* Number of bytes fetched */ 28376a5cb6fSDavid Howells atomic_t n_fetches; /* Number of data fetch ops */ 284f044c884SDavid Howells }; 285f044c884SDavid Howells 2866f8880d8SDavid Howells extern const char afs_init_sysname[]; 287f044c884SDavid Howells 288989782dcSDavid Howells enum afs_cell_state { 289989782dcSDavid Howells AFS_CELL_UNSET, 290989782dcSDavid Howells AFS_CELL_ACTIVATING, 291989782dcSDavid Howells AFS_CELL_ACTIVE, 292989782dcSDavid Howells AFS_CELL_DEACTIVATING, 293989782dcSDavid Howells AFS_CELL_INACTIVE, 294989782dcSDavid Howells AFS_CELL_FAILED, 295989782dcSDavid Howells }; 296989782dcSDavid Howells 297f044c884SDavid Howells /* 298d2ddc776SDavid Howells * AFS cell record. 299d2ddc776SDavid Howells * 300d2ddc776SDavid Howells * This is a tricky concept to get right as it is possible to create aliases 301d2ddc776SDavid Howells * simply by pointing AFSDB/SRV records for two names at the same set of VL 302d2ddc776SDavid Howells * servers; it is also possible to do things like setting up two sets of VL 303d2ddc776SDavid Howells * servers, one of which provides a superset of the volumes provided by the 304d2ddc776SDavid Howells * other (for internal/external division, for example). 305d2ddc776SDavid Howells * 306d2ddc776SDavid Howells * Cells only exist in the sense that (a) a cell's name maps to a set of VL 307d2ddc776SDavid Howells * servers and (b) a cell's name is used by the client to select the key to use 308d2ddc776SDavid Howells * for authentication and encryption. The cell name is not typically used in 309d2ddc776SDavid Howells * the protocol. 310d2ddc776SDavid Howells * 311d2ddc776SDavid Howells * There is no easy way to determine if two cells are aliases or one is a 312d2ddc776SDavid Howells * subset of another. 31308e0e7c8SDavid Howells */ 31408e0e7c8SDavid Howells struct afs_cell { 315989782dcSDavid Howells union { 316989782dcSDavid Howells struct rcu_head rcu; 317989782dcSDavid Howells struct rb_node net_node; /* Node in net->cells */ 318989782dcSDavid Howells }; 319989782dcSDavid Howells struct afs_net *net; 32000d3b7a4SDavid Howells struct key *anonymous_key; /* anonymous user key for this cell */ 321989782dcSDavid Howells struct work_struct manager; /* Manager for init/deinit/dns */ 32208e0e7c8SDavid Howells struct list_head proc_link; /* /proc cell list link */ 3239b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 3249b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 3251da177e4SLinus Torvalds #endif 326989782dcSDavid Howells time64_t dns_expiry; /* Time AFSDB/SRV record expires */ 327989782dcSDavid Howells time64_t last_inactive; /* Time of last drop of usage count */ 328989782dcSDavid Howells atomic_t usage; 329989782dcSDavid Howells unsigned long flags; 330989782dcSDavid Howells #define AFS_CELL_FL_NOT_READY 0 /* The cell record is not ready for use */ 331989782dcSDavid Howells #define AFS_CELL_FL_NO_GC 1 /* The cell was added manually, don't auto-gc */ 332989782dcSDavid Howells #define AFS_CELL_FL_NOT_FOUND 2 /* Permanent DNS error */ 333989782dcSDavid Howells #define AFS_CELL_FL_DNS_FAIL 3 /* Failed to access DNS */ 3348b2a464cSDavid Howells #define AFS_CELL_FL_NO_LOOKUP_YET 4 /* Not completed first DNS lookup yet */ 335989782dcSDavid Howells enum afs_cell_state state; 336989782dcSDavid Howells short error; 337989782dcSDavid Howells 338d2ddc776SDavid Howells /* Active fileserver interaction state. */ 339d2ddc776SDavid Howells struct list_head proc_volumes; /* procfs volume list */ 340d2ddc776SDavid Howells rwlock_t proc_lock; 341989782dcSDavid Howells 342d2ddc776SDavid Howells /* VL server list. */ 3438b2a464cSDavid Howells rwlock_t vl_addrs_lock; /* Lock on vl_addrs */ 3448b2a464cSDavid Howells struct afs_addr_list __rcu *vl_addrs; /* List of VL servers */ 345989782dcSDavid Howells u8 name_len; /* Length of name */ 346989782dcSDavid Howells char name[64 + 1]; /* Cell name, case-flattened and NUL-padded */ 34708e0e7c8SDavid Howells }; 34808e0e7c8SDavid Howells 34908e0e7c8SDavid Howells /* 350d2ddc776SDavid Howells * Cached VLDB entry. 351d2ddc776SDavid Howells * 352d2ddc776SDavid Howells * This is pointed to by cell->vldb_entries, indexed by name. 35308e0e7c8SDavid Howells */ 354d2ddc776SDavid Howells struct afs_vldb_entry { 355d2ddc776SDavid Howells afs_volid_t vid[3]; /* Volume IDs for R/W, R/O and Bak volumes */ 35600d3b7a4SDavid Howells 357d2ddc776SDavid Howells unsigned long flags; 358d2ddc776SDavid Howells #define AFS_VLDB_HAS_RW 0 /* - R/W volume exists */ 359d2ddc776SDavid Howells #define AFS_VLDB_HAS_RO 1 /* - R/O volume exists */ 360d2ddc776SDavid Howells #define AFS_VLDB_HAS_BAK 2 /* - Backup volume exists */ 361d2ddc776SDavid Howells #define AFS_VLDB_QUERY_VALID 3 /* - Record is valid */ 362d2ddc776SDavid Howells #define AFS_VLDB_QUERY_ERROR 4 /* - VL server returned error */ 363d2ddc776SDavid Howells 364d2ddc776SDavid Howells uuid_t fs_server[AFS_NMAXNSERVERS]; 365d2ddc776SDavid Howells u8 fs_mask[AFS_NMAXNSERVERS]; 36608e0e7c8SDavid Howells #define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */ 36708e0e7c8SDavid Howells #define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */ 36808e0e7c8SDavid Howells #define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */ 369d2ddc776SDavid Howells short error; 370d2ddc776SDavid Howells u8 nr_servers; /* Number of server records */ 371d2ddc776SDavid Howells u8 name_len; 372d2ddc776SDavid Howells u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */ 37308e0e7c8SDavid Howells }; 37408e0e7c8SDavid Howells 37508e0e7c8SDavid Howells /* 376d2ddc776SDavid Howells * Record of fileserver with which we're actively communicating. 37708e0e7c8SDavid Howells */ 37808e0e7c8SDavid Howells struct afs_server { 379d2ddc776SDavid Howells struct rcu_head rcu; 380d2ddc776SDavid Howells union { 381d2ddc776SDavid Howells uuid_t uuid; /* Server ID */ 382d2ddc776SDavid Howells struct afs_uuid _uuid; 383d2ddc776SDavid Howells }; 384c435ee34SDavid Howells 385d2ddc776SDavid Howells struct afs_addr_list __rcu *addresses; 386d2ddc776SDavid Howells struct rb_node uuid_rb; /* Link in net->servers */ 387d2ddc776SDavid Howells struct hlist_node addr4_link; /* Link in net->fs_addresses4 */ 388d2ddc776SDavid Howells struct hlist_node addr6_link; /* Link in net->fs_addresses6 */ 389d2ddc776SDavid Howells struct hlist_node proc_link; /* Link in net->fs_proc */ 390d2ddc776SDavid Howells struct afs_server *gc_next; /* Next server in manager's list */ 391d2ddc776SDavid Howells time64_t put_time; /* Time at which last put */ 392d2ddc776SDavid Howells time64_t update_at; /* Time at which to next update the record */ 393c435ee34SDavid Howells unsigned long flags; 394d2ddc776SDavid Howells #define AFS_SERVER_FL_NEW 0 /* New server, don't inc cb_s_break */ 395d2ddc776SDavid Howells #define AFS_SERVER_FL_NOT_READY 1 /* The record is not ready for use */ 396d2ddc776SDavid Howells #define AFS_SERVER_FL_NOT_FOUND 2 /* VL server says no such server */ 397d2ddc776SDavid Howells #define AFS_SERVER_FL_VL_FAIL 3 /* Failed to access VL server */ 398d2ddc776SDavid Howells #define AFS_SERVER_FL_UPDATING 4 399d2ddc776SDavid Howells #define AFS_SERVER_FL_PROBED 5 /* The fileserver has been probed */ 400d2ddc776SDavid Howells #define AFS_SERVER_FL_PROBING 6 /* Fileserver is being probed */ 4015cf9dd55SDavid Howells #define AFS_SERVER_FL_NO_IBULK 7 /* Fileserver doesn't support FS.InlineBulkStatus */ 402f2686b09SDavid Howells #define AFS_SERVER_FL_MAY_HAVE_CB 8 /* May have callbacks on this fileserver */ 403d2ddc776SDavid Howells atomic_t usage; 404d2ddc776SDavid Howells u32 addr_version; /* Address list version */ 40508e0e7c8SDavid Howells 40608e0e7c8SDavid Howells /* file service access */ 407d2ddc776SDavid Howells rwlock_t fs_lock; /* access lock */ 40808e0e7c8SDavid Howells 40908e0e7c8SDavid Howells /* callback promise management */ 410c435ee34SDavid Howells struct list_head cb_interests; /* List of superblocks using this server */ 411c435ee34SDavid Howells unsigned cb_s_break; /* Break-everything counter. */ 412c435ee34SDavid Howells rwlock_t cb_break_lock; /* Volume finding lock */ 413c435ee34SDavid Howells }; 414c435ee34SDavid Howells 415c435ee34SDavid Howells /* 416c435ee34SDavid Howells * Interest by a superblock on a server. 417c435ee34SDavid Howells */ 418c435ee34SDavid Howells struct afs_cb_interest { 419c435ee34SDavid Howells struct list_head cb_link; /* Link in server->cb_interests */ 420c435ee34SDavid Howells struct afs_server *server; /* Server on which this interest resides */ 421c435ee34SDavid Howells struct super_block *sb; /* Superblock on which inodes reside */ 422c435ee34SDavid Howells afs_volid_t vid; /* Volume ID to match */ 423c435ee34SDavid Howells refcount_t usage; 42408e0e7c8SDavid Howells }; 42508e0e7c8SDavid Howells 42608e0e7c8SDavid Howells /* 427d2ddc776SDavid Howells * Replaceable server list. 42808e0e7c8SDavid Howells */ 429d2ddc776SDavid Howells struct afs_server_entry { 430d2ddc776SDavid Howells struct afs_server *server; 431d2ddc776SDavid Howells struct afs_cb_interest *cb_interest; 432d2ddc776SDavid Howells }; 433d2ddc776SDavid Howells 434d2ddc776SDavid Howells struct afs_server_list { 435d2ddc776SDavid Howells refcount_t usage; 436d2ddc776SDavid Howells unsigned short nr_servers; 437d2ddc776SDavid Howells unsigned short index; /* Server currently in use */ 438d2ddc776SDavid Howells unsigned short vnovol_mask; /* Servers to be skipped due to VNOVOL */ 439d2ddc776SDavid Howells unsigned int seq; /* Set to ->servers_seq when installed */ 440d4a96becSDavid Howells rwlock_t lock; 441d2ddc776SDavid Howells struct afs_server_entry servers[]; 44208e0e7c8SDavid Howells }; 44308e0e7c8SDavid Howells 44408e0e7c8SDavid Howells /* 445d2ddc776SDavid Howells * Live AFS volume management. 44608e0e7c8SDavid Howells */ 447d2ddc776SDavid Howells struct afs_volume { 448d2ddc776SDavid Howells afs_volid_t vid; /* volume ID */ 449d2ddc776SDavid Howells atomic_t usage; 450d2ddc776SDavid Howells time64_t update_at; /* Time at which to next update */ 451d2ddc776SDavid Howells struct afs_cell *cell; /* Cell to which belongs (pins ref) */ 452d2ddc776SDavid Howells struct list_head proc_link; /* Link in cell->vl_proc */ 453d2ddc776SDavid Howells unsigned long flags; 454d2ddc776SDavid Howells #define AFS_VOLUME_NEEDS_UPDATE 0 /* - T if an update needs performing */ 455d2ddc776SDavid Howells #define AFS_VOLUME_UPDATING 1 /* - T if an update is in progress */ 456d2ddc776SDavid Howells #define AFS_VOLUME_WAIT 2 /* - T if users must wait for update */ 457d2ddc776SDavid Howells #define AFS_VOLUME_DELETED 3 /* - T if volume appears deleted */ 458d2ddc776SDavid Howells #define AFS_VOLUME_OFFLINE 4 /* - T if volume offline notice given */ 459d2ddc776SDavid Howells #define AFS_VOLUME_BUSY 5 /* - T if volume busy notice given */ 460d2ddc776SDavid Howells #ifdef CONFIG_AFS_FSCACHE 461d2ddc776SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 462d2ddc776SDavid Howells #endif 463d2ddc776SDavid Howells struct afs_server_list *servers; /* List of servers on which volume resides */ 464d2ddc776SDavid Howells rwlock_t servers_lock; /* Lock for ->servers */ 465d2ddc776SDavid Howells unsigned int servers_seq; /* Incremented each time ->servers changes */ 466d2ddc776SDavid Howells 46768251f0aSDavid Howells unsigned cb_v_break; /* Break-everything counter. */ 46868251f0aSDavid Howells rwlock_t cb_break_lock; 46968251f0aSDavid Howells 470d2ddc776SDavid Howells afs_voltype_t type; /* type of volume */ 471d2ddc776SDavid Howells short error; 472d2ddc776SDavid Howells char type_force; /* force volume type (suppress R/O -> R/W) */ 473d2ddc776SDavid Howells u8 name_len; 474d2ddc776SDavid Howells u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */ 47508e0e7c8SDavid Howells }; 47608e0e7c8SDavid Howells 4770fafdc9fSDavid Howells enum afs_lock_state { 4780fafdc9fSDavid Howells AFS_VNODE_LOCK_NONE, /* The vnode has no lock on the server */ 4790fafdc9fSDavid Howells AFS_VNODE_LOCK_WAITING_FOR_CB, /* We're waiting for the server to break the callback */ 4800fafdc9fSDavid Howells AFS_VNODE_LOCK_SETTING, /* We're asking the server for a lock */ 4810fafdc9fSDavid Howells AFS_VNODE_LOCK_GRANTED, /* We have a lock on the server */ 4820fafdc9fSDavid Howells AFS_VNODE_LOCK_EXTENDING, /* We're extending a lock on the server */ 4830fafdc9fSDavid Howells AFS_VNODE_LOCK_NEED_UNLOCK, /* We need to unlock on the server */ 4840fafdc9fSDavid Howells AFS_VNODE_LOCK_UNLOCKING, /* We're telling the server to unlock */ 4850fafdc9fSDavid Howells }; 4860fafdc9fSDavid Howells 48708e0e7c8SDavid Howells /* 488f8de483eSDavid Howells * AFS inode private data. 489f8de483eSDavid Howells * 490f8de483eSDavid Howells * Note that afs_alloc_inode() *must* reset anything that could incorrectly 491f8de483eSDavid Howells * leak from one inode to another. 49208e0e7c8SDavid Howells */ 49308e0e7c8SDavid Howells struct afs_vnode { 49408e0e7c8SDavid Howells struct inode vfs_inode; /* the VFS's inode record */ 49508e0e7c8SDavid Howells 49608e0e7c8SDavid Howells struct afs_volume *volume; /* volume on which vnode resides */ 49708e0e7c8SDavid Howells struct afs_fid fid; /* the file identifier for this inode */ 49808e0e7c8SDavid Howells struct afs_file_status status; /* AFS status info for this file */ 499a4ff7401SDavid Howells afs_dataversion_t invalid_before; /* Child dentries are invalid before this */ 5009b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 5019b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 50208e0e7c8SDavid Howells #endif 503fe342cf7SDavid Howells struct afs_permits __rcu *permit_cache; /* cache of permits so far obtained */ 504d2ddc776SDavid Howells struct mutex io_lock; /* Lock for serialising I/O on this mutex */ 505b61f7dcfSDavid Howells struct rw_semaphore validate_lock; /* lock for validating this vnode */ 5064343d008SDavid Howells spinlock_t wb_lock; /* lock for wb_keys */ 50708e0e7c8SDavid Howells spinlock_t lock; /* waitqueue/flags lock */ 50808e0e7c8SDavid Howells unsigned long flags; 509c435ee34SDavid Howells #define AFS_VNODE_CB_PROMISED 0 /* Set if vnode has a callback promise */ 510260a9803SDavid Howells #define AFS_VNODE_UNSET 1 /* set if vnode attributes not yet set */ 511f3ddee8dSDavid Howells #define AFS_VNODE_DIR_VALID 2 /* Set if dir contents are valid */ 51208e0e7c8SDavid Howells #define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */ 51308e0e7c8SDavid Howells #define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */ 51408e0e7c8SDavid Howells #define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */ 5150fafdc9fSDavid Howells #define AFS_VNODE_AUTOCELL 6 /* set if Vnode is an auto mount point */ 5160fafdc9fSDavid Howells #define AFS_VNODE_PSEUDODIR 7 /* set if Vnode is a pseudo directory */ 5175a813276SDavid Howells #define AFS_VNODE_NEW_CONTENT 8 /* Set if file has new content (create/trunc-0) */ 51808e0e7c8SDavid Howells 5194343d008SDavid Howells struct list_head wb_keys; /* List of keys available for writeback */ 520e8d6c554SDavid Howells struct list_head pending_locks; /* locks waiting to be granted */ 521e8d6c554SDavid Howells struct list_head granted_locks; /* locks granted on this file */ 522e8d6c554SDavid Howells struct delayed_work lock_work; /* work to be done in locking */ 5230fafdc9fSDavid Howells struct key *lock_key; /* Key to be used in lock ops */ 5240fafdc9fSDavid Howells enum afs_lock_state lock_state : 8; 5250fafdc9fSDavid Howells afs_lock_type_t lock_type : 8; 52631143d5dSDavid Howells 52708e0e7c8SDavid Howells /* outstanding callback notification on this file */ 528c435ee34SDavid Howells struct afs_cb_interest *cb_interest; /* Server on which this resides */ 529c435ee34SDavid Howells unsigned int cb_s_break; /* Mass break counter on ->server */ 53068251f0aSDavid Howells unsigned int cb_v_break; /* Mass break counter on ->volume */ 531c435ee34SDavid Howells unsigned int cb_break; /* Break counter on vnode */ 532c435ee34SDavid Howells seqlock_t cb_lock; /* Lock for ->cb_interest, ->status, ->cb_*break */ 533c435ee34SDavid Howells 534c435ee34SDavid Howells time64_t cb_expires_at; /* time at which callback expires */ 53508e0e7c8SDavid Howells unsigned cb_version; /* callback version */ 53608e0e7c8SDavid Howells afs_callback_type_t cb_type; /* type of callback */ 53708e0e7c8SDavid Howells }; 53808e0e7c8SDavid Howells 53900d3b7a4SDavid Howells /* 54000d3b7a4SDavid Howells * cached security record for one user's attempt to access a vnode 54100d3b7a4SDavid Howells */ 54200d3b7a4SDavid Howells struct afs_permit { 54300d3b7a4SDavid Howells struct key *key; /* RxRPC ticket holding a security context */ 544be080a6fSDavid Howells afs_access_t access; /* CallerAccess value for this key */ 54500d3b7a4SDavid Howells }; 54600d3b7a4SDavid Howells 54700d3b7a4SDavid Howells /* 548be080a6fSDavid Howells * Immutable cache of CallerAccess records from attempts to access vnodes. 549be080a6fSDavid Howells * These may be shared between multiple vnodes. 55000d3b7a4SDavid Howells */ 55100d3b7a4SDavid Howells struct afs_permits { 552be080a6fSDavid Howells struct rcu_head rcu; 553be080a6fSDavid Howells struct hlist_node hash_node; /* Link in hash */ 554be080a6fSDavid Howells unsigned long h; /* Hash value for this permit list */ 555be080a6fSDavid Howells refcount_t usage; 556be080a6fSDavid Howells unsigned short nr_permits; /* Number of records */ 557be080a6fSDavid Howells bool invalidated; /* Invalidated due to key change */ 558be080a6fSDavid Howells struct afs_permit permits[]; /* List of permits sorted by key pointer */ 55900d3b7a4SDavid Howells }; 56000d3b7a4SDavid Howells 561b908fe6bSDavid Howells /* 562b908fe6bSDavid Howells * record of one of a system's set of network interfaces 563b908fe6bSDavid Howells */ 564b908fe6bSDavid Howells struct afs_interface { 565b908fe6bSDavid Howells struct in_addr address; /* IPv4 address bound to interface */ 566b908fe6bSDavid Howells struct in_addr netmask; /* netmask applied to address */ 567b908fe6bSDavid Howells unsigned mtu; /* MTU of interface */ 568b908fe6bSDavid Howells }; 569b908fe6bSDavid Howells 5708b2a464cSDavid Howells /* 5718b2a464cSDavid Howells * Cursor for iterating over a server's address list. 5728b2a464cSDavid Howells */ 5738b2a464cSDavid Howells struct afs_addr_cursor { 5748b2a464cSDavid Howells struct afs_addr_list *alist; /* Current address list (pins ref) */ 5758b2a464cSDavid Howells struct sockaddr_rxrpc *addr; 576d2ddc776SDavid Howells u32 abort_code; 5778b2a464cSDavid Howells unsigned short start; /* Starting point in alist->addrs[] */ 5788b2a464cSDavid Howells unsigned short index; /* Wrapping offset from start to current addr */ 5798b2a464cSDavid Howells short error; 5808b2a464cSDavid Howells bool begun; /* T if we've begun iteration */ 5818b2a464cSDavid Howells bool responded; /* T if the current address responded */ 5828b2a464cSDavid Howells }; 5838b2a464cSDavid Howells 5848b2a464cSDavid Howells /* 5858b2a464cSDavid Howells * Cursor for iterating over a set of fileservers. 5868b2a464cSDavid Howells */ 5878b2a464cSDavid Howells struct afs_fs_cursor { 5888b2a464cSDavid Howells struct afs_addr_cursor ac; 589d2ddc776SDavid Howells struct afs_vnode *vnode; 590d2ddc776SDavid Howells struct afs_server_list *server_list; /* Current server list (pins ref) */ 591d2ddc776SDavid Howells struct afs_cb_interest *cbi; /* Server on which this resides (pins ref) */ 592d2ddc776SDavid Howells struct key *key; /* Key for the server */ 593d2ddc776SDavid Howells unsigned int cb_break; /* cb_break + cb_s_break before the call */ 594d2ddc776SDavid Howells unsigned int cb_break_2; /* cb_break + cb_s_break (2nd vnode) */ 595d2ddc776SDavid Howells unsigned char start; /* Initial index in server list */ 596d2ddc776SDavid Howells unsigned char index; /* Number of servers tried beyond start */ 597d2ddc776SDavid Howells unsigned short flags; 598d2ddc776SDavid Howells #define AFS_FS_CURSOR_STOP 0x0001 /* Set to cease iteration */ 599d2ddc776SDavid Howells #define AFS_FS_CURSOR_VBUSY 0x0002 /* Set if seen VBUSY */ 600d2ddc776SDavid Howells #define AFS_FS_CURSOR_VMOVED 0x0004 /* Set if seen VMOVED */ 601d2ddc776SDavid Howells #define AFS_FS_CURSOR_VNOVOL 0x0008 /* Set if seen VNOVOL */ 602d2ddc776SDavid Howells #define AFS_FS_CURSOR_CUR_ONLY 0x0010 /* Set if current server only (file lock held) */ 603d2ddc776SDavid Howells #define AFS_FS_CURSOR_NO_VSLEEP 0x0020 /* Set to prevent sleep on VBUSY, VOFFLINE, ... */ 6048b2a464cSDavid Howells }; 6058b2a464cSDavid Howells 606402cb8ddSDavid Howells /* 607402cb8ddSDavid Howells * Cache auxiliary data. 608402cb8ddSDavid Howells */ 609402cb8ddSDavid Howells struct afs_vnode_cache_aux { 610402cb8ddSDavid Howells u64 data_version; 611402cb8ddSDavid Howells } __packed; 612402cb8ddSDavid Howells 61398bf40cdSDavid Howells #include <trace/events/afs.h> 61498bf40cdSDavid Howells 61508e0e7c8SDavid Howells /*****************************************************************************/ 61608e0e7c8SDavid Howells /* 6178b2a464cSDavid Howells * addr_list.c 6188b2a464cSDavid Howells */ 6198b2a464cSDavid Howells static inline struct afs_addr_list *afs_get_addrlist(struct afs_addr_list *alist) 6208b2a464cSDavid Howells { 6218b2a464cSDavid Howells if (alist) 6228b2a464cSDavid Howells refcount_inc(&alist->usage); 6238b2a464cSDavid Howells return alist; 6248b2a464cSDavid Howells } 6258b2a464cSDavid Howells extern struct afs_addr_list *afs_alloc_addrlist(unsigned int, 6268b2a464cSDavid Howells unsigned short, 6278b2a464cSDavid Howells unsigned short); 6288b2a464cSDavid Howells extern void afs_put_addrlist(struct afs_addr_list *); 6298b2a464cSDavid Howells extern struct afs_addr_list *afs_parse_text_addrs(const char *, size_t, char, 6308b2a464cSDavid Howells unsigned short, unsigned short); 6318b2a464cSDavid Howells extern struct afs_addr_list *afs_dns_query(struct afs_cell *, time64_t *); 6328b2a464cSDavid Howells extern bool afs_iterate_addresses(struct afs_addr_cursor *); 6338b2a464cSDavid Howells extern int afs_end_cursor(struct afs_addr_cursor *); 6348b2a464cSDavid Howells extern int afs_set_vl_cursor(struct afs_addr_cursor *, struct afs_cell *); 6358b2a464cSDavid Howells 636bf99a53cSDavid Howells extern void afs_merge_fs_addr4(struct afs_addr_list *, __be32, u16); 637bf99a53cSDavid Howells extern void afs_merge_fs_addr6(struct afs_addr_list *, __be32 *, u16); 638d2ddc776SDavid Howells 6398b2a464cSDavid Howells /* 6409b3f26c9SDavid Howells * cache.c 6419b3f26c9SDavid Howells */ 6429b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 6439b3f26c9SDavid Howells extern struct fscache_netfs afs_cache_netfs; 6449b3f26c9SDavid Howells extern struct fscache_cookie_def afs_cell_cache_index_def; 6459b3f26c9SDavid Howells extern struct fscache_cookie_def afs_volume_cache_index_def; 6469b3f26c9SDavid Howells extern struct fscache_cookie_def afs_vnode_cache_index_def; 6479b3f26c9SDavid Howells #else 6489b3f26c9SDavid Howells #define afs_cell_cache_index_def (*(struct fscache_cookie_def *) NULL) 6499b3f26c9SDavid Howells #define afs_volume_cache_index_def (*(struct fscache_cookie_def *) NULL) 6509b3f26c9SDavid Howells #define afs_vnode_cache_index_def (*(struct fscache_cookie_def *) NULL) 6519b3f26c9SDavid Howells #endif 6529b3f26c9SDavid Howells 6539b3f26c9SDavid Howells /* 65408e0e7c8SDavid Howells * callback.c 65508e0e7c8SDavid Howells */ 65608e0e7c8SDavid Howells extern void afs_init_callback_state(struct afs_server *); 657c435ee34SDavid Howells extern void afs_break_callback(struct afs_vnode *); 6585cf9dd55SDavid Howells extern void afs_break_callbacks(struct afs_server *, size_t, struct afs_callback_break*); 659c435ee34SDavid Howells 660d4a96becSDavid Howells extern int afs_register_server_cb_interest(struct afs_vnode *, 661d4a96becSDavid Howells struct afs_server_list *, unsigned int); 662c435ee34SDavid Howells extern void afs_put_cb_interest(struct afs_net *, struct afs_cb_interest *); 663d2ddc776SDavid Howells extern void afs_clear_callback_interests(struct afs_net *, struct afs_server_list *); 664c435ee34SDavid Howells 665c435ee34SDavid Howells static inline struct afs_cb_interest *afs_get_cb_interest(struct afs_cb_interest *cbi) 666c435ee34SDavid Howells { 667d4a96becSDavid Howells if (cbi) 668c435ee34SDavid Howells refcount_inc(&cbi->usage); 669c435ee34SDavid Howells return cbi; 670c435ee34SDavid Howells } 6711da177e4SLinus Torvalds 67268251f0aSDavid Howells static inline unsigned int afs_calc_vnode_cb_break(struct afs_vnode *vnode) 67368251f0aSDavid Howells { 67468251f0aSDavid Howells return vnode->cb_break + vnode->cb_s_break + vnode->cb_v_break; 67568251f0aSDavid Howells } 67668251f0aSDavid Howells 67768251f0aSDavid Howells static inline unsigned int afs_cb_break_sum(struct afs_vnode *vnode, 67868251f0aSDavid Howells struct afs_cb_interest *cbi) 67968251f0aSDavid Howells { 68068251f0aSDavid Howells return vnode->cb_break + cbi->server->cb_s_break + vnode->volume->cb_v_break; 68168251f0aSDavid Howells } 68268251f0aSDavid Howells 6831da177e4SLinus Torvalds /* 6841da177e4SLinus Torvalds * cell.c 6851da177e4SLinus Torvalds */ 686989782dcSDavid Howells extern int afs_cell_init(struct afs_net *, const char *); 687989782dcSDavid Howells extern struct afs_cell *afs_lookup_cell_rcu(struct afs_net *, const char *, unsigned); 688989782dcSDavid Howells extern struct afs_cell *afs_lookup_cell(struct afs_net *, const char *, unsigned, 689989782dcSDavid Howells const char *, bool); 6908b2a464cSDavid Howells extern struct afs_cell *afs_get_cell(struct afs_cell *); 6919ed900b1SDavid Howells extern void afs_put_cell(struct afs_net *, struct afs_cell *); 692989782dcSDavid Howells extern void afs_manage_cells(struct work_struct *); 693989782dcSDavid Howells extern void afs_cells_timer(struct timer_list *); 694f044c884SDavid Howells extern void __net_exit afs_cell_purge(struct afs_net *); 69508e0e7c8SDavid Howells 69608e0e7c8SDavid Howells /* 69708e0e7c8SDavid Howells * cmservice.c 69808e0e7c8SDavid Howells */ 69908e0e7c8SDavid Howells extern bool afs_cm_incoming_call(struct afs_call *); 70008e0e7c8SDavid Howells 7011da177e4SLinus Torvalds /* 7021da177e4SLinus Torvalds * dir.c 7031da177e4SLinus Torvalds */ 7044b6f5d20SArjan van de Ven extern const struct file_operations afs_dir_file_operations; 7054d673da1SDavid Howells extern const struct inode_operations afs_dir_inode_operations; 706f3ddee8dSDavid Howells extern const struct address_space_operations afs_dir_aops; 7074d673da1SDavid Howells extern const struct dentry_operations afs_fs_dentry_operations; 7084d673da1SDavid Howells 70966c7e1d3SDavid Howells extern void afs_d_release(struct dentry *); 71066c7e1d3SDavid Howells 71166c7e1d3SDavid Howells /* 71263a4681fSDavid Howells * dir_edit.c 71363a4681fSDavid Howells */ 71463a4681fSDavid Howells extern void afs_edit_dir_add(struct afs_vnode *, struct qstr *, struct afs_fid *, 71563a4681fSDavid Howells enum afs_edit_dir_reason); 71663a4681fSDavid Howells extern void afs_edit_dir_remove(struct afs_vnode *, struct qstr *, enum afs_edit_dir_reason); 71763a4681fSDavid Howells 71863a4681fSDavid Howells /* 71966c7e1d3SDavid Howells * dynroot.c 72066c7e1d3SDavid Howells */ 72166c7e1d3SDavid Howells extern const struct file_operations afs_dynroot_file_operations; 72266c7e1d3SDavid Howells extern const struct inode_operations afs_dynroot_inode_operations; 72366c7e1d3SDavid Howells extern const struct dentry_operations afs_dynroot_dentry_operations; 72466c7e1d3SDavid Howells 72566c7e1d3SDavid Howells extern struct inode *afs_try_auto_mntpt(struct dentry *, struct inode *); 7260da0b7fdSDavid Howells extern int afs_dynroot_mkdir(struct afs_net *, struct afs_cell *); 7270da0b7fdSDavid Howells extern void afs_dynroot_rmdir(struct afs_net *, struct afs_cell *); 7280da0b7fdSDavid Howells extern int afs_dynroot_populate(struct super_block *); 7290da0b7fdSDavid Howells extern void afs_dynroot_depopulate(struct super_block *); 7301da177e4SLinus Torvalds 7311da177e4SLinus Torvalds /* 7321da177e4SLinus Torvalds * file.c 7331da177e4SLinus Torvalds */ 734f5e54d6eSChristoph Hellwig extern const struct address_space_operations afs_fs_aops; 735754661f1SArjan van de Ven extern const struct inode_operations afs_file_inode_operations; 73600d3b7a4SDavid Howells extern const struct file_operations afs_file_operations; 73700d3b7a4SDavid Howells 7384343d008SDavid Howells extern int afs_cache_wb_key(struct afs_vnode *, struct afs_file *); 7394343d008SDavid Howells extern void afs_put_wb_key(struct afs_wb_key *); 74000d3b7a4SDavid Howells extern int afs_open(struct inode *, struct file *); 74100d3b7a4SDavid Howells extern int afs_release(struct inode *, struct file *); 742d2ddc776SDavid Howells extern int afs_fetch_data(struct afs_vnode *, struct key *, struct afs_read *); 743f6d335c0SAl Viro extern int afs_page_filler(void *, struct page *); 744196ee9cdSDavid Howells extern void afs_put_read(struct afs_read *); 7451da177e4SLinus Torvalds 7461da177e4SLinus Torvalds /* 747e8d6c554SDavid Howells * flock.c 748e8d6c554SDavid Howells */ 749f044c884SDavid Howells extern struct workqueue_struct *afs_lock_manager; 750f044c884SDavid Howells 751e8d6c554SDavid Howells extern void afs_lock_work(struct work_struct *); 752e8d6c554SDavid Howells extern void afs_lock_may_be_available(struct afs_vnode *); 753e8d6c554SDavid Howells extern int afs_lock(struct file *, int, struct file_lock *); 754e8d6c554SDavid Howells extern int afs_flock(struct file *, int, struct file_lock *); 755e8d6c554SDavid Howells 756e8d6c554SDavid Howells /* 75708e0e7c8SDavid Howells * fsclient.c 75808e0e7c8SDavid Howells */ 759dd9fbcb8SDavid Howells #define AFS_VNODE_NOT_YET_SET 0x01 760dd9fbcb8SDavid Howells #define AFS_VNODE_META_CHANGED 0x02 761dd9fbcb8SDavid Howells #define AFS_VNODE_DATA_CHANGED 0x04 762dd9fbcb8SDavid Howells extern void afs_update_inode_from_status(struct afs_vnode *, struct afs_file_status *, 763dd9fbcb8SDavid Howells const afs_dataversion_t *, u8); 764dd9fbcb8SDavid Howells 7650c3a5ac2SDavid Howells extern int afs_fs_fetch_file_status(struct afs_fs_cursor *, struct afs_volsync *, bool); 766d2ddc776SDavid Howells extern int afs_fs_give_up_callbacks(struct afs_net *, struct afs_server *); 767d2ddc776SDavid Howells extern int afs_fs_fetch_data(struct afs_fs_cursor *, struct afs_read *); 76863a4681fSDavid Howells extern int afs_fs_create(struct afs_fs_cursor *, const char *, umode_t, u64, 769d2ddc776SDavid Howells struct afs_fid *, struct afs_file_status *, struct afs_callback *); 77063a4681fSDavid Howells extern int afs_fs_remove(struct afs_fs_cursor *, const char *, bool, u64); 77163a4681fSDavid Howells extern int afs_fs_link(struct afs_fs_cursor *, struct afs_vnode *, const char *, u64); 77263a4681fSDavid Howells extern int afs_fs_symlink(struct afs_fs_cursor *, const char *, const char *, u64, 773d2ddc776SDavid Howells struct afs_fid *, struct afs_file_status *); 774d2ddc776SDavid Howells extern int afs_fs_rename(struct afs_fs_cursor *, const char *, 77563a4681fSDavid Howells struct afs_vnode *, const char *, u64, u64); 7764343d008SDavid Howells extern int afs_fs_store_data(struct afs_fs_cursor *, struct address_space *, 777d2ddc776SDavid Howells pgoff_t, pgoff_t, unsigned, unsigned); 778d2ddc776SDavid Howells extern int afs_fs_setattr(struct afs_fs_cursor *, struct iattr *); 779d2ddc776SDavid Howells extern int afs_fs_get_volume_status(struct afs_fs_cursor *, struct afs_volume_status *); 780d2ddc776SDavid Howells extern int afs_fs_set_lock(struct afs_fs_cursor *, afs_lock_type_t); 781d2ddc776SDavid Howells extern int afs_fs_extend_lock(struct afs_fs_cursor *); 782d2ddc776SDavid Howells extern int afs_fs_release_lock(struct afs_fs_cursor *); 783d2ddc776SDavid Howells extern int afs_fs_give_up_all_callbacks(struct afs_net *, struct afs_server *, 784d2ddc776SDavid Howells struct afs_addr_cursor *, struct key *); 785d2ddc776SDavid Howells extern int afs_fs_get_capabilities(struct afs_net *, struct afs_server *, 786d2ddc776SDavid Howells struct afs_addr_cursor *, struct key *); 7875cf9dd55SDavid Howells extern int afs_fs_inline_bulk_status(struct afs_fs_cursor *, struct afs_net *, 7885cf9dd55SDavid Howells struct afs_fid *, struct afs_file_status *, 7895cf9dd55SDavid Howells struct afs_callback *, unsigned int, 7905cf9dd55SDavid Howells struct afs_volsync *); 7915cf9dd55SDavid Howells extern int afs_fs_fetch_status(struct afs_fs_cursor *, struct afs_net *, 7925cf9dd55SDavid Howells struct afs_fid *, struct afs_file_status *, 7935cf9dd55SDavid Howells struct afs_callback *, struct afs_volsync *); 79408e0e7c8SDavid Howells 79508e0e7c8SDavid Howells /* 7961da177e4SLinus Torvalds * inode.c 7971da177e4SLinus Torvalds */ 7980c3a5ac2SDavid Howells extern int afs_fetch_status(struct afs_vnode *, struct key *, bool); 799c435ee34SDavid Howells extern int afs_iget5_test(struct inode *, void *); 8004d673da1SDavid Howells extern struct inode *afs_iget_pseudo_dir(struct super_block *, bool); 80100d3b7a4SDavid Howells extern struct inode *afs_iget(struct super_block *, struct key *, 802260a9803SDavid Howells struct afs_fid *, struct afs_file_status *, 803d2ddc776SDavid Howells struct afs_callback *, 804d2ddc776SDavid Howells struct afs_cb_interest *); 805416351f2SDavid Howells extern void afs_zap_data(struct afs_vnode *); 806260a9803SDavid Howells extern int afs_validate(struct afs_vnode *, struct key *); 807a528d35eSDavid Howells extern int afs_getattr(const struct path *, struct kstat *, u32, unsigned int); 80831143d5dSDavid Howells extern int afs_setattr(struct dentry *, struct iattr *); 809b57922d9SAl Viro extern void afs_evict_inode(struct inode *); 810bec5eb61Swanglei extern int afs_drop_inode(struct inode *); 8111da177e4SLinus Torvalds 8121da177e4SLinus Torvalds /* 8131da177e4SLinus Torvalds * main.c 8141da177e4SLinus Torvalds */ 8150ad53eeeSTejun Heo extern struct workqueue_struct *afs_wq; 8165b86d4ffSDavid Howells extern int afs_net_id; 8175b86d4ffSDavid Howells 8185b86d4ffSDavid Howells static inline struct afs_net *afs_net(struct net *net) 8195b86d4ffSDavid Howells { 8205b86d4ffSDavid Howells return net_generic(net, afs_net_id); 8215b86d4ffSDavid Howells } 8225b86d4ffSDavid Howells 8235b86d4ffSDavid Howells static inline struct afs_net *afs_sb2net(struct super_block *sb) 8245b86d4ffSDavid Howells { 8255b86d4ffSDavid Howells return afs_net(AFS_FS_S(sb)->net_ns); 8265b86d4ffSDavid Howells } 827f044c884SDavid Howells 828f044c884SDavid Howells static inline struct afs_net *afs_d2net(struct dentry *dentry) 829f044c884SDavid Howells { 8305b86d4ffSDavid Howells return afs_sb2net(dentry->d_sb); 831f044c884SDavid Howells } 832f044c884SDavid Howells 833f044c884SDavid Howells static inline struct afs_net *afs_i2net(struct inode *inode) 834f044c884SDavid Howells { 8355b86d4ffSDavid Howells return afs_sb2net(inode->i_sb); 836f044c884SDavid Howells } 837f044c884SDavid Howells 838f044c884SDavid Howells static inline struct afs_net *afs_v2net(struct afs_vnode *vnode) 839f044c884SDavid Howells { 8405b86d4ffSDavid Howells return afs_i2net(&vnode->vfs_inode); 841f044c884SDavid Howells } 842f044c884SDavid Howells 843f044c884SDavid Howells static inline struct afs_net *afs_sock2net(struct sock *sk) 844f044c884SDavid Howells { 8455b86d4ffSDavid Howells return net_generic(sock_net(sk), afs_net_id); 846f044c884SDavid Howells } 8471da177e4SLinus Torvalds 848d55b4da4SDavid Howells static inline void __afs_stat(atomic_t *s) 849d55b4da4SDavid Howells { 850d55b4da4SDavid Howells atomic_inc(s); 851d55b4da4SDavid Howells } 852d55b4da4SDavid Howells 853d55b4da4SDavid Howells #define afs_stat_v(vnode, n) __afs_stat(&afs_v2net(vnode)->n) 854d55b4da4SDavid Howells 8551da177e4SLinus Torvalds /* 85608e0e7c8SDavid Howells * misc.c 85708e0e7c8SDavid Howells */ 85808e0e7c8SDavid Howells extern int afs_abort_to_error(u32); 85908e0e7c8SDavid Howells 86008e0e7c8SDavid Howells /* 8611da177e4SLinus Torvalds * mntpt.c 8621da177e4SLinus Torvalds */ 863754661f1SArjan van de Ven extern const struct inode_operations afs_mntpt_inode_operations; 864bec5eb61Swanglei extern const struct inode_operations afs_autocell_inode_operations; 8654b6f5d20SArjan van de Ven extern const struct file_operations afs_mntpt_file_operations; 8661da177e4SLinus Torvalds 867d18610b0SDavid Howells extern struct vfsmount *afs_d_automount(struct path *); 86808e0e7c8SDavid Howells extern void afs_mntpt_kill_timer(void); 8691da177e4SLinus Torvalds 8701da177e4SLinus Torvalds /* 871b4db2b35SArnd Bergmann * netdevices.c 872b4db2b35SArnd Bergmann */ 8735b86d4ffSDavid Howells extern int afs_get_ipv4_interfaces(struct afs_net *, struct afs_interface *, 8745b86d4ffSDavid Howells size_t, bool); 875b4db2b35SArnd Bergmann 876b4db2b35SArnd Bergmann /* 8771da177e4SLinus Torvalds * proc.c 8781da177e4SLinus Torvalds */ 879b6cfbecaSDavid Howells #ifdef CONFIG_PROC_FS 880f044c884SDavid Howells extern int __net_init afs_proc_init(struct afs_net *); 881f044c884SDavid Howells extern void __net_exit afs_proc_cleanup(struct afs_net *); 8825b86d4ffSDavid Howells extern int afs_proc_cell_setup(struct afs_cell *); 8835b86d4ffSDavid Howells extern void afs_proc_cell_remove(struct afs_cell *); 8846f8880d8SDavid Howells extern void afs_put_sysnames(struct afs_sysnames *); 885b6cfbecaSDavid Howells #else 886b6cfbecaSDavid Howells static inline int afs_proc_init(struct afs_net *net) { return 0; } 887b6cfbecaSDavid Howells static inline void afs_proc_cleanup(struct afs_net *net) {} 888b6cfbecaSDavid Howells static inline int afs_proc_cell_setup(struct afs_cell *cell) { return 0; } 889b6cfbecaSDavid Howells static inline void afs_proc_cell_remove(struct afs_cell *cell) {} 890b6cfbecaSDavid Howells static inline void afs_put_sysnames(struct afs_sysnames *sysnames) {} 891b6cfbecaSDavid Howells #endif 8921da177e4SLinus Torvalds 89308e0e7c8SDavid Howells /* 894d2ddc776SDavid Howells * rotate.c 895d2ddc776SDavid Howells */ 896d2ddc776SDavid Howells extern bool afs_begin_vnode_operation(struct afs_fs_cursor *, struct afs_vnode *, 897d2ddc776SDavid Howells struct key *); 898d2ddc776SDavid Howells extern bool afs_select_fileserver(struct afs_fs_cursor *); 899d2ddc776SDavid Howells extern bool afs_select_current_fileserver(struct afs_fs_cursor *); 900d2ddc776SDavid Howells extern int afs_end_vnode_operation(struct afs_fs_cursor *); 901d2ddc776SDavid Howells 902d2ddc776SDavid Howells /* 90308e0e7c8SDavid Howells * rxrpc.c 90408e0e7c8SDavid Howells */ 905f044c884SDavid Howells extern struct workqueue_struct *afs_async_calls; 9068324f0bcSDavid Howells 907f044c884SDavid Howells extern int __net_init afs_open_socket(struct afs_net *); 908f044c884SDavid Howells extern void __net_exit afs_close_socket(struct afs_net *); 909f044c884SDavid Howells extern void afs_charge_preallocation(struct work_struct *); 910341f741fSDavid Howells extern void afs_put_call(struct afs_call *); 911341f741fSDavid Howells extern int afs_queue_call_work(struct afs_call *); 9128b2a464cSDavid Howells extern long afs_make_call(struct afs_addr_cursor *, struct afs_call *, gfp_t, bool); 913f044c884SDavid Howells extern struct afs_call *afs_alloc_flat_call(struct afs_net *, 914f044c884SDavid Howells const struct afs_call_type *, 91508e0e7c8SDavid Howells size_t, size_t); 91608e0e7c8SDavid Howells extern void afs_flat_call_destructor(struct afs_call *); 91708e0e7c8SDavid Howells extern void afs_send_empty_reply(struct afs_call *); 918b908fe6bSDavid Howells extern void afs_send_simple_reply(struct afs_call *, const void *, size_t); 919d001648eSDavid Howells extern int afs_extract_data(struct afs_call *, void *, size_t, bool); 9205f702c8eSDavid Howells extern int afs_protocol_error(struct afs_call *, int); 92108e0e7c8SDavid Howells 922d001648eSDavid Howells static inline int afs_transfer_reply(struct afs_call *call) 923372ee163SDavid Howells { 924d001648eSDavid Howells return afs_extract_data(call, call->buffer, call->reply_max, false); 925372ee163SDavid Howells } 926372ee163SDavid Howells 92798bf40cdSDavid Howells static inline bool afs_check_call_state(struct afs_call *call, 92898bf40cdSDavid Howells enum afs_call_state state) 92998bf40cdSDavid Howells { 93098bf40cdSDavid Howells return READ_ONCE(call->state) == state; 93198bf40cdSDavid Howells } 93298bf40cdSDavid Howells 93398bf40cdSDavid Howells static inline bool afs_set_call_state(struct afs_call *call, 93498bf40cdSDavid Howells enum afs_call_state from, 93598bf40cdSDavid Howells enum afs_call_state to) 93698bf40cdSDavid Howells { 93798bf40cdSDavid Howells bool ok = false; 93898bf40cdSDavid Howells 93998bf40cdSDavid Howells spin_lock_bh(&call->state_lock); 94098bf40cdSDavid Howells if (call->state == from) { 94198bf40cdSDavid Howells call->state = to; 94298bf40cdSDavid Howells trace_afs_call_state(call, from, to, 0, 0); 94398bf40cdSDavid Howells ok = true; 94498bf40cdSDavid Howells } 94598bf40cdSDavid Howells spin_unlock_bh(&call->state_lock); 94698bf40cdSDavid Howells return ok; 94798bf40cdSDavid Howells } 94898bf40cdSDavid Howells 94998bf40cdSDavid Howells static inline void afs_set_call_complete(struct afs_call *call, 95098bf40cdSDavid Howells int error, u32 remote_abort) 95198bf40cdSDavid Howells { 95298bf40cdSDavid Howells enum afs_call_state state; 95398bf40cdSDavid Howells bool ok = false; 95498bf40cdSDavid Howells 95598bf40cdSDavid Howells spin_lock_bh(&call->state_lock); 95698bf40cdSDavid Howells state = call->state; 95798bf40cdSDavid Howells if (state != AFS_CALL_COMPLETE) { 95898bf40cdSDavid Howells call->abort_code = remote_abort; 95998bf40cdSDavid Howells call->error = error; 96098bf40cdSDavid Howells call->state = AFS_CALL_COMPLETE; 96198bf40cdSDavid Howells trace_afs_call_state(call, state, AFS_CALL_COMPLETE, 96298bf40cdSDavid Howells error, remote_abort); 96398bf40cdSDavid Howells ok = true; 96498bf40cdSDavid Howells } 96598bf40cdSDavid Howells spin_unlock_bh(&call->state_lock); 96698bf40cdSDavid Howells if (ok) 96798bf40cdSDavid Howells trace_afs_call_done(call); 96898bf40cdSDavid Howells } 96998bf40cdSDavid Howells 97008e0e7c8SDavid Howells /* 97100d3b7a4SDavid Howells * security.c 97200d3b7a4SDavid Howells */ 973be080a6fSDavid Howells extern void afs_put_permits(struct afs_permits *); 97400d3b7a4SDavid Howells extern void afs_clear_permits(struct afs_vnode *); 975be080a6fSDavid Howells extern void afs_cache_permit(struct afs_vnode *, struct key *, unsigned int); 976416351f2SDavid Howells extern void afs_zap_permits(struct rcu_head *); 97700d3b7a4SDavid Howells extern struct key *afs_request_key(struct afs_cell *); 9780fafdc9fSDavid Howells extern int afs_check_permit(struct afs_vnode *, struct key *, afs_access_t *); 97910556cb2SAl Viro extern int afs_permission(struct inode *, int); 980be080a6fSDavid Howells extern void __exit afs_clean_up_permit_cache(void); 98100d3b7a4SDavid Howells 98200d3b7a4SDavid Howells /* 98308e0e7c8SDavid Howells * server.c 98408e0e7c8SDavid Howells */ 98508e0e7c8SDavid Howells extern spinlock_t afs_server_peer_lock; 98608e0e7c8SDavid Howells 987c435ee34SDavid Howells static inline struct afs_server *afs_get_server(struct afs_server *server) 988c435ee34SDavid Howells { 989c435ee34SDavid Howells atomic_inc(&server->usage); 990c435ee34SDavid Howells return server; 991c435ee34SDavid Howells } 99208e0e7c8SDavid Howells 993f044c884SDavid Howells extern struct afs_server *afs_find_server(struct afs_net *, 994f044c884SDavid Howells const struct sockaddr_rxrpc *); 995d2ddc776SDavid Howells extern struct afs_server *afs_find_server_by_uuid(struct afs_net *, const uuid_t *); 996d2ddc776SDavid Howells extern struct afs_server *afs_lookup_server(struct afs_cell *, struct key *, const uuid_t *); 9979ed900b1SDavid Howells extern void afs_put_server(struct afs_net *, struct afs_server *); 998d2ddc776SDavid Howells extern void afs_manage_servers(struct work_struct *); 999d2ddc776SDavid Howells extern void afs_servers_timer(struct timer_list *); 1000f044c884SDavid Howells extern void __net_exit afs_purge_servers(struct afs_net *); 1001d2ddc776SDavid Howells extern bool afs_probe_fileserver(struct afs_fs_cursor *); 1002d2ddc776SDavid Howells extern bool afs_check_server_record(struct afs_fs_cursor *, struct afs_server *); 1003d2ddc776SDavid Howells 1004d2ddc776SDavid Howells /* 1005d2ddc776SDavid Howells * server_list.c 1006d2ddc776SDavid Howells */ 1007d2ddc776SDavid Howells static inline struct afs_server_list *afs_get_serverlist(struct afs_server_list *slist) 1008d2ddc776SDavid Howells { 1009d2ddc776SDavid Howells refcount_inc(&slist->usage); 1010d2ddc776SDavid Howells return slist; 1011d2ddc776SDavid Howells } 1012d2ddc776SDavid Howells 1013d2ddc776SDavid Howells extern void afs_put_serverlist(struct afs_net *, struct afs_server_list *); 1014d2ddc776SDavid Howells extern struct afs_server_list *afs_alloc_server_list(struct afs_cell *, struct key *, 1015d2ddc776SDavid Howells struct afs_vldb_entry *, 1016d2ddc776SDavid Howells u8); 1017d2ddc776SDavid Howells extern bool afs_annotate_server_list(struct afs_server_list *, struct afs_server_list *); 101808e0e7c8SDavid Howells 101908e0e7c8SDavid Howells /* 102000d3b7a4SDavid Howells * super.c 102100d3b7a4SDavid Howells */ 1022f044c884SDavid Howells extern int __init afs_fs_init(void); 10235b86d4ffSDavid Howells extern void afs_fs_exit(void); 102400d3b7a4SDavid Howells 102500d3b7a4SDavid Howells /* 102608e0e7c8SDavid Howells * vlclient.c 102708e0e7c8SDavid Howells */ 1028d2ddc776SDavid Howells extern struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_net *, 1029d2ddc776SDavid Howells struct afs_addr_cursor *, 1030d2ddc776SDavid Howells struct key *, const char *, int); 1031d2ddc776SDavid Howells extern struct afs_addr_list *afs_vl_get_addrs_u(struct afs_net *, struct afs_addr_cursor *, 1032d2ddc776SDavid Howells struct key *, const uuid_t *); 1033bf99a53cSDavid Howells extern int afs_vl_get_capabilities(struct afs_net *, struct afs_addr_cursor *, struct key *); 1034bf99a53cSDavid Howells extern struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_net *, struct afs_addr_cursor *, 1035bf99a53cSDavid Howells struct key *, const uuid_t *); 103608e0e7c8SDavid Howells 103708e0e7c8SDavid Howells /* 103808e0e7c8SDavid Howells * volume.c 103908e0e7c8SDavid Howells */ 1040d2ddc776SDavid Howells static inline struct afs_volume *__afs_get_volume(struct afs_volume *volume) 104149566f6fSDavid Howells { 104249566f6fSDavid Howells if (volume) 104349566f6fSDavid Howells atomic_inc(&volume->usage); 104449566f6fSDavid Howells return volume; 104549566f6fSDavid Howells } 104608e0e7c8SDavid Howells 1047d2ddc776SDavid Howells extern struct afs_volume *afs_create_volume(struct afs_mount_params *); 1048d2ddc776SDavid Howells extern void afs_activate_volume(struct afs_volume *); 1049d2ddc776SDavid Howells extern void afs_deactivate_volume(struct afs_volume *); 10509ed900b1SDavid Howells extern void afs_put_volume(struct afs_cell *, struct afs_volume *); 1051d2ddc776SDavid Howells extern int afs_check_volume_status(struct afs_volume *, struct key *); 105208e0e7c8SDavid Howells 105331143d5dSDavid Howells /* 105431143d5dSDavid Howells * write.c 105531143d5dSDavid Howells */ 105631143d5dSDavid Howells extern int afs_set_page_dirty(struct page *); 105715b4650eSNick Piggin extern int afs_write_begin(struct file *file, struct address_space *mapping, 105815b4650eSNick Piggin loff_t pos, unsigned len, unsigned flags, 105915b4650eSNick Piggin struct page **pagep, void **fsdata); 106015b4650eSNick Piggin extern int afs_write_end(struct file *file, struct address_space *mapping, 106115b4650eSNick Piggin loff_t pos, unsigned len, unsigned copied, 106215b4650eSNick Piggin struct page *page, void *fsdata); 106331143d5dSDavid Howells extern int afs_writepage(struct page *, struct writeback_control *); 106431143d5dSDavid Howells extern int afs_writepages(struct address_space *, struct writeback_control *); 106531143d5dSDavid Howells extern void afs_pages_written_back(struct afs_vnode *, struct afs_call *); 106650b5551dSAl Viro extern ssize_t afs_file_write(struct kiocb *, struct iov_iter *); 106702c24a82SJosef Bacik extern int afs_fsync(struct file *, loff_t, loff_t, int); 10681cf7a151SDavid Howells extern int afs_page_mkwrite(struct vm_fault *); 10694343d008SDavid Howells extern void afs_prune_wb_keys(struct afs_vnode *); 10704343d008SDavid Howells extern int afs_launder_page(struct page *); 107131143d5dSDavid Howells 1072d3e3b7eaSDavid Howells /* 1073d3e3b7eaSDavid Howells * xattr.c 1074d3e3b7eaSDavid Howells */ 1075d3e3b7eaSDavid Howells extern const struct xattr_handler *afs_xattr_handlers[]; 1076d3e3b7eaSDavid Howells extern ssize_t afs_listxattr(struct dentry *, char *, size_t); 107731143d5dSDavid Howells 1078d2ddc776SDavid Howells 1079d2ddc776SDavid Howells /* 1080d2ddc776SDavid Howells * Miscellaneous inline functions. 1081d2ddc776SDavid Howells */ 1082d2ddc776SDavid Howells static inline struct afs_vnode *AFS_FS_I(struct inode *inode) 1083d2ddc776SDavid Howells { 1084d2ddc776SDavid Howells return container_of(inode, struct afs_vnode, vfs_inode); 1085d2ddc776SDavid Howells } 1086d2ddc776SDavid Howells 1087d2ddc776SDavid Howells static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode) 1088d2ddc776SDavid Howells { 1089d2ddc776SDavid Howells return &vnode->vfs_inode; 1090d2ddc776SDavid Howells } 1091d2ddc776SDavid Howells 1092d2ddc776SDavid Howells static inline void afs_vnode_commit_status(struct afs_fs_cursor *fc, 1093d2ddc776SDavid Howells struct afs_vnode *vnode, 1094d2ddc776SDavid Howells unsigned int cb_break) 1095d2ddc776SDavid Howells { 1096d2ddc776SDavid Howells if (fc->ac.error == 0) 1097d2ddc776SDavid Howells afs_cache_permit(vnode, fc->key, cb_break); 1098d2ddc776SDavid Howells } 1099d2ddc776SDavid Howells 1100d2ddc776SDavid Howells static inline void afs_check_for_remote_deletion(struct afs_fs_cursor *fc, 1101d2ddc776SDavid Howells struct afs_vnode *vnode) 1102d2ddc776SDavid Howells { 1103d2ddc776SDavid Howells if (fc->ac.error == -ENOENT) { 1104d2ddc776SDavid Howells set_bit(AFS_VNODE_DELETED, &vnode->flags); 1105d2ddc776SDavid Howells afs_break_callback(vnode); 1106d2ddc776SDavid Howells } 1107d2ddc776SDavid Howells } 1108d2ddc776SDavid Howells 1109d2ddc776SDavid Howells 111008e0e7c8SDavid Howells /*****************************************************************************/ 111108e0e7c8SDavid Howells /* 111208e0e7c8SDavid Howells * debug tracing 111308e0e7c8SDavid Howells */ 111408e0e7c8SDavid Howells extern unsigned afs_debug; 111508e0e7c8SDavid Howells 111608e0e7c8SDavid Howells #define dbgprintk(FMT,...) \ 1117ad16df84SSven Schnelle printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__) 111808e0e7c8SDavid Howells 1119530b6412SHarvey Harrison #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__) 1120530b6412SHarvey Harrison #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) 112108e0e7c8SDavid Howells #define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__) 112208e0e7c8SDavid Howells 112308e0e7c8SDavid Howells 112408e0e7c8SDavid Howells #if defined(__KDEBUG) 112508e0e7c8SDavid Howells #define _enter(FMT,...) kenter(FMT,##__VA_ARGS__) 112608e0e7c8SDavid Howells #define _leave(FMT,...) kleave(FMT,##__VA_ARGS__) 112708e0e7c8SDavid Howells #define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__) 112808e0e7c8SDavid Howells 112908e0e7c8SDavid Howells #elif defined(CONFIG_AFS_DEBUG) 113008e0e7c8SDavid Howells #define AFS_DEBUG_KENTER 0x01 113108e0e7c8SDavid Howells #define AFS_DEBUG_KLEAVE 0x02 113208e0e7c8SDavid Howells #define AFS_DEBUG_KDEBUG 0x04 113308e0e7c8SDavid Howells 113408e0e7c8SDavid Howells #define _enter(FMT,...) \ 113508e0e7c8SDavid Howells do { \ 113608e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \ 113708e0e7c8SDavid Howells kenter(FMT,##__VA_ARGS__); \ 113808e0e7c8SDavid Howells } while (0) 113908e0e7c8SDavid Howells 114008e0e7c8SDavid Howells #define _leave(FMT,...) \ 114108e0e7c8SDavid Howells do { \ 114208e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \ 114308e0e7c8SDavid Howells kleave(FMT,##__VA_ARGS__); \ 114408e0e7c8SDavid Howells } while (0) 114508e0e7c8SDavid Howells 114608e0e7c8SDavid Howells #define _debug(FMT,...) \ 114708e0e7c8SDavid Howells do { \ 114808e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \ 114908e0e7c8SDavid Howells kdebug(FMT,##__VA_ARGS__); \ 115008e0e7c8SDavid Howells } while (0) 115108e0e7c8SDavid Howells 115208e0e7c8SDavid Howells #else 115312fdff3fSDavid Howells #define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__) 115412fdff3fSDavid Howells #define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) 115512fdff3fSDavid Howells #define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__) 115608e0e7c8SDavid Howells #endif 115708e0e7c8SDavid Howells 115808e0e7c8SDavid Howells /* 115908e0e7c8SDavid Howells * debug assertion checking 116008e0e7c8SDavid Howells */ 116108e0e7c8SDavid Howells #if 1 // defined(__KDEBUGALL) 116208e0e7c8SDavid Howells 116308e0e7c8SDavid Howells #define ASSERT(X) \ 116408e0e7c8SDavid Howells do { \ 116508e0e7c8SDavid Howells if (unlikely(!(X))) { \ 116608e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 116708e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 116808e0e7c8SDavid Howells BUG(); \ 116908e0e7c8SDavid Howells } \ 117008e0e7c8SDavid Howells } while(0) 117108e0e7c8SDavid Howells 117208e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y) \ 117308e0e7c8SDavid Howells do { \ 117408e0e7c8SDavid Howells if (unlikely(!((X) OP (Y)))) { \ 117508e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 117608e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 117708e0e7c8SDavid Howells printk(KERN_ERR "%lu " #OP " %lu is false\n", \ 117808e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 117908e0e7c8SDavid Howells printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ 118008e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 118108e0e7c8SDavid Howells BUG(); \ 118208e0e7c8SDavid Howells } \ 118308e0e7c8SDavid Howells } while(0) 118408e0e7c8SDavid Howells 1185416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H) \ 1186416351f2SDavid Howells do { \ 1187416351f2SDavid Howells if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) { \ 1188416351f2SDavid Howells printk(KERN_ERR "\n"); \ 1189416351f2SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 1190416351f2SDavid Howells printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n", \ 1191416351f2SDavid Howells (unsigned long)(L), (unsigned long)(N), \ 1192416351f2SDavid Howells (unsigned long)(H)); \ 1193416351f2SDavid Howells printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \ 1194416351f2SDavid Howells (unsigned long)(L), (unsigned long)(N), \ 1195416351f2SDavid Howells (unsigned long)(H)); \ 1196416351f2SDavid Howells BUG(); \ 1197416351f2SDavid Howells } \ 1198416351f2SDavid Howells } while(0) 1199416351f2SDavid Howells 120008e0e7c8SDavid Howells #define ASSERTIF(C, X) \ 120108e0e7c8SDavid Howells do { \ 120208e0e7c8SDavid Howells if (unlikely((C) && !(X))) { \ 120308e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 120408e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 120508e0e7c8SDavid Howells BUG(); \ 120608e0e7c8SDavid Howells } \ 120708e0e7c8SDavid Howells } while(0) 120808e0e7c8SDavid Howells 120908e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y) \ 121008e0e7c8SDavid Howells do { \ 121108e0e7c8SDavid Howells if (unlikely((C) && !((X) OP (Y)))) { \ 121208e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 121308e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 121408e0e7c8SDavid Howells printk(KERN_ERR "%lu " #OP " %lu is false\n", \ 121508e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 121608e0e7c8SDavid Howells printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ 121708e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 121808e0e7c8SDavid Howells BUG(); \ 121908e0e7c8SDavid Howells } \ 122008e0e7c8SDavid Howells } while(0) 122108e0e7c8SDavid Howells 122208e0e7c8SDavid Howells #else 122308e0e7c8SDavid Howells 122408e0e7c8SDavid Howells #define ASSERT(X) \ 122508e0e7c8SDavid Howells do { \ 122608e0e7c8SDavid Howells } while(0) 122708e0e7c8SDavid Howells 122808e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y) \ 122908e0e7c8SDavid Howells do { \ 123008e0e7c8SDavid Howells } while(0) 123108e0e7c8SDavid Howells 1232416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H) \ 1233416351f2SDavid Howells do { \ 1234416351f2SDavid Howells } while(0) 1235416351f2SDavid Howells 123608e0e7c8SDavid Howells #define ASSERTIF(C, X) \ 123708e0e7c8SDavid Howells do { \ 123808e0e7c8SDavid Howells } while(0) 123908e0e7c8SDavid Howells 124008e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y) \ 124108e0e7c8SDavid Howells do { \ 124208e0e7c8SDavid Howells } while(0) 124308e0e7c8SDavid Howells 124408e0e7c8SDavid Howells #endif /* __KDEBUGALL */ 1245