drop unused dentry argument to ->fsync
[safe/jmp/linux-2.6] / fs / afs / internal.h
index 6120d4b..5f679b7 100644 (file)
 #include <linux/skbuff.h>
 #include <linux/rxrpc.h>
 #include <linux/key.h>
+#include <linux/workqueue.h>
+#include <linux/sched.h>
+#include <linux/fscache.h>
+#include <linux/backing-dev.h>
+
 #include "afs.h"
 #include "afs_vl.h"
 
 #define AFS_CELL_MAX_ADDRS 15
 
+struct pagevec;
 struct afs_call;
 
 typedef enum {
@@ -75,11 +81,15 @@ struct afs_call {
        struct key              *key;           /* security for this call */
        struct afs_server       *server;        /* server affected by incoming CM call */
        void                    *request;       /* request data (first part) */
-       void                    *request2;      /* request data (second part) */
+       struct address_space    *mapping;       /* page set */
+       struct afs_writeback    *wb;            /* writeback being performed */
        void                    *buffer;        /* reply receive buffer */
        void                    *reply;         /* reply buffer (first part) */
        void                    *reply2;        /* reply buffer (second part) */
        void                    *reply3;        /* reply buffer (third part) */
+       void                    *reply4;        /* reply buffer (fourth part) */
+       pgoff_t                 first;          /* first page in mapping to deal with */
+       pgoff_t                 last;           /* last page in mapping to deal with */
        enum {                                  /* call state */
                AFS_CALL_REQUESTING,    /* request is being sent for outgoing call */
                AFS_CALL_AWAIT_REPLY,   /* awaiting reply to outgoing call */
@@ -96,14 +106,18 @@ struct afs_call {
        unsigned                request_size;   /* size of request data */
        unsigned                reply_max;      /* maximum size of reply */
        unsigned                reply_size;     /* current size of reply */
+       unsigned                first_offset;   /* offset into mapping[first] */
+       unsigned                last_to;        /* amount of mapping[last] */
        unsigned short          offset;         /* offset into received data store */
        unsigned char           unmarshall;     /* unmarshalling phase */
        bool                    incoming;       /* T if incoming call */
+       bool                    send_pages;     /* T if data from mapping should be sent */
        u16                     service_id;     /* RxRPC service ID to call */
        __be16                  port;           /* target UDP port */
        __be32                  operation_ID;   /* operation ID for an incoming call */
        u32                     count;          /* count for use in unmarshalling */
        __be32                  tmp;            /* place to extract temporary data */
+       afs_dataversion_t       store_version;  /* updated version expected from store */
 };
 
 struct afs_call_type {
@@ -123,6 +137,32 @@ struct afs_call_type {
 };
 
 /*
+ * record of an outstanding writeback on a vnode
+ */
+struct afs_writeback {
+       struct list_head        link;           /* link in vnode->writebacks */
+       struct work_struct      writer;         /* work item to perform the writeback */
+       struct afs_vnode        *vnode;         /* vnode to which this write applies */
+       struct key              *key;           /* owner of this write */
+       wait_queue_head_t       waitq;          /* completion and ready wait queue */
+       pgoff_t                 first;          /* first page in batch */
+       pgoff_t                 point;          /* last page in current store op */
+       pgoff_t                 last;           /* last page in batch (inclusive) */
+       unsigned                offset_first;   /* offset into first page of start of write */
+       unsigned                to_last;        /* offset into last page of end of write */
+       int                     num_conflicts;  /* count of conflicting writes in list */
+       int                     usage;
+       bool                    conflicts;      /* T if has dependent conflicts */
+       enum {
+               AFS_WBACK_SYNCING,              /* synchronisation being performed */
+               AFS_WBACK_PENDING,              /* write pending */
+               AFS_WBACK_CONFLICTING,          /* conflicting writes posted */
+               AFS_WBACK_WRITING,              /* writing back */
+               AFS_WBACK_COMPLETE              /* the writeback record has been unlinked */
+       } state __attribute__((packed));
+};
+
+/*
  * AFS superblock private data
  * - there's one superblock per volume
  */
@@ -155,8 +195,8 @@ struct afs_cell {
        struct key              *anonymous_key; /* anonymous user key for this cell */
        struct list_head        proc_link;      /* /proc cell list link */
        struct proc_dir_entry   *proc_dir;      /* /proc dir for this cell */
-#ifdef AFS_CACHING_SUPPORT
-       struct cachefs_cookie   *cache;         /* caching cookie */
+#ifdef CONFIG_AFS_FSCACHE
+       struct fscache_cookie   *cache;         /* caching cookie */
 #endif
 
        /* server record management */
@@ -211,14 +251,14 @@ struct afs_vlocation {
        struct list_head        grave;          /* link in master graveyard list */
        struct list_head        update;         /* link in master update list */
        struct afs_cell         *cell;          /* cell to which volume belongs */
-#ifdef AFS_CACHING_SUPPORT
-       struct cachefs_cookie   *cache;         /* caching cookie */
+#ifdef CONFIG_AFS_FSCACHE
+       struct fscache_cookie   *cache;         /* caching cookie */
 #endif
        struct afs_cache_vlocation vldb;        /* volume information DB record */
        struct afs_volume       *vols[3];       /* volume access record pointer (index by type) */
        wait_queue_head_t       waitq;          /* status change waitqueue */
        time_t                  update_at;      /* time at which record should be updated */
-       rwlock_t                lock;           /* access lock */
+       spinlock_t              lock;           /* access lock */
        afs_vlocation_state_t   state;          /* volume location state */
        unsigned short          upd_rej_cnt;    /* ENOMEDIUM count during update */
        unsigned short          upd_busy_cnt;   /* EBUSY count during update */
@@ -264,8 +304,8 @@ struct afs_volume {
        atomic_t                usage;
        struct afs_cell         *cell;          /* cell to which belongs (unrefd ptr) */
        struct afs_vlocation    *vlocation;     /* volume location */
-#ifdef AFS_CACHING_SUPPORT
-       struct cachefs_cookie   *cache;         /* caching cookie */
+#ifdef CONFIG_AFS_FSCACHE
+       struct fscache_cookie   *cache;         /* caching cookie */
 #endif
        afs_volid_t             vid;            /* volume ID */
        afs_voltype_t           type;           /* type of volume */
@@ -274,6 +314,7 @@ struct afs_volume {
        unsigned short          rjservers;      /* number of servers discarded due to -ENOMEDIUM */
        struct afs_server       *servers[8];    /* servers on which volume resides (ordered) */
        struct rw_semaphore     server_sem;     /* lock for accessing current server */
+       struct backing_dev_info bdi;
 };
 
 /*
@@ -295,32 +336,41 @@ struct afs_vnode {
        struct afs_server       *server;        /* server currently supplying this file */
        struct afs_fid          fid;            /* the file identifier for this inode */
        struct afs_file_status  status;         /* AFS status info for this file */
-#ifdef AFS_CACHING_SUPPORT
-       struct cachefs_cookie   *cache;         /* caching cookie */
+#ifdef CONFIG_AFS_FSCACHE
+       struct fscache_cookie   *cache;         /* caching cookie */
 #endif
        struct afs_permits      *permits;       /* cache of permits so far obtained */
        struct mutex            permits_lock;   /* lock for altering permits list */
+       struct mutex            validate_lock;  /* lock for validating this vnode */
        wait_queue_head_t       update_waitq;   /* status fetch waitqueue */
-       unsigned                update_cnt;     /* number of outstanding ops that will update the
+       int                     update_cnt;     /* number of outstanding ops that will update the
                                                 * status */
+       spinlock_t              writeback_lock; /* lock for writebacks */
        spinlock_t              lock;           /* waitqueue/flags lock */
        unsigned long           flags;
 #define AFS_VNODE_CB_BROKEN    0               /* set if vnode's callback was broken */
-#define AFS_VNODE_CHANGED      1               /* set if vnode's metadata changed */
+#define AFS_VNODE_UNSET                1               /* set if vnode attributes not yet set */
 #define AFS_VNODE_MODIFIED     2               /* set if vnode's data modified */
 #define AFS_VNODE_ZAP_DATA     3               /* set if vnode's data should be invalidated */
 #define AFS_VNODE_DELETED      4               /* set if vnode deleted on server */
 #define AFS_VNODE_MOUNTPOINT   5               /* set if vnode is a mountpoint symlink */
-#define AFS_VNODE_DIR_CHANGED  6               /* set if vnode's parent dir metadata changed */
-#define AFS_VNODE_DIR_MODIFIED 7               /* set if vnode's parent dir data modified */
+#define AFS_VNODE_LOCKING      6               /* set if waiting for lock on vnode */
+#define AFS_VNODE_READLOCKED   7               /* set if vnode is read-locked on the server */
+#define AFS_VNODE_WRITELOCKED  8               /* set if vnode is write-locked on the server */
+#define AFS_VNODE_UNLOCKING    9               /* set if vnode is being unlocked on the server */
 
        long                    acl_order;      /* ACL check count (callback break count) */
 
+       struct list_head        writebacks;     /* alterations in pagecache that need writing */
+       struct list_head        pending_locks;  /* locks waiting to be granted */
+       struct list_head        granted_locks;  /* locks granted on this file */
+       struct delayed_work     lock_work;      /* work to be done in locking */
+       struct key              *unlock_key;    /* key to be used in unlocking */
+
        /* outstanding callback notification on this file */
        struct rb_node          server_rb;      /* link in server->fs_vnodes */
        struct rb_node          cb_promise;     /* link in server->cb_promises */
        struct work_struct      cb_broken_work; /* work to be done on callback break */
-       struct mutex            cb_broken_lock; /* lock against multiple attempts to fix break */
        time_t                  cb_expires;     /* time at which callback expires */
        time_t                  cb_expires_at;  /* time used to order cb_promise */
        unsigned                cb_version;     /* callback version */
@@ -350,7 +400,6 @@ struct afs_permits {
  * record of one of a system's set of network interfaces
  */
 struct afs_interface {
-       unsigned        index;          /* interface index */
        struct in_addr  address;        /* IPv4 address bound to interface */
        struct in_addr  netmask;        /* netmask applied to address */
        unsigned        mtu;            /* MTU of interface */
@@ -368,7 +417,7 @@ struct afs_uuid {
        u32             time_low;                       /* low part of timestamp */
        u16             time_mid;                       /* mid part of timestamp */
        u16             time_hi_and_version;            /* high part of timestamp and version  */
-#define AFS_UUID_TO_UNIX_TIME  0x01b21dd213814000
+#define AFS_UUID_TO_UNIX_TIME  0x01b21dd213814000ULL
 #define AFS_UUID_TIMEHI_MASK   0x0fff
 #define AFS_UUID_VERSION_TIME  0x1000  /* time-based UUID */
 #define AFS_UUID_VERSION_NAME  0x3000  /* name-based UUID */
@@ -382,26 +431,40 @@ struct afs_uuid {
 
 /*****************************************************************************/
 /*
+ * cache.c
+ */
+#ifdef CONFIG_AFS_FSCACHE
+extern struct fscache_netfs afs_cache_netfs;
+extern struct fscache_cookie_def afs_cell_cache_index_def;
+extern struct fscache_cookie_def afs_vlocation_cache_index_def;
+extern struct fscache_cookie_def afs_volume_cache_index_def;
+extern struct fscache_cookie_def afs_vnode_cache_index_def;
+#else
+#define afs_cell_cache_index_def       (*(struct fscache_cookie_def *) NULL)
+#define afs_vlocation_cache_index_def  (*(struct fscache_cookie_def *) NULL)
+#define afs_volume_cache_index_def     (*(struct fscache_cookie_def *) NULL)
+#define afs_vnode_cache_index_def      (*(struct fscache_cookie_def *) NULL)
+#endif
+
+/*
  * callback.c
  */
 extern void afs_init_callback_state(struct afs_server *);
 extern void afs_broken_callback_work(struct work_struct *);
 extern void afs_break_callbacks(struct afs_server *, size_t,
                                struct afs_callback[]);
+extern void afs_discard_callback_on_delete(struct afs_vnode *);
 extern void afs_give_up_callback(struct afs_vnode *);
 extern void afs_dispatch_give_up_callbacks(struct work_struct *);
 extern void afs_flush_callback_breaks(struct afs_server *);
 extern int __init afs_callback_update_init(void);
-extern void __exit afs_callback_update_kill(void);
+extern void afs_callback_update_kill(void);
 
 /*
  * cell.c
  */
 extern struct rw_semaphore afs_proc_cells_sem;
 extern struct list_head afs_proc_cells;
-#ifdef AFS_CACHING_SUPPORT
-extern struct cachefs_index_def afs_cache_cell_index_def;
-#endif
 
 #define afs_get_cell(C) do { atomic_inc(&(C)->usage); } while(0)
 extern int afs_cell_init(char *);
@@ -422,8 +485,6 @@ extern bool afs_cm_incoming_call(struct afs_call *);
 extern const struct inode_operations afs_dir_inode_operations;
 extern const struct file_operations afs_dir_file_operations;
 
-extern int afs_permission(struct inode *, int, struct nameidata *);
-
 /*
  * file.c
  */
@@ -433,10 +494,16 @@ extern const struct file_operations afs_file_operations;
 
 extern int afs_open(struct inode *, struct file *);
 extern int afs_release(struct inode *, struct file *);
+extern int afs_page_filler(void *, struct page *);
 
-#ifdef AFS_CACHING_SUPPORT
-extern int afs_cache_get_page_cookie(struct page *, struct cachefs_page **);
-#endif
+/*
+ * flock.c
+ */
+extern void __exit afs_kill_lock_manager(void);
+extern void afs_lock_work(struct work_struct *);
+extern void afs_lock_may_be_available(struct afs_vnode *);
+extern int afs_lock(struct file *, int, struct file_lock *);
+extern int afs_flock(struct file *, int, struct file_lock *);
 
 /*
  * fsclient.c
@@ -448,26 +515,62 @@ extern int afs_fs_give_up_callbacks(struct afs_server *,
                                    const struct afs_wait_mode *);
 extern int afs_fs_fetch_data(struct afs_server *, struct key *,
                             struct afs_vnode *, off_t, size_t, struct page *,
-                            struct afs_volsync *,
                             const struct afs_wait_mode *);
+extern int afs_fs_create(struct afs_server *, struct key *,
+                        struct afs_vnode *, const char *, umode_t,
+                        struct afs_fid *, struct afs_file_status *,
+                        struct afs_callback *,
+                        const struct afs_wait_mode *);
+extern int afs_fs_remove(struct afs_server *, struct key *,
+                        struct afs_vnode *, const char *, bool,
+                        const struct afs_wait_mode *);
+extern int afs_fs_link(struct afs_server *, struct key *, struct afs_vnode *,
+                      struct afs_vnode *, const char *,
+                      const struct afs_wait_mode *);
+extern int afs_fs_symlink(struct afs_server *, struct key *,
+                         struct afs_vnode *, const char *, const char *,
+                         struct afs_fid *, struct afs_file_status *,
+                         const struct afs_wait_mode *);
+extern int afs_fs_rename(struct afs_server *, struct key *,
+                        struct afs_vnode *, const char *,
+                        struct afs_vnode *, const char *,
+                        const struct afs_wait_mode *);
+extern int afs_fs_store_data(struct afs_server *, struct afs_writeback *,
+                            pgoff_t, pgoff_t, unsigned, unsigned,
+                            const struct afs_wait_mode *);
+extern int afs_fs_setattr(struct afs_server *, struct key *,
+                         struct afs_vnode *, struct iattr *,
+                         const struct afs_wait_mode *);
+extern int afs_fs_get_volume_status(struct afs_server *, struct key *,
+                                   struct afs_vnode *,
+                                   struct afs_volume_status *,
+                                   const struct afs_wait_mode *);
+extern int afs_fs_set_lock(struct afs_server *, struct key *,
+                          struct afs_vnode *, afs_lock_type_t,
+                          const struct afs_wait_mode *);
+extern int afs_fs_extend_lock(struct afs_server *, struct key *,
+                             struct afs_vnode *,
+                             const struct afs_wait_mode *);
+extern int afs_fs_release_lock(struct afs_server *, struct key *,
+                              struct afs_vnode *,
+                              const struct afs_wait_mode *);
 
 /*
  * inode.c
  */
 extern struct inode *afs_iget(struct super_block *, struct key *,
-                             struct afs_fid *);
-extern int afs_inode_getattr(struct vfsmount *, struct dentry *,
-                            struct kstat *);
-extern void afs_zap_permits(struct rcu_head *);
+                             struct afs_fid *, struct afs_file_status *,
+                             struct afs_callback *);
+extern void afs_zap_data(struct afs_vnode *);
+extern int afs_validate(struct afs_vnode *, struct key *);
+extern int afs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
+extern int afs_setattr(struct dentry *, struct iattr *);
 extern void afs_clear_inode(struct inode *);
 
 /*
  * main.c
  */
 extern struct afs_uuid afs_uuid;
-#ifdef AFS_CACHING_SUPPORT
-extern struct cachefs_netfs afs_cache_netfs;
-#endif
 
 /*
  * misc.c
@@ -479,11 +582,9 @@ extern int afs_abort_to_error(u32);
  */
 extern const struct inode_operations afs_mntpt_inode_operations;
 extern const struct file_operations afs_mntpt_file_operations;
-extern unsigned long afs_mntpt_expiry_timeout;
 
 extern int afs_mntpt_check_symlink(struct afs_vnode *, struct key *);
 extern void afs_mntpt_kill_timer(void);
-extern void afs_umount_begin(struct vfsmount *, int);
 
 /*
  * proc.c
@@ -514,15 +615,20 @@ extern int afs_extract_data(struct afs_call *, struct sk_buff *, bool, void *,
  */
 extern void afs_clear_permits(struct afs_vnode *);
 extern void afs_cache_permit(struct afs_vnode *, struct key *, long);
+extern void afs_zap_permits(struct rcu_head *);
 extern struct key *afs_request_key(struct afs_cell *);
-extern int afs_permission(struct inode *, int, struct nameidata *);
+extern int afs_permission(struct inode *, int);
 
 /*
  * server.c
  */
 extern spinlock_t afs_server_peer_lock;
 
-#define afs_get_server(S) do { atomic_inc(&(S)->usage); } while(0)
+#define afs_get_server(S)                                      \
+do {                                                           \
+       _debug("GET SERVER %d", atomic_read(&(S)->usage));      \
+       atomic_inc(&(S)->usage);                                \
+} while(0)
 
 extern struct afs_server *afs_lookup_server(struct afs_cell *,
                                            const struct in_addr *);
@@ -540,15 +646,11 @@ extern void afs_fs_exit(void);
  * use-rtnetlink.c
  */
 extern int afs_get_ipv4_interfaces(struct afs_interface *, size_t, bool);
-extern int afs_get_MAC_address(u8 [6]);
+extern int afs_get_MAC_address(u8 *, size_t);
 
 /*
  * vlclient.c
  */
-#ifdef AFS_CACHING_SUPPORT
-extern struct cachefs_index_def afs_vlocation_cache_index_def;
-#endif
-
 extern int afs_vl_get_entry_by_name(struct in_addr *, struct key *,
                                    const char *, struct afs_cache_vlocation *,
                                    const struct afs_wait_mode *);
@@ -567,17 +669,11 @@ extern struct afs_vlocation *afs_vlocation_lookup(struct afs_cell *,
                                                  struct key *,
                                                  const char *, size_t);
 extern void afs_put_vlocation(struct afs_vlocation *);
-extern void __exit afs_vlocation_purge(void);
+extern void afs_vlocation_purge(void);
 
 /*
  * vnode.c
  */
-#ifdef AFS_CACHING_SUPPORT
-extern struct cachefs_index_def afs_vnode_cache_index_def;
-#endif
-
-extern struct afs_timer_ops afs_vnode_cb_timed_out_ops;
-
 static inline struct afs_vnode *AFS_FS_I(struct inode *inode)
 {
        return container_of(inode, struct afs_vnode, vfs_inode);
@@ -588,18 +684,37 @@ static inline struct inode *AFS_VNODE_TO_I(struct afs_vnode *vnode)
        return &vnode->vfs_inode;
 }
 
+extern void afs_vnode_finalise_status_update(struct afs_vnode *,
+                                            struct afs_server *);
 extern int afs_vnode_fetch_status(struct afs_vnode *, struct afs_vnode *,
                                  struct key *);
 extern int afs_vnode_fetch_data(struct afs_vnode *, struct key *,
                                off_t, size_t, struct page *);
+extern int afs_vnode_create(struct afs_vnode *, struct key *, const char *,
+                           umode_t, struct afs_fid *, struct afs_file_status *,
+                           struct afs_callback *, struct afs_server **);
+extern int afs_vnode_remove(struct afs_vnode *, struct key *, const char *,
+                           bool);
+extern int afs_vnode_link(struct afs_vnode *, struct afs_vnode *, struct key *,
+                         const char *);
+extern int afs_vnode_symlink(struct afs_vnode *, struct key *, const char *,
+                            const char *, struct afs_fid *,
+                            struct afs_file_status *, struct afs_server **);
+extern int afs_vnode_rename(struct afs_vnode *, struct afs_vnode *,
+                           struct key *, const char *, const char *);
+extern int afs_vnode_store_data(struct afs_writeback *, pgoff_t, pgoff_t,
+                               unsigned, unsigned);
+extern int afs_vnode_setattr(struct afs_vnode *, struct key *, struct iattr *);
+extern int afs_vnode_get_volume_status(struct afs_vnode *, struct key *,
+                                      struct afs_volume_status *);
+extern int afs_vnode_set_lock(struct afs_vnode *, struct key *,
+                             afs_lock_type_t);
+extern int afs_vnode_extend_lock(struct afs_vnode *, struct key *);
+extern int afs_vnode_release_lock(struct afs_vnode *, struct key *);
 
 /*
  * volume.c
  */
-#ifdef AFS_CACHING_SUPPORT
-extern struct cachefs_index_def afs_volume_cache_index_def;
-#endif
-
 #define afs_get_volume(V) do { atomic_inc(&(V)->usage); } while(0)
 
 extern void afs_put_volume(struct afs_volume *);
@@ -608,6 +723,26 @@ extern struct afs_server *afs_volume_pick_fileserver(struct afs_vnode *);
 extern int afs_volume_release_fileserver(struct afs_vnode *,
                                         struct afs_server *, int);
 
+/*
+ * write.c
+ */
+extern int afs_set_page_dirty(struct page *);
+extern void afs_put_writeback(struct afs_writeback *);
+extern int afs_write_begin(struct file *file, struct address_space *mapping,
+                       loff_t pos, unsigned len, unsigned flags,
+                       struct page **pagep, void **fsdata);
+extern int afs_write_end(struct file *file, struct address_space *mapping,
+                       loff_t pos, unsigned len, unsigned copied,
+                       struct page *page, void *fsdata);
+extern int afs_writepage(struct page *, struct writeback_control *);
+extern int afs_writepages(struct address_space *, struct writeback_control *);
+extern void afs_pages_written_back(struct afs_vnode *, struct afs_call *);
+extern ssize_t afs_file_write(struct kiocb *, const struct iovec *,
+                             unsigned long, loff_t);
+extern int afs_writeback_all(struct afs_vnode *);
+extern int afs_fsync(struct file *, int);
+
+
 /*****************************************************************************/
 /*
  * debug tracing
@@ -615,7 +750,7 @@ extern int afs_volume_release_fileserver(struct afs_vnode *,
 extern unsigned afs_debug;
 
 #define dbgprintk(FMT,...) \
-       printk("[%x%-6.6s] "FMT"\n", smp_processor_id(), current->comm ,##__VA_ARGS__)
+       printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__)
 
 /* make sure we maintain the format strings, even when debugging is disabled */
 static inline __attribute__((format(printf,1,2)))
@@ -623,8 +758,8 @@ void _dbprintk(const char *fmt, ...)
 {
 }
 
-#define kenter(FMT,...)        dbgprintk("==> %s("FMT")",__FUNCTION__ ,##__VA_ARGS__)
-#define kleave(FMT,...)        dbgprintk("<== %s()"FMT"",__FUNCTION__ ,##__VA_ARGS__)
+#define kenter(FMT,...)        dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
+#define kleave(FMT,...)        dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
 #define kdebug(FMT,...)        dbgprintk("    "FMT ,##__VA_ARGS__)
 
 
@@ -657,8 +792,8 @@ do {                                                        \
 } while (0)
 
 #else
-#define _enter(FMT,...)        _dbprintk("==> %s("FMT")",__FUNCTION__ ,##__VA_ARGS__)
-#define _leave(FMT,...)        _dbprintk("<== %s()"FMT"",__FUNCTION__ ,##__VA_ARGS__)
+#define _enter(FMT,...)        _dbprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
+#define _leave(FMT,...)        _dbprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
 #define _debug(FMT,...)        _dbprintk("    "FMT ,##__VA_ARGS__)
 #endif
 
@@ -689,6 +824,21 @@ do {                                                                       \
        }                                                               \
 } while(0)
 
+#define ASSERTRANGE(L, OP1, N, OP2, H)                                 \
+do {                                                                   \
+       if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) {               \
+               printk(KERN_ERR "\n");                                  \
+               printk(KERN_ERR "AFS: Assertion failed\n");             \
+               printk(KERN_ERR "%lu "#OP1" %lu "#OP2" %lu is false\n", \
+                      (unsigned long)(L), (unsigned long)(N),          \
+                      (unsigned long)(H));                             \
+               printk(KERN_ERR "0x%lx "#OP1" 0x%lx "#OP2" 0x%lx is false\n", \
+                      (unsigned long)(L), (unsigned long)(N),          \
+                      (unsigned long)(H));                             \
+               BUG();                                                  \
+       }                                                               \
+} while(0)
+
 #define ASSERTIF(C, X)                                         \
 do {                                                           \
        if (unlikely((C) && !(X))) {                            \
@@ -721,6 +871,10 @@ do {                                               \
 do {                                           \
 } while(0)
 
+#define ASSERTRANGE(L, OP1, N, OP2, H)         \
+do {                                           \
+} while(0)
+
 #define ASSERTIF(C, X)                         \
 do {                                           \
 } while(0)