1 /* object based disk file system
3 * This software is licensed under the GPL. See the file COPYING in the
4 * top directory of this distribution for details.
6 * Copyright (C), 1999, Stelias Computing Inc
14 #include <linux/obd_class.h>
15 #include <linux/list.h>
18 void obdfs_read_inode(struct inode *inode);
21 int obdfs_flushd_init(void);
22 int obdfs_flushd_cleanup(void);
23 int obdfs_flush_reqs(struct list_head *inode_list, int check_time);
24 void obdfs_flush_dirty_pages(int check_time);
27 int obdfs_do_writepage(struct inode *, struct page *, int sync);
28 int obdfs_init_pgrqcache(void);
29 void obdfs_cleanup_pgrqcache(void);
30 int obdfs_readpage(struct dentry *dentry, struct page *page);
31 int obdfs_writepage(struct dentry *dentry, struct page *page);
32 struct page *obdfs_getpage(struct inode *inode, unsigned long offset,
33 int create, int locked);
34 int obdfs_write_one_page(struct file *file, struct page *page,
35 unsigned long offset, unsigned long bytes,
37 void obdfs_dequeue_reqs(struct inode *inode);
40 struct dentry *obdfs_lookup(struct inode * dir, struct dentry *dentry);
41 int obdfs_create (struct inode * dir, struct dentry * dentry, int mode);
42 int obdfs_mkdir(struct inode *dir, struct dentry *dentry, int mode);
43 int obdfs_rmdir(struct inode *dir, struct dentry *dentry);
44 int obdfs_unlink(struct inode *dir, struct dentry *dentry);
45 int obdfs_mknod(struct inode *dir, struct dentry *dentry, int mode, int rdev);
46 int obdfs_symlink(struct inode *dir, struct dentry *dentry,
48 int obdfs_link(struct dentry *old_dentry, struct inode *dir,
49 struct dentry *dentry);
50 int obdfs_rename(struct inode *old_dir, struct dentry *old_dentry,
51 struct inode *new_dir, struct dentry *new_dentry);
54 int obdfs_check_dir_entry (const char * function, struct inode * dir,
55 struct ext2_dir_entry_2 * de, struct page * page,
56 unsigned long offset);
59 int obdfs_readlink (struct dentry *, char *, int);
60 struct dentry *obdfs_follow_link(struct dentry *, struct dentry *,
64 /* list of all OBDFS super blocks */
65 struct list_head obdfs_super_list;
68 struct list_head rq_plist; /* linked list of req's */
69 unsigned long rq_jiffies;
70 struct page *rq_page; /* page to be written */
74 inline void obdfs_pgrq_del(struct obdfs_pgrq *pgrq);
75 int obdfs_do_vec_wr(struct inode **inodes, obd_count num_io, obd_count num_oa,
76 struct obdo **obdos, obd_count *oa_bufs,
77 struct page **pages, char **bufs, obd_size *counts,
78 obd_off *offsets, obd_flag *flags);
81 struct obdfs_sb_info {
82 struct list_head osi_list; /* list of supers */
83 struct obd_conn osi_conn;
84 struct super_block *osi_super;
85 struct obd_device *osi_obd;
86 struct obd_ops *osi_ops;
87 ino_t osi_rootino; /* number of root inode */
88 int osi_minor; /* minor of /dev/obdX */
89 struct list_head osi_inodes; /* list of dirty inodes */
90 struct semaphore osi_list_mutex;
93 struct obdfs_inode_info {
95 struct list_head oi_inodes;
96 struct list_head oi_pages;
97 char oi_inline[OBD_INLINESZ];
100 static inline struct obdfs_inode_info *obdfs_i2info(struct inode *inode)
102 return (struct obdfs_inode_info *)&(inode->u.generic_ip);
105 static inline struct obdfs_sb_info *obdfs_i2sbi(struct inode *inode)
107 return (struct obdfs_sb_info *) &(inode->i_sb->u.generic_sbp);
110 static inline struct list_head *obdfs_iplist(struct inode *inode)
112 struct obdfs_inode_info *info = obdfs_i2info(inode);
114 return &info->oi_pages;
117 static inline struct list_head *obdfs_islist(struct inode *inode)
119 struct obdfs_inode_info *info = obdfs_i2info(inode);
121 return &info->oi_inodes;
124 static inline struct list_head *obdfs_slist(struct inode *inode)
126 struct obdfs_sb_info *sbi = obdfs_i2sbi(inode);
128 return &sbi->osi_inodes;
131 #define obd_down(mutex) {\
132 CDEBUG(D_INODE, "got lock at %s, %d\n", __FUNCTION__, __LINE__);\
136 #define obd_up(mutex) {\
138 CDEBUG(D_INODE, "free lock at %s, %d\n", __FUNCTION__, __LINE__);\
141 static inline void obdfs_print_plist(struct inode *inode)
143 struct list_head *page_list = obdfs_iplist(inode);
144 struct list_head *tmp;
146 CDEBUG(D_INODE, "inode %ld: page", inode->i_ino);
147 /* obd_down(&obdfs_i2sbi(inode)->osi_list_mutex); */
148 if (list_empty(page_list)) {
149 printk(" list empty\n");
150 obd_up(&obdfs_i2sbi(inode)->osi_list_mutex);
155 while ( (tmp = tmp->next) != page_list) {
156 struct obdfs_pgrq *pgrq;
157 pgrq = list_entry(tmp, struct obdfs_pgrq, rq_plist);
158 printk(" %p", pgrq->rq_page);
161 /* obd_up(&obdfs_i2sbi(inode)->osi_list_mutex); */
164 void obdfs_sysctl_init(void);
165 void obdfs_sysctl_clean(void);
167 extern struct file_operations obdfs_file_operations;
168 extern struct inode_operations obdfs_file_inode_operations;
169 extern struct inode_operations obdfs_dir_inode_operations;
170 extern struct inode_operations obdfs_symlink_inode_operations;
172 static inline int obdfs_has_inline(struct inode *inode)
174 return (obdfs_i2info(inode)->oi_flags & OBD_FL_INLINEDATA);
177 static void inline obdfs_from_inode(struct obdo *oa, struct inode *inode)
179 struct obdfs_inode_info *oinfo = obdfs_i2info(inode);
181 CDEBUG(D_INODE, "src inode %ld, dst obdo %ld valid 0x%08x\n",
182 inode->i_ino, (long)oa->o_id, oa->o_valid);
183 obdo_from_inode(oa, inode);
184 if (obdfs_has_inline(inode)) {
185 CDEBUG(D_INODE, "copying inline data from inode to obdo\n");
186 memcpy(oa->o_inline, oinfo->oi_inline, OBD_INLINESZ);
187 oa->o_obdflags |= OBD_FL_INLINEDATA;
188 oa->o_valid |= OBD_MD_FLINLINE;
190 } /* obdfs_from_inode */
192 static void inline obdfs_to_inode(struct inode *inode, struct obdo *oa)
194 struct obdfs_inode_info *oinfo = obdfs_i2info(inode);
196 CDEBUG(D_INODE, "src obdo %ld valid 0x%08x, dst inode %ld\n",
197 (long)oa->o_id, oa->o_valid, inode->i_ino);
198 obdo_to_inode(inode, oa);
200 if (obdo_has_inline(oa)) {
201 CDEBUG(D_INODE, "copying inline data from obdo to inode\n");
202 memcpy(oinfo->oi_inline, oa->o_inline, OBD_INLINESZ);
203 oinfo->oi_flags |= OBD_FL_INLINEDATA;
205 } /* obdfs_to_inode */
211 #warning "*** WARNING redefining OPS"
213 #define OPS(sb,op) ((struct obdfs_sb_info *)(& ## sb ## ->u.generic_sbp))->osi_ops->o_ ## op
214 #define IOPS(inode,op) ((struct obdfs_sb_info *)(& ## inode->i_sb ## ->u.generic_sbp))->osi_ops->o_ ## op
218 #warning "*** WARNING redefining ID"
220 #define ID(sb) (&((struct obdfs_sb_info *)( & ## sb ## ->u.generic_sbp))->osi_conn)
221 #define IID(inode) (&((struct obdfs_sb_info *)( & ## inode->i_sb ## ->u.generic_sbp))->osi_conn)
224 #define OBDFS_SUPER_MAGIC 0x4711