Whamcloud - gitweb
ba9541745082e407c70ee7e3f9a5f5489df29eac
[fs/lustre-release.git] / lustre / include / linux / lustre_light.h
1 /* object based disk file system
2  * 
3  * This code is issued under the GNU General Public License.
4  * See the file COPYING in this distribution
5  * 
6  * Copyright (C), 1999, Stelias Computing Inc
7  *
8  *
9  */
10
11
12 #ifndef _LL_H
13 #define _LL_H
14 #include <linux/obd_class.h>
15 #include <linux/obdo.h>
16 #include <linux/list.h>
17 #include <linux/lustre_net.h>
18
19 #define LL_SUPER_MAGIC 0x0BD00BD0;
20
21 #define LL_INLINESZ      60
22 struct ll_inode_info {
23         int              lli_flags;
24         __u64            lli_objid; 
25         char             lli_inline[LL_INLINESZ];
26 };
27
28 struct ll_sb_info {
29         struct list_head         ll_list;      /* list of supers */
30         struct obd_conn          ll_conn;
31         struct super_block      *ll_super;
32         //        struct obd_device       *ll_obd;
33         //struct obd_ops          *ll_ops;
34         ino_t                    ll_rootino;   /* number of root inode */
35         int                      ll_minor;     /* minor of /dev/obdX */
36         struct list_head         ll_inodes;    /* list of dirty inodes */
37         unsigned long            ll_cache_count;
38         struct semaphore         ll_list_mutex;
39         struct lustre_peer       ll_peer;
40         struct lustre_peer      *ll_peer_ptr;
41 };
42
43
44 static inline struct ll_inode_info *ll_i2info(struct inode *inode)
45 {
46         return (struct ll_inode_info *)&(inode->u.generic_ip);
47 }
48
49 static inline int ll_has_inline(struct inode *inode)
50 {
51         return (ll_i2info(inode)->lli_flags & OBD_FL_INLINEDATA);
52 }
53
54
55
56
57
58
59
60 /* super.c */ 
61 struct ll_pgrq {
62         struct list_head         rq_plist;      /* linked list of req's */
63         unsigned long            rq_jiffies;
64         struct page             *rq_page;       /* page to be written */
65 };
66
67 extern struct list_head ll_super_list;       /* list of all LL superblocks */
68
69
70
71 /* dir.c */
72 #define EXT2_DIR_PAD                    4
73 #define EXT2_DIR_ROUND                  (EXT2_DIR_PAD - 1)
74 #define EXT2_DIR_REC_LEN(name_len)      (((name_len) + 8 + EXT2_DIR_ROUND) & \
75                                          ~EXT2_DIR_ROUND)
76 #define EXT2_NAME_LEN 255
77
78 int ll_check_dir_entry (const char * function, struct inode * dir,
79                           struct ext2_dir_entry_2 * de, struct page * page,
80                           unsigned long offset);
81 extern struct file_operations ll_dir_operations;
82 extern struct inode_operations ll_dir_inode_operations;
83
84 /* file.c */
85 extern struct file_operations ll_file_operations;
86 extern struct inode_operations ll_file_inode_operations;
87
88 /* flush.c */
89 void ll_dequeue_pages(struct inode *inode);
90 int ll_flushd_init(void);
91 int ll_flushd_cleanup(void);
92 int ll_flush_reqs(struct list_head *inode_list, unsigned long check_time);
93 int ll_flush_dirty_pages(unsigned long check_time);
94
95 /* namei.c */
96 /*
97  * Structure of the super block
98  */
99
100
101 #define EXT2_SB(sb)     (&((sb)->u.ext2_sb))
102 /*
103  * Maximal count of links to a file
104  */
105 #define EXT2_LINK_MAX           32000
106 /*
107  * Ext2 directory file types.  Only the low 3 bits are used.  The
108  * other bits are reserved for now.
109  */
110 #define EXT2_FT_UNKNOWN         0
111 #define EXT2_FT_REG_FILE        1
112 #define EXT2_FT_DIR             2
113 #define EXT2_FT_CHRDEV          3
114 #define EXT2_FT_BLKDEV          4
115 #define EXT2_FT_FIFO            5
116 #define EXT2_FT_SOCK            6
117 #define EXT2_FT_SYMLINK         7
118
119 #define EXT2_FT_MAX             8
120
121 #define EXT2_BTREE_FL                   0x00001000 /* btree format dir */
122 #define EXT2_RESERVED_FL                0x80000000 /* reserved for ext2 lib */
123 #define EXT2_FEATURE_INCOMPAT_FILETYPE          0x0002
124 #define EXT2_HAS_COMPAT_FEATURE(sb,mask)                        \
125         ( EXT2_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )
126 #define EXT2_HAS_INCOMPAT_FEATURE(sb,mask)                      \
127         ( EXT2_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) )
128
129 /* rw.c */
130 int ll_do_writepage(struct page *, int sync);
131 int ll_init_pgrqcache(void);
132 void ll_cleanup_pgrqcache(void);
133 inline void ll_pgrq_del(struct ll_pgrq *pgrq);
134 int ll_readpage(struct file *file, struct page *page);
135 int ll_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to);
136 int ll_commit_write(struct file *file, struct page *page, unsigned from, unsigned to);
137 int ll_writepage(struct page *page);
138 struct page *ll_getpage(struct inode *inode, unsigned long offset,
139                            int create, int locked);
140 int ll_write_one_page(struct file *file, struct page *page,
141                          unsigned long offset, unsigned long bytes,
142                          const char * buf);
143 int ll_do_vec_wr(struct inode **inodes, obd_count num_io, obd_count num_oa,
144                     struct obdo **obdos, obd_count *oa_bufs,
145                     struct page **pages, char **bufs, obd_size *counts,
146                     obd_off *offsets, obd_flag *flags);
147 void ll_truncate(struct inode *inode);
148
149 /* super.c */
150 extern long ll_cache_count;
151 extern long ll_mutex_start;
152
153 /* symlink.c */
154 extern struct inode_operations ll_fast_symlink_inode_operations;
155 extern struct inode_operations ll_symlink_inode_operations;
156
157 /* sysctl.c */
158 void ll_sysctl_init(void);
159 void ll_sysctl_clean(void);
160
161 static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
162 {
163         return (struct ll_sb_info *) &(inode->i_sb->u.generic_sbp);
164 }
165
166
167 static inline struct list_head *ll_slist(struct inode *inode) 
168 {
169         struct ll_sb_info *sbi = ll_i2sbi(inode);
170
171         return &sbi->ll_inodes;
172 }
173
174 static void inline ll_set_size (struct inode *inode, obd_size size)
175 {  
176        inode->i_size = size;
177        inode->i_blocks = (inode->i_size + inode->i_sb->s_blocksize - 1) >>
178                inode->i_sb->s_blocksize_bits;
179 } /* ll_set_size */
180
181
182
183 #define obd_down(mutex) {                                               \
184         /* CDEBUG(D_INFO, "get lock\n"); */                             \
185         ll_mutex_start = jiffies;                                    \
186         down(mutex);                                                    \
187         if (jiffies - ll_mutex_start)                                \
188                 CDEBUG(D_CACHE, "waited on mutex %ld jiffies\n",        \
189                        jiffies - ll_mutex_start);                    \
190 }
191
192 #define obd_up(mutex) {                                                 \
193         up(mutex);                                                      \
194         if (jiffies - ll_mutex_start > 1)                            \
195                 CDEBUG(D_CACHE, "held mutex for %ld jiffies\n",         \
196                        jiffies - ll_mutex_start);                    \
197         /* CDEBUG(D_INFO, "free lock\n"); */                            \
198 }
199
200 /* We track if a page has been added to the OBD page cache by stting a
201  * flag on the page.  We have chosen a bit that will hopefully not be
202  * used for a while.
203  */
204 #define PG_obdcache 29
205 #define OBDAddCachePage(page)   test_and_set_bit(PG_obdcache, &(page)->flags)
206 #define OBDClearCachePage(page) clear_bit(PG_obdcache, &(page)->flags)
207
208 #endif
209