]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - include/linux/nfs_fs.h
NFS: Add a count of the number of unstable writes carried by an inode
[linux-2.6.git] / include / linux / nfs_fs.h
index 47aaa2c66738c5d574b96d9048964e7822227a00..309217f46e289c024d2be4ae6598bf93577747e7 100644 (file)
 #include <linux/magic.h>
 
 /* Default timeout values */
+#define NFS_DEF_UDP_TIMEO      (11)
+#define NFS_DEF_UDP_RETRANS    (3)
+#define NFS_DEF_TCP_TIMEO      (600)
+#define NFS_DEF_TCP_RETRANS    (2)
+
 #define NFS_MAX_UDP_TIMEOUT    (60*HZ)
 #define NFS_MAX_TCP_TIMEOUT    (600*HZ)
 
+#define NFS_DEF_ACREGMIN       (3)
+#define NFS_DEF_ACREGMAX       (60)
+#define NFS_DEF_ACDIRMIN       (30)
+#define NFS_DEF_ACDIRMAX       (60)
+
 /*
  * When flushing a cluster of dirty pages, there can be different
  * strategies:
 #include <linux/nfs3.h>
 #include <linux/nfs4.h>
 #include <linux/nfs_xdr.h>
-
 #include <linux/nfs_fs_sb.h>
 
-#include <linux/rwsem.h>
 #include <linux/mempool.h>
 
 /*
@@ -70,12 +78,14 @@ struct nfs_access_entry {
 struct nfs4_state;
 struct nfs_open_context {
        atomic_t count;
-       struct vfsmount *vfsmnt;
-       struct dentry *dentry;
+       struct path path;
        struct rpc_cred *cred;
        struct nfs4_state *state;
        fl_owner_t lockowner;
-       int mode;
+       fmode_t mode;
+
+       unsigned long flags;
+#define NFS_CONTEXT_ERROR_WRITE                (0)
        int error;
 
        struct list_head list;
@@ -119,24 +129,22 @@ struct nfs_inode {
         *
         * We need to revalidate the cached attrs for this inode if
         *
-        *      jiffies - read_cache_jiffies > attrtimeo
+        *      jiffies - read_cache_jiffies >= attrtimeo
+        *
+        * Please note the comparison is greater than or equal
+        * so that zero timeout values can be specified.
         */
        unsigned long           read_cache_jiffies;
        unsigned long           attrtimeo;
        unsigned long           attrtimeo_timestamp;
        __u64                   change_attr;            /* v4 only */
 
-       unsigned long           last_updated;
+       unsigned long           attr_gencount;
        /* "Generation counter" for the attribute cache. This is
         * bumped whenever we update the metadata on the
         * server.
         */
        unsigned long           cache_change_attribute;
-       /*
-        * Counter indicating the number of outstanding requests that
-        * will cause a file data update.
-        */
-       atomic_t                data_updates;
 
        struct rb_root          access_cache;
        struct list_head        access_cache_entry_lru;
@@ -155,26 +163,31 @@ struct nfs_inode {
        /*
         * This is the list of dirty unwritten pages.
         */
-       spinlock_t              req_lock;
-       struct list_head        dirty;
-       struct list_head        commit;
        struct radix_tree_root  nfs_page_tree;
 
-       unsigned int            ndirty,
-                               ncommit,
-                               npages;
+       unsigned long           npages;
+       unsigned long           ncommit;
 
        /* Open contexts for shared mmap writes */
        struct list_head        open_files;
 
+       /* Number of in-flight sillydelete RPC calls */
+       atomic_t                silly_count;
+       /* List of deferred sillydelete requests */
+       struct hlist_head       silly_list;
+       wait_queue_head_t       waitqueue;
+
 #ifdef CONFIG_NFS_V4
        struct nfs4_cached_acl  *nfs4_acl;
         /* NFSv4 state */
        struct list_head        open_states;
        struct nfs_delegation   *delegation;
-       int                      delegation_state;
+       fmode_t                  delegation_state;
        struct rw_semaphore     rwsem;
 #endif /* CONFIG_NFS_V4*/
+#ifdef CONFIG_NFS_FSCACHE
+       struct fscache_cookie   *fscache;
+#endif
        struct inode            vfs_inode;
 };
 
@@ -187,45 +200,84 @@ struct nfs_inode {
 #define NFS_INO_INVALID_ACCESS 0x0008          /* cached access cred invalid */
 #define NFS_INO_INVALID_ACL    0x0010          /* cached acls are invalid */
 #define NFS_INO_REVAL_PAGECACHE        0x0020          /* must revalidate pagecache */
+#define NFS_INO_REVAL_FORCED   0x0040          /* force revalidation ignoring a delegation */
 
 /*
  * Bit offsets in flags field
  */
-#define NFS_INO_REVALIDATING   (0)             /* revalidating attrs */
-#define NFS_INO_ADVISE_RDPLUS  (1)             /* advise readdirplus */
-#define NFS_INO_STALE          (2)             /* possible stale inode */
-#define NFS_INO_ACL_LRU_SET    (3)             /* Inode is on the LRU list */
-
-static inline struct nfs_inode *NFS_I(struct inode *inode)
+#define NFS_INO_ADVISE_RDPLUS  (0)             /* advise readdirplus */
+#define NFS_INO_STALE          (1)             /* possible stale inode */
+#define NFS_INO_ACL_LRU_SET    (2)             /* Inode is on the LRU list */
+#define NFS_INO_MOUNTPOINT     (3)             /* inode is remote mountpoint */
+#define NFS_INO_FLUSHING       (4)             /* inode is flushing out data */
+#define NFS_INO_FSCACHE                (5)             /* inode can be cached by FS-Cache */
+#define NFS_INO_FSCACHE_LOCK   (6)             /* FS-Cache cookie management lock */
+
+static inline struct nfs_inode *NFS_I(const struct inode *inode)
 {
        return container_of(inode, struct nfs_inode, vfs_inode);
 }
-#define NFS_SB(s)              ((struct nfs_server *)(s->s_fs_info))
-
-#define NFS_FH(inode)                  (&NFS_I(inode)->fh)
-#define NFS_SERVER(inode)              (NFS_SB(inode->i_sb))
-#define NFS_CLIENT(inode)              (NFS_SERVER(inode)->client)
-#define NFS_PROTO(inode)               (NFS_SERVER(inode)->nfs_client->rpc_ops)
-#define NFS_COOKIEVERF(inode)          (NFS_I(inode)->cookieverf)
-#define NFS_READTIME(inode)            (NFS_I(inode)->read_cache_jiffies)
-#define NFS_CHANGE_ATTR(inode)         (NFS_I(inode)->change_attr)
-#define NFS_ATTRTIMEO(inode)           (NFS_I(inode)->attrtimeo)
-#define NFS_MINATTRTIMEO(inode) \
-       (S_ISDIR(inode->i_mode)? NFS_SERVER(inode)->acdirmin \
-                              : NFS_SERVER(inode)->acregmin)
-#define NFS_MAXATTRTIMEO(inode) \
-       (S_ISDIR(inode->i_mode)? NFS_SERVER(inode)->acdirmax \
-                              : NFS_SERVER(inode)->acregmax)
-#define NFS_ATTRTIMEO_UPDATE(inode)    (NFS_I(inode)->attrtimeo_timestamp)
-
-#define NFS_FLAGS(inode)               (NFS_I(inode)->flags)
-#define NFS_STALE(inode)               (test_bit(NFS_INO_STALE, &NFS_FLAGS(inode)))
-
-#define NFS_FILEID(inode)              (NFS_I(inode)->fileid)
-
-static inline int nfs_caches_unstable(struct inode *inode)
+
+static inline struct nfs_server *NFS_SB(const struct super_block *s)
+{
+       return (struct nfs_server *)(s->s_fs_info);
+}
+
+static inline struct nfs_fh *NFS_FH(const struct inode *inode)
+{
+       return &NFS_I(inode)->fh;
+}
+
+static inline struct nfs_server *NFS_SERVER(const struct inode *inode)
+{
+       return NFS_SB(inode->i_sb);
+}
+
+static inline struct rpc_clnt *NFS_CLIENT(const struct inode *inode)
+{
+       return NFS_SERVER(inode)->client;
+}
+
+static inline const struct nfs_rpc_ops *NFS_PROTO(const struct inode *inode)
+{
+       return NFS_SERVER(inode)->nfs_client->rpc_ops;
+}
+
+static inline __be32 *NFS_COOKIEVERF(const struct inode *inode)
+{
+       return NFS_I(inode)->cookieverf;
+}
+
+static inline unsigned NFS_MINATTRTIMEO(const struct inode *inode)
+{
+       struct nfs_server *nfss = NFS_SERVER(inode);
+       return S_ISDIR(inode->i_mode) ? nfss->acdirmin : nfss->acregmin;
+}
+
+static inline unsigned NFS_MAXATTRTIMEO(const struct inode *inode)
+{
+       struct nfs_server *nfss = NFS_SERVER(inode);
+       return S_ISDIR(inode->i_mode) ? nfss->acdirmax : nfss->acregmax;
+}
+
+static inline int NFS_STALE(const struct inode *inode)
+{
+       return test_bit(NFS_INO_STALE, &NFS_I(inode)->flags);
+}
+
+static inline int NFS_FSCACHE(const struct inode *inode)
 {
-       return atomic_read(&NFS_I(inode)->data_updates) != 0;
+       return test_bit(NFS_INO_FSCACHE, &NFS_I(inode)->flags);
+}
+
+static inline __u64 NFS_FILEID(const struct inode *inode)
+{
+       return NFS_I(inode)->fileid;
+}
+
+static inline void set_nfs_fileid(struct inode *inode, __u64 fileid)
+{
+       NFS_I(inode)->fileid = fileid;
 }
 
 static inline void nfs_mark_for_revalidate(struct inode *inode)
@@ -239,12 +291,6 @@ static inline void nfs_mark_for_revalidate(struct inode *inode)
        spin_unlock(&inode->i_lock);
 }
 
-static inline void NFS_CACHEINV(struct inode *inode)
-{
-       if (!nfs_caches_unstable(inode))
-               nfs_mark_for_revalidate(inode);
-}
-
 static inline int nfs_server_capable(struct inode *inode, int cap)
 {
        return NFS_SERVER(inode)->caps & cap;
@@ -252,31 +298,36 @@ static inline int nfs_server_capable(struct inode *inode, int cap)
 
 static inline int NFS_USE_READDIRPLUS(struct inode *inode)
 {
-       return test_bit(NFS_INO_ADVISE_RDPLUS, &NFS_FLAGS(inode));
+       return test_bit(NFS_INO_ADVISE_RDPLUS, &NFS_I(inode)->flags);
+}
+
+static inline void nfs_set_verifier(struct dentry * dentry, unsigned long verf)
+{
+       dentry->d_time = verf;
 }
 
 /**
  * nfs_save_change_attribute - Returns the inode attribute change cookie
- * @inode - pointer to inode
+ * @dir - pointer to parent directory inode
  * The "change attribute" is updated every time we finish an operation
  * that will result in a metadata change on the server.
  */
-static inline long nfs_save_change_attribute(struct inode *inode)
+static inline unsigned long nfs_save_change_attribute(struct inode *dir)
 {
-       return NFS_I(inode)->cache_change_attribute;
+       return NFS_I(dir)->cache_change_attribute;
 }
 
 /**
- * nfs_verify_change_attribute - Detects NFS inode cache updates
- * @inode - pointer to inode
+ * nfs_verify_change_attribute - Detects NFS remote directory changes
+ * @dir - pointer to parent directory inode
  * @chattr - previously saved change attribute
- * Return "false" if metadata has been updated (or is in the process of
- * being updated) since the change attribute was saved.
+ * Return "false" if the verifiers doesn't match the change attribute.
+ * This would usually indicate that the directory contents have changed on
+ * the server, and that any dentries need revalidating.
  */
-static inline int nfs_verify_change_attribute(struct inode *inode, unsigned long chattr)
+static inline int nfs_verify_change_attribute(struct inode *dir, unsigned long chattr)
 {
-       return !nfs_caches_unstable(inode)
-               && time_after_eq(chattr, NFS_I(inode)->cache_change_attribute);
+       return chattr == NFS_I(dir)->cache_change_attribute;
 }
 
 /*
@@ -285,15 +336,14 @@ static inline int nfs_verify_change_attribute(struct inode *inode, unsigned long
 extern int nfs_sync_mapping(struct address_space *mapping);
 extern void nfs_zap_mapping(struct inode *inode, struct address_space *mapping);
 extern void nfs_zap_caches(struct inode *);
+extern void nfs_invalidate_atime(struct inode *);
 extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *,
                                struct nfs_fattr *);
 extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *);
 extern int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr);
+extern int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr);
 extern int nfs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
-extern int nfs_permission(struct inode *, int, struct nameidata *);
-extern int nfs_access_get_cached(struct inode *, struct rpc_cred *, struct nfs_access_entry *);
-extern void nfs_access_add_cache(struct inode *, struct nfs_access_entry *);
-extern void nfs_access_zap_cache(struct inode *inode);
+extern int nfs_permission(struct inode *, int);
 extern int nfs_open(struct inode *, struct file *);
 extern int nfs_release(struct inode *, struct file *);
 extern int nfs_attribute_timeout(struct inode *inode);
@@ -303,22 +353,15 @@ extern int nfs_revalidate_mapping(struct inode *inode, struct address_space *map
 extern int nfs_revalidate_mapping_nolock(struct inode *inode, struct address_space *mapping);
 extern int nfs_setattr(struct dentry *, struct iattr *);
 extern void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr);
-extern void nfs_begin_attr_update(struct inode *);
-extern void nfs_end_attr_update(struct inode *);
-extern void nfs_begin_data_update(struct inode *);
-extern void nfs_end_data_update(struct inode *);
 extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx);
 extern void put_nfs_open_context(struct nfs_open_context *ctx);
-extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, int mode);
+extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, fmode_t mode);
+extern u64 nfs_compat_user_ino64(u64 fileid);
+extern void nfs_fattr_init(struct nfs_fattr *fattr);
 
 /* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */
 extern __be32 root_nfs_parse_addr(char *name); /*__init*/
-
-static inline void nfs_fattr_init(struct nfs_fattr *fattr)
-{
-       fattr->valid = 0;
-       fattr->time_start = jiffies;
-}
+extern unsigned long nfs_inc_attr_generation_counter(void);
 
 /*
  * linux/fs/nfs/file.c
@@ -330,13 +373,18 @@ extern const struct inode_operations nfs3_file_inode_operations;
 extern const struct file_operations nfs_file_operations;
 extern const struct address_space_operations nfs_file_aops;
 
+static inline struct nfs_open_context *nfs_file_open_context(struct file *filp)
+{
+       return filp->private_data;
+}
+
 static inline struct rpc_cred *nfs_file_cred(struct file *file)
 {
        if (file != NULL) {
-               struct nfs_open_context *ctx;
-
-               ctx = (struct nfs_open_context*)file->private_data;
-               return ctx->cred;
+               struct nfs_open_context *ctx =
+                       nfs_file_open_context(file);
+               if (ctx)
+                       return ctx->cred;
        }
        return NULL;
 }
@@ -377,9 +425,12 @@ extern const struct inode_operations nfs_dir_inode_operations;
 extern const struct inode_operations nfs3_dir_inode_operations;
 #endif /* CONFIG_NFS_V3 */
 extern const struct file_operations nfs_dir_operations;
-extern struct dentry_operations nfs_dentry_operations;
+extern const struct dentry_operations nfs_dentry_operations;
 
+extern void nfs_force_lookup_revalidate(struct inode *dir);
 extern int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fh, struct nfs_fattr *fattr);
+extern int nfs_may_open(struct inode *inode, struct rpc_cred *cred, int openflags);
+extern void nfs_access_zap_cache(struct inode *inode);
 
 /*
  * linux/fs/nfs/symlink.c
@@ -400,7 +451,6 @@ extern void nfs_unregister_sysctl(void);
 /*
  * linux/fs/nfs/namespace.c
  */
-extern struct list_head nfs_automount_list;
 extern const struct inode_operations nfs_mountpoint_inode_operations;
 extern const struct inode_operations nfs_referral_inode_operations;
 extern int nfs_mountpoint_expiry_timeout;
@@ -409,40 +459,33 @@ extern void nfs_release_automount_timer(void);
 /*
  * linux/fs/nfs/unlink.c
  */
-extern int  nfs_async_unlink(struct dentry *);
-extern void nfs_complete_unlink(struct dentry *);
+extern int  nfs_async_unlink(struct inode *dir, struct dentry *dentry);
+extern void nfs_complete_unlink(struct dentry *dentry, struct inode *);
+extern void nfs_block_sillyrename(struct dentry *dentry);
+extern void nfs_unblock_sillyrename(struct dentry *dentry);
 
 /*
  * linux/fs/nfs/write.c
  */
+extern int  nfs_congestion_kb;
 extern int  nfs_writepage(struct page *page, struct writeback_control *wbc);
 extern int  nfs_writepages(struct address_space *, struct writeback_control *);
 extern int  nfs_flush_incompatible(struct file *file, struct page *page);
 extern int  nfs_updatepage(struct file *, struct page *, unsigned int, unsigned int);
 extern int nfs_writeback_done(struct rpc_task *, struct nfs_write_data *);
-extern void nfs_writedata_release(void *);
-extern int nfs_set_page_dirty(struct page *);
 
 /*
  * Try to write back everything synchronously (but check the
  * return value!)
  */
 extern long nfs_sync_mapping_wait(struct address_space *, struct writeback_control *, int);
-extern int nfs_sync_mapping_range(struct address_space *, loff_t, loff_t, int);
 extern int nfs_wb_all(struct inode *inode);
+extern int nfs_wb_nocommit(struct inode *inode);
 extern int nfs_wb_page(struct inode *inode, struct page* page);
-extern int nfs_wb_page_priority(struct inode *inode, struct page* page, int how);
+extern int nfs_wb_page_cancel(struct inode *inode, struct page* page);
 #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
-extern int  nfs_commit_inode(struct inode *, int);
-extern struct nfs_write_data *nfs_commit_alloc(void);
+extern struct nfs_write_data *nfs_commitdata_alloc(void);
 extern void nfs_commit_free(struct nfs_write_data *wdata);
-extern void nfs_commit_release(void *wdata);
-#else
-static inline int
-nfs_commit_inode(struct inode *inode, int how)
-{
-       return 0;
-}
 #endif
 
 static inline int
@@ -454,7 +497,8 @@ nfs_have_writebacks(struct inode *inode)
 /*
  * Allocate nfs_write_data structures
  */
-extern struct nfs_write_data *nfs_writedata_alloc(size_t len);
+extern struct nfs_write_data *nfs_writedata_alloc(unsigned int npages);
+extern void nfs_writedata_free(struct nfs_write_data *);
 
 /*
  * linux/fs/nfs/read.c
@@ -463,12 +507,14 @@ extern int  nfs_readpage(struct file *, struct page *);
 extern int  nfs_readpages(struct file *, struct address_space *,
                struct list_head *, unsigned);
 extern int  nfs_readpage_result(struct rpc_task *, struct nfs_read_data *);
-extern void nfs_readdata_release(void *data);
+extern int  nfs_readpage_async(struct nfs_open_context *, struct inode *,
+                              struct page *);
 
 /*
  * Allocate nfs_read_data structures
  */
-extern struct nfs_read_data *nfs_readdata_alloc(size_t len);
+extern struct nfs_read_data *nfs_readdata_alloc(unsigned int npages);
+extern void nfs_readdata_free(struct nfs_read_data *);
 
 /*
  * linux/fs/nfs3proc.c
@@ -493,23 +539,14 @@ static inline void nfs3_forget_cached_acls(struct inode *inode)
 }
 #endif /* CONFIG_NFS_V3_ACL */
 
-/*
- * linux/fs/mount_clnt.c
- * (Used only by nfsroot module)
- */
-extern int  nfsroot_mount(struct sockaddr_in *, char *, struct nfs_fh *,
-               int, int);
-
 /*
  * inline functions
  */
 
-static inline loff_t
-nfs_size_to_loff_t(__u64 size)
+static inline loff_t nfs_size_to_loff_t(__u64 size)
 {
-       loff_t maxsz = (((loff_t) ULONG_MAX) << PAGE_CACHE_SHIFT) + PAGE_CACHE_SIZE - 1;
-       if (size > maxsz)
-               return maxsz;
+       if (size > (__u64) OFFSET_MAX - 1)
+               return OFFSET_MAX - 1;
        return (loff_t) size;
 }
 
@@ -528,14 +565,7 @@ extern void * nfs_root_data(void);
 
 #define nfs_wait_event(clnt, wq, condition)                            \
 ({                                                                     \
-       int __retval = 0;                                               \
-       if (clnt->cl_intr) {                                            \
-               sigset_t oldmask;                                       \
-               rpc_clnt_sigmask(clnt, &oldmask);                       \
-               __retval = wait_event_interruptible(wq, condition);     \
-               rpc_clnt_sigunmask(clnt, &oldmask);                     \
-       } else                                                          \
-               wait_event(wq, condition);                              \
+       int __retval = wait_event_killable(wq, condition);              \
        __retval;                                                       \
 })
 
@@ -556,6 +586,8 @@ extern void * nfs_root_data(void);
 #define NFSDBG_ROOT            0x0080
 #define NFSDBG_CALLBACK                0x0100
 #define NFSDBG_CLIENT          0x0200
+#define NFSDBG_MOUNT           0x0400
+#define NFSDBG_FSCACHE         0x0800
 #define NFSDBG_ALL             0xFFFF
 
 #ifdef __KERNEL__