1ec26815aSDavid Howells /* internal AFS stuff 21da177e4SLinus Torvalds * 308e0e7c8SDavid Howells * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved. 41da177e4SLinus Torvalds * Written by David Howells (dhowells@redhat.com) 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or 71da177e4SLinus Torvalds * modify it under the terms of the GNU General Public License 81da177e4SLinus Torvalds * as published by the Free Software Foundation; either version 91da177e4SLinus Torvalds * 2 of the License, or (at your option) any later version. 101da177e4SLinus Torvalds */ 111da177e4SLinus Torvalds 121da177e4SLinus Torvalds #include <linux/compiler.h> 131da177e4SLinus Torvalds #include <linux/kernel.h> 148a79790bSTina Ruchandani #include <linux/ktime.h> 151da177e4SLinus Torvalds #include <linux/fs.h> 161da177e4SLinus Torvalds #include <linux/pagemap.h> 1708e0e7c8SDavid Howells #include <linux/rxrpc.h> 1800d3b7a4SDavid Howells #include <linux/key.h> 19e8edc6e0SAlexey Dobriyan #include <linux/workqueue.h> 2000c541eaSAndrew Morton #include <linux/sched.h> 2180e50be4SChristoph Hellwig #include <linux/fscache.h> 22e1da0222SJens Axboe #include <linux/backing-dev.h> 23ff548773SDavid Howells #include <linux/uuid.h> 24f044c884SDavid Howells #include <net/net_namespace.h> 258324f0bcSDavid Howells #include <net/af_rxrpc.h> 2600c541eaSAndrew Morton 2708e0e7c8SDavid Howells #include "afs.h" 2808e0e7c8SDavid Howells #include "afs_vl.h" 2908e0e7c8SDavid Howells 3008e0e7c8SDavid Howells #define AFS_CELL_MAX_ADDRS 15 3108e0e7c8SDavid Howells 3231143d5dSDavid Howells struct pagevec; 3308e0e7c8SDavid Howells struct afs_call; 3408e0e7c8SDavid Howells 3500d3b7a4SDavid Howells struct afs_mount_params { 3600d3b7a4SDavid Howells bool rwpath; /* T if the parent should be considered R/W */ 3700d3b7a4SDavid Howells bool force; /* T to force cell type */ 38bec5eb61Swanglei bool autocell; /* T if set auto mount operation */ 394d673da1SDavid Howells bool dyn_root; /* T if dynamic root */ 4000d3b7a4SDavid Howells afs_voltype_t type; /* type of volume requested */ 4100d3b7a4SDavid Howells int volnamesz; /* size of volume name */ 4200d3b7a4SDavid Howells const char *volname; /* name of volume to mount */ 43f044c884SDavid Howells struct afs_net *net; /* Network namespace in effect */ 4400d3b7a4SDavid Howells struct afs_cell *cell; /* cell in which to find volume */ 4500d3b7a4SDavid Howells struct afs_volume *volume; /* volume record */ 4600d3b7a4SDavid Howells struct key *key; /* key to use for secure mounting */ 4700d3b7a4SDavid Howells }; 4800d3b7a4SDavid Howells 49c435ee34SDavid Howells struct afs_iget_data { 50c435ee34SDavid Howells struct afs_fid fid; 51c435ee34SDavid Howells struct afs_volume *volume; /* volume on which resides */ 52c435ee34SDavid Howells }; 53c435ee34SDavid Howells 548e8d7f13SDavid Howells enum afs_call_state { 5598bf40cdSDavid Howells AFS_CALL_CL_REQUESTING, /* Client: Request is being sent */ 5698bf40cdSDavid Howells AFS_CALL_CL_AWAIT_REPLY, /* Client: Awaiting reply */ 5798bf40cdSDavid Howells AFS_CALL_CL_PROC_REPLY, /* Client: rxrpc call complete; processing reply */ 5898bf40cdSDavid Howells AFS_CALL_SV_AWAIT_OP_ID, /* Server: Awaiting op ID */ 5998bf40cdSDavid Howells AFS_CALL_SV_AWAIT_REQUEST, /* Server: Awaiting request data */ 6098bf40cdSDavid Howells AFS_CALL_SV_REPLYING, /* Server: Replying */ 6198bf40cdSDavid Howells AFS_CALL_SV_AWAIT_ACK, /* Server: Awaiting final ACK */ 628e8d7f13SDavid Howells AFS_CALL_COMPLETE, /* Completed or failed */ 638e8d7f13SDavid Howells }; 64f044c884SDavid Howells 6508e0e7c8SDavid Howells /* 668b2a464cSDavid Howells * List of server addresses. 678b2a464cSDavid Howells */ 688b2a464cSDavid Howells struct afs_addr_list { 698b2a464cSDavid Howells struct rcu_head rcu; /* Must be first */ 708b2a464cSDavid Howells refcount_t usage; 71d2ddc776SDavid Howells u32 version; /* Version */ 728b2a464cSDavid Howells unsigned short nr_addrs; 738b2a464cSDavid Howells unsigned short index; /* Address currently in use */ 74d2ddc776SDavid Howells unsigned short nr_ipv4; /* Number of IPv4 addresses */ 75bf99a53cSDavid Howells unsigned long probed; /* Mask of servers that have been probed */ 76bf99a53cSDavid Howells unsigned long yfs; /* Mask of servers that are YFS */ 778b2a464cSDavid Howells struct sockaddr_rxrpc addrs[]; 788b2a464cSDavid Howells }; 798b2a464cSDavid Howells 808b2a464cSDavid Howells /* 8108e0e7c8SDavid Howells * a record of an in-progress RxRPC call 8208e0e7c8SDavid Howells */ 8308e0e7c8SDavid Howells struct afs_call { 8408e0e7c8SDavid Howells const struct afs_call_type *type; /* type of call */ 8508e0e7c8SDavid Howells wait_queue_head_t waitq; /* processes awaiting completion */ 86341f741fSDavid Howells struct work_struct async_work; /* async I/O processor */ 8708e0e7c8SDavid Howells struct work_struct work; /* actual work processor */ 8808e0e7c8SDavid Howells struct rxrpc_call *rxcall; /* RxRPC call handle */ 8908e0e7c8SDavid Howells struct key *key; /* security for this call */ 90f044c884SDavid Howells struct afs_net *net; /* The network namespace */ 91d0676a16SDavid Howells struct afs_server *cm_server; /* Server affected by incoming CM call */ 92d2ddc776SDavid Howells struct afs_cb_interest *cbi; /* Callback interest for server used */ 9308e0e7c8SDavid Howells void *request; /* request data (first part) */ 944343d008SDavid Howells struct address_space *mapping; /* Pages being written from */ 9508e0e7c8SDavid Howells void *buffer; /* reply receive buffer */ 9697e3043aSDavid Howells void *reply[4]; /* Where to put the reply */ 9731143d5dSDavid Howells pgoff_t first; /* first page in mapping to deal with */ 9831143d5dSDavid Howells pgoff_t last; /* last page in mapping to deal with */ 99d001648eSDavid Howells size_t offset; /* offset into received data store */ 100341f741fSDavid Howells atomic_t usage; 1018e8d7f13SDavid Howells enum afs_call_state state; 10298bf40cdSDavid Howells spinlock_t state_lock; 10308e0e7c8SDavid Howells int error; /* error code */ 104d001648eSDavid Howells u32 abort_code; /* Remote abort ID or 0 */ 10508e0e7c8SDavid Howells unsigned request_size; /* size of request data */ 10608e0e7c8SDavid Howells unsigned reply_max; /* maximum size of reply */ 10731143d5dSDavid Howells unsigned first_offset; /* offset into mapping[first] */ 108c435ee34SDavid Howells unsigned int cb_break; /* cb_break + cb_s_break before the call */ 109bcd89270SMarc Dionne union { 11031143d5dSDavid Howells unsigned last_to; /* amount of mapping[last] */ 111bcd89270SMarc Dionne unsigned count2; /* count used in unmarshalling */ 112bcd89270SMarc Dionne }; 11308e0e7c8SDavid Howells unsigned char unmarshall; /* unmarshalling phase */ 11408e0e7c8SDavid Howells bool incoming; /* T if incoming call */ 11531143d5dSDavid Howells bool send_pages; /* T if data from mapping should be sent */ 116d001648eSDavid Howells bool need_attention; /* T if RxRPC poked us */ 11756ff9c83SDavid Howells bool async; /* T if asynchronous */ 11833cd7f2bSDavid Howells bool ret_reply0; /* T if should return reply[0] on success */ 119a68f4a27SDavid Howells bool upgrade; /* T to request service upgrade */ 120bf99a53cSDavid Howells u16 service_id; /* Actual service ID (after upgrade) */ 121a25e21f0SDavid Howells unsigned int debug_id; /* Trace ID */ 12250a2c953SDavid Howells u32 operation_ID; /* operation ID for an incoming call */ 12308e0e7c8SDavid Howells u32 count; /* count for use in unmarshalling */ 12408e0e7c8SDavid Howells __be32 tmp; /* place to extract temporary data */ 1250c3a5ac2SDavid Howells afs_dataversion_t expected_version; /* Updated version expected from store */ 1260c3a5ac2SDavid Howells afs_dataversion_t expected_version_2; /* 2nd updated version expected from store */ 12708e0e7c8SDavid Howells }; 12808e0e7c8SDavid Howells 12908e0e7c8SDavid Howells struct afs_call_type { 13000d3b7a4SDavid Howells const char *name; 131025db80cSDavid Howells unsigned int op; /* Really enum afs_fs_operation */ 13200d3b7a4SDavid Howells 13308e0e7c8SDavid Howells /* deliver request or reply data to an call 13408e0e7c8SDavid Howells * - returning an error will cause the call to be aborted 13508e0e7c8SDavid Howells */ 136d001648eSDavid Howells int (*deliver)(struct afs_call *call); 13708e0e7c8SDavid Howells 13808e0e7c8SDavid Howells /* clean up a call */ 13908e0e7c8SDavid Howells void (*destructor)(struct afs_call *call); 140341f741fSDavid Howells 141341f741fSDavid Howells /* Work function */ 142341f741fSDavid Howells void (*work)(struct work_struct *work); 14308e0e7c8SDavid Howells }; 14408e0e7c8SDavid Howells 14508e0e7c8SDavid Howells /* 1464343d008SDavid Howells * Key available for writeback on a file. 1474343d008SDavid Howells */ 1484343d008SDavid Howells struct afs_wb_key { 1494343d008SDavid Howells refcount_t usage; 1504343d008SDavid Howells struct key *key; 1514343d008SDavid Howells struct list_head vnode_link; /* Link in vnode->wb_keys */ 1524343d008SDavid Howells }; 1534343d008SDavid Howells 1544343d008SDavid Howells /* 155215804a9SDavid Howells * AFS open file information record. Pointed to by file->private_data. 156215804a9SDavid Howells */ 157215804a9SDavid Howells struct afs_file { 158215804a9SDavid Howells struct key *key; /* The key this file was opened with */ 1594343d008SDavid Howells struct afs_wb_key *wb; /* Writeback key record for this file */ 160215804a9SDavid Howells }; 161215804a9SDavid Howells 162215804a9SDavid Howells static inline struct key *afs_file_key(struct file *file) 163215804a9SDavid Howells { 164215804a9SDavid Howells struct afs_file *af = file->private_data; 165215804a9SDavid Howells 166215804a9SDavid Howells return af->key; 167215804a9SDavid Howells } 168215804a9SDavid Howells 169215804a9SDavid Howells /* 170196ee9cdSDavid Howells * Record of an outstanding read operation on a vnode. 171196ee9cdSDavid Howells */ 172196ee9cdSDavid Howells struct afs_read { 173196ee9cdSDavid Howells loff_t pos; /* Where to start reading */ 174e8e581a8SDavid Howells loff_t len; /* How much we're asking for */ 175196ee9cdSDavid Howells loff_t actual_len; /* How much we're actually getting */ 1766a0e3999SDavid Howells loff_t remain; /* Amount remaining */ 177f3ddee8dSDavid Howells loff_t file_size; /* File size returned by server */ 178f3ddee8dSDavid Howells afs_dataversion_t data_version; /* Version number returned by server */ 179f3ddee8dSDavid Howells refcount_t usage; 180196ee9cdSDavid Howells unsigned int index; /* Which page we're reading into */ 181196ee9cdSDavid Howells unsigned int nr_pages; 182196ee9cdSDavid Howells void (*page_done)(struct afs_call *, struct afs_read *); 183f3ddee8dSDavid Howells struct page **pages; 184f3ddee8dSDavid Howells struct page *array[]; 185196ee9cdSDavid Howells }; 186196ee9cdSDavid Howells 187196ee9cdSDavid Howells /* 18808e0e7c8SDavid Howells * AFS superblock private data 18908e0e7c8SDavid Howells * - there's one superblock per volume 19008e0e7c8SDavid Howells */ 19108e0e7c8SDavid Howells struct afs_super_info { 192f044c884SDavid Howells struct afs_net *net; /* Network namespace */ 19349566f6fSDavid Howells struct afs_cell *cell; /* The cell in which the volume resides */ 19408e0e7c8SDavid Howells struct afs_volume *volume; /* volume record */ 1954d673da1SDavid Howells bool dyn_root; /* True if dynamic root */ 19608e0e7c8SDavid Howells }; 19708e0e7c8SDavid Howells 19808e0e7c8SDavid Howells static inline struct afs_super_info *AFS_FS_S(struct super_block *sb) 19908e0e7c8SDavid Howells { 20008e0e7c8SDavid Howells return sb->s_fs_info; 20108e0e7c8SDavid Howells } 20208e0e7c8SDavid Howells 20308e0e7c8SDavid Howells extern struct file_system_type afs_fs_type; 20408e0e7c8SDavid Howells 20508e0e7c8SDavid Howells /* 2066f8880d8SDavid Howells * Set of substitutes for @sys. 2076f8880d8SDavid Howells */ 2086f8880d8SDavid Howells struct afs_sysnames { 2096f8880d8SDavid Howells #define AFS_NR_SYSNAME 16 2106f8880d8SDavid Howells char *subs[AFS_NR_SYSNAME]; 2116f8880d8SDavid Howells refcount_t usage; 2126f8880d8SDavid Howells unsigned short nr; 2136f8880d8SDavid Howells short error; 2146f8880d8SDavid Howells char blank[1]; 2156f8880d8SDavid Howells }; 2166f8880d8SDavid Howells 2176f8880d8SDavid Howells /* 218f044c884SDavid Howells * AFS network namespace record. 219f044c884SDavid Howells */ 220f044c884SDavid Howells struct afs_net { 221f044c884SDavid Howells struct afs_uuid uuid; 222f044c884SDavid Howells bool live; /* F if this namespace is being removed */ 223f044c884SDavid Howells 224f044c884SDavid Howells /* AF_RXRPC I/O stuff */ 225f044c884SDavid Howells struct socket *socket; 226f044c884SDavid Howells struct afs_call *spare_incoming_call; 227f044c884SDavid Howells struct work_struct charge_preallocation_work; 228f044c884SDavid Howells struct mutex socket_mutex; 229f044c884SDavid Howells atomic_t nr_outstanding_calls; 230f044c884SDavid Howells atomic_t nr_superblocks; 231f044c884SDavid Howells 232f044c884SDavid Howells /* Cell database */ 233989782dcSDavid Howells struct rb_root cells; 234f044c884SDavid Howells struct afs_cell *ws_cell; 235989782dcSDavid Howells struct work_struct cells_manager; 236989782dcSDavid Howells struct timer_list cells_timer; 237989782dcSDavid Howells atomic_t cells_outstanding; 238989782dcSDavid Howells seqlock_t cells_lock; 239f044c884SDavid Howells 240989782dcSDavid Howells spinlock_t proc_cells_lock; 241f044c884SDavid Howells struct list_head proc_cells; 242f044c884SDavid Howells 243d2ddc776SDavid Howells /* Known servers. Theoretically each fileserver can only be in one 244d2ddc776SDavid Howells * cell, but in practice, people create aliases and subsets and there's 245d2ddc776SDavid Howells * no easy way to distinguish them. 246d2ddc776SDavid Howells */ 247d2ddc776SDavid Howells seqlock_t fs_lock; /* For fs_servers */ 248d2ddc776SDavid Howells struct rb_root fs_servers; /* afs_server (by server UUID or address) */ 249d2ddc776SDavid Howells struct list_head fs_updates; /* afs_server (by update_at) */ 250d2ddc776SDavid Howells struct hlist_head fs_proc; /* procfs servers list */ 251d2ddc776SDavid Howells 252d2ddc776SDavid Howells struct hlist_head fs_addresses4; /* afs_server (by lowest IPv4 addr) */ 253d2ddc776SDavid Howells struct hlist_head fs_addresses6; /* afs_server (by lowest IPv6 addr) */ 254d2ddc776SDavid Howells seqlock_t fs_addr_lock; /* For fs_addresses[46] */ 255d2ddc776SDavid Howells 256d2ddc776SDavid Howells struct work_struct fs_manager; 257d2ddc776SDavid Howells struct timer_list fs_timer; 258d2ddc776SDavid Howells atomic_t servers_outstanding; 259f044c884SDavid Howells 260f044c884SDavid Howells /* File locking renewal management */ 261f044c884SDavid Howells struct mutex lock_manager_mutex; 262f044c884SDavid Howells 263f044c884SDavid Howells /* Misc */ 264f044c884SDavid Howells struct proc_dir_entry *proc_afs; /* /proc/net/afs directory */ 2656f8880d8SDavid Howells struct afs_sysnames *sysnames; 2666f8880d8SDavid Howells rwlock_t sysnames_lock; 267d55b4da4SDavid Howells 268d55b4da4SDavid Howells /* Statistics counters */ 269d55b4da4SDavid Howells atomic_t n_lookup; /* Number of lookups done */ 270d55b4da4SDavid Howells atomic_t n_reval; /* Number of dentries needing revalidation */ 271d55b4da4SDavid Howells atomic_t n_inval; /* Number of invalidations by the server */ 272f3ddee8dSDavid Howells atomic_t n_relpg; /* Number of invalidations by releasepage */ 273d55b4da4SDavid Howells atomic_t n_read_dir; /* Number of directory pages read */ 27463a4681fSDavid Howells atomic_t n_dir_cr; /* Number of directory entry creation edits */ 27563a4681fSDavid Howells atomic_t n_dir_rm; /* Number of directory entry removal edits */ 276f044c884SDavid Howells }; 277f044c884SDavid Howells 2786f8880d8SDavid Howells extern const char afs_init_sysname[]; 279f044c884SDavid Howells extern struct afs_net __afs_net;// Dummy AFS network namespace; TODO: replace with real netns 280f044c884SDavid Howells 281989782dcSDavid Howells enum afs_cell_state { 282989782dcSDavid Howells AFS_CELL_UNSET, 283989782dcSDavid Howells AFS_CELL_ACTIVATING, 284989782dcSDavid Howells AFS_CELL_ACTIVE, 285989782dcSDavid Howells AFS_CELL_DEACTIVATING, 286989782dcSDavid Howells AFS_CELL_INACTIVE, 287989782dcSDavid Howells AFS_CELL_FAILED, 288989782dcSDavid Howells }; 289989782dcSDavid Howells 290f044c884SDavid Howells /* 291d2ddc776SDavid Howells * AFS cell record. 292d2ddc776SDavid Howells * 293d2ddc776SDavid Howells * This is a tricky concept to get right as it is possible to create aliases 294d2ddc776SDavid Howells * simply by pointing AFSDB/SRV records for two names at the same set of VL 295d2ddc776SDavid Howells * servers; it is also possible to do things like setting up two sets of VL 296d2ddc776SDavid Howells * servers, one of which provides a superset of the volumes provided by the 297d2ddc776SDavid Howells * other (for internal/external division, for example). 298d2ddc776SDavid Howells * 299d2ddc776SDavid Howells * Cells only exist in the sense that (a) a cell's name maps to a set of VL 300d2ddc776SDavid Howells * servers and (b) a cell's name is used by the client to select the key to use 301d2ddc776SDavid Howells * for authentication and encryption. The cell name is not typically used in 302d2ddc776SDavid Howells * the protocol. 303d2ddc776SDavid Howells * 304d2ddc776SDavid Howells * There is no easy way to determine if two cells are aliases or one is a 305d2ddc776SDavid Howells * subset of another. 30608e0e7c8SDavid Howells */ 30708e0e7c8SDavid Howells struct afs_cell { 308989782dcSDavid Howells union { 309989782dcSDavid Howells struct rcu_head rcu; 310989782dcSDavid Howells struct rb_node net_node; /* Node in net->cells */ 311989782dcSDavid Howells }; 312989782dcSDavid Howells struct afs_net *net; 31300d3b7a4SDavid Howells struct key *anonymous_key; /* anonymous user key for this cell */ 314989782dcSDavid Howells struct work_struct manager; /* Manager for init/deinit/dns */ 31508e0e7c8SDavid Howells struct list_head proc_link; /* /proc cell list link */ 3169b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 3179b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 3181da177e4SLinus Torvalds #endif 319989782dcSDavid Howells time64_t dns_expiry; /* Time AFSDB/SRV record expires */ 320989782dcSDavid Howells time64_t last_inactive; /* Time of last drop of usage count */ 321989782dcSDavid Howells atomic_t usage; 322989782dcSDavid Howells unsigned long flags; 323989782dcSDavid Howells #define AFS_CELL_FL_NOT_READY 0 /* The cell record is not ready for use */ 324989782dcSDavid Howells #define AFS_CELL_FL_NO_GC 1 /* The cell was added manually, don't auto-gc */ 325989782dcSDavid Howells #define AFS_CELL_FL_NOT_FOUND 2 /* Permanent DNS error */ 326989782dcSDavid Howells #define AFS_CELL_FL_DNS_FAIL 3 /* Failed to access DNS */ 3278b2a464cSDavid Howells #define AFS_CELL_FL_NO_LOOKUP_YET 4 /* Not completed first DNS lookup yet */ 328989782dcSDavid Howells enum afs_cell_state state; 329989782dcSDavid Howells short error; 330989782dcSDavid Howells 331d2ddc776SDavid Howells /* Active fileserver interaction state. */ 332d2ddc776SDavid Howells struct list_head proc_volumes; /* procfs volume list */ 333d2ddc776SDavid Howells rwlock_t proc_lock; 334989782dcSDavid Howells 335d2ddc776SDavid Howells /* VL server list. */ 3368b2a464cSDavid Howells rwlock_t vl_addrs_lock; /* Lock on vl_addrs */ 3378b2a464cSDavid Howells struct afs_addr_list __rcu *vl_addrs; /* List of VL servers */ 338989782dcSDavid Howells u8 name_len; /* Length of name */ 339989782dcSDavid Howells char name[64 + 1]; /* Cell name, case-flattened and NUL-padded */ 34008e0e7c8SDavid Howells }; 34108e0e7c8SDavid Howells 34208e0e7c8SDavid Howells /* 343d2ddc776SDavid Howells * Cached VLDB entry. 344d2ddc776SDavid Howells * 345d2ddc776SDavid Howells * This is pointed to by cell->vldb_entries, indexed by name. 34608e0e7c8SDavid Howells */ 347d2ddc776SDavid Howells struct afs_vldb_entry { 348d2ddc776SDavid Howells afs_volid_t vid[3]; /* Volume IDs for R/W, R/O and Bak volumes */ 34900d3b7a4SDavid Howells 350d2ddc776SDavid Howells unsigned long flags; 351d2ddc776SDavid Howells #define AFS_VLDB_HAS_RW 0 /* - R/W volume exists */ 352d2ddc776SDavid Howells #define AFS_VLDB_HAS_RO 1 /* - R/O volume exists */ 353d2ddc776SDavid Howells #define AFS_VLDB_HAS_BAK 2 /* - Backup volume exists */ 354d2ddc776SDavid Howells #define AFS_VLDB_QUERY_VALID 3 /* - Record is valid */ 355d2ddc776SDavid Howells #define AFS_VLDB_QUERY_ERROR 4 /* - VL server returned error */ 356d2ddc776SDavid Howells 357d2ddc776SDavid Howells uuid_t fs_server[AFS_NMAXNSERVERS]; 358d2ddc776SDavid Howells u8 fs_mask[AFS_NMAXNSERVERS]; 35908e0e7c8SDavid Howells #define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */ 36008e0e7c8SDavid Howells #define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */ 36108e0e7c8SDavid Howells #define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */ 362d2ddc776SDavid Howells short error; 363d2ddc776SDavid Howells u8 nr_servers; /* Number of server records */ 364d2ddc776SDavid Howells u8 name_len; 365d2ddc776SDavid Howells u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */ 36608e0e7c8SDavid Howells }; 36708e0e7c8SDavid Howells 36808e0e7c8SDavid Howells /* 369d2ddc776SDavid Howells * Record of fileserver with which we're actively communicating. 37008e0e7c8SDavid Howells */ 37108e0e7c8SDavid Howells struct afs_server { 372d2ddc776SDavid Howells struct rcu_head rcu; 373d2ddc776SDavid Howells union { 374d2ddc776SDavid Howells uuid_t uuid; /* Server ID */ 375d2ddc776SDavid Howells struct afs_uuid _uuid; 376d2ddc776SDavid Howells }; 377c435ee34SDavid Howells 378d2ddc776SDavid Howells struct afs_addr_list __rcu *addresses; 379d2ddc776SDavid Howells struct rb_node uuid_rb; /* Link in net->servers */ 380d2ddc776SDavid Howells struct hlist_node addr4_link; /* Link in net->fs_addresses4 */ 381d2ddc776SDavid Howells struct hlist_node addr6_link; /* Link in net->fs_addresses6 */ 382d2ddc776SDavid Howells struct hlist_node proc_link; /* Link in net->fs_proc */ 383d2ddc776SDavid Howells struct afs_server *gc_next; /* Next server in manager's list */ 384d2ddc776SDavid Howells time64_t put_time; /* Time at which last put */ 385d2ddc776SDavid Howells time64_t update_at; /* Time at which to next update the record */ 386c435ee34SDavid Howells unsigned long flags; 387d2ddc776SDavid Howells #define AFS_SERVER_FL_NEW 0 /* New server, don't inc cb_s_break */ 388d2ddc776SDavid Howells #define AFS_SERVER_FL_NOT_READY 1 /* The record is not ready for use */ 389d2ddc776SDavid Howells #define AFS_SERVER_FL_NOT_FOUND 2 /* VL server says no such server */ 390d2ddc776SDavid Howells #define AFS_SERVER_FL_VL_FAIL 3 /* Failed to access VL server */ 391d2ddc776SDavid Howells #define AFS_SERVER_FL_UPDATING 4 392d2ddc776SDavid Howells #define AFS_SERVER_FL_PROBED 5 /* The fileserver has been probed */ 393d2ddc776SDavid Howells #define AFS_SERVER_FL_PROBING 6 /* Fileserver is being probed */ 3945cf9dd55SDavid Howells #define AFS_SERVER_FL_NO_IBULK 7 /* Fileserver doesn't support FS.InlineBulkStatus */ 395d2ddc776SDavid Howells atomic_t usage; 396d2ddc776SDavid Howells u32 addr_version; /* Address list version */ 39708e0e7c8SDavid Howells 39808e0e7c8SDavid Howells /* file service access */ 399d2ddc776SDavid Howells rwlock_t fs_lock; /* access lock */ 40008e0e7c8SDavid Howells 40108e0e7c8SDavid Howells /* callback promise management */ 402c435ee34SDavid Howells struct list_head cb_interests; /* List of superblocks using this server */ 403c435ee34SDavid Howells unsigned cb_s_break; /* Break-everything counter. */ 404c435ee34SDavid Howells rwlock_t cb_break_lock; /* Volume finding lock */ 405c435ee34SDavid Howells }; 406c435ee34SDavid Howells 407c435ee34SDavid Howells /* 408c435ee34SDavid Howells * Interest by a superblock on a server. 409c435ee34SDavid Howells */ 410c435ee34SDavid Howells struct afs_cb_interest { 411c435ee34SDavid Howells struct list_head cb_link; /* Link in server->cb_interests */ 412c435ee34SDavid Howells struct afs_server *server; /* Server on which this interest resides */ 413c435ee34SDavid Howells struct super_block *sb; /* Superblock on which inodes reside */ 414c435ee34SDavid Howells afs_volid_t vid; /* Volume ID to match */ 415c435ee34SDavid Howells refcount_t usage; 41608e0e7c8SDavid Howells }; 41708e0e7c8SDavid Howells 41808e0e7c8SDavid Howells /* 419d2ddc776SDavid Howells * Replaceable server list. 42008e0e7c8SDavid Howells */ 421d2ddc776SDavid Howells struct afs_server_entry { 422d2ddc776SDavid Howells struct afs_server *server; 423d2ddc776SDavid Howells struct afs_cb_interest *cb_interest; 424d2ddc776SDavid Howells }; 425d2ddc776SDavid Howells 426d2ddc776SDavid Howells struct afs_server_list { 427d2ddc776SDavid Howells refcount_t usage; 428d2ddc776SDavid Howells unsigned short nr_servers; 429d2ddc776SDavid Howells unsigned short index; /* Server currently in use */ 430d2ddc776SDavid Howells unsigned short vnovol_mask; /* Servers to be skipped due to VNOVOL */ 431d2ddc776SDavid Howells unsigned int seq; /* Set to ->servers_seq when installed */ 432d2ddc776SDavid Howells struct afs_server_entry servers[]; 43308e0e7c8SDavid Howells }; 43408e0e7c8SDavid Howells 43508e0e7c8SDavid Howells /* 436d2ddc776SDavid Howells * Live AFS volume management. 43708e0e7c8SDavid Howells */ 438d2ddc776SDavid Howells struct afs_volume { 439d2ddc776SDavid Howells afs_volid_t vid; /* volume ID */ 440d2ddc776SDavid Howells atomic_t usage; 441d2ddc776SDavid Howells time64_t update_at; /* Time at which to next update */ 442d2ddc776SDavid Howells struct afs_cell *cell; /* Cell to which belongs (pins ref) */ 443d2ddc776SDavid Howells struct list_head proc_link; /* Link in cell->vl_proc */ 444d2ddc776SDavid Howells unsigned long flags; 445d2ddc776SDavid Howells #define AFS_VOLUME_NEEDS_UPDATE 0 /* - T if an update needs performing */ 446d2ddc776SDavid Howells #define AFS_VOLUME_UPDATING 1 /* - T if an update is in progress */ 447d2ddc776SDavid Howells #define AFS_VOLUME_WAIT 2 /* - T if users must wait for update */ 448d2ddc776SDavid Howells #define AFS_VOLUME_DELETED 3 /* - T if volume appears deleted */ 449d2ddc776SDavid Howells #define AFS_VOLUME_OFFLINE 4 /* - T if volume offline notice given */ 450d2ddc776SDavid Howells #define AFS_VOLUME_BUSY 5 /* - T if volume busy notice given */ 451d2ddc776SDavid Howells #ifdef CONFIG_AFS_FSCACHE 452d2ddc776SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 453d2ddc776SDavid Howells #endif 454d2ddc776SDavid Howells struct afs_server_list *servers; /* List of servers on which volume resides */ 455d2ddc776SDavid Howells rwlock_t servers_lock; /* Lock for ->servers */ 456d2ddc776SDavid Howells unsigned int servers_seq; /* Incremented each time ->servers changes */ 457d2ddc776SDavid Howells 458d2ddc776SDavid Howells afs_voltype_t type; /* type of volume */ 459d2ddc776SDavid Howells short error; 460d2ddc776SDavid Howells char type_force; /* force volume type (suppress R/O -> R/W) */ 461d2ddc776SDavid Howells u8 name_len; 462d2ddc776SDavid Howells u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */ 46308e0e7c8SDavid Howells }; 46408e0e7c8SDavid Howells 4650fafdc9fSDavid Howells enum afs_lock_state { 4660fafdc9fSDavid Howells AFS_VNODE_LOCK_NONE, /* The vnode has no lock on the server */ 4670fafdc9fSDavid Howells AFS_VNODE_LOCK_WAITING_FOR_CB, /* We're waiting for the server to break the callback */ 4680fafdc9fSDavid Howells AFS_VNODE_LOCK_SETTING, /* We're asking the server for a lock */ 4690fafdc9fSDavid Howells AFS_VNODE_LOCK_GRANTED, /* We have a lock on the server */ 4700fafdc9fSDavid Howells AFS_VNODE_LOCK_EXTENDING, /* We're extending a lock on the server */ 4710fafdc9fSDavid Howells AFS_VNODE_LOCK_NEED_UNLOCK, /* We need to unlock on the server */ 4720fafdc9fSDavid Howells AFS_VNODE_LOCK_UNLOCKING, /* We're telling the server to unlock */ 4730fafdc9fSDavid Howells }; 4740fafdc9fSDavid Howells 47508e0e7c8SDavid Howells /* 476f8de483eSDavid Howells * AFS inode private data. 477f8de483eSDavid Howells * 478f8de483eSDavid Howells * Note that afs_alloc_inode() *must* reset anything that could incorrectly 479f8de483eSDavid Howells * leak from one inode to another. 48008e0e7c8SDavid Howells */ 48108e0e7c8SDavid Howells struct afs_vnode { 48208e0e7c8SDavid Howells struct inode vfs_inode; /* the VFS's inode record */ 48308e0e7c8SDavid Howells 48408e0e7c8SDavid Howells struct afs_volume *volume; /* volume on which vnode resides */ 48508e0e7c8SDavid Howells struct afs_fid fid; /* the file identifier for this inode */ 48608e0e7c8SDavid Howells struct afs_file_status status; /* AFS status info for this file */ 487a4ff7401SDavid Howells afs_dataversion_t invalid_before; /* Child dentries are invalid before this */ 4889b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 4899b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 49008e0e7c8SDavid Howells #endif 491fe342cf7SDavid Howells struct afs_permits __rcu *permit_cache; /* cache of permits so far obtained */ 492d2ddc776SDavid Howells struct mutex io_lock; /* Lock for serialising I/O on this mutex */ 493260a9803SDavid Howells struct mutex validate_lock; /* lock for validating this vnode */ 4944343d008SDavid Howells spinlock_t wb_lock; /* lock for wb_keys */ 49508e0e7c8SDavid Howells spinlock_t lock; /* waitqueue/flags lock */ 49608e0e7c8SDavid Howells unsigned long flags; 497c435ee34SDavid Howells #define AFS_VNODE_CB_PROMISED 0 /* Set if vnode has a callback promise */ 498260a9803SDavid Howells #define AFS_VNODE_UNSET 1 /* set if vnode attributes not yet set */ 499f3ddee8dSDavid Howells #define AFS_VNODE_DIR_VALID 2 /* Set if dir contents are valid */ 50008e0e7c8SDavid Howells #define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */ 50108e0e7c8SDavid Howells #define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */ 50208e0e7c8SDavid Howells #define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */ 5030fafdc9fSDavid Howells #define AFS_VNODE_AUTOCELL 6 /* set if Vnode is an auto mount point */ 5040fafdc9fSDavid Howells #define AFS_VNODE_PSEUDODIR 7 /* set if Vnode is a pseudo directory */ 50508e0e7c8SDavid Howells 5064343d008SDavid Howells struct list_head wb_keys; /* List of keys available for writeback */ 507e8d6c554SDavid Howells struct list_head pending_locks; /* locks waiting to be granted */ 508e8d6c554SDavid Howells struct list_head granted_locks; /* locks granted on this file */ 509e8d6c554SDavid Howells struct delayed_work lock_work; /* work to be done in locking */ 5100fafdc9fSDavid Howells struct key *lock_key; /* Key to be used in lock ops */ 5110fafdc9fSDavid Howells enum afs_lock_state lock_state : 8; 5120fafdc9fSDavid Howells afs_lock_type_t lock_type : 8; 51331143d5dSDavid Howells 51408e0e7c8SDavid Howells /* outstanding callback notification on this file */ 515c435ee34SDavid Howells struct afs_cb_interest *cb_interest; /* Server on which this resides */ 516c435ee34SDavid Howells unsigned int cb_s_break; /* Mass break counter on ->server */ 517c435ee34SDavid Howells unsigned int cb_break; /* Break counter on vnode */ 518c435ee34SDavid Howells seqlock_t cb_lock; /* Lock for ->cb_interest, ->status, ->cb_*break */ 519c435ee34SDavid Howells 520c435ee34SDavid Howells time64_t cb_expires_at; /* time at which callback expires */ 52108e0e7c8SDavid Howells unsigned cb_version; /* callback version */ 52208e0e7c8SDavid Howells afs_callback_type_t cb_type; /* type of callback */ 52308e0e7c8SDavid Howells }; 52408e0e7c8SDavid Howells 52500d3b7a4SDavid Howells /* 52600d3b7a4SDavid Howells * cached security record for one user's attempt to access a vnode 52700d3b7a4SDavid Howells */ 52800d3b7a4SDavid Howells struct afs_permit { 52900d3b7a4SDavid Howells struct key *key; /* RxRPC ticket holding a security context */ 530be080a6fSDavid Howells afs_access_t access; /* CallerAccess value for this key */ 53100d3b7a4SDavid Howells }; 53200d3b7a4SDavid Howells 53300d3b7a4SDavid Howells /* 534be080a6fSDavid Howells * Immutable cache of CallerAccess records from attempts to access vnodes. 535be080a6fSDavid Howells * These may be shared between multiple vnodes. 53600d3b7a4SDavid Howells */ 53700d3b7a4SDavid Howells struct afs_permits { 538be080a6fSDavid Howells struct rcu_head rcu; 539be080a6fSDavid Howells struct hlist_node hash_node; /* Link in hash */ 540be080a6fSDavid Howells unsigned long h; /* Hash value for this permit list */ 541be080a6fSDavid Howells refcount_t usage; 542be080a6fSDavid Howells unsigned short nr_permits; /* Number of records */ 543be080a6fSDavid Howells bool invalidated; /* Invalidated due to key change */ 544be080a6fSDavid Howells struct afs_permit permits[]; /* List of permits sorted by key pointer */ 54500d3b7a4SDavid Howells }; 54600d3b7a4SDavid Howells 547b908fe6bSDavid Howells /* 548b908fe6bSDavid Howells * record of one of a system's set of network interfaces 549b908fe6bSDavid Howells */ 550b908fe6bSDavid Howells struct afs_interface { 551b908fe6bSDavid Howells struct in_addr address; /* IPv4 address bound to interface */ 552b908fe6bSDavid Howells struct in_addr netmask; /* netmask applied to address */ 553b908fe6bSDavid Howells unsigned mtu; /* MTU of interface */ 554b908fe6bSDavid Howells }; 555b908fe6bSDavid Howells 5568b2a464cSDavid Howells /* 5578b2a464cSDavid Howells * Cursor for iterating over a server's address list. 5588b2a464cSDavid Howells */ 5598b2a464cSDavid Howells struct afs_addr_cursor { 5608b2a464cSDavid Howells struct afs_addr_list *alist; /* Current address list (pins ref) */ 5618b2a464cSDavid Howells struct sockaddr_rxrpc *addr; 562d2ddc776SDavid Howells u32 abort_code; 5638b2a464cSDavid Howells unsigned short start; /* Starting point in alist->addrs[] */ 5648b2a464cSDavid Howells unsigned short index; /* Wrapping offset from start to current addr */ 5658b2a464cSDavid Howells short error; 5668b2a464cSDavid Howells bool begun; /* T if we've begun iteration */ 5678b2a464cSDavid Howells bool responded; /* T if the current address responded */ 5688b2a464cSDavid Howells }; 5698b2a464cSDavid Howells 5708b2a464cSDavid Howells /* 5718b2a464cSDavid Howells * Cursor for iterating over a set of fileservers. 5728b2a464cSDavid Howells */ 5738b2a464cSDavid Howells struct afs_fs_cursor { 5748b2a464cSDavid Howells struct afs_addr_cursor ac; 575d2ddc776SDavid Howells struct afs_vnode *vnode; 576d2ddc776SDavid Howells struct afs_server_list *server_list; /* Current server list (pins ref) */ 577d2ddc776SDavid Howells struct afs_cb_interest *cbi; /* Server on which this resides (pins ref) */ 578d2ddc776SDavid Howells struct key *key; /* Key for the server */ 579d2ddc776SDavid Howells unsigned int cb_break; /* cb_break + cb_s_break before the call */ 580d2ddc776SDavid Howells unsigned int cb_break_2; /* cb_break + cb_s_break (2nd vnode) */ 581d2ddc776SDavid Howells unsigned char start; /* Initial index in server list */ 582d2ddc776SDavid Howells unsigned char index; /* Number of servers tried beyond start */ 583d2ddc776SDavid Howells unsigned short flags; 584d2ddc776SDavid Howells #define AFS_FS_CURSOR_STOP 0x0001 /* Set to cease iteration */ 585d2ddc776SDavid Howells #define AFS_FS_CURSOR_VBUSY 0x0002 /* Set if seen VBUSY */ 586d2ddc776SDavid Howells #define AFS_FS_CURSOR_VMOVED 0x0004 /* Set if seen VMOVED */ 587d2ddc776SDavid Howells #define AFS_FS_CURSOR_VNOVOL 0x0008 /* Set if seen VNOVOL */ 588d2ddc776SDavid Howells #define AFS_FS_CURSOR_CUR_ONLY 0x0010 /* Set if current server only (file lock held) */ 589d2ddc776SDavid Howells #define AFS_FS_CURSOR_NO_VSLEEP 0x0020 /* Set to prevent sleep on VBUSY, VOFFLINE, ... */ 5908b2a464cSDavid Howells }; 5918b2a464cSDavid Howells 592402cb8ddSDavid Howells /* 593402cb8ddSDavid Howells * Cache auxiliary data. 594402cb8ddSDavid Howells */ 595402cb8ddSDavid Howells struct afs_vnode_cache_aux { 596402cb8ddSDavid Howells u64 data_version; 597402cb8ddSDavid Howells } __packed; 598402cb8ddSDavid Howells 59998bf40cdSDavid Howells #include <trace/events/afs.h> 60098bf40cdSDavid Howells 60108e0e7c8SDavid Howells /*****************************************************************************/ 60208e0e7c8SDavid Howells /* 6038b2a464cSDavid Howells * addr_list.c 6048b2a464cSDavid Howells */ 6058b2a464cSDavid Howells static inline struct afs_addr_list *afs_get_addrlist(struct afs_addr_list *alist) 6068b2a464cSDavid Howells { 6078b2a464cSDavid Howells if (alist) 6088b2a464cSDavid Howells refcount_inc(&alist->usage); 6098b2a464cSDavid Howells return alist; 6108b2a464cSDavid Howells } 6118b2a464cSDavid Howells extern struct afs_addr_list *afs_alloc_addrlist(unsigned int, 6128b2a464cSDavid Howells unsigned short, 6138b2a464cSDavid Howells unsigned short); 6148b2a464cSDavid Howells extern void afs_put_addrlist(struct afs_addr_list *); 6158b2a464cSDavid Howells extern struct afs_addr_list *afs_parse_text_addrs(const char *, size_t, char, 6168b2a464cSDavid Howells unsigned short, unsigned short); 6178b2a464cSDavid Howells extern struct afs_addr_list *afs_dns_query(struct afs_cell *, time64_t *); 6188b2a464cSDavid Howells extern bool afs_iterate_addresses(struct afs_addr_cursor *); 6198b2a464cSDavid Howells extern int afs_end_cursor(struct afs_addr_cursor *); 6208b2a464cSDavid Howells extern int afs_set_vl_cursor(struct afs_addr_cursor *, struct afs_cell *); 6218b2a464cSDavid Howells 622bf99a53cSDavid Howells extern void afs_merge_fs_addr4(struct afs_addr_list *, __be32, u16); 623bf99a53cSDavid Howells extern void afs_merge_fs_addr6(struct afs_addr_list *, __be32 *, u16); 624d2ddc776SDavid Howells 6258b2a464cSDavid Howells /* 6269b3f26c9SDavid Howells * cache.c 6279b3f26c9SDavid Howells */ 6289b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 6299b3f26c9SDavid Howells extern struct fscache_netfs afs_cache_netfs; 6309b3f26c9SDavid Howells extern struct fscache_cookie_def afs_cell_cache_index_def; 6319b3f26c9SDavid Howells extern struct fscache_cookie_def afs_volume_cache_index_def; 6329b3f26c9SDavid Howells extern struct fscache_cookie_def afs_vnode_cache_index_def; 6339b3f26c9SDavid Howells #else 6349b3f26c9SDavid Howells #define afs_cell_cache_index_def (*(struct fscache_cookie_def *) NULL) 6359b3f26c9SDavid Howells #define afs_volume_cache_index_def (*(struct fscache_cookie_def *) NULL) 6369b3f26c9SDavid Howells #define afs_vnode_cache_index_def (*(struct fscache_cookie_def *) NULL) 6379b3f26c9SDavid Howells #endif 6389b3f26c9SDavid Howells 6399b3f26c9SDavid Howells /* 64008e0e7c8SDavid Howells * callback.c 64108e0e7c8SDavid Howells */ 64208e0e7c8SDavid Howells extern void afs_init_callback_state(struct afs_server *); 643c435ee34SDavid Howells extern void afs_break_callback(struct afs_vnode *); 6445cf9dd55SDavid Howells extern void afs_break_callbacks(struct afs_server *, size_t, struct afs_callback_break*); 645c435ee34SDavid Howells 646d2ddc776SDavid Howells extern int afs_register_server_cb_interest(struct afs_vnode *, struct afs_server_entry *); 647c435ee34SDavid Howells extern void afs_put_cb_interest(struct afs_net *, struct afs_cb_interest *); 648d2ddc776SDavid Howells extern void afs_clear_callback_interests(struct afs_net *, struct afs_server_list *); 649c435ee34SDavid Howells 650c435ee34SDavid Howells static inline struct afs_cb_interest *afs_get_cb_interest(struct afs_cb_interest *cbi) 651c435ee34SDavid Howells { 652c435ee34SDavid Howells refcount_inc(&cbi->usage); 653c435ee34SDavid Howells return cbi; 654c435ee34SDavid Howells } 6551da177e4SLinus Torvalds 6561da177e4SLinus Torvalds /* 6571da177e4SLinus Torvalds * cell.c 6581da177e4SLinus Torvalds */ 659989782dcSDavid Howells extern int afs_cell_init(struct afs_net *, const char *); 660989782dcSDavid Howells extern struct afs_cell *afs_lookup_cell_rcu(struct afs_net *, const char *, unsigned); 661989782dcSDavid Howells extern struct afs_cell *afs_lookup_cell(struct afs_net *, const char *, unsigned, 662989782dcSDavid Howells const char *, bool); 6638b2a464cSDavid Howells extern struct afs_cell *afs_get_cell(struct afs_cell *); 6649ed900b1SDavid Howells extern void afs_put_cell(struct afs_net *, struct afs_cell *); 665989782dcSDavid Howells extern void afs_manage_cells(struct work_struct *); 666989782dcSDavid Howells extern void afs_cells_timer(struct timer_list *); 667f044c884SDavid Howells extern void __net_exit afs_cell_purge(struct afs_net *); 66808e0e7c8SDavid Howells 66908e0e7c8SDavid Howells /* 67008e0e7c8SDavid Howells * cmservice.c 67108e0e7c8SDavid Howells */ 67208e0e7c8SDavid Howells extern bool afs_cm_incoming_call(struct afs_call *); 67308e0e7c8SDavid Howells 6741da177e4SLinus Torvalds /* 6751da177e4SLinus Torvalds * dir.c 6761da177e4SLinus Torvalds */ 6774b6f5d20SArjan van de Ven extern const struct file_operations afs_dir_file_operations; 6784d673da1SDavid Howells extern const struct inode_operations afs_dir_inode_operations; 679f3ddee8dSDavid Howells extern const struct address_space_operations afs_dir_aops; 6804d673da1SDavid Howells extern const struct dentry_operations afs_fs_dentry_operations; 6814d673da1SDavid Howells 68266c7e1d3SDavid Howells extern void afs_d_release(struct dentry *); 68366c7e1d3SDavid Howells 68466c7e1d3SDavid Howells /* 68563a4681fSDavid Howells * dir_edit.c 68663a4681fSDavid Howells */ 68763a4681fSDavid Howells extern void afs_edit_dir_add(struct afs_vnode *, struct qstr *, struct afs_fid *, 68863a4681fSDavid Howells enum afs_edit_dir_reason); 68963a4681fSDavid Howells extern void afs_edit_dir_remove(struct afs_vnode *, struct qstr *, enum afs_edit_dir_reason); 69063a4681fSDavid Howells 69163a4681fSDavid Howells /* 69266c7e1d3SDavid Howells * dynroot.c 69366c7e1d3SDavid Howells */ 69466c7e1d3SDavid Howells extern const struct file_operations afs_dynroot_file_operations; 69566c7e1d3SDavid Howells extern const struct inode_operations afs_dynroot_inode_operations; 69666c7e1d3SDavid Howells extern const struct dentry_operations afs_dynroot_dentry_operations; 69766c7e1d3SDavid Howells 69866c7e1d3SDavid Howells extern struct inode *afs_try_auto_mntpt(struct dentry *, struct inode *); 6991da177e4SLinus Torvalds 7001da177e4SLinus Torvalds /* 7011da177e4SLinus Torvalds * file.c 7021da177e4SLinus Torvalds */ 703f5e54d6eSChristoph Hellwig extern const struct address_space_operations afs_fs_aops; 704754661f1SArjan van de Ven extern const struct inode_operations afs_file_inode_operations; 70500d3b7a4SDavid Howells extern const struct file_operations afs_file_operations; 70600d3b7a4SDavid Howells 7074343d008SDavid Howells extern int afs_cache_wb_key(struct afs_vnode *, struct afs_file *); 7084343d008SDavid Howells extern void afs_put_wb_key(struct afs_wb_key *); 70900d3b7a4SDavid Howells extern int afs_open(struct inode *, struct file *); 71000d3b7a4SDavid Howells extern int afs_release(struct inode *, struct file *); 711d2ddc776SDavid Howells extern int afs_fetch_data(struct afs_vnode *, struct key *, struct afs_read *); 712f6d335c0SAl Viro extern int afs_page_filler(void *, struct page *); 713196ee9cdSDavid Howells extern void afs_put_read(struct afs_read *); 7141da177e4SLinus Torvalds 7151da177e4SLinus Torvalds /* 716e8d6c554SDavid Howells * flock.c 717e8d6c554SDavid Howells */ 718f044c884SDavid Howells extern struct workqueue_struct *afs_lock_manager; 719f044c884SDavid Howells 720e8d6c554SDavid Howells extern void afs_lock_work(struct work_struct *); 721e8d6c554SDavid Howells extern void afs_lock_may_be_available(struct afs_vnode *); 722e8d6c554SDavid Howells extern int afs_lock(struct file *, int, struct file_lock *); 723e8d6c554SDavid Howells extern int afs_flock(struct file *, int, struct file_lock *); 724e8d6c554SDavid Howells 725e8d6c554SDavid Howells /* 72608e0e7c8SDavid Howells * fsclient.c 72708e0e7c8SDavid Howells */ 728dd9fbcb8SDavid Howells #define AFS_VNODE_NOT_YET_SET 0x01 729dd9fbcb8SDavid Howells #define AFS_VNODE_META_CHANGED 0x02 730dd9fbcb8SDavid Howells #define AFS_VNODE_DATA_CHANGED 0x04 731dd9fbcb8SDavid Howells extern void afs_update_inode_from_status(struct afs_vnode *, struct afs_file_status *, 732dd9fbcb8SDavid Howells const afs_dataversion_t *, u8); 733dd9fbcb8SDavid Howells 7340c3a5ac2SDavid Howells extern int afs_fs_fetch_file_status(struct afs_fs_cursor *, struct afs_volsync *, bool); 735d2ddc776SDavid Howells extern int afs_fs_give_up_callbacks(struct afs_net *, struct afs_server *); 736d2ddc776SDavid Howells extern int afs_fs_fetch_data(struct afs_fs_cursor *, struct afs_read *); 73763a4681fSDavid Howells extern int afs_fs_create(struct afs_fs_cursor *, const char *, umode_t, u64, 738d2ddc776SDavid Howells struct afs_fid *, struct afs_file_status *, struct afs_callback *); 73963a4681fSDavid Howells extern int afs_fs_remove(struct afs_fs_cursor *, const char *, bool, u64); 74063a4681fSDavid Howells extern int afs_fs_link(struct afs_fs_cursor *, struct afs_vnode *, const char *, u64); 74163a4681fSDavid Howells extern int afs_fs_symlink(struct afs_fs_cursor *, const char *, const char *, u64, 742d2ddc776SDavid Howells struct afs_fid *, struct afs_file_status *); 743d2ddc776SDavid Howells extern int afs_fs_rename(struct afs_fs_cursor *, const char *, 74463a4681fSDavid Howells struct afs_vnode *, const char *, u64, u64); 7454343d008SDavid Howells extern int afs_fs_store_data(struct afs_fs_cursor *, struct address_space *, 746d2ddc776SDavid Howells pgoff_t, pgoff_t, unsigned, unsigned); 747d2ddc776SDavid Howells extern int afs_fs_setattr(struct afs_fs_cursor *, struct iattr *); 748d2ddc776SDavid Howells extern int afs_fs_get_volume_status(struct afs_fs_cursor *, struct afs_volume_status *); 749d2ddc776SDavid Howells extern int afs_fs_set_lock(struct afs_fs_cursor *, afs_lock_type_t); 750d2ddc776SDavid Howells extern int afs_fs_extend_lock(struct afs_fs_cursor *); 751d2ddc776SDavid Howells extern int afs_fs_release_lock(struct afs_fs_cursor *); 752d2ddc776SDavid Howells extern int afs_fs_give_up_all_callbacks(struct afs_net *, struct afs_server *, 753d2ddc776SDavid Howells struct afs_addr_cursor *, struct key *); 754d2ddc776SDavid Howells extern int afs_fs_get_capabilities(struct afs_net *, struct afs_server *, 755d2ddc776SDavid Howells struct afs_addr_cursor *, struct key *); 7565cf9dd55SDavid Howells extern int afs_fs_inline_bulk_status(struct afs_fs_cursor *, struct afs_net *, 7575cf9dd55SDavid Howells struct afs_fid *, struct afs_file_status *, 7585cf9dd55SDavid Howells struct afs_callback *, unsigned int, 7595cf9dd55SDavid Howells struct afs_volsync *); 7605cf9dd55SDavid Howells extern int afs_fs_fetch_status(struct afs_fs_cursor *, struct afs_net *, 7615cf9dd55SDavid Howells struct afs_fid *, struct afs_file_status *, 7625cf9dd55SDavid Howells struct afs_callback *, struct afs_volsync *); 76308e0e7c8SDavid Howells 76408e0e7c8SDavid Howells /* 7651da177e4SLinus Torvalds * inode.c 7661da177e4SLinus Torvalds */ 7670c3a5ac2SDavid Howells extern int afs_fetch_status(struct afs_vnode *, struct key *, bool); 768c435ee34SDavid Howells extern int afs_iget5_test(struct inode *, void *); 7694d673da1SDavid Howells extern struct inode *afs_iget_pseudo_dir(struct super_block *, bool); 77000d3b7a4SDavid Howells extern struct inode *afs_iget(struct super_block *, struct key *, 771260a9803SDavid Howells struct afs_fid *, struct afs_file_status *, 772d2ddc776SDavid Howells struct afs_callback *, 773d2ddc776SDavid Howells struct afs_cb_interest *); 774416351f2SDavid Howells extern void afs_zap_data(struct afs_vnode *); 775260a9803SDavid Howells extern int afs_validate(struct afs_vnode *, struct key *); 776a528d35eSDavid Howells extern int afs_getattr(const struct path *, struct kstat *, u32, unsigned int); 77731143d5dSDavid Howells extern int afs_setattr(struct dentry *, struct iattr *); 778b57922d9SAl Viro extern void afs_evict_inode(struct inode *); 779bec5eb61Swanglei extern int afs_drop_inode(struct inode *); 7801da177e4SLinus Torvalds 7811da177e4SLinus Torvalds /* 7821da177e4SLinus Torvalds * main.c 7831da177e4SLinus Torvalds */ 7840ad53eeeSTejun Heo extern struct workqueue_struct *afs_wq; 785f044c884SDavid Howells 786f044c884SDavid Howells static inline struct afs_net *afs_d2net(struct dentry *dentry) 787f044c884SDavid Howells { 788f044c884SDavid Howells return &__afs_net; 789f044c884SDavid Howells } 790f044c884SDavid Howells 791f044c884SDavid Howells static inline struct afs_net *afs_i2net(struct inode *inode) 792f044c884SDavid Howells { 793f044c884SDavid Howells return &__afs_net; 794f044c884SDavid Howells } 795f044c884SDavid Howells 796f044c884SDavid Howells static inline struct afs_net *afs_v2net(struct afs_vnode *vnode) 797f044c884SDavid Howells { 798f044c884SDavid Howells return &__afs_net; 799f044c884SDavid Howells } 800f044c884SDavid Howells 801f044c884SDavid Howells static inline struct afs_net *afs_sock2net(struct sock *sk) 802f044c884SDavid Howells { 803f044c884SDavid Howells return &__afs_net; 804f044c884SDavid Howells } 805f044c884SDavid Howells 806f044c884SDavid Howells static inline struct afs_net *afs_get_net(struct afs_net *net) 807f044c884SDavid Howells { 808f044c884SDavid Howells return net; 809f044c884SDavid Howells } 810f044c884SDavid Howells 811f044c884SDavid Howells static inline void afs_put_net(struct afs_net *net) 812f044c884SDavid Howells { 813f044c884SDavid Howells } 8141da177e4SLinus Torvalds 815d55b4da4SDavid Howells static inline void __afs_stat(atomic_t *s) 816d55b4da4SDavid Howells { 817d55b4da4SDavid Howells atomic_inc(s); 818d55b4da4SDavid Howells } 819d55b4da4SDavid Howells 820d55b4da4SDavid Howells #define afs_stat_v(vnode, n) __afs_stat(&afs_v2net(vnode)->n) 821d55b4da4SDavid Howells 8221da177e4SLinus Torvalds /* 82308e0e7c8SDavid Howells * misc.c 82408e0e7c8SDavid Howells */ 82508e0e7c8SDavid Howells extern int afs_abort_to_error(u32); 82608e0e7c8SDavid Howells 82708e0e7c8SDavid Howells /* 8281da177e4SLinus Torvalds * mntpt.c 8291da177e4SLinus Torvalds */ 830754661f1SArjan van de Ven extern const struct inode_operations afs_mntpt_inode_operations; 831bec5eb61Swanglei extern const struct inode_operations afs_autocell_inode_operations; 8324b6f5d20SArjan van de Ven extern const struct file_operations afs_mntpt_file_operations; 8331da177e4SLinus Torvalds 834d18610b0SDavid Howells extern struct vfsmount *afs_d_automount(struct path *); 83508e0e7c8SDavid Howells extern void afs_mntpt_kill_timer(void); 8361da177e4SLinus Torvalds 8371da177e4SLinus Torvalds /* 838b4db2b35SArnd Bergmann * netdevices.c 839b4db2b35SArnd Bergmann */ 840b4db2b35SArnd Bergmann extern int afs_get_ipv4_interfaces(struct afs_interface *, size_t, bool); 841b4db2b35SArnd Bergmann 842b4db2b35SArnd Bergmann /* 8431da177e4SLinus Torvalds * proc.c 8441da177e4SLinus Torvalds */ 845f044c884SDavid Howells extern int __net_init afs_proc_init(struct afs_net *); 846f044c884SDavid Howells extern void __net_exit afs_proc_cleanup(struct afs_net *); 847f044c884SDavid Howells extern int afs_proc_cell_setup(struct afs_net *, struct afs_cell *); 848f044c884SDavid Howells extern void afs_proc_cell_remove(struct afs_net *, struct afs_cell *); 8496f8880d8SDavid Howells extern void afs_put_sysnames(struct afs_sysnames *); 8501da177e4SLinus Torvalds 85108e0e7c8SDavid Howells /* 852d2ddc776SDavid Howells * rotate.c 853d2ddc776SDavid Howells */ 854d2ddc776SDavid Howells extern bool afs_begin_vnode_operation(struct afs_fs_cursor *, struct afs_vnode *, 855d2ddc776SDavid Howells struct key *); 856d2ddc776SDavid Howells extern bool afs_select_fileserver(struct afs_fs_cursor *); 857d2ddc776SDavid Howells extern bool afs_select_current_fileserver(struct afs_fs_cursor *); 858d2ddc776SDavid Howells extern int afs_end_vnode_operation(struct afs_fs_cursor *); 859d2ddc776SDavid Howells 860d2ddc776SDavid Howells /* 86108e0e7c8SDavid Howells * rxrpc.c 86208e0e7c8SDavid Howells */ 863f044c884SDavid Howells extern struct workqueue_struct *afs_async_calls; 8648324f0bcSDavid Howells 865f044c884SDavid Howells extern int __net_init afs_open_socket(struct afs_net *); 866f044c884SDavid Howells extern void __net_exit afs_close_socket(struct afs_net *); 867f044c884SDavid Howells extern void afs_charge_preallocation(struct work_struct *); 868341f741fSDavid Howells extern void afs_put_call(struct afs_call *); 869341f741fSDavid Howells extern int afs_queue_call_work(struct afs_call *); 8708b2a464cSDavid Howells extern long afs_make_call(struct afs_addr_cursor *, struct afs_call *, gfp_t, bool); 871f044c884SDavid Howells extern struct afs_call *afs_alloc_flat_call(struct afs_net *, 872f044c884SDavid Howells const struct afs_call_type *, 87308e0e7c8SDavid Howells size_t, size_t); 87408e0e7c8SDavid Howells extern void afs_flat_call_destructor(struct afs_call *); 87508e0e7c8SDavid Howells extern void afs_send_empty_reply(struct afs_call *); 876b908fe6bSDavid Howells extern void afs_send_simple_reply(struct afs_call *, const void *, size_t); 877d001648eSDavid Howells extern int afs_extract_data(struct afs_call *, void *, size_t, bool); 87808e0e7c8SDavid Howells 879d001648eSDavid Howells static inline int afs_transfer_reply(struct afs_call *call) 880372ee163SDavid Howells { 881d001648eSDavid Howells return afs_extract_data(call, call->buffer, call->reply_max, false); 882372ee163SDavid Howells } 883372ee163SDavid Howells 88498bf40cdSDavid Howells static inline bool afs_check_call_state(struct afs_call *call, 88598bf40cdSDavid Howells enum afs_call_state state) 88698bf40cdSDavid Howells { 88798bf40cdSDavid Howells return READ_ONCE(call->state) == state; 88898bf40cdSDavid Howells } 88998bf40cdSDavid Howells 89098bf40cdSDavid Howells static inline bool afs_set_call_state(struct afs_call *call, 89198bf40cdSDavid Howells enum afs_call_state from, 89298bf40cdSDavid Howells enum afs_call_state to) 89398bf40cdSDavid Howells { 89498bf40cdSDavid Howells bool ok = false; 89598bf40cdSDavid Howells 89698bf40cdSDavid Howells spin_lock_bh(&call->state_lock); 89798bf40cdSDavid Howells if (call->state == from) { 89898bf40cdSDavid Howells call->state = to; 89998bf40cdSDavid Howells trace_afs_call_state(call, from, to, 0, 0); 90098bf40cdSDavid Howells ok = true; 90198bf40cdSDavid Howells } 90298bf40cdSDavid Howells spin_unlock_bh(&call->state_lock); 90398bf40cdSDavid Howells return ok; 90498bf40cdSDavid Howells } 90598bf40cdSDavid Howells 90698bf40cdSDavid Howells static inline void afs_set_call_complete(struct afs_call *call, 90798bf40cdSDavid Howells int error, u32 remote_abort) 90898bf40cdSDavid Howells { 90998bf40cdSDavid Howells enum afs_call_state state; 91098bf40cdSDavid Howells bool ok = false; 91198bf40cdSDavid Howells 91298bf40cdSDavid Howells spin_lock_bh(&call->state_lock); 91398bf40cdSDavid Howells state = call->state; 91498bf40cdSDavid Howells if (state != AFS_CALL_COMPLETE) { 91598bf40cdSDavid Howells call->abort_code = remote_abort; 91698bf40cdSDavid Howells call->error = error; 91798bf40cdSDavid Howells call->state = AFS_CALL_COMPLETE; 91898bf40cdSDavid Howells trace_afs_call_state(call, state, AFS_CALL_COMPLETE, 91998bf40cdSDavid Howells error, remote_abort); 92098bf40cdSDavid Howells ok = true; 92198bf40cdSDavid Howells } 92298bf40cdSDavid Howells spin_unlock_bh(&call->state_lock); 92398bf40cdSDavid Howells if (ok) 92498bf40cdSDavid Howells trace_afs_call_done(call); 92598bf40cdSDavid Howells } 92698bf40cdSDavid Howells 92708e0e7c8SDavid Howells /* 92800d3b7a4SDavid Howells * security.c 92900d3b7a4SDavid Howells */ 930be080a6fSDavid Howells extern void afs_put_permits(struct afs_permits *); 93100d3b7a4SDavid Howells extern void afs_clear_permits(struct afs_vnode *); 932be080a6fSDavid Howells extern void afs_cache_permit(struct afs_vnode *, struct key *, unsigned int); 933416351f2SDavid Howells extern void afs_zap_permits(struct rcu_head *); 93400d3b7a4SDavid Howells extern struct key *afs_request_key(struct afs_cell *); 9350fafdc9fSDavid Howells extern int afs_check_permit(struct afs_vnode *, struct key *, afs_access_t *); 93610556cb2SAl Viro extern int afs_permission(struct inode *, int); 937be080a6fSDavid Howells extern void __exit afs_clean_up_permit_cache(void); 93800d3b7a4SDavid Howells 93900d3b7a4SDavid Howells /* 94008e0e7c8SDavid Howells * server.c 94108e0e7c8SDavid Howells */ 94208e0e7c8SDavid Howells extern spinlock_t afs_server_peer_lock; 94308e0e7c8SDavid Howells 944c435ee34SDavid Howells static inline struct afs_server *afs_get_server(struct afs_server *server) 945c435ee34SDavid Howells { 946c435ee34SDavid Howells atomic_inc(&server->usage); 947c435ee34SDavid Howells return server; 948c435ee34SDavid Howells } 94908e0e7c8SDavid Howells 950f044c884SDavid Howells extern struct afs_server *afs_find_server(struct afs_net *, 951f044c884SDavid Howells const struct sockaddr_rxrpc *); 952d2ddc776SDavid Howells extern struct afs_server *afs_find_server_by_uuid(struct afs_net *, const uuid_t *); 953d2ddc776SDavid Howells extern struct afs_server *afs_lookup_server(struct afs_cell *, struct key *, const uuid_t *); 9549ed900b1SDavid Howells extern void afs_put_server(struct afs_net *, struct afs_server *); 955d2ddc776SDavid Howells extern void afs_manage_servers(struct work_struct *); 956d2ddc776SDavid Howells extern void afs_servers_timer(struct timer_list *); 957f044c884SDavid Howells extern void __net_exit afs_purge_servers(struct afs_net *); 958d2ddc776SDavid Howells extern bool afs_probe_fileserver(struct afs_fs_cursor *); 959d2ddc776SDavid Howells extern bool afs_check_server_record(struct afs_fs_cursor *, struct afs_server *); 960d2ddc776SDavid Howells 961d2ddc776SDavid Howells /* 962d2ddc776SDavid Howells * server_list.c 963d2ddc776SDavid Howells */ 964d2ddc776SDavid Howells static inline struct afs_server_list *afs_get_serverlist(struct afs_server_list *slist) 965d2ddc776SDavid Howells { 966d2ddc776SDavid Howells refcount_inc(&slist->usage); 967d2ddc776SDavid Howells return slist; 968d2ddc776SDavid Howells } 969d2ddc776SDavid Howells 970d2ddc776SDavid Howells extern void afs_put_serverlist(struct afs_net *, struct afs_server_list *); 971d2ddc776SDavid Howells extern struct afs_server_list *afs_alloc_server_list(struct afs_cell *, struct key *, 972d2ddc776SDavid Howells struct afs_vldb_entry *, 973d2ddc776SDavid Howells u8); 974d2ddc776SDavid Howells extern bool afs_annotate_server_list(struct afs_server_list *, struct afs_server_list *); 97508e0e7c8SDavid Howells 97608e0e7c8SDavid Howells /* 97700d3b7a4SDavid Howells * super.c 97800d3b7a4SDavid Howells */ 979f044c884SDavid Howells extern int __init afs_fs_init(void); 980f044c884SDavid Howells extern void __exit afs_fs_exit(void); 98100d3b7a4SDavid Howells 98200d3b7a4SDavid Howells /* 98308e0e7c8SDavid Howells * vlclient.c 98408e0e7c8SDavid Howells */ 985d2ddc776SDavid Howells extern struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_net *, 986d2ddc776SDavid Howells struct afs_addr_cursor *, 987d2ddc776SDavid Howells struct key *, const char *, int); 988d2ddc776SDavid Howells extern struct afs_addr_list *afs_vl_get_addrs_u(struct afs_net *, struct afs_addr_cursor *, 989d2ddc776SDavid Howells struct key *, const uuid_t *); 990bf99a53cSDavid Howells extern int afs_vl_get_capabilities(struct afs_net *, struct afs_addr_cursor *, struct key *); 991bf99a53cSDavid Howells extern struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_net *, struct afs_addr_cursor *, 992bf99a53cSDavid Howells struct key *, const uuid_t *); 99308e0e7c8SDavid Howells 99408e0e7c8SDavid Howells /* 99508e0e7c8SDavid Howells * volume.c 99608e0e7c8SDavid Howells */ 997d2ddc776SDavid Howells static inline struct afs_volume *__afs_get_volume(struct afs_volume *volume) 99849566f6fSDavid Howells { 99949566f6fSDavid Howells if (volume) 100049566f6fSDavid Howells atomic_inc(&volume->usage); 100149566f6fSDavid Howells return volume; 100249566f6fSDavid Howells } 100308e0e7c8SDavid Howells 1004d2ddc776SDavid Howells extern struct afs_volume *afs_create_volume(struct afs_mount_params *); 1005d2ddc776SDavid Howells extern void afs_activate_volume(struct afs_volume *); 1006d2ddc776SDavid Howells extern void afs_deactivate_volume(struct afs_volume *); 10079ed900b1SDavid Howells extern void afs_put_volume(struct afs_cell *, struct afs_volume *); 1008d2ddc776SDavid Howells extern int afs_check_volume_status(struct afs_volume *, struct key *); 100908e0e7c8SDavid Howells 101031143d5dSDavid Howells /* 101131143d5dSDavid Howells * write.c 101231143d5dSDavid Howells */ 101331143d5dSDavid Howells extern int afs_set_page_dirty(struct page *); 101415b4650eSNick Piggin extern int afs_write_begin(struct file *file, struct address_space *mapping, 101515b4650eSNick Piggin loff_t pos, unsigned len, unsigned flags, 101615b4650eSNick Piggin struct page **pagep, void **fsdata); 101715b4650eSNick Piggin extern int afs_write_end(struct file *file, struct address_space *mapping, 101815b4650eSNick Piggin loff_t pos, unsigned len, unsigned copied, 101915b4650eSNick Piggin struct page *page, void *fsdata); 102031143d5dSDavid Howells extern int afs_writepage(struct page *, struct writeback_control *); 102131143d5dSDavid Howells extern int afs_writepages(struct address_space *, struct writeback_control *); 102231143d5dSDavid Howells extern void afs_pages_written_back(struct afs_vnode *, struct afs_call *); 102350b5551dSAl Viro extern ssize_t afs_file_write(struct kiocb *, struct iov_iter *); 102458fed94dSDavid Howells extern int afs_flush(struct file *, fl_owner_t); 102502c24a82SJosef Bacik extern int afs_fsync(struct file *, loff_t, loff_t, int); 10261cf7a151SDavid Howells extern int afs_page_mkwrite(struct vm_fault *); 10274343d008SDavid Howells extern void afs_prune_wb_keys(struct afs_vnode *); 10284343d008SDavid Howells extern int afs_launder_page(struct page *); 102931143d5dSDavid Howells 1030d3e3b7eaSDavid Howells /* 1031d3e3b7eaSDavid Howells * xattr.c 1032d3e3b7eaSDavid Howells */ 1033d3e3b7eaSDavid Howells extern const struct xattr_handler *afs_xattr_handlers[]; 1034d3e3b7eaSDavid Howells extern ssize_t afs_listxattr(struct dentry *, char *, size_t); 103531143d5dSDavid Howells 1036d2ddc776SDavid Howells 1037d2ddc776SDavid Howells /* 1038d2ddc776SDavid Howells * Miscellaneous inline functions. 1039d2ddc776SDavid Howells */ 1040d2ddc776SDavid Howells static inline struct afs_vnode *AFS_FS_I(struct inode *inode) 1041d2ddc776SDavid Howells { 1042d2ddc776SDavid Howells return container_of(inode, struct afs_vnode, vfs_inode); 1043d2ddc776SDavid Howells } 1044d2ddc776SDavid Howells 1045d2ddc776SDavid Howells static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode) 1046d2ddc776SDavid Howells { 1047d2ddc776SDavid Howells return &vnode->vfs_inode; 1048d2ddc776SDavid Howells } 1049d2ddc776SDavid Howells 1050d2ddc776SDavid Howells static inline void afs_vnode_commit_status(struct afs_fs_cursor *fc, 1051d2ddc776SDavid Howells struct afs_vnode *vnode, 1052d2ddc776SDavid Howells unsigned int cb_break) 1053d2ddc776SDavid Howells { 1054d2ddc776SDavid Howells if (fc->ac.error == 0) 1055d2ddc776SDavid Howells afs_cache_permit(vnode, fc->key, cb_break); 1056d2ddc776SDavid Howells } 1057d2ddc776SDavid Howells 1058d2ddc776SDavid Howells static inline void afs_check_for_remote_deletion(struct afs_fs_cursor *fc, 1059d2ddc776SDavid Howells struct afs_vnode *vnode) 1060d2ddc776SDavid Howells { 1061d2ddc776SDavid Howells if (fc->ac.error == -ENOENT) { 1062d2ddc776SDavid Howells set_bit(AFS_VNODE_DELETED, &vnode->flags); 1063d2ddc776SDavid Howells afs_break_callback(vnode); 1064d2ddc776SDavid Howells } 1065d2ddc776SDavid Howells } 1066d2ddc776SDavid Howells 1067d2ddc776SDavid Howells 106808e0e7c8SDavid Howells /*****************************************************************************/ 106908e0e7c8SDavid Howells /* 107008e0e7c8SDavid Howells * debug tracing 107108e0e7c8SDavid Howells */ 107208e0e7c8SDavid Howells extern unsigned afs_debug; 107308e0e7c8SDavid Howells 107408e0e7c8SDavid Howells #define dbgprintk(FMT,...) \ 1075ad16df84SSven Schnelle printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__) 107608e0e7c8SDavid Howells 1077530b6412SHarvey Harrison #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__) 1078530b6412SHarvey Harrison #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) 107908e0e7c8SDavid Howells #define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__) 108008e0e7c8SDavid Howells 108108e0e7c8SDavid Howells 108208e0e7c8SDavid Howells #if defined(__KDEBUG) 108308e0e7c8SDavid Howells #define _enter(FMT,...) kenter(FMT,##__VA_ARGS__) 108408e0e7c8SDavid Howells #define _leave(FMT,...) kleave(FMT,##__VA_ARGS__) 108508e0e7c8SDavid Howells #define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__) 108608e0e7c8SDavid Howells 108708e0e7c8SDavid Howells #elif defined(CONFIG_AFS_DEBUG) 108808e0e7c8SDavid Howells #define AFS_DEBUG_KENTER 0x01 108908e0e7c8SDavid Howells #define AFS_DEBUG_KLEAVE 0x02 109008e0e7c8SDavid Howells #define AFS_DEBUG_KDEBUG 0x04 109108e0e7c8SDavid Howells 109208e0e7c8SDavid Howells #define _enter(FMT,...) \ 109308e0e7c8SDavid Howells do { \ 109408e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \ 109508e0e7c8SDavid Howells kenter(FMT,##__VA_ARGS__); \ 109608e0e7c8SDavid Howells } while (0) 109708e0e7c8SDavid Howells 109808e0e7c8SDavid Howells #define _leave(FMT,...) \ 109908e0e7c8SDavid Howells do { \ 110008e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \ 110108e0e7c8SDavid Howells kleave(FMT,##__VA_ARGS__); \ 110208e0e7c8SDavid Howells } while (0) 110308e0e7c8SDavid Howells 110408e0e7c8SDavid Howells #define _debug(FMT,...) \ 110508e0e7c8SDavid Howells do { \ 110608e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \ 110708e0e7c8SDavid Howells kdebug(FMT,##__VA_ARGS__); \ 110808e0e7c8SDavid Howells } while (0) 110908e0e7c8SDavid Howells 111008e0e7c8SDavid Howells #else 111112fdff3fSDavid Howells #define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__) 111212fdff3fSDavid Howells #define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) 111312fdff3fSDavid Howells #define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__) 111408e0e7c8SDavid Howells #endif 111508e0e7c8SDavid Howells 111608e0e7c8SDavid Howells /* 111708e0e7c8SDavid Howells * debug assertion checking 111808e0e7c8SDavid Howells */ 111908e0e7c8SDavid Howells #if 1 // defined(__KDEBUGALL) 112008e0e7c8SDavid Howells 112108e0e7c8SDavid Howells #define ASSERT(X) \ 112208e0e7c8SDavid Howells do { \ 112308e0e7c8SDavid Howells if (unlikely(!(X))) { \ 112408e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 112508e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 112608e0e7c8SDavid Howells BUG(); \ 112708e0e7c8SDavid Howells } \ 112808e0e7c8SDavid Howells } while(0) 112908e0e7c8SDavid Howells 113008e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y) \ 113108e0e7c8SDavid Howells do { \ 113208e0e7c8SDavid Howells if (unlikely(!((X) OP (Y)))) { \ 113308e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 113408e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 113508e0e7c8SDavid Howells printk(KERN_ERR "%lu " #OP " %lu is false\n", \ 113608e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 113708e0e7c8SDavid Howells printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ 113808e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 113908e0e7c8SDavid Howells BUG(); \ 114008e0e7c8SDavid Howells } \ 114108e0e7c8SDavid Howells } while(0) 114208e0e7c8SDavid Howells 1143416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H) \ 1144416351f2SDavid Howells do { \ 1145416351f2SDavid Howells if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) { \ 1146416351f2SDavid Howells printk(KERN_ERR "\n"); \ 1147416351f2SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 1148416351f2SDavid Howells printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n", \ 1149416351f2SDavid Howells (unsigned long)(L), (unsigned long)(N), \ 1150416351f2SDavid Howells (unsigned long)(H)); \ 1151416351f2SDavid Howells printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \ 1152416351f2SDavid Howells (unsigned long)(L), (unsigned long)(N), \ 1153416351f2SDavid Howells (unsigned long)(H)); \ 1154416351f2SDavid Howells BUG(); \ 1155416351f2SDavid Howells } \ 1156416351f2SDavid Howells } while(0) 1157416351f2SDavid Howells 115808e0e7c8SDavid Howells #define ASSERTIF(C, X) \ 115908e0e7c8SDavid Howells do { \ 116008e0e7c8SDavid Howells if (unlikely((C) && !(X))) { \ 116108e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 116208e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 116308e0e7c8SDavid Howells BUG(); \ 116408e0e7c8SDavid Howells } \ 116508e0e7c8SDavid Howells } while(0) 116608e0e7c8SDavid Howells 116708e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y) \ 116808e0e7c8SDavid Howells do { \ 116908e0e7c8SDavid Howells if (unlikely((C) && !((X) OP (Y)))) { \ 117008e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 117108e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 117208e0e7c8SDavid Howells printk(KERN_ERR "%lu " #OP " %lu is false\n", \ 117308e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 117408e0e7c8SDavid Howells printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ 117508e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 117608e0e7c8SDavid Howells BUG(); \ 117708e0e7c8SDavid Howells } \ 117808e0e7c8SDavid Howells } while(0) 117908e0e7c8SDavid Howells 118008e0e7c8SDavid Howells #else 118108e0e7c8SDavid Howells 118208e0e7c8SDavid Howells #define ASSERT(X) \ 118308e0e7c8SDavid Howells do { \ 118408e0e7c8SDavid Howells } while(0) 118508e0e7c8SDavid Howells 118608e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y) \ 118708e0e7c8SDavid Howells do { \ 118808e0e7c8SDavid Howells } while(0) 118908e0e7c8SDavid Howells 1190416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H) \ 1191416351f2SDavid Howells do { \ 1192416351f2SDavid Howells } while(0) 1193416351f2SDavid Howells 119408e0e7c8SDavid Howells #define ASSERTIF(C, X) \ 119508e0e7c8SDavid Howells do { \ 119608e0e7c8SDavid Howells } while(0) 119708e0e7c8SDavid Howells 119808e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y) \ 119908e0e7c8SDavid Howells do { \ 120008e0e7c8SDavid Howells } while(0) 120108e0e7c8SDavid Howells 120208e0e7c8SDavid Howells #endif /* __KDEBUGALL */ 1203