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> 240722f186SSouptick Joarder #include <linux/mm_types.h> 250a5143f2SDavid Howells #include <linux/dns_resolver.h> 26f044c884SDavid Howells #include <net/net_namespace.h> 275b86d4ffSDavid Howells #include <net/netns/generic.h> 285b86d4ffSDavid Howells #include <net/sock.h> 298324f0bcSDavid Howells #include <net/af_rxrpc.h> 3000c541eaSAndrew Morton 3108e0e7c8SDavid Howells #include "afs.h" 3208e0e7c8SDavid Howells #include "afs_vl.h" 3308e0e7c8SDavid Howells 3408e0e7c8SDavid Howells #define AFS_CELL_MAX_ADDRS 15 3508e0e7c8SDavid Howells 3631143d5dSDavid Howells struct pagevec; 3708e0e7c8SDavid Howells struct afs_call; 3808e0e7c8SDavid Howells 3913fcc683SDavid Howells struct afs_fs_context { 4000d3b7a4SDavid Howells bool force; /* T to force cell type */ 41bec5eb61Swanglei bool autocell; /* T if set auto mount operation */ 424d673da1SDavid Howells bool dyn_root; /* T if dynamic root */ 4313fcc683SDavid Howells bool no_cell; /* T if the source is "none" (for dynroot) */ 4400d3b7a4SDavid Howells afs_voltype_t type; /* type of volume requested */ 4513fcc683SDavid Howells unsigned int volnamesz; /* size of volume name */ 4600d3b7a4SDavid Howells const char *volname; /* name of volume to mount */ 475b86d4ffSDavid Howells struct afs_net *net; /* the AFS net namespace stuff */ 4800d3b7a4SDavid Howells struct afs_cell *cell; /* cell in which to find volume */ 4900d3b7a4SDavid Howells struct afs_volume *volume; /* volume record */ 5000d3b7a4SDavid Howells struct key *key; /* key to use for secure mounting */ 5100d3b7a4SDavid Howells }; 5200d3b7a4SDavid Howells 53c435ee34SDavid Howells struct afs_iget_data { 54c435ee34SDavid Howells struct afs_fid fid; 55c435ee34SDavid Howells struct afs_volume *volume; /* volume on which resides */ 56c435ee34SDavid Howells }; 57c435ee34SDavid Howells 588e8d7f13SDavid Howells enum afs_call_state { 5998bf40cdSDavid Howells AFS_CALL_CL_REQUESTING, /* Client: Request is being sent */ 6098bf40cdSDavid Howells AFS_CALL_CL_AWAIT_REPLY, /* Client: Awaiting reply */ 6198bf40cdSDavid Howells AFS_CALL_CL_PROC_REPLY, /* Client: rxrpc call complete; processing reply */ 6298bf40cdSDavid Howells AFS_CALL_SV_AWAIT_OP_ID, /* Server: Awaiting op ID */ 6398bf40cdSDavid Howells AFS_CALL_SV_AWAIT_REQUEST, /* Server: Awaiting request data */ 6498bf40cdSDavid Howells AFS_CALL_SV_REPLYING, /* Server: Replying */ 6598bf40cdSDavid Howells AFS_CALL_SV_AWAIT_ACK, /* Server: Awaiting final ACK */ 668e8d7f13SDavid Howells AFS_CALL_COMPLETE, /* Completed or failed */ 678e8d7f13SDavid Howells }; 68f044c884SDavid Howells 6908e0e7c8SDavid Howells /* 708b2a464cSDavid Howells * List of server addresses. 718b2a464cSDavid Howells */ 728b2a464cSDavid Howells struct afs_addr_list { 738b2a464cSDavid Howells struct rcu_head rcu; /* Must be first */ 748b2a464cSDavid Howells refcount_t usage; 75d2ddc776SDavid Howells u32 version; /* Version */ 7668eb64c3SDavid Howells unsigned char max_addrs; 7768eb64c3SDavid Howells unsigned char nr_addrs; 783bf0fb6fSDavid Howells unsigned char preferred; /* Preferred address */ 7968eb64c3SDavid Howells unsigned char nr_ipv4; /* Number of IPv4 addresses */ 800a5143f2SDavid Howells enum dns_record_source source:8; 810a5143f2SDavid Howells enum dns_lookup_status status:8; 82bf99a53cSDavid Howells unsigned long probed; /* Mask of servers that have been probed */ 833bf0fb6fSDavid Howells unsigned long failed; /* Mask of addrs that failed locally/ICMP */ 843bf0fb6fSDavid Howells unsigned long responded; /* Mask of addrs that responded */ 858b2a464cSDavid Howells struct sockaddr_rxrpc addrs[]; 8668eb64c3SDavid Howells #define AFS_MAX_ADDRESSES ((unsigned int)(sizeof(unsigned long) * 8)) 878b2a464cSDavid Howells }; 888b2a464cSDavid Howells 898b2a464cSDavid Howells /* 9008e0e7c8SDavid Howells * a record of an in-progress RxRPC call 9108e0e7c8SDavid Howells */ 9208e0e7c8SDavid Howells struct afs_call { 9308e0e7c8SDavid Howells const struct afs_call_type *type; /* type of call */ 943bf0fb6fSDavid Howells struct afs_addr_list *alist; /* Address is alist[addr_ix] */ 9508e0e7c8SDavid Howells wait_queue_head_t waitq; /* processes awaiting completion */ 96341f741fSDavid Howells struct work_struct async_work; /* async I/O processor */ 9708e0e7c8SDavid Howells struct work_struct work; /* actual work processor */ 9808e0e7c8SDavid Howells struct rxrpc_call *rxcall; /* RxRPC call handle */ 9908e0e7c8SDavid Howells struct key *key; /* security for this call */ 100f044c884SDavid Howells struct afs_net *net; /* The network namespace */ 101d0676a16SDavid Howells struct afs_server *cm_server; /* Server affected by incoming CM call */ 102d2ddc776SDavid Howells struct afs_cb_interest *cbi; /* Callback interest for server used */ 10308e0e7c8SDavid Howells void *request; /* request data (first part) */ 1044343d008SDavid Howells struct address_space *mapping; /* Pages being written from */ 10512bdcf33SDavid Howells struct iov_iter iter; /* Buffer iterator */ 10612bdcf33SDavid Howells struct iov_iter *_iter; /* Iterator currently in use */ 10712bdcf33SDavid Howells union { /* Convenience for ->iter */ 10812bdcf33SDavid Howells struct kvec kvec[1]; 10912bdcf33SDavid Howells struct bio_vec bvec[1]; 11012bdcf33SDavid Howells }; 11108e0e7c8SDavid Howells void *buffer; /* reply receive buffer */ 11297e3043aSDavid Howells void *reply[4]; /* Where to put the reply */ 11331143d5dSDavid Howells pgoff_t first; /* first page in mapping to deal with */ 11431143d5dSDavid Howells pgoff_t last; /* last page in mapping to deal with */ 115341f741fSDavid Howells atomic_t usage; 1168e8d7f13SDavid Howells enum afs_call_state state; 11798bf40cdSDavid Howells spinlock_t state_lock; 11808e0e7c8SDavid Howells int error; /* error code */ 119d001648eSDavid Howells u32 abort_code; /* Remote abort ID or 0 */ 1203bf0fb6fSDavid Howells u32 epoch; 12108e0e7c8SDavid Howells unsigned request_size; /* size of request data */ 12208e0e7c8SDavid Howells unsigned reply_max; /* maximum size of reply */ 12331143d5dSDavid Howells unsigned first_offset; /* offset into mapping[first] */ 124c435ee34SDavid Howells unsigned int cb_break; /* cb_break + cb_s_break before the call */ 125bcd89270SMarc Dionne union { 12631143d5dSDavid Howells unsigned last_to; /* amount of mapping[last] */ 127bcd89270SMarc Dionne unsigned count2; /* count used in unmarshalling */ 128bcd89270SMarc Dionne }; 12908e0e7c8SDavid Howells unsigned char unmarshall; /* unmarshalling phase */ 1303bf0fb6fSDavid Howells unsigned char addr_ix; /* Address in ->alist */ 13108e0e7c8SDavid Howells bool incoming; /* T if incoming call */ 13231143d5dSDavid Howells bool send_pages; /* T if data from mapping should be sent */ 133d001648eSDavid Howells bool need_attention; /* T if RxRPC poked us */ 13456ff9c83SDavid Howells bool async; /* T if asynchronous */ 13533cd7f2bSDavid Howells bool ret_reply0; /* T if should return reply[0] on success */ 136a68f4a27SDavid Howells bool upgrade; /* T to request service upgrade */ 13712d8e95aSDavid Howells bool want_reply_time; /* T if want reply_time */ 138bf99a53cSDavid Howells u16 service_id; /* Actual service ID (after upgrade) */ 139a25e21f0SDavid Howells unsigned int debug_id; /* Trace ID */ 14050a2c953SDavid Howells u32 operation_ID; /* operation ID for an incoming call */ 14108e0e7c8SDavid Howells u32 count; /* count for use in unmarshalling */ 14212bdcf33SDavid Howells union { /* place to extract temporary data */ 14312bdcf33SDavid Howells struct { 14412bdcf33SDavid Howells __be32 tmp_u; 14512bdcf33SDavid Howells __be32 tmp; 14612bdcf33SDavid Howells } __attribute__((packed)); 14712bdcf33SDavid Howells __be64 tmp64; 14812bdcf33SDavid Howells }; 1490c3a5ac2SDavid Howells afs_dataversion_t expected_version; /* Updated version expected from store */ 1500c3a5ac2SDavid Howells afs_dataversion_t expected_version_2; /* 2nd updated version expected from store */ 15112d8e95aSDavid Howells ktime_t reply_time; /* Time of first reply packet */ 15208e0e7c8SDavid Howells }; 15308e0e7c8SDavid Howells 15408e0e7c8SDavid Howells struct afs_call_type { 15500d3b7a4SDavid Howells const char *name; 156025db80cSDavid Howells unsigned int op; /* Really enum afs_fs_operation */ 15700d3b7a4SDavid Howells 15808e0e7c8SDavid Howells /* deliver request or reply data to an call 15908e0e7c8SDavid Howells * - returning an error will cause the call to be aborted 16008e0e7c8SDavid Howells */ 161d001648eSDavid Howells int (*deliver)(struct afs_call *call); 16208e0e7c8SDavid Howells 16308e0e7c8SDavid Howells /* clean up a call */ 16408e0e7c8SDavid Howells void (*destructor)(struct afs_call *call); 165341f741fSDavid Howells 166341f741fSDavid Howells /* Work function */ 167341f741fSDavid Howells void (*work)(struct work_struct *work); 1683bf0fb6fSDavid Howells 1693bf0fb6fSDavid Howells /* Call done function (gets called immediately on success or failure) */ 1703bf0fb6fSDavid Howells void (*done)(struct afs_call *call); 17108e0e7c8SDavid Howells }; 17208e0e7c8SDavid Howells 17308e0e7c8SDavid Howells /* 1744343d008SDavid Howells * Key available for writeback on a file. 1754343d008SDavid Howells */ 1764343d008SDavid Howells struct afs_wb_key { 1774343d008SDavid Howells refcount_t usage; 1784343d008SDavid Howells struct key *key; 1794343d008SDavid Howells struct list_head vnode_link; /* Link in vnode->wb_keys */ 1804343d008SDavid Howells }; 1814343d008SDavid Howells 1824343d008SDavid Howells /* 183215804a9SDavid Howells * AFS open file information record. Pointed to by file->private_data. 184215804a9SDavid Howells */ 185215804a9SDavid Howells struct afs_file { 186215804a9SDavid Howells struct key *key; /* The key this file was opened with */ 1874343d008SDavid Howells struct afs_wb_key *wb; /* Writeback key record for this file */ 188215804a9SDavid Howells }; 189215804a9SDavid Howells 190215804a9SDavid Howells static inline struct key *afs_file_key(struct file *file) 191215804a9SDavid Howells { 192215804a9SDavid Howells struct afs_file *af = file->private_data; 193215804a9SDavid Howells 194215804a9SDavid Howells return af->key; 195215804a9SDavid Howells } 196215804a9SDavid Howells 197215804a9SDavid Howells /* 198196ee9cdSDavid Howells * Record of an outstanding read operation on a vnode. 199196ee9cdSDavid Howells */ 200196ee9cdSDavid Howells struct afs_read { 201196ee9cdSDavid Howells loff_t pos; /* Where to start reading */ 202e8e581a8SDavid Howells loff_t len; /* How much we're asking for */ 203196ee9cdSDavid Howells loff_t actual_len; /* How much we're actually getting */ 2046a0e3999SDavid Howells loff_t remain; /* Amount remaining */ 205f3ddee8dSDavid Howells loff_t file_size; /* File size returned by server */ 206f3ddee8dSDavid Howells afs_dataversion_t data_version; /* Version number returned by server */ 207f3ddee8dSDavid Howells refcount_t usage; 208196ee9cdSDavid Howells unsigned int index; /* Which page we're reading into */ 209196ee9cdSDavid Howells unsigned int nr_pages; 21012bdcf33SDavid Howells unsigned int offset; /* offset into current page */ 211196ee9cdSDavid Howells void (*page_done)(struct afs_call *, struct afs_read *); 212f3ddee8dSDavid Howells struct page **pages; 213f3ddee8dSDavid Howells struct page *array[]; 214196ee9cdSDavid Howells }; 215196ee9cdSDavid Howells 216196ee9cdSDavid Howells /* 21708e0e7c8SDavid Howells * AFS superblock private data 21808e0e7c8SDavid Howells * - there's one superblock per volume 21908e0e7c8SDavid Howells */ 22008e0e7c8SDavid Howells struct afs_super_info { 2215b86d4ffSDavid Howells struct net *net_ns; /* Network namespace */ 22249566f6fSDavid Howells struct afs_cell *cell; /* The cell in which the volume resides */ 22308e0e7c8SDavid Howells struct afs_volume *volume; /* volume record */ 2244d673da1SDavid Howells bool dyn_root; /* True if dynamic root */ 22508e0e7c8SDavid Howells }; 22608e0e7c8SDavid Howells 22708e0e7c8SDavid Howells static inline struct afs_super_info *AFS_FS_S(struct super_block *sb) 22808e0e7c8SDavid Howells { 22908e0e7c8SDavid Howells return sb->s_fs_info; 23008e0e7c8SDavid Howells } 23108e0e7c8SDavid Howells 23208e0e7c8SDavid Howells extern struct file_system_type afs_fs_type; 23308e0e7c8SDavid Howells 23408e0e7c8SDavid Howells /* 2356f8880d8SDavid Howells * Set of substitutes for @sys. 2366f8880d8SDavid Howells */ 2376f8880d8SDavid Howells struct afs_sysnames { 2386f8880d8SDavid Howells #define AFS_NR_SYSNAME 16 2396f8880d8SDavid Howells char *subs[AFS_NR_SYSNAME]; 2406f8880d8SDavid Howells refcount_t usage; 2416f8880d8SDavid Howells unsigned short nr; 2426f8880d8SDavid Howells char blank[1]; 2436f8880d8SDavid Howells }; 2446f8880d8SDavid Howells 2456f8880d8SDavid Howells /* 246f044c884SDavid Howells * AFS network namespace record. 247f044c884SDavid Howells */ 248f044c884SDavid Howells struct afs_net { 2495b86d4ffSDavid Howells struct net *net; /* Backpointer to the owning net namespace */ 250f044c884SDavid Howells struct afs_uuid uuid; 251f044c884SDavid Howells bool live; /* F if this namespace is being removed */ 252f044c884SDavid Howells 253f044c884SDavid Howells /* AF_RXRPC I/O stuff */ 254f044c884SDavid Howells struct socket *socket; 255f044c884SDavid Howells struct afs_call *spare_incoming_call; 256f044c884SDavid Howells struct work_struct charge_preallocation_work; 257f044c884SDavid Howells struct mutex socket_mutex; 258f044c884SDavid Howells atomic_t nr_outstanding_calls; 259f044c884SDavid Howells atomic_t nr_superblocks; 260f044c884SDavid Howells 261f044c884SDavid Howells /* Cell database */ 262989782dcSDavid Howells struct rb_root cells; 2631588def9SDavid Howells struct afs_cell __rcu *ws_cell; 264989782dcSDavid Howells struct work_struct cells_manager; 265989782dcSDavid Howells struct timer_list cells_timer; 266989782dcSDavid Howells atomic_t cells_outstanding; 267989782dcSDavid Howells seqlock_t cells_lock; 268f044c884SDavid Howells 2690da0b7fdSDavid Howells struct mutex proc_cells_lock; 2706b3944e4SDavid Howells struct hlist_head proc_cells; 271f044c884SDavid Howells 272d2ddc776SDavid Howells /* Known servers. Theoretically each fileserver can only be in one 273d2ddc776SDavid Howells * cell, but in practice, people create aliases and subsets and there's 274d2ddc776SDavid Howells * no easy way to distinguish them. 275d2ddc776SDavid Howells */ 276d2ddc776SDavid Howells seqlock_t fs_lock; /* For fs_servers */ 277d2ddc776SDavid Howells struct rb_root fs_servers; /* afs_server (by server UUID or address) */ 278d2ddc776SDavid Howells struct list_head fs_updates; /* afs_server (by update_at) */ 279d2ddc776SDavid Howells struct hlist_head fs_proc; /* procfs servers list */ 280d2ddc776SDavid Howells 281d2ddc776SDavid Howells struct hlist_head fs_addresses4; /* afs_server (by lowest IPv4 addr) */ 282d2ddc776SDavid Howells struct hlist_head fs_addresses6; /* afs_server (by lowest IPv6 addr) */ 283d2ddc776SDavid Howells seqlock_t fs_addr_lock; /* For fs_addresses[46] */ 284d2ddc776SDavid Howells 285d2ddc776SDavid Howells struct work_struct fs_manager; 286d2ddc776SDavid Howells struct timer_list fs_timer; 287d2ddc776SDavid Howells atomic_t servers_outstanding; 288f044c884SDavid Howells 289f044c884SDavid Howells /* File locking renewal management */ 290f044c884SDavid Howells struct mutex lock_manager_mutex; 291f044c884SDavid Howells 292f044c884SDavid Howells /* Misc */ 2930da0b7fdSDavid Howells struct super_block *dynroot_sb; /* Dynamic root mount superblock */ 294f044c884SDavid Howells struct proc_dir_entry *proc_afs; /* /proc/net/afs directory */ 2956f8880d8SDavid Howells struct afs_sysnames *sysnames; 2966f8880d8SDavid Howells rwlock_t sysnames_lock; 297d55b4da4SDavid Howells 298d55b4da4SDavid Howells /* Statistics counters */ 299d55b4da4SDavid Howells atomic_t n_lookup; /* Number of lookups done */ 300d55b4da4SDavid Howells atomic_t n_reval; /* Number of dentries needing revalidation */ 301d55b4da4SDavid Howells atomic_t n_inval; /* Number of invalidations by the server */ 302f3ddee8dSDavid Howells atomic_t n_relpg; /* Number of invalidations by releasepage */ 303d55b4da4SDavid Howells atomic_t n_read_dir; /* Number of directory pages read */ 30463a4681fSDavid Howells atomic_t n_dir_cr; /* Number of directory entry creation edits */ 30563a4681fSDavid Howells atomic_t n_dir_rm; /* Number of directory entry removal edits */ 30676a5cb6fSDavid Howells atomic_t n_stores; /* Number of store ops */ 30776a5cb6fSDavid Howells atomic_long_t n_store_bytes; /* Number of bytes stored */ 30876a5cb6fSDavid Howells atomic_long_t n_fetch_bytes; /* Number of bytes fetched */ 30976a5cb6fSDavid Howells atomic_t n_fetches; /* Number of data fetch ops */ 310f044c884SDavid Howells }; 311f044c884SDavid Howells 3126f8880d8SDavid Howells extern const char afs_init_sysname[]; 313f044c884SDavid Howells 314989782dcSDavid Howells enum afs_cell_state { 315989782dcSDavid Howells AFS_CELL_UNSET, 316989782dcSDavid Howells AFS_CELL_ACTIVATING, 317989782dcSDavid Howells AFS_CELL_ACTIVE, 318989782dcSDavid Howells AFS_CELL_DEACTIVATING, 319989782dcSDavid Howells AFS_CELL_INACTIVE, 320989782dcSDavid Howells AFS_CELL_FAILED, 321989782dcSDavid Howells }; 322989782dcSDavid Howells 323f044c884SDavid Howells /* 324d2ddc776SDavid Howells * AFS cell record. 325d2ddc776SDavid Howells * 326d2ddc776SDavid Howells * This is a tricky concept to get right as it is possible to create aliases 327d2ddc776SDavid Howells * simply by pointing AFSDB/SRV records for two names at the same set of VL 328d2ddc776SDavid Howells * servers; it is also possible to do things like setting up two sets of VL 329d2ddc776SDavid Howells * servers, one of which provides a superset of the volumes provided by the 330d2ddc776SDavid Howells * other (for internal/external division, for example). 331d2ddc776SDavid Howells * 332d2ddc776SDavid Howells * Cells only exist in the sense that (a) a cell's name maps to a set of VL 333d2ddc776SDavid Howells * servers and (b) a cell's name is used by the client to select the key to use 334d2ddc776SDavid Howells * for authentication and encryption. The cell name is not typically used in 335d2ddc776SDavid Howells * the protocol. 336d2ddc776SDavid Howells * 337d2ddc776SDavid Howells * There is no easy way to determine if two cells are aliases or one is a 338d2ddc776SDavid Howells * subset of another. 33908e0e7c8SDavid Howells */ 34008e0e7c8SDavid Howells struct afs_cell { 341989782dcSDavid Howells union { 342989782dcSDavid Howells struct rcu_head rcu; 343989782dcSDavid Howells struct rb_node net_node; /* Node in net->cells */ 344989782dcSDavid Howells }; 345989782dcSDavid Howells struct afs_net *net; 34600d3b7a4SDavid Howells struct key *anonymous_key; /* anonymous user key for this cell */ 347989782dcSDavid Howells struct work_struct manager; /* Manager for init/deinit/dns */ 3486b3944e4SDavid Howells struct hlist_node proc_link; /* /proc cell list link */ 3499b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 3509b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 3511da177e4SLinus Torvalds #endif 352989782dcSDavid Howells time64_t dns_expiry; /* Time AFSDB/SRV record expires */ 353989782dcSDavid Howells time64_t last_inactive; /* Time of last drop of usage count */ 354989782dcSDavid Howells atomic_t usage; 355989782dcSDavid Howells unsigned long flags; 356989782dcSDavid Howells #define AFS_CELL_FL_NOT_READY 0 /* The cell record is not ready for use */ 357989782dcSDavid Howells #define AFS_CELL_FL_NO_GC 1 /* The cell was added manually, don't auto-gc */ 358989782dcSDavid Howells #define AFS_CELL_FL_NOT_FOUND 2 /* Permanent DNS error */ 359989782dcSDavid Howells #define AFS_CELL_FL_DNS_FAIL 3 /* Failed to access DNS */ 3608b2a464cSDavid Howells #define AFS_CELL_FL_NO_LOOKUP_YET 4 /* Not completed first DNS lookup yet */ 361989782dcSDavid Howells enum afs_cell_state state; 362989782dcSDavid Howells short error; 363989782dcSDavid Howells 364d2ddc776SDavid Howells /* Active fileserver interaction state. */ 365d2ddc776SDavid Howells struct list_head proc_volumes; /* procfs volume list */ 366d2ddc776SDavid Howells rwlock_t proc_lock; 367989782dcSDavid Howells 368d2ddc776SDavid Howells /* VL server list. */ 3690a5143f2SDavid Howells rwlock_t vl_servers_lock; /* Lock on vl_servers */ 3700a5143f2SDavid Howells struct afs_vlserver_list __rcu *vl_servers; 3710a5143f2SDavid Howells 372989782dcSDavid Howells u8 name_len; /* Length of name */ 373989782dcSDavid Howells char name[64 + 1]; /* Cell name, case-flattened and NUL-padded */ 37408e0e7c8SDavid Howells }; 37508e0e7c8SDavid Howells 37608e0e7c8SDavid Howells /* 3770a5143f2SDavid Howells * Volume Location server record. 3780a5143f2SDavid Howells */ 3790a5143f2SDavid Howells struct afs_vlserver { 3800a5143f2SDavid Howells struct rcu_head rcu; 3810a5143f2SDavid Howells struct afs_addr_list __rcu *addresses; /* List of addresses for this VL server */ 3820a5143f2SDavid Howells unsigned long flags; 3830a5143f2SDavid Howells #define AFS_VLSERVER_FL_PROBED 0 /* The VL server has been probed */ 3840a5143f2SDavid Howells #define AFS_VLSERVER_FL_PROBING 1 /* VL server is being probed */ 3853bf0fb6fSDavid Howells #define AFS_VLSERVER_FL_IS_YFS 2 /* Server is YFS not AFS */ 3860a5143f2SDavid Howells rwlock_t lock; /* Lock on addresses */ 3870a5143f2SDavid Howells atomic_t usage; 3883bf0fb6fSDavid Howells 3893bf0fb6fSDavid Howells /* Probe state */ 3903bf0fb6fSDavid Howells wait_queue_head_t probe_wq; 3913bf0fb6fSDavid Howells atomic_t probe_outstanding; 3923bf0fb6fSDavid Howells spinlock_t probe_lock; 3933bf0fb6fSDavid Howells struct { 3943bf0fb6fSDavid Howells unsigned int rtt; /* RTT as ktime/64 */ 3953bf0fb6fSDavid Howells u32 abort_code; 3963bf0fb6fSDavid Howells short error; 3973bf0fb6fSDavid Howells bool have_result; 3983bf0fb6fSDavid Howells bool responded:1; 3993bf0fb6fSDavid Howells bool is_yfs:1; 4003bf0fb6fSDavid Howells bool not_yfs:1; 4013bf0fb6fSDavid Howells bool local_failure:1; 4023bf0fb6fSDavid Howells } probe; 4033bf0fb6fSDavid Howells 4040a5143f2SDavid Howells u16 port; 4053bf0fb6fSDavid Howells u16 name_len; /* Length of name */ 4060a5143f2SDavid Howells char name[]; /* Server name, case-flattened */ 4070a5143f2SDavid Howells }; 4080a5143f2SDavid Howells 4090a5143f2SDavid Howells /* 4100a5143f2SDavid Howells * Weighted list of Volume Location servers. 4110a5143f2SDavid Howells */ 4120a5143f2SDavid Howells struct afs_vlserver_entry { 4130a5143f2SDavid Howells u16 priority; /* Preference (as SRV) */ 4140a5143f2SDavid Howells u16 weight; /* Weight (as SRV) */ 4150a5143f2SDavid Howells enum dns_record_source source:8; 4160a5143f2SDavid Howells enum dns_lookup_status status:8; 4170a5143f2SDavid Howells struct afs_vlserver *server; 4180a5143f2SDavid Howells }; 4190a5143f2SDavid Howells 4200a5143f2SDavid Howells struct afs_vlserver_list { 4210a5143f2SDavid Howells struct rcu_head rcu; 4220a5143f2SDavid Howells atomic_t usage; 4230a5143f2SDavid Howells u8 nr_servers; 4240a5143f2SDavid Howells u8 index; /* Server currently in use */ 4253bf0fb6fSDavid Howells u8 preferred; /* Preferred server */ 4260a5143f2SDavid Howells enum dns_record_source source:8; 4270a5143f2SDavid Howells enum dns_lookup_status status:8; 4280a5143f2SDavid Howells rwlock_t lock; 4290a5143f2SDavid Howells struct afs_vlserver_entry servers[]; 4300a5143f2SDavid Howells }; 4310a5143f2SDavid Howells 4320a5143f2SDavid Howells /* 433d2ddc776SDavid Howells * Cached VLDB entry. 434d2ddc776SDavid Howells * 435d2ddc776SDavid Howells * This is pointed to by cell->vldb_entries, indexed by name. 43608e0e7c8SDavid Howells */ 437d2ddc776SDavid Howells struct afs_vldb_entry { 438d2ddc776SDavid Howells afs_volid_t vid[3]; /* Volume IDs for R/W, R/O and Bak volumes */ 43900d3b7a4SDavid Howells 440d2ddc776SDavid Howells unsigned long flags; 441d2ddc776SDavid Howells #define AFS_VLDB_HAS_RW 0 /* - R/W volume exists */ 442d2ddc776SDavid Howells #define AFS_VLDB_HAS_RO 1 /* - R/O volume exists */ 443d2ddc776SDavid Howells #define AFS_VLDB_HAS_BAK 2 /* - Backup volume exists */ 444d2ddc776SDavid Howells #define AFS_VLDB_QUERY_VALID 3 /* - Record is valid */ 445d2ddc776SDavid Howells #define AFS_VLDB_QUERY_ERROR 4 /* - VL server returned error */ 446d2ddc776SDavid Howells 447d2ddc776SDavid Howells uuid_t fs_server[AFS_NMAXNSERVERS]; 448d2ddc776SDavid Howells u8 fs_mask[AFS_NMAXNSERVERS]; 44908e0e7c8SDavid Howells #define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */ 45008e0e7c8SDavid Howells #define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */ 45108e0e7c8SDavid Howells #define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */ 452d2ddc776SDavid Howells short error; 453d2ddc776SDavid Howells u8 nr_servers; /* Number of server records */ 454d2ddc776SDavid Howells u8 name_len; 455d2ddc776SDavid Howells u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */ 45608e0e7c8SDavid Howells }; 45708e0e7c8SDavid Howells 45808e0e7c8SDavid Howells /* 459d2ddc776SDavid Howells * Record of fileserver with which we're actively communicating. 46008e0e7c8SDavid Howells */ 46108e0e7c8SDavid Howells struct afs_server { 462d2ddc776SDavid Howells struct rcu_head rcu; 463d2ddc776SDavid Howells union { 464d2ddc776SDavid Howells uuid_t uuid; /* Server ID */ 465d2ddc776SDavid Howells struct afs_uuid _uuid; 466d2ddc776SDavid Howells }; 467c435ee34SDavid Howells 468d2ddc776SDavid Howells struct afs_addr_list __rcu *addresses; 469d2ddc776SDavid Howells struct rb_node uuid_rb; /* Link in net->servers */ 470d2ddc776SDavid Howells struct hlist_node addr4_link; /* Link in net->fs_addresses4 */ 471d2ddc776SDavid Howells struct hlist_node addr6_link; /* Link in net->fs_addresses6 */ 472d2ddc776SDavid Howells struct hlist_node proc_link; /* Link in net->fs_proc */ 473d2ddc776SDavid Howells struct afs_server *gc_next; /* Next server in manager's list */ 474d2ddc776SDavid Howells time64_t put_time; /* Time at which last put */ 475d2ddc776SDavid Howells time64_t update_at; /* Time at which to next update the record */ 476c435ee34SDavid Howells unsigned long flags; 477d2ddc776SDavid Howells #define AFS_SERVER_FL_NOT_READY 1 /* The record is not ready for use */ 478d2ddc776SDavid Howells #define AFS_SERVER_FL_NOT_FOUND 2 /* VL server says no such server */ 479d2ddc776SDavid Howells #define AFS_SERVER_FL_VL_FAIL 3 /* Failed to access VL server */ 480d2ddc776SDavid Howells #define AFS_SERVER_FL_UPDATING 4 481d2ddc776SDavid Howells #define AFS_SERVER_FL_PROBED 5 /* The fileserver has been probed */ 482d2ddc776SDavid Howells #define AFS_SERVER_FL_PROBING 6 /* Fileserver is being probed */ 4835cf9dd55SDavid Howells #define AFS_SERVER_FL_NO_IBULK 7 /* Fileserver doesn't support FS.InlineBulkStatus */ 484f2686b09SDavid Howells #define AFS_SERVER_FL_MAY_HAVE_CB 8 /* May have callbacks on this fileserver */ 48530062bd1SDavid Howells #define AFS_SERVER_FL_IS_YFS 9 /* Server is YFS not AFS */ 48630062bd1SDavid Howells #define AFS_SERVER_FL_NO_RM2 10 /* Fileserver doesn't support YFS.RemoveFile2 */ 4873bf0fb6fSDavid Howells #define AFS_SERVER_FL_HAVE_EPOCH 11 /* ->epoch is valid */ 488d2ddc776SDavid Howells atomic_t usage; 489d2ddc776SDavid Howells u32 addr_version; /* Address list version */ 4903bf0fb6fSDavid Howells u32 cm_epoch; /* Server RxRPC epoch */ 49108e0e7c8SDavid Howells 49208e0e7c8SDavid Howells /* file service access */ 493d2ddc776SDavid Howells rwlock_t fs_lock; /* access lock */ 49408e0e7c8SDavid Howells 49508e0e7c8SDavid Howells /* callback promise management */ 49647ea0f2eSDavid Howells struct hlist_head cb_volumes; /* List of volume interests on this server */ 497c435ee34SDavid Howells unsigned cb_s_break; /* Break-everything counter. */ 498c435ee34SDavid Howells rwlock_t cb_break_lock; /* Volume finding lock */ 4993bf0fb6fSDavid Howells 5003bf0fb6fSDavid Howells /* Probe state */ 5013bf0fb6fSDavid Howells wait_queue_head_t probe_wq; 5023bf0fb6fSDavid Howells atomic_t probe_outstanding; 5033bf0fb6fSDavid Howells spinlock_t probe_lock; 5043bf0fb6fSDavid Howells struct { 5053bf0fb6fSDavid Howells unsigned int rtt; /* RTT as ktime/64 */ 5063bf0fb6fSDavid Howells u32 abort_code; 5073bf0fb6fSDavid Howells u32 cm_epoch; 5083bf0fb6fSDavid Howells short error; 5093bf0fb6fSDavid Howells bool have_result; 5103bf0fb6fSDavid Howells bool responded:1; 5113bf0fb6fSDavid Howells bool is_yfs:1; 5123bf0fb6fSDavid Howells bool not_yfs:1; 5133bf0fb6fSDavid Howells bool local_failure:1; 5143bf0fb6fSDavid Howells bool no_epoch:1; 5153bf0fb6fSDavid Howells bool cm_probed:1; 5163bf0fb6fSDavid Howells bool said_rebooted:1; 5173bf0fb6fSDavid Howells bool said_inconsistent:1; 5183bf0fb6fSDavid Howells } probe; 519c435ee34SDavid Howells }; 520c435ee34SDavid Howells 521c435ee34SDavid Howells /* 52247ea0f2eSDavid Howells * Volume collation in the server's callback interest list. 52347ea0f2eSDavid Howells */ 52447ea0f2eSDavid Howells struct afs_vol_interest { 52547ea0f2eSDavid Howells struct hlist_node srv_link; /* Link in server->cb_volumes */ 52647ea0f2eSDavid Howells struct hlist_head cb_interests; /* List of callback interests on the server */ 52747ea0f2eSDavid Howells afs_volid_t vid; /* Volume ID to match */ 52847ea0f2eSDavid Howells unsigned int usage; 52947ea0f2eSDavid Howells }; 53047ea0f2eSDavid Howells 53147ea0f2eSDavid Howells /* 532c435ee34SDavid Howells * Interest by a superblock on a server. 533c435ee34SDavid Howells */ 534c435ee34SDavid Howells struct afs_cb_interest { 53547ea0f2eSDavid Howells struct hlist_node cb_vlink; /* Link in vol_interest->cb_interests */ 53647ea0f2eSDavid Howells struct afs_vol_interest *vol_interest; 537c435ee34SDavid Howells struct afs_server *server; /* Server on which this interest resides */ 538c435ee34SDavid Howells struct super_block *sb; /* Superblock on which inodes reside */ 539c435ee34SDavid Howells afs_volid_t vid; /* Volume ID to match */ 540c435ee34SDavid Howells refcount_t usage; 54108e0e7c8SDavid Howells }; 54208e0e7c8SDavid Howells 54308e0e7c8SDavid Howells /* 544d2ddc776SDavid Howells * Replaceable server list. 54508e0e7c8SDavid Howells */ 546d2ddc776SDavid Howells struct afs_server_entry { 547d2ddc776SDavid Howells struct afs_server *server; 548d2ddc776SDavid Howells struct afs_cb_interest *cb_interest; 549d2ddc776SDavid Howells }; 550d2ddc776SDavid Howells 551d2ddc776SDavid Howells struct afs_server_list { 552d2ddc776SDavid Howells refcount_t usage; 5533bf0fb6fSDavid Howells unsigned char nr_servers; 5543bf0fb6fSDavid Howells unsigned char preferred; /* Preferred server */ 555d2ddc776SDavid Howells unsigned short vnovol_mask; /* Servers to be skipped due to VNOVOL */ 556d2ddc776SDavid Howells unsigned int seq; /* Set to ->servers_seq when installed */ 557d4a96becSDavid Howells rwlock_t lock; 558d2ddc776SDavid Howells struct afs_server_entry servers[]; 55908e0e7c8SDavid Howells }; 56008e0e7c8SDavid Howells 56108e0e7c8SDavid Howells /* 562d2ddc776SDavid Howells * Live AFS volume management. 56308e0e7c8SDavid Howells */ 564d2ddc776SDavid Howells struct afs_volume { 565d2ddc776SDavid Howells afs_volid_t vid; /* volume ID */ 566d2ddc776SDavid Howells atomic_t usage; 567d2ddc776SDavid Howells time64_t update_at; /* Time at which to next update */ 568d2ddc776SDavid Howells struct afs_cell *cell; /* Cell to which belongs (pins ref) */ 569d2ddc776SDavid Howells struct list_head proc_link; /* Link in cell->vl_proc */ 570d2ddc776SDavid Howells unsigned long flags; 571d2ddc776SDavid Howells #define AFS_VOLUME_NEEDS_UPDATE 0 /* - T if an update needs performing */ 572d2ddc776SDavid Howells #define AFS_VOLUME_UPDATING 1 /* - T if an update is in progress */ 573d2ddc776SDavid Howells #define AFS_VOLUME_WAIT 2 /* - T if users must wait for update */ 574d2ddc776SDavid Howells #define AFS_VOLUME_DELETED 3 /* - T if volume appears deleted */ 575d2ddc776SDavid Howells #define AFS_VOLUME_OFFLINE 4 /* - T if volume offline notice given */ 576d2ddc776SDavid Howells #define AFS_VOLUME_BUSY 5 /* - T if volume busy notice given */ 577d2ddc776SDavid Howells #ifdef CONFIG_AFS_FSCACHE 578d2ddc776SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 579d2ddc776SDavid Howells #endif 580d2ddc776SDavid Howells struct afs_server_list *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. */ 58568251f0aSDavid Howells rwlock_t cb_break_lock; 58668251f0aSDavid Howells 587d2ddc776SDavid Howells afs_voltype_t type; /* type of volume */ 588d2ddc776SDavid Howells short error; 589d2ddc776SDavid Howells char type_force; /* force volume type (suppress R/O -> R/W) */ 590d2ddc776SDavid Howells u8 name_len; 591d2ddc776SDavid Howells u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */ 59208e0e7c8SDavid Howells }; 59308e0e7c8SDavid Howells 5940fafdc9fSDavid Howells enum afs_lock_state { 5950fafdc9fSDavid Howells AFS_VNODE_LOCK_NONE, /* The vnode has no lock on the server */ 5960fafdc9fSDavid Howells AFS_VNODE_LOCK_WAITING_FOR_CB, /* We're waiting for the server to break the callback */ 5970fafdc9fSDavid Howells AFS_VNODE_LOCK_SETTING, /* We're asking the server for a lock */ 5980fafdc9fSDavid Howells AFS_VNODE_LOCK_GRANTED, /* We have a lock on the server */ 5990fafdc9fSDavid Howells AFS_VNODE_LOCK_EXTENDING, /* We're extending a lock on the server */ 6000fafdc9fSDavid Howells AFS_VNODE_LOCK_NEED_UNLOCK, /* We need to unlock on the server */ 6010fafdc9fSDavid Howells AFS_VNODE_LOCK_UNLOCKING, /* We're telling the server to unlock */ 602cdfb26b4SDavid Howells AFS_VNODE_LOCK_DELETED, /* The vnode has been deleted whilst we have a lock */ 6030fafdc9fSDavid Howells }; 6040fafdc9fSDavid Howells 60508e0e7c8SDavid Howells /* 606f8de483eSDavid Howells * AFS inode private data. 607f8de483eSDavid Howells * 608f8de483eSDavid Howells * Note that afs_alloc_inode() *must* reset anything that could incorrectly 609f8de483eSDavid Howells * leak from one inode to another. 61008e0e7c8SDavid Howells */ 61108e0e7c8SDavid Howells struct afs_vnode { 61208e0e7c8SDavid Howells struct inode vfs_inode; /* the VFS's inode record */ 61308e0e7c8SDavid Howells 61408e0e7c8SDavid Howells struct afs_volume *volume; /* volume on which vnode resides */ 61508e0e7c8SDavid Howells struct afs_fid fid; /* the file identifier for this inode */ 61608e0e7c8SDavid Howells struct afs_file_status status; /* AFS status info for this file */ 617a4ff7401SDavid Howells afs_dataversion_t invalid_before; /* Child dentries are invalid before this */ 6189b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 6199b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 62008e0e7c8SDavid Howells #endif 621fe342cf7SDavid Howells struct afs_permits __rcu *permit_cache; /* cache of permits so far obtained */ 622d2ddc776SDavid Howells struct mutex io_lock; /* Lock for serialising I/O on this mutex */ 623b61f7dcfSDavid Howells struct rw_semaphore validate_lock; /* lock for validating this vnode */ 6244343d008SDavid Howells spinlock_t wb_lock; /* lock for wb_keys */ 62508e0e7c8SDavid Howells spinlock_t lock; /* waitqueue/flags lock */ 62608e0e7c8SDavid Howells unsigned long flags; 627c435ee34SDavid Howells #define AFS_VNODE_CB_PROMISED 0 /* Set if vnode has a callback promise */ 628260a9803SDavid Howells #define AFS_VNODE_UNSET 1 /* set if vnode attributes not yet set */ 629f3ddee8dSDavid Howells #define AFS_VNODE_DIR_VALID 2 /* Set if dir contents are valid */ 63008e0e7c8SDavid Howells #define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */ 63108e0e7c8SDavid Howells #define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */ 63208e0e7c8SDavid Howells #define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */ 6330fafdc9fSDavid Howells #define AFS_VNODE_AUTOCELL 6 /* set if Vnode is an auto mount point */ 6340fafdc9fSDavid Howells #define AFS_VNODE_PSEUDODIR 7 /* set if Vnode is a pseudo directory */ 6355a813276SDavid Howells #define AFS_VNODE_NEW_CONTENT 8 /* Set if file has new content (create/trunc-0) */ 63608e0e7c8SDavid Howells 6374343d008SDavid Howells struct list_head wb_keys; /* List of keys available for writeback */ 638e8d6c554SDavid Howells struct list_head pending_locks; /* locks waiting to be granted */ 639e8d6c554SDavid Howells struct list_head granted_locks; /* locks granted on this file */ 640e8d6c554SDavid Howells struct delayed_work lock_work; /* work to be done in locking */ 6410fafdc9fSDavid Howells struct key *lock_key; /* Key to be used in lock ops */ 642a690f60aSDavid Howells ktime_t locked_at; /* Time at which lock obtained */ 6430fafdc9fSDavid Howells enum afs_lock_state lock_state : 8; 6440fafdc9fSDavid Howells afs_lock_type_t lock_type : 8; 64531143d5dSDavid Howells 64608e0e7c8SDavid Howells /* outstanding callback notification on this file */ 647c435ee34SDavid Howells struct afs_cb_interest *cb_interest; /* Server on which this resides */ 648c435ee34SDavid Howells unsigned int cb_s_break; /* Mass break counter on ->server */ 64968251f0aSDavid Howells unsigned int cb_v_break; /* Mass break counter on ->volume */ 650c435ee34SDavid Howells unsigned int cb_break; /* Break counter on vnode */ 651c435ee34SDavid Howells seqlock_t cb_lock; /* Lock for ->cb_interest, ->status, ->cb_*break */ 652c435ee34SDavid Howells 653c435ee34SDavid Howells time64_t cb_expires_at; /* time at which callback expires */ 65408e0e7c8SDavid Howells unsigned cb_version; /* callback version */ 65508e0e7c8SDavid Howells afs_callback_type_t cb_type; /* type of callback */ 65608e0e7c8SDavid Howells }; 65708e0e7c8SDavid Howells 65812bdcf33SDavid Howells static inline struct fscache_cookie *afs_vnode_cache(struct afs_vnode *vnode) 65912bdcf33SDavid Howells { 66012bdcf33SDavid Howells #ifdef CONFIG_AFS_FSCACHE 66112bdcf33SDavid Howells return vnode->cache; 66212bdcf33SDavid Howells #else 66312bdcf33SDavid Howells return NULL; 66412bdcf33SDavid Howells #endif 66512bdcf33SDavid Howells } 66612bdcf33SDavid Howells 66700d3b7a4SDavid Howells /* 66800d3b7a4SDavid Howells * cached security record for one user's attempt to access a vnode 66900d3b7a4SDavid Howells */ 67000d3b7a4SDavid Howells struct afs_permit { 67100d3b7a4SDavid Howells struct key *key; /* RxRPC ticket holding a security context */ 672be080a6fSDavid Howells afs_access_t access; /* CallerAccess value for this key */ 67300d3b7a4SDavid Howells }; 67400d3b7a4SDavid Howells 67500d3b7a4SDavid Howells /* 676be080a6fSDavid Howells * Immutable cache of CallerAccess records from attempts to access vnodes. 677be080a6fSDavid Howells * These may be shared between multiple vnodes. 67800d3b7a4SDavid Howells */ 67900d3b7a4SDavid Howells struct afs_permits { 680be080a6fSDavid Howells struct rcu_head rcu; 681be080a6fSDavid Howells struct hlist_node hash_node; /* Link in hash */ 682be080a6fSDavid Howells unsigned long h; /* Hash value for this permit list */ 683be080a6fSDavid Howells refcount_t usage; 684be080a6fSDavid Howells unsigned short nr_permits; /* Number of records */ 685be080a6fSDavid Howells bool invalidated; /* Invalidated due to key change */ 686be080a6fSDavid Howells struct afs_permit permits[]; /* List of permits sorted by key pointer */ 68700d3b7a4SDavid Howells }; 68800d3b7a4SDavid Howells 689b908fe6bSDavid Howells /* 690b908fe6bSDavid Howells * record of one of a system's set of network interfaces 691b908fe6bSDavid Howells */ 692b908fe6bSDavid Howells struct afs_interface { 693b908fe6bSDavid Howells struct in_addr address; /* IPv4 address bound to interface */ 694b908fe6bSDavid Howells struct in_addr netmask; /* netmask applied to address */ 695b908fe6bSDavid Howells unsigned mtu; /* MTU of interface */ 696b908fe6bSDavid Howells }; 697b908fe6bSDavid Howells 6988b2a464cSDavid Howells /* 6994584ae96SDavid Howells * Error prioritisation and accumulation. 7004584ae96SDavid Howells */ 7014584ae96SDavid Howells struct afs_error { 7024584ae96SDavid Howells short error; /* Accumulated error */ 7034584ae96SDavid Howells bool responded; /* T if server responded */ 7044584ae96SDavid Howells }; 7054584ae96SDavid Howells 7064584ae96SDavid Howells /* 7078b2a464cSDavid Howells * Cursor for iterating over a server's address list. 7088b2a464cSDavid Howells */ 7098b2a464cSDavid Howells struct afs_addr_cursor { 7108b2a464cSDavid Howells struct afs_addr_list *alist; /* Current address list (pins ref) */ 7113bf0fb6fSDavid Howells unsigned long tried; /* Tried addresses */ 7123bf0fb6fSDavid Howells signed char index; /* Current address */ 7138b2a464cSDavid Howells bool responded; /* T if the current address responded */ 714744bcd71SDavid Howells unsigned short nr_iterations; /* Number of address iterations */ 7153bf0fb6fSDavid Howells short error; 7163bf0fb6fSDavid Howells u32 abort_code; 7178b2a464cSDavid Howells }; 7188b2a464cSDavid Howells 7198b2a464cSDavid Howells /* 7200a5143f2SDavid Howells * Cursor for iterating over a set of volume location servers. 7210a5143f2SDavid Howells */ 7220a5143f2SDavid Howells struct afs_vl_cursor { 7230a5143f2SDavid Howells struct afs_addr_cursor ac; 7240a5143f2SDavid Howells struct afs_cell *cell; /* The cell we're querying */ 7250a5143f2SDavid Howells struct afs_vlserver_list *server_list; /* Current server list (pins ref) */ 7263bf0fb6fSDavid Howells struct afs_vlserver *server; /* Server on which this resides */ 7270a5143f2SDavid Howells struct key *key; /* Key for the server */ 7283bf0fb6fSDavid Howells unsigned long untried; /* Bitmask of untried servers */ 7293bf0fb6fSDavid Howells short index; /* Current server */ 7300a5143f2SDavid Howells short error; 7310a5143f2SDavid Howells unsigned short flags; 7320a5143f2SDavid Howells #define AFS_VL_CURSOR_STOP 0x0001 /* Set to cease iteration */ 7330a5143f2SDavid Howells #define AFS_VL_CURSOR_RETRY 0x0002 /* Set to do a retry */ 7340a5143f2SDavid Howells #define AFS_VL_CURSOR_RETRIED 0x0004 /* Set if started a retry */ 735744bcd71SDavid Howells unsigned short nr_iterations; /* Number of server iterations */ 7360a5143f2SDavid Howells }; 7370a5143f2SDavid Howells 7380a5143f2SDavid Howells /* 7398b2a464cSDavid Howells * Cursor for iterating over a set of fileservers. 7408b2a464cSDavid Howells */ 7418b2a464cSDavid Howells struct afs_fs_cursor { 7428b2a464cSDavid Howells struct afs_addr_cursor ac; 743d2ddc776SDavid Howells struct afs_vnode *vnode; 744d2ddc776SDavid Howells struct afs_server_list *server_list; /* Current server list (pins ref) */ 745d2ddc776SDavid Howells struct afs_cb_interest *cbi; /* Server on which this resides (pins ref) */ 746d2ddc776SDavid Howells struct key *key; /* Key for the server */ 7473bf0fb6fSDavid Howells unsigned long untried; /* Bitmask of untried servers */ 748d2ddc776SDavid Howells unsigned int cb_break; /* cb_break + cb_s_break before the call */ 749d2ddc776SDavid Howells unsigned int cb_break_2; /* cb_break + cb_s_break (2nd vnode) */ 7503bf0fb6fSDavid Howells short index; /* Current server */ 751e7f680f4SDavid Howells short error; 752d2ddc776SDavid Howells unsigned short flags; 753d2ddc776SDavid Howells #define AFS_FS_CURSOR_STOP 0x0001 /* Set to cease iteration */ 754d2ddc776SDavid Howells #define AFS_FS_CURSOR_VBUSY 0x0002 /* Set if seen VBUSY */ 755d2ddc776SDavid Howells #define AFS_FS_CURSOR_VMOVED 0x0004 /* Set if seen VMOVED */ 756d2ddc776SDavid Howells #define AFS_FS_CURSOR_VNOVOL 0x0008 /* Set if seen VNOVOL */ 757d2ddc776SDavid Howells #define AFS_FS_CURSOR_CUR_ONLY 0x0010 /* Set if current server only (file lock held) */ 758d2ddc776SDavid Howells #define AFS_FS_CURSOR_NO_VSLEEP 0x0020 /* Set to prevent sleep on VBUSY, VOFFLINE, ... */ 759744bcd71SDavid Howells unsigned short nr_iterations; /* Number of server iterations */ 7608b2a464cSDavid Howells }; 7618b2a464cSDavid Howells 762402cb8ddSDavid Howells /* 763402cb8ddSDavid Howells * Cache auxiliary data. 764402cb8ddSDavid Howells */ 765402cb8ddSDavid Howells struct afs_vnode_cache_aux { 766402cb8ddSDavid Howells u64 data_version; 767402cb8ddSDavid Howells } __packed; 768402cb8ddSDavid Howells 76998bf40cdSDavid Howells #include <trace/events/afs.h> 77098bf40cdSDavid Howells 77108e0e7c8SDavid Howells /*****************************************************************************/ 77208e0e7c8SDavid Howells /* 7738b2a464cSDavid Howells * addr_list.c 7748b2a464cSDavid Howells */ 7758b2a464cSDavid Howells static inline struct afs_addr_list *afs_get_addrlist(struct afs_addr_list *alist) 7768b2a464cSDavid Howells { 7778b2a464cSDavid Howells if (alist) 7788b2a464cSDavid Howells refcount_inc(&alist->usage); 7798b2a464cSDavid Howells return alist; 7808b2a464cSDavid Howells } 7818b2a464cSDavid Howells extern struct afs_addr_list *afs_alloc_addrlist(unsigned int, 7828b2a464cSDavid Howells unsigned short, 7838b2a464cSDavid Howells unsigned short); 7848b2a464cSDavid Howells extern void afs_put_addrlist(struct afs_addr_list *); 7850a5143f2SDavid Howells extern struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *, 7860a5143f2SDavid Howells const char *, size_t, char, 7878b2a464cSDavid Howells unsigned short, unsigned short); 7880a5143f2SDavid Howells extern struct afs_vlserver_list *afs_dns_query(struct afs_cell *, time64_t *); 7898b2a464cSDavid Howells extern bool afs_iterate_addresses(struct afs_addr_cursor *); 7908b2a464cSDavid Howells extern int afs_end_cursor(struct afs_addr_cursor *); 7918b2a464cSDavid Howells 792bf99a53cSDavid Howells extern void afs_merge_fs_addr4(struct afs_addr_list *, __be32, u16); 793bf99a53cSDavid Howells extern void afs_merge_fs_addr6(struct afs_addr_list *, __be32 *, u16); 794d2ddc776SDavid Howells 7958b2a464cSDavid Howells /* 7969b3f26c9SDavid Howells * cache.c 7979b3f26c9SDavid Howells */ 7989b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 7999b3f26c9SDavid Howells extern struct fscache_netfs afs_cache_netfs; 8009b3f26c9SDavid Howells extern struct fscache_cookie_def afs_cell_cache_index_def; 8019b3f26c9SDavid Howells extern struct fscache_cookie_def afs_volume_cache_index_def; 8029b3f26c9SDavid Howells extern struct fscache_cookie_def afs_vnode_cache_index_def; 8039b3f26c9SDavid Howells #else 8049b3f26c9SDavid Howells #define afs_cell_cache_index_def (*(struct fscache_cookie_def *) NULL) 8059b3f26c9SDavid Howells #define afs_volume_cache_index_def (*(struct fscache_cookie_def *) NULL) 8069b3f26c9SDavid Howells #define afs_vnode_cache_index_def (*(struct fscache_cookie_def *) NULL) 8079b3f26c9SDavid Howells #endif 8089b3f26c9SDavid Howells 8099b3f26c9SDavid Howells /* 81008e0e7c8SDavid Howells * callback.c 81108e0e7c8SDavid Howells */ 81208e0e7c8SDavid Howells extern void afs_init_callback_state(struct afs_server *); 81330062bd1SDavid Howells extern void __afs_break_callback(struct afs_vnode *); 814c435ee34SDavid Howells extern void afs_break_callback(struct afs_vnode *); 8155cf9dd55SDavid Howells extern void afs_break_callbacks(struct afs_server *, size_t, struct afs_callback_break*); 816c435ee34SDavid Howells 817d4a96becSDavid Howells extern int afs_register_server_cb_interest(struct afs_vnode *, 818d4a96becSDavid Howells struct afs_server_list *, unsigned int); 819c435ee34SDavid Howells extern void afs_put_cb_interest(struct afs_net *, struct afs_cb_interest *); 820d2ddc776SDavid Howells extern void afs_clear_callback_interests(struct afs_net *, struct afs_server_list *); 821c435ee34SDavid Howells 822c435ee34SDavid Howells static inline struct afs_cb_interest *afs_get_cb_interest(struct afs_cb_interest *cbi) 823c435ee34SDavid Howells { 824d4a96becSDavid Howells if (cbi) 825c435ee34SDavid Howells refcount_inc(&cbi->usage); 826c435ee34SDavid Howells return cbi; 827c435ee34SDavid Howells } 8281da177e4SLinus Torvalds 82968251f0aSDavid Howells static inline unsigned int afs_calc_vnode_cb_break(struct afs_vnode *vnode) 83068251f0aSDavid Howells { 831eeba1e9cSDavid Howells return vnode->cb_break + vnode->cb_v_break; 83268251f0aSDavid Howells } 83368251f0aSDavid Howells 83418ac6185SDavid Howells static inline bool afs_cb_is_broken(unsigned int cb_break, 83518ac6185SDavid Howells const struct afs_vnode *vnode, 83618ac6185SDavid Howells const struct afs_cb_interest *cbi) 83768251f0aSDavid Howells { 83818ac6185SDavid Howells return !cbi || cb_break != (vnode->cb_break + 83918ac6185SDavid Howells vnode->volume->cb_v_break); 84068251f0aSDavid Howells } 84168251f0aSDavid Howells 8421da177e4SLinus Torvalds /* 8431da177e4SLinus Torvalds * cell.c 8441da177e4SLinus Torvalds */ 845989782dcSDavid Howells extern int afs_cell_init(struct afs_net *, const char *); 846989782dcSDavid Howells extern struct afs_cell *afs_lookup_cell_rcu(struct afs_net *, const char *, unsigned); 847989782dcSDavid Howells extern struct afs_cell *afs_lookup_cell(struct afs_net *, const char *, unsigned, 848989782dcSDavid Howells const char *, bool); 8498b2a464cSDavid Howells extern struct afs_cell *afs_get_cell(struct afs_cell *); 8509ed900b1SDavid Howells extern void afs_put_cell(struct afs_net *, struct afs_cell *); 851989782dcSDavid Howells extern void afs_manage_cells(struct work_struct *); 852989782dcSDavid Howells extern void afs_cells_timer(struct timer_list *); 853f044c884SDavid Howells extern void __net_exit afs_cell_purge(struct afs_net *); 85408e0e7c8SDavid Howells 85508e0e7c8SDavid Howells /* 85608e0e7c8SDavid Howells * cmservice.c 85708e0e7c8SDavid Howells */ 85808e0e7c8SDavid Howells extern bool afs_cm_incoming_call(struct afs_call *); 85908e0e7c8SDavid Howells 8601da177e4SLinus Torvalds /* 8611da177e4SLinus Torvalds * dir.c 8621da177e4SLinus Torvalds */ 8634b6f5d20SArjan van de Ven extern const struct file_operations afs_dir_file_operations; 8644d673da1SDavid Howells extern const struct inode_operations afs_dir_inode_operations; 865f3ddee8dSDavid Howells extern const struct address_space_operations afs_dir_aops; 8664d673da1SDavid Howells extern const struct dentry_operations afs_fs_dentry_operations; 8674d673da1SDavid Howells 86866c7e1d3SDavid Howells extern void afs_d_release(struct dentry *); 86966c7e1d3SDavid Howells 87066c7e1d3SDavid Howells /* 87163a4681fSDavid Howells * dir_edit.c 87263a4681fSDavid Howells */ 87363a4681fSDavid Howells extern void afs_edit_dir_add(struct afs_vnode *, struct qstr *, struct afs_fid *, 87463a4681fSDavid Howells enum afs_edit_dir_reason); 87563a4681fSDavid Howells extern void afs_edit_dir_remove(struct afs_vnode *, struct qstr *, enum afs_edit_dir_reason); 87663a4681fSDavid Howells 87763a4681fSDavid Howells /* 87866c7e1d3SDavid Howells * dynroot.c 87966c7e1d3SDavid Howells */ 88066c7e1d3SDavid Howells extern const struct file_operations afs_dynroot_file_operations; 88166c7e1d3SDavid Howells extern const struct inode_operations afs_dynroot_inode_operations; 88266c7e1d3SDavid Howells extern const struct dentry_operations afs_dynroot_dentry_operations; 88366c7e1d3SDavid Howells 88466c7e1d3SDavid Howells extern struct inode *afs_try_auto_mntpt(struct dentry *, struct inode *); 8850da0b7fdSDavid Howells extern int afs_dynroot_mkdir(struct afs_net *, struct afs_cell *); 8860da0b7fdSDavid Howells extern void afs_dynroot_rmdir(struct afs_net *, struct afs_cell *); 8870da0b7fdSDavid Howells extern int afs_dynroot_populate(struct super_block *); 8880da0b7fdSDavid Howells extern void afs_dynroot_depopulate(struct super_block *); 8891da177e4SLinus Torvalds 8901da177e4SLinus Torvalds /* 8911da177e4SLinus Torvalds * file.c 8921da177e4SLinus Torvalds */ 893f5e54d6eSChristoph Hellwig extern const struct address_space_operations afs_fs_aops; 894754661f1SArjan van de Ven extern const struct inode_operations afs_file_inode_operations; 89500d3b7a4SDavid Howells extern const struct file_operations afs_file_operations; 89600d3b7a4SDavid Howells 8974343d008SDavid Howells extern int afs_cache_wb_key(struct afs_vnode *, struct afs_file *); 8984343d008SDavid Howells extern void afs_put_wb_key(struct afs_wb_key *); 89900d3b7a4SDavid Howells extern int afs_open(struct inode *, struct file *); 90000d3b7a4SDavid Howells extern int afs_release(struct inode *, struct file *); 901d2ddc776SDavid Howells extern int afs_fetch_data(struct afs_vnode *, struct key *, struct afs_read *); 902f6d335c0SAl Viro extern int afs_page_filler(void *, struct page *); 903196ee9cdSDavid Howells extern void afs_put_read(struct afs_read *); 9041da177e4SLinus Torvalds 9051da177e4SLinus Torvalds /* 906e8d6c554SDavid Howells * flock.c 907e8d6c554SDavid Howells */ 908f044c884SDavid Howells extern struct workqueue_struct *afs_lock_manager; 909f044c884SDavid Howells 910a690f60aSDavid Howells extern void afs_lock_op_done(struct afs_call *); 911e8d6c554SDavid Howells extern void afs_lock_work(struct work_struct *); 912e8d6c554SDavid Howells extern void afs_lock_may_be_available(struct afs_vnode *); 913e8d6c554SDavid Howells extern int afs_lock(struct file *, int, struct file_lock *); 914e8d6c554SDavid Howells extern int afs_flock(struct file *, int, struct file_lock *); 915e8d6c554SDavid Howells 916e8d6c554SDavid Howells /* 91708e0e7c8SDavid Howells * fsclient.c 91808e0e7c8SDavid Howells */ 919dd9fbcb8SDavid Howells #define AFS_VNODE_NOT_YET_SET 0x01 920dd9fbcb8SDavid Howells #define AFS_VNODE_META_CHANGED 0x02 921dd9fbcb8SDavid Howells #define AFS_VNODE_DATA_CHANGED 0x04 922dd9fbcb8SDavid Howells extern void afs_update_inode_from_status(struct afs_vnode *, struct afs_file_status *, 923dd9fbcb8SDavid Howells const afs_dataversion_t *, u8); 924dd9fbcb8SDavid Howells 9250c3a5ac2SDavid Howells extern int afs_fs_fetch_file_status(struct afs_fs_cursor *, struct afs_volsync *, bool); 926d2ddc776SDavid Howells extern int afs_fs_give_up_callbacks(struct afs_net *, struct afs_server *); 927d2ddc776SDavid Howells extern int afs_fs_fetch_data(struct afs_fs_cursor *, struct afs_read *); 92863a4681fSDavid Howells extern int afs_fs_create(struct afs_fs_cursor *, const char *, umode_t, u64, 929d2ddc776SDavid Howells struct afs_fid *, struct afs_file_status *, struct afs_callback *); 93030062bd1SDavid Howells extern int afs_fs_remove(struct afs_fs_cursor *, struct afs_vnode *, const char *, bool, u64); 93163a4681fSDavid Howells extern int afs_fs_link(struct afs_fs_cursor *, struct afs_vnode *, const char *, u64); 93263a4681fSDavid Howells extern int afs_fs_symlink(struct afs_fs_cursor *, const char *, const char *, u64, 933d2ddc776SDavid Howells struct afs_fid *, struct afs_file_status *); 934d2ddc776SDavid Howells extern int afs_fs_rename(struct afs_fs_cursor *, const char *, 93563a4681fSDavid Howells struct afs_vnode *, const char *, u64, u64); 9364343d008SDavid Howells extern int afs_fs_store_data(struct afs_fs_cursor *, struct address_space *, 937d2ddc776SDavid Howells pgoff_t, pgoff_t, unsigned, unsigned); 938d2ddc776SDavid Howells extern int afs_fs_setattr(struct afs_fs_cursor *, struct iattr *); 939d2ddc776SDavid Howells extern int afs_fs_get_volume_status(struct afs_fs_cursor *, struct afs_volume_status *); 940d2ddc776SDavid Howells extern int afs_fs_set_lock(struct afs_fs_cursor *, afs_lock_type_t); 941d2ddc776SDavid Howells extern int afs_fs_extend_lock(struct afs_fs_cursor *); 942d2ddc776SDavid Howells extern int afs_fs_release_lock(struct afs_fs_cursor *); 943d2ddc776SDavid Howells extern int afs_fs_give_up_all_callbacks(struct afs_net *, struct afs_server *, 944d2ddc776SDavid Howells struct afs_addr_cursor *, struct key *); 9450b9bf381SDavid Howells extern struct afs_call *afs_fs_get_capabilities(struct afs_net *, struct afs_server *, 9460b9bf381SDavid Howells struct afs_addr_cursor *, struct key *, 9470b9bf381SDavid Howells unsigned int); 9485cf9dd55SDavid Howells extern int afs_fs_inline_bulk_status(struct afs_fs_cursor *, struct afs_net *, 9495cf9dd55SDavid Howells struct afs_fid *, struct afs_file_status *, 9505cf9dd55SDavid Howells struct afs_callback *, unsigned int, 9515cf9dd55SDavid Howells struct afs_volsync *); 9525cf9dd55SDavid Howells extern int afs_fs_fetch_status(struct afs_fs_cursor *, struct afs_net *, 9535cf9dd55SDavid Howells struct afs_fid *, struct afs_file_status *, 9545cf9dd55SDavid Howells struct afs_callback *, struct afs_volsync *); 95508e0e7c8SDavid Howells 95608e0e7c8SDavid Howells /* 9573bf0fb6fSDavid Howells * fs_probe.c 9583bf0fb6fSDavid Howells */ 9593bf0fb6fSDavid Howells extern void afs_fileserver_probe_result(struct afs_call *); 9603bf0fb6fSDavid Howells extern int afs_probe_fileservers(struct afs_net *, struct key *, struct afs_server_list *); 9613bf0fb6fSDavid Howells extern int afs_wait_for_fs_probes(struct afs_server_list *, unsigned long); 9623bf0fb6fSDavid Howells 9633bf0fb6fSDavid Howells /* 9641da177e4SLinus Torvalds * inode.c 9651da177e4SLinus Torvalds */ 9660c3a5ac2SDavid Howells extern int afs_fetch_status(struct afs_vnode *, struct key *, bool); 967c435ee34SDavid Howells extern int afs_iget5_test(struct inode *, void *); 9684d673da1SDavid Howells extern struct inode *afs_iget_pseudo_dir(struct super_block *, bool); 96900d3b7a4SDavid Howells extern struct inode *afs_iget(struct super_block *, struct key *, 970260a9803SDavid Howells struct afs_fid *, struct afs_file_status *, 971d2ddc776SDavid Howells struct afs_callback *, 972d2ddc776SDavid Howells struct afs_cb_interest *); 973416351f2SDavid Howells extern void afs_zap_data(struct afs_vnode *); 974260a9803SDavid Howells extern int afs_validate(struct afs_vnode *, struct key *); 975a528d35eSDavid Howells extern int afs_getattr(const struct path *, struct kstat *, u32, unsigned int); 97631143d5dSDavid Howells extern int afs_setattr(struct dentry *, struct iattr *); 977b57922d9SAl Viro extern void afs_evict_inode(struct inode *); 978bec5eb61Swanglei extern int afs_drop_inode(struct inode *); 9791da177e4SLinus Torvalds 9801da177e4SLinus Torvalds /* 9811da177e4SLinus Torvalds * main.c 9821da177e4SLinus Torvalds */ 9830ad53eeeSTejun Heo extern struct workqueue_struct *afs_wq; 9845b86d4ffSDavid Howells extern int afs_net_id; 9855b86d4ffSDavid Howells 9865b86d4ffSDavid Howells static inline struct afs_net *afs_net(struct net *net) 9875b86d4ffSDavid Howells { 9885b86d4ffSDavid Howells return net_generic(net, afs_net_id); 9895b86d4ffSDavid Howells } 9905b86d4ffSDavid Howells 9915b86d4ffSDavid Howells static inline struct afs_net *afs_sb2net(struct super_block *sb) 9925b86d4ffSDavid Howells { 9935b86d4ffSDavid Howells return afs_net(AFS_FS_S(sb)->net_ns); 9945b86d4ffSDavid Howells } 995f044c884SDavid Howells 996f044c884SDavid Howells static inline struct afs_net *afs_d2net(struct dentry *dentry) 997f044c884SDavid Howells { 9985b86d4ffSDavid Howells return afs_sb2net(dentry->d_sb); 999f044c884SDavid Howells } 1000f044c884SDavid Howells 1001f044c884SDavid Howells static inline struct afs_net *afs_i2net(struct inode *inode) 1002f044c884SDavid Howells { 10035b86d4ffSDavid Howells return afs_sb2net(inode->i_sb); 1004f044c884SDavid Howells } 1005f044c884SDavid Howells 1006f044c884SDavid Howells static inline struct afs_net *afs_v2net(struct afs_vnode *vnode) 1007f044c884SDavid Howells { 10085b86d4ffSDavid Howells return afs_i2net(&vnode->vfs_inode); 1009f044c884SDavid Howells } 1010f044c884SDavid Howells 1011f044c884SDavid Howells static inline struct afs_net *afs_sock2net(struct sock *sk) 1012f044c884SDavid Howells { 10135b86d4ffSDavid Howells return net_generic(sock_net(sk), afs_net_id); 1014f044c884SDavid Howells } 10151da177e4SLinus Torvalds 1016d55b4da4SDavid Howells static inline void __afs_stat(atomic_t *s) 1017d55b4da4SDavid Howells { 1018d55b4da4SDavid Howells atomic_inc(s); 1019d55b4da4SDavid Howells } 1020d55b4da4SDavid Howells 1021d55b4da4SDavid Howells #define afs_stat_v(vnode, n) __afs_stat(&afs_v2net(vnode)->n) 1022d55b4da4SDavid Howells 10231da177e4SLinus Torvalds /* 102408e0e7c8SDavid Howells * misc.c 102508e0e7c8SDavid Howells */ 102608e0e7c8SDavid Howells extern int afs_abort_to_error(u32); 10274584ae96SDavid Howells extern void afs_prioritise_error(struct afs_error *, int, u32); 102808e0e7c8SDavid Howells 102908e0e7c8SDavid Howells /* 10301da177e4SLinus Torvalds * mntpt.c 10311da177e4SLinus Torvalds */ 1032754661f1SArjan van de Ven extern const struct inode_operations afs_mntpt_inode_operations; 1033bec5eb61Swanglei extern const struct inode_operations afs_autocell_inode_operations; 10344b6f5d20SArjan van de Ven extern const struct file_operations afs_mntpt_file_operations; 10351da177e4SLinus Torvalds 1036d18610b0SDavid Howells extern struct vfsmount *afs_d_automount(struct path *); 103708e0e7c8SDavid Howells extern void afs_mntpt_kill_timer(void); 10381da177e4SLinus Torvalds 10391da177e4SLinus Torvalds /* 1040b4db2b35SArnd Bergmann * netdevices.c 1041b4db2b35SArnd Bergmann */ 10425b86d4ffSDavid Howells extern int afs_get_ipv4_interfaces(struct afs_net *, struct afs_interface *, 10435b86d4ffSDavid Howells size_t, bool); 1044b4db2b35SArnd Bergmann 1045b4db2b35SArnd Bergmann /* 10461da177e4SLinus Torvalds * proc.c 10471da177e4SLinus Torvalds */ 1048b6cfbecaSDavid Howells #ifdef CONFIG_PROC_FS 1049f044c884SDavid Howells extern int __net_init afs_proc_init(struct afs_net *); 1050f044c884SDavid Howells extern void __net_exit afs_proc_cleanup(struct afs_net *); 10515b86d4ffSDavid Howells extern int afs_proc_cell_setup(struct afs_cell *); 10525b86d4ffSDavid Howells extern void afs_proc_cell_remove(struct afs_cell *); 10536f8880d8SDavid Howells extern void afs_put_sysnames(struct afs_sysnames *); 1054b6cfbecaSDavid Howells #else 1055b6cfbecaSDavid Howells static inline int afs_proc_init(struct afs_net *net) { return 0; } 1056b6cfbecaSDavid Howells static inline void afs_proc_cleanup(struct afs_net *net) {} 1057b6cfbecaSDavid Howells static inline int afs_proc_cell_setup(struct afs_cell *cell) { return 0; } 1058b6cfbecaSDavid Howells static inline void afs_proc_cell_remove(struct afs_cell *cell) {} 1059b6cfbecaSDavid Howells static inline void afs_put_sysnames(struct afs_sysnames *sysnames) {} 1060b6cfbecaSDavid Howells #endif 10611da177e4SLinus Torvalds 106208e0e7c8SDavid Howells /* 1063d2ddc776SDavid Howells * rotate.c 1064d2ddc776SDavid Howells */ 1065d2ddc776SDavid Howells extern bool afs_begin_vnode_operation(struct afs_fs_cursor *, struct afs_vnode *, 1066d2ddc776SDavid Howells struct key *); 1067d2ddc776SDavid Howells extern bool afs_select_fileserver(struct afs_fs_cursor *); 1068d2ddc776SDavid Howells extern bool afs_select_current_fileserver(struct afs_fs_cursor *); 1069d2ddc776SDavid Howells extern int afs_end_vnode_operation(struct afs_fs_cursor *); 1070d2ddc776SDavid Howells 1071d2ddc776SDavid Howells /* 107208e0e7c8SDavid Howells * rxrpc.c 107308e0e7c8SDavid Howells */ 1074f044c884SDavid Howells extern struct workqueue_struct *afs_async_calls; 10758324f0bcSDavid Howells 1076f044c884SDavid Howells extern int __net_init afs_open_socket(struct afs_net *); 1077f044c884SDavid Howells extern void __net_exit afs_close_socket(struct afs_net *); 1078f044c884SDavid Howells extern void afs_charge_preallocation(struct work_struct *); 1079341f741fSDavid Howells extern void afs_put_call(struct afs_call *); 10800b9bf381SDavid Howells extern void afs_make_call(struct afs_addr_cursor *, struct afs_call *, gfp_t); 10810b9bf381SDavid Howells extern long afs_wait_for_call_to_complete(struct afs_call *, struct afs_addr_cursor *); 1082f044c884SDavid Howells extern struct afs_call *afs_alloc_flat_call(struct afs_net *, 1083f044c884SDavid Howells const struct afs_call_type *, 108408e0e7c8SDavid Howells size_t, size_t); 108508e0e7c8SDavid Howells extern void afs_flat_call_destructor(struct afs_call *); 108608e0e7c8SDavid Howells extern void afs_send_empty_reply(struct afs_call *); 1087b908fe6bSDavid Howells extern void afs_send_simple_reply(struct afs_call *, const void *, size_t); 108812bdcf33SDavid Howells extern int afs_extract_data(struct afs_call *, bool); 1089160cb957SDavid Howells extern int afs_protocol_error(struct afs_call *, int, enum afs_eproto_cause); 109008e0e7c8SDavid Howells 109112bdcf33SDavid Howells static inline void afs_extract_begin(struct afs_call *call, void *buf, size_t size) 109212bdcf33SDavid Howells { 109312bdcf33SDavid Howells call->kvec[0].iov_base = buf; 109412bdcf33SDavid Howells call->kvec[0].iov_len = size; 109512bdcf33SDavid Howells iov_iter_kvec(&call->iter, READ, call->kvec, 1, size); 109612bdcf33SDavid Howells } 109712bdcf33SDavid Howells 109812bdcf33SDavid Howells static inline void afs_extract_to_tmp(struct afs_call *call) 109912bdcf33SDavid Howells { 110012bdcf33SDavid Howells afs_extract_begin(call, &call->tmp, sizeof(call->tmp)); 110112bdcf33SDavid Howells } 110212bdcf33SDavid Howells 110312bdcf33SDavid Howells static inline void afs_extract_to_tmp64(struct afs_call *call) 110412bdcf33SDavid Howells { 110512bdcf33SDavid Howells afs_extract_begin(call, &call->tmp64, sizeof(call->tmp64)); 110612bdcf33SDavid Howells } 110712bdcf33SDavid Howells 110812bdcf33SDavid Howells static inline void afs_extract_discard(struct afs_call *call, size_t size) 110912bdcf33SDavid Howells { 111012bdcf33SDavid Howells iov_iter_discard(&call->iter, READ, size); 111112bdcf33SDavid Howells } 111212bdcf33SDavid Howells 111312bdcf33SDavid Howells static inline void afs_extract_to_buf(struct afs_call *call, size_t size) 111412bdcf33SDavid Howells { 111512bdcf33SDavid Howells afs_extract_begin(call, call->buffer, size); 111612bdcf33SDavid Howells } 111712bdcf33SDavid Howells 1118d001648eSDavid Howells static inline int afs_transfer_reply(struct afs_call *call) 1119372ee163SDavid Howells { 112012bdcf33SDavid Howells return afs_extract_data(call, false); 1121372ee163SDavid Howells } 1122372ee163SDavid Howells 112398bf40cdSDavid Howells static inline bool afs_check_call_state(struct afs_call *call, 112498bf40cdSDavid Howells enum afs_call_state state) 112598bf40cdSDavid Howells { 112698bf40cdSDavid Howells return READ_ONCE(call->state) == state; 112798bf40cdSDavid Howells } 112898bf40cdSDavid Howells 112998bf40cdSDavid Howells static inline bool afs_set_call_state(struct afs_call *call, 113098bf40cdSDavid Howells enum afs_call_state from, 113198bf40cdSDavid Howells enum afs_call_state to) 113298bf40cdSDavid Howells { 113398bf40cdSDavid Howells bool ok = false; 113498bf40cdSDavid Howells 113598bf40cdSDavid Howells spin_lock_bh(&call->state_lock); 113698bf40cdSDavid Howells if (call->state == from) { 113798bf40cdSDavid Howells call->state = to; 113898bf40cdSDavid Howells trace_afs_call_state(call, from, to, 0, 0); 113998bf40cdSDavid Howells ok = true; 114098bf40cdSDavid Howells } 114198bf40cdSDavid Howells spin_unlock_bh(&call->state_lock); 114298bf40cdSDavid Howells return ok; 114398bf40cdSDavid Howells } 114498bf40cdSDavid Howells 114598bf40cdSDavid Howells static inline void afs_set_call_complete(struct afs_call *call, 114698bf40cdSDavid Howells int error, u32 remote_abort) 114798bf40cdSDavid Howells { 114898bf40cdSDavid Howells enum afs_call_state state; 114998bf40cdSDavid Howells bool ok = false; 115098bf40cdSDavid Howells 115198bf40cdSDavid Howells spin_lock_bh(&call->state_lock); 115298bf40cdSDavid Howells state = call->state; 115398bf40cdSDavid Howells if (state != AFS_CALL_COMPLETE) { 115498bf40cdSDavid Howells call->abort_code = remote_abort; 115598bf40cdSDavid Howells call->error = error; 115698bf40cdSDavid Howells call->state = AFS_CALL_COMPLETE; 115798bf40cdSDavid Howells trace_afs_call_state(call, state, AFS_CALL_COMPLETE, 115898bf40cdSDavid Howells error, remote_abort); 115998bf40cdSDavid Howells ok = true; 116098bf40cdSDavid Howells } 116198bf40cdSDavid Howells spin_unlock_bh(&call->state_lock); 116298bf40cdSDavid Howells if (ok) 116398bf40cdSDavid Howells trace_afs_call_done(call); 116498bf40cdSDavid Howells } 116598bf40cdSDavid Howells 116608e0e7c8SDavid Howells /* 116700d3b7a4SDavid Howells * security.c 116800d3b7a4SDavid Howells */ 1169be080a6fSDavid Howells extern void afs_put_permits(struct afs_permits *); 117000d3b7a4SDavid Howells extern void afs_clear_permits(struct afs_vnode *); 1171be080a6fSDavid Howells extern void afs_cache_permit(struct afs_vnode *, struct key *, unsigned int); 1172416351f2SDavid Howells extern void afs_zap_permits(struct rcu_head *); 117300d3b7a4SDavid Howells extern struct key *afs_request_key(struct afs_cell *); 11740fafdc9fSDavid Howells extern int afs_check_permit(struct afs_vnode *, struct key *, afs_access_t *); 117510556cb2SAl Viro extern int afs_permission(struct inode *, int); 1176be080a6fSDavid Howells extern void __exit afs_clean_up_permit_cache(void); 117700d3b7a4SDavid Howells 117800d3b7a4SDavid Howells /* 117908e0e7c8SDavid Howells * server.c 118008e0e7c8SDavid Howells */ 118108e0e7c8SDavid Howells extern spinlock_t afs_server_peer_lock; 118208e0e7c8SDavid Howells 1183c435ee34SDavid Howells static inline struct afs_server *afs_get_server(struct afs_server *server) 1184c435ee34SDavid Howells { 1185c435ee34SDavid Howells atomic_inc(&server->usage); 1186c435ee34SDavid Howells return server; 1187c435ee34SDavid Howells } 118808e0e7c8SDavid Howells 1189f044c884SDavid Howells extern struct afs_server *afs_find_server(struct afs_net *, 1190f044c884SDavid Howells const struct sockaddr_rxrpc *); 1191d2ddc776SDavid Howells extern struct afs_server *afs_find_server_by_uuid(struct afs_net *, const uuid_t *); 1192d2ddc776SDavid Howells extern struct afs_server *afs_lookup_server(struct afs_cell *, struct key *, const uuid_t *); 11939ed900b1SDavid Howells extern void afs_put_server(struct afs_net *, struct afs_server *); 1194d2ddc776SDavid Howells extern void afs_manage_servers(struct work_struct *); 1195d2ddc776SDavid Howells extern void afs_servers_timer(struct timer_list *); 1196f044c884SDavid Howells extern void __net_exit afs_purge_servers(struct afs_net *); 1197d2ddc776SDavid Howells extern bool afs_check_server_record(struct afs_fs_cursor *, struct afs_server *); 1198d2ddc776SDavid Howells 1199d2ddc776SDavid Howells /* 1200d2ddc776SDavid Howells * server_list.c 1201d2ddc776SDavid Howells */ 1202d2ddc776SDavid Howells static inline struct afs_server_list *afs_get_serverlist(struct afs_server_list *slist) 1203d2ddc776SDavid Howells { 1204d2ddc776SDavid Howells refcount_inc(&slist->usage); 1205d2ddc776SDavid Howells return slist; 1206d2ddc776SDavid Howells } 1207d2ddc776SDavid Howells 1208d2ddc776SDavid Howells extern void afs_put_serverlist(struct afs_net *, struct afs_server_list *); 1209d2ddc776SDavid Howells extern struct afs_server_list *afs_alloc_server_list(struct afs_cell *, struct key *, 1210d2ddc776SDavid Howells struct afs_vldb_entry *, 1211d2ddc776SDavid Howells u8); 1212d2ddc776SDavid Howells extern bool afs_annotate_server_list(struct afs_server_list *, struct afs_server_list *); 121308e0e7c8SDavid Howells 121408e0e7c8SDavid Howells /* 121500d3b7a4SDavid Howells * super.c 121600d3b7a4SDavid Howells */ 1217f044c884SDavid Howells extern int __init afs_fs_init(void); 12185b86d4ffSDavid Howells extern void afs_fs_exit(void); 121900d3b7a4SDavid Howells 122000d3b7a4SDavid Howells /* 122108e0e7c8SDavid Howells * vlclient.c 122208e0e7c8SDavid Howells */ 12230a5143f2SDavid Howells extern struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_vl_cursor *, 12240a5143f2SDavid Howells const char *, int); 12250a5143f2SDavid Howells extern struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *, const uuid_t *); 12260b9bf381SDavid Howells extern struct afs_call *afs_vl_get_capabilities(struct afs_net *, struct afs_addr_cursor *, 12270b9bf381SDavid Howells struct key *, struct afs_vlserver *, unsigned int); 12280a5143f2SDavid Howells extern struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *, const uuid_t *); 12290a5143f2SDavid Howells 12300a5143f2SDavid Howells /* 12313bf0fb6fSDavid Howells * vl_probe.c 12323bf0fb6fSDavid Howells */ 12333bf0fb6fSDavid Howells extern void afs_vlserver_probe_result(struct afs_call *); 12343bf0fb6fSDavid Howells extern int afs_send_vl_probes(struct afs_net *, struct key *, struct afs_vlserver_list *); 12353bf0fb6fSDavid Howells extern int afs_wait_for_vl_probes(struct afs_vlserver_list *, unsigned long); 12363bf0fb6fSDavid Howells 12373bf0fb6fSDavid Howells /* 12380a5143f2SDavid Howells * vl_rotate.c 12390a5143f2SDavid Howells */ 12400a5143f2SDavid Howells extern bool afs_begin_vlserver_operation(struct afs_vl_cursor *, 12410a5143f2SDavid Howells struct afs_cell *, struct key *); 12420a5143f2SDavid Howells extern bool afs_select_vlserver(struct afs_vl_cursor *); 12430a5143f2SDavid Howells extern bool afs_select_current_vlserver(struct afs_vl_cursor *); 12440a5143f2SDavid Howells extern int afs_end_vlserver_operation(struct afs_vl_cursor *); 12450a5143f2SDavid Howells 12460a5143f2SDavid Howells /* 12470a5143f2SDavid Howells * vlserver_list.c 12480a5143f2SDavid Howells */ 12490a5143f2SDavid Howells static inline struct afs_vlserver *afs_get_vlserver(struct afs_vlserver *vlserver) 12500a5143f2SDavid Howells { 12510a5143f2SDavid Howells atomic_inc(&vlserver->usage); 12520a5143f2SDavid Howells return vlserver; 12530a5143f2SDavid Howells } 12540a5143f2SDavid Howells 12550a5143f2SDavid Howells static inline struct afs_vlserver_list *afs_get_vlserverlist(struct afs_vlserver_list *vllist) 12560a5143f2SDavid Howells { 12570a5143f2SDavid Howells if (vllist) 12580a5143f2SDavid Howells atomic_inc(&vllist->usage); 12590a5143f2SDavid Howells return vllist; 12600a5143f2SDavid Howells } 12610a5143f2SDavid Howells 12620a5143f2SDavid Howells extern struct afs_vlserver *afs_alloc_vlserver(const char *, size_t, unsigned short); 12630a5143f2SDavid Howells extern void afs_put_vlserver(struct afs_net *, struct afs_vlserver *); 12640a5143f2SDavid Howells extern struct afs_vlserver_list *afs_alloc_vlserver_list(unsigned int); 12650a5143f2SDavid Howells extern void afs_put_vlserverlist(struct afs_net *, struct afs_vlserver_list *); 12660a5143f2SDavid Howells extern struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *, 12670a5143f2SDavid Howells const void *, size_t); 126808e0e7c8SDavid Howells 126908e0e7c8SDavid Howells /* 127008e0e7c8SDavid Howells * volume.c 127108e0e7c8SDavid Howells */ 1272d2ddc776SDavid Howells static inline struct afs_volume *__afs_get_volume(struct afs_volume *volume) 127349566f6fSDavid Howells { 127449566f6fSDavid Howells if (volume) 127549566f6fSDavid Howells atomic_inc(&volume->usage); 127649566f6fSDavid Howells return volume; 127749566f6fSDavid Howells } 127808e0e7c8SDavid Howells 127913fcc683SDavid Howells extern struct afs_volume *afs_create_volume(struct afs_fs_context *); 1280d2ddc776SDavid Howells extern void afs_activate_volume(struct afs_volume *); 1281d2ddc776SDavid Howells extern void afs_deactivate_volume(struct afs_volume *); 12829ed900b1SDavid Howells extern void afs_put_volume(struct afs_cell *, struct afs_volume *); 1283d2ddc776SDavid Howells extern int afs_check_volume_status(struct afs_volume *, struct key *); 128408e0e7c8SDavid Howells 128531143d5dSDavid Howells /* 128631143d5dSDavid Howells * write.c 128731143d5dSDavid Howells */ 128831143d5dSDavid Howells extern int afs_set_page_dirty(struct page *); 128915b4650eSNick Piggin extern int afs_write_begin(struct file *file, struct address_space *mapping, 129015b4650eSNick Piggin loff_t pos, unsigned len, unsigned flags, 129115b4650eSNick Piggin struct page **pagep, void **fsdata); 129215b4650eSNick Piggin extern int afs_write_end(struct file *file, struct address_space *mapping, 129315b4650eSNick Piggin loff_t pos, unsigned len, unsigned copied, 129415b4650eSNick Piggin struct page *page, void *fsdata); 129531143d5dSDavid Howells extern int afs_writepage(struct page *, struct writeback_control *); 129631143d5dSDavid Howells extern int afs_writepages(struct address_space *, struct writeback_control *); 129731143d5dSDavid Howells extern void afs_pages_written_back(struct afs_vnode *, struct afs_call *); 129850b5551dSAl Viro extern ssize_t afs_file_write(struct kiocb *, struct iov_iter *); 129902c24a82SJosef Bacik extern int afs_fsync(struct file *, loff_t, loff_t, int); 13000722f186SSouptick Joarder extern vm_fault_t afs_page_mkwrite(struct vm_fault *vmf); 13014343d008SDavid Howells extern void afs_prune_wb_keys(struct afs_vnode *); 13024343d008SDavid Howells extern int afs_launder_page(struct page *); 130331143d5dSDavid Howells 1304d3e3b7eaSDavid Howells /* 1305d3e3b7eaSDavid Howells * xattr.c 1306d3e3b7eaSDavid Howells */ 1307d3e3b7eaSDavid Howells extern const struct xattr_handler *afs_xattr_handlers[]; 1308d3e3b7eaSDavid Howells extern ssize_t afs_listxattr(struct dentry *, char *, size_t); 130931143d5dSDavid Howells 131030062bd1SDavid Howells /* 131130062bd1SDavid Howells * yfsclient.c 131230062bd1SDavid Howells */ 131330062bd1SDavid Howells extern int yfs_fs_fetch_file_status(struct afs_fs_cursor *, struct afs_volsync *, bool); 131430062bd1SDavid Howells extern int yfs_fs_fetch_data(struct afs_fs_cursor *, struct afs_read *); 131530062bd1SDavid Howells extern int yfs_fs_create_file(struct afs_fs_cursor *, const char *, umode_t, u64, 131630062bd1SDavid Howells struct afs_fid *, struct afs_file_status *, struct afs_callback *); 131730062bd1SDavid Howells extern int yfs_fs_make_dir(struct afs_fs_cursor *, const char *, umode_t, u64, 131830062bd1SDavid Howells struct afs_fid *, struct afs_file_status *, struct afs_callback *); 131930062bd1SDavid Howells extern int yfs_fs_remove_file2(struct afs_fs_cursor *, struct afs_vnode *, const char *, u64); 132030062bd1SDavid Howells extern int yfs_fs_remove(struct afs_fs_cursor *, struct afs_vnode *, const char *, bool, u64); 132130062bd1SDavid Howells extern int yfs_fs_link(struct afs_fs_cursor *, struct afs_vnode *, const char *, u64); 132230062bd1SDavid Howells extern int yfs_fs_symlink(struct afs_fs_cursor *, const char *, const char *, u64, 132330062bd1SDavid Howells struct afs_fid *, struct afs_file_status *); 132430062bd1SDavid Howells extern int yfs_fs_rename(struct afs_fs_cursor *, const char *, 132530062bd1SDavid Howells struct afs_vnode *, const char *, u64, u64); 132630062bd1SDavid Howells extern int yfs_fs_store_data(struct afs_fs_cursor *, struct address_space *, 132730062bd1SDavid Howells pgoff_t, pgoff_t, unsigned, unsigned); 132830062bd1SDavid Howells extern int yfs_fs_setattr(struct afs_fs_cursor *, struct iattr *); 132930062bd1SDavid Howells extern int yfs_fs_get_volume_status(struct afs_fs_cursor *, struct afs_volume_status *); 133030062bd1SDavid Howells extern int yfs_fs_set_lock(struct afs_fs_cursor *, afs_lock_type_t); 133130062bd1SDavid Howells extern int yfs_fs_extend_lock(struct afs_fs_cursor *); 133230062bd1SDavid Howells extern int yfs_fs_release_lock(struct afs_fs_cursor *); 133330062bd1SDavid Howells extern int yfs_fs_fetch_status(struct afs_fs_cursor *, struct afs_net *, 133430062bd1SDavid Howells struct afs_fid *, struct afs_file_status *, 133530062bd1SDavid Howells struct afs_callback *, struct afs_volsync *); 133630062bd1SDavid Howells extern int yfs_fs_inline_bulk_status(struct afs_fs_cursor *, struct afs_net *, 133730062bd1SDavid Howells struct afs_fid *, struct afs_file_status *, 133830062bd1SDavid Howells struct afs_callback *, unsigned int, 133930062bd1SDavid Howells struct afs_volsync *); 1340d2ddc776SDavid Howells 1341d2ddc776SDavid Howells /* 1342d2ddc776SDavid Howells * Miscellaneous inline functions. 1343d2ddc776SDavid Howells */ 1344d2ddc776SDavid Howells static inline struct afs_vnode *AFS_FS_I(struct inode *inode) 1345d2ddc776SDavid Howells { 1346d2ddc776SDavid Howells return container_of(inode, struct afs_vnode, vfs_inode); 1347d2ddc776SDavid Howells } 1348d2ddc776SDavid Howells 1349d2ddc776SDavid Howells static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode) 1350d2ddc776SDavid Howells { 1351d2ddc776SDavid Howells return &vnode->vfs_inode; 1352d2ddc776SDavid Howells } 1353d2ddc776SDavid Howells 1354d2ddc776SDavid Howells static inline void afs_vnode_commit_status(struct afs_fs_cursor *fc, 1355d2ddc776SDavid Howells struct afs_vnode *vnode, 1356d2ddc776SDavid Howells unsigned int cb_break) 1357d2ddc776SDavid Howells { 1358d2ddc776SDavid Howells if (fc->ac.error == 0) 1359d2ddc776SDavid Howells afs_cache_permit(vnode, fc->key, cb_break); 1360d2ddc776SDavid Howells } 1361d2ddc776SDavid Howells 1362d2ddc776SDavid Howells static inline void afs_check_for_remote_deletion(struct afs_fs_cursor *fc, 1363d2ddc776SDavid Howells struct afs_vnode *vnode) 1364d2ddc776SDavid Howells { 1365d2ddc776SDavid Howells if (fc->ac.error == -ENOENT) { 1366d2ddc776SDavid Howells set_bit(AFS_VNODE_DELETED, &vnode->flags); 1367d2ddc776SDavid Howells afs_break_callback(vnode); 1368d2ddc776SDavid Howells } 1369d2ddc776SDavid Howells } 1370d2ddc776SDavid Howells 1371f51375cdSDavid Howells static inline int afs_io_error(struct afs_call *call, enum afs_io_error where) 1372f51375cdSDavid Howells { 1373f51375cdSDavid Howells trace_afs_io_error(call->debug_id, -EIO, where); 1374f51375cdSDavid Howells return -EIO; 1375f51375cdSDavid Howells } 1376f51375cdSDavid Howells 1377f51375cdSDavid Howells static inline int afs_bad(struct afs_vnode *vnode, enum afs_file_error where) 1378f51375cdSDavid Howells { 1379f51375cdSDavid Howells trace_afs_file_error(vnode, -EIO, where); 1380f51375cdSDavid Howells return -EIO; 1381f51375cdSDavid Howells } 1382d2ddc776SDavid Howells 138308e0e7c8SDavid Howells /*****************************************************************************/ 138408e0e7c8SDavid Howells /* 138508e0e7c8SDavid Howells * debug tracing 138608e0e7c8SDavid Howells */ 138708e0e7c8SDavid Howells extern unsigned afs_debug; 138808e0e7c8SDavid Howells 138908e0e7c8SDavid Howells #define dbgprintk(FMT,...) \ 1390ad16df84SSven Schnelle printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__) 139108e0e7c8SDavid Howells 1392530b6412SHarvey Harrison #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__) 1393530b6412SHarvey Harrison #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) 139408e0e7c8SDavid Howells #define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__) 139508e0e7c8SDavid Howells 139608e0e7c8SDavid Howells 139708e0e7c8SDavid Howells #if defined(__KDEBUG) 139808e0e7c8SDavid Howells #define _enter(FMT,...) kenter(FMT,##__VA_ARGS__) 139908e0e7c8SDavid Howells #define _leave(FMT,...) kleave(FMT,##__VA_ARGS__) 140008e0e7c8SDavid Howells #define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__) 140108e0e7c8SDavid Howells 140208e0e7c8SDavid Howells #elif defined(CONFIG_AFS_DEBUG) 140308e0e7c8SDavid Howells #define AFS_DEBUG_KENTER 0x01 140408e0e7c8SDavid Howells #define AFS_DEBUG_KLEAVE 0x02 140508e0e7c8SDavid Howells #define AFS_DEBUG_KDEBUG 0x04 140608e0e7c8SDavid Howells 140708e0e7c8SDavid Howells #define _enter(FMT,...) \ 140808e0e7c8SDavid Howells do { \ 140908e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \ 141008e0e7c8SDavid Howells kenter(FMT,##__VA_ARGS__); \ 141108e0e7c8SDavid Howells } while (0) 141208e0e7c8SDavid Howells 141308e0e7c8SDavid Howells #define _leave(FMT,...) \ 141408e0e7c8SDavid Howells do { \ 141508e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \ 141608e0e7c8SDavid Howells kleave(FMT,##__VA_ARGS__); \ 141708e0e7c8SDavid Howells } while (0) 141808e0e7c8SDavid Howells 141908e0e7c8SDavid Howells #define _debug(FMT,...) \ 142008e0e7c8SDavid Howells do { \ 142108e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \ 142208e0e7c8SDavid Howells kdebug(FMT,##__VA_ARGS__); \ 142308e0e7c8SDavid Howells } while (0) 142408e0e7c8SDavid Howells 142508e0e7c8SDavid Howells #else 142612fdff3fSDavid Howells #define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__) 142712fdff3fSDavid Howells #define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) 142812fdff3fSDavid Howells #define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__) 142908e0e7c8SDavid Howells #endif 143008e0e7c8SDavid Howells 143108e0e7c8SDavid Howells /* 143208e0e7c8SDavid Howells * debug assertion checking 143308e0e7c8SDavid Howells */ 143408e0e7c8SDavid Howells #if 1 // defined(__KDEBUGALL) 143508e0e7c8SDavid Howells 143608e0e7c8SDavid Howells #define ASSERT(X) \ 143708e0e7c8SDavid Howells do { \ 143808e0e7c8SDavid Howells if (unlikely(!(X))) { \ 143908e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 144008e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 144108e0e7c8SDavid Howells BUG(); \ 144208e0e7c8SDavid Howells } \ 144308e0e7c8SDavid Howells } while(0) 144408e0e7c8SDavid Howells 144508e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y) \ 144608e0e7c8SDavid Howells do { \ 144708e0e7c8SDavid Howells if (unlikely(!((X) OP (Y)))) { \ 144808e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 144908e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 145008e0e7c8SDavid Howells printk(KERN_ERR "%lu " #OP " %lu is false\n", \ 145108e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 145208e0e7c8SDavid Howells printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ 145308e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 145408e0e7c8SDavid Howells BUG(); \ 145508e0e7c8SDavid Howells } \ 145608e0e7c8SDavid Howells } while(0) 145708e0e7c8SDavid Howells 1458416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H) \ 1459416351f2SDavid Howells do { \ 1460416351f2SDavid Howells if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) { \ 1461416351f2SDavid Howells printk(KERN_ERR "\n"); \ 1462416351f2SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 1463416351f2SDavid Howells printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n", \ 1464416351f2SDavid Howells (unsigned long)(L), (unsigned long)(N), \ 1465416351f2SDavid Howells (unsigned long)(H)); \ 1466416351f2SDavid Howells printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \ 1467416351f2SDavid Howells (unsigned long)(L), (unsigned long)(N), \ 1468416351f2SDavid Howells (unsigned long)(H)); \ 1469416351f2SDavid Howells BUG(); \ 1470416351f2SDavid Howells } \ 1471416351f2SDavid Howells } while(0) 1472416351f2SDavid Howells 147308e0e7c8SDavid Howells #define ASSERTIF(C, X) \ 147408e0e7c8SDavid Howells do { \ 147508e0e7c8SDavid Howells if (unlikely((C) && !(X))) { \ 147608e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 147708e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 147808e0e7c8SDavid Howells BUG(); \ 147908e0e7c8SDavid Howells } \ 148008e0e7c8SDavid Howells } while(0) 148108e0e7c8SDavid Howells 148208e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y) \ 148308e0e7c8SDavid Howells do { \ 148408e0e7c8SDavid Howells if (unlikely((C) && !((X) OP (Y)))) { \ 148508e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 148608e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 148708e0e7c8SDavid Howells printk(KERN_ERR "%lu " #OP " %lu is false\n", \ 148808e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 148908e0e7c8SDavid Howells printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ 149008e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 149108e0e7c8SDavid Howells BUG(); \ 149208e0e7c8SDavid Howells } \ 149308e0e7c8SDavid Howells } while(0) 149408e0e7c8SDavid Howells 149508e0e7c8SDavid Howells #else 149608e0e7c8SDavid Howells 149708e0e7c8SDavid Howells #define ASSERT(X) \ 149808e0e7c8SDavid Howells do { \ 149908e0e7c8SDavid Howells } while(0) 150008e0e7c8SDavid Howells 150108e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y) \ 150208e0e7c8SDavid Howells do { \ 150308e0e7c8SDavid Howells } while(0) 150408e0e7c8SDavid Howells 1505416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H) \ 1506416351f2SDavid Howells do { \ 1507416351f2SDavid Howells } while(0) 1508416351f2SDavid Howells 150908e0e7c8SDavid Howells #define ASSERTIF(C, X) \ 151008e0e7c8SDavid Howells do { \ 151108e0e7c8SDavid Howells } while(0) 151208e0e7c8SDavid Howells 151308e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y) \ 151408e0e7c8SDavid Howells do { \ 151508e0e7c8SDavid Howells } while(0) 151608e0e7c8SDavid Howells 151708e0e7c8SDavid Howells #endif /* __KDEBUGALL */ 1518