1 /* object based disk file system
3 * This code is issued under the GNU General Public License.
4 * See the file COPYING in this distribution
6 * Copyright (C), 1999, Stelias Computing Inc
14 #include <linux/obd_class.h>
15 #include <linux/obdo.h>
16 #include <linux/list.h>
17 #include <linux/lustre_net.h>
19 #define LL_SUPER_MAGIC 0x0BD00BD0;
21 struct ll_inode_info {
24 char lli_inline[OBD_INLINESZ];
28 struct list_head ll_list; /* list of supers */
29 struct obd_conn ll_conn;
30 struct super_block *ll_super;
31 // struct obd_device *ll_obd;
32 //struct obd_ops *ll_ops;
33 ino_t ll_rootino; /* number of root inode */
34 int ll_minor; /* minor of /dev/obdX */
35 struct list_head ll_inodes; /* list of dirty inodes */
36 unsigned long ll_cache_count;
37 struct semaphore ll_list_mutex;
38 struct lustre_peer ll_peer;
39 struct lustre_peer *ll_peer_ptr;
43 static inline struct ll_inode_info *ll_i2info(struct inode *inode)
45 return (struct ll_inode_info *)&(inode->u.generic_ip);
48 static inline int ll_has_inline(struct inode *inode)
50 return (ll_i2info(inode)->lli_flags & OBD_FL_INLINEDATA);
61 struct list_head rq_plist; /* linked list of req's */
62 unsigned long rq_jiffies;
63 struct page *rq_page; /* page to be written */
66 extern struct list_head ll_super_list; /* list of all LL superblocks */
71 #define EXT2_DIR_PAD 4
72 #define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
73 #define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
75 #define EXT2_NAME_LEN 255
77 int ll_check_dir_entry (const char * function, struct inode * dir,
78 struct ext2_dir_entry_2 * de, struct page * page,
79 unsigned long offset);
80 extern struct file_operations ll_dir_operations;
81 extern struct inode_operations ll_dir_inode_operations;
84 extern struct file_operations ll_file_operations;
85 extern struct inode_operations ll_file_inode_operations;
88 void ll_dequeue_pages(struct inode *inode);
89 int ll_flushd_init(void);
90 int ll_flushd_cleanup(void);
91 int ll_flush_reqs(struct list_head *inode_list, unsigned long check_time);
92 int ll_flush_dirty_pages(unsigned long check_time);
96 * Structure of the super block
100 #define EXT2_SB(sb) (&((sb)->u.ext2_sb))
102 * Maximal count of links to a file
104 #define EXT2_LINK_MAX 32000
106 * Ext2 directory file types. Only the low 3 bits are used. The
107 * other bits are reserved for now.
109 #define EXT2_FT_UNKNOWN 0
110 #define EXT2_FT_REG_FILE 1
111 #define EXT2_FT_DIR 2
112 #define EXT2_FT_CHRDEV 3
113 #define EXT2_FT_BLKDEV 4
114 #define EXT2_FT_FIFO 5
115 #define EXT2_FT_SOCK 6
116 #define EXT2_FT_SYMLINK 7
118 #define EXT2_FT_MAX 8
120 #define EXT2_BTREE_FL 0x00001000 /* btree format dir */
121 #define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
122 #define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
123 #define EXT2_HAS_COMPAT_FEATURE(sb,mask) \
124 ( EXT2_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )
125 #define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
126 ( EXT2_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) )
129 int ll_do_writepage(struct page *, int sync);
130 int ll_init_pgrqcache(void);
131 void ll_cleanup_pgrqcache(void);
132 inline void ll_pgrq_del(struct ll_pgrq *pgrq);
133 int ll_readpage(struct file *file, struct page *page);
134 int ll_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to);
135 int ll_commit_write(struct file *file, struct page *page, unsigned from, unsigned to);
136 int ll_writepage(struct page *page);
137 struct page *ll_getpage(struct inode *inode, unsigned long offset,
138 int create, int locked);
139 int ll_write_one_page(struct file *file, struct page *page,
140 unsigned long offset, unsigned long bytes,
142 int ll_do_vec_wr(struct inode **inodes, obd_count num_io, obd_count num_oa,
143 struct obdo **obdos, obd_count *oa_bufs,
144 struct page **pages, char **bufs, obd_size *counts,
145 obd_off *offsets, obd_flag *flags);
146 void ll_truncate(struct inode *inode);
149 extern long ll_cache_count;
150 extern long ll_mutex_start;
153 extern struct inode_operations ll_fast_symlink_inode_operations;
154 extern struct inode_operations ll_symlink_inode_operations;
157 void ll_sysctl_init(void);
158 void ll_sysctl_clean(void);
160 static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
162 return (struct ll_sb_info *) &(inode->i_sb->u.generic_sbp);
166 static inline struct list_head *ll_slist(struct inode *inode)
168 struct ll_sb_info *sbi = ll_i2sbi(inode);
170 return &sbi->ll_inodes;
173 static void inline ll_set_size (struct inode *inode, obd_size size)
175 inode->i_size = size;
176 inode->i_blocks = (inode->i_size + inode->i_sb->s_blocksize - 1) >>
177 inode->i_sb->s_blocksize_bits;
182 #define obd_down(mutex) { \
183 /* CDEBUG(D_INFO, "get lock\n"); */ \
184 ll_mutex_start = jiffies; \
186 if (jiffies - ll_mutex_start) \
187 CDEBUG(D_CACHE, "waited on mutex %ld jiffies\n", \
188 jiffies - ll_mutex_start); \
191 #define obd_up(mutex) { \
193 if (jiffies - ll_mutex_start > 1) \
194 CDEBUG(D_CACHE, "held mutex for %ld jiffies\n", \
195 jiffies - ll_mutex_start); \
196 /* CDEBUG(D_INFO, "free lock\n"); */ \
199 /* We track if a page has been added to the OBD page cache by stting a
200 * flag on the page. We have chosen a bit that will hopefully not be
203 #define PG_obdcache 29
204 #define OBDAddCachePage(page) test_and_set_bit(PG_obdcache, &(page)->flags)
205 #define OBDClearCachePage(page) clear_bit(PG_obdcache, &(page)->flags)