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>
21 struct list_head rq_plist; /* linked list of req's */
22 unsigned long rq_jiffies;
23 struct page *rq_page; /* page to be written */
26 struct list_head obdfs_super_list; /* list of all OBDFS superblocks */
31 #define EXT2_DIR_PAD 4
32 #define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
33 #define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
35 #define EXT2_NAME_LEN 255
37 struct ext2_dir_entry_2 {
38 __u32 inode; /* Inode number */
39 __u16 rec_len; /* Directory entry length */
40 __u8 name_len; /* Name length */
42 char name[EXT2_NAME_LEN]; /* File name */
45 int obdfs_check_dir_entry (const char * function, struct inode * dir,
46 struct ext2_dir_entry_2 * de, struct page * page,
47 unsigned long offset);
48 extern struct file_operations obdfs_dir_operations;
49 extern struct inode_operations obdfs_dir_inode_operations;
52 extern struct file_operations obdfs_file_operations;
53 extern struct inode_operations obdfs_file_inode_operations;
56 void obdfs_dequeue_pages(struct inode *inode);
57 int obdfs_flushd_init(void);
58 int obdfs_flushd_cleanup(void);
59 int obdfs_flush_reqs(struct list_head *inode_list, unsigned long check_time);
60 int obdfs_flush_dirty_pages(unsigned long check_time);
64 * Structure of the super block
68 struct ext2_super_block {
69 __u32 s_inodes_count; /* Inodes count */
70 __u32 s_blocks_count; /* Blocks count */
71 __u32 s_r_blocks_count; /* Reserved blocks count */
72 __u32 s_free_blocks_count; /* Free blocks count */
73 __u32 s_free_inodes_count; /* Free inodes count */
74 __u32 s_first_data_block; /* First Data Block */
75 __u32 s_log_block_size; /* Block size */
76 __s32 s_log_frag_size; /* Fragment size */
77 __u32 s_blocks_per_group; /* # Blocks per group */
78 __u32 s_frags_per_group; /* # Fragments per group */
79 __u32 s_inodes_per_group; /* # Inodes per group */
80 __u32 s_mtime; /* Mount time */
81 __u32 s_wtime; /* Write time */
82 __u16 s_mnt_count; /* Mount count */
83 __s16 s_max_mnt_count; /* Maximal mount count */
84 __u16 s_magic; /* Magic signature */
85 __u16 s_state; /* File system state */
86 __u16 s_errors; /* Behaviour when detecting errors */
87 __u16 s_minor_rev_level; /* minor revision level */
88 __u32 s_lastcheck; /* time of last check */
89 __u32 s_checkinterval; /* max. time between checks */
90 __u32 s_creator_os; /* OS */
91 __u32 s_rev_level; /* Revision level */
92 __u16 s_def_resuid; /* Default uid for reserved blocks */
93 __u16 s_def_resgid; /* Default gid for reserved blocks */
95 * These fields are for EXT2_DYNAMIC_REV superblocks only.
97 * Note: the difference between the compatible feature set and
98 * the incompatible feature set is that if there is a bit set
99 * in the incompatible feature set that the kernel doesn't
100 * know about, it should refuse to mount the filesystem.
102 * e2fsck's requirements are more strict; if it doesn't know
103 * about a feature in either the compatible or incompatible
104 * feature set, it must abort and not try to meddle with
105 * things it doesn't understand...
107 __u32 s_first_ino; /* First non-reserved inode */
108 __u16 s_inode_size; /* size of inode structure */
109 __u16 s_block_group_nr; /* block group # of this superblock */
110 __u32 s_feature_compat; /* compatible feature set */
111 __u32 s_feature_incompat; /* incompatible feature set */
112 __u32 s_feature_ro_compat; /* readonly-compatible feature set */
113 __u8 s_uuid[16]; /* 128-bit uuid for volume */
114 char s_volume_name[16]; /* volume name */
115 char s_last_mounted[64]; /* directory where last mounted */
116 __u32 s_algorithm_usage_bitmap; /* For compression */
118 * Performance hints. Directory preallocation should only
119 * happen if the EXT2_COMPAT_PREALLOC flag is on.
121 __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
122 __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
124 __u32 s_reserved[204]; /* Padding to the end of the block */
128 #define EXT2_SB(sb) (&((sb)->u.ext2_sb))
130 * Maximal count of links to a file
132 #define EXT2_LINK_MAX 32000
134 * Ext2 directory file types. Only the low 3 bits are used. The
135 * other bits are reserved for now.
137 #define EXT2_FT_UNKNOWN 0
138 #define EXT2_FT_REG_FILE 1
139 #define EXT2_FT_DIR 2
140 #define EXT2_FT_CHRDEV 3
141 #define EXT2_FT_BLKDEV 4
142 #define EXT2_FT_FIFO 5
143 #define EXT2_FT_SOCK 6
144 #define EXT2_FT_SYMLINK 7
146 #define EXT2_FT_MAX 8
148 #define EXT2_BTREE_FL 0x00001000 /* btree format dir */
149 #define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
150 #define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
151 #define EXT2_HAS_COMPAT_FEATURE(sb,mask) \
152 ( EXT2_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )
153 #define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
154 ( EXT2_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) )
157 struct dentry *obdfs_lookup(struct inode * dir, struct dentry *dentry);
158 int obdfs_create (struct inode * dir, struct dentry * dentry, int mode);
159 int obdfs_mkdir(struct inode *dir, struct dentry *dentry, int mode);
160 int obdfs_rmdir(struct inode *dir, struct dentry *dentry);
161 int obdfs_unlink(struct inode *dir, struct dentry *dentry);
162 int obdfs_mknod(struct inode *dir, struct dentry *dentry, int mode, int rdev);
163 int obdfs_symlink(struct inode *dir, struct dentry *dentry,
164 const char *symname);
165 int obdfs_link(struct dentry *old_dentry, struct inode *dir,
166 struct dentry *dentry);
167 int obdfs_rename(struct inode *old_dir, struct dentry *old_dentry,
168 struct inode *new_dir, struct dentry *new_dentry);
171 int obdfs_do_writepage(struct page *, int sync);
172 int obdfs_init_pgrqcache(void);
173 void obdfs_cleanup_pgrqcache(void);
174 inline void obdfs_pgrq_del(struct obdfs_pgrq *pgrq);
175 int obdfs_readpage(struct file *file, struct page *page);
176 int obdfs_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to);
177 int obdfs_commit_write(struct file *file, struct page *page, unsigned from, unsigned to);
178 int obdfs_writepage(struct page *page);
179 struct page *obdfs_getpage(struct inode *inode, unsigned long offset,
180 int create, int locked);
181 int obdfs_write_one_page(struct file *file, struct page *page,
182 unsigned long offset, unsigned long bytes,
184 int obdfs_do_vec_wr(struct inode **inodes, obd_count num_io, obd_count num_oa,
185 struct obdo **obdos, obd_count *oa_bufs,
186 struct page **pages, char **bufs, obd_size *counts,
187 obd_off *offsets, obd_flag *flags);
188 void obdfs_truncate(struct inode *inode);
191 extern long obdfs_cache_count;
192 extern long obdfs_mutex_start;
195 extern struct inode_operations obdfs_fast_symlink_inode_operations;
196 extern struct inode_operations obdfs_symlink_inode_operations;
199 void obdfs_sysctl_init(void);
200 void obdfs_sysctl_clean(void);
202 static inline struct obdfs_sb_info *obdfs_i2sbi(struct inode *inode)
204 return (struct obdfs_sb_info *) &(inode->i_sb->u.generic_sbp);
207 static inline struct list_head *obdfs_iplist(struct inode *inode)
209 struct obdfs_inode_info *info = obdfs_i2info(inode);
211 return &info->oi_pages;
214 static inline struct list_head *obdfs_islist(struct inode *inode)
216 struct obdfs_inode_info *info = obdfs_i2info(inode);
218 return &info->oi_inodes;
221 static inline struct list_head *obdfs_slist(struct inode *inode)
223 struct obdfs_sb_info *sbi = obdfs_i2sbi(inode);
225 return &sbi->osi_inodes;
228 #define obd_down(mutex) { \
229 /* CDEBUG(D_INFO, "get lock\n"); */ \
230 obdfs_mutex_start = jiffies; \
232 if (jiffies - obdfs_mutex_start) \
233 CDEBUG(D_CACHE, "waited on mutex %ld jiffies\n", \
234 jiffies - obdfs_mutex_start); \
237 #define obd_up(mutex) { \
239 if (jiffies - obdfs_mutex_start > 1) \
240 CDEBUG(D_CACHE, "held mutex for %ld jiffies\n", \
241 jiffies - obdfs_mutex_start); \
242 /* CDEBUG(D_INFO, "free lock\n"); */ \
245 /* We track if a page has been added to the OBD page cache by stting a
246 * flag on the page. We have chosen a bit that will hopefully not be
249 #define PG_obdcache 29
250 #define OBDAddCachePage(page) test_and_set_bit(PG_obdcache, &(page)->flags)
251 #define OBDClearCachePage(page) clear_bit(PG_obdcache, &(page)->flags)
253 static inline void obdfs_print_plist(struct inode *inode)
255 struct list_head *page_list = obdfs_iplist(inode);
256 struct list_head *tmp;
258 CDEBUG(D_INFO, "inode %ld: page", inode->i_ino);
259 /* obd_down(&obdfs_i2sbi(inode)->osi_list_mutex); */
260 if (list_empty(page_list)) {
261 CDEBUG(D_INFO, " list empty\n");
262 obd_up(&obdfs_i2sbi(inode)->osi_list_mutex);
267 while ( (tmp = tmp->next) != page_list) {
268 struct obdfs_pgrq *pgrq;
269 pgrq = list_entry(tmp, struct obdfs_pgrq, rq_plist);
270 CDEBUG(D_INFO, " %p", pgrq->rq_page);
272 CDEBUG(D_INFO, "\n");
273 /* obd_up(&obdfs_i2sbi(inode)->osi_list_mutex); */
275 #include <linux/obdo.h>