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 struct list_head rq_plist; /* linked list of req's */
19 unsigned long rq_jiffies;
20 struct page *rq_page; /* page to be written */
23 struct list_head obdfs_super_list; /* list of all OBDFS superblocks */
25 struct obdfs_sb_info {
26 struct list_head osi_list; /* list of supers */
27 struct obd_conn osi_conn;
28 struct super_block *osi_super;
29 struct obd_device *osi_obd;
30 struct obd_ops *osi_ops;
31 ino_t osi_rootino; /* number of root inode */
32 int osi_minor; /* minor of /dev/obdX */
33 struct list_head osi_inodes; /* list of dirty inodes */
34 struct semaphore osi_list_mutex;
37 struct obdfs_inode_info {
39 struct list_head oi_inodes;
40 struct list_head oi_pages;
41 char oi_inline[OBD_INLINESZ];
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 int obdfs_flushd_init(void);
57 int obdfs_flushd_cleanup(void);
58 int obdfs_flush_reqs(struct list_head *inode_list, int check_time);
59 void obdfs_flush_dirty_pages(int check_time);
62 struct dentry *obdfs_lookup(struct inode * dir, struct dentry *dentry);
63 int obdfs_create (struct inode * dir, struct dentry * dentry, int mode);
64 int obdfs_mkdir(struct inode *dir, struct dentry *dentry, int mode);
65 int obdfs_rmdir(struct inode *dir, struct dentry *dentry);
66 int obdfs_unlink(struct inode *dir, struct dentry *dentry);
67 int obdfs_mknod(struct inode *dir, struct dentry *dentry, int mode, int rdev);
68 int obdfs_symlink(struct inode *dir, struct dentry *dentry,
70 int obdfs_link(struct dentry *old_dentry, struct inode *dir,
71 struct dentry *dentry);
72 int obdfs_rename(struct inode *old_dir, struct dentry *old_dentry,
73 struct inode *new_dir, struct dentry *new_dentry);
76 int obdfs_do_writepage(struct inode *, struct page *, int sync);
77 int obdfs_init_pgrqcache(void);
78 void obdfs_cleanup_pgrqcache(void);
79 inline void obdfs_pgrq_del(struct obdfs_pgrq *pgrq);
80 int obdfs_readpage(struct dentry *dentry, struct page *page);
81 int obdfs_writepage(struct dentry *dentry, struct page *page);
82 struct page *obdfs_getpage(struct inode *inode, unsigned long offset,
83 int create, int locked);
84 int obdfs_write_one_page(struct file *file, struct page *page,
85 unsigned long offset, unsigned long bytes,
87 int obdfs_do_vec_wr(struct inode **inodes, obd_count num_io, obd_count num_oa,
88 struct obdo **obdos, obd_count *oa_bufs,
89 struct page **pages, char **bufs, obd_size *counts,
90 obd_off *offsets, obd_flag *flags);
95 extern struct inode_operations obdfs_symlink_inode_operations;
98 void obdfs_sysctl_init(void);
99 void obdfs_sysctl_clean(void);
102 static inline struct obdfs_inode_info *obdfs_i2info(struct inode *inode)
104 return (struct obdfs_inode_info *)&(inode->u.generic_ip);
107 static inline struct obdfs_sb_info *obdfs_i2sbi(struct inode *inode)
109 return (struct obdfs_sb_info *) &(inode->i_sb->u.generic_sbp);
112 static inline struct list_head *obdfs_iplist(struct inode *inode)
114 struct obdfs_inode_info *info = obdfs_i2info(inode);
116 return &info->oi_pages;
119 static inline struct list_head *obdfs_islist(struct inode *inode)
121 struct obdfs_inode_info *info = obdfs_i2info(inode);
123 return &info->oi_inodes;
126 static inline struct list_head *obdfs_slist(struct inode *inode)
128 struct obdfs_sb_info *sbi = obdfs_i2sbi(inode);
130 return &sbi->osi_inodes;
133 #define obd_down(mutex) {\
134 CDEBUG(D_INODE, "got lock at %s, %d\n", __FUNCTION__, __LINE__);\
138 #define obd_up(mutex) {\
140 CDEBUG(D_INODE, "free lock at %s, %d\n", __FUNCTION__, __LINE__);\
143 static inline void obdfs_print_plist(struct inode *inode)
145 struct list_head *page_list = obdfs_iplist(inode);
146 struct list_head *tmp;
148 CDEBUG(D_INODE, "inode %ld: page", inode->i_ino);
149 /* obd_down(&obdfs_i2sbi(inode)->osi_list_mutex); */
150 if (list_empty(page_list)) {
151 printk(" list empty\n");
152 obd_up(&obdfs_i2sbi(inode)->osi_list_mutex);
157 while ( (tmp = tmp->next) != page_list) {
158 struct obdfs_pgrq *pgrq;
159 pgrq = list_entry(tmp, struct obdfs_pgrq, rq_plist);
160 printk(" %p", pgrq->rq_page);
163 /* obd_up(&obdfs_i2sbi(inode)->osi_list_mutex); */
166 static inline int obdfs_has_inline(struct inode *inode)
168 return (obdfs_i2info(inode)->oi_flags & OBD_FL_INLINEDATA);
171 static void inline obdfs_from_inode(struct obdo *oa, struct inode *inode)
173 struct obdfs_inode_info *oinfo = obdfs_i2info(inode);
175 CDEBUG(D_INODE, "src inode %ld, dst obdo %ld valid 0x%08x\n",
176 inode->i_ino, (long)oa->o_id, oa->o_valid);
177 obdo_from_inode(oa, inode);
178 if (obdfs_has_inline(inode)) {
179 CDEBUG(D_INODE, "copying inline data from inode to obdo\n");
180 memcpy(oa->o_inline, oinfo->oi_inline, OBD_INLINESZ);
181 oa->o_obdflags |= OBD_FL_INLINEDATA;
182 oa->o_valid |= OBD_MD_FLINLINE;
184 } /* obdfs_from_inode */
186 static void inline obdfs_to_inode(struct inode *inode, struct obdo *oa)
188 struct obdfs_inode_info *oinfo = obdfs_i2info(inode);
190 CDEBUG(D_INODE, "src obdo %ld valid 0x%08x, dst inode %ld\n",
191 (long)oa->o_id, oa->o_valid, inode->i_ino);
192 obdo_to_inode(inode, oa);
194 if (obdo_has_inline(oa)) {
195 CDEBUG(D_INODE, "copying inline data from obdo to inode\n");
196 memcpy(oinfo->oi_inline, oa->o_inline, OBD_INLINESZ);
197 oinfo->oi_flags |= OBD_FL_INLINEDATA;
199 } /* obdfs_to_inode */
205 #warning "*** WARNING redefining OPS"
207 #define OPS(sb,op) ((struct obdfs_sb_info *)(& ## sb ## ->u.generic_sbp))->osi_ops->o_ ## op
208 #define IOPS(inode,op) ((struct obdfs_sb_info *)(& ## inode->i_sb ## ->u.generic_sbp))->osi_ops->o_ ## op
212 #warning "*** WARNING redefining ID"
214 #define ID(sb) (&((struct obdfs_sb_info *)( & ## sb ## ->u.generic_sbp))->osi_conn)
215 #define IID(inode) (&((struct obdfs_sb_info *)( & ## inode->i_sb ## ->u.generic_sbp))->osi_conn)
218 #define OBDFS_SUPER_MAGIC 0x4711