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