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/skbuff.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> 2300c541eaSAndrew Morton 2408e0e7c8SDavid Howells #include "afs.h" 2508e0e7c8SDavid Howells #include "afs_vl.h" 2608e0e7c8SDavid Howells 2708e0e7c8SDavid Howells #define AFS_CELL_MAX_ADDRS 15 2808e0e7c8SDavid Howells 2931143d5dSDavid Howells struct pagevec; 3008e0e7c8SDavid Howells struct afs_call; 3108e0e7c8SDavid Howells 3208e0e7c8SDavid Howells typedef enum { 3308e0e7c8SDavid Howells AFS_VL_NEW, /* new, uninitialised record */ 3408e0e7c8SDavid Howells AFS_VL_CREATING, /* creating record */ 3508e0e7c8SDavid Howells AFS_VL_VALID, /* record is pending */ 3608e0e7c8SDavid Howells AFS_VL_NO_VOLUME, /* no such volume available */ 3708e0e7c8SDavid Howells AFS_VL_UPDATING, /* update in progress */ 3808e0e7c8SDavid Howells AFS_VL_VOLUME_DELETED, /* volume was deleted */ 3908e0e7c8SDavid Howells AFS_VL_UNCERTAIN, /* uncertain state (update failed) */ 4008e0e7c8SDavid Howells } __attribute__((packed)) afs_vlocation_state_t; 411da177e4SLinus Torvalds 4200d3b7a4SDavid Howells struct afs_mount_params { 4300d3b7a4SDavid Howells bool rwpath; /* T if the parent should be considered R/W */ 4400d3b7a4SDavid Howells bool force; /* T to force cell type */ 4500d3b7a4SDavid Howells afs_voltype_t type; /* type of volume requested */ 4600d3b7a4SDavid Howells int volnamesz; /* size of volume name */ 4700d3b7a4SDavid Howells const char *volname; /* name of volume to mount */ 4800d3b7a4SDavid Howells struct afs_cell *cell; /* cell in which to find volume */ 4900d3b7a4SDavid Howells struct afs_volume *volume; /* volume record */ 5000d3b7a4SDavid Howells struct key *key; /* key to use for secure mounting */ 5100d3b7a4SDavid Howells }; 5200d3b7a4SDavid Howells 531da177e4SLinus Torvalds /* 5408e0e7c8SDavid Howells * definition of how to wait for the completion of an operation 551da177e4SLinus Torvalds */ 5608e0e7c8SDavid Howells struct afs_wait_mode { 5708e0e7c8SDavid Howells /* RxRPC received message notification */ 5808e0e7c8SDavid Howells void (*rx_wakeup)(struct afs_call *call); 591da177e4SLinus Torvalds 6008e0e7c8SDavid Howells /* synchronous call waiter and call dispatched notification */ 6108e0e7c8SDavid Howells int (*wait)(struct afs_call *call); 6208e0e7c8SDavid Howells 6308e0e7c8SDavid Howells /* asynchronous call completion */ 6408e0e7c8SDavid Howells void (*async_complete)(void *reply, int error); 6508e0e7c8SDavid Howells }; 6608e0e7c8SDavid Howells 6708e0e7c8SDavid Howells extern const struct afs_wait_mode afs_sync_call; 6808e0e7c8SDavid Howells extern const struct afs_wait_mode afs_async_call; 6908e0e7c8SDavid Howells 7008e0e7c8SDavid Howells /* 7108e0e7c8SDavid Howells * a record of an in-progress RxRPC call 7208e0e7c8SDavid Howells */ 7308e0e7c8SDavid Howells struct afs_call { 7408e0e7c8SDavid Howells const struct afs_call_type *type; /* type of call */ 7508e0e7c8SDavid Howells const struct afs_wait_mode *wait_mode; /* completion wait mode */ 7608e0e7c8SDavid Howells wait_queue_head_t waitq; /* processes awaiting completion */ 7708e0e7c8SDavid Howells struct work_struct async_work; /* asynchronous work processor */ 7808e0e7c8SDavid Howells struct work_struct work; /* actual work processor */ 7908e0e7c8SDavid Howells struct sk_buff_head rx_queue; /* received packets */ 8008e0e7c8SDavid Howells struct rxrpc_call *rxcall; /* RxRPC call handle */ 8108e0e7c8SDavid Howells struct key *key; /* security for this call */ 8208e0e7c8SDavid Howells struct afs_server *server; /* server affected by incoming CM call */ 8308e0e7c8SDavid Howells void *request; /* request data (first part) */ 8431143d5dSDavid Howells struct address_space *mapping; /* page set */ 8531143d5dSDavid Howells struct afs_writeback *wb; /* writeback being performed */ 8608e0e7c8SDavid Howells void *buffer; /* reply receive buffer */ 8708e0e7c8SDavid Howells void *reply; /* reply buffer (first part) */ 8808e0e7c8SDavid Howells void *reply2; /* reply buffer (second part) */ 8908e0e7c8SDavid Howells void *reply3; /* reply buffer (third part) */ 90260a9803SDavid Howells void *reply4; /* reply buffer (fourth part) */ 9131143d5dSDavid Howells pgoff_t first; /* first page in mapping to deal with */ 9231143d5dSDavid Howells pgoff_t last; /* last page in mapping to deal with */ 9308e0e7c8SDavid Howells enum { /* call state */ 9408e0e7c8SDavid Howells AFS_CALL_REQUESTING, /* request is being sent for outgoing call */ 9508e0e7c8SDavid Howells AFS_CALL_AWAIT_REPLY, /* awaiting reply to outgoing call */ 9608e0e7c8SDavid Howells AFS_CALL_AWAIT_OP_ID, /* awaiting op ID on incoming call */ 9708e0e7c8SDavid Howells AFS_CALL_AWAIT_REQUEST, /* awaiting request data on incoming call */ 9808e0e7c8SDavid Howells AFS_CALL_REPLYING, /* replying to incoming call */ 9908e0e7c8SDavid Howells AFS_CALL_AWAIT_ACK, /* awaiting final ACK of incoming call */ 10008e0e7c8SDavid Howells AFS_CALL_COMPLETE, /* successfully completed */ 10108e0e7c8SDavid Howells AFS_CALL_BUSY, /* server was busy */ 10208e0e7c8SDavid Howells AFS_CALL_ABORTED, /* call was aborted */ 10308e0e7c8SDavid Howells AFS_CALL_ERROR, /* call failed due to error */ 10408e0e7c8SDavid Howells } state; 10508e0e7c8SDavid Howells int error; /* error code */ 10608e0e7c8SDavid Howells unsigned request_size; /* size of request data */ 10708e0e7c8SDavid Howells unsigned reply_max; /* maximum size of reply */ 10808e0e7c8SDavid Howells unsigned reply_size; /* current size of reply */ 10931143d5dSDavid Howells unsigned first_offset; /* offset into mapping[first] */ 11031143d5dSDavid Howells unsigned last_to; /* amount of mapping[last] */ 11108e0e7c8SDavid Howells unsigned short offset; /* offset into received data store */ 11208e0e7c8SDavid Howells unsigned char unmarshall; /* unmarshalling phase */ 11308e0e7c8SDavid Howells bool incoming; /* T if incoming call */ 11431143d5dSDavid Howells bool send_pages; /* T if data from mapping should be sent */ 11508e0e7c8SDavid Howells u16 service_id; /* RxRPC service ID to call */ 11608e0e7c8SDavid Howells __be16 port; /* target UDP port */ 11708e0e7c8SDavid Howells __be32 operation_ID; /* operation ID for an incoming call */ 11808e0e7c8SDavid Howells u32 count; /* count for use in unmarshalling */ 11908e0e7c8SDavid Howells __be32 tmp; /* place to extract temporary data */ 12031143d5dSDavid Howells afs_dataversion_t store_version; /* updated version expected from store */ 12108e0e7c8SDavid Howells }; 12208e0e7c8SDavid Howells 12308e0e7c8SDavid Howells struct afs_call_type { 12400d3b7a4SDavid Howells const char *name; 12500d3b7a4SDavid Howells 12608e0e7c8SDavid Howells /* deliver request or reply data to an call 12708e0e7c8SDavid Howells * - returning an error will cause the call to be aborted 12808e0e7c8SDavid Howells */ 12908e0e7c8SDavid Howells int (*deliver)(struct afs_call *call, struct sk_buff *skb, 13008e0e7c8SDavid Howells bool last); 13108e0e7c8SDavid Howells 13208e0e7c8SDavid Howells /* map an abort code to an error number */ 13308e0e7c8SDavid Howells int (*abort_to_error)(u32 abort_code); 13408e0e7c8SDavid Howells 13508e0e7c8SDavid Howells /* clean up a call */ 13608e0e7c8SDavid Howells void (*destructor)(struct afs_call *call); 13708e0e7c8SDavid Howells }; 13808e0e7c8SDavid Howells 13908e0e7c8SDavid Howells /* 14031143d5dSDavid Howells * record of an outstanding writeback on a vnode 14131143d5dSDavid Howells */ 14231143d5dSDavid Howells struct afs_writeback { 14331143d5dSDavid Howells struct list_head link; /* link in vnode->writebacks */ 14431143d5dSDavid Howells struct work_struct writer; /* work item to perform the writeback */ 14531143d5dSDavid Howells struct afs_vnode *vnode; /* vnode to which this write applies */ 14631143d5dSDavid Howells struct key *key; /* owner of this write */ 14731143d5dSDavid Howells wait_queue_head_t waitq; /* completion and ready wait queue */ 14831143d5dSDavid Howells pgoff_t first; /* first page in batch */ 14931143d5dSDavid Howells pgoff_t point; /* last page in current store op */ 15031143d5dSDavid Howells pgoff_t last; /* last page in batch (inclusive) */ 15131143d5dSDavid Howells unsigned offset_first; /* offset into first page of start of write */ 15231143d5dSDavid Howells unsigned to_last; /* offset into last page of end of write */ 15331143d5dSDavid Howells int num_conflicts; /* count of conflicting writes in list */ 15431143d5dSDavid Howells int usage; 15531143d5dSDavid Howells bool conflicts; /* T if has dependent conflicts */ 15631143d5dSDavid Howells enum { 15731143d5dSDavid Howells AFS_WBACK_SYNCING, /* synchronisation being performed */ 15831143d5dSDavid Howells AFS_WBACK_PENDING, /* write pending */ 15931143d5dSDavid Howells AFS_WBACK_CONFLICTING, /* conflicting writes posted */ 16031143d5dSDavid Howells AFS_WBACK_WRITING, /* writing back */ 16131143d5dSDavid Howells AFS_WBACK_COMPLETE /* the writeback record has been unlinked */ 16231143d5dSDavid Howells } state __attribute__((packed)); 16331143d5dSDavid Howells }; 16431143d5dSDavid Howells 16531143d5dSDavid Howells /* 16608e0e7c8SDavid Howells * AFS superblock private data 16708e0e7c8SDavid Howells * - there's one superblock per volume 16808e0e7c8SDavid Howells */ 16908e0e7c8SDavid Howells struct afs_super_info { 17008e0e7c8SDavid Howells struct afs_volume *volume; /* volume record */ 17108e0e7c8SDavid Howells char rwparent; /* T if parent is R/W AFS volume */ 17208e0e7c8SDavid Howells }; 17308e0e7c8SDavid Howells 17408e0e7c8SDavid Howells static inline struct afs_super_info *AFS_FS_S(struct super_block *sb) 17508e0e7c8SDavid Howells { 17608e0e7c8SDavid Howells return sb->s_fs_info; 17708e0e7c8SDavid Howells } 17808e0e7c8SDavid Howells 17908e0e7c8SDavid Howells extern struct file_system_type afs_fs_type; 18008e0e7c8SDavid Howells 18108e0e7c8SDavid Howells /* 18208e0e7c8SDavid Howells * entry in the cached cell catalogue 18308e0e7c8SDavid Howells */ 18408e0e7c8SDavid Howells struct afs_cache_cell { 18500d3b7a4SDavid Howells char name[AFS_MAXCELLNAME]; /* cell name (padded with NULs) */ 18608e0e7c8SDavid Howells struct in_addr vl_servers[15]; /* cached cell VL servers */ 18708e0e7c8SDavid Howells }; 18808e0e7c8SDavid Howells 18908e0e7c8SDavid Howells /* 19008e0e7c8SDavid Howells * AFS cell record 19108e0e7c8SDavid Howells */ 19208e0e7c8SDavid Howells struct afs_cell { 19308e0e7c8SDavid Howells atomic_t usage; 19408e0e7c8SDavid Howells struct list_head link; /* main cell list link */ 19500d3b7a4SDavid Howells struct key *anonymous_key; /* anonymous user key for this cell */ 19608e0e7c8SDavid Howells struct list_head proc_link; /* /proc cell list link */ 19708e0e7c8SDavid Howells struct proc_dir_entry *proc_dir; /* /proc dir for this cell */ 1989b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 1999b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 2001da177e4SLinus Torvalds #endif 2011da177e4SLinus Torvalds 20208e0e7c8SDavid Howells /* server record management */ 20308e0e7c8SDavid Howells rwlock_t servers_lock; /* active server list lock */ 20408e0e7c8SDavid Howells struct list_head servers; /* active server list */ 2051da177e4SLinus Torvalds 20608e0e7c8SDavid Howells /* volume location record management */ 20708e0e7c8SDavid Howells struct rw_semaphore vl_sem; /* volume management serialisation semaphore */ 20808e0e7c8SDavid Howells struct list_head vl_list; /* cell's active VL record list */ 20908e0e7c8SDavid Howells spinlock_t vl_lock; /* vl_list lock */ 21008e0e7c8SDavid Howells unsigned short vl_naddrs; /* number of VL servers in addr list */ 21108e0e7c8SDavid Howells unsigned short vl_curr_svix; /* current server index */ 21208e0e7c8SDavid Howells struct in_addr vl_addrs[AFS_CELL_MAX_ADDRS]; /* cell VL server addresses */ 21308e0e7c8SDavid Howells 21408e0e7c8SDavid Howells char name[0]; /* cell name - must go last */ 21508e0e7c8SDavid Howells }; 21608e0e7c8SDavid Howells 21708e0e7c8SDavid Howells /* 21808e0e7c8SDavid Howells * entry in the cached volume location catalogue 21908e0e7c8SDavid Howells */ 22008e0e7c8SDavid Howells struct afs_cache_vlocation { 22100d3b7a4SDavid Howells /* volume name (lowercase, padded with NULs) */ 22200d3b7a4SDavid Howells uint8_t name[AFS_MAXVOLNAME + 1]; 22300d3b7a4SDavid Howells 22408e0e7c8SDavid Howells uint8_t nservers; /* number of entries used in servers[] */ 22508e0e7c8SDavid Howells uint8_t vidmask; /* voltype mask for vid[] */ 22608e0e7c8SDavid Howells uint8_t srvtmask[8]; /* voltype masks for servers[] */ 22708e0e7c8SDavid Howells #define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */ 22808e0e7c8SDavid Howells #define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */ 22908e0e7c8SDavid Howells #define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */ 23008e0e7c8SDavid Howells 23108e0e7c8SDavid Howells afs_volid_t vid[3]; /* volume IDs for R/W, R/O and Bak volumes */ 23208e0e7c8SDavid Howells struct in_addr servers[8]; /* fileserver addresses */ 23308e0e7c8SDavid Howells time_t rtime; /* last retrieval time */ 23408e0e7c8SDavid Howells }; 23508e0e7c8SDavid Howells 23608e0e7c8SDavid Howells /* 23708e0e7c8SDavid Howells * volume -> vnode hash table entry 23808e0e7c8SDavid Howells */ 23908e0e7c8SDavid Howells struct afs_cache_vhash { 24008e0e7c8SDavid Howells afs_voltype_t vtype; /* which volume variation */ 24108e0e7c8SDavid Howells uint8_t hash_bucket; /* which hash bucket this represents */ 24208e0e7c8SDavid Howells } __attribute__((packed)); 24308e0e7c8SDavid Howells 24408e0e7c8SDavid Howells /* 24508e0e7c8SDavid Howells * AFS volume location record 24608e0e7c8SDavid Howells */ 24708e0e7c8SDavid Howells struct afs_vlocation { 24808e0e7c8SDavid Howells atomic_t usage; 24908e0e7c8SDavid Howells time_t time_of_death; /* time at which put reduced usage to 0 */ 25008e0e7c8SDavid Howells struct list_head link; /* link in cell volume location list */ 25108e0e7c8SDavid Howells struct list_head grave; /* link in master graveyard list */ 25208e0e7c8SDavid Howells struct list_head update; /* link in master update list */ 25308e0e7c8SDavid Howells struct afs_cell *cell; /* cell to which volume belongs */ 2549b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 2559b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 25608e0e7c8SDavid Howells #endif 25708e0e7c8SDavid Howells struct afs_cache_vlocation vldb; /* volume information DB record */ 25808e0e7c8SDavid Howells struct afs_volume *vols[3]; /* volume access record pointer (index by type) */ 25908e0e7c8SDavid Howells wait_queue_head_t waitq; /* status change waitqueue */ 26008e0e7c8SDavid Howells time_t update_at; /* time at which record should be updated */ 26139bf0949SDavid S. Miller spinlock_t lock; /* access lock */ 26208e0e7c8SDavid Howells afs_vlocation_state_t state; /* volume location state */ 26308e0e7c8SDavid Howells unsigned short upd_rej_cnt; /* ENOMEDIUM count during update */ 26408e0e7c8SDavid Howells unsigned short upd_busy_cnt; /* EBUSY count during update */ 26508e0e7c8SDavid Howells bool valid; /* T if valid */ 26608e0e7c8SDavid Howells }; 26708e0e7c8SDavid Howells 26808e0e7c8SDavid Howells /* 26908e0e7c8SDavid Howells * AFS fileserver record 27008e0e7c8SDavid Howells */ 27108e0e7c8SDavid Howells struct afs_server { 27208e0e7c8SDavid Howells atomic_t usage; 27308e0e7c8SDavid Howells time_t time_of_death; /* time at which put reduced usage to 0 */ 27408e0e7c8SDavid Howells struct in_addr addr; /* server address */ 27508e0e7c8SDavid Howells struct afs_cell *cell; /* cell in which server resides */ 27608e0e7c8SDavid Howells struct list_head link; /* link in cell's server list */ 27708e0e7c8SDavid Howells struct list_head grave; /* link in master graveyard list */ 27808e0e7c8SDavid Howells struct rb_node master_rb; /* link in master by-addr tree */ 27908e0e7c8SDavid Howells struct rw_semaphore sem; /* access lock */ 28008e0e7c8SDavid Howells 28108e0e7c8SDavid Howells /* file service access */ 28208e0e7c8SDavid Howells struct rb_root fs_vnodes; /* vnodes backed by this server (ordered by FID) */ 28308e0e7c8SDavid Howells unsigned long fs_act_jif; /* time at which last activity occurred */ 28408e0e7c8SDavid Howells unsigned long fs_dead_jif; /* time at which no longer to be considered dead */ 28508e0e7c8SDavid Howells spinlock_t fs_lock; /* access lock */ 28608e0e7c8SDavid Howells int fs_state; /* 0 or reason FS currently marked dead (-errno) */ 28708e0e7c8SDavid Howells 28808e0e7c8SDavid Howells /* callback promise management */ 28908e0e7c8SDavid Howells struct rb_root cb_promises; /* vnode expiration list (ordered earliest first) */ 29008e0e7c8SDavid Howells struct delayed_work cb_updater; /* callback updater */ 29108e0e7c8SDavid Howells struct delayed_work cb_break_work; /* collected break dispatcher */ 29208e0e7c8SDavid Howells wait_queue_head_t cb_break_waitq; /* space available in cb_break waitqueue */ 29308e0e7c8SDavid Howells spinlock_t cb_lock; /* access lock */ 29408e0e7c8SDavid Howells struct afs_callback cb_break[64]; /* ring of callbacks awaiting breaking */ 29508e0e7c8SDavid Howells atomic_t cb_break_n; /* number of pending breaks */ 29608e0e7c8SDavid Howells u8 cb_break_head; /* head of callback breaking ring */ 29708e0e7c8SDavid Howells u8 cb_break_tail; /* tail of callback breaking ring */ 29808e0e7c8SDavid Howells }; 29908e0e7c8SDavid Howells 30008e0e7c8SDavid Howells /* 30108e0e7c8SDavid Howells * AFS volume access record 30208e0e7c8SDavid Howells */ 30308e0e7c8SDavid Howells struct afs_volume { 30408e0e7c8SDavid Howells atomic_t usage; 30508e0e7c8SDavid Howells struct afs_cell *cell; /* cell to which belongs (unrefd ptr) */ 30608e0e7c8SDavid Howells struct afs_vlocation *vlocation; /* volume location */ 3079b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 3089b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 30908e0e7c8SDavid Howells #endif 31008e0e7c8SDavid Howells afs_volid_t vid; /* volume ID */ 31108e0e7c8SDavid Howells afs_voltype_t type; /* type of volume */ 31208e0e7c8SDavid Howells char type_force; /* force volume type (suppress R/O -> R/W) */ 31308e0e7c8SDavid Howells unsigned short nservers; /* number of server slots filled */ 31408e0e7c8SDavid Howells unsigned short rjservers; /* number of servers discarded due to -ENOMEDIUM */ 31508e0e7c8SDavid Howells struct afs_server *servers[8]; /* servers on which volume resides (ordered) */ 31608e0e7c8SDavid Howells struct rw_semaphore server_sem; /* lock for accessing current server */ 317e1da0222SJens Axboe struct backing_dev_info bdi; 31808e0e7c8SDavid Howells }; 31908e0e7c8SDavid Howells 32008e0e7c8SDavid Howells /* 32108e0e7c8SDavid Howells * vnode catalogue entry 32208e0e7c8SDavid Howells */ 32308e0e7c8SDavid Howells struct afs_cache_vnode { 32408e0e7c8SDavid Howells afs_vnodeid_t vnode_id; /* vnode ID */ 32508e0e7c8SDavid Howells unsigned vnode_unique; /* vnode ID uniquifier */ 32608e0e7c8SDavid Howells afs_dataversion_t data_version; /* data version */ 32708e0e7c8SDavid Howells }; 32808e0e7c8SDavid Howells 32908e0e7c8SDavid Howells /* 33008e0e7c8SDavid Howells * AFS inode private data 33108e0e7c8SDavid Howells */ 33208e0e7c8SDavid Howells struct afs_vnode { 33308e0e7c8SDavid Howells struct inode vfs_inode; /* the VFS's inode record */ 33408e0e7c8SDavid Howells 33508e0e7c8SDavid Howells struct afs_volume *volume; /* volume on which vnode resides */ 33608e0e7c8SDavid Howells struct afs_server *server; /* server currently supplying this file */ 33708e0e7c8SDavid Howells struct afs_fid fid; /* the file identifier for this inode */ 33808e0e7c8SDavid Howells struct afs_file_status status; /* AFS status info for this file */ 3399b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 3409b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 34108e0e7c8SDavid Howells #endif 34200d3b7a4SDavid Howells struct afs_permits *permits; /* cache of permits so far obtained */ 34300d3b7a4SDavid Howells struct mutex permits_lock; /* lock for altering permits list */ 344260a9803SDavid Howells struct mutex validate_lock; /* lock for validating this vnode */ 34508e0e7c8SDavid Howells wait_queue_head_t update_waitq; /* status fetch waitqueue */ 346260a9803SDavid Howells int update_cnt; /* number of outstanding ops that will update the 34708e0e7c8SDavid Howells * status */ 34831143d5dSDavid Howells spinlock_t writeback_lock; /* lock for writebacks */ 34908e0e7c8SDavid Howells spinlock_t lock; /* waitqueue/flags lock */ 35008e0e7c8SDavid Howells unsigned long flags; 35108e0e7c8SDavid Howells #define AFS_VNODE_CB_BROKEN 0 /* set if vnode's callback was broken */ 352260a9803SDavid Howells #define AFS_VNODE_UNSET 1 /* set if vnode attributes not yet set */ 35308e0e7c8SDavid Howells #define AFS_VNODE_MODIFIED 2 /* set if vnode's data modified */ 35408e0e7c8SDavid Howells #define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */ 35508e0e7c8SDavid Howells #define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */ 35608e0e7c8SDavid Howells #define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */ 357e8d6c554SDavid Howells #define AFS_VNODE_LOCKING 6 /* set if waiting for lock on vnode */ 358e8d6c554SDavid Howells #define AFS_VNODE_READLOCKED 7 /* set if vnode is read-locked on the server */ 359e8d6c554SDavid Howells #define AFS_VNODE_WRITELOCKED 8 /* set if vnode is write-locked on the server */ 360e8d6c554SDavid Howells #define AFS_VNODE_UNLOCKING 9 /* set if vnode is being unlocked on the server */ 36108e0e7c8SDavid Howells 36200d3b7a4SDavid Howells long acl_order; /* ACL check count (callback break count) */ 36300d3b7a4SDavid Howells 36431143d5dSDavid Howells struct list_head writebacks; /* alterations in pagecache that need writing */ 365e8d6c554SDavid Howells struct list_head pending_locks; /* locks waiting to be granted */ 366e8d6c554SDavid Howells struct list_head granted_locks; /* locks granted on this file */ 367e8d6c554SDavid Howells struct delayed_work lock_work; /* work to be done in locking */ 368e8d6c554SDavid Howells struct key *unlock_key; /* key to be used in unlocking */ 36931143d5dSDavid Howells 37008e0e7c8SDavid Howells /* outstanding callback notification on this file */ 37108e0e7c8SDavid Howells struct rb_node server_rb; /* link in server->fs_vnodes */ 37208e0e7c8SDavid Howells struct rb_node cb_promise; /* link in server->cb_promises */ 37308e0e7c8SDavid Howells struct work_struct cb_broken_work; /* work to be done on callback break */ 37408e0e7c8SDavid Howells time_t cb_expires; /* time at which callback expires */ 37508e0e7c8SDavid Howells time_t cb_expires_at; /* time used to order cb_promise */ 37608e0e7c8SDavid Howells unsigned cb_version; /* callback version */ 37708e0e7c8SDavid Howells unsigned cb_expiry; /* callback expiry time */ 37808e0e7c8SDavid Howells afs_callback_type_t cb_type; /* type of callback */ 37908e0e7c8SDavid Howells bool cb_promised; /* true if promise still holds */ 38008e0e7c8SDavid Howells }; 38108e0e7c8SDavid Howells 38200d3b7a4SDavid Howells /* 38300d3b7a4SDavid Howells * cached security record for one user's attempt to access a vnode 38400d3b7a4SDavid Howells */ 38500d3b7a4SDavid Howells struct afs_permit { 38600d3b7a4SDavid Howells struct key *key; /* RxRPC ticket holding a security context */ 38700d3b7a4SDavid Howells afs_access_t access_mask; /* access mask for this key */ 38800d3b7a4SDavid Howells }; 38900d3b7a4SDavid Howells 39000d3b7a4SDavid Howells /* 39100d3b7a4SDavid Howells * cache of security records from attempts to access a vnode 39200d3b7a4SDavid Howells */ 39300d3b7a4SDavid Howells struct afs_permits { 39400d3b7a4SDavid Howells struct rcu_head rcu; /* disposal procedure */ 39500d3b7a4SDavid Howells int count; /* number of records */ 39600d3b7a4SDavid Howells struct afs_permit permits[0]; /* the permits so far examined */ 39700d3b7a4SDavid Howells }; 39800d3b7a4SDavid Howells 399b908fe6bSDavid Howells /* 400b908fe6bSDavid Howells * record of one of a system's set of network interfaces 401b908fe6bSDavid Howells */ 402b908fe6bSDavid Howells struct afs_interface { 403b908fe6bSDavid Howells struct in_addr address; /* IPv4 address bound to interface */ 404b908fe6bSDavid Howells struct in_addr netmask; /* netmask applied to address */ 405b908fe6bSDavid Howells unsigned mtu; /* MTU of interface */ 406b908fe6bSDavid Howells }; 407b908fe6bSDavid Howells 408b908fe6bSDavid Howells /* 409b908fe6bSDavid Howells * UUID definition [internet draft] 410b908fe6bSDavid Howells * - the timestamp is a 60-bit value, split 32/16/12, and goes in 100ns 411b908fe6bSDavid Howells * increments since midnight 15th October 1582 412b908fe6bSDavid Howells * - add AFS_UUID_TO_UNIX_TIME to convert unix time in 100ns units to UUID 413b908fe6bSDavid Howells * time 414b908fe6bSDavid Howells * - the clock sequence is a 14-bit counter to avoid duplicate times 415b908fe6bSDavid Howells */ 416b908fe6bSDavid Howells struct afs_uuid { 417b908fe6bSDavid Howells u32 time_low; /* low part of timestamp */ 418b908fe6bSDavid Howells u16 time_mid; /* mid part of timestamp */ 419b908fe6bSDavid Howells u16 time_hi_and_version; /* high part of timestamp and version */ 420b1bdb691SDavid Howells #define AFS_UUID_TO_UNIX_TIME 0x01b21dd213814000ULL 421b908fe6bSDavid Howells #define AFS_UUID_TIMEHI_MASK 0x0fff 422b908fe6bSDavid Howells #define AFS_UUID_VERSION_TIME 0x1000 /* time-based UUID */ 423b908fe6bSDavid Howells #define AFS_UUID_VERSION_NAME 0x3000 /* name-based UUID */ 424b908fe6bSDavid Howells #define AFS_UUID_VERSION_RANDOM 0x4000 /* (pseudo-)random generated UUID */ 425b908fe6bSDavid Howells u8 clock_seq_hi_and_reserved; /* clock seq hi and variant */ 426b908fe6bSDavid Howells #define AFS_UUID_CLOCKHI_MASK 0x3f 427b908fe6bSDavid Howells #define AFS_UUID_VARIANT_STD 0x80 428b908fe6bSDavid Howells u8 clock_seq_low; /* clock seq low */ 429b908fe6bSDavid Howells u8 node[6]; /* spatially unique node ID (MAC addr) */ 430b908fe6bSDavid Howells }; 431b908fe6bSDavid Howells 43208e0e7c8SDavid Howells /*****************************************************************************/ 43308e0e7c8SDavid Howells /* 4349b3f26c9SDavid Howells * cache.c 4359b3f26c9SDavid Howells */ 4369b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 4379b3f26c9SDavid Howells extern struct fscache_netfs afs_cache_netfs; 4389b3f26c9SDavid Howells extern struct fscache_cookie_def afs_cell_cache_index_def; 4399b3f26c9SDavid Howells extern struct fscache_cookie_def afs_vlocation_cache_index_def; 4409b3f26c9SDavid Howells extern struct fscache_cookie_def afs_volume_cache_index_def; 4419b3f26c9SDavid Howells extern struct fscache_cookie_def afs_vnode_cache_index_def; 4429b3f26c9SDavid Howells #else 4439b3f26c9SDavid Howells #define afs_cell_cache_index_def (*(struct fscache_cookie_def *) NULL) 4449b3f26c9SDavid Howells #define afs_vlocation_cache_index_def (*(struct fscache_cookie_def *) NULL) 4459b3f26c9SDavid Howells #define afs_volume_cache_index_def (*(struct fscache_cookie_def *) NULL) 4469b3f26c9SDavid Howells #define afs_vnode_cache_index_def (*(struct fscache_cookie_def *) NULL) 4479b3f26c9SDavid Howells #endif 4489b3f26c9SDavid Howells 4499b3f26c9SDavid Howells /* 45008e0e7c8SDavid Howells * callback.c 45108e0e7c8SDavid Howells */ 45208e0e7c8SDavid Howells extern void afs_init_callback_state(struct afs_server *); 45308e0e7c8SDavid Howells extern void afs_broken_callback_work(struct work_struct *); 45408e0e7c8SDavid Howells extern void afs_break_callbacks(struct afs_server *, size_t, 45508e0e7c8SDavid Howells struct afs_callback[]); 456260a9803SDavid Howells extern void afs_discard_callback_on_delete(struct afs_vnode *); 45708e0e7c8SDavid Howells extern void afs_give_up_callback(struct afs_vnode *); 45808e0e7c8SDavid Howells extern void afs_dispatch_give_up_callbacks(struct work_struct *); 45908e0e7c8SDavid Howells extern void afs_flush_callback_breaks(struct afs_server *); 46008e0e7c8SDavid Howells extern int __init afs_callback_update_init(void); 461fbb3fcbaSDavid Howells extern void afs_callback_update_kill(void); 4621da177e4SLinus Torvalds 4631da177e4SLinus Torvalds /* 4641da177e4SLinus Torvalds * cell.c 4651da177e4SLinus Torvalds */ 4661da177e4SLinus Torvalds extern struct rw_semaphore afs_proc_cells_sem; 4671da177e4SLinus Torvalds extern struct list_head afs_proc_cells; 4681da177e4SLinus Torvalds 46908e0e7c8SDavid Howells #define afs_get_cell(C) do { atomic_inc(&(C)->usage); } while(0) 47008e0e7c8SDavid Howells extern int afs_cell_init(char *); 47108e0e7c8SDavid Howells extern struct afs_cell *afs_cell_create(const char *, char *); 47208e0e7c8SDavid Howells extern struct afs_cell *afs_cell_lookup(const char *, unsigned); 47308e0e7c8SDavid Howells extern struct afs_cell *afs_grab_cell(struct afs_cell *); 47408e0e7c8SDavid Howells extern void afs_put_cell(struct afs_cell *); 47508e0e7c8SDavid Howells extern void afs_cell_purge(void); 47608e0e7c8SDavid Howells 47708e0e7c8SDavid Howells /* 47808e0e7c8SDavid Howells * cmservice.c 47908e0e7c8SDavid Howells */ 48008e0e7c8SDavid Howells extern bool afs_cm_incoming_call(struct afs_call *); 48108e0e7c8SDavid Howells 4821da177e4SLinus Torvalds /* 4831da177e4SLinus Torvalds * dir.c 4841da177e4SLinus Torvalds */ 485754661f1SArjan van de Ven extern const struct inode_operations afs_dir_inode_operations; 4864b6f5d20SArjan van de Ven extern const struct file_operations afs_dir_file_operations; 4871da177e4SLinus Torvalds 4881da177e4SLinus Torvalds /* 4891da177e4SLinus Torvalds * file.c 4901da177e4SLinus Torvalds */ 491f5e54d6eSChristoph Hellwig extern const struct address_space_operations afs_fs_aops; 492754661f1SArjan van de Ven extern const struct inode_operations afs_file_inode_operations; 49300d3b7a4SDavid Howells extern const struct file_operations afs_file_operations; 49400d3b7a4SDavid Howells 49500d3b7a4SDavid Howells extern int afs_open(struct inode *, struct file *); 49600d3b7a4SDavid Howells extern int afs_release(struct inode *, struct file *); 497f6d335c0SAl Viro extern int afs_page_filler(void *, struct page *); 4981da177e4SLinus Torvalds 4991da177e4SLinus Torvalds /* 500e8d6c554SDavid Howells * flock.c 501e8d6c554SDavid Howells */ 502e8d6c554SDavid Howells extern void __exit afs_kill_lock_manager(void); 503e8d6c554SDavid Howells extern void afs_lock_work(struct work_struct *); 504e8d6c554SDavid Howells extern void afs_lock_may_be_available(struct afs_vnode *); 505e8d6c554SDavid Howells extern int afs_lock(struct file *, int, struct file_lock *); 506e8d6c554SDavid Howells extern int afs_flock(struct file *, int, struct file_lock *); 507e8d6c554SDavid Howells 508e8d6c554SDavid Howells /* 50908e0e7c8SDavid Howells * fsclient.c 51008e0e7c8SDavid Howells */ 51100d3b7a4SDavid Howells extern int afs_fs_fetch_file_status(struct afs_server *, struct key *, 51200d3b7a4SDavid Howells struct afs_vnode *, struct afs_volsync *, 51308e0e7c8SDavid Howells const struct afs_wait_mode *); 51408e0e7c8SDavid Howells extern int afs_fs_give_up_callbacks(struct afs_server *, 51508e0e7c8SDavid Howells const struct afs_wait_mode *); 51600d3b7a4SDavid Howells extern int afs_fs_fetch_data(struct afs_server *, struct key *, 51700d3b7a4SDavid Howells struct afs_vnode *, off_t, size_t, struct page *, 518260a9803SDavid Howells const struct afs_wait_mode *); 519260a9803SDavid Howells extern int afs_fs_create(struct afs_server *, struct key *, 520260a9803SDavid Howells struct afs_vnode *, const char *, umode_t, 521260a9803SDavid Howells struct afs_fid *, struct afs_file_status *, 522260a9803SDavid Howells struct afs_callback *, 523260a9803SDavid Howells const struct afs_wait_mode *); 524260a9803SDavid Howells extern int afs_fs_remove(struct afs_server *, struct key *, 525260a9803SDavid Howells struct afs_vnode *, const char *, bool, 526260a9803SDavid Howells const struct afs_wait_mode *); 527260a9803SDavid Howells extern int afs_fs_link(struct afs_server *, struct key *, struct afs_vnode *, 528260a9803SDavid Howells struct afs_vnode *, const char *, 529260a9803SDavid Howells const struct afs_wait_mode *); 530260a9803SDavid Howells extern int afs_fs_symlink(struct afs_server *, struct key *, 531260a9803SDavid Howells struct afs_vnode *, const char *, const char *, 532260a9803SDavid Howells struct afs_fid *, struct afs_file_status *, 533260a9803SDavid Howells const struct afs_wait_mode *); 534260a9803SDavid Howells extern int afs_fs_rename(struct afs_server *, struct key *, 535260a9803SDavid Howells struct afs_vnode *, const char *, 536260a9803SDavid Howells struct afs_vnode *, const char *, 53708e0e7c8SDavid Howells const struct afs_wait_mode *); 53831143d5dSDavid Howells extern int afs_fs_store_data(struct afs_server *, struct afs_writeback *, 53931143d5dSDavid Howells pgoff_t, pgoff_t, unsigned, unsigned, 54031143d5dSDavid Howells const struct afs_wait_mode *); 54131143d5dSDavid Howells extern int afs_fs_setattr(struct afs_server *, struct key *, 54231143d5dSDavid Howells struct afs_vnode *, struct iattr *, 54331143d5dSDavid Howells const struct afs_wait_mode *); 54445222b9eSDavid Howells extern int afs_fs_get_volume_status(struct afs_server *, struct key *, 54545222b9eSDavid Howells struct afs_vnode *, 54645222b9eSDavid Howells struct afs_volume_status *, 54745222b9eSDavid Howells const struct afs_wait_mode *); 548e8d6c554SDavid Howells extern int afs_fs_set_lock(struct afs_server *, struct key *, 549e8d6c554SDavid Howells struct afs_vnode *, afs_lock_type_t, 550e8d6c554SDavid Howells const struct afs_wait_mode *); 551e8d6c554SDavid Howells extern int afs_fs_extend_lock(struct afs_server *, struct key *, 552e8d6c554SDavid Howells struct afs_vnode *, 553e8d6c554SDavid Howells const struct afs_wait_mode *); 554e8d6c554SDavid Howells extern int afs_fs_release_lock(struct afs_server *, struct key *, 555e8d6c554SDavid Howells struct afs_vnode *, 556e8d6c554SDavid Howells const struct afs_wait_mode *); 55708e0e7c8SDavid Howells 55808e0e7c8SDavid Howells /* 5591da177e4SLinus Torvalds * inode.c 5601da177e4SLinus Torvalds */ 56100d3b7a4SDavid Howells extern struct inode *afs_iget(struct super_block *, struct key *, 562260a9803SDavid Howells struct afs_fid *, struct afs_file_status *, 563260a9803SDavid Howells struct afs_callback *); 564416351f2SDavid Howells extern void afs_zap_data(struct afs_vnode *); 565260a9803SDavid Howells extern int afs_validate(struct afs_vnode *, struct key *); 566416351f2SDavid Howells extern int afs_getattr(struct vfsmount *, struct dentry *, struct kstat *); 56731143d5dSDavid Howells extern int afs_setattr(struct dentry *, struct iattr *); 568ec26815aSDavid Howells extern void afs_clear_inode(struct inode *); 5691da177e4SLinus Torvalds 5701da177e4SLinus Torvalds /* 5711da177e4SLinus Torvalds * main.c 5721da177e4SLinus Torvalds */ 573b908fe6bSDavid Howells extern struct afs_uuid afs_uuid; 5741da177e4SLinus Torvalds 5751da177e4SLinus Torvalds /* 57608e0e7c8SDavid Howells * misc.c 57708e0e7c8SDavid Howells */ 57808e0e7c8SDavid Howells extern int afs_abort_to_error(u32); 57908e0e7c8SDavid Howells 58008e0e7c8SDavid Howells /* 5811da177e4SLinus Torvalds * mntpt.c 5821da177e4SLinus Torvalds */ 583754661f1SArjan van de Ven extern const struct inode_operations afs_mntpt_inode_operations; 5844b6f5d20SArjan van de Ven extern const struct file_operations afs_mntpt_file_operations; 5851da177e4SLinus Torvalds 58600d3b7a4SDavid Howells extern int afs_mntpt_check_symlink(struct afs_vnode *, struct key *); 58708e0e7c8SDavid Howells extern void afs_mntpt_kill_timer(void); 5881da177e4SLinus Torvalds 5891da177e4SLinus Torvalds /* 5901da177e4SLinus Torvalds * proc.c 5911da177e4SLinus Torvalds */ 5921da177e4SLinus Torvalds extern int afs_proc_init(void); 5931da177e4SLinus Torvalds extern void afs_proc_cleanup(void); 594ec26815aSDavid Howells extern int afs_proc_cell_setup(struct afs_cell *); 595ec26815aSDavid Howells extern void afs_proc_cell_remove(struct afs_cell *); 5961da177e4SLinus Torvalds 59708e0e7c8SDavid Howells /* 59808e0e7c8SDavid Howells * rxrpc.c 59908e0e7c8SDavid Howells */ 60008e0e7c8SDavid Howells extern int afs_open_socket(void); 60108e0e7c8SDavid Howells extern void afs_close_socket(void); 60208e0e7c8SDavid Howells extern int afs_make_call(struct in_addr *, struct afs_call *, gfp_t, 60308e0e7c8SDavid Howells const struct afs_wait_mode *); 60408e0e7c8SDavid Howells extern struct afs_call *afs_alloc_flat_call(const struct afs_call_type *, 60508e0e7c8SDavid Howells size_t, size_t); 60608e0e7c8SDavid Howells extern void afs_flat_call_destructor(struct afs_call *); 60708e0e7c8SDavid Howells extern void afs_transfer_reply(struct afs_call *, struct sk_buff *); 60808e0e7c8SDavid Howells extern void afs_send_empty_reply(struct afs_call *); 609b908fe6bSDavid Howells extern void afs_send_simple_reply(struct afs_call *, const void *, size_t); 61008e0e7c8SDavid Howells extern int afs_extract_data(struct afs_call *, struct sk_buff *, bool, void *, 61108e0e7c8SDavid Howells size_t); 61208e0e7c8SDavid Howells 61308e0e7c8SDavid Howells /* 61400d3b7a4SDavid Howells * security.c 61500d3b7a4SDavid Howells */ 61600d3b7a4SDavid Howells extern void afs_clear_permits(struct afs_vnode *); 61700d3b7a4SDavid Howells extern void afs_cache_permit(struct afs_vnode *, struct key *, long); 618416351f2SDavid Howells extern void afs_zap_permits(struct rcu_head *); 61900d3b7a4SDavid Howells extern struct key *afs_request_key(struct afs_cell *); 620e6305c43SAl Viro extern int afs_permission(struct inode *, int); 62100d3b7a4SDavid Howells 62200d3b7a4SDavid Howells /* 62308e0e7c8SDavid Howells * server.c 62408e0e7c8SDavid Howells */ 62508e0e7c8SDavid Howells extern spinlock_t afs_server_peer_lock; 62608e0e7c8SDavid Howells 627260a9803SDavid Howells #define afs_get_server(S) \ 628260a9803SDavid Howells do { \ 629260a9803SDavid Howells _debug("GET SERVER %d", atomic_read(&(S)->usage)); \ 630260a9803SDavid Howells atomic_inc(&(S)->usage); \ 631260a9803SDavid Howells } while(0) 63208e0e7c8SDavid Howells 63308e0e7c8SDavid Howells extern struct afs_server *afs_lookup_server(struct afs_cell *, 63408e0e7c8SDavid Howells const struct in_addr *); 63508e0e7c8SDavid Howells extern struct afs_server *afs_find_server(const struct in_addr *); 63608e0e7c8SDavid Howells extern void afs_put_server(struct afs_server *); 63708e0e7c8SDavid Howells extern void __exit afs_purge_servers(void); 63808e0e7c8SDavid Howells 63908e0e7c8SDavid Howells /* 64000d3b7a4SDavid Howells * super.c 64100d3b7a4SDavid Howells */ 64200d3b7a4SDavid Howells extern int afs_fs_init(void); 64300d3b7a4SDavid Howells extern void afs_fs_exit(void); 64400d3b7a4SDavid Howells 64500d3b7a4SDavid Howells /* 646b908fe6bSDavid Howells * use-rtnetlink.c 647b908fe6bSDavid Howells */ 648b908fe6bSDavid Howells extern int afs_get_ipv4_interfaces(struct afs_interface *, size_t, bool); 649ec9c9485SDavid Howells extern int afs_get_MAC_address(u8 *, size_t); 650b908fe6bSDavid Howells 651b908fe6bSDavid Howells /* 65208e0e7c8SDavid Howells * vlclient.c 65308e0e7c8SDavid Howells */ 65400d3b7a4SDavid Howells extern int afs_vl_get_entry_by_name(struct in_addr *, struct key *, 65500d3b7a4SDavid Howells const char *, struct afs_cache_vlocation *, 65608e0e7c8SDavid Howells const struct afs_wait_mode *); 65700d3b7a4SDavid Howells extern int afs_vl_get_entry_by_id(struct in_addr *, struct key *, 65800d3b7a4SDavid Howells afs_volid_t, afs_voltype_t, 65908e0e7c8SDavid Howells struct afs_cache_vlocation *, 66008e0e7c8SDavid Howells const struct afs_wait_mode *); 66108e0e7c8SDavid Howells 66208e0e7c8SDavid Howells /* 66308e0e7c8SDavid Howells * vlocation.c 66408e0e7c8SDavid Howells */ 66508e0e7c8SDavid Howells #define afs_get_vlocation(V) do { atomic_inc(&(V)->usage); } while(0) 66608e0e7c8SDavid Howells 66708e0e7c8SDavid Howells extern int __init afs_vlocation_update_init(void); 66808e0e7c8SDavid Howells extern struct afs_vlocation *afs_vlocation_lookup(struct afs_cell *, 66900d3b7a4SDavid Howells struct key *, 67008e0e7c8SDavid Howells const char *, size_t); 67108e0e7c8SDavid Howells extern void afs_put_vlocation(struct afs_vlocation *); 672fbb3fcbaSDavid Howells extern void afs_vlocation_purge(void); 67308e0e7c8SDavid Howells 67408e0e7c8SDavid Howells /* 67508e0e7c8SDavid Howells * vnode.c 67608e0e7c8SDavid Howells */ 67708e0e7c8SDavid Howells static inline struct afs_vnode *AFS_FS_I(struct inode *inode) 67808e0e7c8SDavid Howells { 67908e0e7c8SDavid Howells return container_of(inode, struct afs_vnode, vfs_inode); 68008e0e7c8SDavid Howells } 68108e0e7c8SDavid Howells 68208e0e7c8SDavid Howells static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode) 68308e0e7c8SDavid Howells { 68408e0e7c8SDavid Howells return &vnode->vfs_inode; 68508e0e7c8SDavid Howells } 68608e0e7c8SDavid Howells 687260a9803SDavid Howells extern void afs_vnode_finalise_status_update(struct afs_vnode *, 688260a9803SDavid Howells struct afs_server *); 68900d3b7a4SDavid Howells extern int afs_vnode_fetch_status(struct afs_vnode *, struct afs_vnode *, 69000d3b7a4SDavid Howells struct key *); 69100d3b7a4SDavid Howells extern int afs_vnode_fetch_data(struct afs_vnode *, struct key *, 69200d3b7a4SDavid Howells off_t, size_t, struct page *); 693260a9803SDavid Howells extern int afs_vnode_create(struct afs_vnode *, struct key *, const char *, 694260a9803SDavid Howells umode_t, struct afs_fid *, struct afs_file_status *, 695260a9803SDavid Howells struct afs_callback *, struct afs_server **); 696260a9803SDavid Howells extern int afs_vnode_remove(struct afs_vnode *, struct key *, const char *, 697260a9803SDavid Howells bool); 698260a9803SDavid Howells extern int afs_vnode_link(struct afs_vnode *, struct afs_vnode *, struct key *, 699260a9803SDavid Howells const char *); 700260a9803SDavid Howells extern int afs_vnode_symlink(struct afs_vnode *, struct key *, const char *, 701260a9803SDavid Howells const char *, struct afs_fid *, 702260a9803SDavid Howells struct afs_file_status *, struct afs_server **); 703260a9803SDavid Howells extern int afs_vnode_rename(struct afs_vnode *, struct afs_vnode *, 704260a9803SDavid Howells struct key *, const char *, const char *); 70531143d5dSDavid Howells extern int afs_vnode_store_data(struct afs_writeback *, pgoff_t, pgoff_t, 70631143d5dSDavid Howells unsigned, unsigned); 70731143d5dSDavid Howells extern int afs_vnode_setattr(struct afs_vnode *, struct key *, struct iattr *); 70845222b9eSDavid Howells extern int afs_vnode_get_volume_status(struct afs_vnode *, struct key *, 70945222b9eSDavid Howells struct afs_volume_status *); 710e8d6c554SDavid Howells extern int afs_vnode_set_lock(struct afs_vnode *, struct key *, 711e8d6c554SDavid Howells afs_lock_type_t); 712e8d6c554SDavid Howells extern int afs_vnode_extend_lock(struct afs_vnode *, struct key *); 713e8d6c554SDavid Howells extern int afs_vnode_release_lock(struct afs_vnode *, struct key *); 71408e0e7c8SDavid Howells 71508e0e7c8SDavid Howells /* 71608e0e7c8SDavid Howells * volume.c 71708e0e7c8SDavid Howells */ 71808e0e7c8SDavid Howells #define afs_get_volume(V) do { atomic_inc(&(V)->usage); } while(0) 71908e0e7c8SDavid Howells 72008e0e7c8SDavid Howells extern void afs_put_volume(struct afs_volume *); 72100d3b7a4SDavid Howells extern struct afs_volume *afs_volume_lookup(struct afs_mount_params *); 72208e0e7c8SDavid Howells extern struct afs_server *afs_volume_pick_fileserver(struct afs_vnode *); 72308e0e7c8SDavid Howells extern int afs_volume_release_fileserver(struct afs_vnode *, 72408e0e7c8SDavid Howells struct afs_server *, int); 72508e0e7c8SDavid Howells 72631143d5dSDavid Howells /* 72731143d5dSDavid Howells * write.c 72831143d5dSDavid Howells */ 72931143d5dSDavid Howells extern int afs_set_page_dirty(struct page *); 73031143d5dSDavid Howells extern void afs_put_writeback(struct afs_writeback *); 73115b4650eSNick Piggin extern int afs_write_begin(struct file *file, struct address_space *mapping, 73215b4650eSNick Piggin loff_t pos, unsigned len, unsigned flags, 73315b4650eSNick Piggin struct page **pagep, void **fsdata); 73415b4650eSNick Piggin extern int afs_write_end(struct file *file, struct address_space *mapping, 73515b4650eSNick Piggin loff_t pos, unsigned len, unsigned copied, 73615b4650eSNick Piggin struct page *page, void *fsdata); 73731143d5dSDavid Howells extern int afs_writepage(struct page *, struct writeback_control *); 73831143d5dSDavid Howells extern int afs_writepages(struct address_space *, struct writeback_control *); 73931143d5dSDavid Howells extern void afs_pages_written_back(struct afs_vnode *, struct afs_call *); 74031143d5dSDavid Howells extern ssize_t afs_file_write(struct kiocb *, const struct iovec *, 74131143d5dSDavid Howells unsigned long, loff_t); 74231143d5dSDavid Howells extern int afs_writeback_all(struct afs_vnode *); 7437ea80859SChristoph Hellwig extern int afs_fsync(struct file *, int); 74431143d5dSDavid Howells 74531143d5dSDavid Howells 74608e0e7c8SDavid Howells /*****************************************************************************/ 74708e0e7c8SDavid Howells /* 74808e0e7c8SDavid Howells * debug tracing 74908e0e7c8SDavid Howells */ 75008e0e7c8SDavid Howells extern unsigned afs_debug; 75108e0e7c8SDavid Howells 75208e0e7c8SDavid Howells #define dbgprintk(FMT,...) \ 753ad16df84SSven Schnelle printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__) 75408e0e7c8SDavid Howells 75508e0e7c8SDavid Howells /* make sure we maintain the format strings, even when debugging is disabled */ 75608e0e7c8SDavid Howells static inline __attribute__((format(printf,1,2))) 75708e0e7c8SDavid Howells void _dbprintk(const char *fmt, ...) 75808e0e7c8SDavid Howells { 75908e0e7c8SDavid Howells } 76008e0e7c8SDavid Howells 761530b6412SHarvey Harrison #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__) 762530b6412SHarvey Harrison #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) 76308e0e7c8SDavid Howells #define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__) 76408e0e7c8SDavid Howells 76508e0e7c8SDavid Howells 76608e0e7c8SDavid Howells #if defined(__KDEBUG) 76708e0e7c8SDavid Howells #define _enter(FMT,...) kenter(FMT,##__VA_ARGS__) 76808e0e7c8SDavid Howells #define _leave(FMT,...) kleave(FMT,##__VA_ARGS__) 76908e0e7c8SDavid Howells #define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__) 77008e0e7c8SDavid Howells 77108e0e7c8SDavid Howells #elif defined(CONFIG_AFS_DEBUG) 77208e0e7c8SDavid Howells #define AFS_DEBUG_KENTER 0x01 77308e0e7c8SDavid Howells #define AFS_DEBUG_KLEAVE 0x02 77408e0e7c8SDavid Howells #define AFS_DEBUG_KDEBUG 0x04 77508e0e7c8SDavid Howells 77608e0e7c8SDavid Howells #define _enter(FMT,...) \ 77708e0e7c8SDavid Howells do { \ 77808e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \ 77908e0e7c8SDavid Howells kenter(FMT,##__VA_ARGS__); \ 78008e0e7c8SDavid Howells } while (0) 78108e0e7c8SDavid Howells 78208e0e7c8SDavid Howells #define _leave(FMT,...) \ 78308e0e7c8SDavid Howells do { \ 78408e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \ 78508e0e7c8SDavid Howells kleave(FMT,##__VA_ARGS__); \ 78608e0e7c8SDavid Howells } while (0) 78708e0e7c8SDavid Howells 78808e0e7c8SDavid Howells #define _debug(FMT,...) \ 78908e0e7c8SDavid Howells do { \ 79008e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \ 79108e0e7c8SDavid Howells kdebug(FMT,##__VA_ARGS__); \ 79208e0e7c8SDavid Howells } while (0) 79308e0e7c8SDavid Howells 79408e0e7c8SDavid Howells #else 795530b6412SHarvey Harrison #define _enter(FMT,...) _dbprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__) 796530b6412SHarvey Harrison #define _leave(FMT,...) _dbprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) 79708e0e7c8SDavid Howells #define _debug(FMT,...) _dbprintk(" "FMT ,##__VA_ARGS__) 79808e0e7c8SDavid Howells #endif 79908e0e7c8SDavid Howells 80008e0e7c8SDavid Howells /* 80108e0e7c8SDavid Howells * debug assertion checking 80208e0e7c8SDavid Howells */ 80308e0e7c8SDavid Howells #if 1 // defined(__KDEBUGALL) 80408e0e7c8SDavid Howells 80508e0e7c8SDavid Howells #define ASSERT(X) \ 80608e0e7c8SDavid Howells do { \ 80708e0e7c8SDavid Howells if (unlikely(!(X))) { \ 80808e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 80908e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 81008e0e7c8SDavid Howells BUG(); \ 81108e0e7c8SDavid Howells } \ 81208e0e7c8SDavid Howells } while(0) 81308e0e7c8SDavid Howells 81408e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y) \ 81508e0e7c8SDavid Howells do { \ 81608e0e7c8SDavid Howells if (unlikely(!((X) OP (Y)))) { \ 81708e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 81808e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 81908e0e7c8SDavid Howells printk(KERN_ERR "%lu " #OP " %lu is false\n", \ 82008e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 82108e0e7c8SDavid Howells printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ 82208e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 82308e0e7c8SDavid Howells BUG(); \ 82408e0e7c8SDavid Howells } \ 82508e0e7c8SDavid Howells } while(0) 82608e0e7c8SDavid Howells 827416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H) \ 828416351f2SDavid Howells do { \ 829416351f2SDavid Howells if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) { \ 830416351f2SDavid Howells printk(KERN_ERR "\n"); \ 831416351f2SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 832416351f2SDavid Howells printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n", \ 833416351f2SDavid Howells (unsigned long)(L), (unsigned long)(N), \ 834416351f2SDavid Howells (unsigned long)(H)); \ 835416351f2SDavid Howells printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \ 836416351f2SDavid Howells (unsigned long)(L), (unsigned long)(N), \ 837416351f2SDavid Howells (unsigned long)(H)); \ 838416351f2SDavid Howells BUG(); \ 839416351f2SDavid Howells } \ 840416351f2SDavid Howells } while(0) 841416351f2SDavid Howells 84208e0e7c8SDavid Howells #define ASSERTIF(C, X) \ 84308e0e7c8SDavid Howells do { \ 84408e0e7c8SDavid Howells if (unlikely((C) && !(X))) { \ 84508e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 84608e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 84708e0e7c8SDavid Howells BUG(); \ 84808e0e7c8SDavid Howells } \ 84908e0e7c8SDavid Howells } while(0) 85008e0e7c8SDavid Howells 85108e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y) \ 85208e0e7c8SDavid Howells do { \ 85308e0e7c8SDavid Howells if (unlikely((C) && !((X) OP (Y)))) { \ 85408e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 85508e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 85608e0e7c8SDavid Howells printk(KERN_ERR "%lu " #OP " %lu is false\n", \ 85708e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 85808e0e7c8SDavid Howells printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ 85908e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 86008e0e7c8SDavid Howells BUG(); \ 86108e0e7c8SDavid Howells } \ 86208e0e7c8SDavid Howells } while(0) 86308e0e7c8SDavid Howells 86408e0e7c8SDavid Howells #else 86508e0e7c8SDavid Howells 86608e0e7c8SDavid Howells #define ASSERT(X) \ 86708e0e7c8SDavid Howells do { \ 86808e0e7c8SDavid Howells } while(0) 86908e0e7c8SDavid Howells 87008e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y) \ 87108e0e7c8SDavid Howells do { \ 87208e0e7c8SDavid Howells } while(0) 87308e0e7c8SDavid Howells 874416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H) \ 875416351f2SDavid Howells do { \ 876416351f2SDavid Howells } while(0) 877416351f2SDavid Howells 87808e0e7c8SDavid Howells #define ASSERTIF(C, X) \ 87908e0e7c8SDavid Howells do { \ 88008e0e7c8SDavid Howells } while(0) 88108e0e7c8SDavid Howells 88208e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y) \ 88308e0e7c8SDavid Howells do { \ 88408e0e7c8SDavid Howells } while(0) 88508e0e7c8SDavid Howells 88608e0e7c8SDavid Howells #endif /* __KDEBUGALL */ 887