xref: /openbmc/linux/fs/afs/internal.h (revision a68f4a27)
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>
248324f0bcSDavid Howells #include <net/af_rxrpc.h>
2500c541eaSAndrew Morton 
2608e0e7c8SDavid Howells #include "afs.h"
2708e0e7c8SDavid Howells #include "afs_vl.h"
2808e0e7c8SDavid Howells 
2908e0e7c8SDavid Howells #define AFS_CELL_MAX_ADDRS 15
3008e0e7c8SDavid Howells 
3131143d5dSDavid Howells struct pagevec;
3208e0e7c8SDavid Howells struct afs_call;
3308e0e7c8SDavid Howells 
3408e0e7c8SDavid Howells typedef enum {
3508e0e7c8SDavid Howells 	AFS_VL_NEW,			/* new, uninitialised record */
3608e0e7c8SDavid Howells 	AFS_VL_CREATING,		/* creating record */
3708e0e7c8SDavid Howells 	AFS_VL_VALID,			/* record is pending */
3808e0e7c8SDavid Howells 	AFS_VL_NO_VOLUME,		/* no such volume available */
3908e0e7c8SDavid Howells 	AFS_VL_UPDATING,		/* update in progress */
4008e0e7c8SDavid Howells 	AFS_VL_VOLUME_DELETED,		/* volume was deleted */
4108e0e7c8SDavid Howells 	AFS_VL_UNCERTAIN,		/* uncertain state (update failed) */
4208e0e7c8SDavid Howells } __attribute__((packed)) afs_vlocation_state_t;
431da177e4SLinus Torvalds 
4400d3b7a4SDavid Howells struct afs_mount_params {
4500d3b7a4SDavid Howells 	bool			rwpath;		/* T if the parent should be considered R/W */
4600d3b7a4SDavid Howells 	bool			force;		/* T to force cell type */
47bec5eb61Swanglei 	bool			autocell;	/* T if set auto mount operation */
4800d3b7a4SDavid Howells 	afs_voltype_t		type;		/* type of volume requested */
4900d3b7a4SDavid Howells 	int			volnamesz;	/* size of volume name */
5000d3b7a4SDavid Howells 	const char		*volname;	/* name of volume to mount */
5100d3b7a4SDavid Howells 	struct afs_cell		*cell;		/* cell in which to find volume */
5200d3b7a4SDavid Howells 	struct afs_volume	*volume;	/* volume record */
5300d3b7a4SDavid Howells 	struct key		*key;		/* key to use for secure mounting */
5400d3b7a4SDavid Howells };
5500d3b7a4SDavid Howells 
568e8d7f13SDavid Howells enum afs_call_state {
578e8d7f13SDavid Howells 	AFS_CALL_REQUESTING,	/* request is being sent for outgoing call */
588e8d7f13SDavid Howells 	AFS_CALL_AWAIT_REPLY,	/* awaiting reply to outgoing call */
598e8d7f13SDavid Howells 	AFS_CALL_AWAIT_OP_ID,	/* awaiting op ID on incoming call */
608e8d7f13SDavid Howells 	AFS_CALL_AWAIT_REQUEST,	/* awaiting request data on incoming call */
618e8d7f13SDavid Howells 	AFS_CALL_REPLYING,	/* replying to incoming call */
628e8d7f13SDavid Howells 	AFS_CALL_AWAIT_ACK,	/* awaiting final ACK of incoming call */
638e8d7f13SDavid Howells 	AFS_CALL_COMPLETE,	/* Completed or failed */
648e8d7f13SDavid Howells };
6508e0e7c8SDavid Howells /*
6608e0e7c8SDavid Howells  * a record of an in-progress RxRPC call
6708e0e7c8SDavid Howells  */
6808e0e7c8SDavid Howells struct afs_call {
6908e0e7c8SDavid Howells 	const struct afs_call_type *type;	/* type of call */
7008e0e7c8SDavid Howells 	wait_queue_head_t	waitq;		/* processes awaiting completion */
71341f741fSDavid Howells 	struct work_struct	async_work;	/* async I/O processor */
7208e0e7c8SDavid Howells 	struct work_struct	work;		/* actual work processor */
7308e0e7c8SDavid Howells 	struct rxrpc_call	*rxcall;	/* RxRPC call handle */
7408e0e7c8SDavid Howells 	struct key		*key;		/* security for this call */
7508e0e7c8SDavid Howells 	struct afs_server	*server;	/* server affected by incoming CM call */
7608e0e7c8SDavid Howells 	void			*request;	/* request data (first part) */
7731143d5dSDavid Howells 	struct address_space	*mapping;	/* page set */
7831143d5dSDavid Howells 	struct afs_writeback	*wb;		/* writeback being performed */
7908e0e7c8SDavid Howells 	void			*buffer;	/* reply receive buffer */
8008e0e7c8SDavid Howells 	void			*reply;		/* reply buffer (first part) */
8108e0e7c8SDavid Howells 	void			*reply2;	/* reply buffer (second part) */
8208e0e7c8SDavid Howells 	void			*reply3;	/* reply buffer (third part) */
83260a9803SDavid Howells 	void			*reply4;	/* reply buffer (fourth part) */
8431143d5dSDavid Howells 	pgoff_t			first;		/* first page in mapping to deal with */
8531143d5dSDavid Howells 	pgoff_t			last;		/* last page in mapping to deal with */
86d001648eSDavid Howells 	size_t			offset;		/* offset into received data store */
87341f741fSDavid Howells 	atomic_t		usage;
888e8d7f13SDavid Howells 	enum afs_call_state	state;
8908e0e7c8SDavid Howells 	int			error;		/* error code */
90d001648eSDavid Howells 	u32			abort_code;	/* Remote abort ID or 0 */
9108e0e7c8SDavid Howells 	unsigned		request_size;	/* size of request data */
9208e0e7c8SDavid Howells 	unsigned		reply_max;	/* maximum size of reply */
9331143d5dSDavid Howells 	unsigned		first_offset;	/* offset into mapping[first] */
94bcd89270SMarc Dionne 	union {
9531143d5dSDavid Howells 		unsigned	last_to;	/* amount of mapping[last] */
96bcd89270SMarc Dionne 		unsigned	count2;		/* count used in unmarshalling */
97bcd89270SMarc Dionne 	};
9808e0e7c8SDavid Howells 	unsigned char		unmarshall;	/* unmarshalling phase */
9908e0e7c8SDavid Howells 	bool			incoming;	/* T if incoming call */
10031143d5dSDavid Howells 	bool			send_pages;	/* T if data from mapping should be sent */
101d001648eSDavid Howells 	bool			need_attention;	/* T if RxRPC poked us */
10256ff9c83SDavid Howells 	bool			async;		/* T if asynchronous */
103a68f4a27SDavid Howells 	bool			upgrade;	/* T to request service upgrade */
10408e0e7c8SDavid Howells 	u16			service_id;	/* RxRPC service ID to call */
10508e0e7c8SDavid Howells 	__be16			port;		/* target UDP port */
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 	/* map an abort code to an error number */
12108e0e7c8SDavid Howells 	int (*abort_to_error)(u32 abort_code);
12208e0e7c8SDavid Howells 
12308e0e7c8SDavid Howells 	/* clean up a call */
12408e0e7c8SDavid Howells 	void (*destructor)(struct afs_call *call);
125341f741fSDavid Howells 
126341f741fSDavid Howells 	/* Work function */
127341f741fSDavid Howells 	void (*work)(struct work_struct *work);
12808e0e7c8SDavid Howells };
12908e0e7c8SDavid Howells 
13008e0e7c8SDavid Howells /*
131196ee9cdSDavid Howells  * Record of an outstanding read operation on a vnode.
132196ee9cdSDavid Howells  */
133196ee9cdSDavid Howells struct afs_read {
134196ee9cdSDavid Howells 	loff_t			pos;		/* Where to start reading */
135e8e581a8SDavid Howells 	loff_t			len;		/* How much we're asking for */
136196ee9cdSDavid Howells 	loff_t			actual_len;	/* How much we're actually getting */
1376a0e3999SDavid Howells 	loff_t			remain;		/* Amount remaining */
138196ee9cdSDavid Howells 	atomic_t		usage;
139196ee9cdSDavid Howells 	unsigned int		index;		/* Which page we're reading into */
140196ee9cdSDavid Howells 	unsigned int		nr_pages;
141196ee9cdSDavid Howells 	void (*page_done)(struct afs_call *, struct afs_read *);
142196ee9cdSDavid Howells 	struct page		*pages[];
143196ee9cdSDavid Howells };
144196ee9cdSDavid Howells 
145196ee9cdSDavid Howells /*
14631143d5dSDavid Howells  * record of an outstanding writeback on a vnode
14731143d5dSDavid Howells  */
14831143d5dSDavid Howells struct afs_writeback {
14931143d5dSDavid Howells 	struct list_head	link;		/* link in vnode->writebacks */
15031143d5dSDavid Howells 	struct work_struct	writer;		/* work item to perform the writeback */
15131143d5dSDavid Howells 	struct afs_vnode	*vnode;		/* vnode to which this write applies */
15231143d5dSDavid Howells 	struct key		*key;		/* owner of this write */
15331143d5dSDavid Howells 	wait_queue_head_t	waitq;		/* completion and ready wait queue */
15431143d5dSDavid Howells 	pgoff_t			first;		/* first page in batch */
15531143d5dSDavid Howells 	pgoff_t			point;		/* last page in current store op */
15631143d5dSDavid Howells 	pgoff_t			last;		/* last page in batch (inclusive) */
15731143d5dSDavid Howells 	unsigned		offset_first;	/* offset into first page of start of write */
15831143d5dSDavid Howells 	unsigned		to_last;	/* offset into last page of end of write */
15931143d5dSDavid Howells 	int			num_conflicts;	/* count of conflicting writes in list */
16031143d5dSDavid Howells 	int			usage;
16131143d5dSDavid Howells 	bool			conflicts;	/* T if has dependent conflicts */
16231143d5dSDavid Howells 	enum {
16331143d5dSDavid Howells 		AFS_WBACK_SYNCING,		/* synchronisation being performed */
16431143d5dSDavid Howells 		AFS_WBACK_PENDING,		/* write pending */
16531143d5dSDavid Howells 		AFS_WBACK_CONFLICTING,		/* conflicting writes posted */
16631143d5dSDavid Howells 		AFS_WBACK_WRITING,		/* writing back */
16731143d5dSDavid Howells 		AFS_WBACK_COMPLETE		/* the writeback record has been unlinked */
16831143d5dSDavid Howells 	} state __attribute__((packed));
16931143d5dSDavid Howells };
17031143d5dSDavid Howells 
17131143d5dSDavid Howells /*
17208e0e7c8SDavid Howells  * AFS superblock private data
17308e0e7c8SDavid Howells  * - there's one superblock per volume
17408e0e7c8SDavid Howells  */
17508e0e7c8SDavid Howells struct afs_super_info {
17608e0e7c8SDavid Howells 	struct afs_volume	*volume;	/* volume record */
17708e0e7c8SDavid Howells 	char			rwparent;	/* T if parent is R/W AFS volume */
17808e0e7c8SDavid Howells };
17908e0e7c8SDavid Howells 
18008e0e7c8SDavid Howells static inline struct afs_super_info *AFS_FS_S(struct super_block *sb)
18108e0e7c8SDavid Howells {
18208e0e7c8SDavid Howells 	return sb->s_fs_info;
18308e0e7c8SDavid Howells }
18408e0e7c8SDavid Howells 
18508e0e7c8SDavid Howells extern struct file_system_type afs_fs_type;
18608e0e7c8SDavid Howells 
18708e0e7c8SDavid Howells /*
18808e0e7c8SDavid Howells  * entry in the cached cell catalogue
18908e0e7c8SDavid Howells  */
19008e0e7c8SDavid Howells struct afs_cache_cell {
19100d3b7a4SDavid Howells 	char		name[AFS_MAXCELLNAME];	/* cell name (padded with NULs) */
19208e0e7c8SDavid Howells 	struct in_addr	vl_servers[15];		/* cached cell VL servers */
19308e0e7c8SDavid Howells };
19408e0e7c8SDavid Howells 
19508e0e7c8SDavid Howells /*
19608e0e7c8SDavid Howells  * AFS cell record
19708e0e7c8SDavid Howells  */
19808e0e7c8SDavid Howells struct afs_cell {
19908e0e7c8SDavid Howells 	atomic_t		usage;
20008e0e7c8SDavid Howells 	struct list_head	link;		/* main cell list link */
20100d3b7a4SDavid Howells 	struct key		*anonymous_key;	/* anonymous user key for this cell */
20208e0e7c8SDavid Howells 	struct list_head	proc_link;	/* /proc cell list link */
2039b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE
2049b3f26c9SDavid Howells 	struct fscache_cookie	*cache;		/* caching cookie */
2051da177e4SLinus Torvalds #endif
2061da177e4SLinus Torvalds 
20708e0e7c8SDavid Howells 	/* server record management */
20808e0e7c8SDavid Howells 	rwlock_t		servers_lock;	/* active server list lock */
20908e0e7c8SDavid Howells 	struct list_head	servers;	/* active server list */
2101da177e4SLinus Torvalds 
21108e0e7c8SDavid Howells 	/* volume location record management */
21208e0e7c8SDavid Howells 	struct rw_semaphore	vl_sem;		/* volume management serialisation semaphore */
21308e0e7c8SDavid Howells 	struct list_head	vl_list;	/* cell's active VL record list */
21408e0e7c8SDavid Howells 	spinlock_t		vl_lock;	/* vl_list lock */
21508e0e7c8SDavid Howells 	unsigned short		vl_naddrs;	/* number of VL servers in addr list */
21608e0e7c8SDavid Howells 	unsigned short		vl_curr_svix;	/* current server index */
21708e0e7c8SDavid Howells 	struct in_addr		vl_addrs[AFS_CELL_MAX_ADDRS];	/* cell VL server addresses */
21808e0e7c8SDavid Howells 
21908e0e7c8SDavid Howells 	char			name[0];	/* cell name - must go last */
22008e0e7c8SDavid Howells };
22108e0e7c8SDavid Howells 
22208e0e7c8SDavid Howells /*
22308e0e7c8SDavid Howells  * entry in the cached volume location catalogue
22408e0e7c8SDavid Howells  */
22508e0e7c8SDavid Howells struct afs_cache_vlocation {
22600d3b7a4SDavid Howells 	/* volume name (lowercase, padded with NULs) */
22700d3b7a4SDavid Howells 	uint8_t			name[AFS_MAXVOLNAME + 1];
22800d3b7a4SDavid Howells 
22908e0e7c8SDavid Howells 	uint8_t			nservers;	/* number of entries used in servers[] */
23008e0e7c8SDavid Howells 	uint8_t			vidmask;	/* voltype mask for vid[] */
23108e0e7c8SDavid Howells 	uint8_t			srvtmask[8];	/* voltype masks for servers[] */
23208e0e7c8SDavid Howells #define AFS_VOL_VTM_RW	0x01 /* R/W version of the volume is available (on this server) */
23308e0e7c8SDavid Howells #define AFS_VOL_VTM_RO	0x02 /* R/O version of the volume is available (on this server) */
23408e0e7c8SDavid Howells #define AFS_VOL_VTM_BAK	0x04 /* backup version of the volume is available (on this server) */
23508e0e7c8SDavid Howells 
23608e0e7c8SDavid Howells 	afs_volid_t		vid[3];		/* volume IDs for R/W, R/O and Bak volumes */
23708e0e7c8SDavid Howells 	struct in_addr		servers[8];	/* fileserver addresses */
23808e0e7c8SDavid Howells 	time_t			rtime;		/* last retrieval time */
23908e0e7c8SDavid Howells };
24008e0e7c8SDavid Howells 
24108e0e7c8SDavid Howells /*
24208e0e7c8SDavid Howells  * volume -> vnode hash table entry
24308e0e7c8SDavid Howells  */
24408e0e7c8SDavid Howells struct afs_cache_vhash {
24508e0e7c8SDavid Howells 	afs_voltype_t		vtype;		/* which volume variation */
24608e0e7c8SDavid Howells 	uint8_t			hash_bucket;	/* which hash bucket this represents */
24708e0e7c8SDavid Howells } __attribute__((packed));
24808e0e7c8SDavid Howells 
24908e0e7c8SDavid Howells /*
25008e0e7c8SDavid Howells  * AFS volume location record
25108e0e7c8SDavid Howells  */
25208e0e7c8SDavid Howells struct afs_vlocation {
25308e0e7c8SDavid Howells 	atomic_t		usage;
2548a79790bSTina Ruchandani 	time64_t		time_of_death;	/* time at which put reduced usage to 0 */
25508e0e7c8SDavid Howells 	struct list_head	link;		/* link in cell volume location list */
25608e0e7c8SDavid Howells 	struct list_head	grave;		/* link in master graveyard list */
25708e0e7c8SDavid Howells 	struct list_head	update;		/* link in master update list */
25808e0e7c8SDavid Howells 	struct afs_cell		*cell;		/* cell to which volume belongs */
2599b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE
2609b3f26c9SDavid Howells 	struct fscache_cookie	*cache;		/* caching cookie */
26108e0e7c8SDavid Howells #endif
26208e0e7c8SDavid Howells 	struct afs_cache_vlocation vldb;	/* volume information DB record */
26308e0e7c8SDavid Howells 	struct afs_volume	*vols[3];	/* volume access record pointer (index by type) */
26408e0e7c8SDavid Howells 	wait_queue_head_t	waitq;		/* status change waitqueue */
2658a79790bSTina Ruchandani 	time64_t		update_at;	/* time at which record should be updated */
26639bf0949SDavid S. Miller 	spinlock_t		lock;		/* access lock */
26708e0e7c8SDavid Howells 	afs_vlocation_state_t	state;		/* volume location state */
26808e0e7c8SDavid Howells 	unsigned short		upd_rej_cnt;	/* ENOMEDIUM count during update */
26908e0e7c8SDavid Howells 	unsigned short		upd_busy_cnt;	/* EBUSY count during update */
27008e0e7c8SDavid Howells 	bool			valid;		/* T if valid */
27108e0e7c8SDavid Howells };
27208e0e7c8SDavid Howells 
27308e0e7c8SDavid Howells /*
27408e0e7c8SDavid Howells  * AFS fileserver record
27508e0e7c8SDavid Howells  */
27608e0e7c8SDavid Howells struct afs_server {
27708e0e7c8SDavid Howells 	atomic_t		usage;
2788a79790bSTina Ruchandani 	time64_t		time_of_death;	/* time at which put reduced usage to 0 */
27908e0e7c8SDavid Howells 	struct in_addr		addr;		/* server address */
28008e0e7c8SDavid Howells 	struct afs_cell		*cell;		/* cell in which server resides */
28108e0e7c8SDavid Howells 	struct list_head	link;		/* link in cell's server list */
28208e0e7c8SDavid Howells 	struct list_head	grave;		/* link in master graveyard list */
28308e0e7c8SDavid Howells 	struct rb_node		master_rb;	/* link in master by-addr tree */
28408e0e7c8SDavid Howells 	struct rw_semaphore	sem;		/* access lock */
28508e0e7c8SDavid Howells 
28608e0e7c8SDavid Howells 	/* file service access */
28708e0e7c8SDavid Howells 	struct rb_root		fs_vnodes;	/* vnodes backed by this server (ordered by FID) */
28808e0e7c8SDavid Howells 	unsigned long		fs_act_jif;	/* time at which last activity occurred */
28908e0e7c8SDavid Howells 	unsigned long		fs_dead_jif;	/* time at which no longer to be considered dead */
29008e0e7c8SDavid Howells 	spinlock_t		fs_lock;	/* access lock */
29108e0e7c8SDavid Howells 	int			fs_state;      	/* 0 or reason FS currently marked dead (-errno) */
29208e0e7c8SDavid Howells 
29308e0e7c8SDavid Howells 	/* callback promise management */
29408e0e7c8SDavid Howells 	struct rb_root		cb_promises;	/* vnode expiration list (ordered earliest first) */
29508e0e7c8SDavid Howells 	struct delayed_work	cb_updater;	/* callback updater */
29608e0e7c8SDavid Howells 	struct delayed_work	cb_break_work;	/* collected break dispatcher */
29708e0e7c8SDavid Howells 	wait_queue_head_t	cb_break_waitq;	/* space available in cb_break waitqueue */
29808e0e7c8SDavid Howells 	spinlock_t		cb_lock;	/* access lock */
29908e0e7c8SDavid Howells 	struct afs_callback	cb_break[64];	/* ring of callbacks awaiting breaking */
30008e0e7c8SDavid Howells 	atomic_t		cb_break_n;	/* number of pending breaks */
30108e0e7c8SDavid Howells 	u8			cb_break_head;	/* head of callback breaking ring */
30208e0e7c8SDavid Howells 	u8			cb_break_tail;	/* tail of callback breaking ring */
30308e0e7c8SDavid Howells };
30408e0e7c8SDavid Howells 
30508e0e7c8SDavid Howells /*
30608e0e7c8SDavid Howells  * AFS volume access record
30708e0e7c8SDavid Howells  */
30808e0e7c8SDavid Howells struct afs_volume {
30908e0e7c8SDavid Howells 	atomic_t		usage;
31008e0e7c8SDavid Howells 	struct afs_cell		*cell;		/* cell to which belongs (unrefd ptr) */
31108e0e7c8SDavid Howells 	struct afs_vlocation	*vlocation;	/* volume location */
3129b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE
3139b3f26c9SDavid Howells 	struct fscache_cookie	*cache;		/* caching cookie */
31408e0e7c8SDavid Howells #endif
31508e0e7c8SDavid Howells 	afs_volid_t		vid;		/* volume ID */
31608e0e7c8SDavid Howells 	afs_voltype_t		type;		/* type of volume */
31708e0e7c8SDavid Howells 	char			type_force;	/* force volume type (suppress R/O -> R/W) */
31808e0e7c8SDavid Howells 	unsigned short		nservers;	/* number of server slots filled */
31908e0e7c8SDavid Howells 	unsigned short		rjservers;	/* number of servers discarded due to -ENOMEDIUM */
32008e0e7c8SDavid Howells 	struct afs_server	*servers[8];	/* servers on which volume resides (ordered) */
32108e0e7c8SDavid Howells 	struct rw_semaphore	server_sem;	/* lock for accessing current server */
32208e0e7c8SDavid Howells };
32308e0e7c8SDavid Howells 
32408e0e7c8SDavid Howells /*
32508e0e7c8SDavid Howells  * vnode catalogue entry
32608e0e7c8SDavid Howells  */
32708e0e7c8SDavid Howells struct afs_cache_vnode {
32808e0e7c8SDavid Howells 	afs_vnodeid_t		vnode_id;	/* vnode ID */
32908e0e7c8SDavid Howells 	unsigned		vnode_unique;	/* vnode ID uniquifier */
33008e0e7c8SDavid Howells 	afs_dataversion_t	data_version;	/* data version */
33108e0e7c8SDavid Howells };
33208e0e7c8SDavid Howells 
33308e0e7c8SDavid Howells /*
33408e0e7c8SDavid Howells  * AFS inode private data
33508e0e7c8SDavid Howells  */
33608e0e7c8SDavid Howells struct afs_vnode {
33708e0e7c8SDavid Howells 	struct inode		vfs_inode;	/* the VFS's inode record */
33808e0e7c8SDavid Howells 
33908e0e7c8SDavid Howells 	struct afs_volume	*volume;	/* volume on which vnode resides */
34008e0e7c8SDavid Howells 	struct afs_server	*server;	/* server currently supplying this file */
34108e0e7c8SDavid Howells 	struct afs_fid		fid;		/* the file identifier for this inode */
34208e0e7c8SDavid Howells 	struct afs_file_status	status;		/* AFS status info for this file */
3439b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE
3449b3f26c9SDavid Howells 	struct fscache_cookie	*cache;		/* caching cookie */
34508e0e7c8SDavid Howells #endif
34600d3b7a4SDavid Howells 	struct afs_permits	*permits;	/* cache of permits so far obtained */
34700d3b7a4SDavid Howells 	struct mutex		permits_lock;	/* lock for altering permits list */
348260a9803SDavid Howells 	struct mutex		validate_lock;	/* lock for validating this vnode */
34908e0e7c8SDavid Howells 	wait_queue_head_t	update_waitq;	/* status fetch waitqueue */
350260a9803SDavid Howells 	int			update_cnt;	/* number of outstanding ops that will update the
35108e0e7c8SDavid Howells 						 * status */
35231143d5dSDavid Howells 	spinlock_t		writeback_lock;	/* lock for writebacks */
35308e0e7c8SDavid Howells 	spinlock_t		lock;		/* waitqueue/flags lock */
35408e0e7c8SDavid Howells 	unsigned long		flags;
35508e0e7c8SDavid Howells #define AFS_VNODE_CB_BROKEN	0		/* set if vnode's callback was broken */
356260a9803SDavid Howells #define AFS_VNODE_UNSET		1		/* set if vnode attributes not yet set */
35708e0e7c8SDavid Howells #define AFS_VNODE_MODIFIED	2		/* set if vnode's data modified */
35808e0e7c8SDavid Howells #define AFS_VNODE_ZAP_DATA	3		/* set if vnode's data should be invalidated */
35908e0e7c8SDavid Howells #define AFS_VNODE_DELETED	4		/* set if vnode deleted on server */
36008e0e7c8SDavid Howells #define AFS_VNODE_MOUNTPOINT	5		/* set if vnode is a mountpoint symlink */
361e8d6c554SDavid Howells #define AFS_VNODE_LOCKING	6		/* set if waiting for lock on vnode */
362e8d6c554SDavid Howells #define AFS_VNODE_READLOCKED	7		/* set if vnode is read-locked on the server */
363e8d6c554SDavid Howells #define AFS_VNODE_WRITELOCKED	8		/* set if vnode is write-locked on the server */
364e8d6c554SDavid Howells #define AFS_VNODE_UNLOCKING	9		/* set if vnode is being unlocked on the server */
365bec5eb61Swanglei #define AFS_VNODE_AUTOCELL	10		/* set if Vnode is an auto mount point */
366bec5eb61Swanglei #define AFS_VNODE_PSEUDODIR	11		/* set if Vnode is a pseudo directory */
36708e0e7c8SDavid Howells 
36800d3b7a4SDavid Howells 	long			acl_order;	/* ACL check count (callback break count) */
36900d3b7a4SDavid Howells 
37031143d5dSDavid Howells 	struct list_head	writebacks;	/* alterations in pagecache that need writing */
371e8d6c554SDavid Howells 	struct list_head	pending_locks;	/* locks waiting to be granted */
372e8d6c554SDavid Howells 	struct list_head	granted_locks;	/* locks granted on this file */
373e8d6c554SDavid Howells 	struct delayed_work	lock_work;	/* work to be done in locking */
374e8d6c554SDavid Howells 	struct key		*unlock_key;	/* key to be used in unlocking */
37531143d5dSDavid Howells 
37608e0e7c8SDavid Howells 	/* outstanding callback notification on this file */
37708e0e7c8SDavid Howells 	struct rb_node		server_rb;	/* link in server->fs_vnodes */
37808e0e7c8SDavid Howells 	struct rb_node		cb_promise;	/* link in server->cb_promises */
37908e0e7c8SDavid Howells 	struct work_struct	cb_broken_work;	/* work to be done on callback break */
38056e71431STina Ruchandani 	time64_t		cb_expires;	/* time at which callback expires */
38156e71431STina Ruchandani 	time64_t		cb_expires_at;	/* time used to order cb_promise */
38208e0e7c8SDavid Howells 	unsigned		cb_version;	/* callback version */
38308e0e7c8SDavid Howells 	unsigned		cb_expiry;	/* callback expiry time */
38408e0e7c8SDavid Howells 	afs_callback_type_t	cb_type;	/* type of callback */
38508e0e7c8SDavid Howells 	bool			cb_promised;	/* true if promise still holds */
38608e0e7c8SDavid Howells };
38708e0e7c8SDavid Howells 
38800d3b7a4SDavid Howells /*
38900d3b7a4SDavid Howells  * cached security record for one user's attempt to access a vnode
39000d3b7a4SDavid Howells  */
39100d3b7a4SDavid Howells struct afs_permit {
39200d3b7a4SDavid Howells 	struct key		*key;		/* RxRPC ticket holding a security context */
39300d3b7a4SDavid Howells 	afs_access_t		access_mask;	/* access mask for this key */
39400d3b7a4SDavid Howells };
39500d3b7a4SDavid Howells 
39600d3b7a4SDavid Howells /*
39700d3b7a4SDavid Howells  * cache of security records from attempts to access a vnode
39800d3b7a4SDavid Howells  */
39900d3b7a4SDavid Howells struct afs_permits {
40000d3b7a4SDavid Howells 	struct rcu_head		rcu;		/* disposal procedure */
40100d3b7a4SDavid Howells 	int			count;		/* number of records */
40200d3b7a4SDavid Howells 	struct afs_permit	permits[0];	/* the permits so far examined */
40300d3b7a4SDavid Howells };
40400d3b7a4SDavid Howells 
405b908fe6bSDavid Howells /*
406b908fe6bSDavid Howells  * record of one of a system's set of network interfaces
407b908fe6bSDavid Howells  */
408b908fe6bSDavid Howells struct afs_interface {
409b908fe6bSDavid Howells 	struct in_addr	address;	/* IPv4 address bound to interface */
410b908fe6bSDavid Howells 	struct in_addr	netmask;	/* netmask applied to address */
411b908fe6bSDavid Howells 	unsigned	mtu;		/* MTU of interface */
412b908fe6bSDavid Howells };
413b908fe6bSDavid Howells 
41441bb26f8SChristoph Hellwig struct afs_uuid {
41541bb26f8SChristoph Hellwig 	__be32		time_low;			/* low part of timestamp */
41641bb26f8SChristoph Hellwig 	__be16		time_mid;			/* mid part of timestamp */
41741bb26f8SChristoph Hellwig 	__be16		time_hi_and_version;		/* high part of timestamp and version  */
41841bb26f8SChristoph Hellwig 	__u8		clock_seq_hi_and_reserved;	/* clock seq hi and variant */
41941bb26f8SChristoph Hellwig 	__u8		clock_seq_low;			/* clock seq low */
42041bb26f8SChristoph Hellwig 	__u8		node[6];			/* spatially unique node ID (MAC addr) */
42141bb26f8SChristoph Hellwig };
42241bb26f8SChristoph Hellwig 
42308e0e7c8SDavid Howells /*****************************************************************************/
42408e0e7c8SDavid Howells /*
4259b3f26c9SDavid Howells  * cache.c
4269b3f26c9SDavid Howells  */
4279b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE
4289b3f26c9SDavid Howells extern struct fscache_netfs afs_cache_netfs;
4299b3f26c9SDavid Howells extern struct fscache_cookie_def afs_cell_cache_index_def;
4309b3f26c9SDavid Howells extern struct fscache_cookie_def afs_vlocation_cache_index_def;
4319b3f26c9SDavid Howells extern struct fscache_cookie_def afs_volume_cache_index_def;
4329b3f26c9SDavid Howells extern struct fscache_cookie_def afs_vnode_cache_index_def;
4339b3f26c9SDavid Howells #else
4349b3f26c9SDavid Howells #define afs_cell_cache_index_def	(*(struct fscache_cookie_def *) NULL)
4359b3f26c9SDavid Howells #define afs_vlocation_cache_index_def	(*(struct fscache_cookie_def *) NULL)
4369b3f26c9SDavid Howells #define afs_volume_cache_index_def	(*(struct fscache_cookie_def *) NULL)
4379b3f26c9SDavid Howells #define afs_vnode_cache_index_def	(*(struct fscache_cookie_def *) NULL)
4389b3f26c9SDavid Howells #endif
4399b3f26c9SDavid Howells 
4409b3f26c9SDavid Howells /*
44108e0e7c8SDavid Howells  * callback.c
44208e0e7c8SDavid Howells  */
44308e0e7c8SDavid Howells extern void afs_init_callback_state(struct afs_server *);
44408e0e7c8SDavid Howells extern void afs_broken_callback_work(struct work_struct *);
44508e0e7c8SDavid Howells extern void afs_break_callbacks(struct afs_server *, size_t,
44608e0e7c8SDavid Howells 				struct afs_callback[]);
447260a9803SDavid Howells extern void afs_discard_callback_on_delete(struct afs_vnode *);
44808e0e7c8SDavid Howells extern void afs_give_up_callback(struct afs_vnode *);
44908e0e7c8SDavid Howells extern void afs_dispatch_give_up_callbacks(struct work_struct *);
45008e0e7c8SDavid Howells extern void afs_flush_callback_breaks(struct afs_server *);
45108e0e7c8SDavid Howells extern int __init afs_callback_update_init(void);
452fbb3fcbaSDavid Howells extern void afs_callback_update_kill(void);
4531da177e4SLinus Torvalds 
4541da177e4SLinus Torvalds /*
4551da177e4SLinus Torvalds  * cell.c
4561da177e4SLinus Torvalds  */
4571da177e4SLinus Torvalds extern struct rw_semaphore afs_proc_cells_sem;
4581da177e4SLinus Torvalds extern struct list_head afs_proc_cells;
4591da177e4SLinus Torvalds 
46008e0e7c8SDavid Howells #define afs_get_cell(C) do { atomic_inc(&(C)->usage); } while(0)
46108e0e7c8SDavid Howells extern int afs_cell_init(char *);
462bec5eb61Swanglei extern struct afs_cell *afs_cell_create(const char *, unsigned, char *, bool);
463bec5eb61Swanglei extern struct afs_cell *afs_cell_lookup(const char *, unsigned, bool);
46408e0e7c8SDavid Howells extern struct afs_cell *afs_grab_cell(struct afs_cell *);
46508e0e7c8SDavid Howells extern void afs_put_cell(struct afs_cell *);
46608e0e7c8SDavid Howells extern void afs_cell_purge(void);
46708e0e7c8SDavid Howells 
46808e0e7c8SDavid Howells /*
46908e0e7c8SDavid Howells  * cmservice.c
47008e0e7c8SDavid Howells  */
47108e0e7c8SDavid Howells extern bool afs_cm_incoming_call(struct afs_call *);
47208e0e7c8SDavid Howells 
4731da177e4SLinus Torvalds /*
4741da177e4SLinus Torvalds  * dir.c
4751da177e4SLinus Torvalds  */
476754661f1SArjan van de Ven extern const struct inode_operations afs_dir_inode_operations;
477d61dcce2SAl Viro extern const struct dentry_operations afs_fs_dentry_operations;
4784b6f5d20SArjan van de Ven extern const struct file_operations afs_dir_file_operations;
4791da177e4SLinus Torvalds 
4801da177e4SLinus Torvalds /*
4811da177e4SLinus Torvalds  * file.c
4821da177e4SLinus Torvalds  */
483f5e54d6eSChristoph Hellwig extern const struct address_space_operations afs_fs_aops;
484754661f1SArjan van de Ven extern const struct inode_operations afs_file_inode_operations;
48500d3b7a4SDavid Howells extern const struct file_operations afs_file_operations;
48600d3b7a4SDavid Howells 
48700d3b7a4SDavid Howells extern int afs_open(struct inode *, struct file *);
48800d3b7a4SDavid Howells extern int afs_release(struct inode *, struct file *);
489f6d335c0SAl Viro extern int afs_page_filler(void *, struct page *);
490196ee9cdSDavid Howells extern void afs_put_read(struct afs_read *);
4911da177e4SLinus Torvalds 
4921da177e4SLinus Torvalds /*
493e8d6c554SDavid Howells  * flock.c
494e8d6c554SDavid Howells  */
495e8d6c554SDavid Howells extern void __exit afs_kill_lock_manager(void);
496e8d6c554SDavid Howells extern void afs_lock_work(struct work_struct *);
497e8d6c554SDavid Howells extern void afs_lock_may_be_available(struct afs_vnode *);
498e8d6c554SDavid Howells extern int afs_lock(struct file *, int, struct file_lock *);
499e8d6c554SDavid Howells extern int afs_flock(struct file *, int, struct file_lock *);
500e8d6c554SDavid Howells 
501e8d6c554SDavid Howells /*
50208e0e7c8SDavid Howells  * fsclient.c
50308e0e7c8SDavid Howells  */
50400d3b7a4SDavid Howells extern int afs_fs_fetch_file_status(struct afs_server *, struct key *,
50500d3b7a4SDavid Howells 				    struct afs_vnode *, struct afs_volsync *,
50656ff9c83SDavid Howells 				    bool);
50756ff9c83SDavid Howells extern int afs_fs_give_up_callbacks(struct afs_server *, bool);
50800d3b7a4SDavid Howells extern int afs_fs_fetch_data(struct afs_server *, struct key *,
50956ff9c83SDavid Howells 			     struct afs_vnode *, struct afs_read *, bool);
510260a9803SDavid Howells extern int afs_fs_create(struct afs_server *, struct key *,
511260a9803SDavid Howells 			 struct afs_vnode *, const char *, umode_t,
512260a9803SDavid Howells 			 struct afs_fid *, struct afs_file_status *,
51356ff9c83SDavid Howells 			 struct afs_callback *, bool);
514260a9803SDavid Howells extern int afs_fs_remove(struct afs_server *, struct key *,
51556ff9c83SDavid Howells 			 struct afs_vnode *, const char *, bool, bool);
516260a9803SDavid Howells extern int afs_fs_link(struct afs_server *, struct key *, struct afs_vnode *,
51756ff9c83SDavid Howells 		       struct afs_vnode *, const char *, bool);
518260a9803SDavid Howells extern int afs_fs_symlink(struct afs_server *, struct key *,
519260a9803SDavid Howells 			  struct afs_vnode *, const char *, const char *,
52056ff9c83SDavid Howells 			  struct afs_fid *, struct afs_file_status *, bool);
521260a9803SDavid Howells extern int afs_fs_rename(struct afs_server *, struct key *,
522260a9803SDavid Howells 			 struct afs_vnode *, const char *,
52356ff9c83SDavid Howells 			 struct afs_vnode *, const char *, bool);
52431143d5dSDavid Howells extern int afs_fs_store_data(struct afs_server *, struct afs_writeback *,
52556ff9c83SDavid Howells 			     pgoff_t, pgoff_t, unsigned, unsigned, bool);
52631143d5dSDavid Howells extern int afs_fs_setattr(struct afs_server *, struct key *,
52756ff9c83SDavid Howells 			  struct afs_vnode *, struct iattr *, bool);
52845222b9eSDavid Howells extern int afs_fs_get_volume_status(struct afs_server *, struct key *,
52945222b9eSDavid Howells 				    struct afs_vnode *,
53056ff9c83SDavid Howells 				    struct afs_volume_status *, bool);
531e8d6c554SDavid Howells extern int afs_fs_set_lock(struct afs_server *, struct key *,
53256ff9c83SDavid Howells 			   struct afs_vnode *, afs_lock_type_t, bool);
533e8d6c554SDavid Howells extern int afs_fs_extend_lock(struct afs_server *, struct key *,
53456ff9c83SDavid Howells 			      struct afs_vnode *, bool);
535e8d6c554SDavid Howells extern int afs_fs_release_lock(struct afs_server *, struct key *,
53656ff9c83SDavid Howells 			       struct afs_vnode *, bool);
53708e0e7c8SDavid Howells 
53808e0e7c8SDavid Howells /*
5391da177e4SLinus Torvalds  * inode.c
5401da177e4SLinus Torvalds  */
541bec5eb61Swanglei extern struct inode *afs_iget_autocell(struct inode *, const char *, int,
542bec5eb61Swanglei 				       struct key *);
54300d3b7a4SDavid Howells extern struct inode *afs_iget(struct super_block *, struct key *,
544260a9803SDavid Howells 			      struct afs_fid *, struct afs_file_status *,
545260a9803SDavid Howells 			      struct afs_callback *);
546416351f2SDavid Howells extern void afs_zap_data(struct afs_vnode *);
547260a9803SDavid Howells extern int afs_validate(struct afs_vnode *, struct key *);
548a528d35eSDavid Howells extern int afs_getattr(const struct path *, struct kstat *, u32, unsigned int);
54931143d5dSDavid Howells extern int afs_setattr(struct dentry *, struct iattr *);
550b57922d9SAl Viro extern void afs_evict_inode(struct inode *);
551bec5eb61Swanglei extern int afs_drop_inode(struct inode *);
5521da177e4SLinus Torvalds 
5531da177e4SLinus Torvalds /*
5541da177e4SLinus Torvalds  * main.c
5551da177e4SLinus Torvalds  */
5560ad53eeeSTejun Heo extern struct workqueue_struct *afs_wq;
55741bb26f8SChristoph Hellwig extern struct afs_uuid afs_uuid;
5581da177e4SLinus Torvalds 
5591da177e4SLinus Torvalds /*
56008e0e7c8SDavid Howells  * misc.c
56108e0e7c8SDavid Howells  */
56208e0e7c8SDavid Howells extern int afs_abort_to_error(u32);
56308e0e7c8SDavid Howells 
56408e0e7c8SDavid Howells /*
5651da177e4SLinus Torvalds  * mntpt.c
5661da177e4SLinus Torvalds  */
567754661f1SArjan van de Ven extern const struct inode_operations afs_mntpt_inode_operations;
568bec5eb61Swanglei extern const struct inode_operations afs_autocell_inode_operations;
5694b6f5d20SArjan van de Ven extern const struct file_operations afs_mntpt_file_operations;
5701da177e4SLinus Torvalds 
571d18610b0SDavid Howells extern struct vfsmount *afs_d_automount(struct path *);
57208e0e7c8SDavid Howells extern void afs_mntpt_kill_timer(void);
5731da177e4SLinus Torvalds 
5741da177e4SLinus Torvalds /*
575b4db2b35SArnd Bergmann  * netdevices.c
576b4db2b35SArnd Bergmann  */
577b4db2b35SArnd Bergmann extern int afs_get_ipv4_interfaces(struct afs_interface *, size_t, bool);
578b4db2b35SArnd Bergmann 
579b4db2b35SArnd Bergmann /*
5801da177e4SLinus Torvalds  * proc.c
5811da177e4SLinus Torvalds  */
5821da177e4SLinus Torvalds extern int afs_proc_init(void);
5831da177e4SLinus Torvalds extern void afs_proc_cleanup(void);
584ec26815aSDavid Howells extern int afs_proc_cell_setup(struct afs_cell *);
585ec26815aSDavid Howells extern void afs_proc_cell_remove(struct afs_cell *);
5861da177e4SLinus Torvalds 
58708e0e7c8SDavid Howells /*
58808e0e7c8SDavid Howells  * rxrpc.c
58908e0e7c8SDavid Howells  */
5908324f0bcSDavid Howells extern struct socket *afs_socket;
591341f741fSDavid Howells extern atomic_t afs_outstanding_calls;
5928324f0bcSDavid Howells 
59308e0e7c8SDavid Howells extern int afs_open_socket(void);
59408e0e7c8SDavid Howells extern void afs_close_socket(void);
595341f741fSDavid Howells extern void afs_put_call(struct afs_call *);
596341f741fSDavid Howells extern int afs_queue_call_work(struct afs_call *);
59756ff9c83SDavid Howells extern int afs_make_call(struct in_addr *, struct afs_call *, gfp_t, bool);
59808e0e7c8SDavid Howells extern struct afs_call *afs_alloc_flat_call(const struct afs_call_type *,
59908e0e7c8SDavid Howells 					    size_t, size_t);
60008e0e7c8SDavid Howells extern void afs_flat_call_destructor(struct afs_call *);
60108e0e7c8SDavid Howells extern void afs_send_empty_reply(struct afs_call *);
602b908fe6bSDavid Howells extern void afs_send_simple_reply(struct afs_call *, const void *, size_t);
603d001648eSDavid Howells extern int afs_extract_data(struct afs_call *, void *, size_t, bool);
60408e0e7c8SDavid Howells 
605d001648eSDavid Howells static inline int afs_transfer_reply(struct afs_call *call)
606372ee163SDavid Howells {
607d001648eSDavid Howells 	return afs_extract_data(call, call->buffer, call->reply_max, false);
608372ee163SDavid Howells }
609372ee163SDavid Howells 
61008e0e7c8SDavid Howells /*
61100d3b7a4SDavid Howells  * security.c
61200d3b7a4SDavid Howells  */
61300d3b7a4SDavid Howells extern void afs_clear_permits(struct afs_vnode *);
61400d3b7a4SDavid Howells extern void afs_cache_permit(struct afs_vnode *, struct key *, long);
615416351f2SDavid Howells extern void afs_zap_permits(struct rcu_head *);
61600d3b7a4SDavid Howells extern struct key *afs_request_key(struct afs_cell *);
61710556cb2SAl Viro extern int afs_permission(struct inode *, int);
61800d3b7a4SDavid Howells 
61900d3b7a4SDavid Howells /*
62008e0e7c8SDavid Howells  * server.c
62108e0e7c8SDavid Howells  */
62208e0e7c8SDavid Howells extern spinlock_t afs_server_peer_lock;
62308e0e7c8SDavid Howells 
624260a9803SDavid Howells #define afs_get_server(S)					\
625260a9803SDavid Howells do {								\
626260a9803SDavid Howells 	_debug("GET SERVER %d", atomic_read(&(S)->usage));	\
627260a9803SDavid Howells 	atomic_inc(&(S)->usage);				\
628260a9803SDavid Howells } while(0)
62908e0e7c8SDavid Howells 
63008e0e7c8SDavid Howells extern struct afs_server *afs_lookup_server(struct afs_cell *,
63108e0e7c8SDavid Howells 					    const struct in_addr *);
6328324f0bcSDavid Howells extern struct afs_server *afs_find_server(const struct sockaddr_rxrpc *);
63308e0e7c8SDavid Howells extern void afs_put_server(struct afs_server *);
63408e0e7c8SDavid Howells extern void __exit afs_purge_servers(void);
63508e0e7c8SDavid Howells 
63608e0e7c8SDavid Howells /*
63700d3b7a4SDavid Howells  * super.c
63800d3b7a4SDavid Howells  */
63900d3b7a4SDavid Howells extern int afs_fs_init(void);
64000d3b7a4SDavid Howells extern void afs_fs_exit(void);
64100d3b7a4SDavid Howells 
64200d3b7a4SDavid Howells /*
64308e0e7c8SDavid Howells  * vlclient.c
64408e0e7c8SDavid Howells  */
64500d3b7a4SDavid Howells extern int afs_vl_get_entry_by_name(struct in_addr *, struct key *,
64600d3b7a4SDavid Howells 				    const char *, struct afs_cache_vlocation *,
64756ff9c83SDavid Howells 				    bool);
64800d3b7a4SDavid Howells extern int afs_vl_get_entry_by_id(struct in_addr *, struct key *,
64900d3b7a4SDavid Howells 				  afs_volid_t, afs_voltype_t,
65056ff9c83SDavid Howells 				  struct afs_cache_vlocation *, bool);
65108e0e7c8SDavid Howells 
65208e0e7c8SDavid Howells /*
65308e0e7c8SDavid Howells  * vlocation.c
65408e0e7c8SDavid Howells  */
65508e0e7c8SDavid Howells #define afs_get_vlocation(V) do { atomic_inc(&(V)->usage); } while(0)
65608e0e7c8SDavid Howells 
65708e0e7c8SDavid Howells extern int __init afs_vlocation_update_init(void);
65808e0e7c8SDavid Howells extern struct afs_vlocation *afs_vlocation_lookup(struct afs_cell *,
65900d3b7a4SDavid Howells 						  struct key *,
66008e0e7c8SDavid Howells 						  const char *, size_t);
66108e0e7c8SDavid Howells extern void afs_put_vlocation(struct afs_vlocation *);
662fbb3fcbaSDavid Howells extern void afs_vlocation_purge(void);
66308e0e7c8SDavid Howells 
66408e0e7c8SDavid Howells /*
66508e0e7c8SDavid Howells  * vnode.c
66608e0e7c8SDavid Howells  */
66708e0e7c8SDavid Howells static inline struct afs_vnode *AFS_FS_I(struct inode *inode)
66808e0e7c8SDavid Howells {
66908e0e7c8SDavid Howells 	return container_of(inode, struct afs_vnode, vfs_inode);
67008e0e7c8SDavid Howells }
67108e0e7c8SDavid Howells 
67208e0e7c8SDavid Howells static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode)
67308e0e7c8SDavid Howells {
67408e0e7c8SDavid Howells 	return &vnode->vfs_inode;
67508e0e7c8SDavid Howells }
67608e0e7c8SDavid Howells 
677260a9803SDavid Howells extern void afs_vnode_finalise_status_update(struct afs_vnode *,
678260a9803SDavid Howells 					     struct afs_server *);
67900d3b7a4SDavid Howells extern int afs_vnode_fetch_status(struct afs_vnode *, struct afs_vnode *,
68000d3b7a4SDavid Howells 				  struct key *);
68100d3b7a4SDavid Howells extern int afs_vnode_fetch_data(struct afs_vnode *, struct key *,
682196ee9cdSDavid Howells 				struct afs_read *);
683260a9803SDavid Howells extern int afs_vnode_create(struct afs_vnode *, struct key *, const char *,
684260a9803SDavid Howells 			    umode_t, struct afs_fid *, struct afs_file_status *,
685260a9803SDavid Howells 			    struct afs_callback *, struct afs_server **);
686260a9803SDavid Howells extern int afs_vnode_remove(struct afs_vnode *, struct key *, const char *,
687260a9803SDavid Howells 			    bool);
688260a9803SDavid Howells extern int afs_vnode_link(struct afs_vnode *, struct afs_vnode *, struct key *,
689260a9803SDavid Howells 			  const char *);
690260a9803SDavid Howells extern int afs_vnode_symlink(struct afs_vnode *, struct key *, const char *,
691260a9803SDavid Howells 			     const char *, struct afs_fid *,
692260a9803SDavid Howells 			     struct afs_file_status *, struct afs_server **);
693260a9803SDavid Howells extern int afs_vnode_rename(struct afs_vnode *, struct afs_vnode *,
694260a9803SDavid Howells 			    struct key *, const char *, const char *);
69531143d5dSDavid Howells extern int afs_vnode_store_data(struct afs_writeback *, pgoff_t, pgoff_t,
69631143d5dSDavid Howells 				unsigned, unsigned);
69731143d5dSDavid Howells extern int afs_vnode_setattr(struct afs_vnode *, struct key *, struct iattr *);
69845222b9eSDavid Howells extern int afs_vnode_get_volume_status(struct afs_vnode *, struct key *,
69945222b9eSDavid Howells 				       struct afs_volume_status *);
700e8d6c554SDavid Howells extern int afs_vnode_set_lock(struct afs_vnode *, struct key *,
701e8d6c554SDavid Howells 			      afs_lock_type_t);
702e8d6c554SDavid Howells extern int afs_vnode_extend_lock(struct afs_vnode *, struct key *);
703e8d6c554SDavid Howells extern int afs_vnode_release_lock(struct afs_vnode *, struct key *);
70408e0e7c8SDavid Howells 
70508e0e7c8SDavid Howells /*
70608e0e7c8SDavid Howells  * volume.c
70708e0e7c8SDavid Howells  */
70808e0e7c8SDavid Howells #define afs_get_volume(V) do { atomic_inc(&(V)->usage); } while(0)
70908e0e7c8SDavid Howells 
71008e0e7c8SDavid Howells extern void afs_put_volume(struct afs_volume *);
71100d3b7a4SDavid Howells extern struct afs_volume *afs_volume_lookup(struct afs_mount_params *);
71208e0e7c8SDavid Howells extern struct afs_server *afs_volume_pick_fileserver(struct afs_vnode *);
71308e0e7c8SDavid Howells extern int afs_volume_release_fileserver(struct afs_vnode *,
71408e0e7c8SDavid Howells 					 struct afs_server *, int);
71508e0e7c8SDavid Howells 
71631143d5dSDavid Howells /*
71731143d5dSDavid Howells  * write.c
71831143d5dSDavid Howells  */
71931143d5dSDavid Howells extern int afs_set_page_dirty(struct page *);
72031143d5dSDavid Howells extern void afs_put_writeback(struct afs_writeback *);
72115b4650eSNick Piggin extern int afs_write_begin(struct file *file, struct address_space *mapping,
72215b4650eSNick Piggin 			loff_t pos, unsigned len, unsigned flags,
72315b4650eSNick Piggin 			struct page **pagep, void **fsdata);
72415b4650eSNick Piggin extern int afs_write_end(struct file *file, struct address_space *mapping,
72515b4650eSNick Piggin 			loff_t pos, unsigned len, unsigned copied,
72615b4650eSNick Piggin 			struct page *page, void *fsdata);
72731143d5dSDavid Howells extern int afs_writepage(struct page *, struct writeback_control *);
72831143d5dSDavid Howells extern int afs_writepages(struct address_space *, struct writeback_control *);
72931143d5dSDavid Howells extern void afs_pages_written_back(struct afs_vnode *, struct afs_call *);
73050b5551dSAl Viro extern ssize_t afs_file_write(struct kiocb *, struct iov_iter *);
73131143d5dSDavid Howells extern int afs_writeback_all(struct afs_vnode *);
73258fed94dSDavid Howells extern int afs_flush(struct file *, fl_owner_t);
73302c24a82SJosef Bacik extern int afs_fsync(struct file *, loff_t, loff_t, int);
73431143d5dSDavid Howells 
735d3e3b7eaSDavid Howells /*
736d3e3b7eaSDavid Howells  * xattr.c
737d3e3b7eaSDavid Howells  */
738d3e3b7eaSDavid Howells extern const struct xattr_handler *afs_xattr_handlers[];
739d3e3b7eaSDavid Howells extern ssize_t afs_listxattr(struct dentry *, char *, size_t);
74031143d5dSDavid Howells 
74108e0e7c8SDavid Howells /*****************************************************************************/
74208e0e7c8SDavid Howells /*
74308e0e7c8SDavid Howells  * debug tracing
74408e0e7c8SDavid Howells  */
7458e8d7f13SDavid Howells #include <trace/events/afs.h>
7468e8d7f13SDavid Howells 
74708e0e7c8SDavid Howells extern unsigned afs_debug;
74808e0e7c8SDavid Howells 
74908e0e7c8SDavid Howells #define dbgprintk(FMT,...) \
750ad16df84SSven Schnelle 	printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__)
75108e0e7c8SDavid Howells 
752530b6412SHarvey Harrison #define kenter(FMT,...)	dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
753530b6412SHarvey Harrison #define kleave(FMT,...)	dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
75408e0e7c8SDavid Howells #define kdebug(FMT,...)	dbgprintk("    "FMT ,##__VA_ARGS__)
75508e0e7c8SDavid Howells 
75608e0e7c8SDavid Howells 
75708e0e7c8SDavid Howells #if defined(__KDEBUG)
75808e0e7c8SDavid Howells #define _enter(FMT,...)	kenter(FMT,##__VA_ARGS__)
75908e0e7c8SDavid Howells #define _leave(FMT,...)	kleave(FMT,##__VA_ARGS__)
76008e0e7c8SDavid Howells #define _debug(FMT,...)	kdebug(FMT,##__VA_ARGS__)
76108e0e7c8SDavid Howells 
76208e0e7c8SDavid Howells #elif defined(CONFIG_AFS_DEBUG)
76308e0e7c8SDavid Howells #define AFS_DEBUG_KENTER	0x01
76408e0e7c8SDavid Howells #define AFS_DEBUG_KLEAVE	0x02
76508e0e7c8SDavid Howells #define AFS_DEBUG_KDEBUG	0x04
76608e0e7c8SDavid Howells 
76708e0e7c8SDavid Howells #define _enter(FMT,...)					\
76808e0e7c8SDavid Howells do {							\
76908e0e7c8SDavid Howells 	if (unlikely(afs_debug & AFS_DEBUG_KENTER))	\
77008e0e7c8SDavid Howells 		kenter(FMT,##__VA_ARGS__);		\
77108e0e7c8SDavid Howells } while (0)
77208e0e7c8SDavid Howells 
77308e0e7c8SDavid Howells #define _leave(FMT,...)					\
77408e0e7c8SDavid Howells do {							\
77508e0e7c8SDavid Howells 	if (unlikely(afs_debug & AFS_DEBUG_KLEAVE))	\
77608e0e7c8SDavid Howells 		kleave(FMT,##__VA_ARGS__);		\
77708e0e7c8SDavid Howells } while (0)
77808e0e7c8SDavid Howells 
77908e0e7c8SDavid Howells #define _debug(FMT,...)					\
78008e0e7c8SDavid Howells do {							\
78108e0e7c8SDavid Howells 	if (unlikely(afs_debug & AFS_DEBUG_KDEBUG))	\
78208e0e7c8SDavid Howells 		kdebug(FMT,##__VA_ARGS__);		\
78308e0e7c8SDavid Howells } while (0)
78408e0e7c8SDavid Howells 
78508e0e7c8SDavid Howells #else
78612fdff3fSDavid Howells #define _enter(FMT,...)	no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
78712fdff3fSDavid Howells #define _leave(FMT,...)	no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
78812fdff3fSDavid Howells #define _debug(FMT,...)	no_printk("    "FMT ,##__VA_ARGS__)
78908e0e7c8SDavid Howells #endif
79008e0e7c8SDavid Howells 
79108e0e7c8SDavid Howells /*
79208e0e7c8SDavid Howells  * debug assertion checking
79308e0e7c8SDavid Howells  */
79408e0e7c8SDavid Howells #if 1 // defined(__KDEBUGALL)
79508e0e7c8SDavid Howells 
79608e0e7c8SDavid Howells #define ASSERT(X)						\
79708e0e7c8SDavid Howells do {								\
79808e0e7c8SDavid Howells 	if (unlikely(!(X))) {					\
79908e0e7c8SDavid Howells 		printk(KERN_ERR "\n");				\
80008e0e7c8SDavid Howells 		printk(KERN_ERR "AFS: Assertion failed\n");	\
80108e0e7c8SDavid Howells 		BUG();						\
80208e0e7c8SDavid Howells 	}							\
80308e0e7c8SDavid Howells } while(0)
80408e0e7c8SDavid Howells 
80508e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y)						\
80608e0e7c8SDavid Howells do {									\
80708e0e7c8SDavid Howells 	if (unlikely(!((X) OP (Y)))) {					\
80808e0e7c8SDavid Howells 		printk(KERN_ERR "\n");					\
80908e0e7c8SDavid Howells 		printk(KERN_ERR "AFS: Assertion failed\n");		\
81008e0e7c8SDavid Howells 		printk(KERN_ERR "%lu " #OP " %lu is false\n",		\
81108e0e7c8SDavid Howells 		       (unsigned long)(X), (unsigned long)(Y));		\
81208e0e7c8SDavid Howells 		printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n",	\
81308e0e7c8SDavid Howells 		       (unsigned long)(X), (unsigned long)(Y));		\
81408e0e7c8SDavid Howells 		BUG();							\
81508e0e7c8SDavid Howells 	}								\
81608e0e7c8SDavid Howells } while(0)
81708e0e7c8SDavid Howells 
818416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H)					\
819416351f2SDavid Howells do {									\
820416351f2SDavid Howells 	if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) {		\
821416351f2SDavid Howells 		printk(KERN_ERR "\n");					\
822416351f2SDavid Howells 		printk(KERN_ERR "AFS: Assertion failed\n");		\
823416351f2SDavid Howells 		printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n",	\
824416351f2SDavid Howells 		       (unsigned long)(L), (unsigned long)(N),		\
825416351f2SDavid Howells 		       (unsigned long)(H));				\
826416351f2SDavid Howells 		printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \
827416351f2SDavid Howells 		       (unsigned long)(L), (unsigned long)(N),		\
828416351f2SDavid Howells 		       (unsigned long)(H));				\
829416351f2SDavid Howells 		BUG();							\
830416351f2SDavid Howells 	}								\
831416351f2SDavid Howells } while(0)
832416351f2SDavid Howells 
83308e0e7c8SDavid Howells #define ASSERTIF(C, X)						\
83408e0e7c8SDavid Howells do {								\
83508e0e7c8SDavid Howells 	if (unlikely((C) && !(X))) {				\
83608e0e7c8SDavid Howells 		printk(KERN_ERR "\n");				\
83708e0e7c8SDavid Howells 		printk(KERN_ERR "AFS: Assertion failed\n");	\
83808e0e7c8SDavid Howells 		BUG();						\
83908e0e7c8SDavid Howells 	}							\
84008e0e7c8SDavid Howells } while(0)
84108e0e7c8SDavid Howells 
84208e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y)					\
84308e0e7c8SDavid Howells do {									\
84408e0e7c8SDavid Howells 	if (unlikely((C) && !((X) OP (Y)))) {				\
84508e0e7c8SDavid Howells 		printk(KERN_ERR "\n");					\
84608e0e7c8SDavid Howells 		printk(KERN_ERR "AFS: Assertion failed\n");		\
84708e0e7c8SDavid Howells 		printk(KERN_ERR "%lu " #OP " %lu is false\n",		\
84808e0e7c8SDavid Howells 		       (unsigned long)(X), (unsigned long)(Y));		\
84908e0e7c8SDavid Howells 		printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n",	\
85008e0e7c8SDavid Howells 		       (unsigned long)(X), (unsigned long)(Y));		\
85108e0e7c8SDavid Howells 		BUG();							\
85208e0e7c8SDavid Howells 	}								\
85308e0e7c8SDavid Howells } while(0)
85408e0e7c8SDavid Howells 
85508e0e7c8SDavid Howells #else
85608e0e7c8SDavid Howells 
85708e0e7c8SDavid Howells #define ASSERT(X)				\
85808e0e7c8SDavid Howells do {						\
85908e0e7c8SDavid Howells } while(0)
86008e0e7c8SDavid Howells 
86108e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y)			\
86208e0e7c8SDavid Howells do {						\
86308e0e7c8SDavid Howells } while(0)
86408e0e7c8SDavid Howells 
865416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H)		\
866416351f2SDavid Howells do {						\
867416351f2SDavid Howells } while(0)
868416351f2SDavid Howells 
86908e0e7c8SDavid Howells #define ASSERTIF(C, X)				\
87008e0e7c8SDavid Howells do {						\
87108e0e7c8SDavid Howells } while(0)
87208e0e7c8SDavid Howells 
87308e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y)		\
87408e0e7c8SDavid Howells do {						\
87508e0e7c8SDavid Howells } while(0)
87608e0e7c8SDavid Howells 
87708e0e7c8SDavid Howells #endif /* __KDEBUGALL */
878