NFS: Stop sillyname renames and unmounts from racing
[safe/jmp/linux-2.6] / include / linux / nfs_fs_sb.h
1 #ifndef _NFS_FS_SB
2 #define _NFS_FS_SB
3
4 #include <linux/list.h>
5 #include <linux/backing-dev.h>
6 #include <linux/wait.h>
7
8 #include <asm/atomic.h>
9
10 struct nfs_iostats;
11
12 /*
13  * The nfs_client identifies our client state to the server.
14  */
15 struct nfs_client {
16         atomic_t                cl_count;
17         int                     cl_cons_state;  /* current construction state (-ve: init error) */
18 #define NFS_CS_READY            0               /* ready to be used */
19 #define NFS_CS_INITING          1               /* busy initialising */
20         int                     cl_nfsversion;  /* NFS protocol version */
21         unsigned long           cl_res_state;   /* NFS resources state */
22 #define NFS_CS_CALLBACK         1               /* - callback started */
23 #define NFS_CS_IDMAP            2               /* - idmap started */
24 #define NFS_CS_RENEWD           3               /* - renewd started */
25         struct sockaddr_in      cl_addr;        /* server identifier */
26         char *                  cl_hostname;    /* hostname of server */
27         struct list_head        cl_share_link;  /* link in global client list */
28         struct list_head        cl_superblocks; /* List of nfs_server structs */
29
30         struct rpc_clnt *       cl_rpcclient;
31         const struct nfs_rpc_ops *rpc_ops;      /* NFS protocol vector */
32         unsigned long           retrans_timeo;  /* retransmit timeout */
33         unsigned int            retrans_count;  /* number of retransmit tries */
34
35 #ifdef CONFIG_NFS_V4
36         u64                     cl_clientid;    /* constant */
37         nfs4_verifier           cl_confirm;
38         unsigned long           cl_state;
39
40         struct rb_root          cl_openowner_id;
41         struct rb_root          cl_lockowner_id;
42
43         /*
44          * The following rwsem ensures exclusive access to the server
45          * while we recover the state following a lease expiration.
46          */
47         struct rw_semaphore     cl_sem;
48
49         struct list_head        cl_delegations;
50         struct rb_root          cl_state_owners;
51         spinlock_t              cl_lock;
52
53         unsigned long           cl_lease_time;
54         unsigned long           cl_last_renewal;
55         struct delayed_work     cl_renewd;
56
57         struct rpc_wait_queue   cl_rpcwaitq;
58
59         /* used for the setclientid verifier */
60         struct timespec         cl_boot_time;
61
62         /* idmapper */
63         struct idmap *          cl_idmap;
64
65         /* Our own IP address, as a null-terminated string.
66          * This is used to generate the clientid, and the callback address.
67          */
68         char                    cl_ipaddr[16];
69         unsigned char           cl_id_uniquifier;
70 #endif
71 };
72
73 /*
74  * NFS client parameters stored in the superblock.
75  */
76 struct nfs_server {
77         struct nfs_client *     nfs_client;     /* shared client and NFS4 state */
78         struct list_head        client_link;    /* List of other nfs_server structs
79                                                  * that share the same client
80                                                  */
81         struct list_head        master_link;    /* link in master servers list */
82         struct rpc_clnt *       client;         /* RPC client handle */
83         struct rpc_clnt *       client_acl;     /* ACL RPC client handle */
84         struct nfs_iostats *    io_stats;       /* I/O statistics */
85         struct backing_dev_info backing_dev_info;
86         atomic_long_t           writeback;      /* number of writeback pages */
87         int                     flags;          /* various flags */
88         unsigned int            caps;           /* server capabilities */
89         unsigned int            rsize;          /* read size */
90         unsigned int            rpages;         /* read size (in pages) */
91         unsigned int            wsize;          /* write size */
92         unsigned int            wpages;         /* write size (in pages) */
93         unsigned int            wtmult;         /* server disk block size */
94         unsigned int            dtsize;         /* readdir size */
95         unsigned int            bsize;          /* server block size */
96         unsigned int            acregmin;       /* attr cache timeouts */
97         unsigned int            acregmax;
98         unsigned int            acdirmin;
99         unsigned int            acdirmax;
100         unsigned int            namelen;
101
102         struct nfs_fsid         fsid;
103         __u64                   maxfilesize;    /* maximum file size */
104         unsigned long           mount_time;     /* when this fs was mounted */
105         dev_t                   s_dev;          /* superblock dev numbers */
106
107 #ifdef CONFIG_NFS_V4
108         u32                     attr_bitmask[2];/* V4 bitmask representing the set
109                                                    of attributes supported on this
110                                                    filesystem */
111         u32                     acl_bitmask;    /* V4 bitmask representing the ACEs
112                                                    that are supported on this
113                                                    filesystem */
114 #endif
115         void (*destroy)(struct nfs_server *);
116
117         atomic_t active; /* Keep trace of any activity to this server */
118         wait_queue_head_t active_wq;  /* Wait for any activity to stop  */
119 };
120
121 /* Server capabilities */
122 #define NFS_CAP_READDIRPLUS     (1U << 0)
123 #define NFS_CAP_HARDLINKS       (1U << 1)
124 #define NFS_CAP_SYMLINKS        (1U << 2)
125 #define NFS_CAP_ACLS            (1U << 3)
126 #define NFS_CAP_ATOMIC_OPEN     (1U << 4)
127
128 #endif