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> 141da177e4SLinus Torvalds #include <linux/fs.h> 151da177e4SLinus Torvalds #include <linux/pagemap.h> 1608e0e7c8SDavid Howells #include <linux/rxrpc.h> 1700d3b7a4SDavid Howells #include <linux/key.h> 18e8edc6e0SAlexey Dobriyan #include <linux/workqueue.h> 1900c541eaSAndrew Morton #include <linux/sched.h> 2080e50be4SChristoph Hellwig #include <linux/fscache.h> 21e1da0222SJens Axboe #include <linux/backing-dev.h> 22ff548773SDavid Howells #include <linux/uuid.h> 238324f0bcSDavid Howells #include <net/af_rxrpc.h> 2400c541eaSAndrew Morton 2508e0e7c8SDavid Howells #include "afs.h" 2608e0e7c8SDavid Howells #include "afs_vl.h" 2708e0e7c8SDavid Howells 2808e0e7c8SDavid Howells #define AFS_CELL_MAX_ADDRS 15 2908e0e7c8SDavid Howells 3031143d5dSDavid Howells struct pagevec; 3108e0e7c8SDavid Howells struct afs_call; 3208e0e7c8SDavid Howells 3308e0e7c8SDavid Howells typedef enum { 3408e0e7c8SDavid Howells AFS_VL_NEW, /* new, uninitialised record */ 3508e0e7c8SDavid Howells AFS_VL_CREATING, /* creating record */ 3608e0e7c8SDavid Howells AFS_VL_VALID, /* record is pending */ 3708e0e7c8SDavid Howells AFS_VL_NO_VOLUME, /* no such volume available */ 3808e0e7c8SDavid Howells AFS_VL_UPDATING, /* update in progress */ 3908e0e7c8SDavid Howells AFS_VL_VOLUME_DELETED, /* volume was deleted */ 4008e0e7c8SDavid Howells AFS_VL_UNCERTAIN, /* uncertain state (update failed) */ 4108e0e7c8SDavid Howells } __attribute__((packed)) afs_vlocation_state_t; 421da177e4SLinus Torvalds 4300d3b7a4SDavid Howells struct afs_mount_params { 4400d3b7a4SDavid Howells bool rwpath; /* T if the parent should be considered R/W */ 4500d3b7a4SDavid Howells bool force; /* T to force cell type */ 46bec5eb61Swanglei bool autocell; /* T if set auto mount operation */ 4700d3b7a4SDavid Howells afs_voltype_t type; /* type of volume requested */ 4800d3b7a4SDavid Howells int volnamesz; /* size of volume name */ 4900d3b7a4SDavid Howells const char *volname; /* name of volume to mount */ 5000d3b7a4SDavid Howells struct afs_cell *cell; /* cell in which to find volume */ 5100d3b7a4SDavid Howells struct afs_volume *volume; /* volume record */ 5200d3b7a4SDavid Howells struct key *key; /* key to use for secure mounting */ 5300d3b7a4SDavid Howells }; 5400d3b7a4SDavid Howells 558e8d7f13SDavid Howells enum afs_call_state { 568e8d7f13SDavid Howells AFS_CALL_REQUESTING, /* request is being sent for outgoing call */ 578e8d7f13SDavid Howells AFS_CALL_AWAIT_REPLY, /* awaiting reply to outgoing call */ 588e8d7f13SDavid Howells AFS_CALL_AWAIT_OP_ID, /* awaiting op ID on incoming call */ 598e8d7f13SDavid Howells AFS_CALL_AWAIT_REQUEST, /* awaiting request data on incoming call */ 608e8d7f13SDavid Howells AFS_CALL_REPLYING, /* replying to incoming call */ 618e8d7f13SDavid Howells AFS_CALL_AWAIT_ACK, /* awaiting final ACK of incoming call */ 628e8d7f13SDavid Howells AFS_CALL_COMPLETE, /* Completed or failed */ 638e8d7f13SDavid Howells }; 6408e0e7c8SDavid Howells /* 6508e0e7c8SDavid Howells * a record of an in-progress RxRPC call 6608e0e7c8SDavid Howells */ 6708e0e7c8SDavid Howells struct afs_call { 6808e0e7c8SDavid Howells const struct afs_call_type *type; /* type of call */ 6908e0e7c8SDavid Howells wait_queue_head_t waitq; /* processes awaiting completion */ 70341f741fSDavid Howells struct work_struct async_work; /* async I/O processor */ 7108e0e7c8SDavid Howells struct work_struct work; /* actual work processor */ 7208e0e7c8SDavid Howells struct rxrpc_call *rxcall; /* RxRPC call handle */ 7308e0e7c8SDavid Howells struct key *key; /* security for this call */ 7408e0e7c8SDavid Howells struct afs_server *server; /* server affected by incoming CM call */ 7508e0e7c8SDavid Howells void *request; /* request data (first part) */ 7631143d5dSDavid Howells struct address_space *mapping; /* page set */ 7731143d5dSDavid Howells struct afs_writeback *wb; /* writeback being performed */ 7808e0e7c8SDavid Howells void *buffer; /* reply receive buffer */ 7908e0e7c8SDavid Howells void *reply; /* reply buffer (first part) */ 8008e0e7c8SDavid Howells void *reply2; /* reply buffer (second part) */ 8108e0e7c8SDavid Howells void *reply3; /* reply buffer (third part) */ 82260a9803SDavid Howells void *reply4; /* reply buffer (fourth part) */ 8331143d5dSDavid Howells pgoff_t first; /* first page in mapping to deal with */ 8431143d5dSDavid Howells pgoff_t last; /* last page in mapping to deal with */ 85d001648eSDavid Howells size_t offset; /* offset into received data store */ 86341f741fSDavid Howells atomic_t usage; 878e8d7f13SDavid Howells enum afs_call_state state; 8808e0e7c8SDavid Howells int error; /* error code */ 89d001648eSDavid Howells u32 abort_code; /* Remote abort ID or 0 */ 9008e0e7c8SDavid Howells unsigned request_size; /* size of request data */ 9108e0e7c8SDavid Howells unsigned reply_max; /* maximum size of reply */ 9231143d5dSDavid Howells unsigned first_offset; /* offset into mapping[first] */ 9331143d5dSDavid Howells unsigned last_to; /* amount of mapping[last] */ 9408e0e7c8SDavid Howells unsigned char unmarshall; /* unmarshalling phase */ 9508e0e7c8SDavid Howells bool incoming; /* T if incoming call */ 9631143d5dSDavid Howells bool send_pages; /* T if data from mapping should be sent */ 97d001648eSDavid Howells bool need_attention; /* T if RxRPC poked us */ 9856ff9c83SDavid Howells bool async; /* T if asynchronous */ 9908e0e7c8SDavid Howells u16 service_id; /* RxRPC service ID to call */ 10008e0e7c8SDavid Howells __be16 port; /* target UDP port */ 10150a2c953SDavid Howells u32 operation_ID; /* operation ID for an incoming call */ 10208e0e7c8SDavid Howells u32 count; /* count for use in unmarshalling */ 10308e0e7c8SDavid Howells __be32 tmp; /* place to extract temporary data */ 10431143d5dSDavid Howells afs_dataversion_t store_version; /* updated version expected from store */ 10508e0e7c8SDavid Howells }; 10608e0e7c8SDavid Howells 10708e0e7c8SDavid Howells struct afs_call_type { 10800d3b7a4SDavid Howells const char *name; 10900d3b7a4SDavid Howells 11008e0e7c8SDavid Howells /* deliver request or reply data to an call 11108e0e7c8SDavid Howells * - returning an error will cause the call to be aborted 11208e0e7c8SDavid Howells */ 113d001648eSDavid Howells int (*deliver)(struct afs_call *call); 11408e0e7c8SDavid Howells 11508e0e7c8SDavid Howells /* map an abort code to an error number */ 11608e0e7c8SDavid Howells int (*abort_to_error)(u32 abort_code); 11708e0e7c8SDavid Howells 11808e0e7c8SDavid Howells /* clean up a call */ 11908e0e7c8SDavid Howells void (*destructor)(struct afs_call *call); 120341f741fSDavid Howells 121341f741fSDavid Howells /* Work function */ 122341f741fSDavid Howells void (*work)(struct work_struct *work); 12308e0e7c8SDavid Howells }; 12408e0e7c8SDavid Howells 12508e0e7c8SDavid Howells /* 126196ee9cdSDavid Howells * Record of an outstanding read operation on a vnode. 127196ee9cdSDavid Howells */ 128196ee9cdSDavid Howells struct afs_read { 129196ee9cdSDavid Howells loff_t pos; /* Where to start reading */ 130196ee9cdSDavid Howells loff_t len; /* How much to read */ 131196ee9cdSDavid Howells loff_t actual_len; /* How much we're actually getting */ 132196ee9cdSDavid Howells atomic_t usage; 133196ee9cdSDavid Howells unsigned int remain; /* Amount remaining */ 134196ee9cdSDavid Howells unsigned int index; /* Which page we're reading into */ 135196ee9cdSDavid Howells unsigned int pg_offset; /* Offset in page we're at */ 136196ee9cdSDavid Howells unsigned int nr_pages; 137196ee9cdSDavid Howells void (*page_done)(struct afs_call *, struct afs_read *); 138196ee9cdSDavid Howells struct page *pages[]; 139196ee9cdSDavid Howells }; 140196ee9cdSDavid Howells 141196ee9cdSDavid Howells /* 14231143d5dSDavid Howells * record of an outstanding writeback on a vnode 14331143d5dSDavid Howells */ 14431143d5dSDavid Howells struct afs_writeback { 14531143d5dSDavid Howells struct list_head link; /* link in vnode->writebacks */ 14631143d5dSDavid Howells struct work_struct writer; /* work item to perform the writeback */ 14731143d5dSDavid Howells struct afs_vnode *vnode; /* vnode to which this write applies */ 14831143d5dSDavid Howells struct key *key; /* owner of this write */ 14931143d5dSDavid Howells wait_queue_head_t waitq; /* completion and ready wait queue */ 15031143d5dSDavid Howells pgoff_t first; /* first page in batch */ 15131143d5dSDavid Howells pgoff_t point; /* last page in current store op */ 15231143d5dSDavid Howells pgoff_t last; /* last page in batch (inclusive) */ 15331143d5dSDavid Howells unsigned offset_first; /* offset into first page of start of write */ 15431143d5dSDavid Howells unsigned to_last; /* offset into last page of end of write */ 15531143d5dSDavid Howells int num_conflicts; /* count of conflicting writes in list */ 15631143d5dSDavid Howells int usage; 15731143d5dSDavid Howells bool conflicts; /* T if has dependent conflicts */ 15831143d5dSDavid Howells enum { 15931143d5dSDavid Howells AFS_WBACK_SYNCING, /* synchronisation being performed */ 16031143d5dSDavid Howells AFS_WBACK_PENDING, /* write pending */ 16131143d5dSDavid Howells AFS_WBACK_CONFLICTING, /* conflicting writes posted */ 16231143d5dSDavid Howells AFS_WBACK_WRITING, /* writing back */ 16331143d5dSDavid Howells AFS_WBACK_COMPLETE /* the writeback record has been unlinked */ 16431143d5dSDavid Howells } state __attribute__((packed)); 16531143d5dSDavid Howells }; 16631143d5dSDavid Howells 16731143d5dSDavid Howells /* 16808e0e7c8SDavid Howells * AFS superblock private data 16908e0e7c8SDavid Howells * - there's one superblock per volume 17008e0e7c8SDavid Howells */ 17108e0e7c8SDavid Howells struct afs_super_info { 17208e0e7c8SDavid Howells struct afs_volume *volume; /* volume record */ 17308e0e7c8SDavid Howells char rwparent; /* T if parent is R/W AFS volume */ 17408e0e7c8SDavid Howells }; 17508e0e7c8SDavid Howells 17608e0e7c8SDavid Howells static inline struct afs_super_info *AFS_FS_S(struct super_block *sb) 17708e0e7c8SDavid Howells { 17808e0e7c8SDavid Howells return sb->s_fs_info; 17908e0e7c8SDavid Howells } 18008e0e7c8SDavid Howells 18108e0e7c8SDavid Howells extern struct file_system_type afs_fs_type; 18208e0e7c8SDavid Howells 18308e0e7c8SDavid Howells /* 18408e0e7c8SDavid Howells * entry in the cached cell catalogue 18508e0e7c8SDavid Howells */ 18608e0e7c8SDavid Howells struct afs_cache_cell { 18700d3b7a4SDavid Howells char name[AFS_MAXCELLNAME]; /* cell name (padded with NULs) */ 18808e0e7c8SDavid Howells struct in_addr vl_servers[15]; /* cached cell VL servers */ 18908e0e7c8SDavid Howells }; 19008e0e7c8SDavid Howells 19108e0e7c8SDavid Howells /* 19208e0e7c8SDavid Howells * AFS cell record 19308e0e7c8SDavid Howells */ 19408e0e7c8SDavid Howells struct afs_cell { 19508e0e7c8SDavid Howells atomic_t usage; 19608e0e7c8SDavid Howells struct list_head link; /* main cell list link */ 19700d3b7a4SDavid Howells struct key *anonymous_key; /* anonymous user key for this cell */ 19808e0e7c8SDavid Howells struct list_head proc_link; /* /proc cell list link */ 1999b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 2009b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 2011da177e4SLinus Torvalds #endif 2021da177e4SLinus Torvalds 20308e0e7c8SDavid Howells /* server record management */ 20408e0e7c8SDavid Howells rwlock_t servers_lock; /* active server list lock */ 20508e0e7c8SDavid Howells struct list_head servers; /* active server list */ 2061da177e4SLinus Torvalds 20708e0e7c8SDavid Howells /* volume location record management */ 20808e0e7c8SDavid Howells struct rw_semaphore vl_sem; /* volume management serialisation semaphore */ 20908e0e7c8SDavid Howells struct list_head vl_list; /* cell's active VL record list */ 21008e0e7c8SDavid Howells spinlock_t vl_lock; /* vl_list lock */ 21108e0e7c8SDavid Howells unsigned short vl_naddrs; /* number of VL servers in addr list */ 21208e0e7c8SDavid Howells unsigned short vl_curr_svix; /* current server index */ 21308e0e7c8SDavid Howells struct in_addr vl_addrs[AFS_CELL_MAX_ADDRS]; /* cell VL server addresses */ 21408e0e7c8SDavid Howells 21508e0e7c8SDavid Howells char name[0]; /* cell name - must go last */ 21608e0e7c8SDavid Howells }; 21708e0e7c8SDavid Howells 21808e0e7c8SDavid Howells /* 21908e0e7c8SDavid Howells * entry in the cached volume location catalogue 22008e0e7c8SDavid Howells */ 22108e0e7c8SDavid Howells struct afs_cache_vlocation { 22200d3b7a4SDavid Howells /* volume name (lowercase, padded with NULs) */ 22300d3b7a4SDavid Howells uint8_t name[AFS_MAXVOLNAME + 1]; 22400d3b7a4SDavid Howells 22508e0e7c8SDavid Howells uint8_t nservers; /* number of entries used in servers[] */ 22608e0e7c8SDavid Howells uint8_t vidmask; /* voltype mask for vid[] */ 22708e0e7c8SDavid Howells uint8_t srvtmask[8]; /* voltype masks for servers[] */ 22808e0e7c8SDavid Howells #define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */ 22908e0e7c8SDavid Howells #define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */ 23008e0e7c8SDavid Howells #define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */ 23108e0e7c8SDavid Howells 23208e0e7c8SDavid Howells afs_volid_t vid[3]; /* volume IDs for R/W, R/O and Bak volumes */ 23308e0e7c8SDavid Howells struct in_addr servers[8]; /* fileserver addresses */ 23408e0e7c8SDavid Howells time_t rtime; /* last retrieval time */ 23508e0e7c8SDavid Howells }; 23608e0e7c8SDavid Howells 23708e0e7c8SDavid Howells /* 23808e0e7c8SDavid Howells * volume -> vnode hash table entry 23908e0e7c8SDavid Howells */ 24008e0e7c8SDavid Howells struct afs_cache_vhash { 24108e0e7c8SDavid Howells afs_voltype_t vtype; /* which volume variation */ 24208e0e7c8SDavid Howells uint8_t hash_bucket; /* which hash bucket this represents */ 24308e0e7c8SDavid Howells } __attribute__((packed)); 24408e0e7c8SDavid Howells 24508e0e7c8SDavid Howells /* 24608e0e7c8SDavid Howells * AFS volume location record 24708e0e7c8SDavid Howells */ 24808e0e7c8SDavid Howells struct afs_vlocation { 24908e0e7c8SDavid Howells atomic_t usage; 25008e0e7c8SDavid Howells time_t time_of_death; /* time at which put reduced usage to 0 */ 25108e0e7c8SDavid Howells struct list_head link; /* link in cell volume location list */ 25208e0e7c8SDavid Howells struct list_head grave; /* link in master graveyard list */ 25308e0e7c8SDavid Howells struct list_head update; /* link in master update list */ 25408e0e7c8SDavid Howells struct afs_cell *cell; /* cell to which volume belongs */ 2559b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 2569b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 25708e0e7c8SDavid Howells #endif 25808e0e7c8SDavid Howells struct afs_cache_vlocation vldb; /* volume information DB record */ 25908e0e7c8SDavid Howells struct afs_volume *vols[3]; /* volume access record pointer (index by type) */ 26008e0e7c8SDavid Howells wait_queue_head_t waitq; /* status change waitqueue */ 26108e0e7c8SDavid Howells time_t update_at; /* time at which record should be updated */ 26239bf0949SDavid S. Miller spinlock_t lock; /* access lock */ 26308e0e7c8SDavid Howells afs_vlocation_state_t state; /* volume location state */ 26408e0e7c8SDavid Howells unsigned short upd_rej_cnt; /* ENOMEDIUM count during update */ 26508e0e7c8SDavid Howells unsigned short upd_busy_cnt; /* EBUSY count during update */ 26608e0e7c8SDavid Howells bool valid; /* T if valid */ 26708e0e7c8SDavid Howells }; 26808e0e7c8SDavid Howells 26908e0e7c8SDavid Howells /* 27008e0e7c8SDavid Howells * AFS fileserver record 27108e0e7c8SDavid Howells */ 27208e0e7c8SDavid Howells struct afs_server { 27308e0e7c8SDavid Howells atomic_t usage; 27408e0e7c8SDavid Howells time_t time_of_death; /* time at which put reduced usage to 0 */ 27508e0e7c8SDavid Howells struct in_addr addr; /* server address */ 27608e0e7c8SDavid Howells struct afs_cell *cell; /* cell in which server resides */ 27708e0e7c8SDavid Howells struct list_head link; /* link in cell's server list */ 27808e0e7c8SDavid Howells struct list_head grave; /* link in master graveyard list */ 27908e0e7c8SDavid Howells struct rb_node master_rb; /* link in master by-addr tree */ 28008e0e7c8SDavid Howells struct rw_semaphore sem; /* access lock */ 28108e0e7c8SDavid Howells 28208e0e7c8SDavid Howells /* file service access */ 28308e0e7c8SDavid Howells struct rb_root fs_vnodes; /* vnodes backed by this server (ordered by FID) */ 28408e0e7c8SDavid Howells unsigned long fs_act_jif; /* time at which last activity occurred */ 28508e0e7c8SDavid Howells unsigned long fs_dead_jif; /* time at which no longer to be considered dead */ 28608e0e7c8SDavid Howells spinlock_t fs_lock; /* access lock */ 28708e0e7c8SDavid Howells int fs_state; /* 0 or reason FS currently marked dead (-errno) */ 28808e0e7c8SDavid Howells 28908e0e7c8SDavid Howells /* callback promise management */ 29008e0e7c8SDavid Howells struct rb_root cb_promises; /* vnode expiration list (ordered earliest first) */ 29108e0e7c8SDavid Howells struct delayed_work cb_updater; /* callback updater */ 29208e0e7c8SDavid Howells struct delayed_work cb_break_work; /* collected break dispatcher */ 29308e0e7c8SDavid Howells wait_queue_head_t cb_break_waitq; /* space available in cb_break waitqueue */ 29408e0e7c8SDavid Howells spinlock_t cb_lock; /* access lock */ 29508e0e7c8SDavid Howells struct afs_callback cb_break[64]; /* ring of callbacks awaiting breaking */ 29608e0e7c8SDavid Howells atomic_t cb_break_n; /* number of pending breaks */ 29708e0e7c8SDavid Howells u8 cb_break_head; /* head of callback breaking ring */ 29808e0e7c8SDavid Howells u8 cb_break_tail; /* tail of callback breaking ring */ 29908e0e7c8SDavid Howells }; 30008e0e7c8SDavid Howells 30108e0e7c8SDavid Howells /* 30208e0e7c8SDavid Howells * AFS volume access record 30308e0e7c8SDavid Howells */ 30408e0e7c8SDavid Howells struct afs_volume { 30508e0e7c8SDavid Howells atomic_t usage; 30608e0e7c8SDavid Howells struct afs_cell *cell; /* cell to which belongs (unrefd ptr) */ 30708e0e7c8SDavid Howells struct afs_vlocation *vlocation; /* volume location */ 3089b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 3099b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 31008e0e7c8SDavid Howells #endif 31108e0e7c8SDavid Howells afs_volid_t vid; /* volume ID */ 31208e0e7c8SDavid Howells afs_voltype_t type; /* type of volume */ 31308e0e7c8SDavid Howells char type_force; /* force volume type (suppress R/O -> R/W) */ 31408e0e7c8SDavid Howells unsigned short nservers; /* number of server slots filled */ 31508e0e7c8SDavid Howells unsigned short rjservers; /* number of servers discarded due to -ENOMEDIUM */ 31608e0e7c8SDavid Howells struct afs_server *servers[8]; /* servers on which volume resides (ordered) */ 31708e0e7c8SDavid Howells struct rw_semaphore server_sem; /* lock for accessing current server */ 318e1da0222SJens Axboe struct backing_dev_info bdi; 31908e0e7c8SDavid Howells }; 32008e0e7c8SDavid Howells 32108e0e7c8SDavid Howells /* 32208e0e7c8SDavid Howells * vnode catalogue entry 32308e0e7c8SDavid Howells */ 32408e0e7c8SDavid Howells struct afs_cache_vnode { 32508e0e7c8SDavid Howells afs_vnodeid_t vnode_id; /* vnode ID */ 32608e0e7c8SDavid Howells unsigned vnode_unique; /* vnode ID uniquifier */ 32708e0e7c8SDavid Howells afs_dataversion_t data_version; /* data version */ 32808e0e7c8SDavid Howells }; 32908e0e7c8SDavid Howells 33008e0e7c8SDavid Howells /* 33108e0e7c8SDavid Howells * AFS inode private data 33208e0e7c8SDavid Howells */ 33308e0e7c8SDavid Howells struct afs_vnode { 33408e0e7c8SDavid Howells struct inode vfs_inode; /* the VFS's inode record */ 33508e0e7c8SDavid Howells 33608e0e7c8SDavid Howells struct afs_volume *volume; /* volume on which vnode resides */ 33708e0e7c8SDavid Howells struct afs_server *server; /* server currently supplying this file */ 33808e0e7c8SDavid Howells struct afs_fid fid; /* the file identifier for this inode */ 33908e0e7c8SDavid Howells struct afs_file_status status; /* AFS status info for this file */ 3409b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 3419b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 34208e0e7c8SDavid Howells #endif 34300d3b7a4SDavid Howells struct afs_permits *permits; /* cache of permits so far obtained */ 34400d3b7a4SDavid Howells struct mutex permits_lock; /* lock for altering permits list */ 345260a9803SDavid Howells struct mutex validate_lock; /* lock for validating this vnode */ 34608e0e7c8SDavid Howells wait_queue_head_t update_waitq; /* status fetch waitqueue */ 347260a9803SDavid Howells int update_cnt; /* number of outstanding ops that will update the 34808e0e7c8SDavid Howells * status */ 34931143d5dSDavid Howells spinlock_t writeback_lock; /* lock for writebacks */ 35008e0e7c8SDavid Howells spinlock_t lock; /* waitqueue/flags lock */ 35108e0e7c8SDavid Howells unsigned long flags; 35208e0e7c8SDavid Howells #define AFS_VNODE_CB_BROKEN 0 /* set if vnode's callback was broken */ 353260a9803SDavid Howells #define AFS_VNODE_UNSET 1 /* set if vnode attributes not yet set */ 35408e0e7c8SDavid Howells #define AFS_VNODE_MODIFIED 2 /* set if vnode's data modified */ 35508e0e7c8SDavid Howells #define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */ 35608e0e7c8SDavid Howells #define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */ 35708e0e7c8SDavid Howells #define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */ 358e8d6c554SDavid Howells #define AFS_VNODE_LOCKING 6 /* set if waiting for lock on vnode */ 359e8d6c554SDavid Howells #define AFS_VNODE_READLOCKED 7 /* set if vnode is read-locked on the server */ 360e8d6c554SDavid Howells #define AFS_VNODE_WRITELOCKED 8 /* set if vnode is write-locked on the server */ 361e8d6c554SDavid Howells #define AFS_VNODE_UNLOCKING 9 /* set if vnode is being unlocked on the server */ 362bec5eb61Swanglei #define AFS_VNODE_AUTOCELL 10 /* set if Vnode is an auto mount point */ 363bec5eb61Swanglei #define AFS_VNODE_PSEUDODIR 11 /* set if Vnode is a pseudo directory */ 36408e0e7c8SDavid Howells 36500d3b7a4SDavid Howells long acl_order; /* ACL check count (callback break count) */ 36600d3b7a4SDavid Howells 36731143d5dSDavid Howells struct list_head writebacks; /* alterations in pagecache that need writing */ 368e8d6c554SDavid Howells struct list_head pending_locks; /* locks waiting to be granted */ 369e8d6c554SDavid Howells struct list_head granted_locks; /* locks granted on this file */ 370e8d6c554SDavid Howells struct delayed_work lock_work; /* work to be done in locking */ 371e8d6c554SDavid Howells struct key *unlock_key; /* key to be used in unlocking */ 37231143d5dSDavid Howells 37308e0e7c8SDavid Howells /* outstanding callback notification on this file */ 37408e0e7c8SDavid Howells struct rb_node server_rb; /* link in server->fs_vnodes */ 37508e0e7c8SDavid Howells struct rb_node cb_promise; /* link in server->cb_promises */ 37608e0e7c8SDavid Howells struct work_struct cb_broken_work; /* work to be done on callback break */ 37708e0e7c8SDavid Howells time_t cb_expires; /* time at which callback expires */ 37808e0e7c8SDavid Howells time_t cb_expires_at; /* time used to order cb_promise */ 37908e0e7c8SDavid Howells unsigned cb_version; /* callback version */ 38008e0e7c8SDavid Howells unsigned cb_expiry; /* callback expiry time */ 38108e0e7c8SDavid Howells afs_callback_type_t cb_type; /* type of callback */ 38208e0e7c8SDavid Howells bool cb_promised; /* true if promise still holds */ 38308e0e7c8SDavid Howells }; 38408e0e7c8SDavid Howells 38500d3b7a4SDavid Howells /* 38600d3b7a4SDavid Howells * cached security record for one user's attempt to access a vnode 38700d3b7a4SDavid Howells */ 38800d3b7a4SDavid Howells struct afs_permit { 38900d3b7a4SDavid Howells struct key *key; /* RxRPC ticket holding a security context */ 39000d3b7a4SDavid Howells afs_access_t access_mask; /* access mask for this key */ 39100d3b7a4SDavid Howells }; 39200d3b7a4SDavid Howells 39300d3b7a4SDavid Howells /* 39400d3b7a4SDavid Howells * cache of security records from attempts to access a vnode 39500d3b7a4SDavid Howells */ 39600d3b7a4SDavid Howells struct afs_permits { 39700d3b7a4SDavid Howells struct rcu_head rcu; /* disposal procedure */ 39800d3b7a4SDavid Howells int count; /* number of records */ 39900d3b7a4SDavid Howells struct afs_permit permits[0]; /* the permits so far examined */ 40000d3b7a4SDavid Howells }; 40100d3b7a4SDavid Howells 402b908fe6bSDavid Howells /* 403b908fe6bSDavid Howells * record of one of a system's set of network interfaces 404b908fe6bSDavid Howells */ 405b908fe6bSDavid Howells struct afs_interface { 406b908fe6bSDavid Howells struct in_addr address; /* IPv4 address bound to interface */ 407b908fe6bSDavid Howells struct in_addr netmask; /* netmask applied to address */ 408b908fe6bSDavid Howells unsigned mtu; /* MTU of interface */ 409b908fe6bSDavid Howells }; 410b908fe6bSDavid Howells 41108e0e7c8SDavid Howells /*****************************************************************************/ 41208e0e7c8SDavid Howells /* 4139b3f26c9SDavid Howells * cache.c 4149b3f26c9SDavid Howells */ 4159b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 4169b3f26c9SDavid Howells extern struct fscache_netfs afs_cache_netfs; 4179b3f26c9SDavid Howells extern struct fscache_cookie_def afs_cell_cache_index_def; 4189b3f26c9SDavid Howells extern struct fscache_cookie_def afs_vlocation_cache_index_def; 4199b3f26c9SDavid Howells extern struct fscache_cookie_def afs_volume_cache_index_def; 4209b3f26c9SDavid Howells extern struct fscache_cookie_def afs_vnode_cache_index_def; 4219b3f26c9SDavid Howells #else 4229b3f26c9SDavid Howells #define afs_cell_cache_index_def (*(struct fscache_cookie_def *) NULL) 4239b3f26c9SDavid Howells #define afs_vlocation_cache_index_def (*(struct fscache_cookie_def *) NULL) 4249b3f26c9SDavid Howells #define afs_volume_cache_index_def (*(struct fscache_cookie_def *) NULL) 4259b3f26c9SDavid Howells #define afs_vnode_cache_index_def (*(struct fscache_cookie_def *) NULL) 4269b3f26c9SDavid Howells #endif 4279b3f26c9SDavid Howells 4289b3f26c9SDavid Howells /* 42908e0e7c8SDavid Howells * callback.c 43008e0e7c8SDavid Howells */ 43108e0e7c8SDavid Howells extern void afs_init_callback_state(struct afs_server *); 43208e0e7c8SDavid Howells extern void afs_broken_callback_work(struct work_struct *); 43308e0e7c8SDavid Howells extern void afs_break_callbacks(struct afs_server *, size_t, 43408e0e7c8SDavid Howells struct afs_callback[]); 435260a9803SDavid Howells extern void afs_discard_callback_on_delete(struct afs_vnode *); 43608e0e7c8SDavid Howells extern void afs_give_up_callback(struct afs_vnode *); 43708e0e7c8SDavid Howells extern void afs_dispatch_give_up_callbacks(struct work_struct *); 43808e0e7c8SDavid Howells extern void afs_flush_callback_breaks(struct afs_server *); 43908e0e7c8SDavid Howells extern int __init afs_callback_update_init(void); 440fbb3fcbaSDavid Howells extern void afs_callback_update_kill(void); 4411da177e4SLinus Torvalds 4421da177e4SLinus Torvalds /* 4431da177e4SLinus Torvalds * cell.c 4441da177e4SLinus Torvalds */ 4451da177e4SLinus Torvalds extern struct rw_semaphore afs_proc_cells_sem; 4461da177e4SLinus Torvalds extern struct list_head afs_proc_cells; 4471da177e4SLinus Torvalds 44808e0e7c8SDavid Howells #define afs_get_cell(C) do { atomic_inc(&(C)->usage); } while(0) 44908e0e7c8SDavid Howells extern int afs_cell_init(char *); 450bec5eb61Swanglei extern struct afs_cell *afs_cell_create(const char *, unsigned, char *, bool); 451bec5eb61Swanglei extern struct afs_cell *afs_cell_lookup(const char *, unsigned, bool); 45208e0e7c8SDavid Howells extern struct afs_cell *afs_grab_cell(struct afs_cell *); 45308e0e7c8SDavid Howells extern void afs_put_cell(struct afs_cell *); 45408e0e7c8SDavid Howells extern void afs_cell_purge(void); 45508e0e7c8SDavid Howells 45608e0e7c8SDavid Howells /* 45708e0e7c8SDavid Howells * cmservice.c 45808e0e7c8SDavid Howells */ 45908e0e7c8SDavid Howells extern bool afs_cm_incoming_call(struct afs_call *); 46008e0e7c8SDavid Howells 4611da177e4SLinus Torvalds /* 4621da177e4SLinus Torvalds * dir.c 4631da177e4SLinus Torvalds */ 464754661f1SArjan van de Ven extern const struct inode_operations afs_dir_inode_operations; 465d61dcce2SAl Viro extern const struct dentry_operations afs_fs_dentry_operations; 4664b6f5d20SArjan van de Ven extern const struct file_operations afs_dir_file_operations; 4671da177e4SLinus Torvalds 4681da177e4SLinus Torvalds /* 4691da177e4SLinus Torvalds * file.c 4701da177e4SLinus Torvalds */ 471f5e54d6eSChristoph Hellwig extern const struct address_space_operations afs_fs_aops; 472754661f1SArjan van de Ven extern const struct inode_operations afs_file_inode_operations; 47300d3b7a4SDavid Howells extern const struct file_operations afs_file_operations; 47400d3b7a4SDavid Howells 47500d3b7a4SDavid Howells extern int afs_open(struct inode *, struct file *); 47600d3b7a4SDavid Howells extern int afs_release(struct inode *, struct file *); 477f6d335c0SAl Viro extern int afs_page_filler(void *, struct page *); 478196ee9cdSDavid Howells extern void afs_put_read(struct afs_read *); 4791da177e4SLinus Torvalds 4801da177e4SLinus Torvalds /* 481e8d6c554SDavid Howells * flock.c 482e8d6c554SDavid Howells */ 483e8d6c554SDavid Howells extern void __exit afs_kill_lock_manager(void); 484e8d6c554SDavid Howells extern void afs_lock_work(struct work_struct *); 485e8d6c554SDavid Howells extern void afs_lock_may_be_available(struct afs_vnode *); 486e8d6c554SDavid Howells extern int afs_lock(struct file *, int, struct file_lock *); 487e8d6c554SDavid Howells extern int afs_flock(struct file *, int, struct file_lock *); 488e8d6c554SDavid Howells 489e8d6c554SDavid Howells /* 49008e0e7c8SDavid Howells * fsclient.c 49108e0e7c8SDavid Howells */ 49200d3b7a4SDavid Howells extern int afs_fs_fetch_file_status(struct afs_server *, struct key *, 49300d3b7a4SDavid Howells struct afs_vnode *, struct afs_volsync *, 49456ff9c83SDavid Howells bool); 49556ff9c83SDavid Howells extern int afs_fs_give_up_callbacks(struct afs_server *, bool); 49600d3b7a4SDavid Howells extern int afs_fs_fetch_data(struct afs_server *, struct key *, 49756ff9c83SDavid Howells struct afs_vnode *, struct afs_read *, bool); 498260a9803SDavid Howells extern int afs_fs_create(struct afs_server *, struct key *, 499260a9803SDavid Howells struct afs_vnode *, const char *, umode_t, 500260a9803SDavid Howells struct afs_fid *, struct afs_file_status *, 50156ff9c83SDavid Howells struct afs_callback *, bool); 502260a9803SDavid Howells extern int afs_fs_remove(struct afs_server *, struct key *, 50356ff9c83SDavid Howells struct afs_vnode *, const char *, bool, bool); 504260a9803SDavid Howells extern int afs_fs_link(struct afs_server *, struct key *, struct afs_vnode *, 50556ff9c83SDavid Howells struct afs_vnode *, const char *, bool); 506260a9803SDavid Howells extern int afs_fs_symlink(struct afs_server *, struct key *, 507260a9803SDavid Howells struct afs_vnode *, const char *, const char *, 50856ff9c83SDavid Howells struct afs_fid *, struct afs_file_status *, bool); 509260a9803SDavid Howells extern int afs_fs_rename(struct afs_server *, struct key *, 510260a9803SDavid Howells struct afs_vnode *, const char *, 51156ff9c83SDavid Howells struct afs_vnode *, const char *, bool); 51231143d5dSDavid Howells extern int afs_fs_store_data(struct afs_server *, struct afs_writeback *, 51356ff9c83SDavid Howells pgoff_t, pgoff_t, unsigned, unsigned, bool); 51431143d5dSDavid Howells extern int afs_fs_setattr(struct afs_server *, struct key *, 51556ff9c83SDavid Howells struct afs_vnode *, struct iattr *, bool); 51645222b9eSDavid Howells extern int afs_fs_get_volume_status(struct afs_server *, struct key *, 51745222b9eSDavid Howells struct afs_vnode *, 51856ff9c83SDavid Howells struct afs_volume_status *, bool); 519e8d6c554SDavid Howells extern int afs_fs_set_lock(struct afs_server *, struct key *, 52056ff9c83SDavid Howells struct afs_vnode *, afs_lock_type_t, bool); 521e8d6c554SDavid Howells extern int afs_fs_extend_lock(struct afs_server *, struct key *, 52256ff9c83SDavid Howells struct afs_vnode *, bool); 523e8d6c554SDavid Howells extern int afs_fs_release_lock(struct afs_server *, struct key *, 52456ff9c83SDavid Howells struct afs_vnode *, bool); 52508e0e7c8SDavid Howells 52608e0e7c8SDavid Howells /* 5271da177e4SLinus Torvalds * inode.c 5281da177e4SLinus Torvalds */ 529bec5eb61Swanglei extern struct inode *afs_iget_autocell(struct inode *, const char *, int, 530bec5eb61Swanglei struct key *); 53100d3b7a4SDavid Howells extern struct inode *afs_iget(struct super_block *, struct key *, 532260a9803SDavid Howells struct afs_fid *, struct afs_file_status *, 533260a9803SDavid Howells struct afs_callback *); 534416351f2SDavid Howells extern void afs_zap_data(struct afs_vnode *); 535260a9803SDavid Howells extern int afs_validate(struct afs_vnode *, struct key *); 536416351f2SDavid Howells extern int afs_getattr(struct vfsmount *, struct dentry *, struct kstat *); 53731143d5dSDavid Howells extern int afs_setattr(struct dentry *, struct iattr *); 538b57922d9SAl Viro extern void afs_evict_inode(struct inode *); 539bec5eb61Swanglei extern int afs_drop_inode(struct inode *); 5401da177e4SLinus Torvalds 5411da177e4SLinus Torvalds /* 5421da177e4SLinus Torvalds * main.c 5431da177e4SLinus Torvalds */ 5440ad53eeeSTejun Heo extern struct workqueue_struct *afs_wq; 545ff548773SDavid Howells extern struct uuid_v1 afs_uuid; 5461da177e4SLinus Torvalds 5471da177e4SLinus Torvalds /* 54808e0e7c8SDavid Howells * misc.c 54908e0e7c8SDavid Howells */ 55008e0e7c8SDavid Howells extern int afs_abort_to_error(u32); 55108e0e7c8SDavid Howells 55208e0e7c8SDavid Howells /* 5531da177e4SLinus Torvalds * mntpt.c 5541da177e4SLinus Torvalds */ 555754661f1SArjan van de Ven extern const struct inode_operations afs_mntpt_inode_operations; 556bec5eb61Swanglei extern const struct inode_operations afs_autocell_inode_operations; 5574b6f5d20SArjan van de Ven extern const struct file_operations afs_mntpt_file_operations; 5581da177e4SLinus Torvalds 559d18610b0SDavid Howells extern struct vfsmount *afs_d_automount(struct path *); 56000d3b7a4SDavid Howells extern int afs_mntpt_check_symlink(struct afs_vnode *, struct key *); 56108e0e7c8SDavid Howells extern void afs_mntpt_kill_timer(void); 5621da177e4SLinus Torvalds 5631da177e4SLinus Torvalds /* 564b4db2b35SArnd Bergmann * netdevices.c 565b4db2b35SArnd Bergmann */ 566b4db2b35SArnd Bergmann extern int afs_get_ipv4_interfaces(struct afs_interface *, size_t, bool); 567b4db2b35SArnd Bergmann 568b4db2b35SArnd Bergmann /* 5691da177e4SLinus Torvalds * proc.c 5701da177e4SLinus Torvalds */ 5711da177e4SLinus Torvalds extern int afs_proc_init(void); 5721da177e4SLinus Torvalds extern void afs_proc_cleanup(void); 573ec26815aSDavid Howells extern int afs_proc_cell_setup(struct afs_cell *); 574ec26815aSDavid Howells extern void afs_proc_cell_remove(struct afs_cell *); 5751da177e4SLinus Torvalds 57608e0e7c8SDavid Howells /* 57708e0e7c8SDavid Howells * rxrpc.c 57808e0e7c8SDavid Howells */ 5798324f0bcSDavid Howells extern struct socket *afs_socket; 580341f741fSDavid Howells extern atomic_t afs_outstanding_calls; 5818324f0bcSDavid Howells 58208e0e7c8SDavid Howells extern int afs_open_socket(void); 58308e0e7c8SDavid Howells extern void afs_close_socket(void); 584341f741fSDavid Howells extern void afs_put_call(struct afs_call *); 585341f741fSDavid Howells extern int afs_queue_call_work(struct afs_call *); 58656ff9c83SDavid Howells extern int afs_make_call(struct in_addr *, struct afs_call *, gfp_t, bool); 58708e0e7c8SDavid Howells extern struct afs_call *afs_alloc_flat_call(const struct afs_call_type *, 58808e0e7c8SDavid Howells size_t, size_t); 58908e0e7c8SDavid Howells extern void afs_flat_call_destructor(struct afs_call *); 59008e0e7c8SDavid Howells extern void afs_send_empty_reply(struct afs_call *); 591b908fe6bSDavid Howells extern void afs_send_simple_reply(struct afs_call *, const void *, size_t); 592d001648eSDavid Howells extern int afs_extract_data(struct afs_call *, void *, size_t, bool); 59308e0e7c8SDavid Howells 594d001648eSDavid Howells static inline int afs_transfer_reply(struct afs_call *call) 595372ee163SDavid Howells { 596d001648eSDavid Howells return afs_extract_data(call, call->buffer, call->reply_max, false); 597372ee163SDavid Howells } 598372ee163SDavid Howells 59908e0e7c8SDavid Howells /* 60000d3b7a4SDavid Howells * security.c 60100d3b7a4SDavid Howells */ 60200d3b7a4SDavid Howells extern void afs_clear_permits(struct afs_vnode *); 60300d3b7a4SDavid Howells extern void afs_cache_permit(struct afs_vnode *, struct key *, long); 604416351f2SDavid Howells extern void afs_zap_permits(struct rcu_head *); 60500d3b7a4SDavid Howells extern struct key *afs_request_key(struct afs_cell *); 60610556cb2SAl Viro extern int afs_permission(struct inode *, int); 60700d3b7a4SDavid Howells 60800d3b7a4SDavid Howells /* 60908e0e7c8SDavid Howells * server.c 61008e0e7c8SDavid Howells */ 61108e0e7c8SDavid Howells extern spinlock_t afs_server_peer_lock; 61208e0e7c8SDavid Howells 613260a9803SDavid Howells #define afs_get_server(S) \ 614260a9803SDavid Howells do { \ 615260a9803SDavid Howells _debug("GET SERVER %d", atomic_read(&(S)->usage)); \ 616260a9803SDavid Howells atomic_inc(&(S)->usage); \ 617260a9803SDavid Howells } while(0) 61808e0e7c8SDavid Howells 61908e0e7c8SDavid Howells extern struct afs_server *afs_lookup_server(struct afs_cell *, 62008e0e7c8SDavid Howells const struct in_addr *); 6218324f0bcSDavid Howells extern struct afs_server *afs_find_server(const struct sockaddr_rxrpc *); 62208e0e7c8SDavid Howells extern void afs_put_server(struct afs_server *); 62308e0e7c8SDavid Howells extern void __exit afs_purge_servers(void); 62408e0e7c8SDavid Howells 62508e0e7c8SDavid Howells /* 62600d3b7a4SDavid Howells * super.c 62700d3b7a4SDavid Howells */ 62800d3b7a4SDavid Howells extern int afs_fs_init(void); 62900d3b7a4SDavid Howells extern void afs_fs_exit(void); 63000d3b7a4SDavid Howells 63100d3b7a4SDavid Howells /* 63208e0e7c8SDavid Howells * vlclient.c 63308e0e7c8SDavid Howells */ 63400d3b7a4SDavid Howells extern int afs_vl_get_entry_by_name(struct in_addr *, struct key *, 63500d3b7a4SDavid Howells const char *, struct afs_cache_vlocation *, 63656ff9c83SDavid Howells bool); 63700d3b7a4SDavid Howells extern int afs_vl_get_entry_by_id(struct in_addr *, struct key *, 63800d3b7a4SDavid Howells afs_volid_t, afs_voltype_t, 63956ff9c83SDavid Howells struct afs_cache_vlocation *, bool); 64008e0e7c8SDavid Howells 64108e0e7c8SDavid Howells /* 64208e0e7c8SDavid Howells * vlocation.c 64308e0e7c8SDavid Howells */ 64408e0e7c8SDavid Howells #define afs_get_vlocation(V) do { atomic_inc(&(V)->usage); } while(0) 64508e0e7c8SDavid Howells 64608e0e7c8SDavid Howells extern int __init afs_vlocation_update_init(void); 64708e0e7c8SDavid Howells extern struct afs_vlocation *afs_vlocation_lookup(struct afs_cell *, 64800d3b7a4SDavid Howells struct key *, 64908e0e7c8SDavid Howells const char *, size_t); 65008e0e7c8SDavid Howells extern void afs_put_vlocation(struct afs_vlocation *); 651fbb3fcbaSDavid Howells extern void afs_vlocation_purge(void); 65208e0e7c8SDavid Howells 65308e0e7c8SDavid Howells /* 65408e0e7c8SDavid Howells * vnode.c 65508e0e7c8SDavid Howells */ 65608e0e7c8SDavid Howells static inline struct afs_vnode *AFS_FS_I(struct inode *inode) 65708e0e7c8SDavid Howells { 65808e0e7c8SDavid Howells return container_of(inode, struct afs_vnode, vfs_inode); 65908e0e7c8SDavid Howells } 66008e0e7c8SDavid Howells 66108e0e7c8SDavid Howells static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode) 66208e0e7c8SDavid Howells { 66308e0e7c8SDavid Howells return &vnode->vfs_inode; 66408e0e7c8SDavid Howells } 66508e0e7c8SDavid Howells 666260a9803SDavid Howells extern void afs_vnode_finalise_status_update(struct afs_vnode *, 667260a9803SDavid Howells struct afs_server *); 66800d3b7a4SDavid Howells extern int afs_vnode_fetch_status(struct afs_vnode *, struct afs_vnode *, 66900d3b7a4SDavid Howells struct key *); 67000d3b7a4SDavid Howells extern int afs_vnode_fetch_data(struct afs_vnode *, struct key *, 671196ee9cdSDavid Howells struct afs_read *); 672260a9803SDavid Howells extern int afs_vnode_create(struct afs_vnode *, struct key *, const char *, 673260a9803SDavid Howells umode_t, struct afs_fid *, struct afs_file_status *, 674260a9803SDavid Howells struct afs_callback *, struct afs_server **); 675260a9803SDavid Howells extern int afs_vnode_remove(struct afs_vnode *, struct key *, const char *, 676260a9803SDavid Howells bool); 677260a9803SDavid Howells extern int afs_vnode_link(struct afs_vnode *, struct afs_vnode *, struct key *, 678260a9803SDavid Howells const char *); 679260a9803SDavid Howells extern int afs_vnode_symlink(struct afs_vnode *, struct key *, const char *, 680260a9803SDavid Howells const char *, struct afs_fid *, 681260a9803SDavid Howells struct afs_file_status *, struct afs_server **); 682260a9803SDavid Howells extern int afs_vnode_rename(struct afs_vnode *, struct afs_vnode *, 683260a9803SDavid Howells struct key *, const char *, const char *); 68431143d5dSDavid Howells extern int afs_vnode_store_data(struct afs_writeback *, pgoff_t, pgoff_t, 68531143d5dSDavid Howells unsigned, unsigned); 68631143d5dSDavid Howells extern int afs_vnode_setattr(struct afs_vnode *, struct key *, struct iattr *); 68745222b9eSDavid Howells extern int afs_vnode_get_volume_status(struct afs_vnode *, struct key *, 68845222b9eSDavid Howells struct afs_volume_status *); 689e8d6c554SDavid Howells extern int afs_vnode_set_lock(struct afs_vnode *, struct key *, 690e8d6c554SDavid Howells afs_lock_type_t); 691e8d6c554SDavid Howells extern int afs_vnode_extend_lock(struct afs_vnode *, struct key *); 692e8d6c554SDavid Howells extern int afs_vnode_release_lock(struct afs_vnode *, struct key *); 69308e0e7c8SDavid Howells 69408e0e7c8SDavid Howells /* 69508e0e7c8SDavid Howells * volume.c 69608e0e7c8SDavid Howells */ 69708e0e7c8SDavid Howells #define afs_get_volume(V) do { atomic_inc(&(V)->usage); } while(0) 69808e0e7c8SDavid Howells 69908e0e7c8SDavid Howells extern void afs_put_volume(struct afs_volume *); 70000d3b7a4SDavid Howells extern struct afs_volume *afs_volume_lookup(struct afs_mount_params *); 70108e0e7c8SDavid Howells extern struct afs_server *afs_volume_pick_fileserver(struct afs_vnode *); 70208e0e7c8SDavid Howells extern int afs_volume_release_fileserver(struct afs_vnode *, 70308e0e7c8SDavid Howells struct afs_server *, int); 70408e0e7c8SDavid Howells 70531143d5dSDavid Howells /* 70631143d5dSDavid Howells * write.c 70731143d5dSDavid Howells */ 70831143d5dSDavid Howells extern int afs_set_page_dirty(struct page *); 70931143d5dSDavid Howells extern void afs_put_writeback(struct afs_writeback *); 71015b4650eSNick Piggin extern int afs_write_begin(struct file *file, struct address_space *mapping, 71115b4650eSNick Piggin loff_t pos, unsigned len, unsigned flags, 71215b4650eSNick Piggin struct page **pagep, void **fsdata); 71315b4650eSNick Piggin extern int afs_write_end(struct file *file, struct address_space *mapping, 71415b4650eSNick Piggin loff_t pos, unsigned len, unsigned copied, 71515b4650eSNick Piggin struct page *page, void *fsdata); 71631143d5dSDavid Howells extern int afs_writepage(struct page *, struct writeback_control *); 71731143d5dSDavid Howells extern int afs_writepages(struct address_space *, struct writeback_control *); 71831143d5dSDavid Howells extern void afs_pages_written_back(struct afs_vnode *, struct afs_call *); 71950b5551dSAl Viro extern ssize_t afs_file_write(struct kiocb *, struct iov_iter *); 72031143d5dSDavid Howells extern int afs_writeback_all(struct afs_vnode *); 72102c24a82SJosef Bacik extern int afs_fsync(struct file *, loff_t, loff_t, int); 72231143d5dSDavid Howells 72331143d5dSDavid Howells 72408e0e7c8SDavid Howells /*****************************************************************************/ 72508e0e7c8SDavid Howells /* 72608e0e7c8SDavid Howells * debug tracing 72708e0e7c8SDavid Howells */ 7288e8d7f13SDavid Howells #include <trace/events/afs.h> 7298e8d7f13SDavid Howells 73008e0e7c8SDavid Howells extern unsigned afs_debug; 73108e0e7c8SDavid Howells 73208e0e7c8SDavid Howells #define dbgprintk(FMT,...) \ 733ad16df84SSven Schnelle printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__) 73408e0e7c8SDavid Howells 735530b6412SHarvey Harrison #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__) 736530b6412SHarvey Harrison #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) 73708e0e7c8SDavid Howells #define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__) 73808e0e7c8SDavid Howells 73908e0e7c8SDavid Howells 74008e0e7c8SDavid Howells #if defined(__KDEBUG) 74108e0e7c8SDavid Howells #define _enter(FMT,...) kenter(FMT,##__VA_ARGS__) 74208e0e7c8SDavid Howells #define _leave(FMT,...) kleave(FMT,##__VA_ARGS__) 74308e0e7c8SDavid Howells #define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__) 74408e0e7c8SDavid Howells 74508e0e7c8SDavid Howells #elif defined(CONFIG_AFS_DEBUG) 74608e0e7c8SDavid Howells #define AFS_DEBUG_KENTER 0x01 74708e0e7c8SDavid Howells #define AFS_DEBUG_KLEAVE 0x02 74808e0e7c8SDavid Howells #define AFS_DEBUG_KDEBUG 0x04 74908e0e7c8SDavid Howells 75008e0e7c8SDavid Howells #define _enter(FMT,...) \ 75108e0e7c8SDavid Howells do { \ 75208e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \ 75308e0e7c8SDavid Howells kenter(FMT,##__VA_ARGS__); \ 75408e0e7c8SDavid Howells } while (0) 75508e0e7c8SDavid Howells 75608e0e7c8SDavid Howells #define _leave(FMT,...) \ 75708e0e7c8SDavid Howells do { \ 75808e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \ 75908e0e7c8SDavid Howells kleave(FMT,##__VA_ARGS__); \ 76008e0e7c8SDavid Howells } while (0) 76108e0e7c8SDavid Howells 76208e0e7c8SDavid Howells #define _debug(FMT,...) \ 76308e0e7c8SDavid Howells do { \ 76408e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \ 76508e0e7c8SDavid Howells kdebug(FMT,##__VA_ARGS__); \ 76608e0e7c8SDavid Howells } while (0) 76708e0e7c8SDavid Howells 76808e0e7c8SDavid Howells #else 76912fdff3fSDavid Howells #define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__) 77012fdff3fSDavid Howells #define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) 77112fdff3fSDavid Howells #define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__) 77208e0e7c8SDavid Howells #endif 77308e0e7c8SDavid Howells 77408e0e7c8SDavid Howells /* 77508e0e7c8SDavid Howells * debug assertion checking 77608e0e7c8SDavid Howells */ 77708e0e7c8SDavid Howells #if 1 // defined(__KDEBUGALL) 77808e0e7c8SDavid Howells 77908e0e7c8SDavid Howells #define ASSERT(X) \ 78008e0e7c8SDavid Howells do { \ 78108e0e7c8SDavid Howells if (unlikely(!(X))) { \ 78208e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 78308e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 78408e0e7c8SDavid Howells BUG(); \ 78508e0e7c8SDavid Howells } \ 78608e0e7c8SDavid Howells } while(0) 78708e0e7c8SDavid Howells 78808e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y) \ 78908e0e7c8SDavid Howells do { \ 79008e0e7c8SDavid Howells if (unlikely(!((X) OP (Y)))) { \ 79108e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 79208e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 79308e0e7c8SDavid Howells printk(KERN_ERR "%lu " #OP " %lu is false\n", \ 79408e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 79508e0e7c8SDavid Howells printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ 79608e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 79708e0e7c8SDavid Howells BUG(); \ 79808e0e7c8SDavid Howells } \ 79908e0e7c8SDavid Howells } while(0) 80008e0e7c8SDavid Howells 801416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H) \ 802416351f2SDavid Howells do { \ 803416351f2SDavid Howells if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) { \ 804416351f2SDavid Howells printk(KERN_ERR "\n"); \ 805416351f2SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 806416351f2SDavid Howells printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n", \ 807416351f2SDavid Howells (unsigned long)(L), (unsigned long)(N), \ 808416351f2SDavid Howells (unsigned long)(H)); \ 809416351f2SDavid Howells printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \ 810416351f2SDavid Howells (unsigned long)(L), (unsigned long)(N), \ 811416351f2SDavid Howells (unsigned long)(H)); \ 812416351f2SDavid Howells BUG(); \ 813416351f2SDavid Howells } \ 814416351f2SDavid Howells } while(0) 815416351f2SDavid Howells 81608e0e7c8SDavid Howells #define ASSERTIF(C, X) \ 81708e0e7c8SDavid Howells do { \ 81808e0e7c8SDavid Howells if (unlikely((C) && !(X))) { \ 81908e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 82008e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 82108e0e7c8SDavid Howells BUG(); \ 82208e0e7c8SDavid Howells } \ 82308e0e7c8SDavid Howells } while(0) 82408e0e7c8SDavid Howells 82508e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y) \ 82608e0e7c8SDavid Howells do { \ 82708e0e7c8SDavid Howells if (unlikely((C) && !((X) OP (Y)))) { \ 82808e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 82908e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 83008e0e7c8SDavid Howells printk(KERN_ERR "%lu " #OP " %lu is false\n", \ 83108e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 83208e0e7c8SDavid Howells printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ 83308e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 83408e0e7c8SDavid Howells BUG(); \ 83508e0e7c8SDavid Howells } \ 83608e0e7c8SDavid Howells } while(0) 83708e0e7c8SDavid Howells 83808e0e7c8SDavid Howells #else 83908e0e7c8SDavid Howells 84008e0e7c8SDavid Howells #define ASSERT(X) \ 84108e0e7c8SDavid Howells do { \ 84208e0e7c8SDavid Howells } while(0) 84308e0e7c8SDavid Howells 84408e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y) \ 84508e0e7c8SDavid Howells do { \ 84608e0e7c8SDavid Howells } while(0) 84708e0e7c8SDavid Howells 848416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H) \ 849416351f2SDavid Howells do { \ 850416351f2SDavid Howells } while(0) 851416351f2SDavid Howells 85208e0e7c8SDavid Howells #define ASSERTIF(C, X) \ 85308e0e7c8SDavid Howells do { \ 85408e0e7c8SDavid Howells } while(0) 85508e0e7c8SDavid Howells 85608e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y) \ 85708e0e7c8SDavid Howells do { \ 85808e0e7c8SDavid Howells } while(0) 85908e0e7c8SDavid Howells 86008e0e7c8SDavid Howells #endif /* __KDEBUGALL */ 861