2874c5fd28426 (Thomas Gleixner 2019-05-27 08:55:01 +0200 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
ec26815ad847d (David Howells 2007-04-26 15:49:28 -0700 2) /* internal AFS stuff
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 3) *
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 4) * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 5) * Written by David Howells (dhowells@redhat.com)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 6) */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 7)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 8) #include <linux/compiler.h>
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 9) #include <linux/kernel.h>
8a79790bf0b7d (Tina Ruchandani 2017-03-16 16:27:46 +0000 10) #include <linux/ktime.h>
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 11) #include <linux/fs.h>
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 12) #include <linux/pagemap.h>
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 13) #include <linux/rxrpc.h>
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 14) #include <linux/key.h>
e8edc6e03a5c8 (Alexey Dobriyan 2007-05-21 01:22:52 +0400 15) #include <linux/workqueue.h>
00c541eae7a47 (Andrew Morton 2007-05-31 00:40:52 -0700 16) #include <linux/sched.h>
5cbf03985c67c (David Howells 2020-02-06 14:22:29 +0000 17) #define FSCACHE_USE_NEW_IO_API
80e50be4220e1 (Christoph Hellwig 2009-10-01 15:44:27 -0700 18) #include <linux/fscache.h>
e1da0222753a2 (Jens Axboe 2010-04-22 11:58:18 +0200 19) #include <linux/backing-dev.h>
ff548773106ec (David Howells 2017-02-10 16:34:07 +0000 20) #include <linux/uuid.h>
0722f18620597 (Souptick Joarder 2018-08-23 17:00:48 -0700 21) #include <linux/mm_types.h>
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 22) #include <linux/dns_resolver.h>
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 23) #include <net/net_namespace.h>
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 24) #include <net/netns/generic.h>
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 25) #include <net/sock.h>
8324f0bcfbfc6 (David Howells 2016-08-30 09:49:29 +0100 26) #include <net/af_rxrpc.h>
00c541eae7a47 (Andrew Morton 2007-05-31 00:40:52 -0700 27)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 28) #include "afs.h"
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 29) #include "afs_vl.h"
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 30)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 31) #define AFS_CELL_MAX_ADDRS 15
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 32)
31143d5d515ec (David Howells 2007-05-09 02:33:46 -0700 33) struct pagevec;
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 34) struct afs_call;
c450846461f88 (David Howells 2020-02-06 14:22:28 +0000 35) struct afs_vnode;
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 36)
6c6c1d63c2430 (David Howells 2019-04-25 14:26:52 +0100 37) /*
6c6c1d63c2430 (David Howells 2019-04-25 14:26:52 +0100 38) * Partial file-locking emulation mode. (The problem being that AFS3 only
6c6c1d63c2430 (David Howells 2019-04-25 14:26:52 +0100 39) * allows whole-file locks and no upgrading/downgrading).
6c6c1d63c2430 (David Howells 2019-04-25 14:26:52 +0100 40) */
6c6c1d63c2430 (David Howells 2019-04-25 14:26:52 +0100 41) enum afs_flock_mode {
6c6c1d63c2430 (David Howells 2019-04-25 14:26:52 +0100 42) afs_flock_mode_unset,
6c6c1d63c2430 (David Howells 2019-04-25 14:26:52 +0100 43) afs_flock_mode_local, /* Local locking only */
6c6c1d63c2430 (David Howells 2019-04-25 14:26:52 +0100 44) afs_flock_mode_openafs, /* Don't get server lock for a partial lock */
6c6c1d63c2430 (David Howells 2019-04-25 14:26:52 +0100 45) afs_flock_mode_strict, /* Always get a server lock for a partial lock */
6c6c1d63c2430 (David Howells 2019-04-25 14:26:52 +0100 46) afs_flock_mode_write, /* Get an exclusive server lock for a partial lock */
6c6c1d63c2430 (David Howells 2019-04-25 14:26:52 +0100 47) };
6c6c1d63c2430 (David Howells 2019-04-25 14:26:52 +0100 48)
13fcc6837049f (David Howells 2018-11-01 23:07:27 +0000 49) struct afs_fs_context {
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 50) bool force; /* T to force cell type */
bec5eb6141308 (wanglei 2010-08-11 09:38:04 +0100 51) bool autocell; /* T if set auto mount operation */
4d673da14533b (David Howells 2018-02-06 06:26:30 +0000 52) bool dyn_root; /* T if dynamic root */
13fcc6837049f (David Howells 2018-11-01 23:07:27 +0000 53) bool no_cell; /* T if the source is "none" (for dynroot) */
6c6c1d63c2430 (David Howells 2019-04-25 14:26:52 +0100 54) enum afs_flock_mode flock_mode; /* Partial file-locking emulation mode */
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 55) afs_voltype_t type; /* type of volume requested */
13fcc6837049f (David Howells 2018-11-01 23:07:27 +0000 56) unsigned int volnamesz; /* size of volume name */
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 57) const char *volname; /* name of volume to mount */
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 58) struct afs_net *net; /* the AFS net namespace stuff */
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 59) struct afs_cell *cell; /* cell in which to find volume */
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 60) struct afs_volume *volume; /* volume record */
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 61) struct key *key; /* key to use for secure mounting */
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 62) };
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 63)
8e8d7f13b6d5a (David Howells 2017-01-05 10:38:34 +0000 64) enum afs_call_state {
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 65) AFS_CALL_CL_REQUESTING, /* Client: Request is being sent */
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 66) AFS_CALL_CL_AWAIT_REPLY, /* Client: Awaiting reply */
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 67) AFS_CALL_CL_PROC_REPLY, /* Client: rxrpc call complete; processing reply */
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 68) AFS_CALL_SV_AWAIT_OP_ID, /* Server: Awaiting op ID */
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 69) AFS_CALL_SV_AWAIT_REQUEST, /* Server: Awaiting request data */
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 70) AFS_CALL_SV_REPLYING, /* Server: Replying */
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 71) AFS_CALL_SV_AWAIT_ACK, /* Server: Awaiting final ACK */
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 72) AFS_CALL_COMPLETE, /* Completed or failed */
8e8d7f13b6d5a (David Howells 2017-01-05 10:38:34 +0000 73) };
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 74)
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 75) /*
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 76) * List of server addresses.
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 77) */
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 78) struct afs_addr_list {
ddd2b85ff73bb (Jann Horn 2020-03-12 21:36:53 +0000 79) struct rcu_head rcu;
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 80) refcount_t usage;
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 81) u32 version; /* Version */
68eb64c3d2fd5 (David Howells 2018-10-04 09:32:27 +0100 82) unsigned char max_addrs;
68eb64c3d2fd5 (David Howells 2018-10-04 09:32:27 +0100 83) unsigned char nr_addrs;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 84) unsigned char preferred; /* Preferred address */
68eb64c3d2fd5 (David Howells 2018-10-04 09:32:27 +0100 85) unsigned char nr_ipv4; /* Number of IPv4 addresses */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 86) enum dns_record_source source:8;
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 87) enum dns_lookup_status status:8;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 88) unsigned long failed; /* Mask of addrs that failed locally/ICMP */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 89) unsigned long responded; /* Mask of addrs that responded */
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 90) struct sockaddr_rxrpc addrs[];
68eb64c3d2fd5 (David Howells 2018-10-04 09:32:27 +0100 91) #define AFS_MAX_ADDRESSES ((unsigned int)(sizeof(unsigned long) * 8))
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 92) };
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 93)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 94) /*
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 95) * a record of an in-progress RxRPC call
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 96) */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 97) struct afs_call {
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 98) const struct afs_call_type *type; /* type of call */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 99) struct afs_addr_list *alist; /* Address is alist[addr_ix] */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 100) wait_queue_head_t waitq; /* processes awaiting completion */
341f741f04bec (David Howells 2017-01-05 10:38:36 +0000 101) struct work_struct async_work; /* async I/O processor */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 102) struct work_struct work; /* actual work processor */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 103) struct rxrpc_call *rxcall; /* RxRPC call handle */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 104) struct key *key; /* security for this call */
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 105) struct afs_net *net; /* The network namespace */
a6853b9ce81a8 (David Howells 2019-06-20 16:49:35 +0100 106) struct afs_server *server; /* The fileserver record if fs op (pins ref) */
a6853b9ce81a8 (David Howells 2019-06-20 16:49:35 +0100 107) struct afs_vlserver *vlserver; /* The vlserver record if vl op */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 108) void *request; /* request data (first part) */
f105da1a798f2 (David Howells 2020-02-06 14:22:28 +0000 109) size_t iov_len; /* Size of *iter to be used */
fc276122496df (David Howells 2019-11-21 09:12:17 +0000 110) struct iov_iter def_iter; /* Default buffer/data iterator */
bd80d8a80e128 (David Howells 2020-02-06 14:22:28 +0000 111) struct iov_iter *write_iter; /* Iterator defining write to be made */
fc276122496df (David Howells 2019-11-21 09:12:17 +0000 112) struct iov_iter *iter; /* Iterator currently in use */
fc276122496df (David Howells 2019-11-21 09:12:17 +0000 113) union { /* Convenience for ->def_iter */
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 114) struct kvec kvec[1];
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 115) struct bio_vec bvec[1];
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 116) };
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 117) void *buffer; /* reply receive buffer */
ffba718e93540 (David Howells 2019-05-09 22:22:50 +0100 118) union {
ffba718e93540 (David Howells 2019-05-09 22:22:50 +0100 119) long ret0; /* Value to reply with instead of 0 */
ffba718e93540 (David Howells 2019-05-09 22:22:50 +0100 120) struct afs_addr_list *ret_alist;
ffba718e93540 (David Howells 2019-05-09 22:22:50 +0100 121) struct afs_vldb_entry *ret_vldb;
c3e9f888263bb (David Howells 2020-04-29 17:26:41 +0100 122) char *ret_str;
ffba718e93540 (David Howells 2019-05-09 22:22:50 +0100 123) };
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 124) struct afs_operation *op;
ffba718e93540 (David Howells 2019-05-09 22:22:50 +0100 125) unsigned int server_index;
341f741f04bec (David Howells 2017-01-05 10:38:36 +0000 126) atomic_t usage;
8e8d7f13b6d5a (David Howells 2017-01-05 10:38:34 +0000 127) enum afs_call_state state;
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 128) spinlock_t state_lock;
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 129) int error; /* error code */
d001648ec7cf8 (David Howells 2016-08-30 20:42:14 +0100 130) u32 abort_code; /* Remote abort ID or 0 */
94f699c9cdb11 (David Howells 2019-05-16 13:21:59 +0100 131) unsigned int max_lifespan; /* Maximum lifespan to set if not 0 */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 132) unsigned request_size; /* size of request data */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 133) unsigned reply_max; /* maximum size of reply */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 134) unsigned count2; /* count used in unmarshalling */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 135) unsigned char unmarshall; /* unmarshalling phase */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 136) unsigned char addr_ix; /* Address in ->alist */
dde9f095583b3 (David Howells 2020-03-13 13:46:08 +0000 137) bool drop_ref; /* T if need to drop ref for incoming call */
d001648ec7cf8 (David Howells 2016-08-30 20:42:14 +0100 138) bool need_attention; /* T if RxRPC poked us */
56ff9c837778b (David Howells 2017-01-05 10:38:36 +0000 139) bool async; /* T if asynchronous */
a68f4a27f55f1 (David Howells 2017-10-18 11:36:39 +0100 140) bool upgrade; /* T to request service upgrade */
4571577f16c82 (David Howells 2019-05-14 11:44:26 +0100 141) bool have_reply_time; /* T if have got reply_time */
20b8391fff56f (David Howells 2019-05-08 16:16:31 +0100 142) bool intr; /* T if interruptible */
38355eec6a7d2 (David Howells 2020-04-08 16:13:20 +0100 143) bool unmarshalling_error; /* T if an unmarshalling error occurred */
bf99a53ce22a2 (David Howells 2017-11-02 15:27:51 +0000 144) u16 service_id; /* Actual service ID (after upgrade) */
a25e21f0bcd25 (David Howells 2018-03-27 23:03:00 +0100 145) unsigned int debug_id; /* Trace ID */
50a2c95381a7d (David Howells 2016-10-13 08:27:10 +0100 146) u32 operation_ID; /* operation ID for an incoming call */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 147) u32 count; /* count for use in unmarshalling */
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 148) union { /* place to extract temporary data */
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 149) struct {
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 150) __be32 tmp_u;
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 151) __be32 tmp;
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 152) } __attribute__((packed));
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 153) __be64 tmp64;
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 154) };
12d8e95a911eb (David Howells 2018-10-20 00:57:58 +0100 155) ktime_t reply_time; /* Time of first reply packet */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 156) };
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 157)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 158) struct afs_call_type {
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 159) const char *name;
025db80c9e421 (David Howells 2017-11-02 15:27:51 +0000 160) unsigned int op; /* Really enum afs_fs_operation */
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 161)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 162) /* deliver request or reply data to an call
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 163) * - returning an error will cause the call to be aborted
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 164) */
d001648ec7cf8 (David Howells 2016-08-30 20:42:14 +0100 165) int (*deliver)(struct afs_call *call);
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 166)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 167) /* clean up a call */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 168) void (*destructor)(struct afs_call *call);
341f741f04bec (David Howells 2017-01-05 10:38:36 +0000 169)
341f741f04bec (David Howells 2017-01-05 10:38:36 +0000 170) /* Work function */
341f741f04bec (David Howells 2017-01-05 10:38:36 +0000 171) void (*work)(struct work_struct *work);
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 172)
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 173) /* Call done function (gets called immediately on success or failure) */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 174) void (*done)(struct afs_call *call);
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 175) };
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 176)
4343d00872e1d (David Howells 2017-11-02 15:27:52 +0000 177) /*
4343d00872e1d (David Howells 2017-11-02 15:27:52 +0000 178) * Key available for writeback on a file.
4343d00872e1d (David Howells 2017-11-02 15:27:52 +0000 179) */
4343d00872e1d (David Howells 2017-11-02 15:27:52 +0000 180) struct afs_wb_key {
4343d00872e1d (David Howells 2017-11-02 15:27:52 +0000 181) refcount_t usage;
4343d00872e1d (David Howells 2017-11-02 15:27:52 +0000 182) struct key *key;
4343d00872e1d (David Howells 2017-11-02 15:27:52 +0000 183) struct list_head vnode_link; /* Link in vnode->wb_keys */
4343d00872e1d (David Howells 2017-11-02 15:27:52 +0000 184) };
4343d00872e1d (David Howells 2017-11-02 15:27:52 +0000 185)
215804a99283c (David Howells 2017-11-02 15:27:52 +0000 186) /*
215804a99283c (David Howells 2017-11-02 15:27:52 +0000 187) * AFS open file information record. Pointed to by file->private_data.
215804a99283c (David Howells 2017-11-02 15:27:52 +0000 188) */
215804a99283c (David Howells 2017-11-02 15:27:52 +0000 189) struct afs_file {
215804a99283c (David Howells 2017-11-02 15:27:52 +0000 190) struct key *key; /* The key this file was opened with */
4343d00872e1d (David Howells 2017-11-02 15:27:52 +0000 191) struct afs_wb_key *wb; /* Writeback key record for this file */
215804a99283c (David Howells 2017-11-02 15:27:52 +0000 192) };
215804a99283c (David Howells 2017-11-02 15:27:52 +0000 193)
215804a99283c (David Howells 2017-11-02 15:27:52 +0000 194) static inline struct key *afs_file_key(struct file *file)
215804a99283c (David Howells 2017-11-02 15:27:52 +0000 195) {
215804a99283c (David Howells 2017-11-02 15:27:52 +0000 196) struct afs_file *af = file->private_data;
215804a99283c (David Howells 2017-11-02 15:27:52 +0000 197)
215804a99283c (David Howells 2017-11-02 15:27:52 +0000 198) return af->key;
215804a99283c (David Howells 2017-11-02 15:27:52 +0000 199) }
215804a99283c (David Howells 2017-11-02 15:27:52 +0000 200)
196ee9cd2d047 (David Howells 2017-01-05 10:38:34 +0000 201) /*
196ee9cd2d047 (David Howells 2017-01-05 10:38:34 +0000 202) * Record of an outstanding read operation on a vnode.
196ee9cd2d047 (David Howells 2017-01-05 10:38:34 +0000 203) */
196ee9cd2d047 (David Howells 2017-01-05 10:38:34 +0000 204) struct afs_read {
196ee9cd2d047 (David Howells 2017-01-05 10:38:34 +0000 205) loff_t pos; /* Where to start reading */
e8e581a88c5f5 (David Howells 2017-03-16 16:27:44 +0000 206) loff_t len; /* How much we're asking for */
196ee9cd2d047 (David Howells 2017-01-05 10:38:34 +0000 207) loff_t actual_len; /* How much we're actually getting */
f3ddee8dc4e2c (David Howells 2018-04-06 14:17:25 +0100 208) loff_t file_size; /* File size returned by server */
c69bf479baa61 (David Howells 2020-02-06 14:22:27 +0000 209) struct key *key; /* The key to use to reissue the read */
c450846461f88 (David Howells 2020-02-06 14:22:28 +0000 210) struct afs_vnode *vnode; /* The file being read into. */
5cbf03985c67c (David Howells 2020-02-06 14:22:29 +0000 211) struct netfs_read_subrequest *subreq; /* Fscache helper read request this belongs to */
f3ddee8dc4e2c (David Howells 2018-04-06 14:17:25 +0100 212) afs_dataversion_t data_version; /* Version number returned by server */
f3ddee8dc4e2c (David Howells 2018-04-06 14:17:25 +0100 213) refcount_t usage;
c450846461f88 (David Howells 2020-02-06 14:22:28 +0000 214) unsigned int call_debug_id;
196ee9cd2d047 (David Howells 2017-01-05 10:38:34 +0000 215) unsigned int nr_pages;
c450846461f88 (David Howells 2020-02-06 14:22:28 +0000 216) int error;
c450846461f88 (David Howells 2020-02-06 14:22:28 +0000 217) void (*done)(struct afs_read *);
c450846461f88 (David Howells 2020-02-06 14:22:28 +0000 218) void (*cleanup)(struct afs_read *);
c450846461f88 (David Howells 2020-02-06 14:22:28 +0000 219) struct iov_iter *iter; /* Iterator representing the buffer */
c450846461f88 (David Howells 2020-02-06 14:22:28 +0000 220) struct iov_iter def_iter; /* Default iterator */
196ee9cd2d047 (David Howells 2017-01-05 10:38:34 +0000 221) };
196ee9cd2d047 (David Howells 2017-01-05 10:38:34 +0000 222)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 223) /*
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 224) * AFS superblock private data
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 225) * - there's one superblock per volume
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 226) */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 227) struct afs_super_info {
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 228) struct net *net_ns; /* Network namespace */
49566f6f06b38 (David Howells 2017-11-02 15:27:46 +0000 229) struct afs_cell *cell; /* The cell in which the volume resides */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 230) struct afs_volume *volume; /* volume record */
6c6c1d63c2430 (David Howells 2019-04-25 14:26:52 +0100 231) enum afs_flock_mode flock_mode:8; /* File locking emulation mode */
4d673da14533b (David Howells 2018-02-06 06:26:30 +0000 232) bool dyn_root; /* True if dynamic root */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 233) };
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 234)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 235) static inline struct afs_super_info *AFS_FS_S(struct super_block *sb)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 236) {
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 237) return sb->s_fs_info;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 238) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 239)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 240) extern struct file_system_type afs_fs_type;
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 241)
6f8880d8e6815 (David Howells 2018-04-09 21:12:31 +0100 242) /*
6f8880d8e6815 (David Howells 2018-04-09 21:12:31 +0100 243) * Set of substitutes for @sys.
6f8880d8e6815 (David Howells 2018-04-09 21:12:31 +0100 244) */
6f8880d8e6815 (David Howells 2018-04-09 21:12:31 +0100 245) struct afs_sysnames {
6f8880d8e6815 (David Howells 2018-04-09 21:12:31 +0100 246) #define AFS_NR_SYSNAME 16
6f8880d8e6815 (David Howells 2018-04-09 21:12:31 +0100 247) char *subs[AFS_NR_SYSNAME];
6f8880d8e6815 (David Howells 2018-04-09 21:12:31 +0100 248) refcount_t usage;
6f8880d8e6815 (David Howells 2018-04-09 21:12:31 +0100 249) unsigned short nr;
6f8880d8e6815 (David Howells 2018-04-09 21:12:31 +0100 250) char blank[1];
6f8880d8e6815 (David Howells 2018-04-09 21:12:31 +0100 251) };
6f8880d8e6815 (David Howells 2018-04-09 21:12:31 +0100 252)
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 253) /*
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 254) * AFS network namespace record.
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 255) */
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 256) struct afs_net {
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 257) struct net *net; /* Backpointer to the owning net namespace */
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 258) struct afs_uuid uuid;
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 259) bool live; /* F if this namespace is being removed */
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 260)
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 261) /* AF_RXRPC I/O stuff */
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 262) struct socket *socket;
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 263) struct afs_call *spare_incoming_call;
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 264) struct work_struct charge_preallocation_work;
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 265) struct mutex socket_mutex;
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 266) atomic_t nr_outstanding_calls;
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 267) atomic_t nr_superblocks;
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 268)
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 269) /* Cell database */
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 270) struct rb_root cells;
92e3cc91d8f51 (David Howells 2020-10-09 14:11:58 +0100 271) struct afs_cell *ws_cell;
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 272) struct work_struct cells_manager;
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 273) struct timer_list cells_timer;
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 274) atomic_t cells_outstanding;
92e3cc91d8f51 (David Howells 2020-10-09 14:11:58 +0100 275) struct rw_semaphore cells_lock;
8a070a964877c (David Howells 2020-04-25 10:26:02 +0100 276) struct mutex cells_alias_lock;
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 277)
0da0b7fd73e4f (David Howells 2018-06-15 15:19:22 +0100 278) struct mutex proc_cells_lock;
6b3944e42e2e5 (David Howells 2018-10-11 22:45:49 +0100 279) struct hlist_head proc_cells;
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 280)
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 281) /* Known servers. Theoretically each fileserver can only be in one
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 282) * cell, but in practice, people create aliases and subsets and there's
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 283) * no easy way to distinguish them.
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 284) */
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 285) seqlock_t fs_lock; /* For fs_servers, fs_probe_*, fs_proc */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 286) struct rb_root fs_servers; /* afs_server (by server UUID or address) */
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 287) struct list_head fs_probe_fast; /* List of afs_server to probe at 30s intervals */
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 288) struct list_head fs_probe_slow; /* List of afs_server to probe at 5m intervals */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 289) struct hlist_head fs_proc; /* procfs servers list */
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 290)
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 291) struct hlist_head fs_addresses4; /* afs_server (by lowest IPv4 addr) */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 292) struct hlist_head fs_addresses6; /* afs_server (by lowest IPv6 addr) */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 293) seqlock_t fs_addr_lock; /* For fs_addresses[46] */
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 294)
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 295) struct work_struct fs_manager;
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 296) struct timer_list fs_timer;
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 297)
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 298) struct work_struct fs_prober;
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 299) struct timer_list fs_probe_timer;
59fa1c4a9f528 (David Howells 2017-11-02 15:27:45 +0000 300) atomic_t servers_outstanding;
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 301)
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 302) /* File locking renewal management */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 303) struct mutex lock_manager_mutex;
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 304)
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 305) /* Misc */
0da0b7fd73e4f (David Howells 2018-06-15 15:19:22 +0100 306) struct super_block *dynroot_sb; /* Dynamic root mount superblock */
d55b4da4331ef (David Howells 2018-04-06 14:17:24 +0100 307) struct proc_dir_entry *proc_afs; /* /proc/net/afs directory */
6f8880d8e6815 (David Howells 2018-04-09 21:12:31 +0100 308) struct afs_sysnames *sysnames;
6f8880d8e6815 (David Howells 2018-04-09 21:12:31 +0100 309) rwlock_t sysnames_lock;
d55b4da4331ef (David Howells 2018-04-06 14:17:24 +0100 310)
d55b4da4331ef (David Howells 2018-04-06 14:17:24 +0100 311) /* Statistics counters */
d55b4da4331ef (David Howells 2018-04-06 14:17:24 +0100 312) atomic_t n_lookup; /* Number of lookups done */
d55b4da4331ef (David Howells 2018-04-06 14:17:24 +0100 313) atomic_t n_reval; /* Number of dentries needing revalidation */
d55b4da4331ef (David Howells 2018-04-06 14:17:24 +0100 314) atomic_t n_inval; /* Number of invalidations by the server */
f3ddee8dc4e2c (David Howells 2018-04-06 14:17:25 +0100 315) atomic_t n_relpg; /* Number of invalidations by releasepage */
d55b4da4331ef (David Howells 2018-04-06 14:17:24 +0100 316) atomic_t n_read_dir; /* Number of directory pages read */
63a4681ff39cb (David Howells 2018-04-06 14:17:25 +0100 317) atomic_t n_dir_cr; /* Number of directory entry creation edits */
63a4681ff39cb (David Howells 2018-04-06 14:17:25 +0100 318) atomic_t n_dir_rm; /* Number of directory entry removal edits */
76a5cb6fc1e22 (David Howells 2018-04-06 14:17:26 +0100 319) atomic_t n_stores; /* Number of store ops */
76a5cb6fc1e22 (David Howells 2018-04-06 14:17:26 +0100 320) atomic_long_t n_store_bytes; /* Number of bytes stored */
76a5cb6fc1e22 (David Howells 2018-04-06 14:17:26 +0100 321) atomic_long_t n_fetch_bytes; /* Number of bytes fetched */
76a5cb6fc1e22 (David Howells 2018-04-06 14:17:26 +0100 322) atomic_t n_fetches; /* Number of data fetch ops */
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 323) };
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 324)
6f8880d8e6815 (David Howells 2018-04-09 21:12:31 +0100 325) extern const char afs_init_sysname[];
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 326)
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 327) enum afs_cell_state {
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 328) AFS_CELL_UNSET,
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 329) AFS_CELL_ACTIVATING,
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 330) AFS_CELL_ACTIVE,
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 331) AFS_CELL_DEACTIVATING,
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 332) AFS_CELL_INACTIVE,
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 333) AFS_CELL_FAILED,
1d0e850a49a5b (David Howells 2020-10-16 13:21:14 +0100 334) AFS_CELL_REMOVED,
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 335) };
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 336)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 337) /*
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 338) * AFS cell record.
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 339) *
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 340) * This is a tricky concept to get right as it is possible to create aliases
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 341) * simply by pointing AFSDB/SRV records for two names at the same set of VL
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 342) * servers; it is also possible to do things like setting up two sets of VL
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 343) * servers, one of which provides a superset of the volumes provided by the
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 344) * other (for internal/external division, for example).
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 345) *
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 346) * Cells only exist in the sense that (a) a cell's name maps to a set of VL
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 347) * servers and (b) a cell's name is used by the client to select the key to use
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 348) * for authentication and encryption. The cell name is not typically used in
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 349) * the protocol.
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 350) *
8a070a964877c (David Howells 2020-04-25 10:26:02 +0100 351) * Two cells are determined to be aliases if they have an explicit alias (YFS
8a070a964877c (David Howells 2020-04-25 10:26:02 +0100 352) * only), share any VL servers in common or have at least one volume in common.
8a070a964877c (David Howells 2020-04-25 10:26:02 +0100 353) * "In common" means that the address list of the VL servers or the fileservers
8a070a964877c (David Howells 2020-04-25 10:26:02 +0100 354) * share at least one endpoint.
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 355) */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 356) struct afs_cell {
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 357) union {
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 358) struct rcu_head rcu;
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 359) struct rb_node net_node; /* Node in net->cells */
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 360) };
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 361) struct afs_net *net;
8a070a964877c (David Howells 2020-04-25 10:26:02 +0100 362) struct afs_cell *alias_of; /* The cell this is an alias of */
8a070a964877c (David Howells 2020-04-25 10:26:02 +0100 363) struct afs_volume *root_volume; /* The root.cell volume if there is one */
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 364) struct key *anonymous_key; /* anonymous user key for this cell */
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 365) struct work_struct manager; /* Manager for init/deinit/dns */
6b3944e42e2e5 (David Howells 2018-10-11 22:45:49 +0100 366) struct hlist_node proc_link; /* /proc cell list link */
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 367) #ifdef CONFIG_AFS_FSCACHE
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 368) struct fscache_cookie *cache; /* caching cookie */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 369) #endif
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 370) time64_t dns_expiry; /* Time AFSDB/SRV record expires */
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 371) time64_t last_inactive; /* Time of last drop of usage count */
88c853c3f5c0a (David Howells 2019-07-23 11:24:59 +0100 372) atomic_t ref; /* Struct refcount */
88c853c3f5c0a (David Howells 2019-07-23 11:24:59 +0100 373) atomic_t active; /* Active usage counter */
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 374) unsigned long flags;
d5c32c89b208e (David Howells 2019-05-07 15:06:36 +0100 375) #define AFS_CELL_FL_NO_GC 0 /* The cell was added manually, don't auto-gc */
d5c32c89b208e (David Howells 2019-05-07 15:06:36 +0100 376) #define AFS_CELL_FL_DO_LOOKUP 1 /* DNS lookup requested */
8a070a964877c (David Howells 2020-04-25 10:26:02 +0100 377) #define AFS_CELL_FL_CHECK_ALIAS 2 /* Need to check for aliases */
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 378) enum afs_cell_state state;
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 379) short error;
d5c32c89b208e (David Howells 2019-05-07 15:06:36 +0100 380) enum dns_record_source dns_source:8; /* Latest source of data from lookup */
d5c32c89b208e (David Howells 2019-05-07 15:06:36 +0100 381) enum dns_lookup_status dns_status:8; /* Latest status of data from lookup */
d5c32c89b208e (David Howells 2019-05-07 15:06:36 +0100 382) unsigned int dns_lookup_count; /* Counter of DNS lookups */
dca54a7bbb8ca (David Howells 2020-10-13 20:51:59 +0100 383) unsigned int debug_id;
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 384)
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 385) /* The volumes belonging to this cell */
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 386) struct rb_root volumes; /* Tree of volumes on this server */
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 387) struct hlist_head proc_volumes; /* procfs volume list */
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 388) seqlock_t volume_lock; /* For volumes */
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 389)
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 390) /* Active fileserver interaction state. */
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 391) struct rb_root fs_servers; /* afs_server (by server UUID) */
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 392) seqlock_t fs_lock; /* For fs_servers */
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 393)
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 394) /* VL server list. */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 395) rwlock_t vl_servers_lock; /* Lock on vl_servers */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 396) struct afs_vlserver_list __rcu *vl_servers;
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 397)
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 398) u8 name_len; /* Length of name */
719fdd32921fb (David Howells 2020-06-24 17:00:24 +0100 399) char *name; /* Cell name, case-flattened and NUL-padded */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 400) };
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 401)
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 402) /*
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 403) * Volume Location server record.
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 404) */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 405) struct afs_vlserver {
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 406) struct rcu_head rcu;
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 407) struct afs_addr_list __rcu *addresses; /* List of addresses for this VL server */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 408) unsigned long flags;
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 409) #define AFS_VLSERVER_FL_PROBED 0 /* The VL server has been probed */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 410) #define AFS_VLSERVER_FL_PROBING 1 /* VL server is being probed */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 411) #define AFS_VLSERVER_FL_IS_YFS 2 /* Server is YFS not AFS */
b95b30940ee46 (David Howells 2020-08-19 15:27:17 +0100 412) #define AFS_VLSERVER_FL_RESPONDING 3 /* VL server is responding */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 413) rwlock_t lock; /* Lock on addresses */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 414) atomic_t usage;
b95b30940ee46 (David Howells 2020-08-19 15:27:17 +0100 415) unsigned int rtt; /* Server's current RTT in uS */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 416)
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 417) /* Probe state */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 418) wait_queue_head_t probe_wq;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 419) atomic_t probe_outstanding;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 420) spinlock_t probe_lock;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 421) struct {
b95b30940ee46 (David Howells 2020-08-19 15:27:17 +0100 422) unsigned int rtt; /* RTT in uS */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 423) u32 abort_code;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 424) short error;
fb72cd3d484ce (David Howells 2020-08-20 15:01:54 +0100 425) unsigned short flags;
fb72cd3d484ce (David Howells 2020-08-20 15:01:54 +0100 426) #define AFS_VLSERVER_PROBE_RESPONDED 0x01 /* At least once response (may be abort) */
fb72cd3d484ce (David Howells 2020-08-20 15:01:54 +0100 427) #define AFS_VLSERVER_PROBE_IS_YFS 0x02 /* The peer appears to be YFS */
fb72cd3d484ce (David Howells 2020-08-20 15:01:54 +0100 428) #define AFS_VLSERVER_PROBE_NOT_YFS 0x04 /* The peer appears not to be YFS */
fb72cd3d484ce (David Howells 2020-08-20 15:01:54 +0100 429) #define AFS_VLSERVER_PROBE_LOCAL_FAILURE 0x08 /* A local failure prevented a probe */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 430) } probe;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 431)
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 432) u16 port;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 433) u16 name_len; /* Length of name */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 434) char name[]; /* Server name, case-flattened */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 435) };
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 436)
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 437) /*
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 438) * Weighted list of Volume Location servers.
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 439) */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 440) struct afs_vlserver_entry {
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 441) u16 priority; /* Preference (as SRV) */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 442) u16 weight; /* Weight (as SRV) */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 443) enum dns_record_source source:8;
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 444) enum dns_lookup_status status:8;
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 445) struct afs_vlserver *server;
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 446) };
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 447)
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 448) struct afs_vlserver_list {
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 449) struct rcu_head rcu;
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 450) atomic_t usage;
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 451) u8 nr_servers;
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 452) u8 index; /* Server currently in use */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 453) u8 preferred; /* Preferred server */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 454) enum dns_record_source source:8;
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 455) enum dns_lookup_status status:8;
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 456) rwlock_t lock;
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 457) struct afs_vlserver_entry servers[];
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 458) };
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 459)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 460) /*
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 461) * Cached VLDB entry.
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 462) *
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 463) * This is pointed to by cell->vldb_entries, indexed by name.
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 464) */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 465) struct afs_vldb_entry {
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 466) afs_volid_t vid[3]; /* Volume IDs for R/W, R/O and Bak volumes */
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 467)
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 468) unsigned long flags;
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 469) #define AFS_VLDB_HAS_RW 0 /* - R/W volume exists */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 470) #define AFS_VLDB_HAS_RO 1 /* - R/O volume exists */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 471) #define AFS_VLDB_HAS_BAK 2 /* - Backup volume exists */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 472) #define AFS_VLDB_QUERY_VALID 3 /* - Record is valid */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 473) #define AFS_VLDB_QUERY_ERROR 4 /* - VL server returned error */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 474)
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 475) uuid_t fs_server[AFS_NMAXNSERVERS];
8100680592345 (David Howells 2020-04-16 17:05:28 +0100 476) u32 addr_version[AFS_NMAXNSERVERS]; /* Registration change counters */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 477) u8 fs_mask[AFS_NMAXNSERVERS];
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 478) #define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 479) #define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 480) #define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 481) short error;
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 482) u8 nr_servers; /* Number of server records */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 483) u8 name_len;
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 484) u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 485) };
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 486)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 487) /*
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 488) * Record of fileserver with which we're actively communicating.
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 489) */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 490) struct afs_server {
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 491) struct rcu_head rcu;
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 492) union {
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 493) uuid_t uuid; /* Server ID */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 494) struct afs_uuid _uuid;
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 495) };
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 496)
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 497) struct afs_addr_list __rcu *addresses;
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 498) struct afs_cell *cell; /* Cell to which belongs (pins ref) */
3c4c4075fc61f (David Howells 2020-05-27 15:51:30 +0100 499) struct rb_node uuid_rb; /* Link in net->fs_servers */
3c4c4075fc61f (David Howells 2020-05-27 15:51:30 +0100 500) struct afs_server __rcu *uuid_next; /* Next server with same UUID */
3c4c4075fc61f (David Howells 2020-05-27 15:51:30 +0100 501) struct afs_server *uuid_prev; /* Previous server with same UUID */
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 502) struct list_head probe_link; /* Link in net->fs_probe_list */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 503) struct hlist_node addr4_link; /* Link in net->fs_addresses4 */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 504) struct hlist_node addr6_link; /* Link in net->fs_addresses6 */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 505) struct hlist_node proc_link; /* Link in net->fs_proc */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 506) struct afs_server *gc_next; /* Next server in manager's list */
977e5f8ed0ab2 (David Howells 2020-04-17 17:31:26 +0100 507) time64_t unuse_time; /* Time at which last unused */
c435ee34551e1 (David Howells 2017-11-02 15:27:49 +0000 508) unsigned long flags;
f3c130e6e6d15 (David Howells 2020-05-02 13:39:57 +0100 509) #define AFS_SERVER_FL_RESPONDING 0 /* The server is responding */
32275d3f758f1 (David Howells 2020-05-02 13:44:50 +0100 510) #define AFS_SERVER_FL_UPDATING 1
32275d3f758f1 (David Howells 2020-05-02 13:44:50 +0100 511) #define AFS_SERVER_FL_NEEDS_UPDATE 2 /* Fileserver address list is out of date */
32275d3f758f1 (David Howells 2020-05-02 13:44:50 +0100 512) #define AFS_SERVER_FL_NOT_READY 4 /* The record is not ready for use */
32275d3f758f1 (David Howells 2020-05-02 13:44:50 +0100 513) #define AFS_SERVER_FL_NOT_FOUND 5 /* VL server says no such server */
32275d3f758f1 (David Howells 2020-05-02 13:44:50 +0100 514) #define AFS_SERVER_FL_VL_FAIL 6 /* Failed to access VL server */
f2686b09269ec (David Howells 2018-05-10 14:12:50 +0100 515) #define AFS_SERVER_FL_MAY_HAVE_CB 8 /* May have callbacks on this fileserver */
32275d3f758f1 (David Howells 2020-05-02 13:44:50 +0100 516) #define AFS_SERVER_FL_IS_YFS 16 /* Server is YFS not AFS */
32275d3f758f1 (David Howells 2020-05-02 13:44:50 +0100 517) #define AFS_SERVER_FL_NO_IBULK 17 /* Fileserver doesn't support FS.InlineBulkStatus */
32275d3f758f1 (David Howells 2020-05-02 13:44:50 +0100 518) #define AFS_SERVER_FL_NO_RM2 18 /* Fileserver doesn't support YFS.RemoveFile2 */
977e5f8ed0ab2 (David Howells 2020-04-17 17:31:26 +0100 519) atomic_t ref; /* Object refcount */
977e5f8ed0ab2 (David Howells 2020-04-17 17:31:26 +0100 520) atomic_t active; /* Active user count */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 521) u32 addr_version; /* Address list version */
f3c130e6e6d15 (David Howells 2020-05-02 13:39:57 +0100 522) unsigned int rtt; /* Server's current RTT in uS */
452181936931f (David Howells 2019-06-20 18:12:17 +0100 523) unsigned int debug_id; /* Debugging ID for traces */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 524)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 525) /* file service access */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 526) rwlock_t fs_lock; /* access lock */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 527)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 528) /* callback promise management */
c435ee34551e1 (David Howells 2017-11-02 15:27:49 +0000 529) unsigned cb_s_break; /* Break-everything counter. */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 530)
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 531) /* Probe state */
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 532) unsigned long probed_at; /* Time last probe was dispatched (jiffies) */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 533) wait_queue_head_t probe_wq;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 534) atomic_t probe_outstanding;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 535) spinlock_t probe_lock;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 536) struct {
f3c130e6e6d15 (David Howells 2020-05-02 13:39:57 +0100 537) unsigned int rtt; /* RTT in uS */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 538) u32 abort_code;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 539) short error;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 540) bool responded:1;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 541) bool is_yfs:1;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 542) bool not_yfs:1;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 543) bool local_failure:1;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 544) } probe;
c435ee34551e1 (David Howells 2017-11-02 15:27:49 +0000 545) };
c435ee34551e1 (David Howells 2017-11-02 15:27:49 +0000 546)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 547) /*
194d28cf197ca (David Howells 2020-04-27 13:42:53 +0100 548) * Replaceable volume server list.
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 549) */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 550) struct afs_server_entry {
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 551) struct afs_server *server;
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 552) };
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 553)
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 554) struct afs_server_list {
194d28cf197ca (David Howells 2020-04-27 13:42:53 +0100 555) afs_volid_t vids[AFS_MAXTYPES]; /* Volume IDs */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 556) refcount_t usage;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 557) unsigned char nr_servers;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 558) unsigned char preferred; /* Preferred server */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 559) unsigned short vnovol_mask; /* Servers to be skipped due to VNOVOL */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 560) unsigned int seq; /* Set to ->servers_seq when installed */
d4a96bec7a736 (David Howells 2018-05-10 08:43:04 +0100 561) rwlock_t lock;
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 562) struct afs_server_entry servers[];
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 563) };
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 564)
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 565) /*
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 566) * Live AFS volume management.
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 567) */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 568) struct afs_volume {
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 569) union {
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 570) struct rcu_head rcu;
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 571) afs_volid_t vid; /* volume ID */
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 572) };
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 573) atomic_t usage;
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 574) time64_t update_at; /* Time at which to next update */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 575) struct afs_cell *cell; /* Cell to which belongs (pins ref) */
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 576) struct rb_node cell_node; /* Link in cell->volumes */
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 577) struct hlist_node proc_link; /* Link in cell->proc_volumes */
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 578) struct super_block __rcu *sb; /* Superblock on which inodes reside */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 579) unsigned long flags;
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 580) #define AFS_VOLUME_NEEDS_UPDATE 0 /* - T if an update needs performing */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 581) #define AFS_VOLUME_UPDATING 1 /* - T if an update is in progress */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 582) #define AFS_VOLUME_WAIT 2 /* - T if users must wait for update */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 583) #define AFS_VOLUME_DELETED 3 /* - T if volume appears deleted */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 584) #define AFS_VOLUME_OFFLINE 4 /* - T if volume offline notice given */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 585) #define AFS_VOLUME_BUSY 5 /* - T if volume busy notice given */
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 586) #define AFS_VOLUME_MAYBE_NO_IBULK 6 /* - T if some servers don't have InlineBulkStatus */
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 587) #ifdef CONFIG_AFS_FSCACHE
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 588) struct fscache_cookie *cache; /* caching cookie */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 589) #endif
8a070a964877c (David Howells 2020-04-25 10:26:02 +0100 590) struct afs_server_list __rcu *servers; /* List of servers on which volume resides */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 591) rwlock_t servers_lock; /* Lock for ->servers */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 592) unsigned int servers_seq; /* Incremented each time ->servers changes */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 593)
68251f0a6818f (David Howells 2018-05-12 22:31:33 +0100 594) unsigned cb_v_break; /* Break-everything counter. */
90fa9b64523a6 (David Howells 2019-06-20 16:49:35 +0100 595) rwlock_t cb_v_break_lock;
68251f0a6818f (David Howells 2018-05-12 22:31:33 +0100 596)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 597) afs_voltype_t type; /* type of volume */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 598) char type_force; /* force volume type (suppress R/O -> R/W) */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 599) u8 name_len;
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 600) u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 601) };
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 602)
0fafdc9f888b4 (David Howells 2017-11-13 16:59:50 +0000 603) enum afs_lock_state {
0fafdc9f888b4 (David Howells 2017-11-13 16:59:50 +0000 604) AFS_VNODE_LOCK_NONE, /* The vnode has no lock on the server */
0fafdc9f888b4 (David Howells 2017-11-13 16:59:50 +0000 605) AFS_VNODE_LOCK_WAITING_FOR_CB, /* We're waiting for the server to break the callback */
0fafdc9f888b4 (David Howells 2017-11-13 16:59:50 +0000 606) AFS_VNODE_LOCK_SETTING, /* We're asking the server for a lock */
0fafdc9f888b4 (David Howells 2017-11-13 16:59:50 +0000 607) AFS_VNODE_LOCK_GRANTED, /* We have a lock on the server */
0fafdc9f888b4 (David Howells 2017-11-13 16:59:50 +0000 608) AFS_VNODE_LOCK_EXTENDING, /* We're extending a lock on the server */
0fafdc9f888b4 (David Howells 2017-11-13 16:59:50 +0000 609) AFS_VNODE_LOCK_NEED_UNLOCK, /* We need to unlock on the server */
0fafdc9f888b4 (David Howells 2017-11-13 16:59:50 +0000 610) AFS_VNODE_LOCK_UNLOCKING, /* We're telling the server to unlock */
cdfb26b40dfa5 (David Howells 2019-04-25 14:26:51 +0100 611) AFS_VNODE_LOCK_DELETED, /* The vnode has been deleted whilst we have a lock */
0fafdc9f888b4 (David Howells 2017-11-13 16:59:50 +0000 612) };
0fafdc9f888b4 (David Howells 2017-11-13 16:59:50 +0000 613)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 614) /*
f8de483e7440b (David Howells 2017-12-01 11:40:43 +0000 615) * AFS inode private data.
f8de483e7440b (David Howells 2017-12-01 11:40:43 +0000 616) *
f8de483e7440b (David Howells 2017-12-01 11:40:43 +0000 617) * Note that afs_alloc_inode() *must* reset anything that could incorrectly
f8de483e7440b (David Howells 2017-12-01 11:40:43 +0000 618) * leak from one inode to another.
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 619) */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 620) struct afs_vnode {
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 621) struct inode vfs_inode; /* the VFS's inode record */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 622)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 623) struct afs_volume *volume; /* volume on which vnode resides */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 624) struct afs_fid fid; /* the file identifier for this inode */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 625) struct afs_file_status status; /* AFS status info for this file */
a4ff7401fbfa0 (David Howells 2018-04-06 14:17:24 +0100 626) afs_dataversion_t invalid_before; /* Child dentries are invalid before this */
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 627) #ifdef CONFIG_AFS_FSCACHE
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 628) struct fscache_cookie *cache; /* caching cookie */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 629) #endif
fe342cf77bc3c (David Howells 2018-04-09 21:12:31 +0100 630) struct afs_permits __rcu *permit_cache; /* cache of permits so far obtained */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 631) struct mutex io_lock; /* Lock for serialising I/O on this mutex */
b61f7dcf4eb26 (David Howells 2018-04-27 20:46:22 +0100 632) struct rw_semaphore validate_lock; /* lock for validating this vnode */
79ddbfa500b37 (David Howells 2019-04-25 14:26:51 +0100 633) struct rw_semaphore rmdir_lock; /* Lock for rmdir vs sillyrename */
79ddbfa500b37 (David Howells 2019-04-25 14:26:51 +0100 634) struct key *silly_key; /* Silly rename key */
4343d00872e1d (David Howells 2017-11-02 15:27:52 +0000 635) spinlock_t wb_lock; /* lock for wb_keys */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 636) spinlock_t lock; /* waitqueue/flags lock */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 637) unsigned long flags;
c435ee34551e1 (David Howells 2017-11-02 15:27:49 +0000 638) #define AFS_VNODE_CB_PROMISED 0 /* Set if vnode has a callback promise */
260a980317dac (David Howells 2007-04-26 15:59:35 -0700 639) #define AFS_VNODE_UNSET 1 /* set if vnode attributes not yet set */
f3ddee8dc4e2c (David Howells 2018-04-06 14:17:25 +0100 640) #define AFS_VNODE_DIR_VALID 2 /* Set if dir contents are valid */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 641) #define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 642) #define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 643) #define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */
0fafdc9f888b4 (David Howells 2017-11-13 16:59:50 +0000 644) #define AFS_VNODE_AUTOCELL 6 /* set if Vnode is an auto mount point */
0fafdc9f888b4 (David Howells 2017-11-13 16:59:50 +0000 645) #define AFS_VNODE_PSEUDODIR 7 /* set if Vnode is a pseudo directory */
5a8132761609b (David Howells 2018-04-06 14:17:26 +0100 646) #define AFS_VNODE_NEW_CONTENT 8 /* Set if file has new content (create/trunc-0) */
b6489a49f7b71 (David Howells 2020-06-15 17:36:58 +0100 647) #define AFS_VNODE_SILLY_DELETED 9 /* Set if file has been silly-deleted */
22650f1481265 (David Howells 2021-04-30 13:47:08 +0100 648) #define AFS_VNODE_MODIFYING 10 /* Set if we're performing a modification op */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 649)
4343d00872e1d (David Howells 2017-11-02 15:27:52 +0000 650) struct list_head wb_keys; /* List of keys available for writeback */
e8d6c554126b8 (David Howells 2007-07-15 23:40:12 -0700 651) struct list_head pending_locks; /* locks waiting to be granted */
e8d6c554126b8 (David Howells 2007-07-15 23:40:12 -0700 652) struct list_head granted_locks; /* locks granted on this file */
e8d6c554126b8 (David Howells 2007-07-15 23:40:12 -0700 653) struct delayed_work lock_work; /* work to be done in locking */
0fafdc9f888b4 (David Howells 2017-11-13 16:59:50 +0000 654) struct key *lock_key; /* Key to be used in lock ops */
a690f60a2ba31 (David Howells 2019-04-25 14:26:50 +0100 655) ktime_t locked_at; /* Time at which lock obtained */
0fafdc9f888b4 (David Howells 2017-11-13 16:59:50 +0000 656) enum afs_lock_state lock_state : 8;
0fafdc9f888b4 (David Howells 2017-11-13 16:59:50 +0000 657) afs_lock_type_t lock_type : 8;
31143d5d515ec (David Howells 2007-05-09 02:33:46 -0700 658)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 659) /* outstanding callback notification on this file */
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 660) void *cb_server; /* Server with callback/filelock */
c435ee34551e1 (David Howells 2017-11-02 15:27:49 +0000 661) unsigned int cb_s_break; /* Mass break counter on ->server */
68251f0a6818f (David Howells 2018-05-12 22:31:33 +0100 662) unsigned int cb_v_break; /* Mass break counter on ->volume */
c435ee34551e1 (David Howells 2017-11-02 15:27:49 +0000 663) unsigned int cb_break; /* Break counter on vnode */
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 664) seqlock_t cb_lock; /* Lock for ->cb_server, ->status, ->cb_*break */
c435ee34551e1 (David Howells 2017-11-02 15:27:49 +0000 665)
c435ee34551e1 (David Howells 2017-11-02 15:27:49 +0000 666) time64_t cb_expires_at; /* time at which callback expires */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 667) };
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 668)
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 669) static inline struct fscache_cookie *afs_vnode_cache(struct afs_vnode *vnode)
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 670) {
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 671) #ifdef CONFIG_AFS_FSCACHE
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 672) return vnode->cache;
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 673) #else
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 674) return NULL;
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 675) #endif
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 676) }
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 677)
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 678) /*
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 679) * cached security record for one user's attempt to access a vnode
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 680) */
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 681) struct afs_permit {
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 682) struct key *key; /* RxRPC ticket holding a security context */
be080a6f43c40 (David Howells 2017-11-02 15:27:49 +0000 683) afs_access_t access; /* CallerAccess value for this key */
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 684) };
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 685)
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 686) /*
be080a6f43c40 (David Howells 2017-11-02 15:27:49 +0000 687) * Immutable cache of CallerAccess records from attempts to access vnodes.
be080a6f43c40 (David Howells 2017-11-02 15:27:49 +0000 688) * These may be shared between multiple vnodes.
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 689) */
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 690) struct afs_permits {
be080a6f43c40 (David Howells 2017-11-02 15:27:49 +0000 691) struct rcu_head rcu;
be080a6f43c40 (David Howells 2017-11-02 15:27:49 +0000 692) struct hlist_node hash_node; /* Link in hash */
be080a6f43c40 (David Howells 2017-11-02 15:27:49 +0000 693) unsigned long h; /* Hash value for this permit list */
be080a6f43c40 (David Howells 2017-11-02 15:27:49 +0000 694) refcount_t usage;
be080a6f43c40 (David Howells 2017-11-02 15:27:49 +0000 695) unsigned short nr_permits; /* Number of records */
be080a6f43c40 (David Howells 2017-11-02 15:27:49 +0000 696) bool invalidated; /* Invalidated due to key change */
be080a6f43c40 (David Howells 2017-11-02 15:27:49 +0000 697) struct afs_permit permits[]; /* List of permits sorted by key pointer */
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 698) };
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 699)
4584ae96ae307 (David Howells 2018-11-13 23:20:28 +0000 700) /*
4584ae96ae307 (David Howells 2018-11-13 23:20:28 +0000 701) * Error prioritisation and accumulation.
4584ae96ae307 (David Howells 2018-11-13 23:20:28 +0000 702) */
4584ae96ae307 (David Howells 2018-11-13 23:20:28 +0000 703) struct afs_error {
4584ae96ae307 (David Howells 2018-11-13 23:20:28 +0000 704) short error; /* Accumulated error */
4584ae96ae307 (David Howells 2018-11-13 23:20:28 +0000 705) bool responded; /* T if server responded */
4584ae96ae307 (David Howells 2018-11-13 23:20:28 +0000 706) };
4584ae96ae307 (David Howells 2018-11-13 23:20:28 +0000 707)
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 708) /*
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 709) * Cursor for iterating over a server's address list.
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 710) */
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 711) struct afs_addr_cursor {
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 712) struct afs_addr_list *alist; /* Current address list (pins ref) */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 713) unsigned long tried; /* Tried addresses */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 714) signed char index; /* Current address */
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 715) bool responded; /* T if the current address responded */
744bcd713a4ea (David Howells 2018-10-20 00:57:58 +0100 716) unsigned short nr_iterations; /* Number of address iterations */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 717) short error;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 718) u32 abort_code;
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 719) };
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 720)
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 721) /*
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 722) * Cursor for iterating over a set of volume location servers.
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 723) */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 724) struct afs_vl_cursor {
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 725) struct afs_addr_cursor ac;
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 726) struct afs_cell *cell; /* The cell we're querying */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 727) struct afs_vlserver_list *server_list; /* Current server list (pins ref) */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 728) struct afs_vlserver *server; /* Server on which this resides */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 729) struct key *key; /* Key for the server */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 730) unsigned long untried; /* Bitmask of untried servers */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 731) short index; /* Current server */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 732) short error;
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 733) unsigned short flags;
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 734) #define AFS_VL_CURSOR_STOP 0x0001 /* Set to cease iteration */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 735) #define AFS_VL_CURSOR_RETRY 0x0002 /* Set to do a retry */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 736) #define AFS_VL_CURSOR_RETRIED 0x0004 /* Set if started a retry */
744bcd713a4ea (David Howells 2018-10-20 00:57:58 +0100 737) unsigned short nr_iterations; /* Number of server iterations */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 738) };
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 739)
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 740) /*
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 741) * Fileserver operation methods.
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 742) */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 743) struct afs_operation_ops {
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 744) void (*issue_afs_rpc)(struct afs_operation *op);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 745) void (*issue_yfs_rpc)(struct afs_operation *op);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 746) void (*success)(struct afs_operation *op);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 747) void (*aborted)(struct afs_operation *op);
dc4191841d099 (David Howells 2020-09-18 09:11:15 +0100 748) void (*failed)(struct afs_operation *op);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 749) void (*edit_dir)(struct afs_operation *op);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 750) void (*put)(struct afs_operation *op);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 751) };
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 752)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 753) struct afs_vnode_param {
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 754) struct afs_vnode *vnode;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 755) struct afs_fid fid; /* Fid to access */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 756) struct afs_status_cb scb; /* Returned status and callback promise */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 757) afs_dataversion_t dv_before; /* Data version before the call */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 758) unsigned int cb_break_before; /* cb_break + cb_s_break before the call */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 759) u8 dv_delta; /* Expected change in data version */
793fe82ee33aa (David Howells 2020-06-12 16:13:52 +0100 760) bool put_vnode:1; /* T if we have a ref on the vnode */
793fe82ee33aa (David Howells 2020-06-12 16:13:52 +0100 761) bool need_io_lock:1; /* T if we need the I/O lock on this */
793fe82ee33aa (David Howells 2020-06-12 16:13:52 +0100 762) bool update_ctime:1; /* Need to update the ctime */
793fe82ee33aa (David Howells 2020-06-12 16:13:52 +0100 763) bool set_size:1; /* Must update i_size */
b6489a49f7b71 (David Howells 2020-06-15 17:36:58 +0100 764) bool op_unlinked:1; /* True if file was unlinked by op */
a9e5c87ca7443 (David Howells 2020-11-22 13:13:45 +0000 765) bool speculative:1; /* T if speculative status fetch (no vnode lock) */
22650f1481265 (David Howells 2021-04-30 13:47:08 +0100 766) bool modification:1; /* Set if the content gets modified */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 767) };
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 768)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 769) /*
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 770) * Fileserver operation wrapper, handling server and address rotation
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 771) * asynchronously. May make simultaneous calls to multiple servers.
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 772) */
a310082f6d0af (David Howells 2020-03-20 09:32:50 +0000 773) struct afs_operation {
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 774) struct afs_net *net; /* Network namespace */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 775) struct key *key; /* Key for the cell */
a58823ac45896 (David Howells 2019-05-09 15:16:10 +0100 776) const struct afs_call_type *type; /* Type of call done */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 777) const struct afs_operation_ops *ops;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 778)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 779) /* Parameters/results for the operation */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 780) struct afs_volume *volume; /* Volume being accessed */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 781) struct afs_vnode_param file[2];
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 782) struct afs_vnode_param *more_files;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 783) struct afs_volsync volsync;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 784) struct dentry *dentry; /* Dentry to be altered */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 785) struct dentry *dentry_2; /* Second dentry to be altered */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 786) struct timespec64 mtime; /* Modification time to record */
da8d07551275a (David Howells 2020-06-13 19:34:59 +0100 787) struct timespec64 ctime; /* Change time to set */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 788) short nr_files; /* Number of entries in file[], more_files */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 789) short error;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 790) unsigned int debug_id;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 791)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 792) unsigned int cb_v_break; /* Volume break counter before op */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 793) unsigned int cb_s_break; /* Server break counter before op */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 794)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 795) union {
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 796) struct {
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 797) int which; /* Which ->file[] to fetch for */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 798) } fetch_status;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 799) struct {
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 800) int reason; /* enum afs_edit_dir_reason */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 801) mode_t mode;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 802) const char *symlink;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 803) } create;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 804) struct {
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 805) bool need_rehash;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 806) } unlink;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 807) struct {
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 808) struct dentry *rehash;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 809) struct dentry *tmp;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 810) bool new_negative;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 811) } rename;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 812) struct {
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 813) struct afs_read *req;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 814) } fetch;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 815) struct {
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 816) afs_lock_type_t type;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 817) } lock;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 818) struct {
bd80d8a80e128 (David Howells 2020-02-06 14:22:28 +0000 819) struct iov_iter *write_iter;
bd80d8a80e128 (David Howells 2020-02-06 14:22:28 +0000 820) loff_t pos;
bd80d8a80e128 (David Howells 2020-02-06 14:22:28 +0000 821) loff_t size;
bd80d8a80e128 (David Howells 2020-02-06 14:22:28 +0000 822) loff_t i_size;
bd80d8a80e128 (David Howells 2020-02-06 14:22:28 +0000 823) bool laundering; /* Laundering page, PG_writeback not set */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 824) } store;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 825) struct {
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 826) struct iattr *attr;
ec0fa0b659144 (David Howells 2020-10-07 14:22:12 +0100 827) loff_t old_i_size;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 828) } setattr;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 829) struct afs_acl *acl;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 830) struct yfs_acl *yacl;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 831) struct {
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 832) struct afs_volume_status vs;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 833) struct kstatfs *buf;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 834) } volstatus;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 835) };
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 836)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 837) /* Fileserver iteration state */
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 838) struct afs_addr_cursor ac;
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 839) struct afs_server_list *server_list; /* Current server list (pins ref) */
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 840) struct afs_server *server; /* Server we're using (ref pinned by server_list) */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 841) struct afs_call *call;
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 842) unsigned long untried; /* Bitmask of untried servers */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 843) short index; /* Current server */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 844) unsigned short nr_iterations; /* Number of server iterations */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 845)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 846) unsigned int flags;
8409f67b6437c (David Howells 2020-04-22 00:02:46 +0100 847) #define AFS_OPERATION_STOP 0x0001 /* Set to cease iteration */
8409f67b6437c (David Howells 2020-04-22 00:02:46 +0100 848) #define AFS_OPERATION_VBUSY 0x0002 /* Set if seen VBUSY */
8409f67b6437c (David Howells 2020-04-22 00:02:46 +0100 849) #define AFS_OPERATION_VMOVED 0x0004 /* Set if seen VMOVED */
8409f67b6437c (David Howells 2020-04-22 00:02:46 +0100 850) #define AFS_OPERATION_VNOVOL 0x0008 /* Set if seen VNOVOL */
8409f67b6437c (David Howells 2020-04-22 00:02:46 +0100 851) #define AFS_OPERATION_CUR_ONLY 0x0010 /* Set if current server only (file lock held) */
8409f67b6437c (David Howells 2020-04-22 00:02:46 +0100 852) #define AFS_OPERATION_NO_VSLEEP 0x0020 /* Set to prevent sleep on VBUSY, VOFFLINE, ... */
8409f67b6437c (David Howells 2020-04-22 00:02:46 +0100 853) #define AFS_OPERATION_UNINTR 0x0040 /* Set if op is uninterruptible */
8409f67b6437c (David Howells 2020-04-22 00:02:46 +0100 854) #define AFS_OPERATION_DOWNGRADE 0x0080 /* Set to retry with downgraded opcode */
8409f67b6437c (David Howells 2020-04-22 00:02:46 +0100 855) #define AFS_OPERATION_LOCK_0 0x0100 /* Set if have io_lock on file[0] */
8409f67b6437c (David Howells 2020-04-22 00:02:46 +0100 856) #define AFS_OPERATION_LOCK_1 0x0200 /* Set if have io_lock on file[1] */
8409f67b6437c (David Howells 2020-04-22 00:02:46 +0100 857) #define AFS_OPERATION_TRIED_ALL 0x0400 /* Set if we've tried all the fileservers */
8409f67b6437c (David Howells 2020-04-22 00:02:46 +0100 858) #define AFS_OPERATION_RETRY_SERVER 0x0800 /* Set if we should retry the current server */
b6489a49f7b71 (David Howells 2020-06-15 17:36:58 +0100 859) #define AFS_OPERATION_DIR_CONFLICT 0x1000 /* Set if we detected a 3rd-party dir change */
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 860) };
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 861)
402cb8dda949d (David Howells 2018-04-04 13:41:28 +0100 862) /*
402cb8dda949d (David Howells 2018-04-04 13:41:28 +0100 863) * Cache auxiliary data.
402cb8dda949d (David Howells 2018-04-04 13:41:28 +0100 864) */
402cb8dda949d (David Howells 2018-04-04 13:41:28 +0100 865) struct afs_vnode_cache_aux {
402cb8dda949d (David Howells 2018-04-04 13:41:28 +0100 866) u64 data_version;
402cb8dda949d (David Howells 2018-04-04 13:41:28 +0100 867) } __packed;
402cb8dda949d (David Howells 2018-04-04 13:41:28 +0100 868)
185f0c7073bd5 (David Howells 2020-10-26 13:22:47 +0000 869) /*
185f0c7073bd5 (David Howells 2020-10-26 13:22:47 +0000 870) * We use page->private to hold the amount of the page that we've written to,
185f0c7073bd5 (David Howells 2020-10-26 13:22:47 +0000 871) * splitting the field into two parts. However, we need to represent a range
2d9900f26ad61 (David Howells 2020-10-28 12:08:39 +0000 872) * 0...PAGE_SIZE, so we reduce the resolution if the size of the page
2d9900f26ad61 (David Howells 2020-10-28 12:08:39 +0000 873) * exceeds what we can encode.
185f0c7073bd5 (David Howells 2020-10-26 13:22:47 +0000 874) */
65dd2d6072d39 (David Howells 2020-10-26 13:57:44 +0000 875) #ifdef CONFIG_64BIT
f86726a69dec5 (David Howells 2020-10-22 14:08:23 +0100 876) #define __AFS_PAGE_PRIV_MASK 0x7fffffffUL
185f0c7073bd5 (David Howells 2020-10-26 13:22:47 +0000 877) #define __AFS_PAGE_PRIV_SHIFT 32
f86726a69dec5 (David Howells 2020-10-22 14:08:23 +0100 878) #define __AFS_PAGE_PRIV_MMAPPED 0x80000000UL
185f0c7073bd5 (David Howells 2020-10-26 13:22:47 +0000 879) #else
f86726a69dec5 (David Howells 2020-10-22 14:08:23 +0100 880) #define __AFS_PAGE_PRIV_MASK 0x7fffUL
185f0c7073bd5 (David Howells 2020-10-26 13:22:47 +0000 881) #define __AFS_PAGE_PRIV_SHIFT 16
f86726a69dec5 (David Howells 2020-10-22 14:08:23 +0100 882) #define __AFS_PAGE_PRIV_MMAPPED 0x8000UL
185f0c7073bd5 (David Howells 2020-10-26 13:22:47 +0000 883) #endif
185f0c7073bd5 (David Howells 2020-10-26 13:22:47 +0000 884)
67d78a6f6e7b3 (David Howells 2020-10-28 14:23:46 +0000 885) static inline unsigned int afs_page_dirty_resolution(struct page *page)
2d9900f26ad61 (David Howells 2020-10-28 12:08:39 +0000 886) {
67d78a6f6e7b3 (David Howells 2020-10-28 14:23:46 +0000 887) int shift = thp_order(page) + PAGE_SHIFT - (__AFS_PAGE_PRIV_SHIFT - 1);
2d9900f26ad61 (David Howells 2020-10-28 12:08:39 +0000 888) return (shift > 0) ? shift : 0;
2d9900f26ad61 (David Howells 2020-10-28 12:08:39 +0000 889) }
2d9900f26ad61 (David Howells 2020-10-28 12:08:39 +0000 890)
67d78a6f6e7b3 (David Howells 2020-10-28 14:23:46 +0000 891) static inline size_t afs_page_dirty_from(struct page *page, unsigned long priv)
185f0c7073bd5 (David Howells 2020-10-26 13:22:47 +0000 892) {
2d9900f26ad61 (David Howells 2020-10-28 12:08:39 +0000 893) unsigned long x = priv & __AFS_PAGE_PRIV_MASK;
2d9900f26ad61 (David Howells 2020-10-28 12:08:39 +0000 894)
2d9900f26ad61 (David Howells 2020-10-28 12:08:39 +0000 895) /* The lower bound is inclusive */
67d78a6f6e7b3 (David Howells 2020-10-28 14:23:46 +0000 896) return x << afs_page_dirty_resolution(page);
185f0c7073bd5 (David Howells 2020-10-26 13:22:47 +0000 897) }
185f0c7073bd5 (David Howells 2020-10-26 13:22:47 +0000 898)
67d78a6f6e7b3 (David Howells 2020-10-28 14:23:46 +0000 899) static inline size_t afs_page_dirty_to(struct page *page, unsigned long priv)
185f0c7073bd5 (David Howells 2020-10-26 13:22:47 +0000 900) {
2d9900f26ad61 (David Howells 2020-10-28 12:08:39 +0000 901) unsigned long x = (priv >> __AFS_PAGE_PRIV_SHIFT) & __AFS_PAGE_PRIV_MASK;
2d9900f26ad61 (David Howells 2020-10-28 12:08:39 +0000 902)
2d9900f26ad61 (David Howells 2020-10-28 12:08:39 +0000 903) /* The upper bound is immediately beyond the region */
67d78a6f6e7b3 (David Howells 2020-10-28 14:23:46 +0000 904) return (x + 1) << afs_page_dirty_resolution(page);
185f0c7073bd5 (David Howells 2020-10-26 13:22:47 +0000 905) }
185f0c7073bd5 (David Howells 2020-10-26 13:22:47 +0000 906)
67d78a6f6e7b3 (David Howells 2020-10-28 14:23:46 +0000 907) static inline unsigned long afs_page_dirty(struct page *page, size_t from, size_t to)
185f0c7073bd5 (David Howells 2020-10-26 13:22:47 +0000 908) {
67d78a6f6e7b3 (David Howells 2020-10-28 14:23:46 +0000 909) unsigned int res = afs_page_dirty_resolution(page);
2d9900f26ad61 (David Howells 2020-10-28 12:08:39 +0000 910) from >>= res;
2d9900f26ad61 (David Howells 2020-10-28 12:08:39 +0000 911) to = (to - 1) >> res;
2d9900f26ad61 (David Howells 2020-10-28 12:08:39 +0000 912) return (to << __AFS_PAGE_PRIV_SHIFT) | from;
185f0c7073bd5 (David Howells 2020-10-26 13:22:47 +0000 913) }
185f0c7073bd5 (David Howells 2020-10-26 13:22:47 +0000 914)
f86726a69dec5 (David Howells 2020-10-22 14:08:23 +0100 915) static inline unsigned long afs_page_dirty_mmapped(unsigned long priv)
f86726a69dec5 (David Howells 2020-10-22 14:08:23 +0100 916) {
f86726a69dec5 (David Howells 2020-10-22 14:08:23 +0100 917) return priv | __AFS_PAGE_PRIV_MMAPPED;
f86726a69dec5 (David Howells 2020-10-22 14:08:23 +0100 918) }
f86726a69dec5 (David Howells 2020-10-22 14:08:23 +0100 919)
f86726a69dec5 (David Howells 2020-10-22 14:08:23 +0100 920) static inline bool afs_is_page_dirty_mmapped(unsigned long priv)
f86726a69dec5 (David Howells 2020-10-22 14:08:23 +0100 921) {
f86726a69dec5 (David Howells 2020-10-22 14:08:23 +0100 922) return priv & __AFS_PAGE_PRIV_MMAPPED;
f86726a69dec5 (David Howells 2020-10-22 14:08:23 +0100 923) }
f86726a69dec5 (David Howells 2020-10-22 14:08:23 +0100 924)
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 925) #include <trace/events/afs.h>
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 926)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 927) /*****************************************************************************/
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 928) /*
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 929) * addr_list.c
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 930) */
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 931) static inline struct afs_addr_list *afs_get_addrlist(struct afs_addr_list *alist)
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 932) {
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 933) if (alist)
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 934) refcount_inc(&alist->usage);
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 935) return alist;
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 936) }
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 937) extern struct afs_addr_list *afs_alloc_addrlist(unsigned int,
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 938) unsigned short,
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 939) unsigned short);
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 940) extern void afs_put_addrlist(struct afs_addr_list *);
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 941) extern struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *,
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 942) const char *, size_t, char,
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 943) unsigned short, unsigned short);
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 944) extern struct afs_vlserver_list *afs_dns_query(struct afs_cell *, time64_t *);
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 945) extern bool afs_iterate_addresses(struct afs_addr_cursor *);
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 946) extern int afs_end_cursor(struct afs_addr_cursor *);
8b2a464ced77f (David Howells 2017-11-02 15:27:50 +0000 947)
bf99a53ce22a2 (David Howells 2017-11-02 15:27:51 +0000 948) extern void afs_merge_fs_addr4(struct afs_addr_list *, __be32, u16);
bf99a53ce22a2 (David Howells 2017-11-02 15:27:51 +0000 949) extern void afs_merge_fs_addr6(struct afs_addr_list *, __be32 *, u16);
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 950)
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 951) /*
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 952) * cache.c
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 953) */
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 954) #ifdef CONFIG_AFS_FSCACHE
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 955) extern struct fscache_netfs afs_cache_netfs;
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 956) extern struct fscache_cookie_def afs_cell_cache_index_def;
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 957) extern struct fscache_cookie_def afs_volume_cache_index_def;
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 958) extern struct fscache_cookie_def afs_vnode_cache_index_def;
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 959) #else
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 960) #define afs_cell_cache_index_def (*(struct fscache_cookie_def *) NULL)
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 961) #define afs_volume_cache_index_def (*(struct fscache_cookie_def *) NULL)
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 962) #define afs_vnode_cache_index_def (*(struct fscache_cookie_def *) NULL)
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 963) #endif
9b3f26c9110dc (David Howells 2009-04-03 16:42:41 +0100 964)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 965) /*
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 966) * callback.c
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 967) */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 968) extern void afs_init_callback_state(struct afs_server *);
051d25250b55c (David Howells 2019-06-20 18:12:16 +0100 969) extern void __afs_break_callback(struct afs_vnode *, enum afs_cb_break_reason);
051d25250b55c (David Howells 2019-06-20 18:12:16 +0100 970) extern void afs_break_callback(struct afs_vnode *, enum afs_cb_break_reason);
051d25250b55c (David Howells 2019-06-20 18:12:16 +0100 971) extern void afs_break_callbacks(struct afs_server *, size_t, struct afs_callback_break *);
c435ee34551e1 (David Howells 2017-11-02 15:27:49 +0000 972)
68251f0a6818f (David Howells 2018-05-12 22:31:33 +0100 973) static inline unsigned int afs_calc_vnode_cb_break(struct afs_vnode *vnode)
68251f0a6818f (David Howells 2018-05-12 22:31:33 +0100 974) {
eeba1e9cf31d0 (David Howells 2019-04-13 08:37:37 +0100 975) return vnode->cb_break + vnode->cb_v_break;
68251f0a6818f (David Howells 2018-05-12 22:31:33 +0100 976) }
68251f0a6818f (David Howells 2018-05-12 22:31:33 +0100 977)
18ac61853cc4e (David Howells 2018-10-20 00:57:59 +0100 978) static inline bool afs_cb_is_broken(unsigned int cb_break,
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 979) const struct afs_vnode *vnode)
68251f0a6818f (David Howells 2018-05-12 22:31:33 +0100 980) {
20325960f8750 (David Howells 2020-04-30 01:03:49 +0100 981) return cb_break != (vnode->cb_break + vnode->volume->cb_v_break);
68251f0a6818f (David Howells 2018-05-12 22:31:33 +0100 982) }
68251f0a6818f (David Howells 2018-05-12 22:31:33 +0100 983)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 984) /*
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 985) * cell.c
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 986) */
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 987) extern int afs_cell_init(struct afs_net *, const char *);
dca54a7bbb8ca (David Howells 2020-10-13 20:51:59 +0100 988) extern struct afs_cell *afs_find_cell(struct afs_net *, const char *, unsigned,
dca54a7bbb8ca (David Howells 2020-10-13 20:51:59 +0100 989) enum afs_cell_trace);
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 990) extern struct afs_cell *afs_lookup_cell(struct afs_net *, const char *, unsigned,
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 991) const char *, bool);
dca54a7bbb8ca (David Howells 2020-10-13 20:51:59 +0100 992) extern struct afs_cell *afs_use_cell(struct afs_cell *, enum afs_cell_trace);
dca54a7bbb8ca (David Howells 2020-10-13 20:51:59 +0100 993) extern void afs_unuse_cell(struct afs_net *, struct afs_cell *, enum afs_cell_trace);
dca54a7bbb8ca (David Howells 2020-10-13 20:51:59 +0100 994) extern struct afs_cell *afs_get_cell(struct afs_cell *, enum afs_cell_trace);
dca54a7bbb8ca (David Howells 2020-10-13 20:51:59 +0100 995) extern void afs_see_cell(struct afs_cell *, enum afs_cell_trace);
dca54a7bbb8ca (David Howells 2020-10-13 20:51:59 +0100 996) extern void afs_put_cell(struct afs_cell *, enum afs_cell_trace);
dca54a7bbb8ca (David Howells 2020-10-13 20:51:59 +0100 997) extern void afs_queue_cell(struct afs_cell *, enum afs_cell_trace);
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 998) extern void afs_manage_cells(struct work_struct *);
989782dcdc91a (David Howells 2017-11-02 15:27:50 +0000 999) extern void afs_cells_timer(struct timer_list *);
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1000) extern void __net_exit afs_cell_purge(struct afs_net *);
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1001)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1002) /*
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1003) * cmservice.c
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1004) */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1005) extern bool afs_cm_incoming_call(struct afs_call *);
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1006)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1007) /*
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1008) * dir.c
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1009) */
4d673da14533b (David Howells 2018-02-06 06:26:30 +0000 1010) extern const struct file_operations afs_dir_file_operations;
754661f143e70 (Arjan van de Ven 2007-02-12 00:55:38 -0800 1011) extern const struct inode_operations afs_dir_inode_operations;
f3ddee8dc4e2c (David Howells 2018-04-06 14:17:25 +0100 1012) extern const struct address_space_operations afs_dir_aops;
d61dcce2977d9 (Al Viro 2011-01-12 20:04:20 -0500 1013) extern const struct dentry_operations afs_fs_dentry_operations;
4d673da14533b (David Howells 2018-02-06 06:26:30 +0000 1014)
66c7e1d319a5b (David Howells 2018-04-06 14:17:25 +0100 1015) extern void afs_d_release(struct dentry *);
728279a5a1fd9 (David Howells 2020-06-16 00:34:09 +0100 1016) extern void afs_check_for_remote_deletion(struct afs_operation *);
66c7e1d319a5b (David Howells 2018-04-06 14:17:25 +0100 1017)
63a4681ff39cb (David Howells 2018-04-06 14:17:25 +0100 1018) /*
63a4681ff39cb (David Howells 2018-04-06 14:17:25 +0100 1019) * dir_edit.c
63a4681ff39cb (David Howells 2018-04-06 14:17:25 +0100 1020) */
63a4681ff39cb (David Howells 2018-04-06 14:17:25 +0100 1021) extern void afs_edit_dir_add(struct afs_vnode *, struct qstr *, struct afs_fid *,
63a4681ff39cb (David Howells 2018-04-06 14:17:25 +0100 1022) enum afs_edit_dir_reason);
63a4681ff39cb (David Howells 2018-04-06 14:17:25 +0100 1023) extern void afs_edit_dir_remove(struct afs_vnode *, struct qstr *, enum afs_edit_dir_reason);
63a4681ff39cb (David Howells 2018-04-06 14:17:25 +0100 1024)
79ddbfa500b37 (David Howells 2019-04-25 14:26:51 +0100 1025) /*
79ddbfa500b37 (David Howells 2019-04-25 14:26:51 +0100 1026) * dir_silly.c
79ddbfa500b37 (David Howells 2019-04-25 14:26:51 +0100 1027) */
79ddbfa500b37 (David Howells 2019-04-25 14:26:51 +0100 1028) extern int afs_sillyrename(struct afs_vnode *, struct afs_vnode *,
79ddbfa500b37 (David Howells 2019-04-25 14:26:51 +0100 1029) struct dentry *, struct key *);
79ddbfa500b37 (David Howells 2019-04-25 14:26:51 +0100 1030) extern int afs_silly_iput(struct dentry *, struct inode *);
79ddbfa500b37 (David Howells 2019-04-25 14:26:51 +0100 1031)
66c7e1d319a5b (David Howells 2018-04-06 14:17:25 +0100 1032) /*
66c7e1d319a5b (David Howells 2018-04-06 14:17:25 +0100 1033) * dynroot.c
66c7e1d319a5b (David Howells 2018-04-06 14:17:25 +0100 1034) */
66c7e1d319a5b (David Howells 2018-04-06 14:17:25 +0100 1035) extern const struct inode_operations afs_dynroot_inode_operations;
66c7e1d319a5b (David Howells 2018-04-06 14:17:25 +0100 1036) extern const struct dentry_operations afs_dynroot_dentry_operations;
66c7e1d319a5b (David Howells 2018-04-06 14:17:25 +0100 1037)
66c7e1d319a5b (David Howells 2018-04-06 14:17:25 +0100 1038) extern struct inode *afs_try_auto_mntpt(struct dentry *, struct inode *);
0da0b7fd73e4f (David Howells 2018-06-15 15:19:22 +0100 1039) extern int afs_dynroot_mkdir(struct afs_net *, struct afs_cell *);
0da0b7fd73e4f (David Howells 2018-06-15 15:19:22 +0100 1040) extern void afs_dynroot_rmdir(struct afs_net *, struct afs_cell *);
0da0b7fd73e4f (David Howells 2018-06-15 15:19:22 +0100 1041) extern int afs_dynroot_populate(struct super_block *);
0da0b7fd73e4f (David Howells 2018-06-15 15:19:22 +0100 1042) extern void afs_dynroot_depopulate(struct super_block *);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1043)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1044) /*
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1045) * file.c
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1046) */
f5e54d6e53a20 (Christoph Hellwig 2006-06-28 04:26:44 -0700 1047) extern const struct address_space_operations afs_fs_aops;
754661f143e70 (Arjan van de Ven 2007-02-12 00:55:38 -0800 1048) extern const struct inode_operations afs_file_inode_operations;
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 1049) extern const struct file_operations afs_file_operations;
3003bbd0697b6 (David Howells 2020-02-06 14:22:29 +0000 1050) extern const struct netfs_read_request_ops afs_req_ops;
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 1051)
4343d00872e1d (David Howells 2017-11-02 15:27:52 +0000 1052) extern int afs_cache_wb_key(struct afs_vnode *, struct afs_file *);
4343d00872e1d (David Howells 2017-11-02 15:27:52 +0000 1053) extern void afs_put_wb_key(struct afs_wb_key *);
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 1054) extern int afs_open(struct inode *, struct file *);
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 1055) extern int afs_release(struct inode *, struct file *);
c69bf479baa61 (David Howells 2020-02-06 14:22:27 +0000 1056) extern int afs_fetch_data(struct afs_vnode *, struct afs_read *);
5cbf03985c67c (David Howells 2020-02-06 14:22:29 +0000 1057) extern struct afs_read *afs_alloc_read(gfp_t);
196ee9cd2d047 (David Howells 2017-01-05 10:38:34 +0000 1058) extern void afs_put_read(struct afs_read *);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1059)
d4438a25295d8 (David Howells 2019-11-21 09:12:17 +0000 1060) static inline struct afs_read *afs_get_read(struct afs_read *req)
d4438a25295d8 (David Howells 2019-11-21 09:12:17 +0000 1061) {
d4438a25295d8 (David Howells 2019-11-21 09:12:17 +0000 1062) refcount_inc(&req->usage);
d4438a25295d8 (David Howells 2019-11-21 09:12:17 +0000 1063) return req;
d4438a25295d8 (David Howells 2019-11-21 09:12:17 +0000 1064) }
d4438a25295d8 (David Howells 2019-11-21 09:12:17 +0000 1065)
e8d6c554126b8 (David Howells 2007-07-15 23:40:12 -0700 1066) /*
e8d6c554126b8 (David Howells 2007-07-15 23:40:12 -0700 1067) * flock.c
e8d6c554126b8 (David Howells 2007-07-15 23:40:12 -0700 1068) */
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1069) extern struct workqueue_struct *afs_lock_manager;
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1070)
a690f60a2ba31 (David Howells 2019-04-25 14:26:50 +0100 1071) extern void afs_lock_op_done(struct afs_call *);
e8d6c554126b8 (David Howells 2007-07-15 23:40:12 -0700 1072) extern void afs_lock_work(struct work_struct *);
e8d6c554126b8 (David Howells 2007-07-15 23:40:12 -0700 1073) extern void afs_lock_may_be_available(struct afs_vnode *);
e8d6c554126b8 (David Howells 2007-07-15 23:40:12 -0700 1074) extern int afs_lock(struct file *, int, struct file_lock *);
e8d6c554126b8 (David Howells 2007-07-15 23:40:12 -0700 1075) extern int afs_flock(struct file *, int, struct file_lock *);
e8d6c554126b8 (David Howells 2007-07-15 23:40:12 -0700 1076)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1077) /*
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1078) * fsclient.c
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1079) */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1080) extern void afs_fs_fetch_status(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1081) extern void afs_fs_fetch_data(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1082) extern void afs_fs_create_file(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1083) extern void afs_fs_make_dir(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1084) extern void afs_fs_remove_file(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1085) extern void afs_fs_remove_dir(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1086) extern void afs_fs_link(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1087) extern void afs_fs_symlink(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1088) extern void afs_fs_rename(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1089) extern void afs_fs_store_data(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1090) extern void afs_fs_setattr(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1091) extern void afs_fs_get_volume_status(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1092) extern void afs_fs_set_lock(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1093) extern void afs_fs_extend_lock(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1094) extern void afs_fs_release_lock(struct afs_operation *);
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1095) extern int afs_fs_give_up_all_callbacks(struct afs_net *, struct afs_server *,
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1096) struct afs_addr_cursor *, struct key *);
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1097) extern bool afs_fs_get_capabilities(struct afs_net *, struct afs_server *,
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1098) struct afs_addr_cursor *, struct key *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1099) extern void afs_fs_inline_bulk_status(struct afs_operation *);
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1100)
260f082bae6dc (David Howells 2019-04-25 14:26:52 +0100 1101) struct afs_acl {
260f082bae6dc (David Howells 2019-04-25 14:26:52 +0100 1102) u32 size;
260f082bae6dc (David Howells 2019-04-25 14:26:52 +0100 1103) u8 data[];
260f082bae6dc (David Howells 2019-04-25 14:26:52 +0100 1104) };
260f082bae6dc (David Howells 2019-04-25 14:26:52 +0100 1105)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1106) extern void afs_fs_fetch_acl(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1107) extern void afs_fs_store_acl(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1108)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1109) /*
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1110) * fs_operation.c
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1111) */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1112) extern struct afs_operation *afs_alloc_operation(struct key *, struct afs_volume *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1113) extern int afs_put_operation(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1114) extern bool afs_begin_vnode_operation(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1115) extern void afs_wait_for_operation(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1116) extern int afs_do_sync_operation(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1117)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1118) static inline void afs_op_nomem(struct afs_operation *op)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1119) {
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1120) op->error = -ENOMEM;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1121) }
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1122)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1123) static inline void afs_op_set_vnode(struct afs_operation *op, unsigned int n,
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1124) struct afs_vnode *vnode)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1125) {
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1126) op->file[n].vnode = vnode;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1127) op->file[n].need_io_lock = true;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1128) }
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1129)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1130) static inline void afs_op_set_fid(struct afs_operation *op, unsigned int n,
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1131) const struct afs_fid *fid)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1132) {
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1133) op->file[n].fid = *fid;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1134) }
260f082bae6dc (David Howells 2019-04-25 14:26:52 +0100 1135)
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 1136) /*
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 1137) * fs_probe.c
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 1138) */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 1139) extern void afs_fileserver_probe_result(struct afs_call *);
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1140) extern void afs_fs_probe_fileserver(struct afs_net *, struct afs_server *, struct key *, bool);
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 1141) extern int afs_wait_for_fs_probes(struct afs_server_list *, unsigned long);
8409f67b6437c (David Howells 2020-04-22 00:02:46 +0100 1142) extern void afs_probe_fileserver(struct afs_net *, struct afs_server *);
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1143) extern void afs_fs_probe_dispatcher(struct work_struct *);
8409f67b6437c (David Howells 2020-04-22 00:02:46 +0100 1144) extern int afs_wait_for_one_fs_probe(struct afs_server *, bool);
5481fc6eb8a7f (David Howells 2020-06-19 23:39:36 +0100 1145) extern void afs_fs_probe_cleanup(struct afs_net *);
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 1146)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1147) /*
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1148) * inode.c
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1149) */
b6489a49f7b71 (David Howells 2020-06-15 17:36:58 +0100 1150) extern const struct afs_operation_ops afs_fetch_status_operation;
b6489a49f7b71 (David Howells 2020-06-15 17:36:58 +0100 1151)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1152) extern void afs_vnode_commit_status(struct afs_operation *, struct afs_vnode_param *);
a58823ac45896 (David Howells 2019-05-09 15:16:10 +0100 1153) extern int afs_fetch_status(struct afs_vnode *, struct key *, bool, afs_access_t *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1154) extern int afs_ilookup5_test_by_fid(struct inode *, void *);
4d673da14533b (David Howells 2018-02-06 06:26:30 +0000 1155) extern struct inode *afs_iget_pseudo_dir(struct super_block *, bool);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1156) extern struct inode *afs_iget(struct afs_operation *, struct afs_vnode_param *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1157) extern struct inode *afs_root_iget(struct super_block *, struct key *);
c925bd0ac4741 (David Howells 2019-05-09 14:31:11 +0100 1158) extern bool afs_check_validity(struct afs_vnode *);
260a980317dac (David Howells 2007-04-26 15:59:35 -0700 1159) extern int afs_validate(struct afs_vnode *, struct key *);
549c7297717c3 (Christian Brauner 2021-01-21 14:19:43 +0100 1160) extern int afs_getattr(struct user_namespace *mnt_userns, const struct path *,
549c7297717c3 (Christian Brauner 2021-01-21 14:19:43 +0100 1161) struct kstat *, u32, unsigned int);
549c7297717c3 (Christian Brauner 2021-01-21 14:19:43 +0100 1162) extern int afs_setattr(struct user_namespace *mnt_userns, struct dentry *, struct iattr *);
b57922d97fd6f (Al Viro 2010-06-07 14:34:48 -0400 1163) extern void afs_evict_inode(struct inode *);
bec5eb6141308 (wanglei 2010-08-11 09:38:04 +0100 1164) extern int afs_drop_inode(struct inode *);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1165)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1166) /*
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1167) * main.c
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1168) */
0ad53eeefcbb2 (Tejun Heo 2011-01-14 15:56:37 +0000 1169) extern struct workqueue_struct *afs_wq;
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 1170) extern int afs_net_id;
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1171)
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 1172) static inline struct afs_net *afs_net(struct net *net)
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1173) {
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 1174) return net_generic(net, afs_net_id);
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1175) }
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1176)
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 1177) static inline struct afs_net *afs_sb2net(struct super_block *sb)
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1178) {
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 1179) return afs_net(AFS_FS_S(sb)->net_ns);
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1180) }
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1181)
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 1182) static inline struct afs_net *afs_d2net(struct dentry *dentry)
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1183) {
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 1184) return afs_sb2net(dentry->d_sb);
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1185) }
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1186)
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 1187) static inline struct afs_net *afs_i2net(struct inode *inode)
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1188) {
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 1189) return afs_sb2net(inode->i_sb);
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1190) }
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1191)
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 1192) static inline struct afs_net *afs_v2net(struct afs_vnode *vnode)
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1193) {
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 1194) return afs_i2net(&vnode->vfs_inode);
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1195) }
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1196)
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 1197) static inline struct afs_net *afs_sock2net(struct sock *sk)
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1198) {
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 1199) return net_generic(sock_net(sk), afs_net_id);
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1200) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1201)
d55b4da4331ef (David Howells 2018-04-06 14:17:24 +0100 1202) static inline void __afs_stat(atomic_t *s)
d55b4da4331ef (David Howells 2018-04-06 14:17:24 +0100 1203) {
d55b4da4331ef (David Howells 2018-04-06 14:17:24 +0100 1204) atomic_inc(s);
d55b4da4331ef (David Howells 2018-04-06 14:17:24 +0100 1205) }
d55b4da4331ef (David Howells 2018-04-06 14:17:24 +0100 1206)
d55b4da4331ef (David Howells 2018-04-06 14:17:24 +0100 1207) #define afs_stat_v(vnode, n) __afs_stat(&afs_v2net(vnode)->n)
d55b4da4331ef (David Howells 2018-04-06 14:17:24 +0100 1208)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1209) /*
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1210) * misc.c
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1211) */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1212) extern int afs_abort_to_error(u32);
4584ae96ae307 (David Howells 2018-11-13 23:20:28 +0000 1213) extern void afs_prioritise_error(struct afs_error *, int, u32);
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1214)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1215) /*
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1216) * mntpt.c
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1217) */
754661f143e70 (Arjan van de Ven 2007-02-12 00:55:38 -0800 1218) extern const struct inode_operations afs_mntpt_inode_operations;
bec5eb6141308 (wanglei 2010-08-11 09:38:04 +0100 1219) extern const struct inode_operations afs_autocell_inode_operations;
4b6f5d20b04dc (Arjan van de Ven 2006-03-28 01:56:42 -0800 1220) extern const struct file_operations afs_mntpt_file_operations;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1221)
d18610b0ce9eb (David Howells 2011-01-14 19:04:05 +0000 1222) extern struct vfsmount *afs_d_automount(struct path *);
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1223) extern void afs_mntpt_kill_timer(void);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1224)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1225) /*
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1226) * proc.c
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1227) */
b6cfbecafbd2e (David Howells 2018-06-05 10:54:24 +0100 1228) #ifdef CONFIG_PROC_FS
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1229) extern int __net_init afs_proc_init(struct afs_net *);
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1230) extern void __net_exit afs_proc_cleanup(struct afs_net *);
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 1231) extern int afs_proc_cell_setup(struct afs_cell *);
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 1232) extern void afs_proc_cell_remove(struct afs_cell *);
6f8880d8e6815 (David Howells 2018-04-09 21:12:31 +0100 1233) extern void afs_put_sysnames(struct afs_sysnames *);
b6cfbecafbd2e (David Howells 2018-06-05 10:54:24 +0100 1234) #else
b6cfbecafbd2e (David Howells 2018-06-05 10:54:24 +0100 1235) static inline int afs_proc_init(struct afs_net *net) { return 0; }
b6cfbecafbd2e (David Howells 2018-06-05 10:54:24 +0100 1236) static inline void afs_proc_cleanup(struct afs_net *net) {}
b6cfbecafbd2e (David Howells 2018-06-05 10:54:24 +0100 1237) static inline int afs_proc_cell_setup(struct afs_cell *cell) { return 0; }
b6cfbecafbd2e (David Howells 2018-06-05 10:54:24 +0100 1238) static inline void afs_proc_cell_remove(struct afs_cell *cell) {}
b6cfbecafbd2e (David Howells 2018-06-05 10:54:24 +0100 1239) static inline void afs_put_sysnames(struct afs_sysnames *sysnames) {}
b6cfbecafbd2e (David Howells 2018-06-05 10:54:24 +0100 1240) #endif
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1241)
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1242) /*
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1243) * rotate.c
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1244) */
a310082f6d0af (David Howells 2020-03-20 09:32:50 +0000 1245) extern bool afs_select_fileserver(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1246) extern void afs_dump_edestaddrreq(const struct afs_operation *);
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1247)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1248) /*
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1249) * rxrpc.c
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1250) */
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1251) extern struct workqueue_struct *afs_async_calls;
8324f0bcfbfc6 (David Howells 2016-08-30 09:49:29 +0100 1252)
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1253) extern int __net_init afs_open_socket(struct afs_net *);
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1254) extern void __net_exit afs_close_socket(struct afs_net *);
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1255) extern void afs_charge_preallocation(struct work_struct *);
341f741f04bec (David Howells 2017-01-05 10:38:36 +0000 1256) extern void afs_put_call(struct afs_call *);
0b9bf3812ad1f (David Howells 2019-04-25 14:26:50 +0100 1257) extern void afs_make_call(struct afs_addr_cursor *, struct afs_call *, gfp_t);
0b9bf3812ad1f (David Howells 2019-04-25 14:26:50 +0100 1258) extern long afs_wait_for_call_to_complete(struct afs_call *, struct afs_addr_cursor *);
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1259) extern struct afs_call *afs_alloc_flat_call(struct afs_net *,
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1260) const struct afs_call_type *,
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1261) size_t, size_t);
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1262) extern void afs_flat_call_destructor(struct afs_call *);
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1263) extern void afs_send_empty_reply(struct afs_call *);
b908fe6b2d129 (David Howells 2007-04-26 15:58:17 -0700 1264) extern void afs_send_simple_reply(struct afs_call *, const void *, size_t);
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1265) extern int afs_extract_data(struct afs_call *, bool);
7126ead910aa9 (David Howells 2020-04-08 16:49:08 +0100 1266) extern int afs_protocol_error(struct afs_call *, enum afs_eproto_cause);
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1267)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1268) static inline void afs_make_op_call(struct afs_operation *op, struct afs_call *call,
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1269) gfp_t gfp)
20b8391fff56f (David Howells 2019-05-08 16:16:31 +0100 1270) {
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1271) op->call = call;
a310082f6d0af (David Howells 2020-03-20 09:32:50 +0000 1272) op->type = call->type;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1273) call->op = op;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1274) call->key = op->key;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1275) call->intr = !(op->flags & AFS_OPERATION_UNINTR);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1276) afs_make_call(&op->ac, call, gfp);
20b8391fff56f (David Howells 2019-05-08 16:16:31 +0100 1277) }
20b8391fff56f (David Howells 2019-05-08 16:16:31 +0100 1278)
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1279) static inline void afs_extract_begin(struct afs_call *call, void *buf, size_t size)
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1280) {
f105da1a798f2 (David Howells 2020-02-06 14:22:28 +0000 1281) call->iov_len = size;
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1282) call->kvec[0].iov_base = buf;
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1283) call->kvec[0].iov_len = size;
fc276122496df (David Howells 2019-11-21 09:12:17 +0000 1284) iov_iter_kvec(&call->def_iter, READ, call->kvec, 1, size);
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1285) }
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1286)
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1287) static inline void afs_extract_to_tmp(struct afs_call *call)
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1288) {
f105da1a798f2 (David Howells 2020-02-06 14:22:28 +0000 1289) call->iov_len = sizeof(call->tmp);
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1290) afs_extract_begin(call, &call->tmp, sizeof(call->tmp));
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1291) }
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1292)
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1293) static inline void afs_extract_to_tmp64(struct afs_call *call)
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1294) {
f105da1a798f2 (David Howells 2020-02-06 14:22:28 +0000 1295) call->iov_len = sizeof(call->tmp64);
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1296) afs_extract_begin(call, &call->tmp64, sizeof(call->tmp64));
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1297) }
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1298)
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1299) static inline void afs_extract_discard(struct afs_call *call, size_t size)
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1300) {
f105da1a798f2 (David Howells 2020-02-06 14:22:28 +0000 1301) call->iov_len = size;
fc276122496df (David Howells 2019-11-21 09:12:17 +0000 1302) iov_iter_discard(&call->def_iter, READ, size);
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1303) }
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1304)
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1305) static inline void afs_extract_to_buf(struct afs_call *call, size_t size)
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1306) {
f105da1a798f2 (David Howells 2020-02-06 14:22:28 +0000 1307) call->iov_len = size;
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1308) afs_extract_begin(call, call->buffer, size);
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1309) }
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1310)
d001648ec7cf8 (David Howells 2016-08-30 20:42:14 +0100 1311) static inline int afs_transfer_reply(struct afs_call *call)
372ee16386bbf (David Howells 2016-08-03 14:11:40 +0100 1312) {
12bdcf333fe13 (David Howells 2018-10-20 00:57:56 +0100 1313) return afs_extract_data(call, false);
372ee16386bbf (David Howells 2016-08-03 14:11:40 +0100 1314) }
372ee16386bbf (David Howells 2016-08-03 14:11:40 +0100 1315)
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1316) static inline bool afs_check_call_state(struct afs_call *call,
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1317) enum afs_call_state state)
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1318) {
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1319) return READ_ONCE(call->state) == state;
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1320) }
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1321)
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1322) static inline bool afs_set_call_state(struct afs_call *call,
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1323) enum afs_call_state from,
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1324) enum afs_call_state to)
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1325) {
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1326) bool ok = false;
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1327)
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1328) spin_lock_bh(&call->state_lock);
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1329) if (call->state == from) {
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1330) call->state = to;
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1331) trace_afs_call_state(call, from, to, 0, 0);
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1332) ok = true;
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1333) }
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1334) spin_unlock_bh(&call->state_lock);
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1335) return ok;
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1336) }
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1337)
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1338) static inline void afs_set_call_complete(struct afs_call *call,
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1339) int error, u32 remote_abort)
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1340) {
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1341) enum afs_call_state state;
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1342) bool ok = false;
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1343)
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1344) spin_lock_bh(&call->state_lock);
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1345) state = call->state;
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1346) if (state != AFS_CALL_COMPLETE) {
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1347) call->abort_code = remote_abort;
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1348) call->error = error;
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1349) call->state = AFS_CALL_COMPLETE;
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1350) trace_afs_call_state(call, state, AFS_CALL_COMPLETE,
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1351) error, remote_abort);
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1352) ok = true;
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1353) }
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1354) spin_unlock_bh(&call->state_lock);
dde9f095583b3 (David Howells 2020-03-13 13:46:08 +0000 1355) if (ok) {
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1356) trace_afs_call_done(call);
dde9f095583b3 (David Howells 2020-03-13 13:46:08 +0000 1357)
dde9f095583b3 (David Howells 2020-03-13 13:46:08 +0000 1358) /* Asynchronous calls have two refs to release - one from the alloc and
dde9f095583b3 (David Howells 2020-03-13 13:46:08 +0000 1359) * one queued with the work item - and we can't just deallocate the
dde9f095583b3 (David Howells 2020-03-13 13:46:08 +0000 1360) * call because the work item may be queued again.
dde9f095583b3 (David Howells 2020-03-13 13:46:08 +0000 1361) */
dde9f095583b3 (David Howells 2020-03-13 13:46:08 +0000 1362) if (call->drop_ref)
dde9f095583b3 (David Howells 2020-03-13 13:46:08 +0000 1363) afs_put_call(call);
dde9f095583b3 (David Howells 2020-03-13 13:46:08 +0000 1364) }
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1365) }
98bf40cd99fcf (David Howells 2017-11-02 15:27:53 +0000 1366)
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 1367) /*
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 1368) * security.c
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 1369) */
be080a6f43c40 (David Howells 2017-11-02 15:27:49 +0000 1370) extern void afs_put_permits(struct afs_permits *);
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 1371) extern void afs_clear_permits(struct afs_vnode *);
a58823ac45896 (David Howells 2019-05-09 15:16:10 +0100 1372) extern void afs_cache_permit(struct afs_vnode *, struct key *, unsigned int,
a58823ac45896 (David Howells 2019-05-09 15:16:10 +0100 1373) struct afs_status_cb *);
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1374) extern void afs_zap_permits(struct rcu_head *);
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 1375) extern struct key *afs_request_key(struct afs_cell *);
8b6a666a97544 (David Howells 2019-05-20 08:48:46 +0100 1376) extern struct key *afs_request_key_rcu(struct afs_cell *);
0fafdc9f888b4 (David Howells 2017-11-13 16:59:50 +0000 1377) extern int afs_check_permit(struct afs_vnode *, struct key *, afs_access_t *);
549c7297717c3 (Christian Brauner 2021-01-21 14:19:43 +0100 1378) extern int afs_permission(struct user_namespace *, struct inode *, int);
be080a6f43c40 (David Howells 2017-11-02 15:27:49 +0000 1379) extern void __exit afs_clean_up_permit_cache(void);
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 1380)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1381) /*
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1382) * server.c
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1383) */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1384) extern spinlock_t afs_server_peer_lock;
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1385)
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1386) extern struct afs_server *afs_find_server(struct afs_net *,
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1387) const struct sockaddr_rxrpc *);
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1388) extern struct afs_server *afs_find_server_by_uuid(struct afs_net *, const uuid_t *);
8100680592345 (David Howells 2020-04-16 17:05:28 +0100 1389) extern struct afs_server *afs_lookup_server(struct afs_cell *, struct key *, const uuid_t *, u32);
452181936931f (David Howells 2019-06-20 18:12:17 +0100 1390) extern struct afs_server *afs_get_server(struct afs_server *, enum afs_server_trace);
977e5f8ed0ab2 (David Howells 2020-04-17 17:31:26 +0100 1391) extern struct afs_server *afs_use_server(struct afs_server *, enum afs_server_trace);
977e5f8ed0ab2 (David Howells 2020-04-17 17:31:26 +0100 1392) extern void afs_unuse_server(struct afs_net *, struct afs_server *, enum afs_server_trace);
977e5f8ed0ab2 (David Howells 2020-04-17 17:31:26 +0100 1393) extern void afs_unuse_server_notime(struct afs_net *, struct afs_server *, enum afs_server_trace);
452181936931f (David Howells 2019-06-20 18:12:17 +0100 1394) extern void afs_put_server(struct afs_net *, struct afs_server *, enum afs_server_trace);
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1395) extern void afs_manage_servers(struct work_struct *);
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1396) extern void afs_servers_timer(struct timer_list *);
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1397) extern void afs_fs_probe_timer(struct timer_list *);
f044c8847bb61 (David Howells 2017-11-02 15:27:45 +0000 1398) extern void __net_exit afs_purge_servers(struct afs_net *);
a310082f6d0af (David Howells 2020-03-20 09:32:50 +0000 1399) extern bool afs_check_server_record(struct afs_operation *, struct afs_server *);
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1400)
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1401) static inline void afs_inc_servers_outstanding(struct afs_net *net)
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1402) {
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1403) atomic_inc(&net->servers_outstanding);
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1404) }
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1405)
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1406) static inline void afs_dec_servers_outstanding(struct afs_net *net)
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1407) {
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1408) if (atomic_dec_and_test(&net->servers_outstanding))
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1409) wake_up_var(&net->servers_outstanding);
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1410) }
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1411)
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1412) static inline bool afs_is_probing_server(struct afs_server *server)
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1413) {
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1414) return list_empty(&server->probe_link);
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1415) }
f6cbb368bcb0b (David Howells 2020-04-24 15:10:00 +0100 1416)
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 1417) /*
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1418) * server_list.c
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 1419) */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1420) static inline struct afs_server_list *afs_get_serverlist(struct afs_server_list *slist)
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1421) {
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1422) refcount_inc(&slist->usage);
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1423) return slist;
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1424) }
00d3b7a4533e3 (David Howells 2007-04-26 15:57:07 -0700 1425)
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1426) extern void afs_put_serverlist(struct afs_net *, struct afs_server_list *);
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1427) extern struct afs_server_list *afs_alloc_server_list(struct afs_cell *, struct key *,
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1428) struct afs_vldb_entry *,
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1429) u8);
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1430) extern bool afs_annotate_server_list(struct afs_server_list *, struct afs_server_list *);
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1431)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1432) /*
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1433) * super.c
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1434) */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1435) extern int __init afs_fs_init(void);
5b86d4ff5dce3 (David Howells 2018-05-18 11:46:15 +0100 1436) extern void afs_fs_exit(void);
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1437)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1438) /*
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1439) * vlclient.c
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1440) */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1441) extern struct afs_vldb_entry *afs_vl_get_entry_by_name_u(struct afs_vl_cursor *,
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1442) const char *, int);
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1443) extern struct afs_addr_list *afs_vl_get_addrs_u(struct afs_vl_cursor *, const uuid_t *);
0b9bf3812ad1f (David Howells 2019-04-25 14:26:50 +0100 1444) extern struct afs_call *afs_vl_get_capabilities(struct afs_net *, struct afs_addr_cursor *,
0b9bf3812ad1f (David Howells 2019-04-25 14:26:50 +0100 1445) struct key *, struct afs_vlserver *, unsigned int);
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1446) extern struct afs_addr_list *afs_yfsvl_get_endpoints(struct afs_vl_cursor *, const uuid_t *);
c3e9f888263bb (David Howells 2020-04-29 17:26:41 +0100 1447) extern char *afs_yfsvl_get_cell_name(struct afs_vl_cursor *);
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1448)
8a070a964877c (David Howells 2020-04-25 10:26:02 +0100 1449) /*
8a070a964877c (David Howells 2020-04-25 10:26:02 +0100 1450) * vl_alias.c
8a070a964877c (David Howells 2020-04-25 10:26:02 +0100 1451) */
8a070a964877c (David Howells 2020-04-25 10:26:02 +0100 1452) extern int afs_cell_detect_alias(struct afs_cell *, struct key *);
8a070a964877c (David Howells 2020-04-25 10:26:02 +0100 1453)
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 1454) /*
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 1455) * vl_probe.c
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 1456) */
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 1457) extern void afs_vlserver_probe_result(struct afs_call *);
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 1458) extern int afs_send_vl_probes(struct afs_net *, struct key *, struct afs_vlserver_list *);
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 1459) extern int afs_wait_for_vl_probes(struct afs_vlserver_list *, unsigned long);
3bf0fb6f33dd5 (David Howells 2018-10-20 00:57:59 +0100 1460)
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1461) /*
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1462) * vl_rotate.c
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1463) */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1464) extern bool afs_begin_vlserver_operation(struct afs_vl_cursor *,
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1465) struct afs_cell *, struct key *);
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1466) extern bool afs_select_vlserver(struct afs_vl_cursor *);
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1467) extern bool afs_select_current_vlserver(struct afs_vl_cursor *);
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1468) extern int afs_end_vlserver_operation(struct afs_vl_cursor *);
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1469)
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1470) /*
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1471) * vlserver_list.c
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1472) */
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1473) static inline struct afs_vlserver *afs_get_vlserver(struct afs_vlserver *vlserver)
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1474) {
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1475) atomic_inc(&vlserver->usage);
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1476) return vlserver;
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1477) }
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1478)
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1479) static inline struct afs_vlserver_list *afs_get_vlserverlist(struct afs_vlserver_list *vllist)
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1480) {
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1481) if (vllist)
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1482) atomic_inc(&vllist->usage);
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1483) return vllist;
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1484) }
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1485)
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1486) extern struct afs_vlserver *afs_alloc_vlserver(const char *, size_t, unsigned short);
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1487) extern void afs_put_vlserver(struct afs_net *, struct afs_vlserver *);
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1488) extern struct afs_vlserver_list *afs_alloc_vlserver_list(unsigned int);
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1489) extern void afs_put_vlserverlist(struct afs_net *, struct afs_vlserver_list *);
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1490) extern struct afs_vlserver_list *afs_extract_vlserver_list(struct afs_cell *,
0a5143f2f89cc (David Howells 2018-10-20 00:57:57 +0100 1491) const void *, size_t);
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1492)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1493) /*
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1494) * volume.c
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1495) */
13fcc6837049f (David Howells 2018-11-01 23:07:27 +0000 1496) extern struct afs_volume *afs_create_volume(struct afs_fs_context *);
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1497) extern void afs_activate_volume(struct afs_volume *);
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1498) extern void afs_deactivate_volume(struct afs_volume *);
cca37d45d5474 (David Howells 2020-04-29 17:02:04 +0100 1499) extern struct afs_volume *afs_get_volume(struct afs_volume *, enum afs_volume_trace);
cca37d45d5474 (David Howells 2020-04-29 17:02:04 +0100 1500) extern void afs_put_volume(struct afs_net *, struct afs_volume *, enum afs_volume_trace);
a310082f6d0af (David Howells 2020-03-20 09:32:50 +0000 1501) extern int afs_check_volume_status(struct afs_volume *, struct afs_operation *);
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1502)
31143d5d515ec (David Howells 2007-05-09 02:33:46 -0700 1503) /*
31143d5d515ec (David Howells 2007-05-09 02:33:46 -0700 1504) * write.c
31143d5d515ec (David Howells 2007-05-09 02:33:46 -0700 1505) */
31143d5d515ec (David Howells 2007-05-09 02:33:46 -0700 1506) extern int afs_set_page_dirty(struct page *);
15b4650e55e06 (Nicholas Piggin 2008-10-15 22:04:32 -0700 1507) extern int afs_write_begin(struct file *file, struct address_space *mapping,
15b4650e55e06 (Nicholas Piggin 2008-10-15 22:04:32 -0700 1508) loff_t pos, unsigned len, unsigned flags,
15b4650e55e06 (Nicholas Piggin 2008-10-15 22:04:32 -0700 1509) struct page **pagep, void **fsdata);
15b4650e55e06 (Nicholas Piggin 2008-10-15 22:04:32 -0700 1510) extern int afs_write_end(struct file *file, struct address_space *mapping,
15b4650e55e06 (Nicholas Piggin 2008-10-15 22:04:32 -0700 1511) loff_t pos, unsigned len, unsigned copied,
15b4650e55e06 (Nicholas Piggin 2008-10-15 22:04:32 -0700 1512) struct page *page, void *fsdata);
31143d5d515ec (David Howells 2007-05-09 02:33:46 -0700 1513) extern int afs_writepage(struct page *, struct writeback_control *);
31143d5d515ec (David Howells 2007-05-09 02:33:46 -0700 1514) extern int afs_writepages(struct address_space *, struct writeback_control *);
50b5551d1719c (Al Viro 2014-04-03 14:13:46 -0400 1515) extern ssize_t afs_file_write(struct kiocb *, struct iov_iter *);
02c24a82187d5 (Josef Bacik 2011-07-16 20:44:56 -0400 1516) extern int afs_fsync(struct file *, loff_t, loff_t, int);
0722f18620597 (Souptick Joarder 2018-08-23 17:00:48 -0700 1517) extern vm_fault_t afs_page_mkwrite(struct vm_fault *vmf);
4343d00872e1d (David Howells 2017-11-02 15:27:52 +0000 1518) extern void afs_prune_wb_keys(struct afs_vnode *);
4343d00872e1d (David Howells 2017-11-02 15:27:52 +0000 1519) extern int afs_launder_page(struct page *);
31143d5d515ec (David Howells 2007-05-09 02:33:46 -0700 1520)
d3e3b7eac886f (David Howells 2017-07-06 15:50:27 +0100 1521) /*
d3e3b7eac886f (David Howells 2017-07-06 15:50:27 +0100 1522) * xattr.c
d3e3b7eac886f (David Howells 2017-07-06 15:50:27 +0100 1523) */
d3e3b7eac886f (David Howells 2017-07-06 15:50:27 +0100 1524) extern const struct xattr_handler *afs_xattr_handlers[];
31143d5d515ec (David Howells 2007-05-09 02:33:46 -0700 1525)
30062bd13e365 (David Howells 2018-10-20 00:57:58 +0100 1526) /*
30062bd13e365 (David Howells 2018-10-20 00:57:58 +0100 1527) * yfsclient.c
30062bd13e365 (David Howells 2018-10-20 00:57:58 +0100 1528) */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1529) extern void yfs_fs_fetch_data(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1530) extern void yfs_fs_create_file(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1531) extern void yfs_fs_make_dir(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1532) extern void yfs_fs_remove_file2(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1533) extern void yfs_fs_remove_file(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1534) extern void yfs_fs_remove_dir(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1535) extern void yfs_fs_link(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1536) extern void yfs_fs_symlink(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1537) extern void yfs_fs_rename(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1538) extern void yfs_fs_store_data(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1539) extern void yfs_fs_setattr(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1540) extern void yfs_fs_get_volume_status(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1541) extern void yfs_fs_set_lock(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1542) extern void yfs_fs_extend_lock(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1543) extern void yfs_fs_release_lock(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1544) extern void yfs_fs_fetch_status(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1545) extern void yfs_fs_inline_bulk_status(struct afs_operation *);
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1546)
ae46578b963f6 (David Howells 2019-04-30 18:30:21 +0100 1547) struct yfs_acl {
ae46578b963f6 (David Howells 2019-04-30 18:30:21 +0100 1548) struct afs_acl *acl; /* Dir/file/symlink ACL */
ae46578b963f6 (David Howells 2019-04-30 18:30:21 +0100 1549) struct afs_acl *vol_acl; /* Whole volume ACL */
ae46578b963f6 (David Howells 2019-04-30 18:30:21 +0100 1550) u32 inherit_flag; /* True if ACL is inherited from parent dir */
ae46578b963f6 (David Howells 2019-04-30 18:30:21 +0100 1551) u32 num_cleaned; /* Number of ACEs removed due to subject removal */
ae46578b963f6 (David Howells 2019-04-30 18:30:21 +0100 1552) unsigned int flags;
ae46578b963f6 (David Howells 2019-04-30 18:30:21 +0100 1553) #define YFS_ACL_WANT_ACL 0x01 /* Set if caller wants ->acl */
ae46578b963f6 (David Howells 2019-04-30 18:30:21 +0100 1554) #define YFS_ACL_WANT_VOL_ACL 0x02 /* Set if caller wants ->vol_acl */
ae46578b963f6 (David Howells 2019-04-30 18:30:21 +0100 1555) };
ae46578b963f6 (David Howells 2019-04-30 18:30:21 +0100 1556)
ae46578b963f6 (David Howells 2019-04-30 18:30:21 +0100 1557) extern void yfs_free_opaque_acl(struct yfs_acl *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1558) extern void yfs_fs_fetch_opaque_acl(struct afs_operation *);
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1559) extern void yfs_fs_store_opaque_acl2(struct afs_operation *);
ae46578b963f6 (David Howells 2019-04-30 18:30:21 +0100 1560)
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1561) /*
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1562) * Miscellaneous inline functions.
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1563) */
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1564) static inline struct afs_vnode *AFS_FS_I(struct inode *inode)
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1565) {
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1566) return container_of(inode, struct afs_vnode, vfs_inode);
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1567) }
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1568)
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1569) static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode)
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1570) {
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1571) return &vnode->vfs_inode;
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1572) }
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1573)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1574) /*
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1575) * Note that a dentry got changed. We need to set d_fsdata to the data version
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1576) * number derived from the result of the operation. It doesn't matter if
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1577) * d_fsdata goes backwards as we'll just revalidate.
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1578) */
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1579) static inline void afs_update_dentry_version(struct afs_operation *op,
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1580) struct afs_vnode_param *dir_vp,
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1581) struct dentry *dentry)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1582) {
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1583) if (!op->error)
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1584) dentry->d_fsdata =
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1585) (void *)(unsigned long)dir_vp->scb.status.data_version;
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1586) }
e49c7b2f6de7f (David Howells 2020-04-10 20:51:51 +0100 1587)
b6489a49f7b71 (David Howells 2020-06-15 17:36:58 +0100 1588) /*
b6489a49f7b71 (David Howells 2020-06-15 17:36:58 +0100 1589) * Check for a conflicting operation on a directory that we just unlinked from.
b6489a49f7b71 (David Howells 2020-06-15 17:36:58 +0100 1590) * If someone managed to sneak a link or an unlink in on the file we just
b6489a49f7b71 (David Howells 2020-06-15 17:36:58 +0100 1591) * unlinked, we won't be able to trust nlink on an AFS file (but not YFS).
b6489a49f7b71 (David Howells 2020-06-15 17:36:58 +0100 1592) */
b6489a49f7b71 (David Howells 2020-06-15 17:36:58 +0100 1593) static inline void afs_check_dir_conflict(struct afs_operation *op,
b6489a49f7b71 (David Howells 2020-06-15 17:36:58 +0100 1594) struct afs_vnode_param *dvp)
b6489a49f7b71 (David Howells 2020-06-15 17:36:58 +0100 1595) {
b6489a49f7b71 (David Howells 2020-06-15 17:36:58 +0100 1596) if (dvp->dv_before + dvp->dv_delta != dvp->scb.status.data_version)
b6489a49f7b71 (David Howells 2020-06-15 17:36:58 +0100 1597) op->flags |= AFS_OPERATION_DIR_CONFLICT;
b6489a49f7b71 (David Howells 2020-06-15 17:36:58 +0100 1598) }
b6489a49f7b71 (David Howells 2020-06-15 17:36:58 +0100 1599)
f51375cd9e1ad (David Howells 2018-10-20 00:57:57 +0100 1600) static inline int afs_io_error(struct afs_call *call, enum afs_io_error where)
f51375cd9e1ad (David Howells 2018-10-20 00:57:57 +0100 1601) {
f51375cd9e1ad (David Howells 2018-10-20 00:57:57 +0100 1602) trace_afs_io_error(call->debug_id, -EIO, where);
f51375cd9e1ad (David Howells 2018-10-20 00:57:57 +0100 1603) return -EIO;
f51375cd9e1ad (David Howells 2018-10-20 00:57:57 +0100 1604) }
f51375cd9e1ad (David Howells 2018-10-20 00:57:57 +0100 1605)
f51375cd9e1ad (David Howells 2018-10-20 00:57:57 +0100 1606) static inline int afs_bad(struct afs_vnode *vnode, enum afs_file_error where)
f51375cd9e1ad (David Howells 2018-10-20 00:57:57 +0100 1607) {
f51375cd9e1ad (David Howells 2018-10-20 00:57:57 +0100 1608) trace_afs_file_error(vnode, -EIO, where);
f51375cd9e1ad (David Howells 2018-10-20 00:57:57 +0100 1609) return -EIO;
f51375cd9e1ad (David Howells 2018-10-20 00:57:57 +0100 1610) }
d2ddc776a4581 (David Howells 2017-11-02 15:27:50 +0000 1611)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1612) /*****************************************************************************/
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1613) /*
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1614) * debug tracing
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1615) */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1616) extern unsigned afs_debug;
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1617)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1618) #define dbgprintk(FMT,...) \
ad16df848d7f8 (Sven Schnelle 2008-04-03 10:44:01 +0100 1619) printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1620)
530b6412786d7 (Harvey Harrison 2008-04-30 00:55:09 -0700 1621) #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
530b6412786d7 (Harvey Harrison 2008-04-30 00:55:09 -0700 1622) #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1623) #define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1624)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1625)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1626) #if defined(__KDEBUG)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1627) #define _enter(FMT,...) kenter(FMT,##__VA_ARGS__)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1628) #define _leave(FMT,...) kleave(FMT,##__VA_ARGS__)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1629) #define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1630)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1631) #elif defined(CONFIG_AFS_DEBUG)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1632) #define AFS_DEBUG_KENTER 0x01
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1633) #define AFS_DEBUG_KLEAVE 0x02
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1634) #define AFS_DEBUG_KDEBUG 0x04
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1635)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1636) #define _enter(FMT,...) \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1637) do { \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1638) if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1639) kenter(FMT,##__VA_ARGS__); \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1640) } while (0)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1641)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1642) #define _leave(FMT,...) \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1643) do { \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1644) if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1645) kleave(FMT,##__VA_ARGS__); \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1646) } while (0)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1647)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1648) #define _debug(FMT,...) \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1649) do { \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1650) if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1651) kdebug(FMT,##__VA_ARGS__); \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1652) } while (0)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1653)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1654) #else
12fdff3fc2483 (David Howells 2010-08-12 16:54:57 +0100 1655) #define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
12fdff3fc2483 (David Howells 2010-08-12 16:54:57 +0100 1656) #define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
12fdff3fc2483 (David Howells 2010-08-12 16:54:57 +0100 1657) #define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1658) #endif
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1659)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1660) /*
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1661) * debug assertion checking
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1662) */
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1663) #if 1 // defined(__KDEBUGALL)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1664)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1665) #define ASSERT(X) \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1666) do { \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1667) if (unlikely(!(X))) { \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1668) printk(KERN_ERR "\n"); \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1669) printk(KERN_ERR "AFS: Assertion failed\n"); \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1670) BUG(); \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1671) } \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1672) } while(0)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1673)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1674) #define ASSERTCMP(X, OP, Y) \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1675) do { \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1676) if (unlikely(!((X) OP (Y)))) { \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1677) printk(KERN_ERR "\n"); \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1678) printk(KERN_ERR "AFS: Assertion failed\n"); \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1679) printk(KERN_ERR "%lu " #OP " %lu is false\n", \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1680) (unsigned long)(X), (unsigned long)(Y)); \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1681) printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1682) (unsigned long)(X), (unsigned long)(Y)); \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1683) BUG(); \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1684) } \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1685) } while(0)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1686)
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1687) #define ASSERTRANGE(L, OP1, N, OP2, H) \
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1688) do { \
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1689) if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) { \
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1690) printk(KERN_ERR "\n"); \
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1691) printk(KERN_ERR "AFS: Assertion failed\n"); \
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1692) printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n", \
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1693) (unsigned long)(L), (unsigned long)(N), \
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1694) (unsigned long)(H)); \
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1695) printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1696) (unsigned long)(L), (unsigned long)(N), \
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1697) (unsigned long)(H)); \
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1698) BUG(); \
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1699) } \
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1700) } while(0)
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1701)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1702) #define ASSERTIF(C, X) \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1703) do { \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1704) if (unlikely((C) && !(X))) { \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1705) printk(KERN_ERR "\n"); \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1706) printk(KERN_ERR "AFS: Assertion failed\n"); \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1707) BUG(); \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1708) } \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1709) } while(0)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1710)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1711) #define ASSERTIFCMP(C, X, OP, Y) \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1712) do { \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1713) if (unlikely((C) && !((X) OP (Y)))) { \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1714) printk(KERN_ERR "\n"); \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1715) printk(KERN_ERR "AFS: Assertion failed\n"); \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1716) printk(KERN_ERR "%lu " #OP " %lu is false\n", \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1717) (unsigned long)(X), (unsigned long)(Y)); \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1718) printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1719) (unsigned long)(X), (unsigned long)(Y)); \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1720) BUG(); \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1721) } \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1722) } while(0)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1723)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1724) #else
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1725)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1726) #define ASSERT(X) \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1727) do { \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1728) } while(0)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1729)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1730) #define ASSERTCMP(X, OP, Y) \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1731) do { \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1732) } while(0)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1733)
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1734) #define ASSERTRANGE(L, OP1, N, OP2, H) \
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1735) do { \
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1736) } while(0)
416351f28d2b3 (David Howells 2007-05-09 02:33:45 -0700 1737)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1738) #define ASSERTIF(C, X) \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1739) do { \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1740) } while(0)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1741)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1742) #define ASSERTIFCMP(C, X, OP, Y) \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1743) do { \
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1744) } while(0)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1745)
08e0e7c82eead (David Howells 2007-04-26 15:55:03 -0700 1746) #endif /* __KDEBUGALL */