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