Whamcloud - gitweb
Need to replace the nfs-utils-lustre that was installed with CMD2.
[fs/lustre-release.git] / lustre / include / linux / lustre_lite.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * lustre lite cluster file system
5  *
6  * This code is issued under the GNU General Public License.
7  * See the file COPYING in this distribution
8  *
9  * Copyright (C) 2002 Cluster File Systems, Inc. <info@clusterfs.com>
10  */
11
12
13
14 #ifndef _LL_H
15 #define _LL_H
16
17 #ifdef __KERNEL__
18
19 #include <linux/version.h>
20
21 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
22 #include <asm/statfs.h>
23 #endif
24
25 #include <linux/fs.h>
26 #include <linux/dcache.h>
27 #include <linux/jbd.h>
28 #include <linux/ext3_fs.h>
29 #include <linux/proc_fs.h>
30
31 #include <linux/obd_class.h>
32 #include <linux/lustre_net.h>
33 #include <linux/lustre_mds.h>
34 #include <linux/lustre_ha.h>
35
36 #include <linux/rbtree.h>
37 #include <linux/lustre_compat25.h>
38 #include <linux/pagemap.h>
39 #include <linux/namei.h>
40
41
42 /* forward declarations */
43 struct remote_acl;
44
45 /* careful, this is easy to screw up */
46 #define PAGE_CACHE_MAXBYTES ((__u64)(~0UL) << PAGE_CACHE_SHIFT)
47
48 #define LL_IT2STR(it) ((it) ? ldlm_it2str((it)->it_op) : "0")
49
50 static inline struct lookup_intent *ll_nd2it(struct nameidata *nd)
51 {
52 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
53         return &nd->intent.open;
54 #else
55         return nd->intent;
56 #endif
57 }
58
59 struct ll_dentry_data {
60         int                      lld_cwd_count;
61         int                      lld_mnt_count;
62         struct obd_client_handle lld_cwd_och;
63         struct obd_client_handle lld_mnt_och;
64 };
65
66 #define ll_d2d(de) ((struct ll_dentry_data*) de->d_fsdata)
67
68 extern struct file_operations ll_pgcache_seq_fops;
69
70 #define LLI_INODE_MAGIC                 0x111d0de5
71 #define LLI_INODE_DEAD                  0xdeadd00d
72 #define LLI_F_HAVE_OST_SIZE_LOCK        0
73 #define LLI_F_HAVE_MDS_SIZE_LOCK        1
74 #define LLI_F_PREFER_EXTENDED_SIZE      2
75 #define LLI_F_DIRTY_HANDLE              3
76                                                    
77 struct ll_inode_info {
78         int                     lli_size_pid;
79         int                     lli_inode_magic;
80         struct lov_stripe_md   *lli_smd;
81         struct mea             *lli_mea;
82         struct lustre_id        lli_id;    /* full lustre_id */
83         char                   *lli_symlink_name;
84         struct semaphore        lli_open_sem;
85         struct semaphore        lli_size_sem;
86         __u64                   lli_maxbytes;
87         __u64                   lli_io_epoch;
88         __u64                   lli_audit_mask;
89         unsigned long           lli_flags;
90
91         /* this lock protects s_d_w and p_w_ll */
92         spinlock_t              lli_lock;
93         int                     lli_send_done_writing;
94         
95         int                     lli_snap_index;
96         
97         struct list_head        lli_pending_write_llaps;
98
99         struct list_head        lli_close_item;
100
101         struct file_operations *ll_save_ifop;
102         struct file_operations *ll_save_ffop;
103         struct file_operations *ll_save_wfop;
104         struct file_operations *ll_save_wrfop;
105 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
106         struct inode            lli_vfs_inode;
107 #endif
108         struct semaphore        lli_och_sem; /* Protects access to och pointers
109                                                 and their usage counters */
110         /* We need all three because every inode may be opened in different
111            modes */
112         struct obd_client_handle *lli_mds_read_och;
113         __u64                   lli_open_fd_read_count;
114         struct obd_client_handle *lli_mds_write_och;
115         __u64                   lli_open_fd_write_count;
116         struct obd_client_handle *lli_mds_exec_och;
117         __u64                   lli_open_fd_exec_count;
118         struct posix_acl       *lli_posix_acl;
119         struct remote_acl      *lli_remote_acl;
120
121         struct lustre_key      *lli_key_info;
122
123         struct list_head        lli_capas;
124
125         wait_queue_head_t       lli_dirty_wait;
126 };
127
128 // FIXME: replace the name of this with LL_I to conform to kernel stuff
129 // static inline struct ll_inode_info *LL_I(struct inode *inode)
130 static inline struct ll_inode_info *ll_i2info(struct inode *inode)
131 {
132 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
133         return container_of(inode, struct ll_inode_info, lli_vfs_inode);
134 #else
135         return (struct ll_inode_info *)&(inode->u.generic_ip);
136 #endif
137 }
138
139 #define LLI_HAVE_FLSIZE(inode)  \
140         test_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &ll_i2info(inode)->lli_flags)
141 #define LLI_DIRTY_HANDLE(inode)  \
142         test_bit(LLI_F_DIRTY_HANDLE, &ll_i2info(inode)->lli_flags)
143
144 /* lprocfs.c */
145 enum {
146          LPROC_LL_DIRTY_HITS = 0,
147          LPROC_LL_DIRTY_MISSES,
148          LPROC_LL_WB_WRITEPAGE,
149          LPROC_LL_WB_PRESSURE,
150          LPROC_LL_WB_OK,
151          LPROC_LL_WB_FAIL,
152          LPROC_LL_READ_BYTES,
153          LPROC_LL_WRITE_BYTES,
154          LPROC_LL_BRW_READ,
155          LPROC_LL_BRW_WRITE,
156          LPROC_LL_IOCTL,
157          LPROC_LL_OPEN,
158          LPROC_LL_RELEASE,
159          LPROC_LL_MAP,
160          LPROC_LL_LLSEEK,
161          LPROC_LL_FSYNC,
162          LPROC_LL_SETATTR,
163          LPROC_LL_TRUNC,
164
165 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
166          LPROC_LL_GETATTR,
167 #else
168          LPROC_LL_REVALIDATE,
169 #endif
170          LPROC_LL_STAFS,
171          LPROC_LL_ALLOC_INODE,
172
173          LPROC_LL_DIRECT_READ,
174          LPROC_LL_DIRECT_WRITE,
175          LPROC_LL_SETXATTR,
176          LPROC_LL_GETXATTR,
177          LPROC_LL_FILE_OPCODES,
178 };
179
180 struct lustre_intent_data {
181         int     it_disposition;
182         int     it_status;
183         __u64   it_lock_handle;
184         void    *it_data;
185         int     it_lock_mode;
186         int     it_int_flags;
187         void    *it_key;
188         int     it_key_size;
189 };
190 #define LUSTRE_IT(it) ((struct lustre_intent_data *)((it)->d.fs_data))
191
192 #else
193 #include <linux/lustre_idl.h>
194 #endif /* __KERNEL__ */
195
196 #define LLAP_FROM_COOKIE(c)                                                    \
197         (LASSERT(((struct ll_async_page *)(c))->llap_magic == LLAP_MAGIC),     \
198          (struct ll_async_page *)(c))
199
200 #include <lustre/lustre_user.h>
201 #include <linux/lustre_sec.h>
202
203 #endif