| 1 |
|
| 2 | |
| 3 | *
|
| 4 | * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
|
| 5 | * Written by David Howells ([email protected])
|
| 6 |
|
| 7 |
|
| 8 | #include <linux/compiler.h>
|
| 9 | #include <linux/kernel.h>
|
| 10 | #include <linux/ktime.h>
|
| 11 | #include <linux/fs.h>
|
| 12 | #include <linux/filelock.h>
|
| 13 | #include <linux/pagemap.h>
|
| 14 | #include <linux/rxrpc.h>
|
| 15 | #include <linux/key.h>
|
| 16 | #include <linux/workqueue.h>
|
| 17 | #include <linux/sched.h>
|
| 18 | #include <linux/fscache.h>
|
| 19 | #include <linux/backing-dev.h>
|
| 20 | #include <linux/uuid.h>
|
| 21 | #include <linux/mm_types.h>
|
| 22 | #include <linux/dns_resolver.h>
|
| 23 | #include <crypto/krb5.h>
|
| 24 | #include <net/net_namespace.h>
|
| 25 | #include <net/netns/generic.h>
|
| 26 | #include <net/sock.h>
|
| 27 | #include <net/af_rxrpc.h>
|
| 28 |
|
| 29 | #include "afs.h"
|
| 30 | #include "afs_vl.h"
|
| 31 |
|
| 32 | #define AFS_CELL_MAX_ADDRS 15
|
| 33 |
|
| 34 | struct afs_call;
|
| 35 | struct afs_vnode;
|
| 36 | struct afs_server_probe;
|
| 37 |
|
| 38 | |
| 39 | * Partial file-locking emulation mode. (The problem being that AFS3 only
|
| 40 | * allows whole-file locks and no upgrading/downgrading).
|
| 41 |
|
| 42 | enum afs_flock_mode {
|
| 43 | afs_flock_mode_unset,
|
| 44 | afs_flock_mode_local,
|
| 45 | afs_flock_mode_openafs,
|
| 46 | afs_flock_mode_strict,
|
| 47 | afs_flock_mode_write,
|
| 48 | };
|
| 49 |
|
| 50 | struct afs_fs_context {
|
| 51 | bool force;
|
| 52 | bool autocell;
|
| 53 | bool dyn_root;
|
| 54 | bool no_cell;
|
| 55 | enum afs_flock_mode flock_mode;
|
| 56 | afs_voltype_t type;
|
| 57 | unsigned int volnamesz;
|
| 58 | const char *volname;
|
| 59 | struct afs_net *net;
|
| 60 | struct afs_cell *cell;
|
| 61 | struct afs_volume *volume;
|
| 62 | struct key *key;
|
| 63 | };
|
| 64 |
|
| 65 | enum afs_call_state {
|
| 66 | AFS_CALL_CL_REQUESTING,
|
| 67 | AFS_CALL_CL_AWAIT_REPLY,
|
| 68 | AFS_CALL_CL_PROC_REPLY,
|
| 69 | AFS_CALL_SV_AWAIT_OP_ID,
|
| 70 | AFS_CALL_SV_AWAIT_REQUEST,
|
| 71 | AFS_CALL_SV_REPLYING,
|
| 72 | AFS_CALL_SV_AWAIT_ACK,
|
| 73 | AFS_CALL_COMPLETE,
|
| 74 | };
|
| 75 |
|
| 76 | |
| 77 | * Address preferences.
|
| 78 |
|
| 79 | struct afs_addr_preference {
|
| 80 | union {
|
| 81 | struct in_addr ipv4_addr;
|
| 82 | struct in6_addr ipv6_addr;
|
| 83 | };
|
| 84 | sa_family_t family;
|
| 85 | u16 prio;
|
| 86 | u8 subnet_mask;
|
| 87 | };
|
| 88 |
|
| 89 | struct afs_addr_preference_list {
|
| 90 | struct rcu_head rcu;
|
| 91 | u16 version;
|
| 92 | u8 ipv6_off;
|
| 93 | u8 nr;
|
| 94 | u8 max_prefs;
|
| 95 | struct afs_addr_preference prefs[] __counted_by(max_prefs);
|
| 96 | };
|
| 97 |
|
| 98 | struct afs_address {
|
| 99 | struct rxrpc_peer *peer;
|
| 100 | short last_error;
|
| 101 | u16 prio;
|
| 102 | };
|
| 103 |
|
| 104 | |
| 105 | * List of server addresses.
|
| 106 |
|
| 107 | struct afs_addr_list {
|
| 108 | struct rcu_head rcu;
|
| 109 | refcount_t usage;
|
| 110 | u32 version;
|
| 111 | unsigned int debug_id;
|
| 112 | unsigned int addr_pref_version;
|
| 113 | unsigned char max_addrs;
|
| 114 | unsigned char nr_addrs;
|
| 115 | unsigned char preferred;
|
| 116 | unsigned char nr_ipv4;
|
| 117 | enum dns_record_source source:8;
|
| 118 | enum dns_lookup_status status:8;
|
| 119 | unsigned long probe_failed;
|
| 120 | unsigned long responded;
|
| 121 | struct afs_address addrs[] __counted_by(max_addrs);
|
| 122 | #define AFS_MAX_ADDRESSES ((unsigned int)(sizeof(unsigned long) * 8))
|
| 123 | };
|
| 124 |
|
| 125 | |
| 126 | * a record of an in-progress RxRPC call
|
| 127 |
|
| 128 | struct afs_call {
|
| 129 | const struct afs_call_type *type;
|
| 130 | wait_queue_head_t waitq;
|
| 131 | struct work_struct async_work;
|
| 132 | struct work_struct work;
|
| 133 | struct work_struct free_work;
|
| 134 | struct rxrpc_call *rxcall;
|
| 135 | struct rxrpc_peer *peer;
|
| 136 | struct key *key;
|
| 137 | struct afs_net *net;
|
| 138 | struct afs_server *server;
|
| 139 | struct afs_vlserver *vlserver;
|
| 140 | void *request;
|
| 141 | size_t iov_len;
|
| 142 | struct iov_iter def_iter;
|
| 143 | struct iov_iter *write_iter;
|
| 144 | struct iov_iter *iter;
|
| 145 | union {
|
| 146 | struct kvec kvec[1];
|
| 147 | struct bio_vec bvec[1];
|
| 148 | };
|
| 149 | void *buffer;
|
| 150 | union {
|
| 151 | struct afs_endpoint_state *probe;
|
| 152 | struct afs_addr_list *vl_probe;
|
| 153 | struct afs_addr_list *ret_alist;
|
| 154 | struct afs_vldb_entry *ret_vldb;
|
| 155 | char *ret_str;
|
| 156 | };
|
| 157 | struct afs_fid fid;
|
| 158 | unsigned char probe_index;
|
| 159 | struct afs_operation *op;
|
| 160 | unsigned int server_index;
|
| 161 | refcount_t ref;
|
| 162 | enum afs_call_state state;
|
| 163 | spinlock_t state_lock;
|
| 164 | int error;
|
| 165 | u32 abort_code;
|
| 166 | unsigned long long remaining;
|
| 167 | unsigned int max_lifespan;
|
| 168 | unsigned request_size;
|
| 169 | unsigned reply_max;
|
| 170 | unsigned count2;
|
| 171 | unsigned char unmarshall;
|
| 172 | bool drop_ref;
|
| 173 | bool need_attention;
|
| 174 | bool async;
|
| 175 | bool upgrade;
|
| 176 | bool intr;
|
| 177 | bool unmarshalling_error;
|
| 178 | bool responded;
|
| 179 | u8 security_ix;
|
| 180 | u16 service_id;
|
| 181 | unsigned int debug_id;
|
| 182 | u32 enctype;
|
| 183 | u32 operation_ID;
|
| 184 | u32 count;
|
| 185 | union {
|
| 186 | struct {
|
| 187 | __be32 tmp_u;
|
| 188 | __be32 tmp;
|
| 189 | } __attribute__((packed));
|
| 190 | __be64 tmp64;
|
| 191 | };
|
| 192 | ktime_t issue_time;
|
| 193 | };
|
| 194 |
|
| 195 | struct afs_call_type {
|
| 196 | const char *name;
|
| 197 | unsigned int op;
|
| 198 |
|
| 199 | |
| 200 | * - returning an error will cause the call to be aborted
|
| 201 |
|
| 202 | int (*deliver)(struct afs_call *call);
|
| 203 |
|
| 204 |
|
| 205 | void (*destructor)(struct afs_call *call);
|
| 206 |
|
| 207 |
|
| 208 | void (*async_rx)(struct work_struct *work);
|
| 209 |
|
| 210 |
|
| 211 | void (*work)(struct work_struct *work);
|
| 212 |
|
| 213 |
|
| 214 | void (*done)(struct afs_call *call);
|
| 215 |
|
| 216 |
|
| 217 | void (*immediate_cancel)(struct afs_call *call);
|
| 218 | };
|
| 219 |
|
| 220 | |
| 221 | * Key available for writeback on a file.
|
| 222 |
|
| 223 | struct afs_wb_key {
|
| 224 | refcount_t usage;
|
| 225 | struct key *key;
|
| 226 | struct list_head vnode_link;
|
| 227 | };
|
| 228 |
|
| 229 | |
| 230 | * AFS open file information record. Pointed to by file->private_data.
|
| 231 |
|
| 232 | struct afs_file {
|
| 233 | struct key *key;
|
| 234 | struct afs_wb_key *wb;
|
| 235 | };
|
| 236 |
|
| 237 | static inline struct key *afs_file_key(struct file *file)
|
| 238 | {
|
| 239 | struct afs_file *af = file->private_data;
|
| 240 |
|
| 241 | return af->key;
|
| 242 | }
|
| 243 |
|
| 244 | |
| 245 | * AFS superblock private data
|
| 246 | * - there's one superblock per volume
|
| 247 |
|
| 248 | struct afs_super_info {
|
| 249 | struct net *net_ns;
|
| 250 | struct afs_cell *cell;
|
| 251 | struct afs_volume *volume;
|
| 252 | enum afs_flock_mode flock_mode:8;
|
| 253 | bool dyn_root;
|
| 254 |
|
| 255 | struct rcu_head rcu;
|
| 256 | };
|
| 257 |
|
| 258 | static inline struct afs_super_info *AFS_FS_S(struct super_block *sb)
|
| 259 | {
|
| 260 | return sb->s_fs_info;
|
| 261 | }
|
| 262 |
|
| 263 | extern struct file_system_type afs_fs_type;
|
| 264 |
|
| 265 | |
| 266 | * Set of substitutes for @sys.
|
| 267 |
|
| 268 | struct afs_sysnames {
|
| 269 | #define AFS_NR_SYSNAME 16
|
| 270 | char *subs[AFS_NR_SYSNAME];
|
| 271 | refcount_t usage;
|
| 272 | unsigned short nr;
|
| 273 | char blank[1];
|
| 274 | };
|
| 275 |
|
| 276 | |
| 277 | * AFS network namespace record.
|
| 278 |
|
| 279 | struct afs_net {
|
| 280 | struct net *net;
|
| 281 | struct afs_uuid uuid;
|
| 282 | bool live;
|
| 283 |
|
| 284 |
|
| 285 | struct socket *socket;
|
| 286 | struct afs_call *spare_incoming_call;
|
| 287 | struct work_struct charge_preallocation_work;
|
| 288 | struct work_struct rx_oob_work;
|
| 289 | struct mutex socket_mutex;
|
| 290 | atomic_t nr_outstanding_calls;
|
| 291 | atomic_t nr_superblocks;
|
| 292 |
|
| 293 |
|
| 294 | struct rb_root cells;
|
| 295 | struct idr cells_dyn_ino;
|
| 296 | struct afs_cell __rcu *ws_cell;
|
| 297 | atomic_t cells_outstanding;
|
| 298 | struct rw_semaphore cells_lock;
|
| 299 | struct mutex cells_alias_lock;
|
| 300 |
|
| 301 | struct mutex proc_cells_lock;
|
| 302 | struct hlist_head proc_cells;
|
| 303 |
|
| 304 | |
| 305 | * cell, but in practice, people create aliases and subsets and there's
|
| 306 | * no easy way to distinguish them.
|
| 307 |
|
| 308 | seqlock_t fs_lock;
|
| 309 | struct list_head fs_probe_fast;
|
| 310 | struct list_head fs_probe_slow;
|
| 311 | struct hlist_head fs_proc;
|
| 312 |
|
| 313 | struct key *fs_cm_token_key;
|
| 314 | struct work_struct fs_prober;
|
| 315 | struct timer_list fs_probe_timer;
|
| 316 | atomic_t servers_outstanding;
|
| 317 |
|
| 318 |
|
| 319 | struct mutex lock_manager_mutex;
|
| 320 |
|
| 321 |
|
| 322 | struct super_block *dynroot_sb;
|
| 323 | struct proc_dir_entry *proc_afs;
|
| 324 | struct afs_sysnames *sysnames;
|
| 325 | rwlock_t sysnames_lock;
|
| 326 | struct afs_addr_preference_list __rcu *address_prefs;
|
| 327 | u16 address_pref_version;
|
| 328 |
|
| 329 |
|
| 330 | atomic_t n_lookup;
|
| 331 | atomic_t n_reval;
|
| 332 | atomic_t n_inval;
|
| 333 | atomic_t n_relpg;
|
| 334 | atomic_t n_read_dir;
|
| 335 | atomic_t n_dir_cr;
|
| 336 | atomic_t n_dir_rm;
|
| 337 | atomic_t n_stores;
|
| 338 | atomic_long_t n_store_bytes;
|
| 339 | atomic_long_t n_fetch_bytes;
|
| 340 | atomic_t n_fetches;
|
| 341 | };
|
| 342 |
|
| 343 | extern const char afs_init_sysname[];
|
| 344 |
|
| 345 | enum afs_cell_state {
|
| 346 | AFS_CELL_SETTING_UP,
|
| 347 | AFS_CELL_UNLOOKED,
|
| 348 | AFS_CELL_ACTIVE,
|
| 349 | AFS_CELL_REMOVING,
|
| 350 | AFS_CELL_DEAD,
|
| 351 | };
|
| 352 |
|
| 353 | |
| 354 | * AFS cell record.
|
| 355 | *
|
| 356 | * This is a tricky concept to get right as it is possible to create aliases
|
| 357 | * simply by pointing AFSDB/SRV records for two names at the same set of VL
|
| 358 | * servers; it is also possible to do things like setting up two sets of VL
|
| 359 | * servers, one of which provides a superset of the volumes provided by the
|
| 360 | * other (for internal/external division, for example).
|
| 361 | *
|
| 362 | * Cells only exist in the sense that (a) a cell's name maps to a set of VL
|
| 363 | * servers and (b) a cell's name is used by the client to select the key to use
|
| 364 | * for authentication and encryption. The cell name is not typically used in
|
| 365 | * the protocol.
|
| 366 | *
|
| 367 | * Two cells are determined to be aliases if they have an explicit alias (YFS
|
| 368 | * only), share any VL servers in common or have at least one volume in common.
|
| 369 | * "In common" means that the address list of the VL servers or the fileservers
|
| 370 | * share at least one endpoint.
|
| 371 |
|
| 372 | struct afs_cell {
|
| 373 | union {
|
| 374 | struct rcu_head rcu;
|
| 375 | struct rb_node net_node;
|
| 376 | };
|
| 377 | struct afs_net *net;
|
| 378 | struct afs_cell *alias_of;
|
| 379 | struct afs_volume *root_volume;
|
| 380 | struct key *anonymous_key;
|
| 381 | struct work_struct destroyer;
|
| 382 | struct work_struct manager;
|
| 383 | struct timer_list management_timer;
|
| 384 | struct hlist_node proc_link;
|
| 385 | time64_t dns_expiry;
|
| 386 | time64_t last_inactive;
|
| 387 | refcount_t ref;
|
| 388 | atomic_t active;
|
| 389 | unsigned long flags;
|
| 390 | #define AFS_CELL_FL_NO_GC 0
|
| 391 | #define AFS_CELL_FL_DO_LOOKUP 1
|
| 392 | #define AFS_CELL_FL_CHECK_ALIAS 2
|
| 393 | #define AFS_CELL_FL_HAVE_INO 3
|
| 394 | enum afs_cell_state state;
|
| 395 | short error;
|
| 396 | enum dns_record_source dns_source:8;
|
| 397 | enum dns_lookup_status dns_status:8;
|
| 398 | unsigned int dns_lookup_count;
|
| 399 | unsigned int debug_id;
|
| 400 | unsigned int dynroot_ino;
|
| 401 |
|
| 402 |
|
| 403 | struct rw_semaphore vs_lock;
|
| 404 | struct rb_root volumes;
|
| 405 | struct hlist_head proc_volumes;
|
| 406 | seqlock_t volume_lock;
|
| 407 |
|
| 408 |
|
| 409 | struct rb_root fs_servers;
|
| 410 | struct rw_semaphore fs_lock;
|
| 411 |
|
| 412 |
|
| 413 | rwlock_t vl_servers_lock;
|
| 414 | struct afs_vlserver_list __rcu *vl_servers;
|
| 415 |
|
| 416 | u8 name_len;
|
| 417 | char *name;
|
| 418 | char *key_desc;
|
| 419 | };
|
| 420 |
|
| 421 | |
| 422 | * Volume Location server record.
|
| 423 |
|
| 424 | struct afs_vlserver {
|
| 425 | struct rcu_head rcu;
|
| 426 | struct afs_addr_list __rcu *addresses;
|
| 427 | unsigned long flags;
|
| 428 | #define AFS_VLSERVER_FL_PROBED 0
|
| 429 | #define AFS_VLSERVER_FL_PROBING 1
|
| 430 | #define AFS_VLSERVER_FL_IS_YFS 2
|
| 431 | #define AFS_VLSERVER_FL_RESPONDING 3
|
| 432 | rwlock_t lock;
|
| 433 | refcount_t ref;
|
| 434 | unsigned int rtt;
|
| 435 | unsigned int debug_id;
|
| 436 |
|
| 437 |
|
| 438 | wait_queue_head_t probe_wq;
|
| 439 | atomic_t probe_outstanding;
|
| 440 | spinlock_t probe_lock;
|
| 441 | struct {
|
| 442 | unsigned int rtt;
|
| 443 | u32 abort_code;
|
| 444 | short error;
|
| 445 | unsigned short flags;
|
| 446 | #define AFS_VLSERVER_PROBE_RESPONDED 0x01
|
| 447 | #define AFS_VLSERVER_PROBE_IS_YFS 0x02
|
| 448 | #define AFS_VLSERVER_PROBE_NOT_YFS 0x04
|
| 449 | #define AFS_VLSERVER_PROBE_LOCAL_FAILURE 0x08
|
| 450 | } probe;
|
| 451 |
|
| 452 | u16 service_id;
|
| 453 | u16 port;
|
| 454 | u16 name_len;
|
| 455 | char name[];
|
| 456 | };
|
| 457 |
|
| 458 | |
| 459 | * Weighted list of Volume Location servers.
|
| 460 |
|
| 461 | struct afs_vlserver_entry {
|
| 462 | u16 priority;
|
| 463 | u16 weight;
|
| 464 | enum dns_record_source source:8;
|
| 465 | enum dns_lookup_status status:8;
|
| 466 | struct afs_vlserver *server;
|
| 467 | };
|
| 468 |
|
| 469 | struct afs_vlserver_list {
|
| 470 | struct rcu_head rcu;
|
| 471 | refcount_t ref;
|
| 472 | u8 nr_servers;
|
| 473 | u8 index;
|
| 474 | u8 preferred;
|
| 475 | enum dns_record_source source:8;
|
| 476 | enum dns_lookup_status status:8;
|
| 477 | rwlock_t lock;
|
| 478 | struct afs_vlserver_entry servers[];
|
| 479 | };
|
| 480 |
|
| 481 | |
| 482 | * Cached VLDB entry.
|
| 483 | *
|
| 484 | * This is pointed to by cell->vldb_entries, indexed by name.
|
| 485 |
|
| 486 | struct afs_vldb_entry {
|
| 487 | afs_volid_t vid[3];
|
| 488 |
|
| 489 | unsigned long flags;
|
| 490 | #define AFS_VLDB_HAS_RW 0
|
| 491 | #define AFS_VLDB_HAS_RO 1
|
| 492 | #define AFS_VLDB_HAS_BAK 2
|
| 493 | #define AFS_VLDB_QUERY_VALID 3
|
| 494 | #define AFS_VLDB_QUERY_ERROR 4
|
| 495 |
|
| 496 | uuid_t fs_server[AFS_NMAXNSERVERS];
|
| 497 | u32 addr_version[AFS_NMAXNSERVERS];
|
| 498 | u8 fs_mask[AFS_NMAXNSERVERS];
|
| 499 | #define AFS_VOL_VTM_RW 0x01
|
| 500 | #define AFS_VOL_VTM_RO 0x02
|
| 501 | #define AFS_VOL_VTM_BAK 0x04
|
| 502 | u8 vlsf_flags[AFS_NMAXNSERVERS];
|
| 503 | short error;
|
| 504 | u8 nr_servers;
|
| 505 | u8 name_len;
|
| 506 | u8 name[AFS_MAXVOLNAME + 1];
|
| 507 | };
|
| 508 |
|
| 509 | |
| 510 | * Fileserver endpoint state. The records the addresses of a fileserver's
|
| 511 | * endpoints and the state and result of a round of probing on them. This
|
| 512 | * allows the rotation algorithm to access those results without them being
|
| 513 | * erased by a subsequent round of probing.
|
| 514 |
|
| 515 | struct afs_endpoint_state {
|
| 516 | struct rcu_head rcu;
|
| 517 | struct afs_addr_list *addresses;
|
| 518 | unsigned long responsive_set;
|
| 519 | unsigned long failed_set;
|
| 520 | refcount_t ref;
|
| 521 | unsigned int server_id;
|
| 522 | unsigned int probe_seq;
|
| 523 | atomic_t nr_probing;
|
| 524 | unsigned int rtt;
|
| 525 | s32 abort_code;
|
| 526 | short error;
|
| 527 | unsigned long flags;
|
| 528 | #define AFS_ESTATE_RESPONDED 0
|
| 529 | #define AFS_ESTATE_SUPERSEDED 1
|
| 530 | #define AFS_ESTATE_IS_YFS 2
|
| 531 | #define AFS_ESTATE_NOT_YFS 3
|
| 532 | #define AFS_ESTATE_LOCAL_FAILURE 4
|
| 533 | };
|
| 534 |
|
| 535 | |
| 536 | * Record of fileserver with which we're actively communicating.
|
| 537 |
|
| 538 | struct afs_server {
|
| 539 | struct rcu_head rcu;
|
| 540 | union {
|
| 541 | uuid_t uuid;
|
| 542 | struct afs_uuid _uuid;
|
| 543 | };
|
| 544 |
|
| 545 | struct afs_cell *cell;
|
| 546 | struct rb_node uuid_rb;
|
| 547 | struct list_head probe_link;
|
| 548 | struct hlist_node proc_link;
|
| 549 | struct list_head volumes;
|
| 550 | struct work_struct destroyer;
|
| 551 | struct timer_list timer;
|
| 552 | struct mutex cm_token_lock;
|
| 553 | struct krb5_buffer cm_rxgk_appdata;
|
| 554 | time64_t unuse_time;
|
| 555 | unsigned long flags;
|
| 556 | #define AFS_SERVER_FL_RESPONDING 0
|
| 557 | #define AFS_SERVER_FL_UPDATING 1
|
| 558 | #define AFS_SERVER_FL_NEEDS_UPDATE 2
|
| 559 | #define AFS_SERVER_FL_UNCREATED 3
|
| 560 | #define AFS_SERVER_FL_CREATING 4
|
| 561 | #define AFS_SERVER_FL_EXPIRED 5
|
| 562 | #define AFS_SERVER_FL_NOT_FOUND 6
|
| 563 | #define AFS_SERVER_FL_VL_FAIL 7
|
| 564 | #define AFS_SERVER_FL_MAY_HAVE_CB 8
|
| 565 | #define AFS_SERVER_FL_IS_YFS 16
|
| 566 | #define AFS_SERVER_FL_NO_IBULK 17
|
| 567 | #define AFS_SERVER_FL_NO_RM2 18
|
| 568 | #define AFS_SERVER_FL_HAS_FS64 19
|
| 569 | #define AFS_SERVER_FL_NO_RENAME2 20
|
| 570 | refcount_t ref;
|
| 571 | atomic_t active;
|
| 572 | u32 addr_version;
|
| 573 | u16 service_id;
|
| 574 | short create_error;
|
| 575 | unsigned int rtt;
|
| 576 | unsigned int debug_id;
|
| 577 |
|
| 578 |
|
| 579 | rwlock_t fs_lock;
|
| 580 |
|
| 581 |
|
| 582 | struct afs_endpoint_state __rcu *endpoint_state;
|
| 583 | unsigned long probed_at;
|
| 584 | wait_queue_head_t probe_wq;
|
| 585 | unsigned int probe_counter;
|
| 586 | spinlock_t probe_lock;
|
| 587 | };
|
| 588 |
|
| 589 | enum afs_ro_replicating {
|
| 590 | AFS_RO_NOT_REPLICATING,
|
| 591 | AFS_RO_REPLICATING_USE_OLD,
|
| 592 | AFS_RO_REPLICATING_USE_NEW,
|
| 593 | } __mode(byte);
|
| 594 |
|
| 595 | |
| 596 | * Replaceable volume server list.
|
| 597 |
|
| 598 | struct afs_server_entry {
|
| 599 | struct afs_server *server;
|
| 600 | struct afs_volume *volume;
|
| 601 | struct list_head slink;
|
| 602 | time64_t cb_expires_at;
|
| 603 | unsigned long flags;
|
| 604 | #define AFS_SE_EXCLUDED 0
|
| 605 | #define AFS_SE_VOLUME_OFFLINE 1
|
| 606 | #define AFS_SE_VOLUME_BUSY 2
|
| 607 | };
|
| 608 |
|
| 609 | struct afs_server_list {
|
| 610 | struct rcu_head rcu;
|
| 611 | refcount_t usage;
|
| 612 | bool attached;
|
| 613 | enum afs_ro_replicating ro_replicating;
|
| 614 | unsigned char nr_servers;
|
| 615 | unsigned short vnovol_mask;
|
| 616 | unsigned int seq;
|
| 617 | rwlock_t lock;
|
| 618 | struct afs_server_entry servers[];
|
| 619 | };
|
| 620 |
|
| 621 | |
| 622 | * Live AFS volume management.
|
| 623 |
|
| 624 | struct afs_volume {
|
| 625 | struct rcu_head rcu;
|
| 626 | afs_volid_t vid;
|
| 627 | afs_volid_t vids[AFS_MAXTYPES];
|
| 628 | refcount_t ref;
|
| 629 | unsigned int debug_id;
|
| 630 | time64_t update_at;
|
| 631 | struct afs_cell *cell;
|
| 632 | struct rb_node cell_node;
|
| 633 | struct hlist_node proc_link;
|
| 634 | struct super_block __rcu *sb;
|
| 635 | struct work_struct destructor;
|
| 636 | unsigned long flags;
|
| 637 | #define AFS_VOLUME_NEEDS_UPDATE 0
|
| 638 | #define AFS_VOLUME_UPDATING 1
|
| 639 | #define AFS_VOLUME_WAIT 2
|
| 640 | #define AFS_VOLUME_DELETED 3
|
| 641 | #define AFS_VOLUME_MAYBE_NO_IBULK 4
|
| 642 | #define AFS_VOLUME_RM_TREE 5
|
| 643 | #ifdef CONFIG_AFS_FSCACHE
|
| 644 | struct fscache_volume *cache;
|
| 645 | #endif
|
| 646 | struct afs_server_list __rcu *servers;
|
| 647 | rwlock_t servers_lock;
|
| 648 | unsigned int servers_seq;
|
| 649 |
|
| 650 |
|
| 651 | struct mutex volsync_lock;
|
| 652 | time64_t creation_time;
|
| 653 | time64_t update_time;
|
| 654 |
|
| 655 |
|
| 656 | struct mutex cb_check_lock;
|
| 657 | time64_t cb_expires_at;
|
| 658 | atomic_t cb_ro_snapshot;
|
| 659 | atomic_t cb_v_break;
|
| 660 | atomic_t cb_v_check;
|
| 661 | atomic_t cb_scrub;
|
| 662 | rwlock_t cb_v_break_lock;
|
| 663 | struct rw_semaphore open_mmaps_lock;
|
| 664 | struct list_head open_mmaps;
|
| 665 |
|
| 666 | afs_voltype_t type;
|
| 667 | char type_force;
|
| 668 | u8 name_len;
|
| 669 | u8 name[AFS_MAXVOLNAME + 1];
|
| 670 | };
|
| 671 |
|
| 672 | enum afs_lock_state {
|
| 673 | AFS_VNODE_LOCK_NONE,
|
| 674 | AFS_VNODE_LOCK_WAITING_FOR_CB,
|
| 675 | AFS_VNODE_LOCK_SETTING,
|
| 676 | AFS_VNODE_LOCK_GRANTED,
|
| 677 | AFS_VNODE_LOCK_EXTENDING,
|
| 678 | AFS_VNODE_LOCK_NEED_UNLOCK,
|
| 679 | AFS_VNODE_LOCK_UNLOCKING,
|
| 680 | AFS_VNODE_LOCK_DELETED,
|
| 681 | };
|
| 682 |
|
| 683 | |
| 684 | * AFS inode private data.
|
| 685 | *
|
| 686 | * Note that afs_alloc_inode() *must* reset anything that could incorrectly
|
| 687 | * leak from one inode to another.
|
| 688 |
|
| 689 | struct afs_vnode {
|
| 690 | struct netfs_inode netfs;
|
| 691 | struct afs_volume *volume;
|
| 692 | struct afs_fid fid;
|
| 693 | struct afs_file_status status;
|
| 694 | afs_dataversion_t invalid_before;
|
| 695 | struct afs_permits __rcu *permit_cache;
|
| 696 | struct list_head io_lock_waiters;
|
| 697 | struct rw_semaphore validate_lock;
|
| 698 | struct rw_semaphore rmdir_lock;
|
| 699 | struct key *silly_key;
|
| 700 | spinlock_t wb_lock;
|
| 701 | spinlock_t lock;
|
| 702 | unsigned long flags;
|
| 703 | #define AFS_VNODE_IO_LOCK 0
|
| 704 | #define AFS_VNODE_UNSET 1
|
| 705 | #define AFS_VNODE_DIR_VALID 2
|
| 706 | #define AFS_VNODE_ZAP_DATA 3
|
| 707 | #define AFS_VNODE_DELETED 4
|
| 708 | #define AFS_VNODE_MOUNTPOINT 5
|
| 709 | #define AFS_VNODE_PSEUDODIR 7
|
| 710 | #define AFS_VNODE_NEW_CONTENT 8
|
| 711 | #define AFS_VNODE_SILLY_DELETED 9
|
| 712 | #define AFS_VNODE_MODIFYING 10
|
| 713 | #define AFS_VNODE_DIR_READ 11
|
| 714 |
|
| 715 | struct folio_queue *directory;
|
| 716 | struct afs_symlink __rcu *symlink;
|
| 717 | struct list_head wb_keys;
|
| 718 | struct list_head pending_locks;
|
| 719 | struct list_head granted_locks;
|
| 720 | struct delayed_work lock_work;
|
| 721 | struct key *lock_key;
|
| 722 | ktime_t locked_at;
|
| 723 | enum afs_lock_state lock_state : 8;
|
| 724 | afs_lock_type_t lock_type : 8;
|
| 725 | unsigned int directory_size;
|
| 726 |
|
| 727 |
|
| 728 | struct work_struct cb_work;
|
| 729 | struct list_head cb_mmap_link;
|
| 730 | void *cb_server;
|
| 731 | atomic_t cb_nr_mmap;
|
| 732 | unsigned int cb_ro_snapshot;
|
| 733 | unsigned int cb_scrub;
|
| 734 | unsigned int cb_break;
|
| 735 | unsigned int cb_v_check;
|
| 736 | seqlock_t cb_lock;
|
| 737 |
|
| 738 | atomic64_t cb_expires_at;
|
| 739 | #define AFS_NO_CB_PROMISE TIME64_MIN
|
| 740 | };
|
| 741 |
|
| 742 | static inline struct fscache_cookie *afs_vnode_cache(struct afs_vnode *vnode)
|
| 743 | {
|
| 744 | #ifdef CONFIG_AFS_FSCACHE
|
| 745 | return netfs_i_cookie(&vnode->netfs);
|
| 746 | #else
|
| 747 | return NULL;
|
| 748 | #endif
|
| 749 | }
|
| 750 |
|
| 751 | static inline void afs_vnode_set_cache(struct afs_vnode *vnode,
|
| 752 | struct fscache_cookie *cookie)
|
| 753 | {
|
| 754 | #ifdef CONFIG_AFS_FSCACHE
|
| 755 | vnode->netfs.cache = cookie;
|
| 756 | #endif
|
| 757 | }
|
| 758 |
|
| 759 | |
| 760 | * cached security record for one user's attempt to access a vnode
|
| 761 |
|
| 762 | struct afs_permit {
|
| 763 | struct key *key;
|
| 764 | afs_access_t access;
|
| 765 | };
|
| 766 |
|
| 767 | |
| 768 | * Immutable cache of CallerAccess records from attempts to access vnodes.
|
| 769 | * These may be shared between multiple vnodes.
|
| 770 |
|
| 771 | struct afs_permits {
|
| 772 | struct rcu_head rcu;
|
| 773 | struct hlist_node hash_node;
|
| 774 | unsigned long h;
|
| 775 | refcount_t usage;
|
| 776 | unsigned short nr_permits;
|
| 777 | bool invalidated;
|
| 778 | struct afs_permit permits[] __counted_by(nr_permits);
|
| 779 | };
|
| 780 |
|
| 781 | |
| 782 | * Copy of symlink content for normal use.
|
| 783 |
|
| 784 | struct afs_symlink {
|
| 785 | struct rcu_head rcu;
|
| 786 | refcount_t ref;
|
| 787 | char content[];
|
| 788 | };
|
| 789 |
|
| 790 | |
| 791 | * Error prioritisation and accumulation.
|
| 792 |
|
| 793 | struct afs_error {
|
| 794 | s32 abort_code;
|
| 795 | short error;
|
| 796 | bool responded;
|
| 797 | bool aborted;
|
| 798 | };
|
| 799 |
|
| 800 | |
| 801 | * Cursor for iterating over a set of volume location servers.
|
| 802 |
|
| 803 | struct afs_vl_cursor {
|
| 804 | struct afs_cell *cell;
|
| 805 | struct afs_vlserver_list *server_list;
|
| 806 | struct afs_vlserver *server;
|
| 807 | struct afs_addr_list *alist;
|
| 808 | struct key *key;
|
| 809 | unsigned long untried_servers;
|
| 810 | unsigned long addr_tried;
|
| 811 | struct afs_error cumul_error;
|
| 812 | unsigned int debug_id;
|
| 813 | s32 call_abort_code;
|
| 814 | short call_error;
|
| 815 | short server_index;
|
| 816 | signed char addr_index;
|
| 817 | unsigned short flags;
|
| 818 | #define AFS_VL_CURSOR_STOP 0x0001
|
| 819 | #define AFS_VL_CURSOR_RETRY 0x0002
|
| 820 | #define AFS_VL_CURSOR_RETRIED 0x0004
|
| 821 | short nr_iterations;
|
| 822 | bool call_responded;
|
| 823 | };
|
| 824 |
|
| 825 | |
| 826 | * Fileserver state tracking for an operation. An array of these is kept,
|
| 827 | * indexed by server index.
|
| 828 |
|
| 829 | struct afs_server_state {
|
| 830 | |
| 831 | * by probing a fileserver when accessing other volumes.
|
| 832 |
|
| 833 | unsigned int probe_seq;
|
| 834 | unsigned long untried_addrs;
|
| 835 | struct wait_queue_entry probe_waiter;
|
| 836 | struct afs_endpoint_state *endpoint_state;
|
| 837 | };
|
| 838 |
|
| 839 | |
| 840 | * Fileserver operation methods.
|
| 841 |
|
| 842 | struct afs_operation_ops {
|
| 843 | void (*issue_afs_rpc)(struct afs_operation *op);
|
| 844 | void (*issue_yfs_rpc)(struct afs_operation *op);
|
| 845 | void (*success)(struct afs_operation *op);
|
| 846 | void (*aborted)(struct afs_operation *op);
|
| 847 | void (*failed)(struct afs_operation *op);
|
| 848 | void (*edit_dir)(struct afs_operation *op);
|
| 849 | void (*put)(struct afs_operation *op);
|
| 850 | };
|
| 851 |
|
| 852 | struct afs_vnode_param {
|
| 853 | struct afs_vnode *vnode;
|
| 854 | struct afs_fid fid;
|
| 855 | struct afs_status_cb scb;
|
| 856 | afs_dataversion_t dv_before;
|
| 857 | unsigned int cb_break_before;
|
| 858 | u8 dv_delta;
|
| 859 | bool put_vnode:1;
|
| 860 | bool need_io_lock:1;
|
| 861 | bool update_ctime:1;
|
| 862 | bool set_size:1;
|
| 863 | bool op_unlinked:1;
|
| 864 | bool speculative:1;
|
| 865 | bool modification:1;
|
| 866 | };
|
| 867 |
|
| 868 | |
| 869 | * Fileserver operation wrapper, handling server and address rotation
|
| 870 | * asynchronously. May make simultaneous calls to multiple servers.
|
| 871 |
|
| 872 | struct afs_operation {
|
| 873 | struct afs_net *net;
|
| 874 | struct key *key;
|
| 875 | const struct afs_call_type *type;
|
| 876 | const struct afs_operation_ops *ops;
|
| 877 |
|
| 878 |
|
| 879 | struct afs_volume *volume;
|
| 880 | struct afs_vnode_param file[2];
|
| 881 | struct afs_vnode_param *more_files;
|
| 882 | struct afs_volsync pre_volsync;
|
| 883 | struct afs_volsync volsync;
|
| 884 | struct dentry *dentry;
|
| 885 | struct dentry *dentry_2;
|
| 886 | struct timespec64 mtime;
|
| 887 | struct timespec64 ctime;
|
| 888 | struct afs_error cumul_error;
|
| 889 | short nr_files;
|
| 890 | unsigned int debug_id;
|
| 891 |
|
| 892 | unsigned int cb_v_break;
|
| 893 |
|
| 894 | union {
|
| 895 | struct {
|
| 896 | int which;
|
| 897 | } fetch_status;
|
| 898 | struct {
|
| 899 | int reason;
|
| 900 | mode_t mode;
|
| 901 | struct afs_symlink *symlink;
|
| 902 | } create;
|
| 903 | struct {
|
| 904 | bool need_rehash;
|
| 905 | } unlink;
|
| 906 | struct {
|
| 907 | struct dentry *rehash;
|
| 908 | struct dentry *tmp;
|
| 909 | unsigned int rename_flags;
|
| 910 | bool new_negative;
|
| 911 | } rename;
|
| 912 | struct {
|
| 913 | struct netfs_io_subrequest *subreq;
|
| 914 | } fetch;
|
| 915 | struct {
|
| 916 | afs_lock_type_t type;
|
| 917 | } lock;
|
| 918 | struct {
|
| 919 | struct iov_iter *write_iter;
|
| 920 | loff_t pos;
|
| 921 | loff_t size;
|
| 922 | loff_t i_size;
|
| 923 | } store;
|
| 924 | struct {
|
| 925 | struct iattr *attr;
|
| 926 | loff_t old_i_size;
|
| 927 | } setattr;
|
| 928 | struct afs_acl *acl;
|
| 929 | struct yfs_acl *yacl;
|
| 930 | struct {
|
| 931 | struct afs_volume_status vs;
|
| 932 | struct kstatfs *buf;
|
| 933 | } volstatus;
|
| 934 | };
|
| 935 |
|
| 936 |
|
| 937 | struct afs_server_list *server_list;
|
| 938 | struct afs_server *server;
|
| 939 | struct afs_endpoint_state *estate;
|
| 940 | struct afs_server_state *server_states;
|
| 941 | struct afs_call *call;
|
| 942 | unsigned long untried_servers;
|
| 943 | unsigned long addr_tried;
|
| 944 | s32 call_abort_code;
|
| 945 | short call_error;
|
| 946 | short server_index;
|
| 947 | short nr_iterations;
|
| 948 | signed char addr_index;
|
| 949 | bool call_responded;
|
| 950 |
|
| 951 | unsigned int flags;
|
| 952 | #define AFS_OPERATION_STOP 0x0001
|
| 953 | #define AFS_OPERATION_VBUSY 0x0002
|
| 954 | #define AFS_OPERATION_VMOVED 0x0004
|
| 955 | #define AFS_OPERATION_VNOVOL 0x0008
|
| 956 | #define AFS_OPERATION_CUR_ONLY 0x0010
|
| 957 | #define AFS_OPERATION_NO_VSLEEP 0x0020
|
| 958 | #define AFS_OPERATION_UNINTR 0x0040
|
| 959 | #define AFS_OPERATION_DOWNGRADE 0x0080
|
| 960 | #define AFS_OPERATION_LOCK_0 0x0100
|
| 961 | #define AFS_OPERATION_LOCK_1 0x0200
|
| 962 | #define AFS_OPERATION_TRIED_ALL 0x0400
|
| 963 | #define AFS_OPERATION_RETRY_SERVER 0x0800
|
| 964 | #define AFS_OPERATION_DIR_CONFLICT 0x1000
|
| 965 | #define AFS_OPERATION_ASYNC 0x2000
|
| 966 | };
|
| 967 |
|
| 968 | |
| 969 | * Cache auxiliary data.
|
| 970 |
|
| 971 | struct afs_vnode_cache_aux {
|
| 972 | __be64 data_version;
|
| 973 | } __packed;
|
| 974 |
|
| 975 | static inline void afs_set_cache_aux(struct afs_vnode *vnode,
|
| 976 | struct afs_vnode_cache_aux *aux)
|
| 977 | {
|
| 978 | aux->data_version = cpu_to_be64(vnode->status.data_version);
|
| 979 | }
|
| 980 |
|
| 981 | static inline void afs_invalidate_cache(struct afs_vnode *vnode, unsigned int flags)
|
| 982 | {
|
| 983 | struct afs_vnode_cache_aux aux;
|
| 984 |
|
| 985 | afs_set_cache_aux(vnode, &aux);
|
| 986 | fscache_invalidate(afs_vnode_cache(vnode), &aux,
|
| 987 | i_size_read(&vnode->netfs.inode), flags);
|
| 988 | }
|
| 989 |
|
| 990 | |
| 991 | * Directory iteration management.
|
| 992 |
|
| 993 | struct afs_dir_iter {
|
| 994 | struct afs_vnode *dvnode;
|
| 995 | union afs_xdr_dir_block *block;
|
| 996 | struct folio_queue *fq;
|
| 997 | unsigned int fpos;
|
| 998 | int fq_slot;
|
| 999 | unsigned int loop_check;
|
| 1000 | u8 nr_slots;
|
| 1001 | u8 bucket;
|
| 1002 | unsigned int prev_entry;
|
| 1003 | };
|
| 1004 |
|
| 1005 | #include <trace/events/afs.h>
|
| 1006 |
|
| 1007 |
|
| 1008 | |
| 1009 | * addr_list.c
|
| 1010 |
|
| 1011 | struct afs_addr_list *afs_get_addrlist(struct afs_addr_list *alist, enum afs_alist_trace reason);
|
| 1012 | extern struct afs_addr_list *afs_alloc_addrlist(unsigned int nr);
|
| 1013 | extern void afs_put_addrlist(struct afs_addr_list *alist, enum afs_alist_trace reason);
|
| 1014 | extern struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *,
|
| 1015 | const char *, size_t, char,
|
| 1016 | unsigned short, unsigned short);
|
| 1017 | bool afs_addr_list_same(const struct afs_addr_list *a,
|
| 1018 | const struct afs_addr_list *b);
|
| 1019 | extern struct afs_vlserver_list *afs_dns_query(struct afs_cell *, time64_t *);
|
| 1020 |
|
| 1021 | extern int afs_merge_fs_addr4(struct afs_net *net, struct afs_addr_list *addr,
|
| 1022 | __be32 xdr, u16 port);
|
| 1023 | extern int afs_merge_fs_addr6(struct afs_net *net, struct afs_addr_list *addr,
|
| 1024 | __be32 *xdr, u16 port);
|
| 1025 | void afs_set_peer_appdata(struct afs_server *server,
|
| 1026 | struct afs_addr_list *old_alist,
|
| 1027 | struct afs_addr_list *new_alist);
|
| 1028 |
|
| 1029 | |
| 1030 | * addr_prefs.c
|
| 1031 |
|
| 1032 | int afs_proc_addr_prefs_write(struct file *file, char *buf, size_t size);
|
| 1033 | void afs_get_address_preferences_rcu(struct afs_net *net, struct afs_addr_list *alist);
|
| 1034 | void afs_get_address_preferences(struct afs_net *net, struct afs_addr_list *alist);
|
| 1035 |
|
| 1036 | |
| 1037 | * callback.c
|
| 1038 |
|
| 1039 | extern void afs_invalidate_mmap_work(struct work_struct *);
|
| 1040 | extern void afs_init_callback_state(struct afs_server *);
|
| 1041 | extern void __afs_break_callback(struct afs_vnode *, enum afs_cb_break_reason);
|
| 1042 | extern void afs_break_callback(struct afs_vnode *, enum afs_cb_break_reason);
|
| 1043 | extern void afs_break_callbacks(struct afs_server *, size_t, struct afs_callback_break *);
|
| 1044 |
|
| 1045 | static inline unsigned int afs_calc_vnode_cb_break(struct afs_vnode *vnode)
|
| 1046 | {
|
| 1047 | return vnode->cb_break + vnode->cb_ro_snapshot + vnode->cb_scrub;
|
| 1048 | }
|
| 1049 |
|
| 1050 | static inline bool afs_cb_is_broken(unsigned int cb_break,
|
| 1051 | const struct afs_vnode *vnode)
|
| 1052 | {
|
| 1053 | return cb_break != (vnode->cb_break +
|
| 1054 | atomic_read(&vnode->volume->cb_ro_snapshot) +
|
| 1055 | atomic_read(&vnode->volume->cb_scrub));
|
| 1056 | }
|
| 1057 |
|
| 1058 | |
| 1059 | * cell.c
|
| 1060 |
|
| 1061 | extern int afs_cell_init(struct afs_net *, const char *);
|
| 1062 | extern struct afs_cell *afs_find_cell(struct afs_net *, const char *, unsigned,
|
| 1063 | enum afs_cell_trace);
|
| 1064 | enum afs_lookup_cell_for {
|
| 1065 | AFS_LOOKUP_CELL_DYNROOT,
|
| 1066 | AFS_LOOKUP_CELL_MOUNTPOINT,
|
| 1067 | AFS_LOOKUP_CELL_DIRECT_MOUNT,
|
| 1068 | AFS_LOOKUP_CELL_PRELOAD,
|
| 1069 | AFS_LOOKUP_CELL_ROOTCELL,
|
| 1070 | AFS_LOOKUP_CELL_ALIAS_CHECK,
|
| 1071 | };
|
| 1072 | struct afs_cell *afs_lookup_cell(struct afs_net *net,
|
| 1073 | const char *name, unsigned int namesz,
|
| 1074 | const char *vllist,
|
| 1075 | enum afs_lookup_cell_for reason,
|
| 1076 | enum afs_cell_trace trace);
|
| 1077 | extern struct afs_cell *afs_use_cell(struct afs_cell *, enum afs_cell_trace);
|
| 1078 | void afs_unuse_cell(struct afs_cell *cell, enum afs_cell_trace reason);
|
| 1079 | extern struct afs_cell *afs_get_cell(struct afs_cell *, enum afs_cell_trace);
|
| 1080 | extern void afs_see_cell(struct afs_cell *, enum afs_cell_trace);
|
| 1081 | extern void afs_put_cell(struct afs_cell *, enum afs_cell_trace);
|
| 1082 | extern void afs_queue_cell(struct afs_cell *, enum afs_cell_trace);
|
| 1083 | void afs_set_cell_timer(struct afs_cell *cell, unsigned int delay_secs);
|
| 1084 | extern void __net_exit afs_cell_purge(struct afs_net *);
|
| 1085 |
|
| 1086 | |
| 1087 | * cmservice.c
|
| 1088 |
|
| 1089 | extern bool afs_cm_incoming_call(struct afs_call *);
|
| 1090 |
|
| 1091 | |
| 1092 | * cm_security.c
|
| 1093 |
|
| 1094 | void afs_process_oob_queue(struct work_struct *work);
|
| 1095 | #ifdef CONFIG_RXGK
|
| 1096 | int afs_create_token_key(struct afs_net *net, struct socket *socket);
|
| 1097 | #else
|
| 1098 | static inline int afs_create_token_key(struct afs_net *net, struct socket *socket)
|
| 1099 | {
|
| 1100 | return 0;
|
| 1101 | }
|
| 1102 | #endif
|
| 1103 |
|
| 1104 | |
| 1105 | * dir.c
|
| 1106 |
|
| 1107 | extern const struct file_operations afs_dir_file_operations;
|
| 1108 | extern const struct inode_operations afs_dir_inode_operations;
|
| 1109 | extern const struct address_space_operations afs_dir_aops;
|
| 1110 | extern const struct dentry_operations afs_fs_dentry_operations;
|
| 1111 |
|
| 1112 | ssize_t afs_read_dir(struct afs_vnode *dvnode, struct file *file)
|
| 1113 | __acquires(&dvnode->validate_lock);
|
| 1114 | extern void afs_d_release(struct dentry *);
|
| 1115 | extern void afs_check_for_remote_deletion(struct afs_operation *);
|
| 1116 |
|
| 1117 | |
| 1118 | * dir_edit.c
|
| 1119 |
|
| 1120 | extern void afs_edit_dir_add(struct afs_vnode *, const struct qstr *, struct afs_fid *,
|
| 1121 | enum afs_edit_dir_reason);
|
| 1122 | extern void afs_edit_dir_remove(struct afs_vnode *, const struct qstr *, enum afs_edit_dir_reason);
|
| 1123 | void afs_edit_dir_update(struct afs_vnode *vnode, const struct qstr *name,
|
| 1124 | struct afs_vnode *new_dvnode, enum afs_edit_dir_reason why);
|
| 1125 | void afs_mkdir_init_dir(struct afs_vnode *dvnode, struct afs_vnode *parent_vnode);
|
| 1126 |
|
| 1127 | |
| 1128 | * dir_search.c
|
| 1129 |
|
| 1130 | unsigned int afs_dir_hash_name(const struct qstr *name);
|
| 1131 | bool afs_dir_init_iter(struct afs_dir_iter *iter, const struct qstr *name);
|
| 1132 | union afs_xdr_dir_block *afs_dir_find_block(struct afs_dir_iter *iter, size_t block);
|
| 1133 | int afs_dir_search_bucket(struct afs_dir_iter *iter, const struct qstr *name,
|
| 1134 | struct afs_fid *_fid);
|
| 1135 | int afs_dir_search(struct afs_vnode *dvnode, const struct qstr *name,
|
| 1136 | struct afs_fid *_fid, afs_dataversion_t *_dir_version);
|
| 1137 |
|
| 1138 | static inline void afs_dir_end_iter(struct afs_dir_iter *iter)
|
| 1139 | {
|
| 1140 | if (iter->block) {
|
| 1141 | kunmap_local(iter->block);
|
| 1142 | iter->block = NULL;
|
| 1143 | }
|
| 1144 | }
|
| 1145 |
|
| 1146 | |
| 1147 | * dir_silly.c
|
| 1148 |
|
| 1149 | extern int afs_sillyrename(struct afs_vnode *, struct afs_vnode *,
|
| 1150 | struct dentry *, struct key *);
|
| 1151 | extern int afs_silly_iput(struct dentry *, struct inode *);
|
| 1152 |
|
| 1153 | |
| 1154 | * dynroot.c
|
| 1155 |
|
| 1156 | extern const struct inode_operations afs_dynroot_inode_operations;
|
| 1157 | extern const struct dentry_operations afs_dynroot_dentry_operations;
|
| 1158 |
|
| 1159 | struct inode *afs_dynroot_iget_root(struct super_block *sb);
|
| 1160 |
|
| 1161 | |
| 1162 | * file.c
|
| 1163 |
|
| 1164 | extern const struct address_space_operations afs_file_aops;
|
| 1165 | extern const struct inode_operations afs_file_inode_operations;
|
| 1166 | extern const struct file_operations afs_file_operations;
|
| 1167 | extern const struct afs_operation_ops afs_fetch_data_operation;
|
| 1168 | extern const struct netfs_request_ops afs_req_ops;
|
| 1169 |
|
| 1170 | extern int afs_cache_wb_key(struct afs_vnode *, struct afs_file *);
|
| 1171 | extern void afs_put_wb_key(struct afs_wb_key *);
|
| 1172 | extern int afs_open(struct inode *, struct file *);
|
| 1173 | extern int afs_release(struct inode *, struct file *);
|
| 1174 | void afs_fetch_data_async_rx(struct work_struct *work);
|
| 1175 | void afs_fetch_data_immediate_cancel(struct afs_call *call);
|
| 1176 | void afs_set_i_size(struct afs_vnode *vnode, uoff_t new_i_size);
|
| 1177 |
|
| 1178 | |
| 1179 | * flock.c
|
| 1180 |
|
| 1181 | extern struct workqueue_struct *afs_lock_manager;
|
| 1182 |
|
| 1183 | extern void afs_lock_op_done(struct afs_call *);
|
| 1184 | extern void afs_lock_work(struct work_struct *);
|
| 1185 | extern void afs_lock_may_be_available(struct afs_vnode *);
|
| 1186 | extern int afs_lock(struct file *, int, struct file_lock *);
|
| 1187 | extern int afs_flock(struct file *, int, struct file_lock *);
|
| 1188 |
|
| 1189 | |
| 1190 | * fsclient.c
|
| 1191 |
|
| 1192 | extern void afs_fs_fetch_status(struct afs_operation *);
|
| 1193 | extern void afs_fs_fetch_data(struct afs_operation *);
|
| 1194 | extern void afs_fs_create_file(struct afs_operation *);
|
| 1195 | extern void afs_fs_make_dir(struct afs_operation *);
|
| 1196 | extern void afs_fs_remove_file(struct afs_operation *);
|
| 1197 | extern void afs_fs_remove_dir(struct afs_operation *);
|
| 1198 | extern void afs_fs_link(struct afs_operation *);
|
| 1199 | extern void afs_fs_symlink(struct afs_operation *);
|
| 1200 | extern void afs_fs_rename(struct afs_operation *);
|
| 1201 | extern void afs_fs_store_data(struct afs_operation *);
|
| 1202 | extern void afs_fs_setattr(struct afs_operation *);
|
| 1203 | extern void afs_fs_get_volume_status(struct afs_operation *);
|
| 1204 | extern void afs_fs_set_lock(struct afs_operation *);
|
| 1205 | extern void afs_fs_extend_lock(struct afs_operation *);
|
| 1206 | extern void afs_fs_release_lock(struct afs_operation *);
|
| 1207 | int afs_fs_give_up_all_callbacks(struct afs_net *net, struct afs_server *server,
|
| 1208 | struct afs_address *addr, struct key *key);
|
| 1209 | bool afs_fs_get_capabilities(struct afs_net *net, struct afs_server *server,
|
| 1210 | struct afs_endpoint_state *estate, unsigned int addr_index,
|
| 1211 | struct key *key);
|
| 1212 | extern void afs_fs_inline_bulk_status(struct afs_operation *);
|
| 1213 |
|
| 1214 | struct afs_acl {
|
| 1215 | u32 size;
|
| 1216 | u8 data[] __counted_by(size);
|
| 1217 | };
|
| 1218 |
|
| 1219 | extern void afs_fs_fetch_acl(struct afs_operation *);
|
| 1220 | extern void afs_fs_store_acl(struct afs_operation *);
|
| 1221 |
|
| 1222 | |
| 1223 | * fs_operation.c
|
| 1224 |
|
| 1225 | extern struct afs_operation *afs_alloc_operation(struct key *, struct afs_volume *);
|
| 1226 | extern int afs_put_operation(struct afs_operation *);
|
| 1227 | extern bool afs_begin_vnode_operation(struct afs_operation *);
|
| 1228 | extern void afs_end_vnode_operation(struct afs_operation *op);
|
| 1229 | extern void afs_wait_for_operation(struct afs_operation *);
|
| 1230 | extern int afs_do_sync_operation(struct afs_operation *);
|
| 1231 |
|
| 1232 | static inline void afs_op_set_vnode(struct afs_operation *op, unsigned int n,
|
| 1233 | struct afs_vnode *vnode)
|
| 1234 | {
|
| 1235 | op->file[n].vnode = vnode;
|
| 1236 | op->file[n].need_io_lock = true;
|
| 1237 | }
|
| 1238 |
|
| 1239 | static inline void afs_op_set_fid(struct afs_operation *op, unsigned int n,
|
| 1240 | const struct afs_fid *fid)
|
| 1241 | {
|
| 1242 | op->file[n].fid = *fid;
|
| 1243 | }
|
| 1244 |
|
| 1245 | |
| 1246 | * fs_probe.c
|
| 1247 |
|
| 1248 | struct afs_endpoint_state *afs_get_endpoint_state(struct afs_endpoint_state *estate,
|
| 1249 | enum afs_estate_trace where);
|
| 1250 | void afs_put_endpoint_state(struct afs_endpoint_state *estate, enum afs_estate_trace where);
|
| 1251 | extern void afs_fileserver_probe_result(struct afs_call *);
|
| 1252 | int afs_fs_probe_fileserver(struct afs_net *net, struct afs_server *server,
|
| 1253 | struct afs_addr_list *new_alist, struct key *key);
|
| 1254 | int afs_wait_for_fs_probes(struct afs_operation *op, struct afs_server_state *states, bool intr);
|
| 1255 | extern void afs_probe_fileserver(struct afs_net *, struct afs_server *);
|
| 1256 | extern void afs_fs_probe_dispatcher(struct work_struct *);
|
| 1257 | int afs_wait_for_one_fs_probe(struct afs_server *server, struct afs_endpoint_state *estate,
|
| 1258 | unsigned long exclude, bool is_intr);
|
| 1259 | extern void afs_fs_probe_cleanup(struct afs_net *);
|
| 1260 |
|
| 1261 | |
| 1262 | * inode.c
|
| 1263 |
|
| 1264 | extern const struct afs_operation_ops afs_fetch_status_operation;
|
| 1265 |
|
| 1266 | extern void afs_vnode_commit_status(struct afs_operation *, struct afs_vnode_param *);
|
| 1267 | extern int afs_fetch_status(struct afs_vnode *, struct key *, bool, afs_access_t *);
|
| 1268 | extern int afs_ilookup5_test_by_fid(struct inode *, void *);
|
| 1269 | extern struct inode *afs_iget(struct afs_operation *, struct afs_vnode_param *);
|
| 1270 | extern struct inode *afs_root_iget(struct super_block *, struct key *);
|
| 1271 | extern int afs_getattr(const struct mnt_idmap *idmap, const struct path *,
|
| 1272 | struct kstat *, u32, unsigned int);
|
| 1273 | extern int afs_setattr(const struct mnt_idmap *idmap, struct dentry *, struct iattr *);
|
| 1274 | extern void afs_evict_inode(struct inode *);
|
| 1275 | extern int afs_drop_inode(struct inode *);
|
| 1276 |
|
| 1277 | |
| 1278 | * main.c
|
| 1279 |
|
| 1280 | extern struct workqueue_struct *afs_wq;
|
| 1281 | extern int afs_net_id;
|
| 1282 |
|
| 1283 | static inline struct afs_net *afs_net(struct net *net)
|
| 1284 | {
|
| 1285 | return net_generic(net, afs_net_id);
|
| 1286 | }
|
| 1287 |
|
| 1288 | static inline struct afs_net *afs_sb2net(struct super_block *sb)
|
| 1289 | {
|
| 1290 | return afs_net(AFS_FS_S(sb)->net_ns);
|
| 1291 | }
|
| 1292 |
|
| 1293 | static inline struct afs_net *afs_d2net(struct dentry *dentry)
|
| 1294 | {
|
| 1295 | return afs_sb2net(dentry->d_sb);
|
| 1296 | }
|
| 1297 |
|
| 1298 | static inline struct afs_net *afs_i2net(struct inode *inode)
|
| 1299 | {
|
| 1300 | return afs_sb2net(inode->i_sb);
|
| 1301 | }
|
| 1302 |
|
| 1303 | static inline struct afs_net *afs_v2net(struct afs_vnode *vnode)
|
| 1304 | {
|
| 1305 | return afs_i2net(&vnode->netfs.inode);
|
| 1306 | }
|
| 1307 |
|
| 1308 | static inline struct afs_net *afs_sock2net(struct sock *sk)
|
| 1309 | {
|
| 1310 | return net_generic(sock_net(sk), afs_net_id);
|
| 1311 | }
|
| 1312 |
|
| 1313 | static inline void __afs_stat(atomic_t *s)
|
| 1314 | {
|
| 1315 | atomic_inc(s);
|
| 1316 | }
|
| 1317 |
|
| 1318 | #define afs_stat_v(vnode, n) __afs_stat(&afs_v2net(vnode)->n)
|
| 1319 |
|
| 1320 | |
| 1321 | * misc.c
|
| 1322 |
|
| 1323 | extern int afs_abort_to_error(u32);
|
| 1324 | extern void afs_prioritise_error(struct afs_error *, int, u32);
|
| 1325 |
|
| 1326 | static inline void afs_op_nomem(struct afs_operation *op)
|
| 1327 | {
|
| 1328 | op->cumul_error.error = -ENOMEM;
|
| 1329 | }
|
| 1330 |
|
| 1331 | static inline int afs_op_error(const struct afs_operation *op)
|
| 1332 | {
|
| 1333 | return op->cumul_error.error;
|
| 1334 | }
|
| 1335 |
|
| 1336 | static inline s32 afs_op_abort_code(const struct afs_operation *op)
|
| 1337 | {
|
| 1338 | return op->cumul_error.abort_code;
|
| 1339 | }
|
| 1340 |
|
| 1341 | static inline int afs_op_set_error(struct afs_operation *op, int error)
|
| 1342 | {
|
| 1343 | return op->cumul_error.error = error;
|
| 1344 | }
|
| 1345 |
|
| 1346 | static inline void afs_op_accumulate_error(struct afs_operation *op, int error, s32 abort_code)
|
| 1347 | {
|
| 1348 | afs_prioritise_error(&op->cumul_error, error, abort_code);
|
| 1349 | }
|
| 1350 |
|
| 1351 | |
| 1352 | * mntpt.c
|
| 1353 |
|
| 1354 | extern const struct inode_operations afs_mntpt_inode_operations;
|
| 1355 | extern const struct inode_operations afs_autocell_inode_operations;
|
| 1356 | extern const struct file_operations afs_mntpt_file_operations;
|
| 1357 |
|
| 1358 | extern struct vfsmount *afs_d_automount(struct path *);
|
| 1359 | extern void afs_mntpt_kill_timer(void);
|
| 1360 |
|
| 1361 | |
| 1362 | * proc.c
|
| 1363 |
|
| 1364 | #ifdef CONFIG_PROC_FS
|
| 1365 | extern int __net_init afs_proc_init(struct afs_net *);
|
| 1366 | extern void __net_exit afs_proc_cleanup(struct afs_net *);
|
| 1367 | extern int afs_proc_cell_setup(struct afs_cell *);
|
| 1368 | extern void afs_proc_cell_remove(struct afs_cell *);
|
| 1369 | extern void afs_put_sysnames(struct afs_sysnames *);
|
| 1370 | #else
|
| 1371 | static inline int afs_proc_init(struct afs_net *net) { return 0; }
|
| 1372 | static inline void afs_proc_cleanup(struct afs_net *net) {}
|
| 1373 | static inline int afs_proc_cell_setup(struct afs_cell *cell) { return 0; }
|
| 1374 | static inline void afs_proc_cell_remove(struct afs_cell *cell) {}
|
| 1375 | static inline void afs_put_sysnames(struct afs_sysnames *sysnames) {}
|
| 1376 | #endif
|
| 1377 |
|
| 1378 | |
| 1379 | * rotate.c
|
| 1380 |
|
| 1381 | void afs_clear_server_states(struct afs_operation *op);
|
| 1382 | extern bool afs_select_fileserver(struct afs_operation *);
|
| 1383 | extern void afs_dump_edestaddrreq(const struct afs_operation *);
|
| 1384 |
|
| 1385 | |
| 1386 | * rxrpc.c
|
| 1387 |
|
| 1388 | extern struct workqueue_struct *afs_async_calls;
|
| 1389 |
|
| 1390 | extern int __net_init afs_open_socket(struct afs_net *);
|
| 1391 | extern void __net_exit afs_close_socket(struct afs_net *);
|
| 1392 | extern void afs_charge_preallocation(struct work_struct *);
|
| 1393 | extern void afs_put_call(struct afs_call *);
|
| 1394 | void afs_deferred_put_call(struct afs_call *call);
|
| 1395 | void afs_make_call(struct afs_call *call, gfp_t gfp);
|
| 1396 | void afs_deliver_to_call(struct afs_call *call);
|
| 1397 | void afs_wait_for_call_to_complete(struct afs_call *call);
|
| 1398 | extern struct afs_call *afs_alloc_flat_call(struct afs_net *,
|
| 1399 | const struct afs_call_type *,
|
| 1400 | size_t, size_t);
|
| 1401 | extern void afs_flat_call_destructor(struct afs_call *);
|
| 1402 | extern void afs_send_empty_reply(struct afs_call *);
|
| 1403 | extern void afs_send_simple_reply(struct afs_call *, const void *, size_t);
|
| 1404 | extern int afs_extract_data(struct afs_call *, bool);
|
| 1405 | extern int afs_protocol_error(struct afs_call *, enum afs_eproto_cause);
|
| 1406 |
|
| 1407 | static inline struct afs_call *afs_get_call(struct afs_call *call,
|
| 1408 | enum afs_call_trace why)
|
| 1409 | {
|
| 1410 | int r;
|
| 1411 |
|
| 1412 | __refcount_inc(&call->ref, &r);
|
| 1413 |
|
| 1414 | trace_afs_call(call->debug_id, why, r + 1,
|
| 1415 | atomic_read(&call->net->nr_outstanding_calls),
|
| 1416 | __builtin_return_address(0));
|
| 1417 | return call;
|
| 1418 | }
|
| 1419 |
|
| 1420 | static inline void afs_see_call(struct afs_call *call, enum afs_call_trace why)
|
| 1421 | {
|
| 1422 | int r = refcount_read(&call->ref);
|
| 1423 |
|
| 1424 | trace_afs_call(call->debug_id, why, r,
|
| 1425 | atomic_read(&call->net->nr_outstanding_calls),
|
| 1426 | __builtin_return_address(0));
|
| 1427 | }
|
| 1428 |
|
| 1429 | static inline void afs_make_op_call(struct afs_operation *op, struct afs_call *call,
|
| 1430 | gfp_t gfp)
|
| 1431 | {
|
| 1432 | struct afs_addr_list *alist = op->estate->addresses;
|
| 1433 |
|
| 1434 | op->call = afs_get_call(call, afs_call_trace_get);
|
| 1435 | op->type = call->type;
|
| 1436 | call->op = op;
|
| 1437 | call->key = op->key;
|
| 1438 | call->intr = !(op->flags & AFS_OPERATION_UNINTR);
|
| 1439 | call->peer = rxrpc_kernel_get_peer(alist->addrs[op->addr_index].peer);
|
| 1440 | call->service_id = op->server->service_id;
|
| 1441 | afs_make_call(call, gfp);
|
| 1442 | afs_put_call(call);
|
| 1443 | }
|
| 1444 |
|
| 1445 | static inline void afs_extract_begin(struct afs_call *call, void *buf, size_t size)
|
| 1446 | {
|
| 1447 | call->iov_len = size;
|
| 1448 | call->kvec[0].iov_base = buf;
|
| 1449 | call->kvec[0].iov_len = size;
|
| 1450 | iov_iter_kvec(&call->def_iter, ITER_DEST, call->kvec, 1, size);
|
| 1451 | }
|
| 1452 |
|
| 1453 | static inline void afs_extract_to_tmp(struct afs_call *call)
|
| 1454 | {
|
| 1455 | call->iov_len = sizeof(call->tmp);
|
| 1456 | afs_extract_begin(call, &call->tmp, sizeof(call->tmp));
|
| 1457 | }
|
| 1458 |
|
| 1459 | static inline void afs_extract_to_tmp64(struct afs_call *call)
|
| 1460 | {
|
| 1461 | call->iov_len = sizeof(call->tmp64);
|
| 1462 | afs_extract_begin(call, &call->tmp64, sizeof(call->tmp64));
|
| 1463 | }
|
| 1464 |
|
| 1465 | static inline void afs_extract_discard(struct afs_call *call, size_t size)
|
| 1466 | {
|
| 1467 | call->iov_len = size;
|
| 1468 | iov_iter_discard(&call->def_iter, ITER_DEST, size);
|
| 1469 | }
|
| 1470 |
|
| 1471 | static inline void afs_extract_to_buf(struct afs_call *call, size_t size)
|
| 1472 | {
|
| 1473 | call->iov_len = size;
|
| 1474 | afs_extract_begin(call, call->buffer, size);
|
| 1475 | }
|
| 1476 |
|
| 1477 | static inline int afs_transfer_reply(struct afs_call *call)
|
| 1478 | {
|
| 1479 | return afs_extract_data(call, false);
|
| 1480 | }
|
| 1481 |
|
| 1482 | static inline bool afs_check_call_state(struct afs_call *call,
|
| 1483 | enum afs_call_state state)
|
| 1484 | {
|
| 1485 | return READ_ONCE(call->state) == state;
|
| 1486 | }
|
| 1487 |
|
| 1488 | static inline bool afs_set_call_state(struct afs_call *call,
|
| 1489 | enum afs_call_state from,
|
| 1490 | enum afs_call_state to)
|
| 1491 | {
|
| 1492 | bool ok = false;
|
| 1493 |
|
| 1494 | spin_lock_bh(&call->state_lock);
|
| 1495 | if (call->state == from) {
|
| 1496 | call->state = to;
|
| 1497 | trace_afs_call_state(call, from, to, 0, 0);
|
| 1498 | ok = true;
|
| 1499 | }
|
| 1500 | spin_unlock_bh(&call->state_lock);
|
| 1501 | return ok;
|
| 1502 | }
|
| 1503 |
|
| 1504 | static inline void afs_set_call_complete(struct afs_call *call,
|
| 1505 | int error, u32 remote_abort)
|
| 1506 | {
|
| 1507 | enum afs_call_state state;
|
| 1508 | bool ok = false;
|
| 1509 |
|
| 1510 | spin_lock_bh(&call->state_lock);
|
| 1511 | state = call->state;
|
| 1512 | if (state != AFS_CALL_COMPLETE) {
|
| 1513 | call->abort_code = remote_abort;
|
| 1514 | call->error = error;
|
| 1515 | call->state = AFS_CALL_COMPLETE;
|
| 1516 | trace_afs_call_state(call, state, AFS_CALL_COMPLETE,
|
| 1517 | error, remote_abort);
|
| 1518 | ok = true;
|
| 1519 | }
|
| 1520 | spin_unlock_bh(&call->state_lock);
|
| 1521 | if (ok) {
|
| 1522 | trace_afs_call_done(call);
|
| 1523 |
|
| 1524 | |
| 1525 | * one queued with the work item - and we can't just deallocate the
|
| 1526 | * call because the work item may be queued again.
|
| 1527 |
|
| 1528 | if (call->drop_ref)
|
| 1529 | afs_put_call(call);
|
| 1530 | }
|
| 1531 | }
|
| 1532 |
|
| 1533 | |
| 1534 | * security.c
|
| 1535 |
|
| 1536 | extern void afs_put_permits(struct afs_permits *);
|
| 1537 | extern void afs_clear_permits(struct afs_vnode *);
|
| 1538 | extern void afs_cache_permit(struct afs_vnode *, struct key *, unsigned int,
|
| 1539 | struct afs_status_cb *);
|
| 1540 | extern struct key *afs_request_key(struct afs_cell *);
|
| 1541 | extern struct key *afs_request_key_rcu(struct afs_cell *);
|
| 1542 | extern int afs_check_permit(struct afs_vnode *, struct key *, afs_access_t *);
|
| 1543 | extern int afs_permission(const struct mnt_idmap *, struct inode *, int);
|
| 1544 | extern void __exit afs_clean_up_permit_cache(void);
|
| 1545 |
|
| 1546 | |
| 1547 | * server.c
|
| 1548 |
|
| 1549 | extern spinlock_t afs_server_peer_lock;
|
| 1550 |
|
| 1551 | struct afs_server *afs_find_server(const struct rxrpc_peer *peer);
|
| 1552 | extern struct afs_server *afs_lookup_server(struct afs_cell *, struct key *, const uuid_t *, u32);
|
| 1553 | extern struct afs_server *afs_get_server(struct afs_server *, enum afs_server_trace);
|
| 1554 | struct afs_server *afs_use_server(struct afs_server *server, bool activate,
|
| 1555 | enum afs_server_trace reason);
|
| 1556 | void afs_unuse_server(struct afs_net *net, struct afs_server *server,
|
| 1557 | enum afs_server_trace reason);
|
| 1558 | void afs_unuse_server_notime(struct afs_net *net, struct afs_server *server,
|
| 1559 | enum afs_server_trace reason);
|
| 1560 | extern void afs_put_server(struct afs_net *, struct afs_server *, enum afs_server_trace);
|
| 1561 | void afs_purge_servers(struct afs_cell *cell);
|
| 1562 | extern void afs_fs_probe_timer(struct timer_list *);
|
| 1563 | void __net_exit afs_wait_for_servers(struct afs_net *net);
|
| 1564 | bool afs_check_server_record(struct afs_operation *op, struct afs_server *server, struct key *key);
|
| 1565 |
|
| 1566 | static inline void afs_see_server(struct afs_server *server, enum afs_server_trace trace)
|
| 1567 | {
|
| 1568 | int r = refcount_read(&server->ref);
|
| 1569 | int a = atomic_read(&server->active);
|
| 1570 |
|
| 1571 | trace_afs_server(server->debug_id, r, a, trace);
|
| 1572 |
|
| 1573 | }
|
| 1574 |
|
| 1575 | static inline void afs_inc_servers_outstanding(struct afs_net *net)
|
| 1576 | {
|
| 1577 | atomic_inc(&net->servers_outstanding);
|
| 1578 | }
|
| 1579 |
|
| 1580 | static inline void afs_dec_servers_outstanding(struct afs_net *net)
|
| 1581 | {
|
| 1582 | if (atomic_dec_and_test(&net->servers_outstanding))
|
| 1583 | wake_up_var(&net->servers_outstanding);
|
| 1584 | }
|
| 1585 |
|
| 1586 | static inline bool afs_is_probing_server(struct afs_server *server)
|
| 1587 | {
|
| 1588 | return list_empty(&server->probe_link);
|
| 1589 | }
|
| 1590 |
|
| 1591 | |
| 1592 | * server_list.c
|
| 1593 |
|
| 1594 | static inline struct afs_server_list *afs_get_serverlist(struct afs_server_list *slist)
|
| 1595 | {
|
| 1596 | refcount_inc(&slist->usage);
|
| 1597 | return slist;
|
| 1598 | }
|
| 1599 |
|
| 1600 | extern void afs_put_serverlist(struct afs_net *, struct afs_server_list *);
|
| 1601 | struct afs_server_list *afs_alloc_server_list(struct afs_volume *volume,
|
| 1602 | struct key *key,
|
| 1603 | struct afs_vldb_entry *vldb);
|
| 1604 | extern bool afs_annotate_server_list(struct afs_server_list *, struct afs_server_list *);
|
| 1605 | void afs_attach_volume_to_servers(struct afs_volume *volume, struct afs_server_list *slist);
|
| 1606 | void afs_reattach_volume_to_servers(struct afs_volume *volume, struct afs_server_list *slist,
|
| 1607 | struct afs_server_list *old);
|
| 1608 | void afs_detach_volume_from_servers(struct afs_volume *volume, struct afs_server_list *slist);
|
| 1609 |
|
| 1610 | |
| 1611 | * super.c
|
| 1612 |
|
| 1613 | extern int __init afs_fs_init(void);
|
| 1614 | extern void afs_fs_exit(void);
|
| 1615 |
|
| 1616 | |
| 1617 | * symlink.c
|
| 1618 |
|
| 1619 | extern const struct inode_operations afs_symlink_inode_operations;
|
| 1620 | extern const struct address_space_operations afs_symlink_aops;
|
| 1621 |
|
| 1622 | void afs_invalidate_symlink(struct afs_vnode *vnode);
|
| 1623 | void afs_evict_symlink(struct afs_vnode *vnode);
|
| 1624 | void afs_init_new_symlink(struct afs_vnode *vnode, struct afs_operation *op);
|
| 1625 | const char *afs_get_link(struct dentry *dentry, struct inode *inode,
|
| 1626 | struct delayed_call *callback);
|
| 1627 | int afs_readlink(struct dentry *dentry, char __user *buffer, int buflen);
|
| 1628 | int afs_symlink_writepages(struct address_space *mapping,
|
| 1629 | struct writeback_control *wbc);
|
| 1630 |
|
| 1631 | |
| 1632 | * validation.c
|
| 1633 |
|
| 1634 | bool afs_check_validity(const struct afs_vnode *vnode);
|
| 1635 | int afs_update_volume_state(struct afs_operation *op);
|
| 1636 | int afs_validate(struct afs_vnode *vnode, struct key *key);
|
| 1637 |
|
| 1638 | |
| 1639 | * vlclient.c
|
| 1640 |
|
| 1641 | extern struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_vl_cursor *,
|
| 1642 | const char *, int);
|
| 1643 | extern struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *, const uuid_t *);
|
| 1644 | struct afs_call *afs_vl_get_capabilities(struct afs_net *net,
|
| 1645 | struct afs_addr_list *alist,
|
| 1646 | unsigned int addr_index,
|
| 1647 | struct key *key,
|
| 1648 | struct afs_vlserver *server,
|
| 1649 | unsigned int server_index);
|
| 1650 | extern struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *, const uuid_t *);
|
| 1651 | extern char *afs_yfsvl_get_cell_name(struct afs_vl_cursor *);
|
| 1652 |
|
| 1653 | |
| 1654 | * vl_alias.c
|
| 1655 |
|
| 1656 | extern int afs_cell_detect_alias(struct afs_cell *, struct key *);
|
| 1657 |
|
| 1658 | |
| 1659 | * vl_probe.c
|
| 1660 |
|
| 1661 | extern void afs_vlserver_probe_result(struct afs_call *);
|
| 1662 | extern int afs_send_vl_probes(struct afs_net *, struct key *, struct afs_vlserver_list *);
|
| 1663 | extern int afs_wait_for_vl_probes(struct afs_vlserver_list *, unsigned long);
|
| 1664 |
|
| 1665 | |
| 1666 | * vl_rotate.c
|
| 1667 |
|
| 1668 | extern bool afs_begin_vlserver_operation(struct afs_vl_cursor *,
|
| 1669 | struct afs_cell *, struct key *);
|
| 1670 | extern bool afs_select_vlserver(struct afs_vl_cursor *);
|
| 1671 | extern bool afs_select_current_vlserver(struct afs_vl_cursor *);
|
| 1672 | extern int afs_end_vlserver_operation(struct afs_vl_cursor *);
|
| 1673 |
|
| 1674 | |
| 1675 | * vlserver_list.c
|
| 1676 |
|
| 1677 | static inline struct afs_vlserver *afs_get_vlserver(struct afs_vlserver *vlserver)
|
| 1678 | {
|
| 1679 | refcount_inc(&vlserver->ref);
|
| 1680 | return vlserver;
|
| 1681 | }
|
| 1682 |
|
| 1683 | static inline struct afs_vlserver_list *afs_get_vlserverlist(struct afs_vlserver_list *vllist)
|
| 1684 | {
|
| 1685 | if (vllist)
|
| 1686 | refcount_inc(&vllist->ref);
|
| 1687 | return vllist;
|
| 1688 | }
|
| 1689 |
|
| 1690 | extern struct afs_vlserver *afs_alloc_vlserver(const char *, size_t, unsigned short);
|
| 1691 | extern void afs_put_vlserver(struct afs_net *, struct afs_vlserver *);
|
| 1692 | extern struct afs_vlserver_list *afs_alloc_vlserver_list(unsigned int);
|
| 1693 | extern void afs_put_vlserverlist(struct afs_net *, struct afs_vlserver_list *);
|
| 1694 | extern struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *,
|
| 1695 | const void *, size_t);
|
| 1696 |
|
| 1697 | |
| 1698 | * volume.c
|
| 1699 |
|
| 1700 | extern struct afs_volume *afs_create_volume(struct afs_fs_context *);
|
| 1701 | extern int afs_activate_volume(struct afs_volume *);
|
| 1702 | extern void afs_deactivate_volume(struct afs_volume *);
|
| 1703 | bool afs_try_get_volume(struct afs_volume *volume, enum afs_volume_trace reason);
|
| 1704 | extern struct afs_volume *afs_get_volume(struct afs_volume *, enum afs_volume_trace);
|
| 1705 | void afs_put_volume(struct afs_volume *volume, enum afs_volume_trace reason);
|
| 1706 | extern int afs_check_volume_status(struct afs_volume *, struct afs_operation *);
|
| 1707 |
|
| 1708 | |
| 1709 | * write.c
|
| 1710 |
|
| 1711 | void afs_prepare_write(struct netfs_io_subrequest *subreq);
|
| 1712 | void afs_issue_write(struct netfs_io_subrequest *subreq);
|
| 1713 | void afs_begin_writeback(struct netfs_io_request *wreq);
|
| 1714 | void afs_retry_request(struct netfs_io_request *wreq, struct netfs_io_stream *stream);
|
| 1715 | extern int afs_writepages(struct address_space *, struct writeback_control *);
|
| 1716 | extern int afs_fsync(struct file *, loff_t, loff_t, int);
|
| 1717 | extern vm_fault_t afs_page_mkwrite(struct vm_fault *vmf);
|
| 1718 | extern void afs_prune_wb_keys(struct afs_vnode *);
|
| 1719 |
|
| 1720 | |
| 1721 | * xattr.c
|
| 1722 |
|
| 1723 | extern const struct xattr_handler * const afs_xattr_handlers[];
|
| 1724 |
|
| 1725 | |
| 1726 | * yfsclient.c
|
| 1727 |
|
| 1728 | extern void yfs_fs_fetch_data(struct afs_operation *);
|
| 1729 | extern void yfs_fs_create_file(struct afs_operation *);
|
| 1730 | extern void yfs_fs_make_dir(struct afs_operation *);
|
| 1731 | extern void yfs_fs_remove_file2(struct afs_operation *);
|
| 1732 | extern void yfs_fs_remove_file(struct afs_operation *);
|
| 1733 | extern void yfs_fs_remove_dir(struct afs_operation *);
|
| 1734 | extern void yfs_fs_link(struct afs_operation *);
|
| 1735 | extern void yfs_fs_symlink(struct afs_operation *);
|
| 1736 | extern void yfs_fs_rename(struct afs_operation *);
|
| 1737 | void yfs_fs_rename_replace(struct afs_operation *op);
|
| 1738 | void yfs_fs_rename_noreplace(struct afs_operation *op);
|
| 1739 | void yfs_fs_rename_exchange(struct afs_operation *op);
|
| 1740 | extern void yfs_fs_store_data(struct afs_operation *);
|
| 1741 | extern void yfs_fs_setattr(struct afs_operation *);
|
| 1742 | extern void yfs_fs_get_volume_status(struct afs_operation *);
|
| 1743 | extern void yfs_fs_set_lock(struct afs_operation *);
|
| 1744 | extern void yfs_fs_extend_lock(struct afs_operation *);
|
| 1745 | extern void yfs_fs_release_lock(struct afs_operation *);
|
| 1746 | extern void yfs_fs_fetch_status(struct afs_operation *);
|
| 1747 | extern void yfs_fs_inline_bulk_status(struct afs_operation *);
|
| 1748 |
|
| 1749 | struct yfs_acl {
|
| 1750 | struct afs_acl *acl;
|
| 1751 | struct afs_acl *vol_acl;
|
| 1752 | u32 inherit_flag;
|
| 1753 | u32 num_cleaned;
|
| 1754 | unsigned int flags;
|
| 1755 | #define YFS_ACL_WANT_ACL 0x01
|
| 1756 | #define YFS_ACL_WANT_VOL_ACL 0x02
|
| 1757 | };
|
| 1758 |
|
| 1759 | extern void yfs_free_opaque_acl(struct yfs_acl *);
|
| 1760 | extern void yfs_fs_fetch_opaque_acl(struct afs_operation *);
|
| 1761 | extern void yfs_fs_store_opaque_acl2(struct afs_operation *);
|
| 1762 |
|
| 1763 | |
| 1764 | * Miscellaneous inline functions.
|
| 1765 |
|
| 1766 | static inline struct afs_vnode *AFS_FS_I(struct inode *inode)
|
| 1767 | {
|
| 1768 | return container_of(inode, struct afs_vnode, netfs.inode);
|
| 1769 | }
|
| 1770 |
|
| 1771 | static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode)
|
| 1772 | {
|
| 1773 | return &vnode->netfs.inode;
|
| 1774 | }
|
| 1775 |
|
| 1776 | |
| 1777 | * Note that a dentry got changed. We need to set d_fsdata to the data version
|
| 1778 | * number derived from the result of the operation. It doesn't matter if
|
| 1779 | * d_fsdata goes backwards as we'll just revalidate.
|
| 1780 |
|
| 1781 | static inline void afs_update_dentry_version(struct afs_operation *op,
|
| 1782 | struct afs_vnode_param *dir_vp,
|
| 1783 | struct dentry *dentry)
|
| 1784 | {
|
| 1785 | if (!op->cumul_error.error)
|
| 1786 | dentry->d_fsdata =
|
| 1787 | (void *)(unsigned long)dir_vp->scb.status.data_version;
|
| 1788 | }
|
| 1789 |
|
| 1790 | |
| 1791 | * Check for a conflicting operation on a directory that we just unlinked from.
|
| 1792 | * If someone managed to sneak a link or an unlink in on the file we just
|
| 1793 | * unlinked, we won't be able to trust nlink on an AFS file (but not YFS).
|
| 1794 |
|
| 1795 | static inline void afs_check_dir_conflict(struct afs_operation *op,
|
| 1796 | struct afs_vnode_param *dvp)
|
| 1797 | {
|
| 1798 | if (dvp->dv_before + dvp->dv_delta != dvp->scb.status.data_version)
|
| 1799 | op->flags |= AFS_OPERATION_DIR_CONFLICT;
|
| 1800 | }
|
| 1801 |
|
| 1802 | static inline int afs_io_error(struct afs_call *call, enum afs_io_error where)
|
| 1803 | {
|
| 1804 | trace_afs_io_error(call->debug_id, -EIO, where);
|
| 1805 | return -EIO;
|
| 1806 | }
|
| 1807 |
|
| 1808 | static inline int afs_bad(struct afs_vnode *vnode, enum afs_file_error where)
|
| 1809 | {
|
| 1810 | trace_afs_file_error(vnode, -EIO, where);
|
| 1811 | return -EIO;
|
| 1812 | }
|
| 1813 |
|
| 1814 | |
| 1815 | * Set the callback promise on a vnode.
|
| 1816 |
|
| 1817 | static inline void afs_set_cb_promise(struct afs_vnode *vnode, time64_t expires_at,
|
| 1818 | enum afs_cb_promise_trace trace)
|
| 1819 | {
|
| 1820 | atomic64_set(&vnode->cb_expires_at, expires_at);
|
| 1821 | trace_afs_cb_promise(vnode, trace);
|
| 1822 | }
|
| 1823 |
|
| 1824 | |
| 1825 | * Clear the callback promise on a vnode, returning true if it was promised.
|
| 1826 |
|
| 1827 | static inline bool afs_clear_cb_promise(struct afs_vnode *vnode,
|
| 1828 | enum afs_cb_promise_trace trace)
|
| 1829 | {
|
| 1830 | trace_afs_cb_promise(vnode, trace);
|
| 1831 | return atomic64_xchg(&vnode->cb_expires_at, AFS_NO_CB_PROMISE) != AFS_NO_CB_PROMISE;
|
| 1832 | }
|
| 1833 |
|
| 1834 | |
| 1835 | * Mark a directory as being invalid.
|
| 1836 |
|
| 1837 | static inline void afs_invalidate_dir(struct afs_vnode *dvnode,
|
| 1838 | enum afs_dir_invalid_trace trace)
|
| 1839 | {
|
| 1840 | if (test_and_clear_bit(AFS_VNODE_DIR_VALID, &dvnode->flags)) {
|
| 1841 | trace_afs_dir_invalid(dvnode, trace);
|
| 1842 | afs_stat_v(dvnode, n_inval);
|
| 1843 | }
|
| 1844 | }
|
| 1845 |
|
| 1846 |
|
| 1847 | |
| 1848 | * debug tracing
|
| 1849 |
|
| 1850 | extern unsigned afs_debug;
|
| 1851 |
|
| 1852 | #define dbgprintk(FMT,...) \
|
| 1853 | printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__)
|
| 1854 |
|
| 1855 | #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
|
| 1856 | #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
|
| 1857 | #define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__)
|
| 1858 |
|
| 1859 |
|
| 1860 | #if defined(__KDEBUG)
|
| 1861 | #define _enter(FMT,...) kenter(FMT,##__VA_ARGS__)
|
| 1862 | #define _leave(FMT,...) kleave(FMT,##__VA_ARGS__)
|
| 1863 | #define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__)
|
| 1864 |
|
| 1865 | #elif defined(CONFIG_AFS_DEBUG)
|
| 1866 | #define AFS_DEBUG_KENTER 0x01
|
| 1867 | #define AFS_DEBUG_KLEAVE 0x02
|
| 1868 | #define AFS_DEBUG_KDEBUG 0x04
|
| 1869 |
|
| 1870 | #define _enter(FMT,...) \
|
| 1871 | do { \
|
| 1872 | if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \
|
| 1873 | kenter(FMT,##__VA_ARGS__); \
|
| 1874 | } while (0)
|
| 1875 |
|
| 1876 | #define _leave(FMT,...) \
|
| 1877 | do { \
|
| 1878 | if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \
|
| 1879 | kleave(FMT,##__VA_ARGS__); \
|
| 1880 | } while (0)
|
| 1881 |
|
| 1882 | #define _debug(FMT,...) \
|
| 1883 | do { \
|
| 1884 | if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \
|
| 1885 | kdebug(FMT,##__VA_ARGS__); \
|
| 1886 | } while (0)
|
| 1887 |
|
| 1888 | #else
|
| 1889 | #define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
|
| 1890 | #define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
|
| 1891 | #define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__)
|
| 1892 | #endif
|
| 1893 |
|
| 1894 | |
| 1895 | * debug assertion checking
|
| 1896 |
|
| 1897 | #if 1 |
| 1898 |
|
| 1899 | #define ASSERT(X) \
|
| 1900 | do { \
|
| 1901 | if (unlikely(!(X))) { \
|
| 1902 | printk(KERN_ERR "\n"); \
|
| 1903 | printk(KERN_ERR "AFS: Assertion failed\n"); \
|
| 1904 | BUG(); \
|
| 1905 | } \
|
| 1906 | } while(0)
|
| 1907 |
|
| 1908 | #define ASSERTCMP(X, OP, Y) \
|
| 1909 | do { \
|
| 1910 | if (unlikely(!((X) OP (Y)))) { \
|
| 1911 | printk(KERN_ERR "\n"); \
|
| 1912 | printk(KERN_ERR "AFS: Assertion failed\n"); \
|
| 1913 | printk(KERN_ERR "%lu " #OP " %lu is false\n", \
|
| 1914 | (unsigned long)(X), (unsigned long)(Y)); \
|
| 1915 | printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \
|
| 1916 | (unsigned long)(X), (unsigned long)(Y)); \
|
| 1917 | BUG(); \
|
| 1918 | } \
|
| 1919 | } while(0)
|
| 1920 |
|
| 1921 | #define ASSERTRANGE(L, OP1, N, OP2, H) \
|
| 1922 | do { \
|
| 1923 | if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) { \
|
| 1924 | printk(KERN_ERR "\n"); \
|
| 1925 | printk(KERN_ERR "AFS: Assertion failed\n"); \
|
| 1926 | printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n", \
|
| 1927 | (unsigned long)(L), (unsigned long)(N), \
|
| 1928 | (unsigned long)(H)); \
|
| 1929 | printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \
|
| 1930 | (unsigned long)(L), (unsigned long)(N), \
|
| 1931 | (unsigned long)(H)); \
|
| 1932 | BUG(); \
|
| 1933 | } \
|
| 1934 | } while(0)
|
| 1935 |
|
| 1936 | #define ASSERTIF(C, X) \
|
| 1937 | do { \
|
| 1938 | if (unlikely((C) && !(X))) { \
|
| 1939 | printk(KERN_ERR "\n"); \
|
| 1940 | printk(KERN_ERR "AFS: Assertion failed\n"); \
|
| 1941 | BUG(); \
|
| 1942 | } \
|
| 1943 | } while(0)
|
| 1944 |
|
| 1945 | #define ASSERTIFCMP(C, X, OP, Y) \
|
| 1946 | do { \
|
| 1947 | if (unlikely((C) && !((X) OP (Y)))) { \
|
| 1948 | printk(KERN_ERR "\n"); \
|
| 1949 | printk(KERN_ERR "AFS: Assertion failed\n"); \
|
| 1950 | printk(KERN_ERR "%lu " #OP " %lu is false\n", \
|
| 1951 | (unsigned long)(X), (unsigned long)(Y)); \
|
| 1952 | printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \
|
| 1953 | (unsigned long)(X), (unsigned long)(Y)); \
|
| 1954 | BUG(); \
|
| 1955 | } \
|
| 1956 | } while(0)
|
| 1957 |
|
| 1958 | #else |
| 1959 |
|
| 1960 | #define ASSERT(X) \
|
| 1961 | do { \
|
| 1962 | } while(0)
|
| 1963 |
|
| 1964 | #define ASSERTCMP(X, OP, Y) \
|
| 1965 | do { \
|
| 1966 | } while(0)
|
| 1967 |
|
| 1968 | #define ASSERTRANGE(L, OP1, N, OP2, H) \
|
| 1969 | do { \
|
| 1970 | } while(0)
|
| 1971 |
|
| 1972 | #define ASSERTIF(C, X) \
|
| 1973 | do { \
|
| 1974 | } while(0)
|
| 1975 |
|
| 1976 | #define ASSERTIFCMP(C, X, OP, Y) \
|
| 1977 | do { \
|
| 1978 | } while(0)
|
| 1979 |
|
| 1980 | #endif
|