David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 1 | /* internal AFS stuff |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 3 | * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * Written by David Howells (dhowells@redhat.com) |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | */ |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/compiler.h> |
| 13 | #include <linux/kernel.h> |
Tina Ruchandani | 8a79790 | 2017-03-16 16:27:46 +0000 | [diff] [blame] | 14 | #include <linux/ktime.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/fs.h> |
| 16 | #include <linux/pagemap.h> |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 17 | #include <linux/rxrpc.h> |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 18 | #include <linux/key.h> |
Alexey Dobriyan | e8edc6e | 2007-05-21 01:22:52 +0400 | [diff] [blame] | 19 | #include <linux/workqueue.h> |
Andrew Morton | 00c541e | 2007-05-31 00:40:52 -0700 | [diff] [blame] | 20 | #include <linux/sched.h> |
Christoph Hellwig | 80e50be | 2009-10-01 15:44:27 -0700 | [diff] [blame] | 21 | #include <linux/fscache.h> |
Jens Axboe | e1da022 | 2010-04-22 11:58:18 +0200 | [diff] [blame] | 22 | #include <linux/backing-dev.h> |
David Howells | ff54877 | 2017-02-10 16:34:07 +0000 | [diff] [blame] | 23 | #include <linux/uuid.h> |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 24 | #include <net/net_namespace.h> |
David Howells | 8324f0b | 2016-08-30 09:49:29 +0100 | [diff] [blame] | 25 | #include <net/af_rxrpc.h> |
Andrew Morton | 00c541e | 2007-05-31 00:40:52 -0700 | [diff] [blame] | 26 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 27 | #include "afs.h" |
| 28 | #include "afs_vl.h" |
| 29 | |
| 30 | #define AFS_CELL_MAX_ADDRS 15 |
| 31 | |
David Howells | 31143d5 | 2007-05-09 02:33:46 -0700 | [diff] [blame] | 32 | struct pagevec; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 33 | struct afs_call; |
| 34 | |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 35 | struct afs_mount_params { |
| 36 | bool rwpath; /* T if the parent should be considered R/W */ |
| 37 | bool force; /* T to force cell type */ |
wanglei | bec5eb6 | 2010-08-11 09:38:04 +0100 | [diff] [blame] | 38 | bool autocell; /* T if set auto mount operation */ |
David Howells | 4d673da | 2018-02-06 06:26:30 +0000 | [diff] [blame] | 39 | bool dyn_root; /* T if dynamic root */ |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 40 | afs_voltype_t type; /* type of volume requested */ |
| 41 | int volnamesz; /* size of volume name */ |
| 42 | const char *volname; /* name of volume to mount */ |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 43 | struct afs_net *net; /* Network namespace in effect */ |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 44 | struct afs_cell *cell; /* cell in which to find volume */ |
| 45 | struct afs_volume *volume; /* volume record */ |
| 46 | struct key *key; /* key to use for secure mounting */ |
| 47 | }; |
| 48 | |
David Howells | c435ee3 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 49 | struct afs_iget_data { |
| 50 | struct afs_fid fid; |
| 51 | struct afs_volume *volume; /* volume on which resides */ |
| 52 | }; |
| 53 | |
David Howells | 8e8d7f1 | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 54 | enum afs_call_state { |
David Howells | 98bf40c | 2017-11-02 15:27:53 +0000 | [diff] [blame] | 55 | AFS_CALL_CL_REQUESTING, /* Client: Request is being sent */ |
| 56 | AFS_CALL_CL_AWAIT_REPLY, /* Client: Awaiting reply */ |
| 57 | AFS_CALL_CL_PROC_REPLY, /* Client: rxrpc call complete; processing reply */ |
| 58 | AFS_CALL_SV_AWAIT_OP_ID, /* Server: Awaiting op ID */ |
| 59 | AFS_CALL_SV_AWAIT_REQUEST, /* Server: Awaiting request data */ |
| 60 | AFS_CALL_SV_REPLYING, /* Server: Replying */ |
| 61 | AFS_CALL_SV_AWAIT_ACK, /* Server: Awaiting final ACK */ |
| 62 | AFS_CALL_COMPLETE, /* Completed or failed */ |
David Howells | 8e8d7f1 | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 63 | }; |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 64 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 65 | /* |
David Howells | 8b2a464 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 66 | * List of server addresses. |
| 67 | */ |
| 68 | struct afs_addr_list { |
| 69 | struct rcu_head rcu; /* Must be first */ |
| 70 | refcount_t usage; |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 71 | u32 version; /* Version */ |
David Howells | 8b2a464 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 72 | unsigned short nr_addrs; |
| 73 | unsigned short index; /* Address currently in use */ |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 74 | unsigned short nr_ipv4; /* Number of IPv4 addresses */ |
David Howells | bf99a53 | 2017-11-02 15:27:51 +0000 | [diff] [blame] | 75 | unsigned long probed; /* Mask of servers that have been probed */ |
| 76 | unsigned long yfs; /* Mask of servers that are YFS */ |
David Howells | 8b2a464 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 77 | struct sockaddr_rxrpc addrs[]; |
| 78 | }; |
| 79 | |
| 80 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 81 | * a record of an in-progress RxRPC call |
| 82 | */ |
| 83 | struct afs_call { |
| 84 | const struct afs_call_type *type; /* type of call */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 85 | wait_queue_head_t waitq; /* processes awaiting completion */ |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 86 | struct work_struct async_work; /* async I/O processor */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 87 | struct work_struct work; /* actual work processor */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 88 | struct rxrpc_call *rxcall; /* RxRPC call handle */ |
| 89 | struct key *key; /* security for this call */ |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 90 | struct afs_net *net; /* The network namespace */ |
David Howells | d0676a1 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 91 | struct afs_server *cm_server; /* Server affected by incoming CM call */ |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 92 | struct afs_cb_interest *cbi; /* Callback interest for server used */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 93 | void *request; /* request data (first part) */ |
David Howells | 4343d00 | 2017-11-02 15:27:52 +0000 | [diff] [blame] | 94 | struct address_space *mapping; /* Pages being written from */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 95 | void *buffer; /* reply receive buffer */ |
David Howells | 97e3043 | 2017-11-02 15:27:48 +0000 | [diff] [blame] | 96 | void *reply[4]; /* Where to put the reply */ |
David Howells | 31143d5 | 2007-05-09 02:33:46 -0700 | [diff] [blame] | 97 | pgoff_t first; /* first page in mapping to deal with */ |
| 98 | pgoff_t last; /* last page in mapping to deal with */ |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 99 | size_t offset; /* offset into received data store */ |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 100 | atomic_t usage; |
David Howells | 8e8d7f1 | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 101 | enum afs_call_state state; |
David Howells | 98bf40c | 2017-11-02 15:27:53 +0000 | [diff] [blame] | 102 | spinlock_t state_lock; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 103 | int error; /* error code */ |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 104 | u32 abort_code; /* Remote abort ID or 0 */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 105 | unsigned request_size; /* size of request data */ |
| 106 | unsigned reply_max; /* maximum size of reply */ |
David Howells | 31143d5 | 2007-05-09 02:33:46 -0700 | [diff] [blame] | 107 | unsigned first_offset; /* offset into mapping[first] */ |
David Howells | c435ee3 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 108 | unsigned int cb_break; /* cb_break + cb_s_break before the call */ |
Marc Dionne | bcd8927 | 2017-03-16 16:27:44 +0000 | [diff] [blame] | 109 | union { |
| 110 | unsigned last_to; /* amount of mapping[last] */ |
| 111 | unsigned count2; /* count used in unmarshalling */ |
| 112 | }; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 113 | unsigned char unmarshall; /* unmarshalling phase */ |
| 114 | bool incoming; /* T if incoming call */ |
David Howells | 31143d5 | 2007-05-09 02:33:46 -0700 | [diff] [blame] | 115 | bool send_pages; /* T if data from mapping should be sent */ |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 116 | bool need_attention; /* T if RxRPC poked us */ |
David Howells | 56ff9c8 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 117 | bool async; /* T if asynchronous */ |
David Howells | 33cd7f2 | 2017-11-02 15:27:48 +0000 | [diff] [blame] | 118 | bool ret_reply0; /* T if should return reply[0] on success */ |
David Howells | a68f4a2 | 2017-10-18 11:36:39 +0100 | [diff] [blame] | 119 | bool upgrade; /* T to request service upgrade */ |
David Howells | bf99a53 | 2017-11-02 15:27:51 +0000 | [diff] [blame] | 120 | u16 service_id; /* Actual service ID (after upgrade) */ |
David Howells | 50a2c95 | 2016-10-13 08:27:10 +0100 | [diff] [blame] | 121 | u32 operation_ID; /* operation ID for an incoming call */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 122 | u32 count; /* count for use in unmarshalling */ |
| 123 | __be32 tmp; /* place to extract temporary data */ |
David Howells | 31143d5 | 2007-05-09 02:33:46 -0700 | [diff] [blame] | 124 | afs_dataversion_t store_version; /* updated version expected from store */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 125 | }; |
| 126 | |
| 127 | struct afs_call_type { |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 128 | const char *name; |
David Howells | 025db80 | 2017-11-02 15:27:51 +0000 | [diff] [blame] | 129 | unsigned int op; /* Really enum afs_fs_operation */ |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 130 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 131 | /* deliver request or reply data to an call |
| 132 | * - returning an error will cause the call to be aborted |
| 133 | */ |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 134 | int (*deliver)(struct afs_call *call); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 135 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 136 | /* clean up a call */ |
| 137 | void (*destructor)(struct afs_call *call); |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 138 | |
| 139 | /* Work function */ |
| 140 | void (*work)(struct work_struct *work); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 141 | }; |
| 142 | |
| 143 | /* |
David Howells | 4343d00 | 2017-11-02 15:27:52 +0000 | [diff] [blame] | 144 | * Key available for writeback on a file. |
| 145 | */ |
| 146 | struct afs_wb_key { |
| 147 | refcount_t usage; |
| 148 | struct key *key; |
| 149 | struct list_head vnode_link; /* Link in vnode->wb_keys */ |
| 150 | }; |
| 151 | |
| 152 | /* |
David Howells | 215804a | 2017-11-02 15:27:52 +0000 | [diff] [blame] | 153 | * AFS open file information record. Pointed to by file->private_data. |
| 154 | */ |
| 155 | struct afs_file { |
| 156 | struct key *key; /* The key this file was opened with */ |
David Howells | 4343d00 | 2017-11-02 15:27:52 +0000 | [diff] [blame] | 157 | struct afs_wb_key *wb; /* Writeback key record for this file */ |
David Howells | 215804a | 2017-11-02 15:27:52 +0000 | [diff] [blame] | 158 | }; |
| 159 | |
| 160 | static inline struct key *afs_file_key(struct file *file) |
| 161 | { |
| 162 | struct afs_file *af = file->private_data; |
| 163 | |
| 164 | return af->key; |
| 165 | } |
| 166 | |
| 167 | /* |
David Howells | 196ee9c | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 168 | * Record of an outstanding read operation on a vnode. |
| 169 | */ |
| 170 | struct afs_read { |
| 171 | loff_t pos; /* Where to start reading */ |
David Howells | e8e581a | 2017-03-16 16:27:44 +0000 | [diff] [blame] | 172 | loff_t len; /* How much we're asking for */ |
David Howells | 196ee9c | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 173 | loff_t actual_len; /* How much we're actually getting */ |
David Howells | 6a0e399 | 2017-03-16 16:27:46 +0000 | [diff] [blame] | 174 | loff_t remain; /* Amount remaining */ |
David Howells | 196ee9c | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 175 | atomic_t usage; |
David Howells | 196ee9c | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 176 | unsigned int index; /* Which page we're reading into */ |
David Howells | 196ee9c | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 177 | unsigned int nr_pages; |
| 178 | void (*page_done)(struct afs_call *, struct afs_read *); |
| 179 | struct page *pages[]; |
| 180 | }; |
| 181 | |
| 182 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 183 | * AFS superblock private data |
| 184 | * - there's one superblock per volume |
| 185 | */ |
| 186 | struct afs_super_info { |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 187 | struct afs_net *net; /* Network namespace */ |
David Howells | 49566f6 | 2017-11-02 15:27:46 +0000 | [diff] [blame] | 188 | struct afs_cell *cell; /* The cell in which the volume resides */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 189 | struct afs_volume *volume; /* volume record */ |
David Howells | 4d673da | 2018-02-06 06:26:30 +0000 | [diff] [blame] | 190 | bool dyn_root; /* True if dynamic root */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 191 | }; |
| 192 | |
| 193 | static inline struct afs_super_info *AFS_FS_S(struct super_block *sb) |
| 194 | { |
| 195 | return sb->s_fs_info; |
| 196 | } |
| 197 | |
| 198 | extern struct file_system_type afs_fs_type; |
| 199 | |
| 200 | /* |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 201 | * AFS network namespace record. |
| 202 | */ |
| 203 | struct afs_net { |
| 204 | struct afs_uuid uuid; |
| 205 | bool live; /* F if this namespace is being removed */ |
| 206 | |
| 207 | /* AF_RXRPC I/O stuff */ |
| 208 | struct socket *socket; |
| 209 | struct afs_call *spare_incoming_call; |
| 210 | struct work_struct charge_preallocation_work; |
| 211 | struct mutex socket_mutex; |
| 212 | atomic_t nr_outstanding_calls; |
| 213 | atomic_t nr_superblocks; |
| 214 | |
| 215 | /* Cell database */ |
David Howells | 989782d | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 216 | struct rb_root cells; |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 217 | struct afs_cell *ws_cell; |
David Howells | 989782d | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 218 | struct work_struct cells_manager; |
| 219 | struct timer_list cells_timer; |
| 220 | atomic_t cells_outstanding; |
| 221 | seqlock_t cells_lock; |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 222 | |
David Howells | 989782d | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 223 | spinlock_t proc_cells_lock; |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 224 | struct list_head proc_cells; |
| 225 | |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 226 | /* Known servers. Theoretically each fileserver can only be in one |
| 227 | * cell, but in practice, people create aliases and subsets and there's |
| 228 | * no easy way to distinguish them. |
| 229 | */ |
| 230 | seqlock_t fs_lock; /* For fs_servers */ |
| 231 | struct rb_root fs_servers; /* afs_server (by server UUID or address) */ |
| 232 | struct list_head fs_updates; /* afs_server (by update_at) */ |
| 233 | struct hlist_head fs_proc; /* procfs servers list */ |
| 234 | |
| 235 | struct hlist_head fs_addresses4; /* afs_server (by lowest IPv4 addr) */ |
| 236 | struct hlist_head fs_addresses6; /* afs_server (by lowest IPv6 addr) */ |
| 237 | seqlock_t fs_addr_lock; /* For fs_addresses[46] */ |
| 238 | |
| 239 | struct work_struct fs_manager; |
| 240 | struct timer_list fs_timer; |
| 241 | atomic_t servers_outstanding; |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 242 | |
| 243 | /* File locking renewal management */ |
| 244 | struct mutex lock_manager_mutex; |
| 245 | |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 246 | /* Misc */ |
| 247 | struct proc_dir_entry *proc_afs; /* /proc/net/afs directory */ |
| 248 | }; |
| 249 | |
| 250 | extern struct afs_net __afs_net;// Dummy AFS network namespace; TODO: replace with real netns |
| 251 | |
David Howells | 989782d | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 252 | enum afs_cell_state { |
| 253 | AFS_CELL_UNSET, |
| 254 | AFS_CELL_ACTIVATING, |
| 255 | AFS_CELL_ACTIVE, |
| 256 | AFS_CELL_DEACTIVATING, |
| 257 | AFS_CELL_INACTIVE, |
| 258 | AFS_CELL_FAILED, |
| 259 | }; |
| 260 | |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 261 | /* |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 262 | * AFS cell record. |
| 263 | * |
| 264 | * This is a tricky concept to get right as it is possible to create aliases |
| 265 | * simply by pointing AFSDB/SRV records for two names at the same set of VL |
| 266 | * servers; it is also possible to do things like setting up two sets of VL |
| 267 | * servers, one of which provides a superset of the volumes provided by the |
| 268 | * other (for internal/external division, for example). |
| 269 | * |
| 270 | * Cells only exist in the sense that (a) a cell's name maps to a set of VL |
| 271 | * servers and (b) a cell's name is used by the client to select the key to use |
| 272 | * for authentication and encryption. The cell name is not typically used in |
| 273 | * the protocol. |
| 274 | * |
| 275 | * There is no easy way to determine if two cells are aliases or one is a |
| 276 | * subset of another. |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 277 | */ |
| 278 | struct afs_cell { |
David Howells | 989782d | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 279 | union { |
| 280 | struct rcu_head rcu; |
| 281 | struct rb_node net_node; /* Node in net->cells */ |
| 282 | }; |
| 283 | struct afs_net *net; |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 284 | struct key *anonymous_key; /* anonymous user key for this cell */ |
David Howells | 989782d | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 285 | struct work_struct manager; /* Manager for init/deinit/dns */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 286 | struct list_head proc_link; /* /proc cell list link */ |
David Howells | 9b3f26c | 2009-04-03 16:42:41 +0100 | [diff] [blame] | 287 | #ifdef CONFIG_AFS_FSCACHE |
| 288 | struct fscache_cookie *cache; /* caching cookie */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | #endif |
David Howells | 989782d | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 290 | time64_t dns_expiry; /* Time AFSDB/SRV record expires */ |
| 291 | time64_t last_inactive; /* Time of last drop of usage count */ |
| 292 | atomic_t usage; |
| 293 | unsigned long flags; |
| 294 | #define AFS_CELL_FL_NOT_READY 0 /* The cell record is not ready for use */ |
| 295 | #define AFS_CELL_FL_NO_GC 1 /* The cell was added manually, don't auto-gc */ |
| 296 | #define AFS_CELL_FL_NOT_FOUND 2 /* Permanent DNS error */ |
| 297 | #define AFS_CELL_FL_DNS_FAIL 3 /* Failed to access DNS */ |
David Howells | 8b2a464 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 298 | #define AFS_CELL_FL_NO_LOOKUP_YET 4 /* Not completed first DNS lookup yet */ |
David Howells | 989782d | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 299 | enum afs_cell_state state; |
| 300 | short error; |
| 301 | |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 302 | /* Active fileserver interaction state. */ |
| 303 | struct list_head proc_volumes; /* procfs volume list */ |
| 304 | rwlock_t proc_lock; |
David Howells | 989782d | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 305 | |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 306 | /* VL server list. */ |
David Howells | 8b2a464 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 307 | rwlock_t vl_addrs_lock; /* Lock on vl_addrs */ |
| 308 | struct afs_addr_list __rcu *vl_addrs; /* List of VL servers */ |
David Howells | 989782d | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 309 | u8 name_len; /* Length of name */ |
| 310 | char name[64 + 1]; /* Cell name, case-flattened and NUL-padded */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 311 | }; |
| 312 | |
| 313 | /* |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 314 | * Cached VLDB entry. |
| 315 | * |
| 316 | * This is pointed to by cell->vldb_entries, indexed by name. |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 317 | */ |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 318 | struct afs_vldb_entry { |
| 319 | afs_volid_t vid[3]; /* Volume IDs for R/W, R/O and Bak volumes */ |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 320 | |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 321 | unsigned long flags; |
| 322 | #define AFS_VLDB_HAS_RW 0 /* - R/W volume exists */ |
| 323 | #define AFS_VLDB_HAS_RO 1 /* - R/O volume exists */ |
| 324 | #define AFS_VLDB_HAS_BAK 2 /* - Backup volume exists */ |
| 325 | #define AFS_VLDB_QUERY_VALID 3 /* - Record is valid */ |
| 326 | #define AFS_VLDB_QUERY_ERROR 4 /* - VL server returned error */ |
| 327 | |
| 328 | uuid_t fs_server[AFS_NMAXNSERVERS]; |
| 329 | u8 fs_mask[AFS_NMAXNSERVERS]; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 330 | #define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */ |
| 331 | #define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */ |
| 332 | #define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */ |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 333 | short error; |
| 334 | u8 nr_servers; /* Number of server records */ |
| 335 | u8 name_len; |
| 336 | u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 337 | }; |
| 338 | |
| 339 | /* |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 340 | * Record of fileserver with which we're actively communicating. |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 341 | */ |
| 342 | struct afs_server { |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 343 | struct rcu_head rcu; |
| 344 | union { |
| 345 | uuid_t uuid; /* Server ID */ |
| 346 | struct afs_uuid _uuid; |
| 347 | }; |
David Howells | c435ee3 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 348 | |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 349 | struct afs_addr_list __rcu *addresses; |
| 350 | struct rb_node uuid_rb; /* Link in net->servers */ |
| 351 | struct hlist_node addr4_link; /* Link in net->fs_addresses4 */ |
| 352 | struct hlist_node addr6_link; /* Link in net->fs_addresses6 */ |
| 353 | struct hlist_node proc_link; /* Link in net->fs_proc */ |
| 354 | struct afs_server *gc_next; /* Next server in manager's list */ |
| 355 | time64_t put_time; /* Time at which last put */ |
| 356 | time64_t update_at; /* Time at which to next update the record */ |
David Howells | c435ee3 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 357 | unsigned long flags; |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 358 | #define AFS_SERVER_FL_NEW 0 /* New server, don't inc cb_s_break */ |
| 359 | #define AFS_SERVER_FL_NOT_READY 1 /* The record is not ready for use */ |
| 360 | #define AFS_SERVER_FL_NOT_FOUND 2 /* VL server says no such server */ |
| 361 | #define AFS_SERVER_FL_VL_FAIL 3 /* Failed to access VL server */ |
| 362 | #define AFS_SERVER_FL_UPDATING 4 |
| 363 | #define AFS_SERVER_FL_PROBED 5 /* The fileserver has been probed */ |
| 364 | #define AFS_SERVER_FL_PROBING 6 /* Fileserver is being probed */ |
| 365 | atomic_t usage; |
| 366 | u32 addr_version; /* Address list version */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 367 | |
| 368 | /* file service access */ |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 369 | rwlock_t fs_lock; /* access lock */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 370 | |
| 371 | /* callback promise management */ |
David Howells | c435ee3 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 372 | struct list_head cb_interests; /* List of superblocks using this server */ |
| 373 | unsigned cb_s_break; /* Break-everything counter. */ |
| 374 | rwlock_t cb_break_lock; /* Volume finding lock */ |
| 375 | }; |
| 376 | |
| 377 | /* |
| 378 | * Interest by a superblock on a server. |
| 379 | */ |
| 380 | struct afs_cb_interest { |
| 381 | struct list_head cb_link; /* Link in server->cb_interests */ |
| 382 | struct afs_server *server; /* Server on which this interest resides */ |
| 383 | struct super_block *sb; /* Superblock on which inodes reside */ |
| 384 | afs_volid_t vid; /* Volume ID to match */ |
| 385 | refcount_t usage; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 386 | }; |
| 387 | |
| 388 | /* |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 389 | * Replaceable server list. |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 390 | */ |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 391 | struct afs_server_entry { |
| 392 | struct afs_server *server; |
| 393 | struct afs_cb_interest *cb_interest; |
| 394 | }; |
| 395 | |
| 396 | struct afs_server_list { |
| 397 | refcount_t usage; |
| 398 | unsigned short nr_servers; |
| 399 | unsigned short index; /* Server currently in use */ |
| 400 | unsigned short vnovol_mask; /* Servers to be skipped due to VNOVOL */ |
| 401 | unsigned int seq; /* Set to ->servers_seq when installed */ |
| 402 | struct afs_server_entry servers[]; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 403 | }; |
| 404 | |
| 405 | /* |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 406 | * Live AFS volume management. |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 407 | */ |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 408 | struct afs_volume { |
| 409 | afs_volid_t vid; /* volume ID */ |
| 410 | atomic_t usage; |
| 411 | time64_t update_at; /* Time at which to next update */ |
| 412 | struct afs_cell *cell; /* Cell to which belongs (pins ref) */ |
| 413 | struct list_head proc_link; /* Link in cell->vl_proc */ |
| 414 | unsigned long flags; |
| 415 | #define AFS_VOLUME_NEEDS_UPDATE 0 /* - T if an update needs performing */ |
| 416 | #define AFS_VOLUME_UPDATING 1 /* - T if an update is in progress */ |
| 417 | #define AFS_VOLUME_WAIT 2 /* - T if users must wait for update */ |
| 418 | #define AFS_VOLUME_DELETED 3 /* - T if volume appears deleted */ |
| 419 | #define AFS_VOLUME_OFFLINE 4 /* - T if volume offline notice given */ |
| 420 | #define AFS_VOLUME_BUSY 5 /* - T if volume busy notice given */ |
| 421 | #ifdef CONFIG_AFS_FSCACHE |
| 422 | struct fscache_cookie *cache; /* caching cookie */ |
| 423 | #endif |
| 424 | struct afs_server_list *servers; /* List of servers on which volume resides */ |
| 425 | rwlock_t servers_lock; /* Lock for ->servers */ |
| 426 | unsigned int servers_seq; /* Incremented each time ->servers changes */ |
| 427 | |
| 428 | afs_voltype_t type; /* type of volume */ |
| 429 | short error; |
| 430 | char type_force; /* force volume type (suppress R/O -> R/W) */ |
| 431 | u8 name_len; |
| 432 | u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 433 | }; |
| 434 | |
David Howells | 0fafdc9 | 2017-11-13 16:59:50 +0000 | [diff] [blame] | 435 | enum afs_lock_state { |
| 436 | AFS_VNODE_LOCK_NONE, /* The vnode has no lock on the server */ |
| 437 | AFS_VNODE_LOCK_WAITING_FOR_CB, /* We're waiting for the server to break the callback */ |
| 438 | AFS_VNODE_LOCK_SETTING, /* We're asking the server for a lock */ |
| 439 | AFS_VNODE_LOCK_GRANTED, /* We have a lock on the server */ |
| 440 | AFS_VNODE_LOCK_EXTENDING, /* We're extending a lock on the server */ |
| 441 | AFS_VNODE_LOCK_NEED_UNLOCK, /* We need to unlock on the server */ |
| 442 | AFS_VNODE_LOCK_UNLOCKING, /* We're telling the server to unlock */ |
| 443 | }; |
| 444 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 445 | /* |
David Howells | f8de483 | 2017-12-01 11:40:43 +0000 | [diff] [blame] | 446 | * AFS inode private data. |
| 447 | * |
| 448 | * Note that afs_alloc_inode() *must* reset anything that could incorrectly |
| 449 | * leak from one inode to another. |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 450 | */ |
| 451 | struct afs_vnode { |
| 452 | struct inode vfs_inode; /* the VFS's inode record */ |
| 453 | |
| 454 | struct afs_volume *volume; /* volume on which vnode resides */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 455 | struct afs_fid fid; /* the file identifier for this inode */ |
| 456 | struct afs_file_status status; /* AFS status info for this file */ |
David Howells | 9b3f26c | 2009-04-03 16:42:41 +0100 | [diff] [blame] | 457 | #ifdef CONFIG_AFS_FSCACHE |
| 458 | struct fscache_cookie *cache; /* caching cookie */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 459 | #endif |
David Howells | be080a6 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 460 | struct afs_permits *permit_cache; /* cache of permits so far obtained */ |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 461 | struct mutex io_lock; /* Lock for serialising I/O on this mutex */ |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 462 | struct mutex validate_lock; /* lock for validating this vnode */ |
David Howells | 4343d00 | 2017-11-02 15:27:52 +0000 | [diff] [blame] | 463 | spinlock_t wb_lock; /* lock for wb_keys */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 464 | spinlock_t lock; /* waitqueue/flags lock */ |
| 465 | unsigned long flags; |
David Howells | c435ee3 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 466 | #define AFS_VNODE_CB_PROMISED 0 /* Set if vnode has a callback promise */ |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 467 | #define AFS_VNODE_UNSET 1 /* set if vnode attributes not yet set */ |
David Howells | c435ee3 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 468 | #define AFS_VNODE_DIR_MODIFIED 2 /* set if dir vnode's data modified */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 469 | #define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */ |
| 470 | #define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */ |
| 471 | #define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */ |
David Howells | 0fafdc9 | 2017-11-13 16:59:50 +0000 | [diff] [blame] | 472 | #define AFS_VNODE_AUTOCELL 6 /* set if Vnode is an auto mount point */ |
| 473 | #define AFS_VNODE_PSEUDODIR 7 /* set if Vnode is a pseudo directory */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 474 | |
David Howells | 4343d00 | 2017-11-02 15:27:52 +0000 | [diff] [blame] | 475 | struct list_head wb_keys; /* List of keys available for writeback */ |
David Howells | e8d6c55 | 2007-07-15 23:40:12 -0700 | [diff] [blame] | 476 | struct list_head pending_locks; /* locks waiting to be granted */ |
| 477 | struct list_head granted_locks; /* locks granted on this file */ |
| 478 | struct delayed_work lock_work; /* work to be done in locking */ |
David Howells | 0fafdc9 | 2017-11-13 16:59:50 +0000 | [diff] [blame] | 479 | struct key *lock_key; /* Key to be used in lock ops */ |
| 480 | enum afs_lock_state lock_state : 8; |
| 481 | afs_lock_type_t lock_type : 8; |
David Howells | 31143d5 | 2007-05-09 02:33:46 -0700 | [diff] [blame] | 482 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 483 | /* outstanding callback notification on this file */ |
David Howells | c435ee3 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 484 | struct afs_cb_interest *cb_interest; /* Server on which this resides */ |
| 485 | unsigned int cb_s_break; /* Mass break counter on ->server */ |
| 486 | unsigned int cb_break; /* Break counter on vnode */ |
| 487 | seqlock_t cb_lock; /* Lock for ->cb_interest, ->status, ->cb_*break */ |
| 488 | |
| 489 | time64_t cb_expires_at; /* time at which callback expires */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 490 | unsigned cb_version; /* callback version */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 491 | afs_callback_type_t cb_type; /* type of callback */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 492 | }; |
| 493 | |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 494 | /* |
| 495 | * cached security record for one user's attempt to access a vnode |
| 496 | */ |
| 497 | struct afs_permit { |
| 498 | struct key *key; /* RxRPC ticket holding a security context */ |
David Howells | be080a6 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 499 | afs_access_t access; /* CallerAccess value for this key */ |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 500 | }; |
| 501 | |
| 502 | /* |
David Howells | be080a6 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 503 | * Immutable cache of CallerAccess records from attempts to access vnodes. |
| 504 | * These may be shared between multiple vnodes. |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 505 | */ |
| 506 | struct afs_permits { |
David Howells | be080a6 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 507 | struct rcu_head rcu; |
| 508 | struct hlist_node hash_node; /* Link in hash */ |
| 509 | unsigned long h; /* Hash value for this permit list */ |
| 510 | refcount_t usage; |
| 511 | unsigned short nr_permits; /* Number of records */ |
| 512 | bool invalidated; /* Invalidated due to key change */ |
| 513 | struct afs_permit permits[]; /* List of permits sorted by key pointer */ |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 514 | }; |
| 515 | |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 516 | /* |
| 517 | * record of one of a system's set of network interfaces |
| 518 | */ |
| 519 | struct afs_interface { |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 520 | struct in_addr address; /* IPv4 address bound to interface */ |
| 521 | struct in_addr netmask; /* netmask applied to address */ |
| 522 | unsigned mtu; /* MTU of interface */ |
| 523 | }; |
| 524 | |
David Howells | 8b2a464 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 525 | /* |
| 526 | * Cursor for iterating over a server's address list. |
| 527 | */ |
| 528 | struct afs_addr_cursor { |
| 529 | struct afs_addr_list *alist; /* Current address list (pins ref) */ |
| 530 | struct sockaddr_rxrpc *addr; |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 531 | u32 abort_code; |
David Howells | 8b2a464 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 532 | unsigned short start; /* Starting point in alist->addrs[] */ |
| 533 | unsigned short index; /* Wrapping offset from start to current addr */ |
| 534 | short error; |
| 535 | bool begun; /* T if we've begun iteration */ |
| 536 | bool responded; /* T if the current address responded */ |
| 537 | }; |
| 538 | |
| 539 | /* |
| 540 | * Cursor for iterating over a set of fileservers. |
| 541 | */ |
| 542 | struct afs_fs_cursor { |
| 543 | struct afs_addr_cursor ac; |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 544 | struct afs_vnode *vnode; |
| 545 | struct afs_server_list *server_list; /* Current server list (pins ref) */ |
| 546 | struct afs_cb_interest *cbi; /* Server on which this resides (pins ref) */ |
| 547 | struct key *key; /* Key for the server */ |
| 548 | unsigned int cb_break; /* cb_break + cb_s_break before the call */ |
| 549 | unsigned int cb_break_2; /* cb_break + cb_s_break (2nd vnode) */ |
| 550 | unsigned char start; /* Initial index in server list */ |
| 551 | unsigned char index; /* Number of servers tried beyond start */ |
| 552 | unsigned short flags; |
| 553 | #define AFS_FS_CURSOR_STOP 0x0001 /* Set to cease iteration */ |
| 554 | #define AFS_FS_CURSOR_VBUSY 0x0002 /* Set if seen VBUSY */ |
| 555 | #define AFS_FS_CURSOR_VMOVED 0x0004 /* Set if seen VMOVED */ |
| 556 | #define AFS_FS_CURSOR_VNOVOL 0x0008 /* Set if seen VNOVOL */ |
| 557 | #define AFS_FS_CURSOR_CUR_ONLY 0x0010 /* Set if current server only (file lock held) */ |
| 558 | #define AFS_FS_CURSOR_NO_VSLEEP 0x0020 /* Set to prevent sleep on VBUSY, VOFFLINE, ... */ |
David Howells | 8b2a464 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 559 | }; |
| 560 | |
David Howells | 98bf40c | 2017-11-02 15:27:53 +0000 | [diff] [blame] | 561 | #include <trace/events/afs.h> |
| 562 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 563 | /*****************************************************************************/ |
| 564 | /* |
David Howells | 8b2a464 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 565 | * addr_list.c |
| 566 | */ |
| 567 | static inline struct afs_addr_list *afs_get_addrlist(struct afs_addr_list *alist) |
| 568 | { |
| 569 | if (alist) |
| 570 | refcount_inc(&alist->usage); |
| 571 | return alist; |
| 572 | } |
| 573 | extern struct afs_addr_list *afs_alloc_addrlist(unsigned int, |
| 574 | unsigned short, |
| 575 | unsigned short); |
| 576 | extern void afs_put_addrlist(struct afs_addr_list *); |
| 577 | extern struct afs_addr_list *afs_parse_text_addrs(const char *, size_t, char, |
| 578 | unsigned short, unsigned short); |
| 579 | extern struct afs_addr_list *afs_dns_query(struct afs_cell *, time64_t *); |
| 580 | extern bool afs_iterate_addresses(struct afs_addr_cursor *); |
| 581 | extern int afs_end_cursor(struct afs_addr_cursor *); |
| 582 | extern int afs_set_vl_cursor(struct afs_addr_cursor *, struct afs_cell *); |
| 583 | |
David Howells | bf99a53 | 2017-11-02 15:27:51 +0000 | [diff] [blame] | 584 | extern void afs_merge_fs_addr4(struct afs_addr_list *, __be32, u16); |
| 585 | extern void afs_merge_fs_addr6(struct afs_addr_list *, __be32 *, u16); |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 586 | |
David Howells | 8b2a464 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 587 | /* |
David Howells | 9b3f26c | 2009-04-03 16:42:41 +0100 | [diff] [blame] | 588 | * cache.c |
| 589 | */ |
| 590 | #ifdef CONFIG_AFS_FSCACHE |
| 591 | extern struct fscache_netfs afs_cache_netfs; |
| 592 | extern struct fscache_cookie_def afs_cell_cache_index_def; |
David Howells | 9b3f26c | 2009-04-03 16:42:41 +0100 | [diff] [blame] | 593 | extern struct fscache_cookie_def afs_volume_cache_index_def; |
| 594 | extern struct fscache_cookie_def afs_vnode_cache_index_def; |
| 595 | #else |
| 596 | #define afs_cell_cache_index_def (*(struct fscache_cookie_def *) NULL) |
David Howells | 9b3f26c | 2009-04-03 16:42:41 +0100 | [diff] [blame] | 597 | #define afs_volume_cache_index_def (*(struct fscache_cookie_def *) NULL) |
| 598 | #define afs_vnode_cache_index_def (*(struct fscache_cookie_def *) NULL) |
| 599 | #endif |
| 600 | |
| 601 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 602 | * callback.c |
| 603 | */ |
| 604 | extern void afs_init_callback_state(struct afs_server *); |
David Howells | c435ee3 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 605 | extern void afs_break_callback(struct afs_vnode *); |
| 606 | extern void afs_break_callbacks(struct afs_server *, size_t,struct afs_callback[]); |
| 607 | |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 608 | extern int afs_register_server_cb_interest(struct afs_vnode *, struct afs_server_entry *); |
David Howells | c435ee3 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 609 | extern void afs_put_cb_interest(struct afs_net *, struct afs_cb_interest *); |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 610 | extern void afs_clear_callback_interests(struct afs_net *, struct afs_server_list *); |
David Howells | c435ee3 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 611 | |
| 612 | static inline struct afs_cb_interest *afs_get_cb_interest(struct afs_cb_interest *cbi) |
| 613 | { |
| 614 | refcount_inc(&cbi->usage); |
| 615 | return cbi; |
| 616 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | |
| 618 | /* |
| 619 | * cell.c |
| 620 | */ |
David Howells | 989782d | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 621 | extern int afs_cell_init(struct afs_net *, const char *); |
| 622 | extern struct afs_cell *afs_lookup_cell_rcu(struct afs_net *, const char *, unsigned); |
| 623 | extern struct afs_cell *afs_lookup_cell(struct afs_net *, const char *, unsigned, |
| 624 | const char *, bool); |
David Howells | 8b2a464 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 625 | extern struct afs_cell *afs_get_cell(struct afs_cell *); |
David Howells | 9ed900b | 2017-11-02 15:27:46 +0000 | [diff] [blame] | 626 | extern void afs_put_cell(struct afs_net *, struct afs_cell *); |
David Howells | 989782d | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 627 | extern void afs_manage_cells(struct work_struct *); |
| 628 | extern void afs_cells_timer(struct timer_list *); |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 629 | extern void __net_exit afs_cell_purge(struct afs_net *); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 630 | |
| 631 | /* |
| 632 | * cmservice.c |
| 633 | */ |
| 634 | extern bool afs_cm_incoming_call(struct afs_call *); |
| 635 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | /* |
| 637 | * dir.c |
| 638 | */ |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 639 | extern const struct file_operations afs_dir_file_operations; |
David Howells | 4d673da | 2018-02-06 06:26:30 +0000 | [diff] [blame] | 640 | extern const struct inode_operations afs_dir_inode_operations; |
| 641 | extern const struct file_operations afs_dynroot_file_operations; |
| 642 | extern const struct inode_operations afs_dynroot_inode_operations; |
| 643 | extern const struct dentry_operations afs_fs_dentry_operations; |
| 644 | |
| 645 | extern bool afs_dir_check_page(struct inode *, struct page *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | |
| 647 | /* |
| 648 | * file.c |
| 649 | */ |
Christoph Hellwig | f5e54d6 | 2006-06-28 04:26:44 -0700 | [diff] [blame] | 650 | extern const struct address_space_operations afs_fs_aops; |
Arjan van de Ven | 754661f | 2007-02-12 00:55:38 -0800 | [diff] [blame] | 651 | extern const struct inode_operations afs_file_inode_operations; |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 652 | extern const struct file_operations afs_file_operations; |
| 653 | |
David Howells | 4343d00 | 2017-11-02 15:27:52 +0000 | [diff] [blame] | 654 | extern int afs_cache_wb_key(struct afs_vnode *, struct afs_file *); |
| 655 | extern void afs_put_wb_key(struct afs_wb_key *); |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 656 | extern int afs_open(struct inode *, struct file *); |
| 657 | extern int afs_release(struct inode *, struct file *); |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 658 | extern int afs_fetch_data(struct afs_vnode *, struct key *, struct afs_read *); |
Al Viro | f6d335c | 2010-05-21 15:27:09 +0100 | [diff] [blame] | 659 | extern int afs_page_filler(void *, struct page *); |
David Howells | 196ee9c | 2017-01-05 10:38:34 +0000 | [diff] [blame] | 660 | extern void afs_put_read(struct afs_read *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | /* |
David Howells | e8d6c55 | 2007-07-15 23:40:12 -0700 | [diff] [blame] | 663 | * flock.c |
| 664 | */ |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 665 | extern struct workqueue_struct *afs_lock_manager; |
| 666 | |
David Howells | e8d6c55 | 2007-07-15 23:40:12 -0700 | [diff] [blame] | 667 | extern void afs_lock_work(struct work_struct *); |
| 668 | extern void afs_lock_may_be_available(struct afs_vnode *); |
| 669 | extern int afs_lock(struct file *, int, struct file_lock *); |
| 670 | extern int afs_flock(struct file *, int, struct file_lock *); |
| 671 | |
| 672 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 673 | * fsclient.c |
| 674 | */ |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 675 | extern int afs_fs_fetch_file_status(struct afs_fs_cursor *, struct afs_volsync *); |
| 676 | extern int afs_fs_give_up_callbacks(struct afs_net *, struct afs_server *); |
| 677 | extern int afs_fs_fetch_data(struct afs_fs_cursor *, struct afs_read *); |
| 678 | extern int afs_fs_create(struct afs_fs_cursor *, const char *, umode_t, |
| 679 | struct afs_fid *, struct afs_file_status *, struct afs_callback *); |
| 680 | extern int afs_fs_remove(struct afs_fs_cursor *, const char *, bool); |
| 681 | extern int afs_fs_link(struct afs_fs_cursor *, struct afs_vnode *, const char *); |
| 682 | extern int afs_fs_symlink(struct afs_fs_cursor *, const char *, const char *, |
| 683 | struct afs_fid *, struct afs_file_status *); |
| 684 | extern int afs_fs_rename(struct afs_fs_cursor *, const char *, |
| 685 | struct afs_vnode *, const char *); |
David Howells | 4343d00 | 2017-11-02 15:27:52 +0000 | [diff] [blame] | 686 | extern int afs_fs_store_data(struct afs_fs_cursor *, struct address_space *, |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 687 | pgoff_t, pgoff_t, unsigned, unsigned); |
| 688 | extern int afs_fs_setattr(struct afs_fs_cursor *, struct iattr *); |
| 689 | extern int afs_fs_get_volume_status(struct afs_fs_cursor *, struct afs_volume_status *); |
| 690 | extern int afs_fs_set_lock(struct afs_fs_cursor *, afs_lock_type_t); |
| 691 | extern int afs_fs_extend_lock(struct afs_fs_cursor *); |
| 692 | extern int afs_fs_release_lock(struct afs_fs_cursor *); |
| 693 | extern int afs_fs_give_up_all_callbacks(struct afs_net *, struct afs_server *, |
| 694 | struct afs_addr_cursor *, struct key *); |
| 695 | extern int afs_fs_get_capabilities(struct afs_net *, struct afs_server *, |
| 696 | struct afs_addr_cursor *, struct key *); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 697 | |
| 698 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | * inode.c |
| 700 | */ |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 701 | extern int afs_fetch_status(struct afs_vnode *, struct key *); |
David Howells | c435ee3 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 702 | extern int afs_iget5_test(struct inode *, void *); |
David Howells | 4d673da | 2018-02-06 06:26:30 +0000 | [diff] [blame] | 703 | extern struct inode *afs_iget_pseudo_dir(struct super_block *, bool); |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 704 | extern struct inode *afs_iget(struct super_block *, struct key *, |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 705 | struct afs_fid *, struct afs_file_status *, |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 706 | struct afs_callback *, |
| 707 | struct afs_cb_interest *); |
David Howells | 416351f | 2007-05-09 02:33:45 -0700 | [diff] [blame] | 708 | extern void afs_zap_data(struct afs_vnode *); |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 709 | extern int afs_validate(struct afs_vnode *, struct key *); |
David Howells | a528d35 | 2017-01-31 16:46:22 +0000 | [diff] [blame] | 710 | extern int afs_getattr(const struct path *, struct kstat *, u32, unsigned int); |
David Howells | 31143d5 | 2007-05-09 02:33:46 -0700 | [diff] [blame] | 711 | extern int afs_setattr(struct dentry *, struct iattr *); |
Al Viro | b57922d | 2010-06-07 14:34:48 -0400 | [diff] [blame] | 712 | extern void afs_evict_inode(struct inode *); |
wanglei | bec5eb6 | 2010-08-11 09:38:04 +0100 | [diff] [blame] | 713 | extern int afs_drop_inode(struct inode *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | |
| 715 | /* |
| 716 | * main.c |
| 717 | */ |
Tejun Heo | 0ad53ee | 2011-01-14 15:56:37 +0000 | [diff] [blame] | 718 | extern struct workqueue_struct *afs_wq; |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 719 | |
| 720 | static inline struct afs_net *afs_d2net(struct dentry *dentry) |
| 721 | { |
| 722 | return &__afs_net; |
| 723 | } |
| 724 | |
| 725 | static inline struct afs_net *afs_i2net(struct inode *inode) |
| 726 | { |
| 727 | return &__afs_net; |
| 728 | } |
| 729 | |
| 730 | static inline struct afs_net *afs_v2net(struct afs_vnode *vnode) |
| 731 | { |
| 732 | return &__afs_net; |
| 733 | } |
| 734 | |
| 735 | static inline struct afs_net *afs_sock2net(struct sock *sk) |
| 736 | { |
| 737 | return &__afs_net; |
| 738 | } |
| 739 | |
| 740 | static inline struct afs_net *afs_get_net(struct afs_net *net) |
| 741 | { |
| 742 | return net; |
| 743 | } |
| 744 | |
| 745 | static inline void afs_put_net(struct afs_net *net) |
| 746 | { |
| 747 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 748 | |
| 749 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 750 | * misc.c |
| 751 | */ |
| 752 | extern int afs_abort_to_error(u32); |
| 753 | |
| 754 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 755 | * mntpt.c |
| 756 | */ |
Arjan van de Ven | 754661f | 2007-02-12 00:55:38 -0800 | [diff] [blame] | 757 | extern const struct inode_operations afs_mntpt_inode_operations; |
wanglei | bec5eb6 | 2010-08-11 09:38:04 +0100 | [diff] [blame] | 758 | extern const struct inode_operations afs_autocell_inode_operations; |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 759 | extern const struct file_operations afs_mntpt_file_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 760 | |
David Howells | d18610b | 2011-01-14 19:04:05 +0000 | [diff] [blame] | 761 | extern struct vfsmount *afs_d_automount(struct path *); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 762 | extern void afs_mntpt_kill_timer(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | |
| 764 | /* |
Arnd Bergmann | b4db2b3 | 2017-02-10 16:34:07 +0000 | [diff] [blame] | 765 | * netdevices.c |
| 766 | */ |
| 767 | extern int afs_get_ipv4_interfaces(struct afs_interface *, size_t, bool); |
| 768 | |
| 769 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 | * proc.c |
| 771 | */ |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 772 | extern int __net_init afs_proc_init(struct afs_net *); |
| 773 | extern void __net_exit afs_proc_cleanup(struct afs_net *); |
| 774 | extern int afs_proc_cell_setup(struct afs_net *, struct afs_cell *); |
| 775 | extern void afs_proc_cell_remove(struct afs_net *, struct afs_cell *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 776 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 777 | /* |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 778 | * rotate.c |
| 779 | */ |
| 780 | extern bool afs_begin_vnode_operation(struct afs_fs_cursor *, struct afs_vnode *, |
| 781 | struct key *); |
| 782 | extern bool afs_select_fileserver(struct afs_fs_cursor *); |
| 783 | extern bool afs_select_current_fileserver(struct afs_fs_cursor *); |
| 784 | extern int afs_end_vnode_operation(struct afs_fs_cursor *); |
| 785 | |
| 786 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 787 | * rxrpc.c |
| 788 | */ |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 789 | extern struct workqueue_struct *afs_async_calls; |
David Howells | 8324f0b | 2016-08-30 09:49:29 +0100 | [diff] [blame] | 790 | |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 791 | extern int __net_init afs_open_socket(struct afs_net *); |
| 792 | extern void __net_exit afs_close_socket(struct afs_net *); |
| 793 | extern void afs_charge_preallocation(struct work_struct *); |
David Howells | 341f741 | 2017-01-05 10:38:36 +0000 | [diff] [blame] | 794 | extern void afs_put_call(struct afs_call *); |
| 795 | extern int afs_queue_call_work(struct afs_call *); |
David Howells | 8b2a464 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 796 | extern long afs_make_call(struct afs_addr_cursor *, struct afs_call *, gfp_t, bool); |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 797 | extern struct afs_call *afs_alloc_flat_call(struct afs_net *, |
| 798 | const struct afs_call_type *, |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 799 | size_t, size_t); |
| 800 | extern void afs_flat_call_destructor(struct afs_call *); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 801 | extern void afs_send_empty_reply(struct afs_call *); |
David Howells | b908fe6 | 2007-04-26 15:58:17 -0700 | [diff] [blame] | 802 | extern void afs_send_simple_reply(struct afs_call *, const void *, size_t); |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 803 | extern int afs_extract_data(struct afs_call *, void *, size_t, bool); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 804 | |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 805 | static inline int afs_transfer_reply(struct afs_call *call) |
David Howells | 372ee16 | 2016-08-03 14:11:40 +0100 | [diff] [blame] | 806 | { |
David Howells | d001648 | 2016-08-30 20:42:14 +0100 | [diff] [blame] | 807 | return afs_extract_data(call, call->buffer, call->reply_max, false); |
David Howells | 372ee16 | 2016-08-03 14:11:40 +0100 | [diff] [blame] | 808 | } |
| 809 | |
David Howells | 98bf40c | 2017-11-02 15:27:53 +0000 | [diff] [blame] | 810 | static inline bool afs_check_call_state(struct afs_call *call, |
| 811 | enum afs_call_state state) |
| 812 | { |
| 813 | return READ_ONCE(call->state) == state; |
| 814 | } |
| 815 | |
| 816 | static inline bool afs_set_call_state(struct afs_call *call, |
| 817 | enum afs_call_state from, |
| 818 | enum afs_call_state to) |
| 819 | { |
| 820 | bool ok = false; |
| 821 | |
| 822 | spin_lock_bh(&call->state_lock); |
| 823 | if (call->state == from) { |
| 824 | call->state = to; |
| 825 | trace_afs_call_state(call, from, to, 0, 0); |
| 826 | ok = true; |
| 827 | } |
| 828 | spin_unlock_bh(&call->state_lock); |
| 829 | return ok; |
| 830 | } |
| 831 | |
| 832 | static inline void afs_set_call_complete(struct afs_call *call, |
| 833 | int error, u32 remote_abort) |
| 834 | { |
| 835 | enum afs_call_state state; |
| 836 | bool ok = false; |
| 837 | |
| 838 | spin_lock_bh(&call->state_lock); |
| 839 | state = call->state; |
| 840 | if (state != AFS_CALL_COMPLETE) { |
| 841 | call->abort_code = remote_abort; |
| 842 | call->error = error; |
| 843 | call->state = AFS_CALL_COMPLETE; |
| 844 | trace_afs_call_state(call, state, AFS_CALL_COMPLETE, |
| 845 | error, remote_abort); |
| 846 | ok = true; |
| 847 | } |
| 848 | spin_unlock_bh(&call->state_lock); |
| 849 | if (ok) |
| 850 | trace_afs_call_done(call); |
| 851 | } |
| 852 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 853 | /* |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 854 | * security.c |
| 855 | */ |
David Howells | be080a6 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 856 | extern void afs_put_permits(struct afs_permits *); |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 857 | extern void afs_clear_permits(struct afs_vnode *); |
David Howells | be080a6 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 858 | extern void afs_cache_permit(struct afs_vnode *, struct key *, unsigned int); |
David Howells | 416351f | 2007-05-09 02:33:45 -0700 | [diff] [blame] | 859 | extern void afs_zap_permits(struct rcu_head *); |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 860 | extern struct key *afs_request_key(struct afs_cell *); |
David Howells | 0fafdc9 | 2017-11-13 16:59:50 +0000 | [diff] [blame] | 861 | extern int afs_check_permit(struct afs_vnode *, struct key *, afs_access_t *); |
Al Viro | 10556cb2 | 2011-06-20 19:28:19 -0400 | [diff] [blame] | 862 | extern int afs_permission(struct inode *, int); |
David Howells | be080a6 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 863 | extern void __exit afs_clean_up_permit_cache(void); |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 864 | |
| 865 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 866 | * server.c |
| 867 | */ |
| 868 | extern spinlock_t afs_server_peer_lock; |
| 869 | |
David Howells | c435ee3 | 2017-11-02 15:27:49 +0000 | [diff] [blame] | 870 | static inline struct afs_server *afs_get_server(struct afs_server *server) |
| 871 | { |
| 872 | atomic_inc(&server->usage); |
| 873 | return server; |
| 874 | } |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 875 | |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 876 | extern struct afs_server *afs_find_server(struct afs_net *, |
| 877 | const struct sockaddr_rxrpc *); |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 878 | extern struct afs_server *afs_find_server_by_uuid(struct afs_net *, const uuid_t *); |
| 879 | extern struct afs_server *afs_lookup_server(struct afs_cell *, struct key *, const uuid_t *); |
David Howells | 9ed900b | 2017-11-02 15:27:46 +0000 | [diff] [blame] | 880 | extern void afs_put_server(struct afs_net *, struct afs_server *); |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 881 | extern void afs_manage_servers(struct work_struct *); |
| 882 | extern void afs_servers_timer(struct timer_list *); |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 883 | extern void __net_exit afs_purge_servers(struct afs_net *); |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 884 | extern bool afs_probe_fileserver(struct afs_fs_cursor *); |
| 885 | extern bool afs_check_server_record(struct afs_fs_cursor *, struct afs_server *); |
| 886 | |
| 887 | /* |
| 888 | * server_list.c |
| 889 | */ |
| 890 | static inline struct afs_server_list *afs_get_serverlist(struct afs_server_list *slist) |
| 891 | { |
| 892 | refcount_inc(&slist->usage); |
| 893 | return slist; |
| 894 | } |
| 895 | |
| 896 | extern void afs_put_serverlist(struct afs_net *, struct afs_server_list *); |
| 897 | extern struct afs_server_list *afs_alloc_server_list(struct afs_cell *, struct key *, |
| 898 | struct afs_vldb_entry *, |
| 899 | u8); |
| 900 | extern bool afs_annotate_server_list(struct afs_server_list *, struct afs_server_list *); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 901 | |
| 902 | /* |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 903 | * super.c |
| 904 | */ |
David Howells | f044c88 | 2017-11-02 15:27:45 +0000 | [diff] [blame] | 905 | extern int __init afs_fs_init(void); |
| 906 | extern void __exit afs_fs_exit(void); |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 907 | |
| 908 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 909 | * vlclient.c |
| 910 | */ |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 911 | extern struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_net *, |
| 912 | struct afs_addr_cursor *, |
| 913 | struct key *, const char *, int); |
| 914 | extern struct afs_addr_list *afs_vl_get_addrs_u(struct afs_net *, struct afs_addr_cursor *, |
| 915 | struct key *, const uuid_t *); |
David Howells | bf99a53 | 2017-11-02 15:27:51 +0000 | [diff] [blame] | 916 | extern int afs_vl_get_capabilities(struct afs_net *, struct afs_addr_cursor *, struct key *); |
| 917 | extern struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_net *, struct afs_addr_cursor *, |
| 918 | struct key *, const uuid_t *); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 919 | |
| 920 | /* |
| 921 | * volume.c |
| 922 | */ |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 923 | static inline struct afs_volume *__afs_get_volume(struct afs_volume *volume) |
David Howells | 49566f6 | 2017-11-02 15:27:46 +0000 | [diff] [blame] | 924 | { |
| 925 | if (volume) |
| 926 | atomic_inc(&volume->usage); |
| 927 | return volume; |
| 928 | } |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 929 | |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 930 | extern struct afs_volume *afs_create_volume(struct afs_mount_params *); |
| 931 | extern void afs_activate_volume(struct afs_volume *); |
| 932 | extern void afs_deactivate_volume(struct afs_volume *); |
David Howells | 9ed900b | 2017-11-02 15:27:46 +0000 | [diff] [blame] | 933 | extern void afs_put_volume(struct afs_cell *, struct afs_volume *); |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 934 | extern int afs_check_volume_status(struct afs_volume *, struct key *); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 935 | |
David Howells | 31143d5 | 2007-05-09 02:33:46 -0700 | [diff] [blame] | 936 | /* |
| 937 | * write.c |
| 938 | */ |
| 939 | extern int afs_set_page_dirty(struct page *); |
Nick Piggin | 15b4650 | 2008-10-15 22:04:32 -0700 | [diff] [blame] | 940 | extern int afs_write_begin(struct file *file, struct address_space *mapping, |
| 941 | loff_t pos, unsigned len, unsigned flags, |
| 942 | struct page **pagep, void **fsdata); |
| 943 | extern int afs_write_end(struct file *file, struct address_space *mapping, |
| 944 | loff_t pos, unsigned len, unsigned copied, |
| 945 | struct page *page, void *fsdata); |
David Howells | 31143d5 | 2007-05-09 02:33:46 -0700 | [diff] [blame] | 946 | extern int afs_writepage(struct page *, struct writeback_control *); |
| 947 | extern int afs_writepages(struct address_space *, struct writeback_control *); |
David Howells | 31143d5 | 2007-05-09 02:33:46 -0700 | [diff] [blame] | 948 | extern void afs_pages_written_back(struct afs_vnode *, struct afs_call *); |
Al Viro | 50b5551 | 2014-04-03 14:13:46 -0400 | [diff] [blame] | 949 | extern ssize_t afs_file_write(struct kiocb *, struct iov_iter *); |
David Howells | 58fed94 | 2017-03-16 16:27:45 +0000 | [diff] [blame] | 950 | extern int afs_flush(struct file *, fl_owner_t); |
Josef Bacik | 02c24a8 | 2011-07-16 20:44:56 -0400 | [diff] [blame] | 951 | extern int afs_fsync(struct file *, loff_t, loff_t, int); |
David Howells | 1cf7a15 | 2017-11-02 15:27:52 +0000 | [diff] [blame] | 952 | extern int afs_page_mkwrite(struct vm_fault *); |
David Howells | 4343d00 | 2017-11-02 15:27:52 +0000 | [diff] [blame] | 953 | extern void afs_prune_wb_keys(struct afs_vnode *); |
| 954 | extern int afs_launder_page(struct page *); |
David Howells | 31143d5 | 2007-05-09 02:33:46 -0700 | [diff] [blame] | 955 | |
David Howells | d3e3b7ea | 2017-07-06 15:50:27 +0100 | [diff] [blame] | 956 | /* |
| 957 | * xattr.c |
| 958 | */ |
| 959 | extern const struct xattr_handler *afs_xattr_handlers[]; |
| 960 | extern ssize_t afs_listxattr(struct dentry *, char *, size_t); |
David Howells | 31143d5 | 2007-05-09 02:33:46 -0700 | [diff] [blame] | 961 | |
David Howells | d2ddc77 | 2017-11-02 15:27:50 +0000 | [diff] [blame] | 962 | |
| 963 | /* |
| 964 | * Miscellaneous inline functions. |
| 965 | */ |
| 966 | static inline struct afs_vnode *AFS_FS_I(struct inode *inode) |
| 967 | { |
| 968 | return container_of(inode, struct afs_vnode, vfs_inode); |
| 969 | } |
| 970 | |
| 971 | static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode) |
| 972 | { |
| 973 | return &vnode->vfs_inode; |
| 974 | } |
| 975 | |
| 976 | static inline void afs_vnode_commit_status(struct afs_fs_cursor *fc, |
| 977 | struct afs_vnode *vnode, |
| 978 | unsigned int cb_break) |
| 979 | { |
| 980 | if (fc->ac.error == 0) |
| 981 | afs_cache_permit(vnode, fc->key, cb_break); |
| 982 | } |
| 983 | |
| 984 | static inline void afs_check_for_remote_deletion(struct afs_fs_cursor *fc, |
| 985 | struct afs_vnode *vnode) |
| 986 | { |
| 987 | if (fc->ac.error == -ENOENT) { |
| 988 | set_bit(AFS_VNODE_DELETED, &vnode->flags); |
| 989 | afs_break_callback(vnode); |
| 990 | } |
| 991 | } |
| 992 | |
| 993 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 994 | /*****************************************************************************/ |
| 995 | /* |
| 996 | * debug tracing |
| 997 | */ |
| 998 | extern unsigned afs_debug; |
| 999 | |
| 1000 | #define dbgprintk(FMT,...) \ |
Sven Schnelle | ad16df8 | 2008-04-03 10:44:01 +0100 | [diff] [blame] | 1001 | printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__) |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 1002 | |
Harvey Harrison | 530b641 | 2008-04-30 00:55:09 -0700 | [diff] [blame] | 1003 | #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__) |
| 1004 | #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 1005 | #define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__) |
| 1006 | |
| 1007 | |
| 1008 | #if defined(__KDEBUG) |
| 1009 | #define _enter(FMT,...) kenter(FMT,##__VA_ARGS__) |
| 1010 | #define _leave(FMT,...) kleave(FMT,##__VA_ARGS__) |
| 1011 | #define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__) |
| 1012 | |
| 1013 | #elif defined(CONFIG_AFS_DEBUG) |
| 1014 | #define AFS_DEBUG_KENTER 0x01 |
| 1015 | #define AFS_DEBUG_KLEAVE 0x02 |
| 1016 | #define AFS_DEBUG_KDEBUG 0x04 |
| 1017 | |
| 1018 | #define _enter(FMT,...) \ |
| 1019 | do { \ |
| 1020 | if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \ |
| 1021 | kenter(FMT,##__VA_ARGS__); \ |
| 1022 | } while (0) |
| 1023 | |
| 1024 | #define _leave(FMT,...) \ |
| 1025 | do { \ |
| 1026 | if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \ |
| 1027 | kleave(FMT,##__VA_ARGS__); \ |
| 1028 | } while (0) |
| 1029 | |
| 1030 | #define _debug(FMT,...) \ |
| 1031 | do { \ |
| 1032 | if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \ |
| 1033 | kdebug(FMT,##__VA_ARGS__); \ |
| 1034 | } while (0) |
| 1035 | |
| 1036 | #else |
David Howells | 12fdff3 | 2010-08-12 16:54:57 +0100 | [diff] [blame] | 1037 | #define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__) |
| 1038 | #define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) |
| 1039 | #define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__) |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 1040 | #endif |
| 1041 | |
| 1042 | /* |
| 1043 | * debug assertion checking |
| 1044 | */ |
| 1045 | #if 1 // defined(__KDEBUGALL) |
| 1046 | |
| 1047 | #define ASSERT(X) \ |
| 1048 | do { \ |
| 1049 | if (unlikely(!(X))) { \ |
| 1050 | printk(KERN_ERR "\n"); \ |
| 1051 | printk(KERN_ERR "AFS: Assertion failed\n"); \ |
| 1052 | BUG(); \ |
| 1053 | } \ |
| 1054 | } while(0) |
| 1055 | |
| 1056 | #define ASSERTCMP(X, OP, Y) \ |
| 1057 | do { \ |
| 1058 | if (unlikely(!((X) OP (Y)))) { \ |
| 1059 | printk(KERN_ERR "\n"); \ |
| 1060 | printk(KERN_ERR "AFS: Assertion failed\n"); \ |
| 1061 | printk(KERN_ERR "%lu " #OP " %lu is false\n", \ |
| 1062 | (unsigned long)(X), (unsigned long)(Y)); \ |
| 1063 | printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ |
| 1064 | (unsigned long)(X), (unsigned long)(Y)); \ |
| 1065 | BUG(); \ |
| 1066 | } \ |
| 1067 | } while(0) |
| 1068 | |
David Howells | 416351f | 2007-05-09 02:33:45 -0700 | [diff] [blame] | 1069 | #define ASSERTRANGE(L, OP1, N, OP2, H) \ |
| 1070 | do { \ |
| 1071 | if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) { \ |
| 1072 | printk(KERN_ERR "\n"); \ |
| 1073 | printk(KERN_ERR "AFS: Assertion failed\n"); \ |
| 1074 | printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n", \ |
| 1075 | (unsigned long)(L), (unsigned long)(N), \ |
| 1076 | (unsigned long)(H)); \ |
| 1077 | printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \ |
| 1078 | (unsigned long)(L), (unsigned long)(N), \ |
| 1079 | (unsigned long)(H)); \ |
| 1080 | BUG(); \ |
| 1081 | } \ |
| 1082 | } while(0) |
| 1083 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 1084 | #define ASSERTIF(C, X) \ |
| 1085 | do { \ |
| 1086 | if (unlikely((C) && !(X))) { \ |
| 1087 | printk(KERN_ERR "\n"); \ |
| 1088 | printk(KERN_ERR "AFS: Assertion failed\n"); \ |
| 1089 | BUG(); \ |
| 1090 | } \ |
| 1091 | } while(0) |
| 1092 | |
| 1093 | #define ASSERTIFCMP(C, X, OP, Y) \ |
| 1094 | do { \ |
| 1095 | if (unlikely((C) && !((X) OP (Y)))) { \ |
| 1096 | printk(KERN_ERR "\n"); \ |
| 1097 | printk(KERN_ERR "AFS: Assertion failed\n"); \ |
| 1098 | printk(KERN_ERR "%lu " #OP " %lu is false\n", \ |
| 1099 | (unsigned long)(X), (unsigned long)(Y)); \ |
| 1100 | printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ |
| 1101 | (unsigned long)(X), (unsigned long)(Y)); \ |
| 1102 | BUG(); \ |
| 1103 | } \ |
| 1104 | } while(0) |
| 1105 | |
| 1106 | #else |
| 1107 | |
| 1108 | #define ASSERT(X) \ |
| 1109 | do { \ |
| 1110 | } while(0) |
| 1111 | |
| 1112 | #define ASSERTCMP(X, OP, Y) \ |
| 1113 | do { \ |
| 1114 | } while(0) |
| 1115 | |
David Howells | 416351f | 2007-05-09 02:33:45 -0700 | [diff] [blame] | 1116 | #define ASSERTRANGE(L, OP1, N, OP2, H) \ |
| 1117 | do { \ |
| 1118 | } while(0) |
| 1119 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 1120 | #define ASSERTIF(C, X) \ |
| 1121 | do { \ |
| 1122 | } while(0) |
| 1123 | |
| 1124 | #define ASSERTIFCMP(C, X, OP, Y) \ |
| 1125 | do { \ |
| 1126 | } while(0) |
| 1127 | |
| 1128 | #endif /* __KDEBUGALL */ |