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 unsigned long osi_cache_count;
35 struct semaphore osi_list_mutex;
38 struct obdfs_inode_info {
40 struct list_head oi_inodes;
41 struct list_head oi_pages;
42 char oi_inline[OBD_INLINESZ];
46 int obdfs_check_dir_entry (const char * function, struct inode * dir,
47 struct ext2_dir_entry_2 * de, struct page * page,
48 unsigned long offset);
49 extern struct file_operations obdfs_dir_operations;
50 extern struct inode_operations obdfs_dir_inode_operations;
53 extern struct file_operations obdfs_file_operations;
54 extern struct inode_operations obdfs_file_inode_operations;
57 void obdfs_dequeue_pages(struct inode *inode);
58 int obdfs_flushd_init(void);
59 int obdfs_flushd_cleanup(void);
60 int obdfs_flush_reqs(struct list_head *inode_list, unsigned long check_time);
61 int obdfs_flush_dirty_pages(unsigned long check_time);
64 struct dentry *obdfs_lookup(struct inode * dir, struct dentry *dentry);
65 int obdfs_create (struct inode * dir, struct dentry * dentry, int mode);
66 int obdfs_mkdir(struct inode *dir, struct dentry *dentry, int mode);
67 int obdfs_rmdir(struct inode *dir, struct dentry *dentry);
68 int obdfs_unlink(struct inode *dir, struct dentry *dentry);
69 int obdfs_mknod(struct inode *dir, struct dentry *dentry, int mode, int rdev);
70 int obdfs_symlink(struct inode *dir, struct dentry *dentry,
72 int obdfs_link(struct dentry *old_dentry, struct inode *dir,
73 struct dentry *dentry);
74 int obdfs_rename(struct inode *old_dir, struct dentry *old_dentry,
75 struct inode *new_dir, struct dentry *new_dentry);
78 int obdfs_do_writepage(struct inode *, struct page *, int sync);
79 int obdfs_init_pgrqcache(void);
80 void obdfs_cleanup_pgrqcache(void);
81 inline void obdfs_pgrq_del(struct obdfs_pgrq *pgrq);
82 int obdfs_readpage(struct dentry *dentry, struct page *page);
83 int obdfs_writepage(struct dentry *dentry, struct page *page);
84 struct page *obdfs_getpage(struct inode *inode, unsigned long offset,
85 int create, int locked);
86 int obdfs_write_one_page(struct file *file, struct page *page,
87 unsigned long offset, unsigned long bytes,
89 int obdfs_do_vec_wr(struct inode **inodes, obd_count num_io, obd_count num_oa,
90 struct obdo **obdos, obd_count *oa_bufs,
91 struct page **pages, char **bufs, obd_size *counts,
92 obd_off *offsets, obd_flag *flags);
93 void obdfs_truncate(struct inode *inode);
96 extern long obdfs_cache_count;
99 extern struct inode_operations obdfs_fast_symlink_inode_operations;
100 extern struct inode_operations obdfs_symlink_inode_operations;
103 void obdfs_sysctl_init(void);
104 void obdfs_sysctl_clean(void);
107 static inline struct obdfs_inode_info *obdfs_i2info(struct inode *inode)
109 return (struct obdfs_inode_info *)&(inode->u.generic_ip);
112 static inline struct obdfs_sb_info *obdfs_i2sbi(struct inode *inode)
114 return (struct obdfs_sb_info *) &(inode->i_sb->u.generic_sbp);
117 static inline struct list_head *obdfs_iplist(struct inode *inode)
119 struct obdfs_inode_info *info = obdfs_i2info(inode);
121 return &info->oi_pages;
124 static inline struct list_head *obdfs_islist(struct inode *inode)
126 struct obdfs_inode_info *info = obdfs_i2info(inode);
128 return &info->oi_inodes;
131 static inline struct list_head *obdfs_slist(struct inode *inode)
133 struct obdfs_sb_info *sbi = obdfs_i2sbi(inode);
135 return &sbi->osi_inodes;
138 #define obd_down(mutex) {\
139 /* CDEBUG(D_INFO, "get lock\n"); */ \
143 #define obd_up(mutex) {\
145 /* CDEBUG(D_INFO, "free lock\n"); */ \
148 static inline void obdfs_print_plist(struct inode *inode)
150 struct list_head *page_list = obdfs_iplist(inode);
151 struct list_head *tmp;
153 CDEBUG(D_INFO, "inode %ld: page", inode->i_ino);
154 /* obd_down(&obdfs_i2sbi(inode)->osi_list_mutex); */
155 if (list_empty(page_list)) {
156 CDEBUG(D_INFO, " list empty\n");
157 obd_up(&obdfs_i2sbi(inode)->osi_list_mutex);
162 while ( (tmp = tmp->next) != page_list) {
163 struct obdfs_pgrq *pgrq;
164 pgrq = list_entry(tmp, struct obdfs_pgrq, rq_plist);
165 CDEBUG(D_INFO, " %p", pgrq->rq_page);
167 CDEBUG(D_INFO, "\n");
168 /* obd_up(&obdfs_i2sbi(inode)->osi_list_mutex); */
171 static inline int obdfs_has_inline(struct inode *inode)
173 return (obdfs_i2info(inode)->oi_flags & OBD_FL_INLINEDATA);
176 static void inline obdfs_from_inode(struct obdo *oa, struct inode *inode)
178 struct obdfs_inode_info *oinfo = obdfs_i2info(inode);
180 CDEBUG(D_INFO, "src inode %ld, dst obdo %ld valid 0x%08x\n",
181 inode->i_ino, (long)oa->o_id, oa->o_valid);
182 obdo_from_inode(oa, inode);
183 if (obdfs_has_inline(inode)) {
184 CDEBUG(D_INFO, "copying inline data from inode to obdo\n");
185 memcpy(oa->o_inline, oinfo->oi_inline, OBD_INLINESZ);
186 oa->o_obdflags |= OBD_FL_INLINEDATA;
187 oa->o_valid |= OBD_MD_FLINLINE;
189 } /* obdfs_from_inode */
191 static void inline obdfs_to_inode(struct inode *inode, struct obdo *oa)
193 struct obdfs_inode_info *oinfo = obdfs_i2info(inode);
195 CDEBUG(D_INFO, "src obdo %ld valid 0x%08x, dst inode %ld\n",
196 (long)oa->o_id, oa->o_valid, inode->i_ino);
197 obdo_to_inode(inode, oa);
199 if (obdo_has_inline(oa)) {
200 CDEBUG(D_INFO, "copying inline data from obdo to inode\n");
201 memcpy(oinfo->oi_inline, oa->o_inline, OBD_INLINESZ);
202 oinfo->oi_flags |= OBD_FL_INLINEDATA;
204 } /* obdfs_to_inode */
210 #warning "*** WARNING redefining OPS"
212 #define OPS(sb,op) ((struct obdfs_sb_info *)(& ## sb ## ->u.generic_sbp))->osi_ops->o_ ## op
213 #define IOPS(inode,op) ((struct obdfs_sb_info *)(& ## inode->i_sb ## ->u.generic_sbp))->osi_ops->o_ ## op
217 #warning "*** WARNING redefining ID"
219 #define ID(sb) (&((struct obdfs_sb_info *)( & ## sb ## ->u.generic_sbp))->osi_conn)
220 #define IID(inode) (&((struct obdfs_sb_info *)( & ## inode->i_sb ## ->u.generic_sbp))->osi_conn)
223 #define OBDFS_SUPER_MAGIC 0x4711