xref: /openbmc/linux/fs/afs/internal.h (revision 97e3043a)
1ec26815aSDavid Howells /* internal AFS stuff
21da177e4SLinus Torvalds  *
308e0e7c8SDavid Howells  * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
41da177e4SLinus Torvalds  * Written by David Howells (dhowells@redhat.com)
51da177e4SLinus Torvalds  *
61da177e4SLinus Torvalds  * This program is free software; you can redistribute it and/or
71da177e4SLinus Torvalds  * modify it under the terms of the GNU General Public License
81da177e4SLinus Torvalds  * as published by the Free Software Foundation; either version
91da177e4SLinus Torvalds  * 2 of the License, or (at your option) any later version.
101da177e4SLinus Torvalds  */
111da177e4SLinus Torvalds 
121da177e4SLinus Torvalds #include <linux/compiler.h>
131da177e4SLinus Torvalds #include <linux/kernel.h>
148a79790bSTina Ruchandani #include <linux/ktime.h>
151da177e4SLinus Torvalds #include <linux/fs.h>
161da177e4SLinus Torvalds #include <linux/pagemap.h>
1708e0e7c8SDavid Howells #include <linux/rxrpc.h>
1800d3b7a4SDavid Howells #include <linux/key.h>
19e8edc6e0SAlexey Dobriyan #include <linux/workqueue.h>
2000c541eaSAndrew Morton #include <linux/sched.h>
2180e50be4SChristoph Hellwig #include <linux/fscache.h>
22e1da0222SJens Axboe #include <linux/backing-dev.h>
23ff548773SDavid Howells #include <linux/uuid.h>
24f044c884SDavid Howells #include <net/net_namespace.h>
258324f0bcSDavid Howells #include <net/af_rxrpc.h>
2600c541eaSAndrew Morton 
2708e0e7c8SDavid Howells #include "afs.h"
2808e0e7c8SDavid Howells #include "afs_vl.h"
2908e0e7c8SDavid Howells 
3008e0e7c8SDavid Howells #define AFS_CELL_MAX_ADDRS 15
3108e0e7c8SDavid Howells 
3231143d5dSDavid Howells struct pagevec;
3308e0e7c8SDavid Howells struct afs_call;
3408e0e7c8SDavid Howells 
3508e0e7c8SDavid Howells typedef enum {
3608e0e7c8SDavid Howells 	AFS_VL_NEW,			/* new, uninitialised record */
3708e0e7c8SDavid Howells 	AFS_VL_CREATING,		/* creating record */
3808e0e7c8SDavid Howells 	AFS_VL_VALID,			/* record is pending */
3908e0e7c8SDavid Howells 	AFS_VL_NO_VOLUME,		/* no such volume available */
4008e0e7c8SDavid Howells 	AFS_VL_UPDATING,		/* update in progress */
4108e0e7c8SDavid Howells 	AFS_VL_VOLUME_DELETED,		/* volume was deleted */
4208e0e7c8SDavid Howells 	AFS_VL_UNCERTAIN,		/* uncertain state (update failed) */
4308e0e7c8SDavid Howells } __attribute__((packed)) afs_vlocation_state_t;
441da177e4SLinus Torvalds 
4500d3b7a4SDavid Howells struct afs_mount_params {
4600d3b7a4SDavid Howells 	bool			rwpath;		/* T if the parent should be considered R/W */
4700d3b7a4SDavid Howells 	bool			force;		/* T to force cell type */
48bec5eb61Swanglei 	bool			autocell;	/* T if set auto mount operation */
4900d3b7a4SDavid Howells 	afs_voltype_t		type;		/* type of volume requested */
5000d3b7a4SDavid Howells 	int			volnamesz;	/* size of volume name */
5100d3b7a4SDavid Howells 	const char		*volname;	/* name of volume to mount */
52f044c884SDavid Howells 	struct afs_net		*net;		/* Network namespace in effect */
5300d3b7a4SDavid Howells 	struct afs_cell		*cell;		/* cell in which to find volume */
5400d3b7a4SDavid Howells 	struct afs_volume	*volume;	/* volume record */
5500d3b7a4SDavid Howells 	struct key		*key;		/* key to use for secure mounting */
5600d3b7a4SDavid Howells };
5700d3b7a4SDavid Howells 
588e8d7f13SDavid Howells enum afs_call_state {
598e8d7f13SDavid Howells 	AFS_CALL_REQUESTING,	/* request is being sent for outgoing call */
608e8d7f13SDavid Howells 	AFS_CALL_AWAIT_REPLY,	/* awaiting reply to outgoing call */
618e8d7f13SDavid Howells 	AFS_CALL_AWAIT_OP_ID,	/* awaiting op ID on incoming call */
628e8d7f13SDavid Howells 	AFS_CALL_AWAIT_REQUEST,	/* awaiting request data on incoming call */
638e8d7f13SDavid Howells 	AFS_CALL_REPLYING,	/* replying to incoming call */
648e8d7f13SDavid Howells 	AFS_CALL_AWAIT_ACK,	/* awaiting final ACK of incoming call */
658e8d7f13SDavid Howells 	AFS_CALL_COMPLETE,	/* Completed or failed */
668e8d7f13SDavid Howells };
67f044c884SDavid Howells 
6808e0e7c8SDavid Howells /*
6908e0e7c8SDavid Howells  * a record of an in-progress RxRPC call
7008e0e7c8SDavid Howells  */
7108e0e7c8SDavid Howells struct afs_call {
7208e0e7c8SDavid Howells 	const struct afs_call_type *type;	/* type of call */
7308e0e7c8SDavid Howells 	wait_queue_head_t	waitq;		/* processes awaiting completion */
74341f741fSDavid Howells 	struct work_struct	async_work;	/* async I/O processor */
7508e0e7c8SDavid Howells 	struct work_struct	work;		/* actual work processor */
7608e0e7c8SDavid Howells 	struct rxrpc_call	*rxcall;	/* RxRPC call handle */
7708e0e7c8SDavid Howells 	struct key		*key;		/* security for this call */
78f044c884SDavid Howells 	struct afs_net		*net;		/* The network namespace */
7908e0e7c8SDavid Howells 	struct afs_server	*server;	/* server affected by incoming CM call */
8008e0e7c8SDavid Howells 	void			*request;	/* request data (first part) */
8131143d5dSDavid Howells 	struct address_space	*mapping;	/* page set */
8231143d5dSDavid Howells 	struct afs_writeback	*wb;		/* writeback being performed */
8308e0e7c8SDavid Howells 	void			*buffer;	/* reply receive buffer */
8497e3043aSDavid Howells 	void			*reply[4];	/* Where to put the reply */
8531143d5dSDavid Howells 	pgoff_t			first;		/* first page in mapping to deal with */
8631143d5dSDavid Howells 	pgoff_t			last;		/* last page in mapping to deal with */
87d001648eSDavid Howells 	size_t			offset;		/* offset into received data store */
88341f741fSDavid Howells 	atomic_t		usage;
898e8d7f13SDavid Howells 	enum afs_call_state	state;
9008e0e7c8SDavid Howells 	int			error;		/* error code */
91d001648eSDavid Howells 	u32			abort_code;	/* Remote abort ID or 0 */
9208e0e7c8SDavid Howells 	unsigned		request_size;	/* size of request data */
9308e0e7c8SDavid Howells 	unsigned		reply_max;	/* maximum size of reply */
9431143d5dSDavid Howells 	unsigned		first_offset;	/* offset into mapping[first] */
95bcd89270SMarc Dionne 	union {
9631143d5dSDavid Howells 		unsigned	last_to;	/* amount of mapping[last] */
97bcd89270SMarc Dionne 		unsigned	count2;		/* count used in unmarshalling */
98bcd89270SMarc Dionne 	};
9908e0e7c8SDavid Howells 	unsigned char		unmarshall;	/* unmarshalling phase */
10008e0e7c8SDavid Howells 	bool			incoming;	/* T if incoming call */
10131143d5dSDavid Howells 	bool			send_pages;	/* T if data from mapping should be sent */
102d001648eSDavid Howells 	bool			need_attention;	/* T if RxRPC poked us */
10356ff9c83SDavid Howells 	bool			async;		/* T if asynchronous */
104a68f4a27SDavid Howells 	bool			upgrade;	/* T to request service upgrade */
10508e0e7c8SDavid Howells 	u16			service_id;	/* RxRPC service ID to call */
10650a2c953SDavid Howells 	u32			operation_ID;	/* operation ID for an incoming call */
10708e0e7c8SDavid Howells 	u32			count;		/* count for use in unmarshalling */
10808e0e7c8SDavid Howells 	__be32			tmp;		/* place to extract temporary data */
10931143d5dSDavid Howells 	afs_dataversion_t	store_version;	/* updated version expected from store */
11008e0e7c8SDavid Howells };
11108e0e7c8SDavid Howells 
11208e0e7c8SDavid Howells struct afs_call_type {
11300d3b7a4SDavid Howells 	const char *name;
11400d3b7a4SDavid Howells 
11508e0e7c8SDavid Howells 	/* deliver request or reply data to an call
11608e0e7c8SDavid Howells 	 * - returning an error will cause the call to be aborted
11708e0e7c8SDavid Howells 	 */
118d001648eSDavid Howells 	int (*deliver)(struct afs_call *call);
11908e0e7c8SDavid Howells 
12008e0e7c8SDavid Howells 	/* clean up a call */
12108e0e7c8SDavid Howells 	void (*destructor)(struct afs_call *call);
122341f741fSDavid Howells 
123341f741fSDavid Howells 	/* Work function */
124341f741fSDavid Howells 	void (*work)(struct work_struct *work);
12508e0e7c8SDavid Howells };
12608e0e7c8SDavid Howells 
12708e0e7c8SDavid Howells /*
128196ee9cdSDavid Howells  * Record of an outstanding read operation on a vnode.
129196ee9cdSDavid Howells  */
130196ee9cdSDavid Howells struct afs_read {
131196ee9cdSDavid Howells 	loff_t			pos;		/* Where to start reading */
132e8e581a8SDavid Howells 	loff_t			len;		/* How much we're asking for */
133196ee9cdSDavid Howells 	loff_t			actual_len;	/* How much we're actually getting */
1346a0e3999SDavid Howells 	loff_t			remain;		/* Amount remaining */
135196ee9cdSDavid Howells 	atomic_t		usage;
136196ee9cdSDavid Howells 	unsigned int		index;		/* Which page we're reading into */
137196ee9cdSDavid Howells 	unsigned int		nr_pages;
138196ee9cdSDavid Howells 	void (*page_done)(struct afs_call *, struct afs_read *);
139196ee9cdSDavid Howells 	struct page		*pages[];
140196ee9cdSDavid Howells };
141196ee9cdSDavid Howells 
142196ee9cdSDavid Howells /*
14331143d5dSDavid Howells  * record of an outstanding writeback on a vnode
14431143d5dSDavid Howells  */
14531143d5dSDavid Howells struct afs_writeback {
14631143d5dSDavid Howells 	struct list_head	link;		/* link in vnode->writebacks */
14731143d5dSDavid Howells 	struct work_struct	writer;		/* work item to perform the writeback */
14831143d5dSDavid Howells 	struct afs_vnode	*vnode;		/* vnode to which this write applies */
14931143d5dSDavid Howells 	struct key		*key;		/* owner of this write */
15031143d5dSDavid Howells 	wait_queue_head_t	waitq;		/* completion and ready wait queue */
15131143d5dSDavid Howells 	pgoff_t			first;		/* first page in batch */
15231143d5dSDavid Howells 	pgoff_t			point;		/* last page in current store op */
15331143d5dSDavid Howells 	pgoff_t			last;		/* last page in batch (inclusive) */
15431143d5dSDavid Howells 	unsigned		offset_first;	/* offset into first page of start of write */
15531143d5dSDavid Howells 	unsigned		to_last;	/* offset into last page of end of write */
15631143d5dSDavid Howells 	int			num_conflicts;	/* count of conflicting writes in list */
15731143d5dSDavid Howells 	int			usage;
15831143d5dSDavid Howells 	bool			conflicts;	/* T if has dependent conflicts */
15931143d5dSDavid Howells 	enum {
16031143d5dSDavid Howells 		AFS_WBACK_SYNCING,		/* synchronisation being performed */
16131143d5dSDavid Howells 		AFS_WBACK_PENDING,		/* write pending */
16231143d5dSDavid Howells 		AFS_WBACK_CONFLICTING,		/* conflicting writes posted */
16331143d5dSDavid Howells 		AFS_WBACK_WRITING,		/* writing back */
16431143d5dSDavid Howells 		AFS_WBACK_COMPLETE		/* the writeback record has been unlinked */
16531143d5dSDavid Howells 	} state __attribute__((packed));
16631143d5dSDavid Howells };
16731143d5dSDavid Howells 
16831143d5dSDavid Howells /*
16908e0e7c8SDavid Howells  * AFS superblock private data
17008e0e7c8SDavid Howells  * - there's one superblock per volume
17108e0e7c8SDavid Howells  */
17208e0e7c8SDavid Howells struct afs_super_info {
173f044c884SDavid Howells 	struct afs_net		*net;		/* Network namespace */
17449566f6fSDavid Howells 	struct afs_cell		*cell;		/* The cell in which the volume resides */
17508e0e7c8SDavid Howells 	struct afs_volume	*volume;	/* volume record */
17608e0e7c8SDavid Howells 	char			rwparent;	/* T if parent is R/W AFS volume */
17708e0e7c8SDavid Howells };
17808e0e7c8SDavid Howells 
17908e0e7c8SDavid Howells static inline struct afs_super_info *AFS_FS_S(struct super_block *sb)
18008e0e7c8SDavid Howells {
18108e0e7c8SDavid Howells 	return sb->s_fs_info;
18208e0e7c8SDavid Howells }
18308e0e7c8SDavid Howells 
18408e0e7c8SDavid Howells extern struct file_system_type afs_fs_type;
18508e0e7c8SDavid Howells 
18608e0e7c8SDavid Howells /*
187f044c884SDavid Howells  * AFS network namespace record.
188f044c884SDavid Howells  */
189f044c884SDavid Howells struct afs_net {
190f044c884SDavid Howells 	struct afs_uuid		uuid;
191f044c884SDavid Howells 	bool			live;		/* F if this namespace is being removed */
192f044c884SDavid Howells 
193f044c884SDavid Howells 	/* AF_RXRPC I/O stuff */
194f044c884SDavid Howells 	struct socket		*socket;
195f044c884SDavid Howells 	struct afs_call		*spare_incoming_call;
196f044c884SDavid Howells 	struct work_struct	charge_preallocation_work;
197f044c884SDavid Howells 	struct mutex		socket_mutex;
198f044c884SDavid Howells 	atomic_t		nr_outstanding_calls;
199f044c884SDavid Howells 	atomic_t		nr_superblocks;
200f044c884SDavid Howells 
201f044c884SDavid Howells 	/* Cell database */
202f044c884SDavid Howells 	struct list_head	cells;
203f044c884SDavid Howells 	struct afs_cell		*ws_cell;
204f044c884SDavid Howells 	rwlock_t		cells_lock;
205f044c884SDavid Howells 	struct rw_semaphore	cells_sem;
206f044c884SDavid Howells 	wait_queue_head_t	cells_freeable_wq;
207f044c884SDavid Howells 
208f044c884SDavid Howells 	struct rw_semaphore	proc_cells_sem;
209f044c884SDavid Howells 	struct list_head	proc_cells;
210f044c884SDavid Howells 
211f044c884SDavid Howells 	/* Volume location database */
212f044c884SDavid Howells 	struct list_head	vl_updates;		/* VL records in need-update order */
213f044c884SDavid Howells 	struct list_head	vl_graveyard;		/* Inactive VL records */
214f044c884SDavid Howells 	struct delayed_work	vl_reaper;
215f044c884SDavid Howells 	struct delayed_work	vl_updater;
216f044c884SDavid Howells 	spinlock_t		vl_updates_lock;
217f044c884SDavid Howells 	spinlock_t		vl_graveyard_lock;
218f044c884SDavid Howells 
219f044c884SDavid Howells 	/* File locking renewal management */
220f044c884SDavid Howells 	struct mutex		lock_manager_mutex;
221f044c884SDavid Howells 
222f044c884SDavid Howells 	/* Server database */
223f044c884SDavid Howells 	struct rb_root		servers;		/* Active servers */
224f044c884SDavid Howells 	rwlock_t		servers_lock;
225f044c884SDavid Howells 	struct list_head	server_graveyard;	/* Inactive server LRU list */
226f044c884SDavid Howells 	spinlock_t		server_graveyard_lock;
22759fa1c4aSDavid Howells 	struct timer_list	server_timer;
22859fa1c4aSDavid Howells 	struct work_struct	server_reaper;
22959fa1c4aSDavid Howells 	atomic_t		servers_outstanding;
230f044c884SDavid Howells 
231f044c884SDavid Howells 	/* Misc */
232f044c884SDavid Howells 	struct proc_dir_entry	*proc_afs;		/* /proc/net/afs directory */
233f044c884SDavid Howells };
234f044c884SDavid Howells 
235f044c884SDavid Howells extern struct afs_net __afs_net;// Dummy AFS network namespace; TODO: replace with real netns
236f044c884SDavid Howells 
237f044c884SDavid Howells /*
23808e0e7c8SDavid Howells  * AFS cell record
23908e0e7c8SDavid Howells  */
24008e0e7c8SDavid Howells struct afs_cell {
24108e0e7c8SDavid Howells 	atomic_t		usage;
24208e0e7c8SDavid Howells 	struct list_head	link;		/* main cell list link */
243f044c884SDavid Howells 	struct afs_net		*net;		/* The network namespace */
24400d3b7a4SDavid Howells 	struct key		*anonymous_key;	/* anonymous user key for this cell */
24508e0e7c8SDavid Howells 	struct list_head	proc_link;	/* /proc cell list link */
2469b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE
2479b3f26c9SDavid Howells 	struct fscache_cookie	*cache;		/* caching cookie */
2481da177e4SLinus Torvalds #endif
2491da177e4SLinus Torvalds 
25008e0e7c8SDavid Howells 	/* server record management */
25108e0e7c8SDavid Howells 	rwlock_t		servers_lock;	/* active server list lock */
25208e0e7c8SDavid Howells 	struct list_head	servers;	/* active server list */
2531da177e4SLinus Torvalds 
25408e0e7c8SDavid Howells 	/* volume location record management */
25508e0e7c8SDavid Howells 	struct rw_semaphore	vl_sem;		/* volume management serialisation semaphore */
25608e0e7c8SDavid Howells 	struct list_head	vl_list;	/* cell's active VL record list */
25708e0e7c8SDavid Howells 	spinlock_t		vl_lock;	/* vl_list lock */
25808e0e7c8SDavid Howells 	unsigned short		vl_naddrs;	/* number of VL servers in addr list */
25908e0e7c8SDavid Howells 	unsigned short		vl_curr_svix;	/* current server index */
2604d9df986SDavid Howells 	struct sockaddr_rxrpc	vl_addrs[AFS_CELL_MAX_ADDRS];	/* cell VL server addresses */
26108e0e7c8SDavid Howells 
26208e0e7c8SDavid Howells 	char			name[0];	/* cell name - must go last */
26308e0e7c8SDavid Howells };
26408e0e7c8SDavid Howells 
26508e0e7c8SDavid Howells /*
26608e0e7c8SDavid Howells  * entry in the cached volume location catalogue
26708e0e7c8SDavid Howells  */
26808e0e7c8SDavid Howells struct afs_cache_vlocation {
26900d3b7a4SDavid Howells 	/* volume name (lowercase, padded with NULs) */
27000d3b7a4SDavid Howells 	uint8_t			name[AFS_MAXVOLNAME + 1];
27100d3b7a4SDavid Howells 
27208e0e7c8SDavid Howells 	uint8_t			nservers;	/* number of entries used in servers[] */
27308e0e7c8SDavid Howells 	uint8_t			vidmask;	/* voltype mask for vid[] */
27408e0e7c8SDavid Howells 	uint8_t			srvtmask[8];	/* voltype masks for servers[] */
27508e0e7c8SDavid Howells #define AFS_VOL_VTM_RW	0x01 /* R/W version of the volume is available (on this server) */
27608e0e7c8SDavid Howells #define AFS_VOL_VTM_RO	0x02 /* R/O version of the volume is available (on this server) */
27708e0e7c8SDavid Howells #define AFS_VOL_VTM_BAK	0x04 /* backup version of the volume is available (on this server) */
27808e0e7c8SDavid Howells 
27908e0e7c8SDavid Howells 	afs_volid_t		vid[3];		/* volume IDs for R/W, R/O and Bak volumes */
2804d9df986SDavid Howells 	struct sockaddr_rxrpc	servers[8];	/* fileserver addresses */
28108e0e7c8SDavid Howells 	time_t			rtime;		/* last retrieval time */
28208e0e7c8SDavid Howells };
28308e0e7c8SDavid Howells 
28408e0e7c8SDavid Howells /*
28508e0e7c8SDavid Howells  * AFS volume location record
28608e0e7c8SDavid Howells  */
28708e0e7c8SDavid Howells struct afs_vlocation {
28808e0e7c8SDavid Howells 	atomic_t		usage;
2898a79790bSTina Ruchandani 	time64_t		time_of_death;	/* time at which put reduced usage to 0 */
29008e0e7c8SDavid Howells 	struct list_head	link;		/* link in cell volume location list */
29108e0e7c8SDavid Howells 	struct list_head	grave;		/* link in master graveyard list */
29208e0e7c8SDavid Howells 	struct list_head	update;		/* link in master update list */
29308e0e7c8SDavid Howells 	struct afs_cell		*cell;		/* cell to which volume belongs */
29408e0e7c8SDavid Howells 	struct afs_cache_vlocation vldb;	/* volume information DB record */
29508e0e7c8SDavid Howells 	struct afs_volume	*vols[3];	/* volume access record pointer (index by type) */
29608e0e7c8SDavid Howells 	wait_queue_head_t	waitq;		/* status change waitqueue */
2978a79790bSTina Ruchandani 	time64_t		update_at;	/* time at which record should be updated */
29839bf0949SDavid S. Miller 	spinlock_t		lock;		/* access lock */
29908e0e7c8SDavid Howells 	afs_vlocation_state_t	state;		/* volume location state */
30008e0e7c8SDavid Howells 	unsigned short		upd_rej_cnt;	/* ENOMEDIUM count during update */
30108e0e7c8SDavid Howells 	unsigned short		upd_busy_cnt;	/* EBUSY count during update */
30208e0e7c8SDavid Howells 	bool			valid;		/* T if valid */
30308e0e7c8SDavid Howells };
30408e0e7c8SDavid Howells 
30508e0e7c8SDavid Howells /*
30608e0e7c8SDavid Howells  * AFS fileserver record
30708e0e7c8SDavid Howells  */
30808e0e7c8SDavid Howells struct afs_server {
30908e0e7c8SDavid Howells 	atomic_t		usage;
3108a79790bSTina Ruchandani 	time64_t		time_of_death;	/* time at which put reduced usage to 0 */
3114d9df986SDavid Howells 	struct sockaddr_rxrpc	addr;		/* server address */
3129ed900b1SDavid Howells 	struct afs_net		*net;		/* Network namespace in which the server resides */
31308e0e7c8SDavid Howells 	struct afs_cell		*cell;		/* cell in which server resides */
31408e0e7c8SDavid Howells 	struct list_head	link;		/* link in cell's server list */
31508e0e7c8SDavid Howells 	struct list_head	grave;		/* link in master graveyard list */
31608e0e7c8SDavid Howells 	struct rb_node		master_rb;	/* link in master by-addr tree */
31708e0e7c8SDavid Howells 	struct rw_semaphore	sem;		/* access lock */
31808e0e7c8SDavid Howells 
31908e0e7c8SDavid Howells 	/* file service access */
32008e0e7c8SDavid Howells 	struct rb_root		fs_vnodes;	/* vnodes backed by this server (ordered by FID) */
32108e0e7c8SDavid Howells 	unsigned long		fs_act_jif;	/* time at which last activity occurred */
32208e0e7c8SDavid Howells 	unsigned long		fs_dead_jif;	/* time at which no longer to be considered dead */
32308e0e7c8SDavid Howells 	spinlock_t		fs_lock;	/* access lock */
32408e0e7c8SDavid Howells 	int			fs_state;      	/* 0 or reason FS currently marked dead (-errno) */
32508e0e7c8SDavid Howells 
32608e0e7c8SDavid Howells 	/* callback promise management */
32708e0e7c8SDavid Howells 	struct rb_root		cb_promises;	/* vnode expiration list (ordered earliest first) */
32808e0e7c8SDavid Howells 	struct delayed_work	cb_updater;	/* callback updater */
32908e0e7c8SDavid Howells 	struct delayed_work	cb_break_work;	/* collected break dispatcher */
33008e0e7c8SDavid Howells 	wait_queue_head_t	cb_break_waitq;	/* space available in cb_break waitqueue */
33108e0e7c8SDavid Howells 	spinlock_t		cb_lock;	/* access lock */
33208e0e7c8SDavid Howells 	struct afs_callback	cb_break[64];	/* ring of callbacks awaiting breaking */
33308e0e7c8SDavid Howells 	atomic_t		cb_break_n;	/* number of pending breaks */
33408e0e7c8SDavid Howells 	u8			cb_break_head;	/* head of callback breaking ring */
33508e0e7c8SDavid Howells 	u8			cb_break_tail;	/* tail of callback breaking ring */
33608e0e7c8SDavid Howells };
33708e0e7c8SDavid Howells 
33808e0e7c8SDavid Howells /*
33908e0e7c8SDavid Howells  * AFS volume access record
34008e0e7c8SDavid Howells  */
34108e0e7c8SDavid Howells struct afs_volume {
34208e0e7c8SDavid Howells 	atomic_t		usage;
34308e0e7c8SDavid Howells 	struct afs_cell		*cell;		/* cell to which belongs (unrefd ptr) */
34408e0e7c8SDavid Howells 	struct afs_vlocation	*vlocation;	/* volume location */
3459b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE
3469b3f26c9SDavid Howells 	struct fscache_cookie	*cache;		/* caching cookie */
34708e0e7c8SDavid Howells #endif
34808e0e7c8SDavid Howells 	afs_volid_t		vid;		/* volume ID */
34908e0e7c8SDavid Howells 	afs_voltype_t		type;		/* type of volume */
35008e0e7c8SDavid Howells 	char			type_force;	/* force volume type (suppress R/O -> R/W) */
35108e0e7c8SDavid Howells 	unsigned short		nservers;	/* number of server slots filled */
35208e0e7c8SDavid Howells 	unsigned short		rjservers;	/* number of servers discarded due to -ENOMEDIUM */
35308e0e7c8SDavid Howells 	struct afs_server	*servers[8];	/* servers on which volume resides (ordered) */
35408e0e7c8SDavid Howells 	struct rw_semaphore	server_sem;	/* lock for accessing current server */
35508e0e7c8SDavid Howells };
35608e0e7c8SDavid Howells 
35708e0e7c8SDavid Howells /*
35808e0e7c8SDavid Howells  * vnode catalogue entry
35908e0e7c8SDavid Howells  */
36008e0e7c8SDavid Howells struct afs_cache_vnode {
36108e0e7c8SDavid Howells 	afs_vnodeid_t		vnode_id;	/* vnode ID */
36208e0e7c8SDavid Howells 	unsigned		vnode_unique;	/* vnode ID uniquifier */
36308e0e7c8SDavid Howells 	afs_dataversion_t	data_version;	/* data version */
36408e0e7c8SDavid Howells };
36508e0e7c8SDavid Howells 
36608e0e7c8SDavid Howells /*
36708e0e7c8SDavid Howells  * AFS inode private data
36808e0e7c8SDavid Howells  */
36908e0e7c8SDavid Howells struct afs_vnode {
37008e0e7c8SDavid Howells 	struct inode		vfs_inode;	/* the VFS's inode record */
37108e0e7c8SDavid Howells 
37208e0e7c8SDavid Howells 	struct afs_volume	*volume;	/* volume on which vnode resides */
37308e0e7c8SDavid Howells 	struct afs_server	*server;	/* server currently supplying this file */
37408e0e7c8SDavid Howells 	struct afs_fid		fid;		/* the file identifier for this inode */
37508e0e7c8SDavid Howells 	struct afs_file_status	status;		/* AFS status info for this file */
3769b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE
3779b3f26c9SDavid Howells 	struct fscache_cookie	*cache;		/* caching cookie */
37808e0e7c8SDavid Howells #endif
37900d3b7a4SDavid Howells 	struct afs_permits	*permits;	/* cache of permits so far obtained */
38000d3b7a4SDavid Howells 	struct mutex		permits_lock;	/* lock for altering permits list */
381260a9803SDavid Howells 	struct mutex		validate_lock;	/* lock for validating this vnode */
38208e0e7c8SDavid Howells 	wait_queue_head_t	update_waitq;	/* status fetch waitqueue */
383260a9803SDavid Howells 	int			update_cnt;	/* number of outstanding ops that will update the
38408e0e7c8SDavid Howells 						 * status */
38531143d5dSDavid Howells 	spinlock_t		writeback_lock;	/* lock for writebacks */
38608e0e7c8SDavid Howells 	spinlock_t		lock;		/* waitqueue/flags lock */
38708e0e7c8SDavid Howells 	unsigned long		flags;
38808e0e7c8SDavid Howells #define AFS_VNODE_CB_BROKEN	0		/* set if vnode's callback was broken */
389260a9803SDavid Howells #define AFS_VNODE_UNSET		1		/* set if vnode attributes not yet set */
39008e0e7c8SDavid Howells #define AFS_VNODE_MODIFIED	2		/* set if vnode's data modified */
39108e0e7c8SDavid Howells #define AFS_VNODE_ZAP_DATA	3		/* set if vnode's data should be invalidated */
39208e0e7c8SDavid Howells #define AFS_VNODE_DELETED	4		/* set if vnode deleted on server */
39308e0e7c8SDavid Howells #define AFS_VNODE_MOUNTPOINT	5		/* set if vnode is a mountpoint symlink */
394e8d6c554SDavid Howells #define AFS_VNODE_LOCKING	6		/* set if waiting for lock on vnode */
395e8d6c554SDavid Howells #define AFS_VNODE_READLOCKED	7		/* set if vnode is read-locked on the server */
396e8d6c554SDavid Howells #define AFS_VNODE_WRITELOCKED	8		/* set if vnode is write-locked on the server */
397e8d6c554SDavid Howells #define AFS_VNODE_UNLOCKING	9		/* set if vnode is being unlocked on the server */
398bec5eb61Swanglei #define AFS_VNODE_AUTOCELL	10		/* set if Vnode is an auto mount point */
399bec5eb61Swanglei #define AFS_VNODE_PSEUDODIR	11		/* set if Vnode is a pseudo directory */
40008e0e7c8SDavid Howells 
40100d3b7a4SDavid Howells 	long			acl_order;	/* ACL check count (callback break count) */
40200d3b7a4SDavid Howells 
40331143d5dSDavid Howells 	struct list_head	writebacks;	/* alterations in pagecache that need writing */
404e8d6c554SDavid Howells 	struct list_head	pending_locks;	/* locks waiting to be granted */
405e8d6c554SDavid Howells 	struct list_head	granted_locks;	/* locks granted on this file */
406e8d6c554SDavid Howells 	struct delayed_work	lock_work;	/* work to be done in locking */
407e8d6c554SDavid Howells 	struct key		*unlock_key;	/* key to be used in unlocking */
40831143d5dSDavid Howells 
40908e0e7c8SDavid Howells 	/* outstanding callback notification on this file */
41008e0e7c8SDavid Howells 	struct rb_node		server_rb;	/* link in server->fs_vnodes */
41108e0e7c8SDavid Howells 	struct rb_node		cb_promise;	/* link in server->cb_promises */
41208e0e7c8SDavid Howells 	struct work_struct	cb_broken_work;	/* work to be done on callback break */
41356e71431STina Ruchandani 	time64_t		cb_expires;	/* time at which callback expires */
41456e71431STina Ruchandani 	time64_t		cb_expires_at;	/* time used to order cb_promise */
41508e0e7c8SDavid Howells 	unsigned		cb_version;	/* callback version */
41608e0e7c8SDavid Howells 	unsigned		cb_expiry;	/* callback expiry time */
41708e0e7c8SDavid Howells 	afs_callback_type_t	cb_type;	/* type of callback */
41808e0e7c8SDavid Howells 	bool			cb_promised;	/* true if promise still holds */
41908e0e7c8SDavid Howells };
42008e0e7c8SDavid Howells 
42100d3b7a4SDavid Howells /*
42200d3b7a4SDavid Howells  * cached security record for one user's attempt to access a vnode
42300d3b7a4SDavid Howells  */
42400d3b7a4SDavid Howells struct afs_permit {
42500d3b7a4SDavid Howells 	struct key		*key;		/* RxRPC ticket holding a security context */
42600d3b7a4SDavid Howells 	afs_access_t		access_mask;	/* access mask for this key */
42700d3b7a4SDavid Howells };
42800d3b7a4SDavid Howells 
42900d3b7a4SDavid Howells /*
43000d3b7a4SDavid Howells  * cache of security records from attempts to access a vnode
43100d3b7a4SDavid Howells  */
43200d3b7a4SDavid Howells struct afs_permits {
43300d3b7a4SDavid Howells 	struct rcu_head		rcu;		/* disposal procedure */
43400d3b7a4SDavid Howells 	int			count;		/* number of records */
43500d3b7a4SDavid Howells 	struct afs_permit	permits[0];	/* the permits so far examined */
43600d3b7a4SDavid Howells };
43700d3b7a4SDavid Howells 
438b908fe6bSDavid Howells /*
439b908fe6bSDavid Howells  * record of one of a system's set of network interfaces
440b908fe6bSDavid Howells  */
441b908fe6bSDavid Howells struct afs_interface {
442b908fe6bSDavid Howells 	struct in_addr	address;	/* IPv4 address bound to interface */
443b908fe6bSDavid Howells 	struct in_addr	netmask;	/* netmask applied to address */
444b908fe6bSDavid Howells 	unsigned	mtu;		/* MTU of interface */
445b908fe6bSDavid Howells };
446b908fe6bSDavid Howells 
44708e0e7c8SDavid Howells /*****************************************************************************/
44808e0e7c8SDavid Howells /*
4499b3f26c9SDavid Howells  * cache.c
4509b3f26c9SDavid Howells  */
4519b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE
4529b3f26c9SDavid Howells extern struct fscache_netfs afs_cache_netfs;
4539b3f26c9SDavid Howells extern struct fscache_cookie_def afs_cell_cache_index_def;
4549b3f26c9SDavid Howells extern struct fscache_cookie_def afs_volume_cache_index_def;
4559b3f26c9SDavid Howells extern struct fscache_cookie_def afs_vnode_cache_index_def;
4569b3f26c9SDavid Howells #else
4579b3f26c9SDavid Howells #define afs_cell_cache_index_def	(*(struct fscache_cookie_def *) NULL)
4589b3f26c9SDavid Howells #define afs_volume_cache_index_def	(*(struct fscache_cookie_def *) NULL)
4599b3f26c9SDavid Howells #define afs_vnode_cache_index_def	(*(struct fscache_cookie_def *) NULL)
4609b3f26c9SDavid Howells #endif
4619b3f26c9SDavid Howells 
4629b3f26c9SDavid Howells /*
46308e0e7c8SDavid Howells  * callback.c
46408e0e7c8SDavid Howells  */
465f044c884SDavid Howells extern struct workqueue_struct *afs_callback_update_worker;
466f044c884SDavid Howells 
46708e0e7c8SDavid Howells extern void afs_init_callback_state(struct afs_server *);
46808e0e7c8SDavid Howells extern void afs_broken_callback_work(struct work_struct *);
46908e0e7c8SDavid Howells extern void afs_break_callbacks(struct afs_server *, size_t,
47008e0e7c8SDavid Howells 				struct afs_callback[]);
471260a9803SDavid Howells extern void afs_discard_callback_on_delete(struct afs_vnode *);
47208e0e7c8SDavid Howells extern void afs_give_up_callback(struct afs_vnode *);
47308e0e7c8SDavid Howells extern void afs_dispatch_give_up_callbacks(struct work_struct *);
47408e0e7c8SDavid Howells extern void afs_flush_callback_breaks(struct afs_server *);
4751da177e4SLinus Torvalds 
4761da177e4SLinus Torvalds /*
4771da177e4SLinus Torvalds  * cell.c
4781da177e4SLinus Torvalds  */
47949566f6fSDavid Howells static inline struct afs_cell *afs_get_cell(struct afs_cell *cell)
48049566f6fSDavid Howells {
48149566f6fSDavid Howells 	if (cell)
48249566f6fSDavid Howells 		atomic_inc(&cell->usage);
48349566f6fSDavid Howells 	return cell;
48449566f6fSDavid Howells }
485f044c884SDavid Howells extern int afs_cell_init(struct afs_net *, char *);
486f044c884SDavid Howells extern struct afs_cell *afs_cell_create(struct afs_net *, const char *, unsigned, char *, bool);
487f044c884SDavid Howells extern struct afs_cell *afs_cell_lookup(struct afs_net *, const char *, unsigned, bool);
48808e0e7c8SDavid Howells extern struct afs_cell *afs_grab_cell(struct afs_cell *);
4899ed900b1SDavid Howells extern void afs_put_cell(struct afs_net *, struct afs_cell *);
490f044c884SDavid Howells extern void __net_exit afs_cell_purge(struct afs_net *);
49108e0e7c8SDavid Howells 
49208e0e7c8SDavid Howells /*
49308e0e7c8SDavid Howells  * cmservice.c
49408e0e7c8SDavid Howells  */
49508e0e7c8SDavid Howells extern bool afs_cm_incoming_call(struct afs_call *);
49608e0e7c8SDavid Howells 
4971da177e4SLinus Torvalds /*
4981da177e4SLinus Torvalds  * dir.c
4991da177e4SLinus Torvalds  */
500754661f1SArjan van de Ven extern const struct inode_operations afs_dir_inode_operations;
501d61dcce2SAl Viro extern const struct dentry_operations afs_fs_dentry_operations;
5024b6f5d20SArjan van de Ven extern const struct file_operations afs_dir_file_operations;
5031da177e4SLinus Torvalds 
5041da177e4SLinus Torvalds /*
5051da177e4SLinus Torvalds  * file.c
5061da177e4SLinus Torvalds  */
507f5e54d6eSChristoph Hellwig extern const struct address_space_operations afs_fs_aops;
508754661f1SArjan van de Ven extern const struct inode_operations afs_file_inode_operations;
50900d3b7a4SDavid Howells extern const struct file_operations afs_file_operations;
51000d3b7a4SDavid Howells 
51100d3b7a4SDavid Howells extern int afs_open(struct inode *, struct file *);
51200d3b7a4SDavid Howells extern int afs_release(struct inode *, struct file *);
513f6d335c0SAl Viro extern int afs_page_filler(void *, struct page *);
514196ee9cdSDavid Howells extern void afs_put_read(struct afs_read *);
5151da177e4SLinus Torvalds 
5161da177e4SLinus Torvalds /*
517e8d6c554SDavid Howells  * flock.c
518e8d6c554SDavid Howells  */
519f044c884SDavid Howells extern struct workqueue_struct *afs_lock_manager;
520f044c884SDavid Howells 
521e8d6c554SDavid Howells extern void afs_lock_work(struct work_struct *);
522e8d6c554SDavid Howells extern void afs_lock_may_be_available(struct afs_vnode *);
523e8d6c554SDavid Howells extern int afs_lock(struct file *, int, struct file_lock *);
524e8d6c554SDavid Howells extern int afs_flock(struct file *, int, struct file_lock *);
525e8d6c554SDavid Howells 
526e8d6c554SDavid Howells /*
52708e0e7c8SDavid Howells  * fsclient.c
52808e0e7c8SDavid Howells  */
52900d3b7a4SDavid Howells extern int afs_fs_fetch_file_status(struct afs_server *, struct key *,
53000d3b7a4SDavid Howells 				    struct afs_vnode *, struct afs_volsync *,
53156ff9c83SDavid Howells 				    bool);
532f044c884SDavid Howells extern int afs_fs_give_up_callbacks(struct afs_net *, struct afs_server *, bool);
53300d3b7a4SDavid Howells extern int afs_fs_fetch_data(struct afs_server *, struct key *,
53456ff9c83SDavid Howells 			     struct afs_vnode *, struct afs_read *, bool);
535260a9803SDavid Howells extern int afs_fs_create(struct afs_server *, struct key *,
536260a9803SDavid Howells 			 struct afs_vnode *, const char *, umode_t,
537260a9803SDavid Howells 			 struct afs_fid *, struct afs_file_status *,
53856ff9c83SDavid Howells 			 struct afs_callback *, bool);
539260a9803SDavid Howells extern int afs_fs_remove(struct afs_server *, struct key *,
54056ff9c83SDavid Howells 			 struct afs_vnode *, const char *, bool, bool);
541260a9803SDavid Howells extern int afs_fs_link(struct afs_server *, struct key *, struct afs_vnode *,
54256ff9c83SDavid Howells 		       struct afs_vnode *, const char *, bool);
543260a9803SDavid Howells extern int afs_fs_symlink(struct afs_server *, struct key *,
544260a9803SDavid Howells 			  struct afs_vnode *, const char *, const char *,
54556ff9c83SDavid Howells 			  struct afs_fid *, struct afs_file_status *, bool);
546260a9803SDavid Howells extern int afs_fs_rename(struct afs_server *, struct key *,
547260a9803SDavid Howells 			 struct afs_vnode *, const char *,
54856ff9c83SDavid Howells 			 struct afs_vnode *, const char *, bool);
54931143d5dSDavid Howells extern int afs_fs_store_data(struct afs_server *, struct afs_writeback *,
55056ff9c83SDavid Howells 			     pgoff_t, pgoff_t, unsigned, unsigned, bool);
55131143d5dSDavid Howells extern int afs_fs_setattr(struct afs_server *, struct key *,
55256ff9c83SDavid Howells 			  struct afs_vnode *, struct iattr *, bool);
55345222b9eSDavid Howells extern int afs_fs_get_volume_status(struct afs_server *, struct key *,
55445222b9eSDavid Howells 				    struct afs_vnode *,
55556ff9c83SDavid Howells 				    struct afs_volume_status *, bool);
556e8d6c554SDavid Howells extern int afs_fs_set_lock(struct afs_server *, struct key *,
55756ff9c83SDavid Howells 			   struct afs_vnode *, afs_lock_type_t, bool);
558e8d6c554SDavid Howells extern int afs_fs_extend_lock(struct afs_server *, struct key *,
55956ff9c83SDavid Howells 			      struct afs_vnode *, bool);
560e8d6c554SDavid Howells extern int afs_fs_release_lock(struct afs_server *, struct key *,
56156ff9c83SDavid Howells 			       struct afs_vnode *, bool);
56208e0e7c8SDavid Howells 
56308e0e7c8SDavid Howells /*
5641da177e4SLinus Torvalds  * inode.c
5651da177e4SLinus Torvalds  */
566bec5eb61Swanglei extern struct inode *afs_iget_autocell(struct inode *, const char *, int,
567bec5eb61Swanglei 				       struct key *);
56800d3b7a4SDavid Howells extern struct inode *afs_iget(struct super_block *, struct key *,
569260a9803SDavid Howells 			      struct afs_fid *, struct afs_file_status *,
570260a9803SDavid Howells 			      struct afs_callback *);
571416351f2SDavid Howells extern void afs_zap_data(struct afs_vnode *);
572260a9803SDavid Howells extern int afs_validate(struct afs_vnode *, struct key *);
573a528d35eSDavid Howells extern int afs_getattr(const struct path *, struct kstat *, u32, unsigned int);
57431143d5dSDavid Howells extern int afs_setattr(struct dentry *, struct iattr *);
575b57922d9SAl Viro extern void afs_evict_inode(struct inode *);
576bec5eb61Swanglei extern int afs_drop_inode(struct inode *);
5771da177e4SLinus Torvalds 
5781da177e4SLinus Torvalds /*
5791da177e4SLinus Torvalds  * main.c
5801da177e4SLinus Torvalds  */
5810ad53eeeSTejun Heo extern struct workqueue_struct *afs_wq;
582f044c884SDavid Howells 
583f044c884SDavid Howells static inline struct afs_net *afs_d2net(struct dentry *dentry)
584f044c884SDavid Howells {
585f044c884SDavid Howells 	return &__afs_net;
586f044c884SDavid Howells }
587f044c884SDavid Howells 
588f044c884SDavid Howells static inline struct afs_net *afs_i2net(struct inode *inode)
589f044c884SDavid Howells {
590f044c884SDavid Howells 	return &__afs_net;
591f044c884SDavid Howells }
592f044c884SDavid Howells 
593f044c884SDavid Howells static inline struct afs_net *afs_v2net(struct afs_vnode *vnode)
594f044c884SDavid Howells {
595f044c884SDavid Howells 	return &__afs_net;
596f044c884SDavid Howells }
597f044c884SDavid Howells 
598f044c884SDavid Howells static inline struct afs_net *afs_sock2net(struct sock *sk)
599f044c884SDavid Howells {
600f044c884SDavid Howells 	return &__afs_net;
601f044c884SDavid Howells }
602f044c884SDavid Howells 
603f044c884SDavid Howells static inline struct afs_net *afs_get_net(struct afs_net *net)
604f044c884SDavid Howells {
605f044c884SDavid Howells 	return net;
606f044c884SDavid Howells }
607f044c884SDavid Howells 
608f044c884SDavid Howells static inline void afs_put_net(struct afs_net *net)
609f044c884SDavid Howells {
610f044c884SDavid Howells }
6111da177e4SLinus Torvalds 
6121da177e4SLinus Torvalds /*
61308e0e7c8SDavid Howells  * misc.c
61408e0e7c8SDavid Howells  */
61508e0e7c8SDavid Howells extern int afs_abort_to_error(u32);
61608e0e7c8SDavid Howells 
61708e0e7c8SDavid Howells /*
6181da177e4SLinus Torvalds  * mntpt.c
6191da177e4SLinus Torvalds  */
620754661f1SArjan van de Ven extern const struct inode_operations afs_mntpt_inode_operations;
621bec5eb61Swanglei extern const struct inode_operations afs_autocell_inode_operations;
6224b6f5d20SArjan van de Ven extern const struct file_operations afs_mntpt_file_operations;
6231da177e4SLinus Torvalds 
624d18610b0SDavid Howells extern struct vfsmount *afs_d_automount(struct path *);
62508e0e7c8SDavid Howells extern void afs_mntpt_kill_timer(void);
6261da177e4SLinus Torvalds 
6271da177e4SLinus Torvalds /*
628b4db2b35SArnd Bergmann  * netdevices.c
629b4db2b35SArnd Bergmann  */
630b4db2b35SArnd Bergmann extern int afs_get_ipv4_interfaces(struct afs_interface *, size_t, bool);
631b4db2b35SArnd Bergmann 
632b4db2b35SArnd Bergmann /*
6331da177e4SLinus Torvalds  * proc.c
6341da177e4SLinus Torvalds  */
635f044c884SDavid Howells extern int __net_init afs_proc_init(struct afs_net *);
636f044c884SDavid Howells extern void __net_exit afs_proc_cleanup(struct afs_net *);
637f044c884SDavid Howells extern int afs_proc_cell_setup(struct afs_net *, struct afs_cell *);
638f044c884SDavid Howells extern void afs_proc_cell_remove(struct afs_net *, struct afs_cell *);
6391da177e4SLinus Torvalds 
64008e0e7c8SDavid Howells /*
64108e0e7c8SDavid Howells  * rxrpc.c
64208e0e7c8SDavid Howells  */
643f044c884SDavid Howells extern struct workqueue_struct *afs_async_calls;
6448324f0bcSDavid Howells 
645f044c884SDavid Howells extern int __net_init afs_open_socket(struct afs_net *);
646f044c884SDavid Howells extern void __net_exit afs_close_socket(struct afs_net *);
647f044c884SDavid Howells extern void afs_charge_preallocation(struct work_struct *);
648341f741fSDavid Howells extern void afs_put_call(struct afs_call *);
649341f741fSDavid Howells extern int afs_queue_call_work(struct afs_call *);
6504d9df986SDavid Howells extern int afs_make_call(struct sockaddr_rxrpc *, struct afs_call *, gfp_t, bool);
651f044c884SDavid Howells extern struct afs_call *afs_alloc_flat_call(struct afs_net *,
652f044c884SDavid Howells 					    const struct afs_call_type *,
65308e0e7c8SDavid Howells 					    size_t, size_t);
65408e0e7c8SDavid Howells extern void afs_flat_call_destructor(struct afs_call *);
65508e0e7c8SDavid Howells extern void afs_send_empty_reply(struct afs_call *);
656b908fe6bSDavid Howells extern void afs_send_simple_reply(struct afs_call *, const void *, size_t);
657d001648eSDavid Howells extern int afs_extract_data(struct afs_call *, void *, size_t, bool);
65808e0e7c8SDavid Howells 
659d001648eSDavid Howells static inline int afs_transfer_reply(struct afs_call *call)
660372ee163SDavid Howells {
661d001648eSDavid Howells 	return afs_extract_data(call, call->buffer, call->reply_max, false);
662372ee163SDavid Howells }
663372ee163SDavid Howells 
66408e0e7c8SDavid Howells /*
66500d3b7a4SDavid Howells  * security.c
66600d3b7a4SDavid Howells  */
66700d3b7a4SDavid Howells extern void afs_clear_permits(struct afs_vnode *);
66800d3b7a4SDavid Howells extern void afs_cache_permit(struct afs_vnode *, struct key *, long);
669416351f2SDavid Howells extern void afs_zap_permits(struct rcu_head *);
67000d3b7a4SDavid Howells extern struct key *afs_request_key(struct afs_cell *);
67110556cb2SAl Viro extern int afs_permission(struct inode *, int);
67200d3b7a4SDavid Howells 
67300d3b7a4SDavid Howells /*
67408e0e7c8SDavid Howells  * server.c
67508e0e7c8SDavid Howells  */
67608e0e7c8SDavid Howells extern spinlock_t afs_server_peer_lock;
67708e0e7c8SDavid Howells 
678260a9803SDavid Howells #define afs_get_server(S)					\
679260a9803SDavid Howells do {								\
680260a9803SDavid Howells 	_debug("GET SERVER %d", atomic_read(&(S)->usage));	\
681260a9803SDavid Howells 	atomic_inc(&(S)->usage);				\
682260a9803SDavid Howells } while(0)
68308e0e7c8SDavid Howells 
68459fa1c4aSDavid Howells extern void afs_server_timer(struct timer_list *);
68508e0e7c8SDavid Howells extern struct afs_server *afs_lookup_server(struct afs_cell *,
6864d9df986SDavid Howells 					    struct sockaddr_rxrpc *);
687f044c884SDavid Howells extern struct afs_server *afs_find_server(struct afs_net *,
688f044c884SDavid Howells 					  const struct sockaddr_rxrpc *);
6899ed900b1SDavid Howells extern void afs_put_server(struct afs_net *, struct afs_server *);
690f044c884SDavid Howells extern void afs_reap_server(struct work_struct *);
691f044c884SDavid Howells extern void __net_exit afs_purge_servers(struct afs_net *);
69208e0e7c8SDavid Howells 
69308e0e7c8SDavid Howells /*
69400d3b7a4SDavid Howells  * super.c
69500d3b7a4SDavid Howells  */
696f044c884SDavid Howells extern int __init afs_fs_init(void);
697f044c884SDavid Howells extern void __exit afs_fs_exit(void);
69800d3b7a4SDavid Howells 
69900d3b7a4SDavid Howells /*
70008e0e7c8SDavid Howells  * vlclient.c
70108e0e7c8SDavid Howells  */
702f044c884SDavid Howells extern int afs_vl_get_entry_by_name(struct afs_net *,
7034d9df986SDavid Howells 				    struct sockaddr_rxrpc *, struct key *,
70400d3b7a4SDavid Howells 				    const char *, struct afs_cache_vlocation *,
70556ff9c83SDavid Howells 				    bool);
706f044c884SDavid Howells extern int afs_vl_get_entry_by_id(struct afs_net *,
7074d9df986SDavid Howells 				  struct sockaddr_rxrpc *, struct key *,
70800d3b7a4SDavid Howells 				  afs_volid_t, afs_voltype_t,
70956ff9c83SDavid Howells 				  struct afs_cache_vlocation *, bool);
71008e0e7c8SDavid Howells 
71108e0e7c8SDavid Howells /*
71208e0e7c8SDavid Howells  * vlocation.c
71308e0e7c8SDavid Howells  */
714f044c884SDavid Howells extern struct workqueue_struct *afs_vlocation_update_worker;
715f044c884SDavid Howells 
71608e0e7c8SDavid Howells #define afs_get_vlocation(V) do { atomic_inc(&(V)->usage); } while(0)
71708e0e7c8SDavid Howells 
718f044c884SDavid Howells extern struct afs_vlocation *afs_vlocation_lookup(struct afs_net *,
719f044c884SDavid Howells 						  struct afs_cell *,
72000d3b7a4SDavid Howells 						  struct key *,
72108e0e7c8SDavid Howells 						  const char *, size_t);
722f044c884SDavid Howells extern void afs_put_vlocation(struct afs_net *, struct afs_vlocation *);
723f044c884SDavid Howells extern void afs_vlocation_updater(struct work_struct *);
724f044c884SDavid Howells extern void afs_vlocation_reaper(struct work_struct *);
725f044c884SDavid Howells extern void __net_exit afs_vlocation_purge(struct afs_net *);
72608e0e7c8SDavid Howells 
72708e0e7c8SDavid Howells /*
72808e0e7c8SDavid Howells  * vnode.c
72908e0e7c8SDavid Howells  */
73008e0e7c8SDavid Howells static inline struct afs_vnode *AFS_FS_I(struct inode *inode)
73108e0e7c8SDavid Howells {
73208e0e7c8SDavid Howells 	return container_of(inode, struct afs_vnode, vfs_inode);
73308e0e7c8SDavid Howells }
73408e0e7c8SDavid Howells 
73508e0e7c8SDavid Howells static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode)
73608e0e7c8SDavid Howells {
73708e0e7c8SDavid Howells 	return &vnode->vfs_inode;
73808e0e7c8SDavid Howells }
73908e0e7c8SDavid Howells 
740260a9803SDavid Howells extern void afs_vnode_finalise_status_update(struct afs_vnode *,
741260a9803SDavid Howells 					     struct afs_server *);
74200d3b7a4SDavid Howells extern int afs_vnode_fetch_status(struct afs_vnode *, struct afs_vnode *,
74300d3b7a4SDavid Howells 				  struct key *);
74400d3b7a4SDavid Howells extern int afs_vnode_fetch_data(struct afs_vnode *, struct key *,
745196ee9cdSDavid Howells 				struct afs_read *);
746260a9803SDavid Howells extern int afs_vnode_create(struct afs_vnode *, struct key *, const char *,
747260a9803SDavid Howells 			    umode_t, struct afs_fid *, struct afs_file_status *,
748260a9803SDavid Howells 			    struct afs_callback *, struct afs_server **);
749260a9803SDavid Howells extern int afs_vnode_remove(struct afs_vnode *, struct key *, const char *,
750260a9803SDavid Howells 			    bool);
751260a9803SDavid Howells extern int afs_vnode_link(struct afs_vnode *, struct afs_vnode *, struct key *,
752260a9803SDavid Howells 			  const char *);
753260a9803SDavid Howells extern int afs_vnode_symlink(struct afs_vnode *, struct key *, const char *,
754260a9803SDavid Howells 			     const char *, struct afs_fid *,
755260a9803SDavid Howells 			     struct afs_file_status *, struct afs_server **);
756260a9803SDavid Howells extern int afs_vnode_rename(struct afs_vnode *, struct afs_vnode *,
757260a9803SDavid Howells 			    struct key *, const char *, const char *);
75831143d5dSDavid Howells extern int afs_vnode_store_data(struct afs_writeback *, pgoff_t, pgoff_t,
75931143d5dSDavid Howells 				unsigned, unsigned);
76031143d5dSDavid Howells extern int afs_vnode_setattr(struct afs_vnode *, struct key *, struct iattr *);
76145222b9eSDavid Howells extern int afs_vnode_get_volume_status(struct afs_vnode *, struct key *,
76245222b9eSDavid Howells 				       struct afs_volume_status *);
763e8d6c554SDavid Howells extern int afs_vnode_set_lock(struct afs_vnode *, struct key *,
764e8d6c554SDavid Howells 			      afs_lock_type_t);
765e8d6c554SDavid Howells extern int afs_vnode_extend_lock(struct afs_vnode *, struct key *);
766e8d6c554SDavid Howells extern int afs_vnode_release_lock(struct afs_vnode *, struct key *);
76708e0e7c8SDavid Howells 
76808e0e7c8SDavid Howells /*
76908e0e7c8SDavid Howells  * volume.c
77008e0e7c8SDavid Howells  */
77149566f6fSDavid Howells static inline struct afs_volume *afs_get_volume(struct afs_volume *volume)
77249566f6fSDavid Howells {
77349566f6fSDavid Howells 	if (volume)
77449566f6fSDavid Howells 		atomic_inc(&volume->usage);
77549566f6fSDavid Howells 	return volume;
77649566f6fSDavid Howells }
77708e0e7c8SDavid Howells 
7789ed900b1SDavid Howells extern void afs_put_volume(struct afs_cell *, struct afs_volume *);
77900d3b7a4SDavid Howells extern struct afs_volume *afs_volume_lookup(struct afs_mount_params *);
78008e0e7c8SDavid Howells extern struct afs_server *afs_volume_pick_fileserver(struct afs_vnode *);
78108e0e7c8SDavid Howells extern int afs_volume_release_fileserver(struct afs_vnode *,
78208e0e7c8SDavid Howells 					 struct afs_server *, int);
78308e0e7c8SDavid Howells 
78431143d5dSDavid Howells /*
78531143d5dSDavid Howells  * write.c
78631143d5dSDavid Howells  */
78731143d5dSDavid Howells extern int afs_set_page_dirty(struct page *);
78831143d5dSDavid Howells extern void afs_put_writeback(struct afs_writeback *);
78915b4650eSNick Piggin extern int afs_write_begin(struct file *file, struct address_space *mapping,
79015b4650eSNick Piggin 			loff_t pos, unsigned len, unsigned flags,
79115b4650eSNick Piggin 			struct page **pagep, void **fsdata);
79215b4650eSNick Piggin extern int afs_write_end(struct file *file, struct address_space *mapping,
79315b4650eSNick Piggin 			loff_t pos, unsigned len, unsigned copied,
79415b4650eSNick Piggin 			struct page *page, void *fsdata);
79531143d5dSDavid Howells extern int afs_writepage(struct page *, struct writeback_control *);
79631143d5dSDavid Howells extern int afs_writepages(struct address_space *, struct writeback_control *);
79731143d5dSDavid Howells extern void afs_pages_written_back(struct afs_vnode *, struct afs_call *);
79850b5551dSAl Viro extern ssize_t afs_file_write(struct kiocb *, struct iov_iter *);
79931143d5dSDavid Howells extern int afs_writeback_all(struct afs_vnode *);
80058fed94dSDavid Howells extern int afs_flush(struct file *, fl_owner_t);
80102c24a82SJosef Bacik extern int afs_fsync(struct file *, loff_t, loff_t, int);
80231143d5dSDavid Howells 
803d3e3b7eaSDavid Howells /*
804d3e3b7eaSDavid Howells  * xattr.c
805d3e3b7eaSDavid Howells  */
806d3e3b7eaSDavid Howells extern const struct xattr_handler *afs_xattr_handlers[];
807d3e3b7eaSDavid Howells extern ssize_t afs_listxattr(struct dentry *, char *, size_t);
80831143d5dSDavid Howells 
80908e0e7c8SDavid Howells /*****************************************************************************/
81008e0e7c8SDavid Howells /*
81108e0e7c8SDavid Howells  * debug tracing
81208e0e7c8SDavid Howells  */
8138e8d7f13SDavid Howells #include <trace/events/afs.h>
8148e8d7f13SDavid Howells 
81508e0e7c8SDavid Howells extern unsigned afs_debug;
81608e0e7c8SDavid Howells 
81708e0e7c8SDavid Howells #define dbgprintk(FMT,...) \
818ad16df84SSven Schnelle 	printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__)
81908e0e7c8SDavid Howells 
820530b6412SHarvey Harrison #define kenter(FMT,...)	dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
821530b6412SHarvey Harrison #define kleave(FMT,...)	dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
82208e0e7c8SDavid Howells #define kdebug(FMT,...)	dbgprintk("    "FMT ,##__VA_ARGS__)
82308e0e7c8SDavid Howells 
82408e0e7c8SDavid Howells 
82508e0e7c8SDavid Howells #if defined(__KDEBUG)
82608e0e7c8SDavid Howells #define _enter(FMT,...)	kenter(FMT,##__VA_ARGS__)
82708e0e7c8SDavid Howells #define _leave(FMT,...)	kleave(FMT,##__VA_ARGS__)
82808e0e7c8SDavid Howells #define _debug(FMT,...)	kdebug(FMT,##__VA_ARGS__)
82908e0e7c8SDavid Howells 
83008e0e7c8SDavid Howells #elif defined(CONFIG_AFS_DEBUG)
83108e0e7c8SDavid Howells #define AFS_DEBUG_KENTER	0x01
83208e0e7c8SDavid Howells #define AFS_DEBUG_KLEAVE	0x02
83308e0e7c8SDavid Howells #define AFS_DEBUG_KDEBUG	0x04
83408e0e7c8SDavid Howells 
83508e0e7c8SDavid Howells #define _enter(FMT,...)					\
83608e0e7c8SDavid Howells do {							\
83708e0e7c8SDavid Howells 	if (unlikely(afs_debug & AFS_DEBUG_KENTER))	\
83808e0e7c8SDavid Howells 		kenter(FMT,##__VA_ARGS__);		\
83908e0e7c8SDavid Howells } while (0)
84008e0e7c8SDavid Howells 
84108e0e7c8SDavid Howells #define _leave(FMT,...)					\
84208e0e7c8SDavid Howells do {							\
84308e0e7c8SDavid Howells 	if (unlikely(afs_debug & AFS_DEBUG_KLEAVE))	\
84408e0e7c8SDavid Howells 		kleave(FMT,##__VA_ARGS__);		\
84508e0e7c8SDavid Howells } while (0)
84608e0e7c8SDavid Howells 
84708e0e7c8SDavid Howells #define _debug(FMT,...)					\
84808e0e7c8SDavid Howells do {							\
84908e0e7c8SDavid Howells 	if (unlikely(afs_debug & AFS_DEBUG_KDEBUG))	\
85008e0e7c8SDavid Howells 		kdebug(FMT,##__VA_ARGS__);		\
85108e0e7c8SDavid Howells } while (0)
85208e0e7c8SDavid Howells 
85308e0e7c8SDavid Howells #else
85412fdff3fSDavid Howells #define _enter(FMT,...)	no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
85512fdff3fSDavid Howells #define _leave(FMT,...)	no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
85612fdff3fSDavid Howells #define _debug(FMT,...)	no_printk("    "FMT ,##__VA_ARGS__)
85708e0e7c8SDavid Howells #endif
85808e0e7c8SDavid Howells 
85908e0e7c8SDavid Howells /*
86008e0e7c8SDavid Howells  * debug assertion checking
86108e0e7c8SDavid Howells  */
86208e0e7c8SDavid Howells #if 1 // defined(__KDEBUGALL)
86308e0e7c8SDavid Howells 
86408e0e7c8SDavid Howells #define ASSERT(X)						\
86508e0e7c8SDavid Howells do {								\
86608e0e7c8SDavid Howells 	if (unlikely(!(X))) {					\
86708e0e7c8SDavid Howells 		printk(KERN_ERR "\n");				\
86808e0e7c8SDavid Howells 		printk(KERN_ERR "AFS: Assertion failed\n");	\
86908e0e7c8SDavid Howells 		BUG();						\
87008e0e7c8SDavid Howells 	}							\
87108e0e7c8SDavid Howells } while(0)
87208e0e7c8SDavid Howells 
87308e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y)						\
87408e0e7c8SDavid Howells do {									\
87508e0e7c8SDavid Howells 	if (unlikely(!((X) OP (Y)))) {					\
87608e0e7c8SDavid Howells 		printk(KERN_ERR "\n");					\
87708e0e7c8SDavid Howells 		printk(KERN_ERR "AFS: Assertion failed\n");		\
87808e0e7c8SDavid Howells 		printk(KERN_ERR "%lu " #OP " %lu is false\n",		\
87908e0e7c8SDavid Howells 		       (unsigned long)(X), (unsigned long)(Y));		\
88008e0e7c8SDavid Howells 		printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n",	\
88108e0e7c8SDavid Howells 		       (unsigned long)(X), (unsigned long)(Y));		\
88208e0e7c8SDavid Howells 		BUG();							\
88308e0e7c8SDavid Howells 	}								\
88408e0e7c8SDavid Howells } while(0)
88508e0e7c8SDavid Howells 
886416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H)					\
887416351f2SDavid Howells do {									\
888416351f2SDavid Howells 	if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) {		\
889416351f2SDavid Howells 		printk(KERN_ERR "\n");					\
890416351f2SDavid Howells 		printk(KERN_ERR "AFS: Assertion failed\n");		\
891416351f2SDavid Howells 		printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n",	\
892416351f2SDavid Howells 		       (unsigned long)(L), (unsigned long)(N),		\
893416351f2SDavid Howells 		       (unsigned long)(H));				\
894416351f2SDavid Howells 		printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \
895416351f2SDavid Howells 		       (unsigned long)(L), (unsigned long)(N),		\
896416351f2SDavid Howells 		       (unsigned long)(H));				\
897416351f2SDavid Howells 		BUG();							\
898416351f2SDavid Howells 	}								\
899416351f2SDavid Howells } while(0)
900416351f2SDavid Howells 
90108e0e7c8SDavid Howells #define ASSERTIF(C, X)						\
90208e0e7c8SDavid Howells do {								\
90308e0e7c8SDavid Howells 	if (unlikely((C) && !(X))) {				\
90408e0e7c8SDavid Howells 		printk(KERN_ERR "\n");				\
90508e0e7c8SDavid Howells 		printk(KERN_ERR "AFS: Assertion failed\n");	\
90608e0e7c8SDavid Howells 		BUG();						\
90708e0e7c8SDavid Howells 	}							\
90808e0e7c8SDavid Howells } while(0)
90908e0e7c8SDavid Howells 
91008e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y)					\
91108e0e7c8SDavid Howells do {									\
91208e0e7c8SDavid Howells 	if (unlikely((C) && !((X) OP (Y)))) {				\
91308e0e7c8SDavid Howells 		printk(KERN_ERR "\n");					\
91408e0e7c8SDavid Howells 		printk(KERN_ERR "AFS: Assertion failed\n");		\
91508e0e7c8SDavid Howells 		printk(KERN_ERR "%lu " #OP " %lu is false\n",		\
91608e0e7c8SDavid Howells 		       (unsigned long)(X), (unsigned long)(Y));		\
91708e0e7c8SDavid Howells 		printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n",	\
91808e0e7c8SDavid Howells 		       (unsigned long)(X), (unsigned long)(Y));		\
91908e0e7c8SDavid Howells 		BUG();							\
92008e0e7c8SDavid Howells 	}								\
92108e0e7c8SDavid Howells } while(0)
92208e0e7c8SDavid Howells 
92308e0e7c8SDavid Howells #else
92408e0e7c8SDavid Howells 
92508e0e7c8SDavid Howells #define ASSERT(X)				\
92608e0e7c8SDavid Howells do {						\
92708e0e7c8SDavid Howells } while(0)
92808e0e7c8SDavid Howells 
92908e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y)			\
93008e0e7c8SDavid Howells do {						\
93108e0e7c8SDavid Howells } while(0)
93208e0e7c8SDavid Howells 
933416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H)		\
934416351f2SDavid Howells do {						\
935416351f2SDavid Howells } while(0)
936416351f2SDavid Howells 
93708e0e7c8SDavid Howells #define ASSERTIF(C, X)				\
93808e0e7c8SDavid Howells do {						\
93908e0e7c8SDavid Howells } while(0)
94008e0e7c8SDavid Howells 
94108e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y)		\
94208e0e7c8SDavid Howells do {						\
94308e0e7c8SDavid Howells } while(0)
94408e0e7c8SDavid Howells 
94508e0e7c8SDavid Howells #endif /* __KDEBUGALL */
946