1ec26815aSDavid Howells /* internal AFS stuff 21da177e4SLinus Torvalds * 308e0e7c8SDavid Howells * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved. 41da177e4SLinus Torvalds * Written by David Howells (dhowells@redhat.com) 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or 71da177e4SLinus Torvalds * modify it under the terms of the GNU General Public License 81da177e4SLinus Torvalds * as published by the Free Software Foundation; either version 91da177e4SLinus Torvalds * 2 of the License, or (at your option) any later version. 101da177e4SLinus Torvalds */ 111da177e4SLinus Torvalds 121da177e4SLinus Torvalds #include <linux/compiler.h> 131da177e4SLinus Torvalds #include <linux/kernel.h> 148a79790bSTina Ruchandani #include <linux/ktime.h> 151da177e4SLinus Torvalds #include <linux/fs.h> 161da177e4SLinus Torvalds #include <linux/pagemap.h> 1708e0e7c8SDavid Howells #include <linux/rxrpc.h> 1800d3b7a4SDavid Howells #include <linux/key.h> 19e8edc6e0SAlexey Dobriyan #include <linux/workqueue.h> 2000c541eaSAndrew Morton #include <linux/sched.h> 2180e50be4SChristoph Hellwig #include <linux/fscache.h> 22e1da0222SJens Axboe #include <linux/backing-dev.h> 23ff548773SDavid Howells #include <linux/uuid.h> 248324f0bcSDavid Howells #include <net/af_rxrpc.h> 2500c541eaSAndrew Morton 2608e0e7c8SDavid Howells #include "afs.h" 2708e0e7c8SDavid Howells #include "afs_vl.h" 2808e0e7c8SDavid Howells 2908e0e7c8SDavid Howells #define AFS_CELL_MAX_ADDRS 15 3008e0e7c8SDavid Howells 3131143d5dSDavid Howells struct pagevec; 3208e0e7c8SDavid Howells struct afs_call; 3308e0e7c8SDavid Howells 3408e0e7c8SDavid Howells typedef enum { 3508e0e7c8SDavid Howells AFS_VL_NEW, /* new, uninitialised record */ 3608e0e7c8SDavid Howells AFS_VL_CREATING, /* creating record */ 3708e0e7c8SDavid Howells AFS_VL_VALID, /* record is pending */ 3808e0e7c8SDavid Howells AFS_VL_NO_VOLUME, /* no such volume available */ 3908e0e7c8SDavid Howells AFS_VL_UPDATING, /* update in progress */ 4008e0e7c8SDavid Howells AFS_VL_VOLUME_DELETED, /* volume was deleted */ 4108e0e7c8SDavid Howells AFS_VL_UNCERTAIN, /* uncertain state (update failed) */ 4208e0e7c8SDavid Howells } __attribute__((packed)) afs_vlocation_state_t; 431da177e4SLinus Torvalds 4400d3b7a4SDavid Howells struct afs_mount_params { 4500d3b7a4SDavid Howells bool rwpath; /* T if the parent should be considered R/W */ 4600d3b7a4SDavid Howells bool force; /* T to force cell type */ 47bec5eb61Swanglei bool autocell; /* T if set auto mount operation */ 4800d3b7a4SDavid Howells afs_voltype_t type; /* type of volume requested */ 4900d3b7a4SDavid Howells int volnamesz; /* size of volume name */ 5000d3b7a4SDavid Howells const char *volname; /* name of volume to mount */ 5100d3b7a4SDavid Howells struct afs_cell *cell; /* cell in which to find volume */ 5200d3b7a4SDavid Howells struct afs_volume *volume; /* volume record */ 5300d3b7a4SDavid Howells struct key *key; /* key to use for secure mounting */ 5400d3b7a4SDavid Howells }; 5500d3b7a4SDavid Howells 568e8d7f13SDavid Howells enum afs_call_state { 578e8d7f13SDavid Howells AFS_CALL_REQUESTING, /* request is being sent for outgoing call */ 588e8d7f13SDavid Howells AFS_CALL_AWAIT_REPLY, /* awaiting reply to outgoing call */ 598e8d7f13SDavid Howells AFS_CALL_AWAIT_OP_ID, /* awaiting op ID on incoming call */ 608e8d7f13SDavid Howells AFS_CALL_AWAIT_REQUEST, /* awaiting request data on incoming call */ 618e8d7f13SDavid Howells AFS_CALL_REPLYING, /* replying to incoming call */ 628e8d7f13SDavid Howells AFS_CALL_AWAIT_ACK, /* awaiting final ACK of incoming call */ 638e8d7f13SDavid Howells AFS_CALL_COMPLETE, /* Completed or failed */ 648e8d7f13SDavid Howells }; 6508e0e7c8SDavid Howells /* 6608e0e7c8SDavid Howells * a record of an in-progress RxRPC call 6708e0e7c8SDavid Howells */ 6808e0e7c8SDavid Howells struct afs_call { 6908e0e7c8SDavid Howells const struct afs_call_type *type; /* type of call */ 7008e0e7c8SDavid Howells wait_queue_head_t waitq; /* processes awaiting completion */ 71341f741fSDavid Howells struct work_struct async_work; /* async I/O processor */ 7208e0e7c8SDavid Howells struct work_struct work; /* actual work processor */ 7308e0e7c8SDavid Howells struct rxrpc_call *rxcall; /* RxRPC call handle */ 7408e0e7c8SDavid Howells struct key *key; /* security for this call */ 7508e0e7c8SDavid Howells struct afs_server *server; /* server affected by incoming CM call */ 7608e0e7c8SDavid Howells void *request; /* request data (first part) */ 7731143d5dSDavid Howells struct address_space *mapping; /* page set */ 7831143d5dSDavid Howells struct afs_writeback *wb; /* writeback being performed */ 7908e0e7c8SDavid Howells void *buffer; /* reply receive buffer */ 8008e0e7c8SDavid Howells void *reply; /* reply buffer (first part) */ 8108e0e7c8SDavid Howells void *reply2; /* reply buffer (second part) */ 8208e0e7c8SDavid Howells void *reply3; /* reply buffer (third part) */ 83260a9803SDavid Howells void *reply4; /* reply buffer (fourth part) */ 8431143d5dSDavid Howells pgoff_t first; /* first page in mapping to deal with */ 8531143d5dSDavid Howells pgoff_t last; /* last page in mapping to deal with */ 86d001648eSDavid Howells size_t offset; /* offset into received data store */ 87341f741fSDavid Howells atomic_t usage; 888e8d7f13SDavid Howells enum afs_call_state state; 8908e0e7c8SDavid Howells int error; /* error code */ 90d001648eSDavid Howells u32 abort_code; /* Remote abort ID or 0 */ 9108e0e7c8SDavid Howells unsigned request_size; /* size of request data */ 9208e0e7c8SDavid Howells unsigned reply_max; /* maximum size of reply */ 9331143d5dSDavid Howells unsigned first_offset; /* offset into mapping[first] */ 94bcd89270SMarc Dionne union { 9531143d5dSDavid Howells unsigned last_to; /* amount of mapping[last] */ 96bcd89270SMarc Dionne unsigned count2; /* count used in unmarshalling */ 97bcd89270SMarc Dionne }; 9808e0e7c8SDavid Howells unsigned char unmarshall; /* unmarshalling phase */ 9908e0e7c8SDavid Howells bool incoming; /* T if incoming call */ 10031143d5dSDavid Howells bool send_pages; /* T if data from mapping should be sent */ 101d001648eSDavid Howells bool need_attention; /* T if RxRPC poked us */ 10256ff9c83SDavid Howells bool async; /* T if asynchronous */ 10308e0e7c8SDavid Howells u16 service_id; /* RxRPC service ID to call */ 10408e0e7c8SDavid Howells __be16 port; /* target UDP port */ 10550a2c953SDavid Howells u32 operation_ID; /* operation ID for an incoming call */ 10608e0e7c8SDavid Howells u32 count; /* count for use in unmarshalling */ 10708e0e7c8SDavid Howells __be32 tmp; /* place to extract temporary data */ 10831143d5dSDavid Howells afs_dataversion_t store_version; /* updated version expected from store */ 10908e0e7c8SDavid Howells }; 11008e0e7c8SDavid Howells 11108e0e7c8SDavid Howells struct afs_call_type { 11200d3b7a4SDavid Howells const char *name; 11300d3b7a4SDavid Howells 11408e0e7c8SDavid Howells /* deliver request or reply data to an call 11508e0e7c8SDavid Howells * - returning an error will cause the call to be aborted 11608e0e7c8SDavid Howells */ 117d001648eSDavid Howells int (*deliver)(struct afs_call *call); 11808e0e7c8SDavid Howells 11908e0e7c8SDavid Howells /* map an abort code to an error number */ 12008e0e7c8SDavid Howells int (*abort_to_error)(u32 abort_code); 12108e0e7c8SDavid Howells 12208e0e7c8SDavid Howells /* clean up a call */ 12308e0e7c8SDavid Howells void (*destructor)(struct afs_call *call); 124341f741fSDavid Howells 125341f741fSDavid Howells /* Work function */ 126341f741fSDavid Howells void (*work)(struct work_struct *work); 12708e0e7c8SDavid Howells }; 12808e0e7c8SDavid Howells 12908e0e7c8SDavid Howells /* 130196ee9cdSDavid Howells * Record of an outstanding read operation on a vnode. 131196ee9cdSDavid Howells */ 132196ee9cdSDavid Howells struct afs_read { 133196ee9cdSDavid Howells loff_t pos; /* Where to start reading */ 134e8e581a8SDavid Howells loff_t len; /* How much we're asking for */ 135196ee9cdSDavid Howells loff_t actual_len; /* How much we're actually getting */ 1366a0e3999SDavid Howells loff_t remain; /* Amount remaining */ 137196ee9cdSDavid Howells atomic_t usage; 138196ee9cdSDavid Howells unsigned int index; /* Which page we're reading into */ 139196ee9cdSDavid Howells unsigned int nr_pages; 140196ee9cdSDavid Howells void (*page_done)(struct afs_call *, struct afs_read *); 141196ee9cdSDavid Howells struct page *pages[]; 142196ee9cdSDavid Howells }; 143196ee9cdSDavid Howells 144196ee9cdSDavid Howells /* 14531143d5dSDavid Howells * record of an outstanding writeback on a vnode 14631143d5dSDavid Howells */ 14731143d5dSDavid Howells struct afs_writeback { 14831143d5dSDavid Howells struct list_head link; /* link in vnode->writebacks */ 14931143d5dSDavid Howells struct work_struct writer; /* work item to perform the writeback */ 15031143d5dSDavid Howells struct afs_vnode *vnode; /* vnode to which this write applies */ 15131143d5dSDavid Howells struct key *key; /* owner of this write */ 15231143d5dSDavid Howells wait_queue_head_t waitq; /* completion and ready wait queue */ 15331143d5dSDavid Howells pgoff_t first; /* first page in batch */ 15431143d5dSDavid Howells pgoff_t point; /* last page in current store op */ 15531143d5dSDavid Howells pgoff_t last; /* last page in batch (inclusive) */ 15631143d5dSDavid Howells unsigned offset_first; /* offset into first page of start of write */ 15731143d5dSDavid Howells unsigned to_last; /* offset into last page of end of write */ 15831143d5dSDavid Howells int num_conflicts; /* count of conflicting writes in list */ 15931143d5dSDavid Howells int usage; 16031143d5dSDavid Howells bool conflicts; /* T if has dependent conflicts */ 16131143d5dSDavid Howells enum { 16231143d5dSDavid Howells AFS_WBACK_SYNCING, /* synchronisation being performed */ 16331143d5dSDavid Howells AFS_WBACK_PENDING, /* write pending */ 16431143d5dSDavid Howells AFS_WBACK_CONFLICTING, /* conflicting writes posted */ 16531143d5dSDavid Howells AFS_WBACK_WRITING, /* writing back */ 16631143d5dSDavid Howells AFS_WBACK_COMPLETE /* the writeback record has been unlinked */ 16731143d5dSDavid Howells } state __attribute__((packed)); 16831143d5dSDavid Howells }; 16931143d5dSDavid Howells 17031143d5dSDavid Howells /* 17108e0e7c8SDavid Howells * AFS superblock private data 17208e0e7c8SDavid Howells * - there's one superblock per volume 17308e0e7c8SDavid Howells */ 17408e0e7c8SDavid Howells struct afs_super_info { 17508e0e7c8SDavid Howells struct afs_volume *volume; /* volume record */ 17608e0e7c8SDavid Howells char rwparent; /* T if parent is R/W AFS volume */ 17708e0e7c8SDavid Howells }; 17808e0e7c8SDavid Howells 17908e0e7c8SDavid Howells static inline struct afs_super_info *AFS_FS_S(struct super_block *sb) 18008e0e7c8SDavid Howells { 18108e0e7c8SDavid Howells return sb->s_fs_info; 18208e0e7c8SDavid Howells } 18308e0e7c8SDavid Howells 18408e0e7c8SDavid Howells extern struct file_system_type afs_fs_type; 18508e0e7c8SDavid Howells 18608e0e7c8SDavid Howells /* 18708e0e7c8SDavid Howells * entry in the cached cell catalogue 18808e0e7c8SDavid Howells */ 18908e0e7c8SDavid Howells struct afs_cache_cell { 19000d3b7a4SDavid Howells char name[AFS_MAXCELLNAME]; /* cell name (padded with NULs) */ 19108e0e7c8SDavid Howells struct in_addr vl_servers[15]; /* cached cell VL servers */ 19208e0e7c8SDavid Howells }; 19308e0e7c8SDavid Howells 19408e0e7c8SDavid Howells /* 19508e0e7c8SDavid Howells * AFS cell record 19608e0e7c8SDavid Howells */ 19708e0e7c8SDavid Howells struct afs_cell { 19808e0e7c8SDavid Howells atomic_t usage; 19908e0e7c8SDavid Howells struct list_head link; /* main cell list link */ 20000d3b7a4SDavid Howells struct key *anonymous_key; /* anonymous user key for this cell */ 20108e0e7c8SDavid Howells struct list_head proc_link; /* /proc cell list link */ 2029b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 2039b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 2041da177e4SLinus Torvalds #endif 2051da177e4SLinus Torvalds 20608e0e7c8SDavid Howells /* server record management */ 20708e0e7c8SDavid Howells rwlock_t servers_lock; /* active server list lock */ 20808e0e7c8SDavid Howells struct list_head servers; /* active server list */ 2091da177e4SLinus Torvalds 21008e0e7c8SDavid Howells /* volume location record management */ 21108e0e7c8SDavid Howells struct rw_semaphore vl_sem; /* volume management serialisation semaphore */ 21208e0e7c8SDavid Howells struct list_head vl_list; /* cell's active VL record list */ 21308e0e7c8SDavid Howells spinlock_t vl_lock; /* vl_list lock */ 21408e0e7c8SDavid Howells unsigned short vl_naddrs; /* number of VL servers in addr list */ 21508e0e7c8SDavid Howells unsigned short vl_curr_svix; /* current server index */ 21608e0e7c8SDavid Howells struct in_addr vl_addrs[AFS_CELL_MAX_ADDRS]; /* cell VL server addresses */ 21708e0e7c8SDavid Howells 21808e0e7c8SDavid Howells char name[0]; /* cell name - must go last */ 21908e0e7c8SDavid Howells }; 22008e0e7c8SDavid Howells 22108e0e7c8SDavid Howells /* 22208e0e7c8SDavid Howells * entry in the cached volume location catalogue 22308e0e7c8SDavid Howells */ 22408e0e7c8SDavid Howells struct afs_cache_vlocation { 22500d3b7a4SDavid Howells /* volume name (lowercase, padded with NULs) */ 22600d3b7a4SDavid Howells uint8_t name[AFS_MAXVOLNAME + 1]; 22700d3b7a4SDavid Howells 22808e0e7c8SDavid Howells uint8_t nservers; /* number of entries used in servers[] */ 22908e0e7c8SDavid Howells uint8_t vidmask; /* voltype mask for vid[] */ 23008e0e7c8SDavid Howells uint8_t srvtmask[8]; /* voltype masks for servers[] */ 23108e0e7c8SDavid Howells #define AFS_VOL_VTM_RW 0x01 /* R/W version of the volume is available (on this server) */ 23208e0e7c8SDavid Howells #define AFS_VOL_VTM_RO 0x02 /* R/O version of the volume is available (on this server) */ 23308e0e7c8SDavid Howells #define AFS_VOL_VTM_BAK 0x04 /* backup version of the volume is available (on this server) */ 23408e0e7c8SDavid Howells 23508e0e7c8SDavid Howells afs_volid_t vid[3]; /* volume IDs for R/W, R/O and Bak volumes */ 23608e0e7c8SDavid Howells struct in_addr servers[8]; /* fileserver addresses */ 23708e0e7c8SDavid Howells time_t rtime; /* last retrieval time */ 23808e0e7c8SDavid Howells }; 23908e0e7c8SDavid Howells 24008e0e7c8SDavid Howells /* 24108e0e7c8SDavid Howells * volume -> vnode hash table entry 24208e0e7c8SDavid Howells */ 24308e0e7c8SDavid Howells struct afs_cache_vhash { 24408e0e7c8SDavid Howells afs_voltype_t vtype; /* which volume variation */ 24508e0e7c8SDavid Howells uint8_t hash_bucket; /* which hash bucket this represents */ 24608e0e7c8SDavid Howells } __attribute__((packed)); 24708e0e7c8SDavid Howells 24808e0e7c8SDavid Howells /* 24908e0e7c8SDavid Howells * AFS volume location record 25008e0e7c8SDavid Howells */ 25108e0e7c8SDavid Howells struct afs_vlocation { 25208e0e7c8SDavid Howells atomic_t usage; 2538a79790bSTina Ruchandani time64_t time_of_death; /* time at which put reduced usage to 0 */ 25408e0e7c8SDavid Howells struct list_head link; /* link in cell volume location list */ 25508e0e7c8SDavid Howells struct list_head grave; /* link in master graveyard list */ 25608e0e7c8SDavid Howells struct list_head update; /* link in master update list */ 25708e0e7c8SDavid Howells struct afs_cell *cell; /* cell to which volume belongs */ 2589b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 2599b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 26008e0e7c8SDavid Howells #endif 26108e0e7c8SDavid Howells struct afs_cache_vlocation vldb; /* volume information DB record */ 26208e0e7c8SDavid Howells struct afs_volume *vols[3]; /* volume access record pointer (index by type) */ 26308e0e7c8SDavid Howells wait_queue_head_t waitq; /* status change waitqueue */ 2648a79790bSTina Ruchandani time64_t update_at; /* time at which record should be updated */ 26539bf0949SDavid S. Miller spinlock_t lock; /* access lock */ 26608e0e7c8SDavid Howells afs_vlocation_state_t state; /* volume location state */ 26708e0e7c8SDavid Howells unsigned short upd_rej_cnt; /* ENOMEDIUM count during update */ 26808e0e7c8SDavid Howells unsigned short upd_busy_cnt; /* EBUSY count during update */ 26908e0e7c8SDavid Howells bool valid; /* T if valid */ 27008e0e7c8SDavid Howells }; 27108e0e7c8SDavid Howells 27208e0e7c8SDavid Howells /* 27308e0e7c8SDavid Howells * AFS fileserver record 27408e0e7c8SDavid Howells */ 27508e0e7c8SDavid Howells struct afs_server { 27608e0e7c8SDavid Howells atomic_t usage; 2778a79790bSTina Ruchandani time64_t time_of_death; /* time at which put reduced usage to 0 */ 27808e0e7c8SDavid Howells struct in_addr addr; /* server address */ 27908e0e7c8SDavid Howells struct afs_cell *cell; /* cell in which server resides */ 28008e0e7c8SDavid Howells struct list_head link; /* link in cell's server list */ 28108e0e7c8SDavid Howells struct list_head grave; /* link in master graveyard list */ 28208e0e7c8SDavid Howells struct rb_node master_rb; /* link in master by-addr tree */ 28308e0e7c8SDavid Howells struct rw_semaphore sem; /* access lock */ 28408e0e7c8SDavid Howells 28508e0e7c8SDavid Howells /* file service access */ 28608e0e7c8SDavid Howells struct rb_root fs_vnodes; /* vnodes backed by this server (ordered by FID) */ 28708e0e7c8SDavid Howells unsigned long fs_act_jif; /* time at which last activity occurred */ 28808e0e7c8SDavid Howells unsigned long fs_dead_jif; /* time at which no longer to be considered dead */ 28908e0e7c8SDavid Howells spinlock_t fs_lock; /* access lock */ 29008e0e7c8SDavid Howells int fs_state; /* 0 or reason FS currently marked dead (-errno) */ 29108e0e7c8SDavid Howells 29208e0e7c8SDavid Howells /* callback promise management */ 29308e0e7c8SDavid Howells struct rb_root cb_promises; /* vnode expiration list (ordered earliest first) */ 29408e0e7c8SDavid Howells struct delayed_work cb_updater; /* callback updater */ 29508e0e7c8SDavid Howells struct delayed_work cb_break_work; /* collected break dispatcher */ 29608e0e7c8SDavid Howells wait_queue_head_t cb_break_waitq; /* space available in cb_break waitqueue */ 29708e0e7c8SDavid Howells spinlock_t cb_lock; /* access lock */ 29808e0e7c8SDavid Howells struct afs_callback cb_break[64]; /* ring of callbacks awaiting breaking */ 29908e0e7c8SDavid Howells atomic_t cb_break_n; /* number of pending breaks */ 30008e0e7c8SDavid Howells u8 cb_break_head; /* head of callback breaking ring */ 30108e0e7c8SDavid Howells u8 cb_break_tail; /* tail of callback breaking ring */ 30208e0e7c8SDavid Howells }; 30308e0e7c8SDavid Howells 30408e0e7c8SDavid Howells /* 30508e0e7c8SDavid Howells * AFS volume access record 30608e0e7c8SDavid Howells */ 30708e0e7c8SDavid Howells struct afs_volume { 30808e0e7c8SDavid Howells atomic_t usage; 30908e0e7c8SDavid Howells struct afs_cell *cell; /* cell to which belongs (unrefd ptr) */ 31008e0e7c8SDavid Howells struct afs_vlocation *vlocation; /* volume location */ 3119b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 3129b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 31308e0e7c8SDavid Howells #endif 31408e0e7c8SDavid Howells afs_volid_t vid; /* volume ID */ 31508e0e7c8SDavid Howells afs_voltype_t type; /* type of volume */ 31608e0e7c8SDavid Howells char type_force; /* force volume type (suppress R/O -> R/W) */ 31708e0e7c8SDavid Howells unsigned short nservers; /* number of server slots filled */ 31808e0e7c8SDavid Howells unsigned short rjservers; /* number of servers discarded due to -ENOMEDIUM */ 31908e0e7c8SDavid Howells struct afs_server *servers[8]; /* servers on which volume resides (ordered) */ 32008e0e7c8SDavid Howells struct rw_semaphore server_sem; /* lock for accessing current server */ 32108e0e7c8SDavid Howells }; 32208e0e7c8SDavid Howells 32308e0e7c8SDavid Howells /* 32408e0e7c8SDavid Howells * vnode catalogue entry 32508e0e7c8SDavid Howells */ 32608e0e7c8SDavid Howells struct afs_cache_vnode { 32708e0e7c8SDavid Howells afs_vnodeid_t vnode_id; /* vnode ID */ 32808e0e7c8SDavid Howells unsigned vnode_unique; /* vnode ID uniquifier */ 32908e0e7c8SDavid Howells afs_dataversion_t data_version; /* data version */ 33008e0e7c8SDavid Howells }; 33108e0e7c8SDavid Howells 33208e0e7c8SDavid Howells /* 33308e0e7c8SDavid Howells * AFS inode private data 33408e0e7c8SDavid Howells */ 33508e0e7c8SDavid Howells struct afs_vnode { 33608e0e7c8SDavid Howells struct inode vfs_inode; /* the VFS's inode record */ 33708e0e7c8SDavid Howells 33808e0e7c8SDavid Howells struct afs_volume *volume; /* volume on which vnode resides */ 33908e0e7c8SDavid Howells struct afs_server *server; /* server currently supplying this file */ 34008e0e7c8SDavid Howells struct afs_fid fid; /* the file identifier for this inode */ 34108e0e7c8SDavid Howells struct afs_file_status status; /* AFS status info for this file */ 3429b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 3439b3f26c9SDavid Howells struct fscache_cookie *cache; /* caching cookie */ 34408e0e7c8SDavid Howells #endif 34500d3b7a4SDavid Howells struct afs_permits *permits; /* cache of permits so far obtained */ 34600d3b7a4SDavid Howells struct mutex permits_lock; /* lock for altering permits list */ 347260a9803SDavid Howells struct mutex validate_lock; /* lock for validating this vnode */ 34808e0e7c8SDavid Howells wait_queue_head_t update_waitq; /* status fetch waitqueue */ 349260a9803SDavid Howells int update_cnt; /* number of outstanding ops that will update the 35008e0e7c8SDavid Howells * status */ 35131143d5dSDavid Howells spinlock_t writeback_lock; /* lock for writebacks */ 35208e0e7c8SDavid Howells spinlock_t lock; /* waitqueue/flags lock */ 35308e0e7c8SDavid Howells unsigned long flags; 35408e0e7c8SDavid Howells #define AFS_VNODE_CB_BROKEN 0 /* set if vnode's callback was broken */ 355260a9803SDavid Howells #define AFS_VNODE_UNSET 1 /* set if vnode attributes not yet set */ 35608e0e7c8SDavid Howells #define AFS_VNODE_MODIFIED 2 /* set if vnode's data modified */ 35708e0e7c8SDavid Howells #define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */ 35808e0e7c8SDavid Howells #define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */ 35908e0e7c8SDavid Howells #define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */ 360e8d6c554SDavid Howells #define AFS_VNODE_LOCKING 6 /* set if waiting for lock on vnode */ 361e8d6c554SDavid Howells #define AFS_VNODE_READLOCKED 7 /* set if vnode is read-locked on the server */ 362e8d6c554SDavid Howells #define AFS_VNODE_WRITELOCKED 8 /* set if vnode is write-locked on the server */ 363e8d6c554SDavid Howells #define AFS_VNODE_UNLOCKING 9 /* set if vnode is being unlocked on the server */ 364bec5eb61Swanglei #define AFS_VNODE_AUTOCELL 10 /* set if Vnode is an auto mount point */ 365bec5eb61Swanglei #define AFS_VNODE_PSEUDODIR 11 /* set if Vnode is a pseudo directory */ 36608e0e7c8SDavid Howells 36700d3b7a4SDavid Howells long acl_order; /* ACL check count (callback break count) */ 36800d3b7a4SDavid Howells 36931143d5dSDavid Howells struct list_head writebacks; /* alterations in pagecache that need writing */ 370e8d6c554SDavid Howells struct list_head pending_locks; /* locks waiting to be granted */ 371e8d6c554SDavid Howells struct list_head granted_locks; /* locks granted on this file */ 372e8d6c554SDavid Howells struct delayed_work lock_work; /* work to be done in locking */ 373e8d6c554SDavid Howells struct key *unlock_key; /* key to be used in unlocking */ 37431143d5dSDavid Howells 37508e0e7c8SDavid Howells /* outstanding callback notification on this file */ 37608e0e7c8SDavid Howells struct rb_node server_rb; /* link in server->fs_vnodes */ 37708e0e7c8SDavid Howells struct rb_node cb_promise; /* link in server->cb_promises */ 37808e0e7c8SDavid Howells struct work_struct cb_broken_work; /* work to be done on callback break */ 37956e71431STina Ruchandani time64_t cb_expires; /* time at which callback expires */ 38056e71431STina Ruchandani time64_t cb_expires_at; /* time used to order cb_promise */ 38108e0e7c8SDavid Howells unsigned cb_version; /* callback version */ 38208e0e7c8SDavid Howells unsigned cb_expiry; /* callback expiry time */ 38308e0e7c8SDavid Howells afs_callback_type_t cb_type; /* type of callback */ 38408e0e7c8SDavid Howells bool cb_promised; /* true if promise still holds */ 38508e0e7c8SDavid Howells }; 38608e0e7c8SDavid Howells 38700d3b7a4SDavid Howells /* 38800d3b7a4SDavid Howells * cached security record for one user's attempt to access a vnode 38900d3b7a4SDavid Howells */ 39000d3b7a4SDavid Howells struct afs_permit { 39100d3b7a4SDavid Howells struct key *key; /* RxRPC ticket holding a security context */ 39200d3b7a4SDavid Howells afs_access_t access_mask; /* access mask for this key */ 39300d3b7a4SDavid Howells }; 39400d3b7a4SDavid Howells 39500d3b7a4SDavid Howells /* 39600d3b7a4SDavid Howells * cache of security records from attempts to access a vnode 39700d3b7a4SDavid Howells */ 39800d3b7a4SDavid Howells struct afs_permits { 39900d3b7a4SDavid Howells struct rcu_head rcu; /* disposal procedure */ 40000d3b7a4SDavid Howells int count; /* number of records */ 40100d3b7a4SDavid Howells struct afs_permit permits[0]; /* the permits so far examined */ 40200d3b7a4SDavid Howells }; 40300d3b7a4SDavid Howells 404b908fe6bSDavid Howells /* 405b908fe6bSDavid Howells * record of one of a system's set of network interfaces 406b908fe6bSDavid Howells */ 407b908fe6bSDavid Howells struct afs_interface { 408b908fe6bSDavid Howells struct in_addr address; /* IPv4 address bound to interface */ 409b908fe6bSDavid Howells struct in_addr netmask; /* netmask applied to address */ 410b908fe6bSDavid Howells unsigned mtu; /* MTU of interface */ 411b908fe6bSDavid Howells }; 412b908fe6bSDavid Howells 41341bb26f8SChristoph Hellwig struct afs_uuid { 41441bb26f8SChristoph Hellwig __be32 time_low; /* low part of timestamp */ 41541bb26f8SChristoph Hellwig __be16 time_mid; /* mid part of timestamp */ 41641bb26f8SChristoph Hellwig __be16 time_hi_and_version; /* high part of timestamp and version */ 41741bb26f8SChristoph Hellwig __u8 clock_seq_hi_and_reserved; /* clock seq hi and variant */ 41841bb26f8SChristoph Hellwig __u8 clock_seq_low; /* clock seq low */ 41941bb26f8SChristoph Hellwig __u8 node[6]; /* spatially unique node ID (MAC addr) */ 42041bb26f8SChristoph Hellwig }; 42141bb26f8SChristoph Hellwig 42208e0e7c8SDavid Howells /*****************************************************************************/ 42308e0e7c8SDavid Howells /* 4249b3f26c9SDavid Howells * cache.c 4259b3f26c9SDavid Howells */ 4269b3f26c9SDavid Howells #ifdef CONFIG_AFS_FSCACHE 4279b3f26c9SDavid Howells extern struct fscache_netfs afs_cache_netfs; 4289b3f26c9SDavid Howells extern struct fscache_cookie_def afs_cell_cache_index_def; 4299b3f26c9SDavid Howells extern struct fscache_cookie_def afs_vlocation_cache_index_def; 4309b3f26c9SDavid Howells extern struct fscache_cookie_def afs_volume_cache_index_def; 4319b3f26c9SDavid Howells extern struct fscache_cookie_def afs_vnode_cache_index_def; 4329b3f26c9SDavid Howells #else 4339b3f26c9SDavid Howells #define afs_cell_cache_index_def (*(struct fscache_cookie_def *) NULL) 4349b3f26c9SDavid Howells #define afs_vlocation_cache_index_def (*(struct fscache_cookie_def *) NULL) 4359b3f26c9SDavid Howells #define afs_volume_cache_index_def (*(struct fscache_cookie_def *) NULL) 4369b3f26c9SDavid Howells #define afs_vnode_cache_index_def (*(struct fscache_cookie_def *) NULL) 4379b3f26c9SDavid Howells #endif 4389b3f26c9SDavid Howells 4399b3f26c9SDavid Howells /* 44008e0e7c8SDavid Howells * callback.c 44108e0e7c8SDavid Howells */ 44208e0e7c8SDavid Howells extern void afs_init_callback_state(struct afs_server *); 44308e0e7c8SDavid Howells extern void afs_broken_callback_work(struct work_struct *); 44408e0e7c8SDavid Howells extern void afs_break_callbacks(struct afs_server *, size_t, 44508e0e7c8SDavid Howells struct afs_callback[]); 446260a9803SDavid Howells extern void afs_discard_callback_on_delete(struct afs_vnode *); 44708e0e7c8SDavid Howells extern void afs_give_up_callback(struct afs_vnode *); 44808e0e7c8SDavid Howells extern void afs_dispatch_give_up_callbacks(struct work_struct *); 44908e0e7c8SDavid Howells extern void afs_flush_callback_breaks(struct afs_server *); 45008e0e7c8SDavid Howells extern int __init afs_callback_update_init(void); 451fbb3fcbaSDavid Howells extern void afs_callback_update_kill(void); 4521da177e4SLinus Torvalds 4531da177e4SLinus Torvalds /* 4541da177e4SLinus Torvalds * cell.c 4551da177e4SLinus Torvalds */ 4561da177e4SLinus Torvalds extern struct rw_semaphore afs_proc_cells_sem; 4571da177e4SLinus Torvalds extern struct list_head afs_proc_cells; 4581da177e4SLinus Torvalds 45908e0e7c8SDavid Howells #define afs_get_cell(C) do { atomic_inc(&(C)->usage); } while(0) 46008e0e7c8SDavid Howells extern int afs_cell_init(char *); 461bec5eb61Swanglei extern struct afs_cell *afs_cell_create(const char *, unsigned, char *, bool); 462bec5eb61Swanglei extern struct afs_cell *afs_cell_lookup(const char *, unsigned, bool); 46308e0e7c8SDavid Howells extern struct afs_cell *afs_grab_cell(struct afs_cell *); 46408e0e7c8SDavid Howells extern void afs_put_cell(struct afs_cell *); 46508e0e7c8SDavid Howells extern void afs_cell_purge(void); 46608e0e7c8SDavid Howells 46708e0e7c8SDavid Howells /* 46808e0e7c8SDavid Howells * cmservice.c 46908e0e7c8SDavid Howells */ 47008e0e7c8SDavid Howells extern bool afs_cm_incoming_call(struct afs_call *); 47108e0e7c8SDavid Howells 4721da177e4SLinus Torvalds /* 4731da177e4SLinus Torvalds * dir.c 4741da177e4SLinus Torvalds */ 475754661f1SArjan van de Ven extern const struct inode_operations afs_dir_inode_operations; 476d61dcce2SAl Viro extern const struct dentry_operations afs_fs_dentry_operations; 4774b6f5d20SArjan van de Ven extern const struct file_operations afs_dir_file_operations; 4781da177e4SLinus Torvalds 4791da177e4SLinus Torvalds /* 4801da177e4SLinus Torvalds * file.c 4811da177e4SLinus Torvalds */ 482f5e54d6eSChristoph Hellwig extern const struct address_space_operations afs_fs_aops; 483754661f1SArjan van de Ven extern const struct inode_operations afs_file_inode_operations; 48400d3b7a4SDavid Howells extern const struct file_operations afs_file_operations; 48500d3b7a4SDavid Howells 48600d3b7a4SDavid Howells extern int afs_open(struct inode *, struct file *); 48700d3b7a4SDavid Howells extern int afs_release(struct inode *, struct file *); 488f6d335c0SAl Viro extern int afs_page_filler(void *, struct page *); 489196ee9cdSDavid Howells extern void afs_put_read(struct afs_read *); 4901da177e4SLinus Torvalds 4911da177e4SLinus Torvalds /* 492e8d6c554SDavid Howells * flock.c 493e8d6c554SDavid Howells */ 494e8d6c554SDavid Howells extern void __exit afs_kill_lock_manager(void); 495e8d6c554SDavid Howells extern void afs_lock_work(struct work_struct *); 496e8d6c554SDavid Howells extern void afs_lock_may_be_available(struct afs_vnode *); 497e8d6c554SDavid Howells extern int afs_lock(struct file *, int, struct file_lock *); 498e8d6c554SDavid Howells extern int afs_flock(struct file *, int, struct file_lock *); 499e8d6c554SDavid Howells 500e8d6c554SDavid Howells /* 50108e0e7c8SDavid Howells * fsclient.c 50208e0e7c8SDavid Howells */ 50300d3b7a4SDavid Howells extern int afs_fs_fetch_file_status(struct afs_server *, struct key *, 50400d3b7a4SDavid Howells struct afs_vnode *, struct afs_volsync *, 50556ff9c83SDavid Howells bool); 50656ff9c83SDavid Howells extern int afs_fs_give_up_callbacks(struct afs_server *, bool); 50700d3b7a4SDavid Howells extern int afs_fs_fetch_data(struct afs_server *, struct key *, 50856ff9c83SDavid Howells struct afs_vnode *, struct afs_read *, bool); 509260a9803SDavid Howells extern int afs_fs_create(struct afs_server *, struct key *, 510260a9803SDavid Howells struct afs_vnode *, const char *, umode_t, 511260a9803SDavid Howells struct afs_fid *, struct afs_file_status *, 51256ff9c83SDavid Howells struct afs_callback *, bool); 513260a9803SDavid Howells extern int afs_fs_remove(struct afs_server *, struct key *, 51456ff9c83SDavid Howells struct afs_vnode *, const char *, bool, bool); 515260a9803SDavid Howells extern int afs_fs_link(struct afs_server *, struct key *, struct afs_vnode *, 51656ff9c83SDavid Howells struct afs_vnode *, const char *, bool); 517260a9803SDavid Howells extern int afs_fs_symlink(struct afs_server *, struct key *, 518260a9803SDavid Howells struct afs_vnode *, const char *, const char *, 51956ff9c83SDavid Howells struct afs_fid *, struct afs_file_status *, bool); 520260a9803SDavid Howells extern int afs_fs_rename(struct afs_server *, struct key *, 521260a9803SDavid Howells struct afs_vnode *, const char *, 52256ff9c83SDavid Howells struct afs_vnode *, const char *, bool); 52331143d5dSDavid Howells extern int afs_fs_store_data(struct afs_server *, struct afs_writeback *, 52456ff9c83SDavid Howells pgoff_t, pgoff_t, unsigned, unsigned, bool); 52531143d5dSDavid Howells extern int afs_fs_setattr(struct afs_server *, struct key *, 52656ff9c83SDavid Howells struct afs_vnode *, struct iattr *, bool); 52745222b9eSDavid Howells extern int afs_fs_get_volume_status(struct afs_server *, struct key *, 52845222b9eSDavid Howells struct afs_vnode *, 52956ff9c83SDavid Howells struct afs_volume_status *, bool); 530e8d6c554SDavid Howells extern int afs_fs_set_lock(struct afs_server *, struct key *, 53156ff9c83SDavid Howells struct afs_vnode *, afs_lock_type_t, bool); 532e8d6c554SDavid Howells extern int afs_fs_extend_lock(struct afs_server *, struct key *, 53356ff9c83SDavid Howells struct afs_vnode *, bool); 534e8d6c554SDavid Howells extern int afs_fs_release_lock(struct afs_server *, struct key *, 53556ff9c83SDavid Howells struct afs_vnode *, bool); 53608e0e7c8SDavid Howells 53708e0e7c8SDavid Howells /* 5381da177e4SLinus Torvalds * inode.c 5391da177e4SLinus Torvalds */ 540bec5eb61Swanglei extern struct inode *afs_iget_autocell(struct inode *, const char *, int, 541bec5eb61Swanglei struct key *); 54200d3b7a4SDavid Howells extern struct inode *afs_iget(struct super_block *, struct key *, 543260a9803SDavid Howells struct afs_fid *, struct afs_file_status *, 544260a9803SDavid Howells struct afs_callback *); 545416351f2SDavid Howells extern void afs_zap_data(struct afs_vnode *); 546260a9803SDavid Howells extern int afs_validate(struct afs_vnode *, struct key *); 547a528d35eSDavid Howells extern int afs_getattr(const struct path *, struct kstat *, u32, unsigned int); 54831143d5dSDavid Howells extern int afs_setattr(struct dentry *, struct iattr *); 549b57922d9SAl Viro extern void afs_evict_inode(struct inode *); 550bec5eb61Swanglei extern int afs_drop_inode(struct inode *); 5511da177e4SLinus Torvalds 5521da177e4SLinus Torvalds /* 5531da177e4SLinus Torvalds * main.c 5541da177e4SLinus Torvalds */ 5550ad53eeeSTejun Heo extern struct workqueue_struct *afs_wq; 55641bb26f8SChristoph Hellwig extern struct afs_uuid afs_uuid; 5571da177e4SLinus Torvalds 5581da177e4SLinus Torvalds /* 55908e0e7c8SDavid Howells * misc.c 56008e0e7c8SDavid Howells */ 56108e0e7c8SDavid Howells extern int afs_abort_to_error(u32); 56208e0e7c8SDavid Howells 56308e0e7c8SDavid Howells /* 5641da177e4SLinus Torvalds * mntpt.c 5651da177e4SLinus Torvalds */ 566754661f1SArjan van de Ven extern const struct inode_operations afs_mntpt_inode_operations; 567bec5eb61Swanglei extern const struct inode_operations afs_autocell_inode_operations; 5684b6f5d20SArjan van de Ven extern const struct file_operations afs_mntpt_file_operations; 5691da177e4SLinus Torvalds 570d18610b0SDavid Howells extern struct vfsmount *afs_d_automount(struct path *); 57108e0e7c8SDavid Howells extern void afs_mntpt_kill_timer(void); 5721da177e4SLinus Torvalds 5731da177e4SLinus Torvalds /* 574b4db2b35SArnd Bergmann * netdevices.c 575b4db2b35SArnd Bergmann */ 576b4db2b35SArnd Bergmann extern int afs_get_ipv4_interfaces(struct afs_interface *, size_t, bool); 577b4db2b35SArnd Bergmann 578b4db2b35SArnd Bergmann /* 5791da177e4SLinus Torvalds * proc.c 5801da177e4SLinus Torvalds */ 5811da177e4SLinus Torvalds extern int afs_proc_init(void); 5821da177e4SLinus Torvalds extern void afs_proc_cleanup(void); 583ec26815aSDavid Howells extern int afs_proc_cell_setup(struct afs_cell *); 584ec26815aSDavid Howells extern void afs_proc_cell_remove(struct afs_cell *); 5851da177e4SLinus Torvalds 58608e0e7c8SDavid Howells /* 58708e0e7c8SDavid Howells * rxrpc.c 58808e0e7c8SDavid Howells */ 5898324f0bcSDavid Howells extern struct socket *afs_socket; 590341f741fSDavid Howells extern atomic_t afs_outstanding_calls; 5918324f0bcSDavid Howells 59208e0e7c8SDavid Howells extern int afs_open_socket(void); 59308e0e7c8SDavid Howells extern void afs_close_socket(void); 594341f741fSDavid Howells extern void afs_put_call(struct afs_call *); 595341f741fSDavid Howells extern int afs_queue_call_work(struct afs_call *); 59656ff9c83SDavid Howells extern int afs_make_call(struct in_addr *, struct afs_call *, gfp_t, bool); 59708e0e7c8SDavid Howells extern struct afs_call *afs_alloc_flat_call(const struct afs_call_type *, 59808e0e7c8SDavid Howells size_t, size_t); 59908e0e7c8SDavid Howells extern void afs_flat_call_destructor(struct afs_call *); 60008e0e7c8SDavid Howells extern void afs_send_empty_reply(struct afs_call *); 601b908fe6bSDavid Howells extern void afs_send_simple_reply(struct afs_call *, const void *, size_t); 602d001648eSDavid Howells extern int afs_extract_data(struct afs_call *, void *, size_t, bool); 60308e0e7c8SDavid Howells 604d001648eSDavid Howells static inline int afs_transfer_reply(struct afs_call *call) 605372ee163SDavid Howells { 606d001648eSDavid Howells return afs_extract_data(call, call->buffer, call->reply_max, false); 607372ee163SDavid Howells } 608372ee163SDavid Howells 60908e0e7c8SDavid Howells /* 61000d3b7a4SDavid Howells * security.c 61100d3b7a4SDavid Howells */ 61200d3b7a4SDavid Howells extern void afs_clear_permits(struct afs_vnode *); 61300d3b7a4SDavid Howells extern void afs_cache_permit(struct afs_vnode *, struct key *, long); 614416351f2SDavid Howells extern void afs_zap_permits(struct rcu_head *); 61500d3b7a4SDavid Howells extern struct key *afs_request_key(struct afs_cell *); 61610556cb2SAl Viro extern int afs_permission(struct inode *, int); 61700d3b7a4SDavid Howells 61800d3b7a4SDavid Howells /* 61908e0e7c8SDavid Howells * server.c 62008e0e7c8SDavid Howells */ 62108e0e7c8SDavid Howells extern spinlock_t afs_server_peer_lock; 62208e0e7c8SDavid Howells 623260a9803SDavid Howells #define afs_get_server(S) \ 624260a9803SDavid Howells do { \ 625260a9803SDavid Howells _debug("GET SERVER %d", atomic_read(&(S)->usage)); \ 626260a9803SDavid Howells atomic_inc(&(S)->usage); \ 627260a9803SDavid Howells } while(0) 62808e0e7c8SDavid Howells 62908e0e7c8SDavid Howells extern struct afs_server *afs_lookup_server(struct afs_cell *, 63008e0e7c8SDavid Howells const struct in_addr *); 6318324f0bcSDavid Howells extern struct afs_server *afs_find_server(const struct sockaddr_rxrpc *); 63208e0e7c8SDavid Howells extern void afs_put_server(struct afs_server *); 63308e0e7c8SDavid Howells extern void __exit afs_purge_servers(void); 63408e0e7c8SDavid Howells 63508e0e7c8SDavid Howells /* 63600d3b7a4SDavid Howells * super.c 63700d3b7a4SDavid Howells */ 63800d3b7a4SDavid Howells extern int afs_fs_init(void); 63900d3b7a4SDavid Howells extern void afs_fs_exit(void); 64000d3b7a4SDavid Howells 64100d3b7a4SDavid Howells /* 64208e0e7c8SDavid Howells * vlclient.c 64308e0e7c8SDavid Howells */ 64400d3b7a4SDavid Howells extern int afs_vl_get_entry_by_name(struct in_addr *, struct key *, 64500d3b7a4SDavid Howells const char *, struct afs_cache_vlocation *, 64656ff9c83SDavid Howells bool); 64700d3b7a4SDavid Howells extern int afs_vl_get_entry_by_id(struct in_addr *, struct key *, 64800d3b7a4SDavid Howells afs_volid_t, afs_voltype_t, 64956ff9c83SDavid Howells struct afs_cache_vlocation *, bool); 65008e0e7c8SDavid Howells 65108e0e7c8SDavid Howells /* 65208e0e7c8SDavid Howells * vlocation.c 65308e0e7c8SDavid Howells */ 65408e0e7c8SDavid Howells #define afs_get_vlocation(V) do { atomic_inc(&(V)->usage); } while(0) 65508e0e7c8SDavid Howells 65608e0e7c8SDavid Howells extern int __init afs_vlocation_update_init(void); 65708e0e7c8SDavid Howells extern struct afs_vlocation *afs_vlocation_lookup(struct afs_cell *, 65800d3b7a4SDavid Howells struct key *, 65908e0e7c8SDavid Howells const char *, size_t); 66008e0e7c8SDavid Howells extern void afs_put_vlocation(struct afs_vlocation *); 661fbb3fcbaSDavid Howells extern void afs_vlocation_purge(void); 66208e0e7c8SDavid Howells 66308e0e7c8SDavid Howells /* 66408e0e7c8SDavid Howells * vnode.c 66508e0e7c8SDavid Howells */ 66608e0e7c8SDavid Howells static inline struct afs_vnode *AFS_FS_I(struct inode *inode) 66708e0e7c8SDavid Howells { 66808e0e7c8SDavid Howells return container_of(inode, struct afs_vnode, vfs_inode); 66908e0e7c8SDavid Howells } 67008e0e7c8SDavid Howells 67108e0e7c8SDavid Howells static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode) 67208e0e7c8SDavid Howells { 67308e0e7c8SDavid Howells return &vnode->vfs_inode; 67408e0e7c8SDavid Howells } 67508e0e7c8SDavid Howells 676260a9803SDavid Howells extern void afs_vnode_finalise_status_update(struct afs_vnode *, 677260a9803SDavid Howells struct afs_server *); 67800d3b7a4SDavid Howells extern int afs_vnode_fetch_status(struct afs_vnode *, struct afs_vnode *, 67900d3b7a4SDavid Howells struct key *); 68000d3b7a4SDavid Howells extern int afs_vnode_fetch_data(struct afs_vnode *, struct key *, 681196ee9cdSDavid Howells struct afs_read *); 682260a9803SDavid Howells extern int afs_vnode_create(struct afs_vnode *, struct key *, const char *, 683260a9803SDavid Howells umode_t, struct afs_fid *, struct afs_file_status *, 684260a9803SDavid Howells struct afs_callback *, struct afs_server **); 685260a9803SDavid Howells extern int afs_vnode_remove(struct afs_vnode *, struct key *, const char *, 686260a9803SDavid Howells bool); 687260a9803SDavid Howells extern int afs_vnode_link(struct afs_vnode *, struct afs_vnode *, struct key *, 688260a9803SDavid Howells const char *); 689260a9803SDavid Howells extern int afs_vnode_symlink(struct afs_vnode *, struct key *, const char *, 690260a9803SDavid Howells const char *, struct afs_fid *, 691260a9803SDavid Howells struct afs_file_status *, struct afs_server **); 692260a9803SDavid Howells extern int afs_vnode_rename(struct afs_vnode *, struct afs_vnode *, 693260a9803SDavid Howells struct key *, const char *, const char *); 69431143d5dSDavid Howells extern int afs_vnode_store_data(struct afs_writeback *, pgoff_t, pgoff_t, 69531143d5dSDavid Howells unsigned, unsigned); 69631143d5dSDavid Howells extern int afs_vnode_setattr(struct afs_vnode *, struct key *, struct iattr *); 69745222b9eSDavid Howells extern int afs_vnode_get_volume_status(struct afs_vnode *, struct key *, 69845222b9eSDavid Howells struct afs_volume_status *); 699e8d6c554SDavid Howells extern int afs_vnode_set_lock(struct afs_vnode *, struct key *, 700e8d6c554SDavid Howells afs_lock_type_t); 701e8d6c554SDavid Howells extern int afs_vnode_extend_lock(struct afs_vnode *, struct key *); 702e8d6c554SDavid Howells extern int afs_vnode_release_lock(struct afs_vnode *, struct key *); 70308e0e7c8SDavid Howells 70408e0e7c8SDavid Howells /* 70508e0e7c8SDavid Howells * volume.c 70608e0e7c8SDavid Howells */ 70708e0e7c8SDavid Howells #define afs_get_volume(V) do { atomic_inc(&(V)->usage); } while(0) 70808e0e7c8SDavid Howells 70908e0e7c8SDavid Howells extern void afs_put_volume(struct afs_volume *); 71000d3b7a4SDavid Howells extern struct afs_volume *afs_volume_lookup(struct afs_mount_params *); 71108e0e7c8SDavid Howells extern struct afs_server *afs_volume_pick_fileserver(struct afs_vnode *); 71208e0e7c8SDavid Howells extern int afs_volume_release_fileserver(struct afs_vnode *, 71308e0e7c8SDavid Howells struct afs_server *, int); 71408e0e7c8SDavid Howells 71531143d5dSDavid Howells /* 71631143d5dSDavid Howells * write.c 71731143d5dSDavid Howells */ 71831143d5dSDavid Howells extern int afs_set_page_dirty(struct page *); 71931143d5dSDavid Howells extern void afs_put_writeback(struct afs_writeback *); 72015b4650eSNick Piggin extern int afs_write_begin(struct file *file, struct address_space *mapping, 72115b4650eSNick Piggin loff_t pos, unsigned len, unsigned flags, 72215b4650eSNick Piggin struct page **pagep, void **fsdata); 72315b4650eSNick Piggin extern int afs_write_end(struct file *file, struct address_space *mapping, 72415b4650eSNick Piggin loff_t pos, unsigned len, unsigned copied, 72515b4650eSNick Piggin struct page *page, void *fsdata); 72631143d5dSDavid Howells extern int afs_writepage(struct page *, struct writeback_control *); 72731143d5dSDavid Howells extern int afs_writepages(struct address_space *, struct writeback_control *); 72831143d5dSDavid Howells extern void afs_pages_written_back(struct afs_vnode *, struct afs_call *); 72950b5551dSAl Viro extern ssize_t afs_file_write(struct kiocb *, struct iov_iter *); 73031143d5dSDavid Howells extern int afs_writeback_all(struct afs_vnode *); 73158fed94dSDavid Howells extern int afs_flush(struct file *, fl_owner_t); 73202c24a82SJosef Bacik extern int afs_fsync(struct file *, loff_t, loff_t, int); 73331143d5dSDavid Howells 73431143d5dSDavid Howells 73508e0e7c8SDavid Howells /*****************************************************************************/ 73608e0e7c8SDavid Howells /* 73708e0e7c8SDavid Howells * debug tracing 73808e0e7c8SDavid Howells */ 7398e8d7f13SDavid Howells #include <trace/events/afs.h> 7408e8d7f13SDavid Howells 74108e0e7c8SDavid Howells extern unsigned afs_debug; 74208e0e7c8SDavid Howells 74308e0e7c8SDavid Howells #define dbgprintk(FMT,...) \ 744ad16df84SSven Schnelle printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__) 74508e0e7c8SDavid Howells 746530b6412SHarvey Harrison #define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__) 747530b6412SHarvey Harrison #define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) 74808e0e7c8SDavid Howells #define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__) 74908e0e7c8SDavid Howells 75008e0e7c8SDavid Howells 75108e0e7c8SDavid Howells #if defined(__KDEBUG) 75208e0e7c8SDavid Howells #define _enter(FMT,...) kenter(FMT,##__VA_ARGS__) 75308e0e7c8SDavid Howells #define _leave(FMT,...) kleave(FMT,##__VA_ARGS__) 75408e0e7c8SDavid Howells #define _debug(FMT,...) kdebug(FMT,##__VA_ARGS__) 75508e0e7c8SDavid Howells 75608e0e7c8SDavid Howells #elif defined(CONFIG_AFS_DEBUG) 75708e0e7c8SDavid Howells #define AFS_DEBUG_KENTER 0x01 75808e0e7c8SDavid Howells #define AFS_DEBUG_KLEAVE 0x02 75908e0e7c8SDavid Howells #define AFS_DEBUG_KDEBUG 0x04 76008e0e7c8SDavid Howells 76108e0e7c8SDavid Howells #define _enter(FMT,...) \ 76208e0e7c8SDavid Howells do { \ 76308e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KENTER)) \ 76408e0e7c8SDavid Howells kenter(FMT,##__VA_ARGS__); \ 76508e0e7c8SDavid Howells } while (0) 76608e0e7c8SDavid Howells 76708e0e7c8SDavid Howells #define _leave(FMT,...) \ 76808e0e7c8SDavid Howells do { \ 76908e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KLEAVE)) \ 77008e0e7c8SDavid Howells kleave(FMT,##__VA_ARGS__); \ 77108e0e7c8SDavid Howells } while (0) 77208e0e7c8SDavid Howells 77308e0e7c8SDavid Howells #define _debug(FMT,...) \ 77408e0e7c8SDavid Howells do { \ 77508e0e7c8SDavid Howells if (unlikely(afs_debug & AFS_DEBUG_KDEBUG)) \ 77608e0e7c8SDavid Howells kdebug(FMT,##__VA_ARGS__); \ 77708e0e7c8SDavid Howells } while (0) 77808e0e7c8SDavid Howells 77908e0e7c8SDavid Howells #else 78012fdff3fSDavid Howells #define _enter(FMT,...) no_printk("==> %s("FMT")",__func__ ,##__VA_ARGS__) 78112fdff3fSDavid Howells #define _leave(FMT,...) no_printk("<== %s()"FMT"",__func__ ,##__VA_ARGS__) 78212fdff3fSDavid Howells #define _debug(FMT,...) no_printk(" "FMT ,##__VA_ARGS__) 78308e0e7c8SDavid Howells #endif 78408e0e7c8SDavid Howells 78508e0e7c8SDavid Howells /* 78608e0e7c8SDavid Howells * debug assertion checking 78708e0e7c8SDavid Howells */ 78808e0e7c8SDavid Howells #if 1 // defined(__KDEBUGALL) 78908e0e7c8SDavid Howells 79008e0e7c8SDavid Howells #define ASSERT(X) \ 79108e0e7c8SDavid Howells do { \ 79208e0e7c8SDavid Howells if (unlikely(!(X))) { \ 79308e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 79408e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 79508e0e7c8SDavid Howells BUG(); \ 79608e0e7c8SDavid Howells } \ 79708e0e7c8SDavid Howells } while(0) 79808e0e7c8SDavid Howells 79908e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y) \ 80008e0e7c8SDavid Howells do { \ 80108e0e7c8SDavid Howells if (unlikely(!((X) OP (Y)))) { \ 80208e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 80308e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 80408e0e7c8SDavid Howells printk(KERN_ERR "%lu " #OP " %lu is false\n", \ 80508e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 80608e0e7c8SDavid Howells printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ 80708e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 80808e0e7c8SDavid Howells BUG(); \ 80908e0e7c8SDavid Howells } \ 81008e0e7c8SDavid Howells } while(0) 81108e0e7c8SDavid Howells 812416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H) \ 813416351f2SDavid Howells do { \ 814416351f2SDavid Howells if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) { \ 815416351f2SDavid Howells printk(KERN_ERR "\n"); \ 816416351f2SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 817416351f2SDavid Howells printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n", \ 818416351f2SDavid Howells (unsigned long)(L), (unsigned long)(N), \ 819416351f2SDavid Howells (unsigned long)(H)); \ 820416351f2SDavid Howells printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \ 821416351f2SDavid Howells (unsigned long)(L), (unsigned long)(N), \ 822416351f2SDavid Howells (unsigned long)(H)); \ 823416351f2SDavid Howells BUG(); \ 824416351f2SDavid Howells } \ 825416351f2SDavid Howells } while(0) 826416351f2SDavid Howells 82708e0e7c8SDavid Howells #define ASSERTIF(C, X) \ 82808e0e7c8SDavid Howells do { \ 82908e0e7c8SDavid Howells if (unlikely((C) && !(X))) { \ 83008e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 83108e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 83208e0e7c8SDavid Howells BUG(); \ 83308e0e7c8SDavid Howells } \ 83408e0e7c8SDavid Howells } while(0) 83508e0e7c8SDavid Howells 83608e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y) \ 83708e0e7c8SDavid Howells do { \ 83808e0e7c8SDavid Howells if (unlikely((C) && !((X) OP (Y)))) { \ 83908e0e7c8SDavid Howells printk(KERN_ERR "\n"); \ 84008e0e7c8SDavid Howells printk(KERN_ERR "AFS: Assertion failed\n"); \ 84108e0e7c8SDavid Howells printk(KERN_ERR "%lu " #OP " %lu is false\n", \ 84208e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 84308e0e7c8SDavid Howells printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \ 84408e0e7c8SDavid Howells (unsigned long)(X), (unsigned long)(Y)); \ 84508e0e7c8SDavid Howells BUG(); \ 84608e0e7c8SDavid Howells } \ 84708e0e7c8SDavid Howells } while(0) 84808e0e7c8SDavid Howells 84908e0e7c8SDavid Howells #else 85008e0e7c8SDavid Howells 85108e0e7c8SDavid Howells #define ASSERT(X) \ 85208e0e7c8SDavid Howells do { \ 85308e0e7c8SDavid Howells } while(0) 85408e0e7c8SDavid Howells 85508e0e7c8SDavid Howells #define ASSERTCMP(X, OP, Y) \ 85608e0e7c8SDavid Howells do { \ 85708e0e7c8SDavid Howells } while(0) 85808e0e7c8SDavid Howells 859416351f2SDavid Howells #define ASSERTRANGE(L, OP1, N, OP2, H) \ 860416351f2SDavid Howells do { \ 861416351f2SDavid Howells } while(0) 862416351f2SDavid Howells 86308e0e7c8SDavid Howells #define ASSERTIF(C, X) \ 86408e0e7c8SDavid Howells do { \ 86508e0e7c8SDavid Howells } while(0) 86608e0e7c8SDavid Howells 86708e0e7c8SDavid Howells #define ASSERTIFCMP(C, X, OP, Y) \ 86808e0e7c8SDavid Howells do { \ 86908e0e7c8SDavid Howells } while(0) 87008e0e7c8SDavid Howells 87108e0e7c8SDavid Howells #endif /* __KDEBUGALL */ 872